@p8ec/shared 1.0.0 → 1.1.1

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
@@ -1,4 +1,4 @@
1
- # P(8) Global Shared Library for Node.js and TypeScript/JavaScript.
1
+ # P(8) Global Shared Library for Node.js and TypeScript/JavaScript
2
2
 
3
3
  This repository contains the shared library for all P(8) products.
4
4
 
@@ -8,16 +8,28 @@ This repository contains the shared configuration for all P(8) products.
8
8
 
9
9
  ### Usage
10
10
 
11
+ #### Installation
12
+
13
+ ```shell
14
+ npm i -D @p8ec/shared
15
+ ```
16
+
17
+ #### Initialization
18
+
19
+ ```shell
20
+ p8-shared-cli init
21
+ ```
22
+
23
+ This command will create the following files in your project and remove corresponding configuration entries from `package.json`:
24
+
11
25
  #### **`.eslintrc.js`**
12
26
 
13
27
  ```javascript
14
- // .eslintrc.js
15
28
  module.exports = require('@p8ec/shared').eslintConfigRecommended;
16
29
  ```
17
30
 
18
31
  #### **`.prettierrc.js`**
19
32
 
20
33
  ```javascript
21
- // .prettierrc.js
22
34
  module.exports = require('@p8ec/shared').prettierConfigRecommended;
23
35
  ```
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * 2023 Copyright P8 Enterprise Components, Inc.
5
+ * All Rights Reserved.
6
+ * Private and Confidential.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ /**
33
+ * P8 Shared CLI tool.
34
+ *
35
+ * This tool is used to simplify the process of creating new P8 components.
36
+ *
37
+ * Usage:
38
+ * p8-shared [command] [options]
39
+ *
40
+ * Commands:
41
+ * init [--flavor=recommended]
42
+ * Initializes a new P8 component.
43
+ * Options:
44
+ * --flavor: The flavor of the component to create. Defaults to 'recommended'.
45
+ */
46
+ const path = __importStar(require("path"));
47
+ const fs = __importStar(require("fs"));
48
+ const ferramenta_1 = require("ferramenta");
49
+ const args = ferramenta_1.processArgs.args;
50
+ const self = path.parse(ferramenta_1.processArgs.name).name;
51
+ if (args.length === 0) {
52
+ // eslint-disable-next-line no-console
53
+ console.log(`
54
+ Usage: ${self} [command] [options]
55
+
56
+ Commands:
57
+ init [--flavor=recommended]
58
+ Initializes a new P8 component.
59
+ Options:
60
+ --flavor: The flavor of the component to create. Defaults to 'recommended'.
61
+ `);
62
+ process.exit(1);
63
+ }
64
+ const init = () => {
65
+ // eslint-disable-next-line no-console
66
+ console.log('Creating .eslintrc.js...');
67
+ fs.writeFileSync(path.join(path.resolve(__dirname), '.eslintrc.js'), `module.exports = require('@p8ec/shared').eslintConfigRecommended;`);
68
+ // eslint-disable-next-line no-console
69
+ console.log('Creating .prettierrc.js...');
70
+ fs.writeFileSync(path.join(path.resolve(__dirname), '.prettierrc.js'), `module.exports = require('@p8ec/shared').prettierConfigRecommended;`);
71
+ // Remove eslintConfig and prettier from package.json
72
+ // eslint-disable-next-line no-console
73
+ console.log('Removing eslintConfig and prettier from package.json...');
74
+ const packageJson = JSON.parse(String(fs.readFileSync(path.join(process.cwd(), 'package.json'))));
75
+ delete packageJson['eslintConfig'];
76
+ delete packageJson['prettier'];
77
+ fs.writeFileSync(path.join(process.cwd(), 'package.json'), JSON.stringify(packageJson, null, 2));
78
+ };
79
+ switch (args[0]) {
80
+ case 'init':
81
+ init();
82
+ break;
83
+ default:
84
+ // eslint-disable-next-line no-console
85
+ console.error(`Unknown command: ${args[0]}`);
86
+ process.exit(1);
87
+ break;
88
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@p8ec/shared",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "P(8) Global Shared Library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,7 +13,7 @@
13
13
  "scripts": {
14
14
  "build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:types",
15
15
  "build:esm": "tsc -p configs/tsconfig.esm.json",
16
- "build:cjs": "tsc -p configs/tsconfig.cjs.json",
16
+ "build:cjs": "tsc -p configs/tsconfig.cjs.json && chmod -R +x dist/cjs/bin/*.js",
17
17
  "build:types": "tsc -p configs/tsconfig.types.json",
18
18
  "clean": "rimraf dist docs coverage",
19
19
  "reset": "npm run clean && rimraf node_modules && npm install",
@@ -26,6 +26,9 @@
26
26
  "docs:patch": "mv docs/functions docs/funcs && sed -i'.bak' 's/href=\\\"functions/href=\\\"funcs/g' docs/*.html",
27
27
  "docs:clean": "rimraf docs"
28
28
  },
29
+ "bin": {
30
+ "p8-shared-cli": "dist/cjs/bin/p8-shared-cli.js"
31
+ },
29
32
  "main": "dist/cjs/index.js",
30
33
  "module": "dist/esm/index.js",
31
34
  "types": "dist/types/index.d.ts",
@@ -116,5 +119,8 @@
116
119
  "license": "MIT",
117
120
  "lint-staged1": {
118
121
  "*.{js,jsx,ts,tsx}": "npm run lint:fix"
122
+ },
123
+ "dependencies": {
124
+ "ferramenta": "^1.3.0"
119
125
  }
120
126
  }