Skip to content

Commit b777365

Browse files
committed
feat(init/define-prop): add edition options
1 parent 0617563 commit b777365

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/init/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export async function init(target: string) {
1111
const selectedMacros = (await checkbox({
1212
message: chalk.green(`Which vue macros do you want to use?`),
1313
choices: [
14-
...stableMacros.slice(-2),
1514
...officialMacros.slice(-1),
15+
...stableMacros.slice(-2),
1616
...experimentalMacros,
1717
],
1818
pageSize: 14,
@@ -39,11 +39,25 @@ export async function init(target: string) {
3939
{ value: '::' },
4040
{ value: '*' },
4141
],
42-
}) as any
42+
})
4343

4444
selectedMacros.shortVmodel = { prefix }
4545
}
4646

47+
if (selectedMacros.defineProp) {
48+
const edition = await select({
49+
message: chalk.green(
50+
`Which edition do you want to use?`,
51+
),
52+
choices: [
53+
{ name: 'kevinEdition', value: 'kevinEdition' },
54+
{ name: 'johnsonEdition', value: 'johnsonEdition' },
55+
],
56+
})
57+
58+
selectedMacros.defineProp = { edition }
59+
}
60+
4761
await rewriteConfig(selectedMacros, target)
4862
}
4963

src/init/tsconfig.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { TSConfig } from 'pkg-types'
22
import { readTSConfig, writeTSConfig } from 'pkg-types'
33
import { fs } from 'zx'
44
import type { VueMacros } from '../common'
5-
import { vueMacros } from '../common'
5+
import { camelize, vueMacros } from '../common'
66

77
export async function rewriteTsConfig(selectedMacros: VueMacros, target: string) {
88
const filename = `${target}/nuxt.config.ts`
@@ -28,9 +28,11 @@ export async function rewriteTsConfig(selectedMacros: VueMacros, target: string)
2828
const vueCompilerOptions = tsconfig.vueCompilerOptions ??= {}
2929
const plugins = vueCompilerOptions.plugins ??= []
3030
for (const [macro, options] of Object.entries(macros)) {
31-
if (macro === 'short-vmodel' && options !== true) {
31+
if (options !== true) {
3232
const vueMacros = vueCompilerOptions.vueMacros ??= {}
33-
vueMacros.shortVmodel = options
33+
vueMacros[camelize(macro)] = options.edition
34+
? { experimentalDefinePropProposal: options.edition }
35+
: options
3436
}
3537

3638
// prevent exportProps and exportExpose co-usage

0 commit comments

Comments
 (0)