@p8ec/shared 2.5.2 → 2.5.3
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/cjs/bin/p8-shared-cli.js +33 -8
- package/dist/cjs/bin/utils/prompt.js +1 -1
- package/dist/cjs/bin/utils/yesno.js +1 -1
- package/dist/cjs/eslintConfigRecommended.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/prettierConfigRecommended.js +1 -1
- package/dist/esm/eslintConfigRecommended.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/prettierConfigRecommended.js +1 -1
- package/dist/types/eslintConfigRecommended.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/prettierConfigRecommended.d.ts +1 -1
- package/package.json +3 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 2026 Copyright P8 Enterprise Components, Inc.
|
|
5
5
|
* All Rights Reserved.
|
|
6
6
|
*/
|
|
7
7
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -50,7 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
50
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.run = exports.dirn = exports.init = exports.detectPackageManager = exports.initCleanup = exports.cliUtils = exports.IS_DEV = void 0;
|
|
53
|
+
exports.run = exports.dirn = exports.init = exports.detectWorkspace = exports.detectPackageManager = exports.initCleanup = exports.cliUtils = exports.IS_DEV = void 0;
|
|
54
54
|
/**
|
|
55
55
|
* P8 Shared CLI tool.
|
|
56
56
|
*
|
|
@@ -138,6 +138,28 @@ const detectPackageManager = (cwd = process.cwd()) => {
|
|
|
138
138
|
return 'npm';
|
|
139
139
|
};
|
|
140
140
|
exports.detectPackageManager = detectPackageManager;
|
|
141
|
+
/**
|
|
142
|
+
* Detects if the project is a workspace.
|
|
143
|
+
*/
|
|
144
|
+
const detectWorkspace = (cwd = process.cwd()) => {
|
|
145
|
+
if (fs.existsSync(path.join(cwd, 'pnpm-workspace.yaml'))) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
const packageJsonPath = path.join(cwd, 'package.json');
|
|
149
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
150
|
+
try {
|
|
151
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
152
|
+
if (packageJson.workspaces) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
catch (_a) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
};
|
|
162
|
+
exports.detectWorkspace = detectWorkspace;
|
|
141
163
|
/**
|
|
142
164
|
* Initializes a TypeScript project with P8 shared configurations.
|
|
143
165
|
*/
|
|
@@ -225,8 +247,11 @@ const dirn = (levelsUp) => {
|
|
|
225
247
|
return process.cwd().split(path.sep).reverse()[levels];
|
|
226
248
|
};
|
|
227
249
|
exports.dirn = dirn;
|
|
228
|
-
const run = (script, packageManager = (0, exports.detectPackageManager)(), workspaceMode
|
|
250
|
+
const run = (script, packageManager = (0, exports.detectPackageManager)(), workspaceMode) => {
|
|
229
251
|
var _a;
|
|
252
|
+
if (!workspaceMode || workspaceMode === 'none') {
|
|
253
|
+
workspaceMode = (0, exports.detectWorkspace)() ? 'seq' : 'none';
|
|
254
|
+
}
|
|
230
255
|
const pnpmWorkspaceSeq = '-r --workspace-concurrency=1 --if-present --reporter-hide-prefix';
|
|
231
256
|
const pnpmWorkspacePar = '-r --if-present --parallel';
|
|
232
257
|
const yarnWorkspaceSeq = 'workspaces foreach -A';
|
|
@@ -259,7 +284,7 @@ exports.run = run;
|
|
|
259
284
|
const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
260
285
|
// Ask the user for arguments if IS_DEV is true
|
|
261
286
|
if (exports.IS_DEV) {
|
|
262
|
-
args = (yield (0, prompt_1.default)('Enter arguments:
|
|
287
|
+
args = (yield (0, prompt_1.default)('Enter arguments:')).split(' ');
|
|
263
288
|
}
|
|
264
289
|
switch (args[0]) {
|
|
265
290
|
case 'init':
|
|
@@ -269,7 +294,7 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
269
294
|
writeLn((0, exports.dirn)(args[1]));
|
|
270
295
|
break;
|
|
271
296
|
case 'run':
|
|
272
|
-
writeLn((0, exports.run)(args[1], args[2]));
|
|
297
|
+
writeLn((0, exports.run)(args[1], args[2], args[3]));
|
|
273
298
|
break;
|
|
274
299
|
default:
|
|
275
300
|
console.error(`Unknown command: ${args[0]}`);
|
|
@@ -280,14 +305,14 @@ if (require.main === module) {
|
|
|
280
305
|
main()
|
|
281
306
|
.then((r) => {
|
|
282
307
|
if (exports.IS_DEV) {
|
|
283
|
-
writeLn(`DEV: setup completed with result: ${r}`);
|
|
308
|
+
writeLn(`DEV: setup completed successfully with result: ${JSON.stringify(r)}`);
|
|
284
309
|
}
|
|
285
310
|
})
|
|
286
311
|
.catch((err) => {
|
|
287
312
|
if (exports.IS_DEV) {
|
|
288
|
-
writeLn(`DEV: setup failed with error: ${err}`);
|
|
313
|
+
writeLn(`DEV: setup failed with error: ${JSON.stringify(err)}`);
|
|
289
314
|
}
|
|
290
|
-
console.error(
|
|
315
|
+
console.error(err.toString());
|
|
291
316
|
process.exit(1);
|
|
292
317
|
});
|
|
293
318
|
}
|
package/dist/cjs/index.js
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@p8ec/shared",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.3",
|
|
4
4
|
"description": "P(8) Global Shared Library for Javascript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,9 +18,10 @@
|
|
|
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:testrun": "NODE_ENV=development ts-node src/bin/p8-shared-cli.ts",
|
|
22
21
|
"test": "jest --no-cache --runInBand",
|
|
23
22
|
"test:cov": "jest --coverage --no-cache --runInBand",
|
|
23
|
+
"test:cli:dev": "NODE_ENV=development ts-node src/bin/p8-shared-cli.ts",
|
|
24
|
+
"test:cli": "ts-node src/bin/p8-shared-cli.ts",
|
|
24
25
|
"lint": "eslint --cache \"src/**/*.{js,jsx,ts,tsx}\"",
|
|
25
26
|
"lint:fix": "eslint --cache --fix \"src/**/*.{js,jsx,ts,tsx}\"",
|
|
26
27
|
"docs:build": "typedoc --name 'P(8) Global Shared Library' --includeVersion --out docs src",
|