@decaf-ts/cli 0.3.2 → 0.3.6
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/LICENSE.md +21 -157
- package/README.md +157 -2
- package/dist/cli.cjs +143 -62
- package/dist/cli.esm.cjs +143 -62
- package/lib/CliWrapper.cjs +93 -21
- package/lib/CliWrapper.d.ts +88 -16
- package/lib/bin/cli.cjs +17 -9
- package/lib/bin/cli.d.ts +15 -7
- package/lib/constants.cjs +5 -5
- package/lib/constants.d.ts +4 -4
- package/lib/demo/cli-module.cjs +26 -18
- package/lib/demo/cli-module.d.ts +25 -17
- package/lib/esm/CliWrapper.d.ts +88 -16
- package/lib/esm/CliWrapper.js +95 -23
- package/lib/esm/bin/cli.d.ts +15 -7
- package/lib/esm/bin/cli.js +17 -9
- package/lib/esm/constants.d.ts +4 -4
- package/lib/esm/constants.js +5 -5
- package/lib/esm/demo/cli-module.d.ts +25 -17
- package/lib/esm/demo/cli-module.js +26 -18
- package/lib/esm/index.d.ts +5 -18
- package/lib/esm/index.js +7 -20
- package/lib/esm/types.d.ts +6 -3
- package/lib/esm/types.js +1 -1
- package/lib/esm/utils.d.ts +39 -18
- package/lib/esm/utils.js +42 -20
- package/lib/index.cjs +6 -19
- package/lib/index.d.ts +5 -18
- package/lib/types.cjs +1 -1
- package/lib/types.d.ts +6 -3
- package/lib/utils.cjs +42 -20
- package/lib/utils.d.ts +39 -18
- package/package.json +3 -2
package/lib/utils.d.ts
CHANGED
|
@@ -1,49 +1,70 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { CliModule } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
* @description
|
|
4
|
+
* @description Utility class for CLI operations
|
|
5
|
+
* @summary A static utility class that provides methods for loading modules, retrieving package information, and initializing CLI commands
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Initialize a Command object with package information
|
|
9
|
+
* const command = new Command();
|
|
10
|
+
* CLIUtils.initialize(command, './path/to/package');
|
|
11
|
+
*
|
|
12
|
+
* // Load a CLI module from a file
|
|
13
|
+
* const module = await CLIUtils.loadFromFile('./path/to/cli-module.js');
|
|
5
14
|
*
|
|
6
15
|
* @class CLIUtils
|
|
7
|
-
* @static
|
|
8
16
|
*/
|
|
9
17
|
export declare class CLIUtils {
|
|
10
18
|
/**
|
|
11
|
-
* @description Dynamically imports a
|
|
12
|
-
* @
|
|
13
|
-
*
|
|
19
|
+
* @description Dynamically imports a module file
|
|
20
|
+
* @summary Loads a JavaScript file and returns it as a CliModule, handling both ESM and CommonJS formats
|
|
21
|
+
*
|
|
22
|
+
* @param {string} path The file path to the module to load
|
|
23
|
+
* @return {Promise<CliModule>} A promise that resolves to the loaded CliModule
|
|
14
24
|
*/
|
|
15
25
|
static loadFromFile(path: string): Promise<CliModule>;
|
|
16
26
|
/**
|
|
17
|
-
* @description
|
|
18
|
-
* @summary
|
|
27
|
+
* @description Normalizes module imports to handle both ESM and CommonJS formats
|
|
28
|
+
* @summary Properly imports JavaScript files regardless of their module format by handling the ESM wrapper for CommonJS modules
|
|
19
29
|
*
|
|
20
|
-
* @
|
|
21
|
-
* @param {Promise} importPromise
|
|
30
|
+
* @template T The type of the imported module
|
|
31
|
+
* @param {Promise<T>} importPromise The promise returned by the dynamic import
|
|
32
|
+
* @return {Promise<T>} A promise that resolves to the normalized module
|
|
22
33
|
* @private
|
|
23
34
|
*/
|
|
24
35
|
static normalizeImport<T>(importPromise: Promise<T>): Promise<T>;
|
|
25
36
|
/**
|
|
26
|
-
* @description
|
|
37
|
+
* @description Initializes a Command object with package information
|
|
38
|
+
* @summary Sets up a Commander Command object with the package name, description, and version from the package.json file
|
|
27
39
|
*
|
|
28
|
-
* @param {Command} command
|
|
29
|
-
* @param {string} [basePath] defaults to the current working directory
|
|
40
|
+
* @param {Command} command The Command object to initialize
|
|
41
|
+
* @param {string} [basePath] The base path where the package.json file is located, defaults to the current working directory
|
|
42
|
+
* @return {void}
|
|
30
43
|
*/
|
|
31
44
|
static initialize(command: Command, basePath: string): void;
|
|
32
45
|
/**
|
|
33
|
-
* @description
|
|
46
|
+
* @description Retrieves and parses the package.json file
|
|
47
|
+
* @summary Reads the package.json file from the specified path and parses it into a JavaScript object
|
|
34
48
|
*
|
|
35
|
-
* @param {string} basePath
|
|
49
|
+
* @param {string} basePath The base path where the package.json file is located
|
|
50
|
+
* @return {Record<string, unknown>} The parsed package.json content as an object
|
|
36
51
|
* @private
|
|
37
52
|
*/
|
|
38
53
|
private static getPackage;
|
|
39
54
|
/**
|
|
40
|
-
* @description
|
|
41
|
-
* @
|
|
55
|
+
* @description Returns the version from package.json
|
|
56
|
+
* @summary Retrieves the version field from the package.json file at the specified path
|
|
57
|
+
*
|
|
58
|
+
* @param {string} basePath The base path where the package.json file is located
|
|
59
|
+
* @return {string} The package version string
|
|
42
60
|
*/
|
|
43
61
|
static packageVersion(basePath: string): string;
|
|
44
62
|
/**
|
|
45
|
-
* @description
|
|
46
|
-
* @
|
|
63
|
+
* @description Returns the name from package.json
|
|
64
|
+
* @summary Retrieves the name field from the package.json file at the specified path and extracts the package name without the scope
|
|
65
|
+
*
|
|
66
|
+
* @param {string} basePath The base path where the package.json file is located
|
|
67
|
+
* @return {string} The package name without the scope (e.g., "cli" from "@decaf-ts/cli")
|
|
47
68
|
*/
|
|
48
69
|
static packageName(basePath: string): string;
|
|
49
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decaf-ts/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "cli for decaf-ts projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"coverage": "rimraf ./workdocs/reports/data/*.json && npm run test:all -- --coverage --config=./workdocs/reports/jest.coverage.config.ts",
|
|
30
30
|
"lint": "eslint .",
|
|
31
31
|
"lint-fix": "eslint --fix .",
|
|
32
|
+
"prepare-pr": "npm run lint-fix && npm run build:prod && npm run coverage && npm run docs",
|
|
32
33
|
"prepare-release": "npm run lint-fix && npm run build:prod && npm run coverage && npm run docs",
|
|
33
34
|
"release": "./bin/tag-release.sh",
|
|
34
35
|
"clean-publish": "npx clean-publish",
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
"ts"
|
|
69
70
|
],
|
|
70
71
|
"author": "Tiago Venceslau",
|
|
71
|
-
"license": "
|
|
72
|
+
"license": "MIT",
|
|
72
73
|
"bugs": {
|
|
73
74
|
"url": "https://github.com/decaf-ts/cli/issues"
|
|
74
75
|
},
|