@decaf-ts/utils 1.1.0 → 1.2.0

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.
Files changed (94) hide show
  1. package/README.md +1 -1
  2. package/dist/utils.cjs +1 -1
  3. package/dist/utils.cjs.map +1 -1
  4. package/dist/utils.js +1 -1
  5. package/dist/utils.js.map +1 -1
  6. package/lib/cjs/cli/commands/build-scripts.cjs +87 -0
  7. package/lib/cjs/cli/commands/build-scripts.cjs.map +1 -1
  8. package/lib/cjs/index.cjs +1 -1
  9. package/lib/esm/cli/commands/build-scripts.js +87 -0
  10. package/lib/esm/cli/commands/build-scripts.js.map +1 -1
  11. package/lib/esm/index.js +1 -1
  12. package/lib/types/assets/slogans.d.cts +19 -0
  13. package/lib/types/assets/slogans.d.mts +19 -0
  14. package/lib/types/bin/build-scripts.d.cts +1 -0
  15. package/lib/types/bin/build-scripts.d.mts +1 -0
  16. package/lib/types/bin/release-chain-dispatch.d.cts +1 -0
  17. package/lib/types/bin/release-chain-dispatch.d.mts +1 -0
  18. package/lib/types/bin/release-chain.d.cts +1 -0
  19. package/lib/types/bin/release-chain.d.mts +1 -0
  20. package/lib/types/bin/tag-release.d.cts +1 -0
  21. package/lib/types/bin/tag-release.d.mts +1 -0
  22. package/lib/types/cli/command.d.cts +104 -0
  23. package/lib/types/cli/command.d.mts +104 -0
  24. package/lib/types/cli/commands/build-scripts.d.cts +148 -0
  25. package/lib/types/cli/commands/build-scripts.d.mts +148 -0
  26. package/lib/types/cli/commands/build-scripts.d.ts +3 -0
  27. package/lib/types/cli/commands/index.d.cts +3 -0
  28. package/lib/types/cli/commands/index.d.mts +3 -0
  29. package/lib/types/cli/commands/release-chain.d.cts +62 -0
  30. package/lib/types/cli/commands/release-chain.d.mts +62 -0
  31. package/lib/types/cli/commands/tag-release.d.cts +105 -0
  32. package/lib/types/cli/commands/tag-release.d.mts +105 -0
  33. package/lib/types/cli/constants.d.cts +75 -0
  34. package/lib/types/cli/constants.d.mts +75 -0
  35. package/lib/types/cli/index.d.cts +4 -0
  36. package/lib/types/cli/index.d.mts +4 -0
  37. package/lib/types/cli/types.d.cts +30 -0
  38. package/lib/types/cli/types.d.mts +30 -0
  39. package/lib/types/index.d.cts +38 -0
  40. package/lib/types/index.d.mts +38 -0
  41. package/lib/types/index.d.ts +1 -1
  42. package/lib/types/input/index.d.cts +2 -0
  43. package/lib/types/input/index.d.mts +2 -0
  44. package/lib/types/input/input.d.cts +517 -0
  45. package/lib/types/input/input.d.mts +517 -0
  46. package/lib/types/input/types.d.cts +159 -0
  47. package/lib/types/input/types.d.mts +159 -0
  48. package/lib/types/output/common.d.cts +53 -0
  49. package/lib/types/output/common.d.mts +53 -0
  50. package/lib/types/output/index.d.cts +1 -0
  51. package/lib/types/output/index.d.mts +1 -0
  52. package/lib/types/release-chain/index.d.cts +43 -0
  53. package/lib/types/release-chain/index.d.mts +43 -0
  54. package/lib/types/tests/Consumer.d.cts +151 -0
  55. package/lib/types/tests/Consumer.d.mts +151 -0
  56. package/lib/types/tests/ProducerChildProcess.d.cts +18 -0
  57. package/lib/types/tests/ProducerChildProcess.d.mts +18 -0
  58. package/lib/types/tests/TestReporter.d.cts +245 -0
  59. package/lib/types/tests/TestReporter.d.mts +245 -0
  60. package/lib/types/tests/index.d.cts +4 -0
  61. package/lib/types/tests/index.d.mts +4 -0
  62. package/lib/types/tests/jestPerformanceRunner.d.cts +37 -0
  63. package/lib/types/tests/jestPerformanceRunner.d.mts +37 -0
  64. package/lib/types/tests/utils.d.cts +5 -0
  65. package/lib/types/tests/utils.d.mts +5 -0
  66. package/lib/types/utils/constants.d.cts +65 -0
  67. package/lib/types/utils/constants.d.mts +65 -0
  68. package/lib/types/utils/fs.d.cts +259 -0
  69. package/lib/types/utils/fs.d.mts +259 -0
  70. package/lib/types/utils/http.d.cts +41 -0
  71. package/lib/types/utils/http.d.mts +41 -0
  72. package/lib/types/utils/index.d.cts +6 -0
  73. package/lib/types/utils/index.d.mts +6 -0
  74. package/lib/types/utils/md.d.cts +156 -0
  75. package/lib/types/utils/md.d.mts +156 -0
  76. package/lib/types/utils/performanceRunner.d.cts +129 -0
  77. package/lib/types/utils/performanceRunner.d.mts +129 -0
  78. package/lib/types/utils/timeout.d.cts +12 -0
  79. package/lib/types/utils/timeout.d.mts +12 -0
  80. package/lib/types/utils/types.d.cts +112 -0
  81. package/lib/types/utils/types.d.mts +112 -0
  82. package/lib/types/utils/utils.d.cts +133 -0
  83. package/lib/types/utils/utils.d.mts +133 -0
  84. package/lib/types/writers/OutputWriter.d.cts +49 -0
  85. package/lib/types/writers/OutputWriter.d.mts +49 -0
  86. package/lib/types/writers/RegexpOutputWriter.d.cts +110 -0
  87. package/lib/types/writers/RegexpOutputWriter.d.mts +110 -0
  88. package/lib/types/writers/StandardOutputWriter.d.cts +130 -0
  89. package/lib/types/writers/StandardOutputWriter.d.mts +130 -0
  90. package/lib/types/writers/index.d.cts +4 -0
  91. package/lib/types/writers/index.d.mts +4 -0
  92. package/lib/types/writers/types.d.cts +29 -0
  93. package/lib/types/writers/types.d.mts +29 -0
  94. package/package.json +14 -8
@@ -0,0 +1,105 @@
1
+ import { Command } from "../command.js";
2
+ import { DefaultCommandValues } from "../index.js";
3
+ import { LoggingConfig } from "@decaf-ts/logging";
4
+ declare const options: {
5
+ ci: {
6
+ type: string;
7
+ default: boolean;
8
+ };
9
+ message: {
10
+ type: string;
11
+ short: string;
12
+ };
13
+ tag: {
14
+ type: string;
15
+ short: string;
16
+ default: undefined;
17
+ };
18
+ };
19
+ /**
20
+ * @class ReleaseScript
21
+ * @extends {Command}
22
+ * @cavegory scripts
23
+ * @description A command-line script for managing releases and version updates.
24
+ * @summary This script automates the process of creating and pushing new releases. It handles version updates,
25
+ * commit messages, and optionally publishes to NPM. The script supports semantic versioning and can work in both CI and non-CI environments.
26
+ *
27
+ * @param {Object} options - Configuration options for the script
28
+ * @param {boolean} options.ci - Whether the script is running in a CI environment (default: true)
29
+ * @param {string} options.message - The release message (short: 'm')
30
+ * @param {string} options.tag - The version tag to use (short: 't', default: undefined)
31
+ */
32
+ export declare class ReleaseScript extends Command<typeof options, void> {
33
+ constructor();
34
+ /**
35
+ * @description Prepares the version for the release.
36
+ * @summary This method validates the provided tag or prompts the user for a new one if not provided or invalid.
37
+ * It also displays the latest git tags for reference.
38
+ * @param {string} tag - The version tag to prepare
39
+ * @returns {Promise<string>} The prepared version tag
40
+ *
41
+ * @mermaid
42
+ * sequenceDiagram
43
+ * participant R as ReleaseScript
44
+ * participant T as TestVersion
45
+ * participant U as UserInput
46
+ * participant G as Git
47
+ * R->>T: testVersion(tag)
48
+ * alt tag is valid
49
+ * T-->>R: return tag
50
+ * else tag is invalid or not provided
51
+ * R->>G: List latest git tags
52
+ * R->>U: Prompt for new tag
53
+ * U-->>R: return new tag
54
+ * end
55
+ */
56
+ prepareVersion(tag?: string): Promise<string>;
57
+ /**
58
+ * @description Tests if the provided version is valid.
59
+ * @summary This method checks if the version is a valid semantic version or a predefined update type (PATCH, MINOR, MAJOR).
60
+ * @param {string} version - The version to test
61
+ * @returns {string | undefined} The validated version or undefined if invalid
62
+ */
63
+ testVersion(version: string): string | undefined;
64
+ /**
65
+ * @description Prepares the release message.
66
+ * @summary This method either returns the provided message or prompts the user for a new one if not provided.
67
+ * @param {string} [message] - The release message
68
+ * @returns {Promise<string>} The prepared release message
69
+ */
70
+ prepareMessage(message?: string): Promise<string>;
71
+ /**
72
+ * @description Runs the release script.
73
+ * @summary This method orchestrates the entire release process, including version preparation, message creation,
74
+ * git operations, and npm publishing (if not in CI environment).
75
+ * @param {ParseArgsResult} args - The parsed command-line arguments
76
+ * @returns {Promise<void>}
77
+ *
78
+ * @mermaid
79
+ * sequenceDiagram
80
+ * participant R as ReleaseScript
81
+ * participant V as PrepareVersion
82
+ * participant M as PrepareMessage
83
+ * participant N as NPM
84
+ * participant G as Git
85
+ * participant U as UserInput
86
+ * R->>V: prepareVersion(tag)
87
+ * R->>M: prepareMessage(message)
88
+ * R->>N: Run prepare-release script
89
+ * R->>G: Check git status
90
+ * alt changes exist
91
+ * R->>U: Ask for confirmation
92
+ * U-->>R: Confirm
93
+ * R->>G: Add and commit changes
94
+ * end
95
+ * R->>N: Update npm version
96
+ * R->>G: Push changes and tags
97
+ * alt not CI environment
98
+ * R->>N: Publish to npm
99
+ * end
100
+ */
101
+ run(args: LoggingConfig & typeof DefaultCommandValues & {
102
+ [k in keyof typeof options]: unknown;
103
+ }): Promise<void>;
104
+ }
105
+ export {};
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @description Default command options for CLI commands.
3
+ * @summary Defines the structure and default values for common command-line options used across various CLI commands.
4
+ * @const DefaultCommandOptions
5
+ * @typedef {Object} DefaultCommandOptions
6
+ * @property {Object} verbose - Verbosity level option.
7
+ * @property {string} verbose.type - The type of the verbose option (number).
8
+ * @property {string} verbose.short - The short flag for the verbose option (V).
9
+ * @property {number} verbose.default - The default value for verbosity (0).
10
+ * @property {Object} version - Version display option.
11
+ * @property {string} version.type - The type of the version option (boolean).
12
+ * @property {string} version.short - The short flag for the version option (v).
13
+ * @property {undefined} version.default - The default value for version display (undefined).
14
+ * @property {Object} help - Help display option.
15
+ * @property {string} help.type - The type of the help option (boolean).
16
+ * @property {string} help.short - The short flag for the help option (h).
17
+ * @property {boolean} help.default - The default value for help display (false).
18
+ * @property {Object} logLevel - Log level option.
19
+ * @property {string} logLevel.type - The type of the logLevel option (string).
20
+ * @property {string} logLevel.default - The default value for log level ("info").
21
+ * @property {Object} logStyle - Log styling option.
22
+ * @property {string} logStyle.type - The type of the logStyle option (boolean).
23
+ * @property {boolean} logStyle.default - The default value for log styling (true).
24
+ * @property {Object} timestamp - Timestamp display option.
25
+ * @property {string} timestamp.type - The type of the timestamp option (boolean).
26
+ * @property {boolean} timestamp.default - The default value for timestamp display (true).
27
+ * @property {Object} banner - Banner display option.
28
+ * @property {string} banner.type - The type of the banner option (boolean).
29
+ * @property {boolean} banner.default - The default value for banner display (false).
30
+ * @memberOf module:utils
31
+ */
32
+ export declare const DefaultCommandOptions: {
33
+ verbose: {
34
+ type: string;
35
+ short: string;
36
+ default: undefined;
37
+ };
38
+ version: {
39
+ type: string;
40
+ short: string;
41
+ default: undefined;
42
+ };
43
+ help: {
44
+ type: string;
45
+ short: string;
46
+ default: boolean;
47
+ };
48
+ logLevel: {
49
+ type: string;
50
+ default: string;
51
+ };
52
+ logStyle: {
53
+ type: string;
54
+ default: boolean;
55
+ };
56
+ timestamp: {
57
+ type: string;
58
+ default: boolean;
59
+ };
60
+ banner: {
61
+ type: string;
62
+ default: boolean;
63
+ };
64
+ };
65
+ /**
66
+ * @description Default command values derived from DefaultCommandOptions.
67
+ * @summary Creates an object with the default values of all options defined in DefaultCommandOptions.
68
+ * @const DefaultCommandValues
69
+ * @typedef {Object} DefaultCommandValues
70
+ * @property {unknown} [key: string] - The default value for each option in DefaultCommandOptions.
71
+ * @memberOf module:utils
72
+ */
73
+ export declare const DefaultCommandValues: {
74
+ [k in keyof typeof DefaultCommandOptions]: unknown;
75
+ };
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @description Default command options for CLI commands.
3
+ * @summary Defines the structure and default values for common command-line options used across various CLI commands.
4
+ * @const DefaultCommandOptions
5
+ * @typedef {Object} DefaultCommandOptions
6
+ * @property {Object} verbose - Verbosity level option.
7
+ * @property {string} verbose.type - The type of the verbose option (number).
8
+ * @property {string} verbose.short - The short flag for the verbose option (V).
9
+ * @property {number} verbose.default - The default value for verbosity (0).
10
+ * @property {Object} version - Version display option.
11
+ * @property {string} version.type - The type of the version option (boolean).
12
+ * @property {string} version.short - The short flag for the version option (v).
13
+ * @property {undefined} version.default - The default value for version display (undefined).
14
+ * @property {Object} help - Help display option.
15
+ * @property {string} help.type - The type of the help option (boolean).
16
+ * @property {string} help.short - The short flag for the help option (h).
17
+ * @property {boolean} help.default - The default value for help display (false).
18
+ * @property {Object} logLevel - Log level option.
19
+ * @property {string} logLevel.type - The type of the logLevel option (string).
20
+ * @property {string} logLevel.default - The default value for log level ("info").
21
+ * @property {Object} logStyle - Log styling option.
22
+ * @property {string} logStyle.type - The type of the logStyle option (boolean).
23
+ * @property {boolean} logStyle.default - The default value for log styling (true).
24
+ * @property {Object} timestamp - Timestamp display option.
25
+ * @property {string} timestamp.type - The type of the timestamp option (boolean).
26
+ * @property {boolean} timestamp.default - The default value for timestamp display (true).
27
+ * @property {Object} banner - Banner display option.
28
+ * @property {string} banner.type - The type of the banner option (boolean).
29
+ * @property {boolean} banner.default - The default value for banner display (false).
30
+ * @memberOf module:utils
31
+ */
32
+ export declare const DefaultCommandOptions: {
33
+ verbose: {
34
+ type: string;
35
+ short: string;
36
+ default: undefined;
37
+ };
38
+ version: {
39
+ type: string;
40
+ short: string;
41
+ default: undefined;
42
+ };
43
+ help: {
44
+ type: string;
45
+ short: string;
46
+ default: boolean;
47
+ };
48
+ logLevel: {
49
+ type: string;
50
+ default: string;
51
+ };
52
+ logStyle: {
53
+ type: string;
54
+ default: boolean;
55
+ };
56
+ timestamp: {
57
+ type: string;
58
+ default: boolean;
59
+ };
60
+ banner: {
61
+ type: string;
62
+ default: boolean;
63
+ };
64
+ };
65
+ /**
66
+ * @description Default command values derived from DefaultCommandOptions.
67
+ * @summary Creates an object with the default values of all options defined in DefaultCommandOptions.
68
+ * @const DefaultCommandValues
69
+ * @typedef {Object} DefaultCommandValues
70
+ * @property {unknown} [key: string] - The default value for each option in DefaultCommandOptions.
71
+ * @memberOf module:utils
72
+ */
73
+ export declare const DefaultCommandValues: {
74
+ [k in keyof typeof DefaultCommandOptions]: unknown;
75
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./command.cjs";
2
+ export * from "./commands.cjs";
3
+ export * from "./constants.cjs";
4
+ export * from "./types.cjs";
@@ -0,0 +1,4 @@
1
+ export * from "./command.js";
2
+ export * from "./commands.js";
3
+ export * from "./constants.js";
4
+ export * from "./types.js";
@@ -0,0 +1,30 @@
1
+ import { ParseArgsOptionConfig } from "../input/types.cjs";
2
+ import { LoggingConfig } from "@decaf-ts/logging";
3
+ /**
4
+ * @description Interface for input options.
5
+ * @summary Defines the structure of input options for CLI commands.
6
+ * @interface InputOptions
7
+ * @property {number} [verbose] - The verbosity level.
8
+ * @property {boolean} [version] - Flag to show version information.
9
+ * @property {boolean} [banner] - Flag to show banner.
10
+ * @property {boolean} [help] - Flag to show help information.
11
+ * @memberOf module:utils
12
+ */
13
+ export type InputOptions = {
14
+ verbose?: number;
15
+ version?: boolean;
16
+ banner?: boolean;
17
+ help?: boolean;
18
+ };
19
+ /**
20
+ * @description Type definition for command options.
21
+ * @summary Combines input options, input option configurations, and logging configurations into a single type.
22
+ * @template I - The type of additional input options specific to the command.
23
+ * @typedef {Object} CommandOptions
24
+ * @memberOf module:utils
25
+ */
26
+ export type CommandOptions<I> = I & Partial<{
27
+ [k in keyof InputOptions]: ParseArgsOptionConfig;
28
+ }> & Partial<{
29
+ [k in keyof LoggingConfig]: ParseArgsOptionConfig;
30
+ }>;
@@ -0,0 +1,30 @@
1
+ import { ParseArgsOptionConfig } from "../input/types.js";
2
+ import { LoggingConfig } from "@decaf-ts/logging";
3
+ /**
4
+ * @description Interface for input options.
5
+ * @summary Defines the structure of input options for CLI commands.
6
+ * @interface InputOptions
7
+ * @property {number} [verbose] - The verbosity level.
8
+ * @property {boolean} [version] - Flag to show version information.
9
+ * @property {boolean} [banner] - Flag to show banner.
10
+ * @property {boolean} [help] - Flag to show help information.
11
+ * @memberOf module:utils
12
+ */
13
+ export type InputOptions = {
14
+ verbose?: number;
15
+ version?: boolean;
16
+ banner?: boolean;
17
+ help?: boolean;
18
+ };
19
+ /**
20
+ * @description Type definition for command options.
21
+ * @summary Combines input options, input option configurations, and logging configurations into a single type.
22
+ * @template I - The type of additional input options specific to the command.
23
+ * @typedef {Object} CommandOptions
24
+ * @memberOf module:utils
25
+ */
26
+ export type CommandOptions<I> = I & Partial<{
27
+ [k in keyof InputOptions]: ParseArgsOptionConfig;
28
+ }> & Partial<{
29
+ [k in keyof LoggingConfig]: ParseArgsOptionConfig;
30
+ }>;
@@ -0,0 +1,38 @@
1
+ export * from "./cli.cjs";
2
+ export * from "./input.cjs";
3
+ export * from "./output.cjs";
4
+ export * from "./utils.cjs";
5
+ export * from "./writers.cjs";
6
+ export * from "./release-chain.cjs";
7
+ /**
8
+ * @module utils
9
+ * @description Utilities and building blocks for Decaf-TS CLI and scripting.
10
+ * @summary Aggregates CLI command infrastructure, input helpers, output writers, filesystem/network utilities,
11
+ * and shared types. Consumers typically use {@link Command}, {@link UserInput}, {@link StandardOutputWriter},
12
+ * {@link printBanner}, and utilities from {@link module:utils|utils}.
13
+ *
14
+ * This entrypoint re-exports subpackages:
15
+ * - CLI framework under `./cli` (command base, options, built-in commands)
16
+ * - Input helpers under `./input` (prompting and arg parsing)
17
+ * - Output helpers under `./output` (banner and styling)
18
+ * - General utilities under `./utils` (fs, http, exec, types)
19
+ * - Writers under `./writers` (stdout/stderr processors)
20
+ *
21
+ * Note: Individual exports are documented in their source files.
22
+ */
23
+ /**
24
+ * @description Represents the current version of the module.
25
+ * @summary Stores the version for the @decaf-ts/utils package. The build replaces
26
+ * the placeholder with the actual version number at publish time.
27
+ * @const VERSION
28
+ * @memberOf module:utils
29
+ */
30
+ export declare const VERSION = "1.1.0";
31
+ /**
32
+ * @description Represents the current version of the module.
33
+ * @summary Stores the version for the @decaf-ts/utils package. The build replaces
34
+ * the placeholder with the actual version number at publish time.
35
+ * @const VERSION
36
+ * @memberOf module:utils
37
+ */
38
+ export declare const PACKAGE_NAME = "@decaf-ts/utils";
@@ -0,0 +1,38 @@
1
+ export * from "./cli.js";
2
+ export * from "./input.js";
3
+ export * from "./output.js";
4
+ export * from "./utils.js";
5
+ export * from "./writers.js";
6
+ export * from "./release-chain.js";
7
+ /**
8
+ * @module utils
9
+ * @description Utilities and building blocks for Decaf-TS CLI and scripting.
10
+ * @summary Aggregates CLI command infrastructure, input helpers, output writers, filesystem/network utilities,
11
+ * and shared types. Consumers typically use {@link Command}, {@link UserInput}, {@link StandardOutputWriter},
12
+ * {@link printBanner}, and utilities from {@link module:utils|utils}.
13
+ *
14
+ * This entrypoint re-exports subpackages:
15
+ * - CLI framework under `./cli` (command base, options, built-in commands)
16
+ * - Input helpers under `./input` (prompting and arg parsing)
17
+ * - Output helpers under `./output` (banner and styling)
18
+ * - General utilities under `./utils` (fs, http, exec, types)
19
+ * - Writers under `./writers` (stdout/stderr processors)
20
+ *
21
+ * Note: Individual exports are documented in their source files.
22
+ */
23
+ /**
24
+ * @description Represents the current version of the module.
25
+ * @summary Stores the version for the @decaf-ts/utils package. The build replaces
26
+ * the placeholder with the actual version number at publish time.
27
+ * @const VERSION
28
+ * @memberOf module:utils
29
+ */
30
+ export declare const VERSION = "1.1.0";
31
+ /**
32
+ * @description Represents the current version of the module.
33
+ * @summary Stores the version for the @decaf-ts/utils package. The build replaces
34
+ * the placeholder with the actual version number at publish time.
35
+ * @const VERSION
36
+ * @memberOf module:utils
37
+ */
38
+ export declare const PACKAGE_NAME = "@decaf-ts/utils";
@@ -27,7 +27,7 @@ export * from "./release-chain";
27
27
  * @const VERSION
28
28
  * @memberOf module:utils
29
29
  */
30
- export declare const VERSION = "1.0.10";
30
+ export declare const VERSION = "1.1.0";
31
31
  /**
32
32
  * @description Represents the current version of the module.
33
33
  * @summary Stores the version for the @decaf-ts/utils package. The build replaces
@@ -0,0 +1,2 @@
1
+ export * from './input.cjs';
2
+ export * from './types.cjs';
@@ -0,0 +1,2 @@
1
+ export * from './input.js';
2
+ export * from './types.js';