File tree Expand file tree Collapse file tree 5 files changed +52
-11
lines changed Expand file tree Collapse file tree 5 files changed +52
-11
lines changed Original file line number Diff line number Diff line change @@ -314,7 +314,7 @@ module.exports = class Creator {
314
314
type : 'checkbox' ,
315
315
message : 'Check the features needed for your project:' ,
316
316
choices : [ ] ,
317
- pageSize : 8
317
+ pageSize : 10
318
318
}
319
319
return {
320
320
presetPrompt,
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ test('should pass', async () => {
9
9
const expectedPrompts = [
10
10
{
11
11
message : 'features' ,
12
- check : [ ]
12
+ check : [ 0 ]
13
13
}
14
14
]
15
15
@@ -27,7 +27,36 @@ test('should pass', async () => {
27
27
)
28
28
} )
29
29
30
- test ( 'should not include the plugin if ts is also present' , async ( ) => {
30
+ test ( 'with TS' , async ( ) => {
31
+ const mockTSModule = api => {
32
+ api . onPromptComplete ( answers => {
33
+ answers . useTsWithBabel = true
34
+ answers . features . push ( 'ts' )
35
+ } )
36
+ }
37
+
38
+ const expectedPrompts = [
39
+ {
40
+ message : 'features' ,
41
+ check : [ ] // no need to check if "useTsWithBabel" is explicitly true
42
+ }
43
+ ]
44
+
45
+ const expectedOptions = {
46
+ plugins : {
47
+ '@vue/cli-plugin-babel' : { }
48
+ }
49
+ }
50
+
51
+ await assertPromptModule (
52
+ [ mockTSModule , moduleToTest ] ,
53
+ expectedPrompts ,
54
+ expectedOptions ,
55
+ { pluginsOnly : true }
56
+ )
57
+ } )
58
+
59
+ test ( 'with TS, no Babel' , async ( ) => {
31
60
const mockTSModule = api => {
32
61
api . onPromptComplete ( answers => {
33
62
answers . features . push ( 'ts' )
Original file line number Diff line number Diff line change 1
1
module . exports = cli => {
2
+ cli . injectFeature ( {
3
+ name : 'Babel' ,
4
+ value : 'babel' ,
5
+ short : 'Babel' ,
6
+ checked : true
7
+ } )
8
+
2
9
cli . onPromptComplete ( ( answers , options ) => {
3
- if (
4
- ! answers . features . includes ( 'ts' ) ||
5
- answers . useTsWithBabel ||
6
- answers . experimentalCompileTsWithBabel
7
- ) {
8
- options . plugins [ '@vue/cli-plugin-babel' ] = { }
10
+ if ( answers . features . includes ( 'ts' ) ) {
11
+ if ( ! answers . useTsWithBabel && ! answers . experimentalCompileTsWithBabel ) {
12
+ return
13
+ }
14
+ } else {
15
+ if ( ! answers . features . includes ( 'babel' ) ) {
16
+ return
17
+ }
9
18
}
19
+ options . plugins [ '@vue/cli-plugin-babel' ] = { }
10
20
} )
11
21
}
Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ module.exports = cli => {
5
5
cli . injectFeature ( {
6
6
name : 'Linter / Formatter' ,
7
7
value : 'linter' ,
8
- short : 'Linter'
8
+ short : 'Linter' ,
9
+ checked : true
9
10
} )
10
11
11
12
cli . injectPrompt ( {
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ module.exports = cli => {
26
26
name : 'useTsWithBabel' ,
27
27
when : answers => answers . features . includes ( 'ts' ) ,
28
28
type : 'confirm' ,
29
- message : 'Use Babel alongside TypeScript for auto-detected polyfills?'
29
+ message : 'Use Babel alongside TypeScript for auto-detected polyfills?' ,
30
+ default : answers => answers . features . includes ( 'babel' )
30
31
} )
31
32
}
32
33
You can’t perform that action at this time.
0 commit comments