@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.
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ extends: [
3
+ "@commitlint/config-conventional"
4
+ ]
5
+ }
@@ -0,0 +1,5 @@
1
+ export default {
2
+ extends: [
3
+ "@commitlint/config-conventional"
4
+ ]
5
+ }
@@ -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 [--flavor=recommended]
50
+ init [cleanup]
59
51
  Initializes a new P8 component.
60
52
  Options:
61
- --flavor: The flavor of the component to create. Defaults to 'recommended'.
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
- if (packageJson['eslintConfig']) {
68
- writeLn('Backing up eslintConfig to eslint.package.json.bak...');
69
- writeFile('eslint.package.json.bak', packageJson['eslintConfig']);
70
- delete packageJson['eslintConfig'];
71
- }
72
- if (packageJson['prettier']) {
73
- writeLn('Backing up prettier to prettier.package.json.bak...');
74
- writeFile('prettier.package.json.bak', packageJson['prettier']);
75
- delete packageJson['prettier'];
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')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@p8ec/shared",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "P(8) Global Shared Library",
5
5
  "license": "MIT",
6
6
  "repository": {