1
- const path = require ( 'path' ) ;
2
- const fs = require ( 'fs' ) ;
1
+ const path = require ( 'path' )
2
+ const fs = require ( 'fs' )
3
3
const {
4
4
sortDependencies,
5
5
installDependencies,
6
6
runLintFix,
7
- printMessage
7
+ printMessage,
8
8
} = require ( './utils' )
9
9
10
10
module . exports = {
11
11
helpers : {
12
- if_or : function ( v1 , v2 , options ) {
12
+ if_or : function ( v1 , v2 , options ) {
13
13
if ( v1 || v2 ) {
14
- return options . fn ( this ) ;
14
+ return options . fn ( this )
15
15
}
16
16
17
- return options . inverse ( this ) ;
18
- }
17
+ return options . inverse ( this )
18
+ } ,
19
19
} ,
20
20
prompts : {
21
21
name : {
22
22
type : 'string' ,
23
23
required : true ,
24
- message : 'Project name'
24
+ message : 'Project name' ,
25
25
} ,
26
26
description : {
27
27
type : 'string' ,
28
28
required : false ,
29
29
message : 'Project description' ,
30
- default : 'A Vue.js project'
30
+ default : 'A Vue.js project' ,
31
31
} ,
32
32
author : {
33
33
type : 'string' ,
34
- message : 'Author'
34
+ message : 'Author' ,
35
35
} ,
36
36
build : {
37
37
type : 'list' ,
@@ -40,22 +40,23 @@ module.exports = {
40
40
{
41
41
name : 'Runtime + Compiler: recommended for most users' ,
42
42
value : 'standalone' ,
43
- short : 'standalone'
43
+ short : 'standalone' ,
44
44
} ,
45
45
{
46
- name : 'Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere' ,
46
+ name :
47
+ 'Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere' ,
47
48
value : 'runtime' ,
48
- short : 'runtime'
49
- }
50
- ]
49
+ short : 'runtime' ,
50
+ } ,
51
+ ] ,
51
52
} ,
52
53
router : {
53
54
type : 'confirm' ,
54
- message : 'Install vue-router?'
55
+ message : 'Install vue-router?' ,
55
56
} ,
56
57
lint : {
57
58
type : 'confirm' ,
58
- message : 'Use ESLint to lint your code?'
59
+ message : 'Use ESLint to lint your code?' ,
59
60
} ,
60
61
lintConfig : {
61
62
when : 'lint' ,
@@ -65,23 +66,23 @@ module.exports = {
65
66
{
66
67
name : 'Standard (https://github.com/standard/standard)' ,
67
68
value : 'standard' ,
68
- short : 'Standard'
69
+ short : 'Standard' ,
69
70
} ,
70
71
{
71
72
name : 'Airbnb (https://github.com/airbnb/javascript)' ,
72
73
value : 'airbnb' ,
73
- short : 'Airbnb'
74
+ short : 'Airbnb' ,
74
75
} ,
75
76
{
76
77
name : 'none (configure it yourself)' ,
77
78
value : 'none' ,
78
- short : 'none'
79
- }
80
- ]
79
+ short : 'none' ,
80
+ } ,
81
+ ] ,
81
82
} ,
82
83
unit : {
83
84
type : 'confirm' ,
84
- message : 'Set up unit tests'
85
+ message : 'Set up unit tests' ,
85
86
} ,
86
87
runner : {
87
88
when : 'unit' ,
@@ -91,45 +92,46 @@ module.exports = {
91
92
{
92
93
name : 'Jest' ,
93
94
value : 'jest' ,
94
- short : 'jest'
95
+ short : 'jest' ,
95
96
} ,
96
97
{
97
98
name : 'Karma and Mocha' ,
98
99
value : 'karma' ,
99
- short : 'karma'
100
+ short : 'karma' ,
100
101
} ,
101
102
{
102
103
name : 'none (configure it yourself)' ,
103
104
value : 'noTest' ,
104
- short : 'noTest'
105
- }
106
- ]
105
+ short : 'noTest' ,
106
+ } ,
107
+ ] ,
107
108
} ,
108
109
e2e : {
109
110
type : 'confirm' ,
110
- message : 'Setup e2e tests with Nightwatch?'
111
+ message : 'Setup e2e tests with Nightwatch?' ,
111
112
} ,
112
113
autoInstall : {
113
114
type : 'list' ,
114
- message : 'Should we run `npm install` for you after the project has been created? (recommended)' ,
115
+ message :
116
+ 'Should we run `npm install` for you after the project has been created? (recommended)' ,
115
117
choices : [
116
118
{
117
119
name : 'Yes, use NPM' ,
118
120
value : 'npm' ,
119
- short : 'npm'
121
+ short : 'npm' ,
120
122
} ,
121
123
{
122
124
name : 'Yes, use Yarn' ,
123
125
value : 'yarn' ,
124
- short : 'yarn'
126
+ short : 'yarn' ,
125
127
} ,
126
128
{
127
129
name : 'No, I will handle that myself' ,
128
130
value : false ,
129
- short : 'no'
130
- }
131
- ]
132
- }
131
+ short : 'no' ,
132
+ } ,
133
+ ] ,
134
+ } ,
133
135
} ,
134
136
filters : {
135
137
'.eslintrc.js' : 'lint' ,
@@ -143,27 +145,28 @@ module.exports = {
143
145
'test/unit/specs/index.js' : "unit && runner === 'karma'" ,
144
146
'test/unit/setup.js' : "unit && runner === 'jest'" ,
145
147
'test/e2e/**/*' : 'e2e' ,
146
- 'src/router/**/*' : 'router'
148
+ 'src/router/**/*' : 'router' ,
147
149
} ,
148
- 'complete' : function ( data , { chalk } ) {
149
-
150
+ complete : function ( data , { chalk } ) {
150
151
const green = chalk . green
151
152
152
153
sortDependencies ( data , green )
153
154
154
155
const cwd = path . join ( process . cwd ( ) , data . inPlace ? '' : data . destDirName )
155
-
156
+
156
157
if ( data . autoInstall ) {
157
158
installDependencies ( cwd , data . autoInstall , green )
158
- . then ( ( ) => {
159
- return runLintFix ( cwd , data , green )
160
- } )
161
- . then ( ( ) => {
162
- printMessage ( data , green )
163
- } )
159
+ . then ( ( ) => {
160
+ return runLintFix ( cwd , data , green )
161
+ } )
162
+ . then ( ( ) => {
163
+ printMessage ( data , green )
164
+ } )
165
+ . catch ( e => {
166
+ console . log ( chalk . red ( 'Error:' ) , e )
167
+ } )
164
168
} else {
165
169
printMessage ( data , chalk )
166
170
}
167
-
168
- }
169
- } ;
171
+ } ,
172
+ }
0 commit comments