@decaf-ts/utils 1.2.2 → 1.3.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 (60) 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 +30 -3
  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 +30 -3
  10. package/lib/esm/cli/commands/build-scripts.js.map +1 -1
  11. package/lib/esm/index.js +1 -1
  12. package/lib/types/cli/commands/build-scripts.d.cts +1 -0
  13. package/lib/types/cli/commands/build-scripts.d.mts +1 -0
  14. package/lib/types/cli/index.d.cts +1 -1
  15. package/lib/types/cli/index.d.mts +1 -1
  16. package/lib/types/index.d.cts +7 -7
  17. package/lib/types/index.d.mts +7 -7
  18. package/lib/types/tests/utils.d.cts +1 -1
  19. package/lib/types/tests/utils.d.mts +1 -1
  20. package/package.json +1 -1
  21. package/lib/types/assets/slogans.d.ts +0 -19
  22. package/lib/types/bin/build-scripts.d.ts +0 -1
  23. package/lib/types/bin/release-chain-dispatch.d.ts +0 -1
  24. package/lib/types/bin/release-chain.d.ts +0 -1
  25. package/lib/types/bin/tag-release.d.ts +0 -1
  26. package/lib/types/cli/command.d.ts +0 -104
  27. package/lib/types/cli/commands/build-scripts.d.ts +0 -148
  28. package/lib/types/cli/commands/index.d.ts +0 -3
  29. package/lib/types/cli/commands/release-chain.d.ts +0 -62
  30. package/lib/types/cli/commands/tag-release.d.ts +0 -105
  31. package/lib/types/cli/constants.d.ts +0 -75
  32. package/lib/types/cli/index.d.ts +0 -4
  33. package/lib/types/cli/types.d.ts +0 -30
  34. package/lib/types/index.d.ts +0 -38
  35. package/lib/types/input/index.d.ts +0 -2
  36. package/lib/types/input/input.d.ts +0 -517
  37. package/lib/types/input/types.d.ts +0 -159
  38. package/lib/types/output/common.d.ts +0 -53
  39. package/lib/types/output/index.d.ts +0 -1
  40. package/lib/types/release-chain/index.d.ts +0 -43
  41. package/lib/types/tests/Consumer.d.ts +0 -151
  42. package/lib/types/tests/ProducerChildProcess.d.ts +0 -18
  43. package/lib/types/tests/TestReporter.d.ts +0 -245
  44. package/lib/types/tests/index.d.ts +0 -4
  45. package/lib/types/tests/jestPerformanceRunner.d.ts +0 -37
  46. package/lib/types/tests/utils.d.ts +0 -5
  47. package/lib/types/utils/constants.d.ts +0 -65
  48. package/lib/types/utils/fs.d.ts +0 -259
  49. package/lib/types/utils/http.d.ts +0 -41
  50. package/lib/types/utils/index.d.ts +0 -6
  51. package/lib/types/utils/md.d.ts +0 -156
  52. package/lib/types/utils/performanceRunner.d.ts +0 -129
  53. package/lib/types/utils/timeout.d.ts +0 -12
  54. package/lib/types/utils/types.d.ts +0 -112
  55. package/lib/types/utils/utils.d.ts +0 -133
  56. package/lib/types/writers/OutputWriter.d.ts +0 -49
  57. package/lib/types/writers/RegexpOutputWriter.d.ts +0 -110
  58. package/lib/types/writers/StandardOutputWriter.d.ts +0 -130
  59. package/lib/types/writers/index.d.ts +0 -4
  60. package/lib/types/writers/types.d.ts +0 -29
@@ -1,112 +0,0 @@
1
- import { ChildProcessWithoutNullStreams } from "child_process";
2
- import { Environment } from "@decaf-ts/logging";
3
- /**
4
- * @description Defines the structure for promise resolution and rejection.
5
- * @summary Provides methods to resolve or reject a promise.
6
- * @template R - The type of the resolved value.
7
- * @template E - The type of the error value, defaulting to Error.
8
- * @typedef {Object} PromiseExecutor
9
- * @property {function(R): void} resolve - Function to resolve the promise.
10
- * @property {function(E): void} reject - Function to reject the promise.
11
- * @memberOf module:utils
12
- */
13
- export interface PromiseExecutor<R, E = Error> {
14
- resolve: (value: R | PromiseLike<R>) => void;
15
- reject: (error: E) => void;
16
- }
17
- /**
18
- * @description Represents the result of a command execution.
19
- * @summary Extends Promise with additional properties related to the command execution.
20
- * This interface provides a comprehensive way to handle and interact with the results
21
- * of an asynchronous command execution, including access to the command details,
22
- * output logs, and the ability to abort the execution.
23
- *
24
- * @template R - The type of the resolved value, defaulting to void.
25
- * @interface CommandResult
26
- * @extends Promise<R>
27
- * @memberOf module:utils
28
- */
29
- export interface CommandResult<R = void> {
30
- promise: Promise<R>;
31
- /**
32
- * @description Controller to abort the command execution.
33
- * @summary Provides a mechanism to cancel the ongoing command execution.
34
- */
35
- abort: AbortController;
36
- /**
37
- * @description The executed command string.
38
- * @summary Contains the actual command that was executed.
39
- */
40
- command: string;
41
- /**
42
- * @description The child process object.
43
- * @summary Represents the Node.js child process that was spawned to execute the command.
44
- */
45
- cmd?: ChildProcessWithoutNullStreams;
46
- /**
47
- * @description Array of stdout logs.
48
- * @summary Contains all the standard output messages produced during the command execution.
49
- */
50
- logs: string[];
51
- /**
52
- * @description Array of stderr logs.
53
- * @summary Contains all the standard error messages produced during the command execution.
54
- */
55
- errs: string[];
56
- /**
57
- * @description allows chaining commands.
58
- * @summary allows chaining commands (or piping).
59
- */
60
- pipe: <E>(cb: (r: R) => E) => Promise<E>;
61
- }
62
- /**
63
- * @description Factory type for creating Environment instances.
64
- * @summary Defines a function type that creates and returns Environment instances.
65
- *
66
- * @template T - The type of object the Environment will accumulate.
67
- * @template E - The specific Environment type to be created, extending Environment<T>.
68
- * @typedef {function(...unknown[]): E} EnvironmentFactory
69
- * @memberOf module:utils
70
- */
71
- export type EnvironmentFactory<T extends object, E extends Environment<T>> = (...args: unknown[]) => E;
72
- /**
73
- * @description Map of project dependencies with detailed information.
74
- * @summary Represents the structure of project dependencies categorized by type (production, development, peer).
75
- * Each category contains an array of objects with name and version information.
76
- *
77
- * @typedef {Object} DependencyMap
78
- * @property {Array<{name: string, version: string}>} prod - Production dependencies with name and version.
79
- * @property {Array<{name: string, version: string}>} dev - Development dependencies with name and version.
80
- * @property {Array<{name: string, version: string}>} peer - Peer dependencies with name and version.
81
- * @memberOf module:utils
82
- */
83
- export type DependencyMap = {
84
- prod: {
85
- name: string;
86
- version: string;
87
- }[];
88
- dev: {
89
- name: string;
90
- version: string;
91
- }[];
92
- peer: {
93
- name: string;
94
- version: string;
95
- }[];
96
- };
97
- /**
98
- * @description Simplified map of project dependencies.
99
- * @summary Represents a simplified structure of project dependencies categorized by type.
100
- * Each category contains an optional array of dependency names without version information.
101
- *
102
- * @typedef {Object} SimpleDependencyMap
103
- * @property {string[]} [prod] - Optional array of production dependency names.
104
- * @property {string[]} [dev] - Optional array of development dependency names.
105
- * @property {string[]} [peer] - Optional array of peer dependency names.
106
- * @memberOf module:utils
107
- */
108
- export type SimpleDependencyMap = {
109
- prod?: string[];
110
- dev?: string[];
111
- peer?: string[];
112
- };
@@ -1,133 +0,0 @@
1
- import { ChildProcessWithoutNullStreams, SpawnOptionsWithoutStdio } from "child_process";
2
- import { StandardOutputWriter } from "../writers/StandardOutputWriter";
3
- import { CommandResult } from "./types";
4
- import { OutputWriterConstructor } from "../writers/types";
5
- import { Logger } from "@decaf-ts/logging";
6
- /**
7
- * @description Creates a locked version of a function.
8
- * @summary This higher-order function takes a function and returns a new function that ensures
9
- * sequential execution of the original function, even when called multiple times concurrently.
10
- * It uses a Promise-based locking mechanism to queue function calls.
11
- *
12
- * @template R - The return type of the input function.
13
- *
14
- * @param f - The function to be locked. It can take any number of parameters and return a value of type R.
15
- * @return A new function with the same signature as the input function, but with sequential execution guaranteed.
16
- *
17
- * @function lockify
18
- *
19
- * @mermaid
20
- * sequenceDiagram
21
- * participant Caller
22
- * participant LockedFunction
23
- * participant OriginalFunction
24
- * Caller->>LockedFunction: Call with params
25
- * LockedFunction->>LockedFunction: Check current lock
26
- * alt Lock is resolved
27
- * LockedFunction->>OriginalFunction: Execute with params
28
- * OriginalFunction-->>LockedFunction: Return result
29
- * LockedFunction-->>Caller: Return result
30
- * else Lock is pending
31
- * LockedFunction->>LockedFunction: Queue execution
32
- * LockedFunction-->>Caller: Return promise
33
- * Note over LockedFunction: Wait for previous execution
34
- * LockedFunction->>OriginalFunction: Execute with params
35
- * OriginalFunction-->>LockedFunction: Return result
36
- * LockedFunction-->>Caller: Resolve promise with result
37
- * end
38
- * LockedFunction->>LockedFunction: Update lock
39
- *
40
- * @memberOf module:utils
41
- */
42
- export declare function lockify<R>(f: (...params: unknown[]) => R): (...params: unknown[]) => Promise<R>;
43
- /**
44
- * @description Chains multiple abort signals to a controller.
45
- * @summary Creates a mechanism where multiple abort signals can trigger a single abort controller.
46
- * This is useful for coordinating cancellation across multiple asynchronous operations.
47
- *
48
- * @param {AbortController} controller - The abort controller to be triggered by signals.
49
- * @param {...AbortSignal} signals - One or more abort signals that can trigger the controller.
50
- * @return {AbortController} The input controller, now connected to the signals.
51
- *
52
- * @function chainAbortController
53
- *
54
- * @memberOf module:utils
55
- */
56
- export declare function chainAbortController(controller: AbortController, ...signals: AbortSignal[]): AbortController;
57
- /**
58
- * @description Creates a new controller chained to multiple abort signals.
59
- * @summary Creates a new abort controller that will be triggered if any of the provided signals are aborted.
60
- *
61
- * @param {...AbortSignal} signals - One or more abort signals that can trigger the new controller.
62
- * @return {AbortController} A new abort controller connected to the signals.
63
- *
64
- * @function chainAbortController
65
- *
66
- * @memberOf module:utils
67
- */
68
- export declare function chainAbortController(...signals: AbortSignal[]): AbortController;
69
- /**
70
- * @description Spawns a command as a child process with output handling.
71
- * @summary Creates a child process to execute a command with support for piping multiple commands,
72
- * custom output handling, and abort control. This function handles the low-level details of
73
- * spawning processes and connecting their inputs/outputs when piping is used.
74
- *
75
- * @template R - The type of the processed output, defaulting to string.
76
- * @param {StandardOutputWriter<R>} output - The output writer to handle command output.
77
- * @param {string} command - The command to execute, can include pipe operators.
78
- * @param {SpawnOptionsWithoutStdio} opts - Options for the spawned process.
79
- * @param {AbortController} abort - Controller to abort the command execution.
80
- * @param {Logger} logger - Logger for recording command execution details.
81
- * @return {ChildProcessWithoutNullStreams} The spawned child process.
82
- *
83
- * @function spawnCommand
84
- *
85
- * @memberOf module:utils
86
- */
87
- export declare function spawnCommand<R = string>(output: StandardOutputWriter<R>, command: string, opts: SpawnOptionsWithoutStdio, abort: AbortController, logger: Logger): ChildProcessWithoutNullStreams;
88
- /**
89
- * @description Executes a command asynchronously with customizable output handling.
90
- * @summary This function runs a shell command as a child process, providing fine-grained
91
- * control over its execution and output handling. It supports custom output writers,
92
- * allows for command abortion, and captures both stdout and stderr.
93
- *
94
- * @template R - The type of the resolved value from the command execution.
95
- *
96
- * @param command - The command to run, either as a string or an array of strings.
97
- * @param opts - Spawn options for the child process. Defaults to an empty object.
98
- * @param outputConstructor - Constructor for the output writer. Defaults to StandardOutputWriter.
99
- * @param args - Additional arguments to pass to the output constructor.
100
- * @return {CommandResult} A promise that resolves to the command result of type R.
101
- *
102
- * @function runCommand
103
- *
104
- * @mermaid
105
- * sequenceDiagram
106
- * participant Caller
107
- * participant runCommand
108
- * participant OutputWriter
109
- * participant ChildProcess
110
- * Caller->>runCommand: Call with command and options
111
- * runCommand->>OutputWriter: Create new instance
112
- * runCommand->>OutputWriter: Parse command
113
- * runCommand->>ChildProcess: Spawn process
114
- * ChildProcess-->>runCommand: Return process object
115
- * runCommand->>ChildProcess: Set up event listeners
116
- * loop For each stdout data
117
- * ChildProcess->>runCommand: Emit stdout data
118
- * runCommand->>OutputWriter: Handle stdout data
119
- * end
120
- * loop For each stderr data
121
- * ChildProcess->>runCommand: Emit stderr data
122
- * runCommand->>OutputWriter: Handle stderr data
123
- * end
124
- * ChildProcess->>runCommand: Emit error (if any)
125
- * runCommand->>OutputWriter: Handle error
126
- * ChildProcess->>runCommand: Emit exit
127
- * runCommand->>OutputWriter: Handle exit
128
- * OutputWriter-->>runCommand: Resolve or reject promise
129
- * runCommand-->>Caller: Return CommandResult
130
- *
131
- * @memberOf module:utils
132
- */
133
- export declare function runCommand<R = string>(command: string, opts?: SpawnOptionsWithoutStdio, outputConstructor?: OutputWriterConstructor<R, StandardOutputWriter<R>, Error>, ...args: unknown[]): CommandResult<R>;
@@ -1,49 +0,0 @@
1
- /**
2
- * @description Defines the structure for output writing operations.
3
- * @summary The OutputWriter interface provides a standardized set of methods for handling
4
- * various types of output in a command-line interface (CLI) application. It includes
5
- * methods for writing data, handling errors, and managing the program's exit process.
6
- * This interface allows for consistent output handling across different parts of the application.
7
- *
8
- * @interface OutputWriter
9
- * @memberOf module:utils
10
- */
11
- export interface OutputWriter {
12
- /**
13
- * @description Handles the output of data chunks.
14
- * @summary Processes and writes a chunk of data to the output stream.
15
- * This method is typically used for standard output operations.
16
- *
17
- * @param chunk - The data to be written. Can be of any type.
18
- * @return void
19
- */
20
- data(chunk: any): void;
21
- /**
22
- * @description Handles error output.
23
- * @summary Processes and writes error information to the error output stream.
24
- * This method is used for non-critical errors or warnings.
25
- *
26
- * @param chunk - The error data to be written. Can be of any type.
27
- * @return void
28
- */
29
- error(chunk: any): void;
30
- /**
31
- * @description Handles critical errors.
32
- * @summary Processes and writes critical error information.
33
- * This method is used for handling and reporting Error objects.
34
- *
35
- * @param err - The Error object to be processed and written.
36
- * @return void
37
- */
38
- errors(err: Error): void;
39
- /**
40
- * @description Manages the program exit process.
41
- * @summary Handles the termination of the program with a specified exit code.
42
- * This method is called when the program needs to exit, either successfully or due to an error.
43
- *
44
- * @param code - The exit code to be used when terminating the program.
45
- * @param logs - Array of log messages to be processed before exiting.
46
- * @return void
47
- */
48
- exit(code: number, logs: string[]): void;
49
- }
@@ -1,110 +0,0 @@
1
- import { StandardOutputWriter } from "./StandardOutputWriter";
2
- import { PromiseExecutor } from "../utils/types";
3
- /**
4
- * @description A specialized output writer that uses regular expressions to process output.
5
- * @summary This class extends StandardOutputWriter to provide regex-based output processing.
6
- * It allows for pattern matching in the output stream and can trigger specific actions
7
- * based on matched patterns.
8
- *
9
- * @template T - The type of the resolved value, defaulting to string.
10
- *
11
- * @param cmd - The command string to be executed.
12
- * @param lock - A PromiseExecutor to control the asynchronous flow.
13
- * @param regexp - A string or RegExp to match against the output.
14
- * @param flags - Optional flags for the RegExp constructor, defaults to "g".
15
- *
16
- * @class
17
- * @example
18
- * ```typescript
19
- * import { RegexpOutputWriter } from '@decaf-ts/utils';
20
- * import { PromiseExecutor } from '@decaf-ts/utils';
21
- *
22
- * // Create a promise executor
23
- * const executor: PromiseExecutor<string, Error> = {
24
- * resolve: (value) => console.log(`Resolved: ${value}`),
25
- * reject: (error) => console.error(`Rejected: ${error.message}`)
26
- * };
27
- *
28
- * // Create a regexp output writer that matches version numbers
29
- * const writer = new RegexpOutputWriter('node --version', executor, /v(\d+\.\d+\.\d+)/);
30
- *
31
- * // Use the writer to handle command output
32
- * writer.data('v14.17.0'); // This will automatically resolve with "v14.17.0"
33
- * ```
34
- *
35
- * @mermaid
36
- * sequenceDiagram
37
- * participant Client
38
- * participant RegexpOutputWriter
39
- * participant StandardOutputWriter
40
- * participant Logger
41
- *
42
- * Client->>RegexpOutputWriter: new RegexpOutputWriter(cmd, lock, regexp, flags)
43
- * RegexpOutputWriter->>StandardOutputWriter: super(cmd, lock)
44
- * StandardOutputWriter->>Logger: Logging.for(cmd)
45
- * RegexpOutputWriter->>RegexpOutputWriter: compile regexp
46
- *
47
- * Client->>RegexpOutputWriter: data(chunk)
48
- * RegexpOutputWriter->>StandardOutputWriter: super.data(chunk)
49
- * StandardOutputWriter->>Logger: logger.info(log)
50
- * RegexpOutputWriter->>RegexpOutputWriter: testAndResolve(chunk)
51
- * RegexpOutputWriter->>RegexpOutputWriter: test(chunk)
52
- * alt match found
53
- * RegexpOutputWriter->>RegexpOutputWriter: resolve(match[0])
54
- * RegexpOutputWriter->>StandardOutputWriter: resolve(match[0])
55
- * end
56
- *
57
- * Client->>RegexpOutputWriter: error(chunk)
58
- * RegexpOutputWriter->>StandardOutputWriter: super.error(chunk)
59
- * StandardOutputWriter->>Logger: logger.info(log)
60
- * RegexpOutputWriter->>RegexpOutputWriter: testAndReject(chunk)
61
- * RegexpOutputWriter->>RegexpOutputWriter: test(chunk)
62
- * alt match found
63
- * RegexpOutputWriter->>RegexpOutputWriter: reject(match[0])
64
- * RegexpOutputWriter->>StandardOutputWriter: reject(match[0])
65
- * end
66
- */
67
- export declare class RegexpOutputWriter extends StandardOutputWriter<string> {
68
- /**
69
- * @description The regular expression used for matching output.
70
- * @summary This readonly property stores the compiled RegExp used for pattern matching.
71
- */
72
- protected readonly regexp: RegExp;
73
- constructor(cmd: string, lock: PromiseExecutor<string, Error>, regexp: string | RegExp, flags?: string);
74
- /**
75
- * @description Tests the input data against the stored regular expression.
76
- * @summary Executes the regular expression on the input data and returns the match result.
77
- *
78
- * @param data - The string to test against the regular expression.
79
- * @return The result of the regular expression execution, or undefined if an error occurs.
80
- */
81
- private test;
82
- /**
83
- * @description Tests the data and resolves the promise if a match is found.
84
- * @summary Executes the test method and resolves the promise with the first match group if successful.
85
- *
86
- * @param data - The string to test against the regular expression.
87
- */
88
- protected testAndResolve(data: string): void;
89
- /**
90
- * @description Tests the data and rejects the promise if a match is found.
91
- * @summary Executes the test method and rejects the promise with the first match group if successful.
92
- *
93
- * @param data - The string to test against the regular expression.
94
- */
95
- protected testAndReject(data: string): void;
96
- /**
97
- * @description Processes incoming data chunks.
98
- * @summary Calls the parent class data method and then tests the data for a match to potentially resolve the promise.
99
- *
100
- * @param chunk - The data chunk to process.
101
- */
102
- data(chunk: any): void;
103
- /**
104
- * @description Processes incoming error chunks.
105
- * @summary Calls the parent class error method and then tests the data for a match to potentially reject the promise.
106
- *
107
- * @param chunk - The error chunk to process.
108
- */
109
- error(chunk: any): void;
110
- }
@@ -1,130 +0,0 @@
1
- import { OutputWriter } from "./OutputWriter";
2
- import { PromiseExecutor } from "../utils/types";
3
- import { OutputType } from "./types";
4
- import { Logger } from "@decaf-ts/logging";
5
- /**
6
- * @description A standard output writer for handling command execution output.
7
- * @summary This class implements the OutputWriter interface and provides methods for
8
- * handling various types of output from command execution, including standard output,
9
- * error output, and exit codes. It also includes utility methods for parsing commands
10
- * and resolving or rejecting promises based on execution results.
11
- *
12
- * @template R - The type of the resolved value, defaulting to string.
13
- *
14
- * @param cmd - The command string to be executed.
15
- * @param lock - A PromiseExecutor to control the asynchronous flow.
16
- * @param args - Additional arguments (unused in the current implementation).
17
- *
18
- * @class
19
- * @example
20
- * ```typescript
21
- * import { StandardOutputWriter } from '@decaf-ts/utils';
22
- * import { PromiseExecutor } from '@decaf-ts/utils';
23
- *
24
- * // Create a promise executor
25
- * const executor: PromiseExecutor<string> = {
26
- * resolve: (value) => console.log(`Resolved: ${value}`),
27
- * reject: (error) => console.error(`Rejected: ${error.message}`)
28
- * };
29
- *
30
- * // Create a standard output writer
31
- * const writer = new StandardOutputWriter('ls -la', executor);
32
- *
33
- * // Use the writer to handle command output
34
- * writer.data('File list output...');
35
- * writer.exit(0, ['Command executed successfully']);
36
- * ```
37
- *
38
- * @mermaid
39
- * sequenceDiagram
40
- * participant Client
41
- * participant StandardOutputWriter
42
- * participant Logger
43
- * participant PromiseExecutor
44
- *
45
- * Client->>StandardOutputWriter: new StandardOutputWriter(cmd, lock)
46
- * StandardOutputWriter->>Logger: Logging.for(cmd)
47
- *
48
- * Client->>StandardOutputWriter: data(chunk)
49
- * StandardOutputWriter->>StandardOutputWriter: log("stdout", chunk)
50
- * StandardOutputWriter->>Logger: logger.info(log)
51
- *
52
- * Client->>StandardOutputWriter: error(chunk)
53
- * StandardOutputWriter->>StandardOutputWriter: log("stderr", chunk)
54
- * StandardOutputWriter->>Logger: logger.info(log)
55
- *
56
- * Client->>StandardOutputWriter: exit(code, logs)
57
- * StandardOutputWriter->>StandardOutputWriter: log("stdout", exitMessage)
58
- * alt code === 0
59
- * StandardOutputWriter->>StandardOutputWriter: resolve(logs)
60
- * StandardOutputWriter->>PromiseExecutor: lock.resolve(reason)
61
- * else code !== 0
62
- * StandardOutputWriter->>StandardOutputWriter: reject(error)
63
- * StandardOutputWriter->>PromiseExecutor: lock.reject(reason)
64
- * end
65
- */
66
- export declare class StandardOutputWriter<R = string> implements OutputWriter {
67
- protected cmd: string;
68
- protected lock: PromiseExecutor<R>;
69
- protected logger: Logger;
70
- constructor(cmd: string, lock: PromiseExecutor<R>, ...args: unknown[]);
71
- /**
72
- * @description Logs output to the console.
73
- * @summary Formats and logs the given data with a timestamp and type indicator.
74
- *
75
- * @param type - The type of output (stdout or stderr).
76
- * @param data - The data to be logged.
77
- */
78
- protected log(type: OutputType, data: string | Buffer): void;
79
- /**
80
- * @description Handles standard output data.
81
- * @summary Logs the given chunk as standard output.
82
- *
83
- * @param chunk - The data chunk to be logged.
84
- */
85
- data(chunk: any): void;
86
- /**
87
- * @description Handles error output data.
88
- * @summary Logs the given chunk as error output.
89
- *
90
- * @param chunk - The error data chunk to be logged.
91
- */
92
- error(chunk: any): void;
93
- /**
94
- * @description Handles error objects.
95
- * @summary Logs the error message from the given Error object.
96
- *
97
- * @param err - The Error object to be logged.
98
- */
99
- errors(err: Error): void;
100
- /**
101
- * @description Handles the exit of a command.
102
- * @summary Logs the exit code and resolves or rejects the promise based on the code.
103
- *
104
- * @param code - The exit code of the command.
105
- * @param logs - Array of log messages to be processed before exiting.
106
- */
107
- exit(code: number | string, logs: string[]): void;
108
- /**
109
- * @description Parses a command string or array into components.
110
- * @summary Converts the command into a consistent format and stores it, then returns it split into command and arguments.
111
- *
112
- * @param command - The command as a string or array of strings.
113
- * @return A tuple containing the command and its arguments as separate elements.
114
- */
115
- parseCommand(command: string | string[]): [string, string[]];
116
- /**
117
- * @description Resolves the promise with a success message.
118
- * @summary Logs a success message and resolves the promise with the given reason.
119
- *
120
- * @param reason - The reason for resolving the promise.
121
- */
122
- protected resolve(reason: R): void;
123
- /**
124
- * @description Rejects the promise with an error message.
125
- * @summary Logs an error message and rejects the promise with the given reason.
126
- *
127
- * @param reason - The reason for rejecting the promise, either a number (exit code) or a string.
128
- */
129
- protected reject(reason: number | string | Error): void;
130
- }
@@ -1,4 +0,0 @@
1
- export * from './OutputWriter';
2
- export * from './RegexpOutputWriter';
3
- export * from './StandardOutputWriter';
4
- export * from './types';
@@ -1,29 +0,0 @@
1
- import { StandardOutputWriter } from "./StandardOutputWriter";
2
- import { PromiseExecutor } from "../utils/types";
3
- /**
4
- * @description Represents the type of output stream.
5
- * @summary A union type for standard output and standard error streams.
6
- * @typedef {("stdout" | "stderr")} OutputType
7
- * @memberOf module:utils
8
- */
9
- export type OutputType = "stdout" | "stderr";
10
- /**
11
- * @description Constructor type for output writers.
12
- * @summary Defines the structure for creating new output writer instances. This type represents
13
- * a constructor function that takes a PromiseExecutor and additional arguments to create
14
- * a new instance of an output writer. It allows for flexible creation of different types
15
- * of output writers while maintaining a consistent interface.
16
- *
17
- * @template R - The type of the resolved value, defaulting to string.
18
- * @template C - The type of the output writer, extending StandardOutputWriter<R>.
19
- * @template E - The type of the error value, defaulting to number.
20
- *
21
- * @param {PromiseExecutor<R, E>} lock - The promise executor for managing asynchronous operations.
22
- * @param {...unknown[]} args - Additional arguments passed to the constructor.
23
- * @return {C} An instance of the output writer.
24
- *
25
- * @memberOf module:utils
26
- */
27
- export type OutputWriterConstructor<R = string, C extends StandardOutputWriter<R> = StandardOutputWriter<R>, E = number> = {
28
- new (cmd: string, lock: PromiseExecutor<R, E>, ...args: unknown[]): C;
29
- };