@decaf-ts/cli 0.3.5 → 0.3.7

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/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 util class to retrieve versions and other information
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 cjs file into a decaf module
12
- * @param {string} path
13
- * @static
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 allows safe dynamic imports
18
- * @summary property imports JS files regardless of esm status
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
- * @typeParam T
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 initializes the Cli object
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 retrieves and parses the package.json file
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 returns the package version
41
- * @param {string} [basePath] defaults to current working dir
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 returns the package name
46
- * @param {string} [basePath] defaults to current working dir
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.5",
3
+ "version": "0.3.7",
4
4
  "description": "cli for decaf-ts projects",
5
5
  "type": "module",
6
6
  "exports": {
@@ -29,13 +29,21 @@
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 repo: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",
35
36
  "drawings": "for FILE in workdocs/drawings/*.drawio; do echo \"converting $FILE to image...\" && docker run --rm -v $(pwd):/data rlespinasse/drawio-export --format png $FILE; done && cp -rf workdocs/drawings/export/* workdocs/resources/",
36
37
  "uml": "cd workdocs/uml && for FILE in ./*.puml; do docker run --rm -v $(pwd):/work -w /work miy4/plantuml -DPLANTUML_LIMIT_SIZE=8192 -tpng $FILE; done && cd ../.. && cp -fr workdocs/uml/*.png workdocs/resources/",
37
38
  "docs": "npx rimraf ./docs && mkdir docs && npx build-scripts --docs",
38
- "publish-docs": "docker run -it --rm --user $(id -u):$(id -g) -v \"$(pwd)/workdocs/confluence:/content\" -e ATLASSIAN_API_TOKEN=$(cat .confluence-token) ghcr.io/markdown-confluence/publish:latest"
39
+ "publish-docs": "docker run -it --rm --user $(id -u):$(id -g) -v \"$(pwd)/workdocs/confluence:/content\" -e ATLASSIAN_API_TOKEN=$(cat .confluence-token) ghcr.io/markdown-confluence/publish:latest",
40
+ "repo:init": "codex exec \"$(cat ./.codex/prompts/repo-setup.md)\nbase_path is `./`, initialize the repository\"",
41
+ "repo:setup": "codex exec \"$(cat ./.codex/prompts/repo-setup.md)\nbase_path is ./\"",
42
+ "repo:doc": "codex exec \"$(cat ./.codex/prompts/doc.md) $(cat ./.codex/prompts/bulk-docs.md)\nbase_path is ./\"",
43
+ "repo:tests": "codex exec \"$(cat ./.codex/prompts/bulk-tests.md)\nbase_path is ./ and coverage is 95%\" -s workspace-write",
44
+ "repo:readme": "codex exec \"$(cat ./.codex/prompts/update-readme.md)\nbase_path is ./\"",
45
+ "repo:pr": "npm run repo:doc && npm run repo:tests && npm run repo:readme",
46
+ "sync-codex": "./bin/sync-codex.sh"
39
47
  },
40
48
  "repository": {
41
49
  "type": "git",
@@ -67,8 +75,8 @@
67
75
  "typescript",
68
76
  "ts"
69
77
  ],
70
- "author": "Tiago Venceslau",
71
- "license": "LGPL-3.0-or-later",
78
+ "author": "Tiago Venceslau and Contributors",
79
+ "license": "MIT",
72
80
  "bugs": {
73
81
  "url": "https://github.com/decaf-ts/cli/issues"
74
82
  },