generator-reackt 0.3.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +3 -3
- package/.stylelintrc +155 -71
- package/generators/app/index.js +392 -309
- package/generators/component/index.js +51 -56
- package/generators/module/index.js +127 -117
- package/generators/util/fs.js +34 -22
- package/package.json +63 -66
- package/templates/app/.babelrc +1 -6
- package/templates/app/.eslintrc.js +46 -185
- package/templates/app/.stylelintrc +57 -146
- package/templates/app/jsconfig.json +1 -2
- package/templates/app/src/components/{App/App.js → App.js} +1 -1
- package/templates/app/src/index.js +7 -13
- package/templates/app/src/index.scss +0 -1
- package/templates/app/webpack.config.babel.js +2 -8
- package/templates/app/src/icons.js +0 -4
package/generators/app/index.js
CHANGED
|
@@ -1,309 +1,392 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
'
|
|
94
|
-
'
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
'
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
if (
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
this.
|
|
303
|
-
|
|
304
|
-
this
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
1
|
+
import { got } from 'got';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import gulpIf from 'gulp-if';
|
|
4
|
+
import jsonfile from 'jsonfile';
|
|
5
|
+
import { format } from 'date-fns';
|
|
6
|
+
import prettier from 'gulp-prettier';
|
|
7
|
+
import { createRequire } from 'module';
|
|
8
|
+
import stylelint from 'yeoman-stylelint';
|
|
9
|
+
import inquirerPrompt from 'inquirer-autocomplete-prompt';
|
|
10
|
+
import spdxIdentifiers from 'spdx-license-ids' assert { type: 'json' };
|
|
11
|
+
|
|
12
|
+
import fileSystem from '../util/fs.js';
|
|
13
|
+
|
|
14
|
+
spdxIdentifiers.push('SEE LICENSE IN LICENSE');
|
|
15
|
+
spdxIdentifiers.sort();
|
|
16
|
+
|
|
17
|
+
const { readFileSync } = jsonfile;
|
|
18
|
+
|
|
19
|
+
// we cannot use ES6 imports on this object, as it directly exports a class to
|
|
20
|
+
// module.exports - no default export nor a named export is present for us to use
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
22
|
+
const Generator = require('yeoman-generator');
|
|
23
|
+
|
|
24
|
+
const src = (...paths) => join('src', ...paths);
|
|
25
|
+
|
|
26
|
+
const styleFrameworks = [
|
|
27
|
+
{ value: null, name: 'None' },
|
|
28
|
+
{ value: 'bootstrap', name: 'Bootstrap' },
|
|
29
|
+
{ value: 'bulma', name: 'Bulma' },
|
|
30
|
+
{ value: 'foundation', name: 'Foundation' },
|
|
31
|
+
{ value: 'materialize', name: 'Materialize' },
|
|
32
|
+
{ value: 'uikit', name: 'UIKit' },
|
|
33
|
+
{ value: 'materialUi', name: 'Material-UI' }
|
|
34
|
+
];
|
|
35
|
+
const packages = {
|
|
36
|
+
fontAwesome: [
|
|
37
|
+
'@fortawesome/fontawesome-svg-core',
|
|
38
|
+
'@fortawesome/free-solid-svg-icons',
|
|
39
|
+
'@fortawesome/react-fontawesome'
|
|
40
|
+
],
|
|
41
|
+
bootstrap: ['bootstrap', 'react-bootstrap'],
|
|
42
|
+
uikit: ['uikit', 'uikit-react'],
|
|
43
|
+
foundation: ['foundation-sites'],
|
|
44
|
+
materialize: ['materialize-css'],
|
|
45
|
+
bulma: ['bulma'],
|
|
46
|
+
materialUi: ['@material-ui/core'],
|
|
47
|
+
lintStaged: ['husky', 'lint-staged'],
|
|
48
|
+
redux: ['redux', 'react-redux', 'redux-saga'],
|
|
49
|
+
reduxJest: ['redux-mock-store'],
|
|
50
|
+
core: [
|
|
51
|
+
'@babel/runtime-corejs3',
|
|
52
|
+
'core-js@3',
|
|
53
|
+
'normalize-scss',
|
|
54
|
+
'prop-types',
|
|
55
|
+
'react',
|
|
56
|
+
'react-dom',
|
|
57
|
+
'react-router-dom',
|
|
58
|
+
'reselect',
|
|
59
|
+
'classnames'
|
|
60
|
+
],
|
|
61
|
+
storybook: [
|
|
62
|
+
'@storybook/react',
|
|
63
|
+
'@storybook/builder-webpack5',
|
|
64
|
+
'@storybook/manager-webpack5'
|
|
65
|
+
],
|
|
66
|
+
esdoc: [
|
|
67
|
+
'esdoc',
|
|
68
|
+
'esdoc-ecmascript-proposal-plugin',
|
|
69
|
+
'esdoc-jsx-plugin',
|
|
70
|
+
'esdoc-standard-plugin',
|
|
71
|
+
'opener'
|
|
72
|
+
],
|
|
73
|
+
jest: [
|
|
74
|
+
'babel-jest',
|
|
75
|
+
'eslint-plugin-jest',
|
|
76
|
+
'jest',
|
|
77
|
+
'react-test-renderer',
|
|
78
|
+
'opener'
|
|
79
|
+
],
|
|
80
|
+
dev: [
|
|
81
|
+
'@babel/core',
|
|
82
|
+
'@babel/eslint-parser',
|
|
83
|
+
'@babel/plugin-transform-runtime',
|
|
84
|
+
'@babel/preset-env',
|
|
85
|
+
'@babel/preset-react',
|
|
86
|
+
'@babel/register',
|
|
87
|
+
'autoprefixer',
|
|
88
|
+
'babel-loader',
|
|
89
|
+
'clean-webpack-plugin',
|
|
90
|
+
'cross-env',
|
|
91
|
+
'css-loader',
|
|
92
|
+
'css-minimizer-webpack-plugin',
|
|
93
|
+
'eslint-config-prettier',
|
|
94
|
+
'eslint-import-resolver-webpack',
|
|
95
|
+
'eslint-plugin-import',
|
|
96
|
+
'eslint-plugin-jsx-a11y',
|
|
97
|
+
'eslint-plugin-prettier',
|
|
98
|
+
'eslint-plugin-react-hooks',
|
|
99
|
+
'eslint-plugin-react',
|
|
100
|
+
'eslint-webpack-plugin',
|
|
101
|
+
'eslint',
|
|
102
|
+
'html-loader',
|
|
103
|
+
'html-webpack-plugin',
|
|
104
|
+
'mini-css-extract-plugin',
|
|
105
|
+
'postcss-flexbugs-fixes',
|
|
106
|
+
'postcss-loader',
|
|
107
|
+
'postcss-scss',
|
|
108
|
+
'prettier',
|
|
109
|
+
'sass-loader',
|
|
110
|
+
'sass',
|
|
111
|
+
'style-loader',
|
|
112
|
+
'stylelint-config-recommended',
|
|
113
|
+
'stylelint-webpack-plugin',
|
|
114
|
+
'stylelint',
|
|
115
|
+
'terser-webpack-plugin',
|
|
116
|
+
'webpack-cli',
|
|
117
|
+
'webpack',
|
|
118
|
+
'webpack-dev-server'
|
|
119
|
+
]
|
|
120
|
+
};
|
|
121
|
+
const files = {
|
|
122
|
+
core: [
|
|
123
|
+
'.babelrc',
|
|
124
|
+
'.prettierrc',
|
|
125
|
+
'.stylelintrc',
|
|
126
|
+
'.editorconfig',
|
|
127
|
+
'jsconfig.json',
|
|
128
|
+
'.browserslistrc',
|
|
129
|
+
src('utils', 'index.js')
|
|
130
|
+
],
|
|
131
|
+
templated: [
|
|
132
|
+
'.eslintrc.js',
|
|
133
|
+
'package.json',
|
|
134
|
+
src('index.js'),
|
|
135
|
+
src('index.html'),
|
|
136
|
+
src('index.scss'),
|
|
137
|
+
'webpack.config.babel.js'
|
|
138
|
+
],
|
|
139
|
+
esdoc: ['.esdoc.json'],
|
|
140
|
+
jest: ['jest.config.js'],
|
|
141
|
+
lintStaged: ['.lintstagedrc']
|
|
142
|
+
};
|
|
143
|
+
const directories = {
|
|
144
|
+
redux: [src('reducers'), src('sagas'), src('selectors')],
|
|
145
|
+
core: [src('components'), src('utils')]
|
|
146
|
+
};
|
|
147
|
+
const scripts = {
|
|
148
|
+
esdoc: {
|
|
149
|
+
'build:documentation': 'esdoc',
|
|
150
|
+
'view:documentation': 'opener ./docs/index.html'
|
|
151
|
+
},
|
|
152
|
+
jest: {
|
|
153
|
+
test: 'jest',
|
|
154
|
+
'view:coverage': 'opener ./coverage/index.html'
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export default class extends Generator {
|
|
159
|
+
constructor(...args) {
|
|
160
|
+
super(...args);
|
|
161
|
+
|
|
162
|
+
this.env.adapter.promptModule.registerPrompt(
|
|
163
|
+
'autocomplete',
|
|
164
|
+
inquirerPrompt
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
this.answers = {};
|
|
168
|
+
this.fileSystem = fileSystem(this);
|
|
169
|
+
this.sourceRoot(this.fileSystem.resolve('templates', 'app'));
|
|
170
|
+
this.registerTransformStream(
|
|
171
|
+
gulpIf(
|
|
172
|
+
/\.js$/,
|
|
173
|
+
prettier(readFileSync(this.fileSystem.resolve('.prettierrc')))
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
this.registerTransformStream(
|
|
177
|
+
gulpIf(
|
|
178
|
+
/\.scss$/,
|
|
179
|
+
stylelint({
|
|
180
|
+
configFile: this.fileSystem.resolve('.stylelintrc')
|
|
181
|
+
})
|
|
182
|
+
)
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async prompting() {
|
|
187
|
+
const { name, email } = this.user.git;
|
|
188
|
+
|
|
189
|
+
this.answers = await this.prompt([
|
|
190
|
+
{
|
|
191
|
+
type: 'input',
|
|
192
|
+
name: 'package.name',
|
|
193
|
+
message: 'Package name',
|
|
194
|
+
default: this.appname.replace(/\s+/g, '-')
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
type: 'input',
|
|
198
|
+
name: 'package.version',
|
|
199
|
+
message: 'Package version',
|
|
200
|
+
default: '0.1.0'
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
type: 'autocomplete',
|
|
204
|
+
name: 'package.license',
|
|
205
|
+
message: 'Package license',
|
|
206
|
+
source: (_, input) => {
|
|
207
|
+
const pattern = new RegExp(`.*${input}.*`, 'i');
|
|
208
|
+
|
|
209
|
+
return new Promise((resolve) => {
|
|
210
|
+
resolve(
|
|
211
|
+
spdxIdentifiers.filter((identifier) => pattern.test(identifier))
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
type: 'input',
|
|
218
|
+
name: 'package.description',
|
|
219
|
+
message: 'Package description'
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
type: 'input',
|
|
223
|
+
name: 'author.name',
|
|
224
|
+
message: 'Author name',
|
|
225
|
+
default: name()
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
type: 'input',
|
|
229
|
+
name: 'author.email',
|
|
230
|
+
message: 'Author email address',
|
|
231
|
+
default: email()
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
type: 'list',
|
|
235
|
+
name: 'styleFramework',
|
|
236
|
+
message: 'What CSS framework would you like to use?',
|
|
237
|
+
choices: styleFrameworks
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
type: 'confirm',
|
|
241
|
+
name: 'flags.addLintStaged',
|
|
242
|
+
message: 'Force linting before commits?',
|
|
243
|
+
default: true
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
type: 'confirm',
|
|
247
|
+
name: 'flags.addFontAwesome',
|
|
248
|
+
message: 'Add Font Awesome?',
|
|
249
|
+
default: true
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
type: 'confirm',
|
|
253
|
+
name: 'flags.addRedux',
|
|
254
|
+
message: 'Add Redux?',
|
|
255
|
+
default: true
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
type: 'confirm',
|
|
259
|
+
name: 'flags.addJest',
|
|
260
|
+
message: 'Add Jest?',
|
|
261
|
+
default: true
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
type: 'confirm',
|
|
265
|
+
name: 'flags.addStorybook',
|
|
266
|
+
message: 'Add Storybook?',
|
|
267
|
+
default: false
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
type: 'confirm',
|
|
271
|
+
name: 'flags.addESDoc',
|
|
272
|
+
message: 'Add ESDoc?',
|
|
273
|
+
default: false
|
|
274
|
+
}
|
|
275
|
+
]);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async writing() {
|
|
279
|
+
const {
|
|
280
|
+
flags,
|
|
281
|
+
package: { license },
|
|
282
|
+
author: { name, email }
|
|
283
|
+
} = this.answers;
|
|
284
|
+
|
|
285
|
+
let licenseText = 'Place your license here.\n';
|
|
286
|
+
|
|
287
|
+
if (license !== 'SEE LICENSE IN LICENSE') {
|
|
288
|
+
this.log(`Downloading ${license} license from spdx/license-list-data...`);
|
|
289
|
+
const { body: rawLicense } = await got(
|
|
290
|
+
`https://raw.githubusercontent.com/spdx/license-list-data/master/text/${license}.txt`
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
licenseText = rawLicense
|
|
294
|
+
.replace('<year>', format(new Date(), 'yyyy'))
|
|
295
|
+
.replace('<copyright holders>', `${name} <${email}>`);
|
|
296
|
+
}
|
|
297
|
+
this.fileSystem.createFile('LICENSE', licenseText);
|
|
298
|
+
|
|
299
|
+
// copy files and directories
|
|
300
|
+
files.core.forEach(this.fileSystem.copy);
|
|
301
|
+
files.templated.forEach(this.fileSystem.copyTemplateInPlace);
|
|
302
|
+
directories.core.forEach(this.fileSystem.copyDirectory);
|
|
303
|
+
|
|
304
|
+
// this is a workaround for npm not packaging up .gitignore files
|
|
305
|
+
this.fileSystem.copyTo('gitignore', '.gitignore');
|
|
306
|
+
|
|
307
|
+
if (flags.addRedux) {
|
|
308
|
+
directories.redux.forEach(this.fileSystem.copyDirectory);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (flags.addJest) {
|
|
312
|
+
files.jest.forEach(this.fileSystem.copy);
|
|
313
|
+
this.fs.append(this.destinationPath('.gitignore'), 'coverage/');
|
|
314
|
+
this.fs.extendJSON(this.destinationPath('package.json'), {
|
|
315
|
+
scripts: {
|
|
316
|
+
...scripts.jest
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (flags.addESDoc) {
|
|
322
|
+
files.esdoc.forEach(this.fileSystem.copy);
|
|
323
|
+
this.fs.append(this.destinationPath('.gitignore'), 'docs/');
|
|
324
|
+
this.fs.extendJSON(this.destinationPath('package.json'), {
|
|
325
|
+
scripts: {
|
|
326
|
+
...scripts.esdoc
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (flags.addLintStaged) {
|
|
332
|
+
files.lintStaged.forEach(this.fileSystem.copy);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
install() {
|
|
337
|
+
const main = [];
|
|
338
|
+
const dev = [];
|
|
339
|
+
const { flags, styleFramework } = this.answers;
|
|
340
|
+
|
|
341
|
+
this.log('Building a list of packages to install');
|
|
342
|
+
|
|
343
|
+
main.push.apply(main, packages.core);
|
|
344
|
+
dev.push.apply(dev, packages.dev);
|
|
345
|
+
|
|
346
|
+
if (styleFramework !== null) {
|
|
347
|
+
main.push.apply(main, packages[styleFramework]);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (flags.addLintStaged) {
|
|
351
|
+
dev.push.apply(dev, packages.lintStaged);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (flags.addFontAwesome) {
|
|
355
|
+
main.push.apply(main, packages.fontAwesome);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (flags.addRedux) {
|
|
359
|
+
main.push.apply(main, packages.redux);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (flags.addJest) {
|
|
363
|
+
dev.push.apply(dev, packages.jest);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (flags.addRedux && flags.addJest) {
|
|
367
|
+
dev.push.apply(dev, packages.reduxJest);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (flags.addStorybook) {
|
|
371
|
+
dev.push.apply(dev, packages.storybook);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (flags.addESDoc) {
|
|
375
|
+
main.push.apply(main, packages.esdoc);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
this.log(
|
|
379
|
+
`Getting ready to install ${main.length} dependencies and ${dev.length} dev dependencies.`
|
|
380
|
+
);
|
|
381
|
+
this.log(`Dependencies: ${main.join(' ')}
|
|
382
|
+
Dev dependencies: ${dev.join(' ')}`);
|
|
383
|
+
this.npmInstall(main, { save: true });
|
|
384
|
+
this.npmInstall(dev, { 'save-dev': true });
|
|
385
|
+
this.spawnCommandSync('git', ['init']);
|
|
386
|
+
this.spawnCommandSync('npx', ['husky', 'init']);
|
|
387
|
+
this.spawnCommandSync('bash', [
|
|
388
|
+
'-c',
|
|
389
|
+
'echo "npx lint-staged" > .husky/pre-commit'
|
|
390
|
+
]);
|
|
391
|
+
}
|
|
392
|
+
}
|