easy-soft-develop 1.0.2 → 2.0.82
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/bin/cli.js +96 -3
- package/package.json +32 -22
- package/src/cliCollection/check-all-package-version.js +5 -0
- package/src/cliCollection/clear-all-dependence.js +39 -0
- package/src/cliCollection/commit-refresh.js +12 -0
- package/src/cliCollection/create-assist-scripts.cli.js +19 -0
- package/src/cliCollection/create-lerna-project.js +9 -0
- package/src/cliCollection/create-project-with-template.js +61 -0
- package/src/cliCollection/sleep.js +9 -0
- package/src/cliCollection/update-all-package-version.js +5 -0
- package/src/cliCollection/update-package-from-package.js +149 -0
- package/src/index.js +30 -22
- package/src/project/initProject.js +258 -0
- package/src/templates/babel.config.template.js +21 -0
- package/src/templates/commitlint.config.template.js +124 -0
- package/src/templates/editor.template.js +36 -0
- package/src/templates/eslint.template.js +249 -0
- package/src/templates/git.template.js +67 -0
- package/src/templates/lint-staged.template.js +35 -0
- package/src/templates/package.template.js +190 -0
- package/src/templates/prettier.template.js +133 -0
- package/src/templates/stylelint.template.js +79 -0
- package/src/templates/template.config.js +8 -0
- package/src/tools/clean.js +50 -0
- package/src/tools/commit.refresh.js +40 -0
- package/src/tools/develop.file.js +443 -0
- package/src/tools/initial.environment.js +118 -0
- package/src/tools/meta.js +242 -0
- package/src/tools/package.install.global.develop.dependence.js +92 -0
- package/src/tools/package.script.js +75 -0
- package/src/tools/package.tools.js +33 -0
- package/src/{package.update.js → tools/package.update.js} +16 -11
- package/src/tools/prettier.file.js +11 -0
- package/src/tools/prettier.package.json.js +17 -0
- package/src/{sleep.js → tools/sleep.js} +6 -3
- package/src/clean.js +0 -45
- package/src/commit.refresh.js +0 -40
- package/src/develop.assist.js +0 -110
- package/src/init.env.js +0 -146
- package/src/package.init.global.dependence.dev.js +0 -29
- package/src/package.tools.js +0 -32
- package/src/shell.js +0 -9
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
const {
|
|
2
|
+
promptSuccess,
|
|
3
|
+
promptInfo,
|
|
4
|
+
promptError,
|
|
5
|
+
mkdirSync,
|
|
6
|
+
writeFileSync,
|
|
7
|
+
promptEmptyLine,
|
|
8
|
+
writeFileWithOptionsSync,
|
|
9
|
+
checkStringIsEmpty,
|
|
10
|
+
writeJsonFileSync,
|
|
11
|
+
} = require('./meta');
|
|
12
|
+
const { fileGlobalHeader } = require('../templates/template.config');
|
|
13
|
+
const {
|
|
14
|
+
contentFile: commitlintConfigContentFile,
|
|
15
|
+
} = require('../templates/commitlint.config.template');
|
|
16
|
+
const {
|
|
17
|
+
contentFile: babelConfigContentFile,
|
|
18
|
+
} = require('../templates/babel.config.template');
|
|
19
|
+
const {
|
|
20
|
+
contentFile: editorContentFile,
|
|
21
|
+
} = require('../templates/editor.template');
|
|
22
|
+
const {
|
|
23
|
+
contentFile: eslintContentFile,
|
|
24
|
+
ignoreFile: eslintIgnoreFile,
|
|
25
|
+
configFile: eslintConfigFile,
|
|
26
|
+
ruleFile: eslintRuleFile,
|
|
27
|
+
extendFile: eslintExtendFile,
|
|
28
|
+
parserFile: eslintParserFile,
|
|
29
|
+
pluginFile: eslintPluginFile,
|
|
30
|
+
} = require('../templates/eslint.template');
|
|
31
|
+
const {
|
|
32
|
+
attributeFile: gitAttributeFile,
|
|
33
|
+
ignoreFile: gitIgnoreFile,
|
|
34
|
+
} = require('../templates/git.template');
|
|
35
|
+
const {
|
|
36
|
+
contentFile: lintStagedContentFile,
|
|
37
|
+
} = require('../templates/lint-staged.template');
|
|
38
|
+
const {
|
|
39
|
+
globalChildPackageFile,
|
|
40
|
+
globalMainPackageFile,
|
|
41
|
+
customChildPackageFile,
|
|
42
|
+
customMainPackageFile,
|
|
43
|
+
} = require('../templates/package.template');
|
|
44
|
+
const {
|
|
45
|
+
ignoreFile: prettierIgnoreFile,
|
|
46
|
+
contentFile: prettierContentFile,
|
|
47
|
+
configFile: prettierConfigFile,
|
|
48
|
+
} = require('../templates/prettier.template');
|
|
49
|
+
const {
|
|
50
|
+
ignoreFile: stylelintIgnoreFile,
|
|
51
|
+
contentFile: stylelintContentFile,
|
|
52
|
+
configFile: stylelintConfigFile,
|
|
53
|
+
} = require('../templates/stylelint.template');
|
|
54
|
+
|
|
55
|
+
function createScriptFile(folderPath, fileName, content, coverFile = false) {
|
|
56
|
+
mkdirSync(folderPath);
|
|
57
|
+
|
|
58
|
+
const result = writeFileSync(`${folderPath}/${fileName}`, content, {
|
|
59
|
+
coverFile: !!coverFile,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (result) {
|
|
63
|
+
promptSuccess(`${folderPath}/${fileName} create success`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
promptEmptyLine();
|
|
67
|
+
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function createCommitlintConfigFile(successMessage = '') {
|
|
72
|
+
let result = writeFileWithOptionsSync(commitlintConfigContentFile);
|
|
73
|
+
|
|
74
|
+
if (result) {
|
|
75
|
+
if (!checkStringIsEmpty(successMessage)) {
|
|
76
|
+
promptInfo(successMessage);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function createBabelConfigFile(successMessage = '') {
|
|
82
|
+
let result = writeFileWithOptionsSync(babelConfigContentFile);
|
|
83
|
+
|
|
84
|
+
if (result) {
|
|
85
|
+
if (!checkStringIsEmpty(successMessage)) {
|
|
86
|
+
promptInfo(successMessage);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function createNcuConfigFile(successMessage = '') {
|
|
92
|
+
let result = writeJsonFileSync(`./.ncurc.json`, {}, { coverFile: false });
|
|
93
|
+
|
|
94
|
+
if (result) {
|
|
95
|
+
if (!checkStringIsEmpty(successMessage)) {
|
|
96
|
+
promptInfo(successMessage);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function createNpmConfigFile(successMessage = '') {
|
|
102
|
+
let result = writeFileSync(
|
|
103
|
+
`./.npmrc`,
|
|
104
|
+
`# npm config
|
|
105
|
+
auto-install-peers=true`,
|
|
106
|
+
{ coverFile: false },
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
if (result) {
|
|
110
|
+
if (!checkStringIsEmpty(successMessage)) {
|
|
111
|
+
promptInfo(successMessage);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function createAssistConfigScriptFile() {
|
|
117
|
+
const content = `${fileGlobalHeader}
|
|
118
|
+
const cleanCommand = '';
|
|
119
|
+
|
|
120
|
+
const cleanCollection = [];
|
|
121
|
+
|
|
122
|
+
const developDependencePackageCollection = [];
|
|
123
|
+
|
|
124
|
+
const updateSpecialPackageCollection = [];
|
|
125
|
+
|
|
126
|
+
module.exports = {
|
|
127
|
+
cleanCommand,
|
|
128
|
+
cleanCollection,
|
|
129
|
+
developDependencePackageCollection,
|
|
130
|
+
updateSpecialPackageCollection,
|
|
131
|
+
};
|
|
132
|
+
`;
|
|
133
|
+
|
|
134
|
+
return createScriptFile(
|
|
135
|
+
`./develop/assists/config`,
|
|
136
|
+
'index.js',
|
|
137
|
+
content,
|
|
138
|
+
false,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function createCleanScriptFile() {
|
|
143
|
+
const content = `${fileGlobalHeader}
|
|
144
|
+
const { clean } = require('easy-soft-develop');
|
|
145
|
+
|
|
146
|
+
const { cleanCommand, cleanCollection } = require('./config');
|
|
147
|
+
|
|
148
|
+
clean(cleanCommand, cleanCollection);
|
|
149
|
+
`;
|
|
150
|
+
|
|
151
|
+
return createScriptFile('./develop/assists', 'clean.js', content, true);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function createPackageCheckSpecialVersionScriptFile() {
|
|
155
|
+
const content = `${fileGlobalHeader}
|
|
156
|
+
const { updateSpecialPackageVersion } = require('easy-soft-develop');
|
|
157
|
+
|
|
158
|
+
const { updateSpecialPackageCollection } = require('./config');
|
|
159
|
+
|
|
160
|
+
updateSpecialPackageVersion(updateSpecialPackageCollection);
|
|
161
|
+
`;
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
createScriptFile(
|
|
165
|
+
'./develop/assists',
|
|
166
|
+
'package.update.special.version.js',
|
|
167
|
+
content,
|
|
168
|
+
true,
|
|
169
|
+
);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
promptError(error);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function createInstallGlobalDevDependenceScriptFile() {
|
|
176
|
+
const content = `${fileGlobalHeader}
|
|
177
|
+
const { installGlobalDevDependencePackages } = require('easy-soft-develop');
|
|
178
|
+
|
|
179
|
+
const { developDependencePackageCollection } = require('./config');
|
|
180
|
+
|
|
181
|
+
installGlobalDevDependencePackages(developDependencePackageCollection);
|
|
182
|
+
`;
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
createScriptFile(
|
|
186
|
+
'./develop/assists',
|
|
187
|
+
'install.global.develop.dependence.js',
|
|
188
|
+
content,
|
|
189
|
+
true,
|
|
190
|
+
);
|
|
191
|
+
} catch (error) {
|
|
192
|
+
promptError(error);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function createInitialEnvironmentScriptFiles() {
|
|
197
|
+
const content = `${fileGlobalHeader}
|
|
198
|
+
const { initialEnvironment } = require('easy-soft-develop');
|
|
199
|
+
|
|
200
|
+
const eslintFile = require('../config/eslint/template/content');
|
|
201
|
+
const eslintIgnoreFile = require('../config/eslint/template/ignore.content');
|
|
202
|
+
const prettierFile = require('../config/prettier/template/content');
|
|
203
|
+
const prettierIgnoreFile = require('../config/prettier/template/ignore.content');
|
|
204
|
+
const stylelintFile = require('../config/stylelint/template/content');
|
|
205
|
+
const editorFile = require('../config/editor/template/content');
|
|
206
|
+
const editorAttributesFile = require('../config/git/template/attributes.content');
|
|
207
|
+
const editorIgnoreFile = require('../config/git/template/ignore.content');
|
|
208
|
+
const lintStagedFile = require('../config/lint-staged/template/content');
|
|
209
|
+
const mainNecessaryPackageFile = require('../config/package/template/main.content');
|
|
210
|
+
const childrenNecessaryPackageFile = require('../config/package/template/children.content');
|
|
211
|
+
const mainCustomPackageFile = require('../config/package/custom/main.content');
|
|
212
|
+
const childrenCustomPackageFile = require('../config/package/custom/children.content');
|
|
213
|
+
|
|
214
|
+
const mainEslintFileContent = eslintFile.mainContent;
|
|
215
|
+
const packageEslintFileContent = eslintFile.packageContent;
|
|
216
|
+
|
|
217
|
+
const eslintIgnoreContent = eslintIgnoreFile.content;
|
|
218
|
+
|
|
219
|
+
const mainPrettierContent = prettierFile.mainContent;
|
|
220
|
+
const packagePrettierContent = prettierFile.packageContent;
|
|
221
|
+
|
|
222
|
+
const prettierIgnoreContent = prettierIgnoreFile.content;
|
|
223
|
+
|
|
224
|
+
const mainStylelintContent = stylelintFile.mainContent;
|
|
225
|
+
const packageStylelintContent = stylelintFile.packageContent;
|
|
226
|
+
|
|
227
|
+
const editorConfigContent = editorFile.content;
|
|
228
|
+
|
|
229
|
+
const gitAttributesContent = editorAttributesFile.content;
|
|
230
|
+
|
|
231
|
+
const gitIgnoreContent = editorIgnoreFile.content;
|
|
232
|
+
const lintStagedRcContent = lintStagedFile.content;
|
|
233
|
+
|
|
234
|
+
const mainFileContentList = [
|
|
235
|
+
{
|
|
236
|
+
name: '.eslintrc.js',
|
|
237
|
+
content: mainEslintFileContent,
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: '.prettierrc.js',
|
|
241
|
+
content: mainPrettierContent,
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: '.stylelintrc.js',
|
|
245
|
+
content: mainStylelintContent,
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: '.editorconfig',
|
|
249
|
+
content: editorConfigContent,
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: '.eslintignore',
|
|
253
|
+
content: eslintIgnoreContent,
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
name: '.prettierignore',
|
|
257
|
+
content: prettierIgnoreContent,
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: '.gitattributes',
|
|
261
|
+
content: gitAttributesContent,
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: '.gitignore',
|
|
265
|
+
content: gitIgnoreContent,
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: '.lintstagedrc',
|
|
269
|
+
content: lintStagedRcContent,
|
|
270
|
+
},
|
|
271
|
+
];
|
|
272
|
+
|
|
273
|
+
const packageFileContentList = [
|
|
274
|
+
{
|
|
275
|
+
name: '.eslintrc.js',
|
|
276
|
+
content: packageEslintFileContent,
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: '.prettierrc.js',
|
|
280
|
+
content: packagePrettierContent,
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: '.stylelintrc.js',
|
|
284
|
+
content: packageStylelintContent,
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
name: '.editorconfig',
|
|
288
|
+
content: editorConfigContent,
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
name: '.eslintignore',
|
|
292
|
+
content: eslintIgnoreContent,
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
name: '.prettierignore',
|
|
296
|
+
content: prettierIgnoreContent,
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: '.gitattributes',
|
|
300
|
+
content: gitAttributesContent,
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: '.gitignore',
|
|
304
|
+
content: gitIgnoreContent,
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
name: '.lintstagedrc',
|
|
308
|
+
content: lintStagedRcContent,
|
|
309
|
+
},
|
|
310
|
+
];
|
|
311
|
+
|
|
312
|
+
initialEnvironment({
|
|
313
|
+
mainFileContentList: mainFileContentList,
|
|
314
|
+
packageFileContentList: packageFileContentList,
|
|
315
|
+
mainScripts: {
|
|
316
|
+
...mainCustomPackageFile,
|
|
317
|
+
...mainNecessaryPackageFile,
|
|
318
|
+
},
|
|
319
|
+
childScripts: {
|
|
320
|
+
...childrenCustomPackageFile,
|
|
321
|
+
...childrenNecessaryPackageFile,
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
`;
|
|
325
|
+
|
|
326
|
+
try {
|
|
327
|
+
createScriptFile(
|
|
328
|
+
'./develop/assists',
|
|
329
|
+
'initial.environment.js',
|
|
330
|
+
content,
|
|
331
|
+
true,
|
|
332
|
+
);
|
|
333
|
+
} catch (error) {
|
|
334
|
+
promptError(error);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function createDevelopFiles(waitMessage = '', successMessage = '') {
|
|
339
|
+
if (!checkStringIsEmpty(waitMessage)) {
|
|
340
|
+
promptInfo(waitMessage);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
mkdirSync(`./develop`);
|
|
344
|
+
mkdirSync(`./develop/assists`);
|
|
345
|
+
mkdirSync(`./develop/config`);
|
|
346
|
+
|
|
347
|
+
writeFileWithOptionsSync(editorContentFile);
|
|
348
|
+
|
|
349
|
+
//#region eslint
|
|
350
|
+
|
|
351
|
+
writeFileWithOptionsSync(eslintContentFile);
|
|
352
|
+
|
|
353
|
+
writeFileWithOptionsSync(eslintIgnoreFile);
|
|
354
|
+
|
|
355
|
+
writeFileWithOptionsSync(eslintConfigFile);
|
|
356
|
+
|
|
357
|
+
writeFileWithOptionsSync(eslintRuleFile);
|
|
358
|
+
|
|
359
|
+
writeFileWithOptionsSync(eslintExtendFile);
|
|
360
|
+
|
|
361
|
+
writeFileWithOptionsSync(eslintParserFile);
|
|
362
|
+
|
|
363
|
+
writeFileWithOptionsSync(eslintPluginFile);
|
|
364
|
+
|
|
365
|
+
//#endregion
|
|
366
|
+
|
|
367
|
+
//#region git
|
|
368
|
+
|
|
369
|
+
writeFileWithOptionsSync(gitAttributeFile);
|
|
370
|
+
|
|
371
|
+
writeFileWithOptionsSync(gitIgnoreFile);
|
|
372
|
+
|
|
373
|
+
//#endregion
|
|
374
|
+
|
|
375
|
+
//#region lintStaged
|
|
376
|
+
|
|
377
|
+
writeFileWithOptionsSync(lintStagedContentFile);
|
|
378
|
+
|
|
379
|
+
//#endregion
|
|
380
|
+
|
|
381
|
+
//#region package.json
|
|
382
|
+
|
|
383
|
+
writeFileWithOptionsSync(globalChildPackageFile);
|
|
384
|
+
|
|
385
|
+
writeFileWithOptionsSync(globalMainPackageFile);
|
|
386
|
+
|
|
387
|
+
writeFileWithOptionsSync(customChildPackageFile);
|
|
388
|
+
|
|
389
|
+
writeFileWithOptionsSync(customMainPackageFile);
|
|
390
|
+
|
|
391
|
+
//#endregion
|
|
392
|
+
|
|
393
|
+
//#region prettier
|
|
394
|
+
|
|
395
|
+
writeFileWithOptionsSync(prettierIgnoreFile);
|
|
396
|
+
|
|
397
|
+
writeFileWithOptionsSync(prettierContentFile);
|
|
398
|
+
|
|
399
|
+
writeFileWithOptionsSync(prettierConfigFile);
|
|
400
|
+
|
|
401
|
+
//#endregion
|
|
402
|
+
|
|
403
|
+
//#region stylelint
|
|
404
|
+
|
|
405
|
+
writeFileWithOptionsSync(stylelintIgnoreFile);
|
|
406
|
+
|
|
407
|
+
writeFileWithOptionsSync(stylelintContentFile);
|
|
408
|
+
|
|
409
|
+
writeFileWithOptionsSync(stylelintConfigFile);
|
|
410
|
+
|
|
411
|
+
//#endregion
|
|
412
|
+
|
|
413
|
+
//#region assists
|
|
414
|
+
|
|
415
|
+
createAssistConfigScriptFile();
|
|
416
|
+
|
|
417
|
+
createCleanScriptFile();
|
|
418
|
+
|
|
419
|
+
createPackageCheckSpecialVersionScriptFile();
|
|
420
|
+
|
|
421
|
+
createInstallGlobalDevDependenceScriptFile();
|
|
422
|
+
|
|
423
|
+
createInitialEnvironmentScriptFiles();
|
|
424
|
+
|
|
425
|
+
//#endregion
|
|
426
|
+
|
|
427
|
+
if (!checkStringIsEmpty(successMessage)) {
|
|
428
|
+
promptInfo(successMessage);
|
|
429
|
+
promptEmptyLine();
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
module.exports = {
|
|
434
|
+
createCommitlintConfigFile,
|
|
435
|
+
createBabelConfigFile,
|
|
436
|
+
createNcuConfigFile,
|
|
437
|
+
createNpmConfigFile,
|
|
438
|
+
createCleanScriptFile,
|
|
439
|
+
createPackageCheckSpecialVersionScriptFile,
|
|
440
|
+
createInstallGlobalDevDependenceScriptFile,
|
|
441
|
+
createInitialEnvironmentScriptFiles,
|
|
442
|
+
createDevelopFiles,
|
|
443
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const {
|
|
2
|
+
promptSuccess,
|
|
3
|
+
writeFileSync,
|
|
4
|
+
assignObject,
|
|
5
|
+
readJsonFileSync,
|
|
6
|
+
writeJsonFileSync,
|
|
7
|
+
resolvePath,
|
|
8
|
+
promptEmptyLine,
|
|
9
|
+
} = require('./meta');
|
|
10
|
+
const { globalScript } = require('./package.script');
|
|
11
|
+
|
|
12
|
+
const { loopPackage } = require('./package.tools');
|
|
13
|
+
const { prettierAllPackageJson } = require('./prettier.package.json');
|
|
14
|
+
|
|
15
|
+
function createMainFile(fileWithContentCollection) {
|
|
16
|
+
if (!Array.isArray(fileWithContentCollection)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fileWithContentCollection.forEach((o) => {
|
|
21
|
+
const { name, content } = o;
|
|
22
|
+
|
|
23
|
+
writeFileSync(name, content);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const log = `main files [${fileWithContentCollection
|
|
27
|
+
.map((o) => {
|
|
28
|
+
const { name } = o;
|
|
29
|
+
return name;
|
|
30
|
+
})
|
|
31
|
+
.join()}] refresh success`;
|
|
32
|
+
|
|
33
|
+
promptSuccess(log);
|
|
34
|
+
promptEmptyLine();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function createPackageFile(fileWithContentCollection) {
|
|
38
|
+
loopPackage(({ absolutePath }) => {
|
|
39
|
+
const itemPath = absolutePath;
|
|
40
|
+
|
|
41
|
+
if (!Array.isArray(fileWithContentCollection)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fileWithContentCollection.forEach((o) => {
|
|
46
|
+
const { name, content } = o;
|
|
47
|
+
|
|
48
|
+
writeFileSync(`${itemPath}/${name}`, content);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const log = `package files [${fileWithContentCollection
|
|
53
|
+
.map((o) => {
|
|
54
|
+
const { name } = o;
|
|
55
|
+
return name;
|
|
56
|
+
})
|
|
57
|
+
.join()}] refresh success`;
|
|
58
|
+
|
|
59
|
+
promptSuccess(log);
|
|
60
|
+
promptEmptyLine();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function adjustMainPackageJson({ scripts }) {
|
|
64
|
+
const mainProjectPath = resolvePath(`./package.json`);
|
|
65
|
+
|
|
66
|
+
const packageJson = readJsonFileSync(mainProjectPath);
|
|
67
|
+
|
|
68
|
+
packageJson.scripts = assignObject(
|
|
69
|
+
{
|
|
70
|
+
'z:build:all': 'echo please supplement build all packages commend',
|
|
71
|
+
'z:publish:npm-all': 'echo please supplement publish to npm commend',
|
|
72
|
+
},
|
|
73
|
+
globalScript,
|
|
74
|
+
packageJson.scripts || {},
|
|
75
|
+
scripts,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
writeJsonFileSync(mainProjectPath, packageJson, { coverFile: true });
|
|
79
|
+
|
|
80
|
+
promptSuccess('adjust main package.json success');
|
|
81
|
+
promptEmptyLine();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function adjustChildrenPackageJson({ scripts }) {
|
|
85
|
+
loopPackage(({ absolutePath }) => {
|
|
86
|
+
const itemPath = absolutePath;
|
|
87
|
+
|
|
88
|
+
const childPackageJsonPath = `${itemPath}/package.json`;
|
|
89
|
+
|
|
90
|
+
const packageJson = readJsonFileSync(childPackageJsonPath);
|
|
91
|
+
|
|
92
|
+
packageJson.scripts = assignObject(packageJson.scripts || {}, scripts);
|
|
93
|
+
|
|
94
|
+
writeJsonFileSync(childPackageJsonPath, packageJson, { coverFile: true });
|
|
95
|
+
|
|
96
|
+
promptSuccess('adjust child package.json success');
|
|
97
|
+
promptEmptyLine();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function initialEnvironment({
|
|
102
|
+
mainFileContentList = [],
|
|
103
|
+
packageFileContentList = [],
|
|
104
|
+
mainScripts = {},
|
|
105
|
+
childScripts = {},
|
|
106
|
+
}) {
|
|
107
|
+
createMainFile(mainFileContentList || []);
|
|
108
|
+
|
|
109
|
+
createPackageFile(packageFileContentList || []);
|
|
110
|
+
|
|
111
|
+
adjustMainPackageJson({ scripts: mainScripts || {} });
|
|
112
|
+
|
|
113
|
+
adjustChildrenPackageJson({ scripts: childScripts || {} });
|
|
114
|
+
|
|
115
|
+
prettierAllPackageJson();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
module.exports = { initialEnvironment };
|