@p8ec/shared 2.3.0 → 2.4.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.
- package/dist/assets/lefthook.yml +2 -2
- package/dist/cjs/bin/p8-shared-cli.js +42 -7
- package/dist/cjs/bin/utils/prompt.js +1 -1
- package/dist/cjs/bin/utils/yesno.js +1 -1
- package/dist/cjs/eslintConfigRecommended.js +2 -35
- package/dist/esm/eslintConfigRecommended.js +2 -2
- package/dist/types/prettierConfigRecommended.d.ts +2 -1
- package/package.json +8 -9
package/dist/assets/lefthook.yml
CHANGED
|
@@ -8,8 +8,8 @@ pre-commit:
|
|
|
8
8
|
git:
|
|
9
9
|
run: |
|
|
10
10
|
if [[ $(git rev-parse --abbrev-ref HEAD) =~ ^(main|master|release)$ ]]; then
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
echo "Direct commits to main, master, and release branches are not allowed."
|
|
12
|
+
exit 1
|
|
13
13
|
fi
|
|
14
14
|
|
|
15
15
|
### Commit message hook ###
|
|
@@ -115,6 +115,8 @@ const init = (option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
115
115
|
copyAsset(`eslint.config.${moduleType}`);
|
|
116
116
|
writeLn(`Creating prettier.config.${moduleType}...`);
|
|
117
117
|
copyAsset(`prettier.config.${moduleType}`);
|
|
118
|
+
packageJson.scripts['npm:reset'] = 'rm -rf ./**/node_modules && rm -rf ./**/package-lock.json && npm install';
|
|
119
|
+
packageJson.scripts['npm:audit'] = 'npm audit --audit-level=moderate';
|
|
118
120
|
const lefthook = yield (0, yesno_1.default)({
|
|
119
121
|
question: 'Do you want to use commitlint/lefthook? [y]n',
|
|
120
122
|
defaultValue: true,
|
|
@@ -130,10 +132,31 @@ const init = (option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
130
132
|
const lefthookInstall = 'lefthook install';
|
|
131
133
|
packageJson.scripts.postinstall = lefthookInstall;
|
|
132
134
|
const npmInstall = 'npm install --save-dev @commitlint/{config-conventional,cli} commitlint lefthook';
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
const pnpmInstall = 'pnpm install -D @commitlint/{config-conventional,cli} commitlint lefthook';
|
|
136
|
+
if (yield (0, yesno_1.default)({
|
|
137
|
+
question: `Do you want to run "${npmInstall}" now? [y]n`,
|
|
138
|
+
defaultValue: true,
|
|
139
|
+
yesValues: ['yes', 'y'],
|
|
140
|
+
noValues: ['no', 'n'],
|
|
141
|
+
})) {
|
|
142
|
+
writeLn(`Executing ${npmInstall}...`);
|
|
143
|
+
execShell(npmInstall);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
writeLn('You could run the following command to install needed dependencies:');
|
|
147
|
+
writeLn(npmInstall);
|
|
148
|
+
writeLn('Or, for pnpm users:');
|
|
149
|
+
writeLn(pnpmInstall);
|
|
150
|
+
}
|
|
151
|
+
if (yield (0, yesno_1.default)({
|
|
152
|
+
question: `Do you want to run "${lefthookInstall}" now? [y]n`,
|
|
153
|
+
defaultValue: true,
|
|
154
|
+
yesValues: ['yes', 'y'],
|
|
155
|
+
noValues: ['no', 'n'],
|
|
156
|
+
})) {
|
|
157
|
+
writeLn(`Executing ${lefthookInstall}...`);
|
|
158
|
+
execShell(lefthookInstall);
|
|
159
|
+
}
|
|
137
160
|
}
|
|
138
161
|
if (option === null || option === void 0 ? void 0 : option.split(',').includes('cleanup')) {
|
|
139
162
|
initCleanup(packageJson);
|
|
@@ -153,13 +176,13 @@ const dirn = (levelsUp) => {
|
|
|
153
176
|
return process.cwd().split(path.sep).reverse()[levels];
|
|
154
177
|
};
|
|
155
178
|
const setup = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
-
// Ask user for arguments if IS_DEV is true
|
|
179
|
+
// Ask the user for arguments if IS_DEV is true
|
|
157
180
|
if (IS_DEV) {
|
|
158
181
|
args = (yield (0, prompt_1.default)('Enter arguments: ')).split(' ');
|
|
159
182
|
}
|
|
160
183
|
switch (args[0]) {
|
|
161
184
|
case 'init':
|
|
162
|
-
init(args[1]);
|
|
185
|
+
yield init(args[1]);
|
|
163
186
|
break;
|
|
164
187
|
case 'dirn':
|
|
165
188
|
writeLn(dirn(args[1]));
|
|
@@ -169,4 +192,16 @@ const setup = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
169
192
|
process.exit(1);
|
|
170
193
|
}
|
|
171
194
|
});
|
|
172
|
-
setup()
|
|
195
|
+
setup()
|
|
196
|
+
.then((r) => {
|
|
197
|
+
if (IS_DEV) {
|
|
198
|
+
writeLn(`DEV: setup completed with result: ${r}`);
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
.catch((err) => {
|
|
202
|
+
if (IS_DEV) {
|
|
203
|
+
writeLn(`DEV: setup failed with error: ${err}`);
|
|
204
|
+
}
|
|
205
|
+
console.error(`Error: ${err}`);
|
|
206
|
+
process.exit(1);
|
|
207
|
+
});
|
|
@@ -77,7 +77,7 @@ function ask(_a) {
|
|
|
77
77
|
input: process.stdin,
|
|
78
78
|
output: process.stdout,
|
|
79
79
|
});
|
|
80
|
-
return new Promise((resolve
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
81
|
rl.question(question + ' ', (answer) => __awaiter(this, void 0, void 0, function* () {
|
|
82
82
|
rl.close();
|
|
83
83
|
const cleaned = answer.trim().toLowerCase();
|
|
@@ -3,39 +3,6 @@
|
|
|
3
3
|
* 2024 Copyright P8 Enterprise Components, Inc.
|
|
4
4
|
* All Rights Reserved.
|
|
5
5
|
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
6
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
8
|
};
|
|
@@ -44,13 +11,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
44
11
|
* Recommended ESLint configuration for TypeScript projects.
|
|
45
12
|
*/
|
|
46
13
|
const js_1 = __importDefault(require("@eslint/js"));
|
|
47
|
-
const
|
|
14
|
+
const typescript_eslint_1 = __importDefault(require("typescript-eslint"));
|
|
48
15
|
const recommended_1 = __importDefault(require("eslint-plugin-prettier/recommended"));
|
|
49
16
|
// @ts-expect-error - importing from a JS file to TS:
|
|
50
17
|
const eslint_plugin_headers_1 = __importDefault(require("eslint-plugin-headers"));
|
|
51
18
|
exports.default = (override) => {
|
|
52
19
|
var _a;
|
|
53
|
-
return
|
|
20
|
+
return typescript_eslint_1.default.config(js_1.default.configs.recommended, typescript_eslint_1.default.configs.recommended, recommended_1.default, {
|
|
54
21
|
ignores: ['**/dist/'],
|
|
55
22
|
}, {
|
|
56
23
|
plugins: {
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* Recommended ESLint configuration for TypeScript projects.
|
|
7
7
|
*/
|
|
8
8
|
import eslint from '@eslint/js';
|
|
9
|
-
import
|
|
9
|
+
import tslint from 'typescript-eslint';
|
|
10
10
|
import eslintPluginPrettierRecommendedConfig from 'eslint-plugin-prettier/recommended';
|
|
11
11
|
// @ts-expect-error - importing from a JS file to TS:
|
|
12
12
|
import eslintPluginHeaders from 'eslint-plugin-headers';
|
|
13
13
|
export default (override) => {
|
|
14
14
|
var _a;
|
|
15
|
-
return tslint.config(eslint.configs.recommended,
|
|
15
|
+
return tslint.config(eslint.configs.recommended, tslint.configs.recommended, eslintPluginPrettierRecommendedConfig, {
|
|
16
16
|
ignores: ['**/dist/'],
|
|
17
17
|
}, {
|
|
18
18
|
plugins: {
|
|
@@ -27,9 +27,10 @@ declare const _default: (overrides?: PrettierConfigOverride) => {
|
|
|
27
27
|
filepath?: string | undefined;
|
|
28
28
|
requirePragma?: boolean | undefined;
|
|
29
29
|
insertPragma?: boolean | undefined;
|
|
30
|
+
checkIgnorePragma?: boolean | undefined;
|
|
30
31
|
proseWrap?: "preserve" | "always" | "never" | undefined;
|
|
31
32
|
arrowParens?: "always" | "avoid" | undefined;
|
|
32
|
-
plugins?: (string | import("prettier").Plugin<any>)[] | undefined;
|
|
33
|
+
plugins?: (string | URL | import("prettier").Plugin<any>)[] | undefined;
|
|
33
34
|
htmlWhitespaceSensitivity?: "strict" | "ignore" | "css" | undefined;
|
|
34
35
|
endOfLine?: "auto" | "lf" | "crlf" | "cr" | undefined;
|
|
35
36
|
quoteProps?: "preserve" | "as-needed" | "consistent" | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@p8ec/shared",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "P(8) Global Shared Library for Javascript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"build:assets": "cp -R src/assets dist",
|
|
19
19
|
"build:scripts": "cp -R ../scripts dist && chmod -R +x dist/scripts/*.sh",
|
|
20
20
|
"clean": "rm -rf dist docs coverage",
|
|
21
|
-
"cli": "NODE_ENV=development ts-node src/bin/p8-shared-cli.ts",
|
|
21
|
+
"cli:testrun": "NODE_ENV=development ts-node src/bin/p8-shared-cli.ts",
|
|
22
22
|
"test": "jest --no-cache --runInBand",
|
|
23
23
|
"test:cov": "jest --coverage --no-cache --runInBand",
|
|
24
24
|
"lint": "eslint --cache \"src/**/*.{js,jsx,ts,tsx}\"",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"docs:clean": "rimraf docs"
|
|
29
29
|
},
|
|
30
30
|
"bin": {
|
|
31
|
-
"p8-shared-cli": "dist/cjs/bin/p8-shared-cli.js",
|
|
32
31
|
"p8-cli": "dist/cjs/bin/p8-shared-cli.js"
|
|
33
32
|
},
|
|
34
33
|
"main": "dist/cjs/index.js",
|
|
@@ -36,13 +35,13 @@
|
|
|
36
35
|
"types": "dist/types/index.d.ts",
|
|
37
36
|
"license": "MIT",
|
|
38
37
|
"dependencies": {
|
|
39
|
-
"@eslint/js": "^9.
|
|
40
|
-
"eslint": "^9.
|
|
41
|
-
"eslint-config-prettier": "^10.1.
|
|
38
|
+
"@eslint/js": "^9.32.0",
|
|
39
|
+
"eslint": "^9.32.0",
|
|
40
|
+
"eslint-config-prettier": "^10.1.8",
|
|
42
41
|
"eslint-plugin-headers": "^1.3.3",
|
|
43
|
-
"eslint-plugin-prettier": "^5.4
|
|
42
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
44
43
|
"ferramenta": "^1.3.2",
|
|
45
|
-
"prettier": "^3.
|
|
46
|
-
"typescript-eslint": "^8.
|
|
44
|
+
"prettier": "^3.6.2",
|
|
45
|
+
"typescript-eslint": "^8.39.0"
|
|
47
46
|
}
|
|
48
47
|
}
|