@p8ec/shared 1.3.1 → 1.3.2
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.
|
@@ -33,14 +33,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
33
33
|
*
|
|
34
34
|
* This tool is used to simplify the process of creating new P8 components.
|
|
35
35
|
*
|
|
36
|
-
* Usage:
|
|
37
|
-
* p8-shared [command] [options]
|
|
38
|
-
*
|
|
39
|
-
* Commands:
|
|
40
|
-
* init [--flavor=recommended]
|
|
41
|
-
* Initializes a new P8 component.
|
|
42
|
-
* Options:
|
|
43
|
-
* --flavor: The flavor of the component to create. Defaults to 'recommended'.
|
|
44
36
|
*/
|
|
45
37
|
const path = __importStar(require("path"));
|
|
46
38
|
const fs = __importStar(require("fs"));
|
|
@@ -55,25 +47,26 @@ if (args.length === 0) {
|
|
|
55
47
|
Usage: ${self} [command] [options]
|
|
56
48
|
|
|
57
49
|
Commands:
|
|
58
|
-
init [
|
|
50
|
+
init [cleanup]
|
|
59
51
|
Initializes a new P8 component.
|
|
60
52
|
Options:
|
|
61
|
-
|
|
53
|
+
cleanup: Removes redundant configurations from package.json.
|
|
62
54
|
`);
|
|
63
55
|
process.exit(1);
|
|
64
56
|
}
|
|
65
57
|
const initCleanup = (packageJson) => {
|
|
66
58
|
writeLn('Removing eslintConfig and prettier from package.json...');
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
59
|
+
const configBackup = {};
|
|
60
|
+
const configBackupFile = 'p8-package-backup.json';
|
|
61
|
+
const configBackupSections = ['eslintConfig', 'prettier', 'commitlint'];
|
|
62
|
+
configBackupSections.forEach((section) => {
|
|
63
|
+
if (packageJson[section]) {
|
|
64
|
+
writeLn(`Backing up ${section} to ${section}.${configBackupFile}...`);
|
|
65
|
+
configBackup[section] = packageJson[section];
|
|
66
|
+
delete packageJson[section];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
writeFile(`${configBackupFile}`, JSON.stringify(configBackup, null, 2));
|
|
77
70
|
writeFile('package.json', JSON.stringify(packageJson, null, 2));
|
|
78
71
|
};
|
|
79
72
|
/**
|
|
@@ -86,6 +79,8 @@ const init = (option) => {
|
|
|
86
79
|
copyAsset(`.eslintrc.${moduleType}`);
|
|
87
80
|
writeLn(`Creating .prettierrc.${moduleType}...`);
|
|
88
81
|
copyAsset(`.prettierrc.${moduleType}`);
|
|
82
|
+
writeLn(`Creating .commitlintrc.${moduleType}...`);
|
|
83
|
+
copyAsset(`.commitlintrc.${moduleType}`);
|
|
89
84
|
writeLn('Creating lefthook.yml...');
|
|
90
85
|
copyAsset('lefthook.yml');
|
|
91
86
|
if (option === null || option === void 0 ? void 0 : option.split(',').includes('cleanup')) {
|