|
15 | 15 | </div> |
16 | 16 | <div class="vp-code-group vp-doc" v-else> |
17 | 17 | <CodeGroup :groups="[ |
18 | | - { id: 'pkg-priv', label: '~/.cdsrc.json', lang: 'json', group, code: pkgStr, private: true }, |
19 | | - { id: 'pkg', label: 'package/.cdsrc.json', lang: 'json', group, code: pkgStr }, |
20 | | - { id: 'js', label: '.cdsrc.js', lang: 'js', group, code: jsStr }, |
21 | | - { id: 'yml', label: '.cdsrc.yaml', lang: 'yml', group, code: ymlStr }, |
| 18 | + { id: 'pkg-rc', label: 'package.json', lang: 'json', group, code: pkgStr }, |
| 19 | + { id: 'pkg-priv', label: '~/.cdsrc.json', lang: 'json', group, code: rcJsonStr, private: true }, |
| 20 | + { id: 'pkg', label: '.cdsrc.json', lang: 'json', group, code: rcJsonStr }, |
| 21 | + { id: 'js', label: '.cdsrc.js', lang: 'js', group, code: rcJsStr }, |
| 22 | + { id: 'yml', label: '.cdsrc.yaml', lang: 'yml', group, code: rcYmlStr }, |
22 | 23 | { id: 'env', label: '.env file', lang: 'properties', group, code: propStr }, |
23 | 24 | { id: 'shl', label: 'Linux/macOS Shells', lang: 'sh', group, code: 'export '+envStr, transient: true }, |
24 | 25 | { id: 'shp', label: 'Powershell', lang: 'powershell', group, code: '$Env:'+envStr, transient: true }, |
|
80 | 81 | FloatingVue.options.themes.cfgPopper = { $extend: 'dropdown' } |
81 | 82 |
|
82 | 83 | const slots = useSlots() |
83 | | - //@ts-expect-error |
84 | 84 | const slotVal = slots.default?.().at(0)?.children?.toString().trim() ?? 'error: provide <Config>your_key:value</Config>' |
85 | 85 |
|
86 | | - const [key, val] = slotVal.split(/\s*[:=]\s*/) |
| 86 | + const [key, val] = slotVal.split(/\s*[:=]\s*(.*)/) // split on first `:` or `=` |
87 | 87 | const label = labelProp || `${keyOnly ? key: slotVal}` |
88 | 88 |
|
89 | 89 | const cfgKey = ref() |
90 | 90 | const popperVisible = ref(false) |
91 | 91 | const group = ref() |
92 | 92 | const pkgStr = ref() |
93 | | - const jsStr = ref() |
94 | | - const ymlStr = ref() |
| 93 | + const rcJsonStr = ref() |
| 94 | + const rcJsStr = ref() |
| 95 | + const rcYmlStr = ref() |
95 | 96 | const propStr = ref() |
96 | 97 | const envStr = ref() |
97 | 98 | const javaAppyml = ref() |
|
116 | 117 | const pkg = toJson(key, jsonVal ?? value) |
117 | 118 |
|
118 | 119 | pkgStr.value = JSON.stringify(pkg, null, 2) |
119 | | - jsStr.value = 'module.exports = ' + pkgStr.value.replace(/"(\w*?)":/g, '$1:') |
| 120 | + rcJsonStr.value = JSON.stringify(pkg.cds??{}, null, 2) |
| 121 | + rcJsStr.value = 'module.exports = ' + rcJsonStr.value.replace(/"(\w*?)":/g, '$1:') |
| 122 | + rcYmlStr.value = yaml.stringify(pkg.cds) |
120 | 123 | propStr.value = `${key}=${jsonVal ? JSON.stringify(jsonVal) : value}` |
121 | 124 |
|
122 | 125 | let envKey = key.replaceAll('_', '__').replaceAll('.', '_') |
123 | 126 | if (/^[a-z_]+$/.test(envKey)) envKey = envKey.toUpperCase() // only uppercase if not camelCase |
124 | 127 | envStr.value = `${envKey}=${jsonVal ? JSON.stringify(jsonVal) : value}` |
125 | 128 |
|
126 | | - javaAppyml.value = ymlStr.value = yaml.stringify(pkg) |
| 129 | + javaAppyml.value = yaml.stringify(pkg) |
127 | 130 | javaEnvStr.value = `-D${propStr.value}` |
128 | 131 | }) |
129 | 132 |
|
|
0 commit comments