@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,104 @@
1
+ import { ParseArgsResult } from "../input/types.js";
2
+ import { CommandOptions } from "./types.js";
3
+ import { DefaultCommandValues } from "./constants.js";
4
+ import { LoggedClass, Logger, LoggingConfig } from "@decaf-ts/logging";
5
+ /**
6
+ * @class Command
7
+ * @abstract
8
+ * @template I - The type of input options for the command.
9
+ * @template R - The return type of the command execution.
10
+ * @memberOf module:utils
11
+ * @description Abstract base class for command implementation.
12
+ * @summary Provides a structure for creating command-line interface commands with input handling, logging, and execution flow.
13
+ *
14
+ * @param {string} name - The name of the command.
15
+ * @param {CommandOptions<I>} [inputs] - The input options for the command.
16
+ * @param {string[]} [requirements] - The list of required dependencies for the command.
17
+ */
18
+ export declare abstract class Command<I, R> extends LoggedClass {
19
+ protected name: string;
20
+ protected inputs: CommandOptions<I>;
21
+ protected requirements: string[];
22
+ /**
23
+ * @static
24
+ * @description Static logger for the Command class.
25
+ * @type {Logger}
26
+ */
27
+ static log: Logger;
28
+ protected constructor(name: string, inputs?: CommandOptions<I>, requirements?: string[]);
29
+ /**
30
+ * @protected
31
+ * @async
32
+ * @description Checks if all required dependencies are present.
33
+ * @summary Retrieves the list of dependencies and compares it against the required dependencies for the command.
34
+ * @returns {Promise<void>} A promise that resolves when the check is complete.
35
+ *
36
+ * @mermaid
37
+ * sequenceDiagram
38
+ * participant Command
39
+ * participant getDependencies
40
+ * participant Set
41
+ * Command->>getDependencies: Call
42
+ * getDependencies-->>Command: Return {prod, dev, peer}
43
+ * Command->>Set: Create Set from prod, dev, peer
44
+ * Set-->>Command: Return unique dependencies
45
+ * Command->>Command: Compare against requirements
46
+ * alt Missing dependencies
47
+ * Command->>Command: Add to missing list
48
+ * end
49
+ * Note over Command: If missing.length > 0, handle missing dependencies
50
+ */
51
+ protected checkRequirements(): Promise<void>;
52
+ /**
53
+ * @protected
54
+ * @description Provides help information for the command.
55
+ * @summary This method should be overridden in derived classes to provide specific help information.
56
+ * @param {ParseArgsResult} args - The parsed command-line arguments.
57
+ * @returns {void}
58
+ */
59
+ protected help(args: ParseArgsResult): void;
60
+ /**
61
+ * @protected
62
+ * @abstract
63
+ * @description Runs the command with the provided arguments.
64
+ * @summary This method should be implemented in derived classes to define the command's behavior.
65
+ * @param {ParseArgsResult} answers - The parsed command-line arguments.
66
+ * @returns {Promise<R | string | void>} A promise that resolves with the command's result.
67
+ */
68
+ protected abstract run<R>(answers: LoggingConfig & typeof DefaultCommandValues & {
69
+ [k in keyof I]: unknown;
70
+ }): Promise<R | string | void>;
71
+ /**
72
+ * @async
73
+ * @description Executes the command.
74
+ * @summary This method handles the overall execution flow of the command, including parsing arguments,
75
+ * setting up logging, checking for version or help requests, and running the command.
76
+ * @returns {Promise<R | string | void>} A promise that resolves with the command's result.
77
+ *
78
+ * @mermaid
79
+ * sequenceDiagram
80
+ * participant Command
81
+ * participant UserInput
82
+ * participant Logging
83
+ * participant getPackageVersion
84
+ * participant printBanner
85
+ * Command->>UserInput: parseArgs(inputs)
86
+ * UserInput-->>Command: Return ParseArgsResult
87
+ * Command->>Command: Process options
88
+ * Command->>Logging: setConfig(options)
89
+ * alt version requested
90
+ * Command->>getPackageVersion: Call
91
+ * getPackageVersion-->>Command: Return version
92
+ * else help requested
93
+ * Command->>Command: help(args)
94
+ * else banner requested
95
+ * Command->>printBanner: Call
96
+ * end
97
+ * Command->>Command: run(args)
98
+ * alt error occurs
99
+ * Command->>Command: Log error
100
+ * end
101
+ * Command-->>Command: Return result
102
+ */
103
+ execute(): Promise<R | string | void>;
104
+ }
@@ -0,0 +1,148 @@
1
+ import { Command } from "../command.cjs";
2
+ import { CommandOptions } from "../types.cjs";
3
+ import { DefaultCommandValues } from "../constants.cjs";
4
+ import { LoggingConfig } from "@decaf-ts/logging";
5
+ declare module "@rollup/plugin-terser";
6
+ export declare function parseList(input?: string | string[]): string[];
7
+ export declare function packageToGlobal(name: string): string;
8
+ export declare function getPackageDependencies(): string[];
9
+ declare enum Modes {
10
+ CJS = "commonjs",
11
+ ESM = "es2022"
12
+ }
13
+ declare enum BuildMode {
14
+ BUILD = "build",
15
+ BUNDLE = "bundle",
16
+ ALL = "all"
17
+ }
18
+ declare const options: {
19
+ prod: {
20
+ type: string;
21
+ default: boolean;
22
+ };
23
+ dev: {
24
+ type: string;
25
+ default: boolean;
26
+ };
27
+ buildMode: {
28
+ type: string;
29
+ default: BuildMode;
30
+ };
31
+ includes: {
32
+ type: string;
33
+ default: string;
34
+ };
35
+ externals: {
36
+ type: string;
37
+ default: string;
38
+ };
39
+ docs: {
40
+ type: string;
41
+ default: boolean;
42
+ };
43
+ commands: {
44
+ type: string;
45
+ default: boolean;
46
+ };
47
+ entry: {
48
+ type: string;
49
+ default: string;
50
+ };
51
+ banner: {
52
+ type: string;
53
+ default: boolean;
54
+ };
55
+ validateNodeNext: {
56
+ type: string;
57
+ default: boolean;
58
+ };
59
+ };
60
+ /**
61
+ * @description A command-line script for building and bundling TypeScript projects.
62
+ * @summary This class provides a comprehensive build script that handles TypeScript compilation,
63
+ * bundling with Rollup, and documentation generation. It supports different build modes
64
+ * (development, production), module formats (CJS, ESM), and can be extended with custom
65
+ * configurations.
66
+ * @class BuildScripts
67
+ */
68
+ export declare class BuildScripts extends Command<CommandOptions<typeof options>, void> {
69
+ private replacements;
70
+ private readonly pkgVersion;
71
+ private readonly pkgName;
72
+ constructor();
73
+ /**
74
+ * @description Patches files with version and package name.
75
+ * @summary This method reads all files in a directory, finds placeholders for version
76
+ * and package name, and replaces them with the actual values from package.json.
77
+ * @param {string} p - The path to the directory containing the files to patch.
78
+ */
79
+ patchFiles(p: string): void;
80
+ private reportDiagnostics;
81
+ private formatDiagnostics;
82
+ private readConfigFile;
83
+ private evalDiagnostics;
84
+ private preCheckDiagnostics;
85
+ private checkTsDiagnostics;
86
+ private buildTs;
87
+ private build;
88
+ private rewriteRelativeJsSpecifiersToCjs;
89
+ private buildCjsFromEsm;
90
+ private applyTsConfigProfile;
91
+ private checkNodeNextCompatibility;
92
+ private buildTypes;
93
+ private rewriteRelativeDeclarationSpecifiers;
94
+ private emitDualDeclarationFiles;
95
+ private updatePackageJsonDualTypeExports;
96
+ /**
97
+ * @description Copies assets to the build output directory.
98
+ * @summary This method checks for the existence of an 'assets' directory in the source
99
+ * and copies it to the appropriate build output directory (lib or dist).
100
+ * @param {Modes} mode - The build mode (CJS or ESM).
101
+ */
102
+ copyAssets(mode: Modes): void;
103
+ /**
104
+ * @description Bundles the project using Rollup.
105
+ * @summary This method configures and runs Rollup to bundle the project. It handles
106
+ * different module formats, development and production builds, and external dependencies.
107
+ * @param {Modes} mode - The module format (CJS or ESM).
108
+ * @param {boolean} isDev - Whether it's a development build.
109
+ * @param {boolean} isLib - Whether it's a library build.
110
+ * @param {string} [entryFile="src/index.ts"] - The entry file for the bundle.
111
+ * @param {string} [nameOverride=this.pkgName] - The name of the output bundle.
112
+ * @param {string|string[]} [externalsArg] - A list of external dependencies.
113
+ * @param {string|string[]} [includeArg] - A list of dependencies to include.
114
+ * @returns {Promise<void>}
115
+ */
116
+ bundle(mode: Modes, isDev: boolean, isLib: boolean, entryFile?: string, nameOverride?: string, externalsArg?: string | string[], includeArg?: string | string[]): Promise<void>;
117
+ private buildByEnv;
118
+ /**
119
+ * @description Builds the project for development.
120
+ * @summary This method runs the build process with development-specific configurations.
121
+ * @param {BuildMode} [mode=BuildMode.ALL] - The build mode (build, bundle, or all).
122
+ * @param {string|string[]} [includesArg] - A list of dependencies to include.
123
+ * @param {string|string[]} [externalsArg] - A list of external dependencies.
124
+ * @returns {Promise<void>}
125
+ */
126
+ buildDev(entryFile?: string, mode?: BuildMode, validateNodeNext?: boolean, includesArg?: string | string[], externalsArg?: string | string[]): Promise<void>;
127
+ /**
128
+ * @description Builds the project for production.
129
+ * @summary This method runs the build process with production-specific configurations,
130
+ * including minification and other optimizations.
131
+ * @param {BuildMode} [mode=BuildMode.ALL] - The build mode (build, bundle, or all).
132
+ * @param {string|string[]} [includesArg] - A list of dependencies to include.
133
+ * @param {string|string[]} [externalsArg] - A list of external dependencies.
134
+ * @returns {Promise<void>}
135
+ */
136
+ buildProd(entryFile?: string, mode?: BuildMode, validateNodeNext?: boolean, includesArg?: string | string[], externalsArg?: string | string[]): Promise<void>;
137
+ /**
138
+ * @description Generates the project documentation.
139
+ * @summary This method uses JSDoc and other tools to generate HTML documentation for the project.
140
+ * It also patches the README.md file with version and package size information.
141
+ * @returns {Promise<void>}
142
+ */
143
+ buildDocs(): Promise<void>;
144
+ protected run<R>(answers: LoggingConfig & typeof DefaultCommandValues & {
145
+ [k in keyof typeof options]: unknown;
146
+ }): Promise<string | void | R>;
147
+ }
148
+ export {};
@@ -0,0 +1,148 @@
1
+ import { Command } from "../command.js";
2
+ import { CommandOptions } from "../types.js";
3
+ import { DefaultCommandValues } from "../constants.js";
4
+ import { LoggingConfig } from "@decaf-ts/logging";
5
+ declare module "@rollup/plugin-terser";
6
+ export declare function parseList(input?: string | string[]): string[];
7
+ export declare function packageToGlobal(name: string): string;
8
+ export declare function getPackageDependencies(): string[];
9
+ declare enum Modes {
10
+ CJS = "commonjs",
11
+ ESM = "es2022"
12
+ }
13
+ declare enum BuildMode {
14
+ BUILD = "build",
15
+ BUNDLE = "bundle",
16
+ ALL = "all"
17
+ }
18
+ declare const options: {
19
+ prod: {
20
+ type: string;
21
+ default: boolean;
22
+ };
23
+ dev: {
24
+ type: string;
25
+ default: boolean;
26
+ };
27
+ buildMode: {
28
+ type: string;
29
+ default: BuildMode;
30
+ };
31
+ includes: {
32
+ type: string;
33
+ default: string;
34
+ };
35
+ externals: {
36
+ type: string;
37
+ default: string;
38
+ };
39
+ docs: {
40
+ type: string;
41
+ default: boolean;
42
+ };
43
+ commands: {
44
+ type: string;
45
+ default: boolean;
46
+ };
47
+ entry: {
48
+ type: string;
49
+ default: string;
50
+ };
51
+ banner: {
52
+ type: string;
53
+ default: boolean;
54
+ };
55
+ validateNodeNext: {
56
+ type: string;
57
+ default: boolean;
58
+ };
59
+ };
60
+ /**
61
+ * @description A command-line script for building and bundling TypeScript projects.
62
+ * @summary This class provides a comprehensive build script that handles TypeScript compilation,
63
+ * bundling with Rollup, and documentation generation. It supports different build modes
64
+ * (development, production), module formats (CJS, ESM), and can be extended with custom
65
+ * configurations.
66
+ * @class BuildScripts
67
+ */
68
+ export declare class BuildScripts extends Command<CommandOptions<typeof options>, void> {
69
+ private replacements;
70
+ private readonly pkgVersion;
71
+ private readonly pkgName;
72
+ constructor();
73
+ /**
74
+ * @description Patches files with version and package name.
75
+ * @summary This method reads all files in a directory, finds placeholders for version
76
+ * and package name, and replaces them with the actual values from package.json.
77
+ * @param {string} p - The path to the directory containing the files to patch.
78
+ */
79
+ patchFiles(p: string): void;
80
+ private reportDiagnostics;
81
+ private formatDiagnostics;
82
+ private readConfigFile;
83
+ private evalDiagnostics;
84
+ private preCheckDiagnostics;
85
+ private checkTsDiagnostics;
86
+ private buildTs;
87
+ private build;
88
+ private rewriteRelativeJsSpecifiersToCjs;
89
+ private buildCjsFromEsm;
90
+ private applyTsConfigProfile;
91
+ private checkNodeNextCompatibility;
92
+ private buildTypes;
93
+ private rewriteRelativeDeclarationSpecifiers;
94
+ private emitDualDeclarationFiles;
95
+ private updatePackageJsonDualTypeExports;
96
+ /**
97
+ * @description Copies assets to the build output directory.
98
+ * @summary This method checks for the existence of an 'assets' directory in the source
99
+ * and copies it to the appropriate build output directory (lib or dist).
100
+ * @param {Modes} mode - The build mode (CJS or ESM).
101
+ */
102
+ copyAssets(mode: Modes): void;
103
+ /**
104
+ * @description Bundles the project using Rollup.
105
+ * @summary This method configures and runs Rollup to bundle the project. It handles
106
+ * different module formats, development and production builds, and external dependencies.
107
+ * @param {Modes} mode - The module format (CJS or ESM).
108
+ * @param {boolean} isDev - Whether it's a development build.
109
+ * @param {boolean} isLib - Whether it's a library build.
110
+ * @param {string} [entryFile="src/index.ts"] - The entry file for the bundle.
111
+ * @param {string} [nameOverride=this.pkgName] - The name of the output bundle.
112
+ * @param {string|string[]} [externalsArg] - A list of external dependencies.
113
+ * @param {string|string[]} [includeArg] - A list of dependencies to include.
114
+ * @returns {Promise<void>}
115
+ */
116
+ bundle(mode: Modes, isDev: boolean, isLib: boolean, entryFile?: string, nameOverride?: string, externalsArg?: string | string[], includeArg?: string | string[]): Promise<void>;
117
+ private buildByEnv;
118
+ /**
119
+ * @description Builds the project for development.
120
+ * @summary This method runs the build process with development-specific configurations.
121
+ * @param {BuildMode} [mode=BuildMode.ALL] - The build mode (build, bundle, or all).
122
+ * @param {string|string[]} [includesArg] - A list of dependencies to include.
123
+ * @param {string|string[]} [externalsArg] - A list of external dependencies.
124
+ * @returns {Promise<void>}
125
+ */
126
+ buildDev(entryFile?: string, mode?: BuildMode, validateNodeNext?: boolean, includesArg?: string | string[], externalsArg?: string | string[]): Promise<void>;
127
+ /**
128
+ * @description Builds the project for production.
129
+ * @summary This method runs the build process with production-specific configurations,
130
+ * including minification and other optimizations.
131
+ * @param {BuildMode} [mode=BuildMode.ALL] - The build mode (build, bundle, or all).
132
+ * @param {string|string[]} [includesArg] - A list of dependencies to include.
133
+ * @param {string|string[]} [externalsArg] - A list of external dependencies.
134
+ * @returns {Promise<void>}
135
+ */
136
+ buildProd(entryFile?: string, mode?: BuildMode, validateNodeNext?: boolean, includesArg?: string | string[], externalsArg?: string | string[]): Promise<void>;
137
+ /**
138
+ * @description Generates the project documentation.
139
+ * @summary This method uses JSDoc and other tools to generate HTML documentation for the project.
140
+ * It also patches the README.md file with version and package size information.
141
+ * @returns {Promise<void>}
142
+ */
143
+ buildDocs(): Promise<void>;
144
+ protected run<R>(answers: LoggingConfig & typeof DefaultCommandValues & {
145
+ [k in keyof typeof options]: unknown;
146
+ }): Promise<string | void | R>;
147
+ }
148
+ export {};
@@ -90,6 +90,9 @@ export declare class BuildScripts extends Command<CommandOptions<typeof options>
90
90
  private applyTsConfigProfile;
91
91
  private checkNodeNextCompatibility;
92
92
  private buildTypes;
93
+ private rewriteRelativeDeclarationSpecifiers;
94
+ private emitDualDeclarationFiles;
95
+ private updatePackageJsonDualTypeExports;
93
96
  /**
94
97
  * @description Copies assets to the build output directory.
95
98
  * @summary This method checks for the existence of an 'assets' directory in the source
@@ -0,0 +1,3 @@
1
+ export * from "./build-scripts.cjs";
2
+ export * from "./tag-release.cjs";
3
+ export * from "./release-chain.cjs";
@@ -0,0 +1,3 @@
1
+ export * from "./build-scripts.js";
2
+ export * from "./tag-release.js";
3
+ export * from "./release-chain.js";
@@ -0,0 +1,62 @@
1
+ import { Command } from "../command.cjs";
2
+ import { CommandOptions } from "../types.cjs";
3
+ import { DefaultCommandValues } from "../constants.cjs";
4
+ import { LoggingConfig } from "@decaf-ts/logging";
5
+ declare const releaseChainArgs: {
6
+ meta: {
7
+ type: string;
8
+ default: string;
9
+ };
10
+ branch: {
11
+ type: string;
12
+ default: string;
13
+ };
14
+ current: {
15
+ type: string;
16
+ default: string;
17
+ };
18
+ package: {
19
+ type: string;
20
+ default: string;
21
+ };
22
+ token: {
23
+ type: string;
24
+ default: string;
25
+ };
26
+ submoduleFile: {
27
+ type: string;
28
+ default: string;
29
+ };
30
+ submodulePath: {
31
+ type: string;
32
+ default: string;
33
+ };
34
+ workflow: {
35
+ type: string;
36
+ default: string;
37
+ };
38
+ repo: {
39
+ type: string;
40
+ default: string;
41
+ };
42
+ ref: {
43
+ type: string;
44
+ default: string;
45
+ };
46
+ targetBase: {
47
+ type: string;
48
+ default: string;
49
+ };
50
+ };
51
+ type ReleaseChainAnswerMap = {
52
+ [K in keyof typeof releaseChainArgs]: unknown;
53
+ };
54
+ export declare class ReleaseChainCommand extends Command<CommandOptions<typeof releaseChainArgs>, void> {
55
+ constructor();
56
+ protected run(options: LoggingConfig & typeof DefaultCommandValues & ReleaseChainAnswerMap): Promise<void>;
57
+ }
58
+ export declare class ReleaseChainDispatchCommand extends Command<CommandOptions<typeof releaseChainArgs>, void> {
59
+ constructor();
60
+ protected run(options: LoggingConfig & typeof DefaultCommandValues & ReleaseChainAnswerMap): Promise<void>;
61
+ }
62
+ export {};
@@ -0,0 +1,62 @@
1
+ import { Command } from "../command.js";
2
+ import { CommandOptions } from "../types.js";
3
+ import { DefaultCommandValues } from "../constants.js";
4
+ import { LoggingConfig } from "@decaf-ts/logging";
5
+ declare const releaseChainArgs: {
6
+ meta: {
7
+ type: string;
8
+ default: string;
9
+ };
10
+ branch: {
11
+ type: string;
12
+ default: string;
13
+ };
14
+ current: {
15
+ type: string;
16
+ default: string;
17
+ };
18
+ package: {
19
+ type: string;
20
+ default: string;
21
+ };
22
+ token: {
23
+ type: string;
24
+ default: string;
25
+ };
26
+ submoduleFile: {
27
+ type: string;
28
+ default: string;
29
+ };
30
+ submodulePath: {
31
+ type: string;
32
+ default: string;
33
+ };
34
+ workflow: {
35
+ type: string;
36
+ default: string;
37
+ };
38
+ repo: {
39
+ type: string;
40
+ default: string;
41
+ };
42
+ ref: {
43
+ type: string;
44
+ default: string;
45
+ };
46
+ targetBase: {
47
+ type: string;
48
+ default: string;
49
+ };
50
+ };
51
+ type ReleaseChainAnswerMap = {
52
+ [K in keyof typeof releaseChainArgs]: unknown;
53
+ };
54
+ export declare class ReleaseChainCommand extends Command<CommandOptions<typeof releaseChainArgs>, void> {
55
+ constructor();
56
+ protected run(options: LoggingConfig & typeof DefaultCommandValues & ReleaseChainAnswerMap): Promise<void>;
57
+ }
58
+ export declare class ReleaseChainDispatchCommand extends Command<CommandOptions<typeof releaseChainArgs>, void> {
59
+ constructor();
60
+ protected run(options: LoggingConfig & typeof DefaultCommandValues & ReleaseChainAnswerMap): Promise<void>;
61
+ }
62
+ export {};
@@ -0,0 +1,105 @@
1
+ import { Command } from "../command.cjs";
2
+ import { DefaultCommandValues } from "../index.cjs";
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 {};