@p8ec/shared 2.5.1 → 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/README.md CHANGED
@@ -6,13 +6,6 @@ Shared TypeScript/JavaScript libraries for P(8) products.
6
6
 
7
7
  Shared (**and very opinionated**) configuration for P(8) projects.
8
8
 
9
- **Contents:**
10
-
11
- - ESLint configuration
12
- - Prettier configuration
13
- - Commitlint configuration
14
- - Lefthook configuration
15
-
16
9
  ### Usage
17
10
 
18
11
  #### Installation
@@ -73,6 +66,6 @@ p8-cli [command] [options]
73
66
  - `run` - Returns a script string using the detected or specified package manager. Options: `script` - script name,
74
67
  `packageManager` - npm, yarn, or pnpm (auto-detected by default), `workspaceMode` - mode of concurrency for workspaces
75
68
  (if applicable): `seq` (default) or `par`.
76
- - Example: `p8-cli run build` - runs the `build` script using the detected package manager.
77
- - Example: `p8-cli run test pnpm par` - runs the `test` script using
69
+ - Example: `p8-cli run build` - returns the `build` script using the detected package manager.
70
+ - Example: `p8-cli run test pnpm par` - returns the `test` script using
78
71
  `pnpm` in parallel mode for workspaces.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  /**
4
- * 2024 Copyright P8 Enterprise Components, Inc.
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 = 'none') => {
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: ')).split(' ');
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(`Error: ${err}`);
315
+ console.error(err.toString());
291
316
  process.exit(1);
292
317
  });
293
318
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * 2024 Copyright P8 Enterprise Components, Inc.
3
+ * 2026 Copyright P8 Enterprise Components, Inc.
4
4
  * All Rights Reserved.
5
5
  */
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * 2024 Copyright P8 Enterprise Components, Inc.
3
+ * 2026 Copyright P8 Enterprise Components, Inc.
4
4
  * All Rights Reserved.
5
5
  */
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * 2024 Copyright P8 Enterprise Components, Inc.
3
+ * 2026 Copyright P8 Enterprise Components, Inc.
4
4
  * All Rights Reserved.
5
5
  */
6
6
  var __importDefault = (this && this.__importDefault) || function (mod) {
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * 2024 Copyright P8 Enterprise Components, Inc.
3
+ * 2026 Copyright P8 Enterprise Components, Inc.
4
4
  * All Rights Reserved.
5
5
  */
6
6
  var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * 2024 Copyright P8 Enterprise Components, Inc.
3
+ * 2026 Copyright P8 Enterprise Components, Inc.
4
4
  * All Rights Reserved.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 2024 Copyright P8 Enterprise Components, Inc.
2
+ * 2026 Copyright P8 Enterprise Components, Inc.
3
3
  * All Rights Reserved.
4
4
  */
5
5
  /**
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 2024 Copyright P8 Enterprise Components, Inc.
2
+ * 2026 Copyright P8 Enterprise Components, Inc.
3
3
  * All Rights Reserved.
4
4
  */
5
5
  import eslintConfigRecommended from './eslintConfigRecommended';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 2024 Copyright P8 Enterprise Components, Inc.
2
+ * 2026 Copyright P8 Enterprise Components, Inc.
3
3
  * All Rights Reserved.
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 2024 Copyright P8 Enterprise Components, Inc.
2
+ * 2026 Copyright P8 Enterprise Components, Inc.
3
3
  * All Rights Reserved.
4
4
  */
5
5
  import { ConfigWithExtends } from 'typescript-eslint';
@@ -8,5 +8,5 @@ interface EslintConfigOverrideInterface {
8
8
  eslintConfig?: ConfigWithExtends;
9
9
  }
10
10
  export type EslintConfigOverride = EslintConfigOverrideInterface;
11
- declare const _default: (override?: EslintConfigOverride) => import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
11
+ declare const _default: (override?: EslintConfigOverride) => import("typescript-eslint").FlatConfig.ConfigArray;
12
12
  export default _default;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 2024 Copyright P8 Enterprise Components, Inc.
2
+ * 2026 Copyright P8 Enterprise Components, Inc.
3
3
  * All Rights Reserved.
4
4
  */
5
5
  import eslintConfigRecommended, { EslintConfigOverride } from './eslintConfigRecommended';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 2024 Copyright P8 Enterprise Components, Inc.
2
+ * 2026 Copyright P8 Enterprise Components, Inc.
3
3
  * All Rights Reserved.
4
4
  */
5
5
  import { Options } from 'prettier';
@@ -28,7 +28,7 @@ declare const _default: (overrides?: PrettierConfigOverride) => {
28
28
  requirePragma?: boolean | undefined;
29
29
  insertPragma?: boolean | undefined;
30
30
  checkIgnorePragma?: boolean | undefined;
31
- proseWrap?: "preserve" | "always" | "never" | undefined;
31
+ proseWrap?: "always" | "never" | "preserve" | undefined;
32
32
  arrowParens?: "always" | "avoid" | undefined;
33
33
  plugins?: (string | URL | import("prettier").Plugin<any>)[] | undefined;
34
34
  htmlWhitespaceSensitivity?: "strict" | "ignore" | "css" | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@p8ec/shared",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "description": "P(8) Global Shared Library for Javascript",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,14 +18,15 @@
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
- "docs:build": "typedoc --name 'P(8) Global Shared Library' --includeVersion --readme README_GENERATED.md --out docs src",
27
- "docs:patch": "mv docs/functions docs/funcs && sed -i'.bak' 's/href=\\\"functions/href=\\\"funcs/g' docs/*.html",
28
- "docs:clean": "rimraf docs"
27
+ "docs:build": "typedoc --name 'P(8) Global Shared Library' --includeVersion --out docs src",
28
+ "docs:patch": "(mv docs/functions docs/funcs && sed -i'.bak' 's/href=\\\"functions/href=\\\"funcs/g' docs/*.html) || true",
29
+ "docs:clean": "rm -rf docs"
29
30
  },
30
31
  "bin": {
31
32
  "p8-cli": "dist/cjs/bin/p8-shared-cli.js"
@@ -35,13 +36,13 @@
35
36
  "types": "dist/types/index.d.ts",
36
37
  "license": "MIT",
37
38
  "dependencies": {
38
- "@eslint/js": "^9.32.0",
39
- "eslint": "^9.32.0",
39
+ "@eslint/js": "^9.39.2",
40
+ "eslint": "^9.39.2",
40
41
  "eslint-config-prettier": "^10.1.8",
41
42
  "eslint-plugin-headers": "^1.3.3",
42
43
  "eslint-plugin-prettier": "^5.5.4",
43
44
  "ferramenta": "^1.3.2",
44
- "prettier": "^3.6.2",
45
- "typescript-eslint": "^8.39.0"
45
+ "prettier": "^3.7.4",
46
+ "typescript-eslint": "^8.52.0"
46
47
  }
47
48
  }