depflow 3.0.0-dev.1 → 3.0.0-dev.11

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 (165) hide show
  1. package/README.md +108 -43
  2. package/dist/builder/Builder.d.ts +279 -0
  3. package/dist/builder/Builder.js +391 -0
  4. package/dist/builder/Builder.js.map +1 -0
  5. package/dist/cli/CLI.d.ts +157 -0
  6. package/dist/cli/CLI.js +214 -0
  7. package/dist/cli/CLI.js.map +1 -0
  8. package/dist/cli/DepFLowCLI.d.ts +93 -0
  9. package/dist/cli/DepFLowCLI.js +413 -0
  10. package/dist/cli/DepFLowCLI.js.map +1 -0
  11. package/dist/cli/Flags.d.ts +106 -0
  12. package/dist/cli/Flags.js +125 -0
  13. package/dist/cli/Flags.js.map +1 -0
  14. package/dist/cli/bin.js +68 -0
  15. package/dist/cli/bin.js.map +1 -0
  16. package/dist/config/Config.d.ts +690 -0
  17. package/dist/config/Config.js +45 -0
  18. package/dist/config/Config.js.map +1 -0
  19. package/dist/config/ImportMap.d.ts +60 -0
  20. package/dist/config/ImportMap.js +66 -0
  21. package/dist/config/ImportMap.js.map +1 -0
  22. package/dist/config/JsonSchema.d.ts +12 -0
  23. package/dist/config/JsonSchema.js +26 -0
  24. package/dist/config/JsonSchema.js.map +1 -0
  25. package/dist/config/Settings.d.ts +201 -0
  26. package/dist/config/Settings.js +191 -0
  27. package/dist/config/Settings.js.map +1 -0
  28. package/dist/config/TSConfig.d.ts +73 -0
  29. package/dist/config/TSConfig.js +73 -0
  30. package/dist/config/TSConfig.js.map +1 -0
  31. package/dist/config/codecs/JsonCodec.d.ts +30 -0
  32. package/dist/config/codecs/JsonCodec.js +31 -0
  33. package/dist/config/codecs/JsonCodec.js.map +1 -0
  34. package/dist/config/codecs/YamlCodec.d.ts +62 -0
  35. package/dist/config/codecs/YamlCodec.js +89 -0
  36. package/dist/config/codecs/YamlCodec.js.map +1 -0
  37. package/dist/dependency/DepUtils.d.ts +50 -0
  38. package/dist/dependency/DepUtils.js +71 -0
  39. package/dist/dependency/DepUtils.js.map +1 -0
  40. package/dist/dependency/Dependency.d.ts +81 -0
  41. package/dist/dependency/Dependency.js +71 -0
  42. package/dist/dependency/Dependency.js.map +1 -0
  43. package/dist/dependency/Git.d.ts +75 -0
  44. package/dist/dependency/Git.js +97 -0
  45. package/dist/dependency/Git.js.map +1 -0
  46. package/dist/dependency/GitDependency.d.ts +30 -0
  47. package/dist/dependency/GitDependency.js +79 -0
  48. package/dist/dependency/GitDependency.js.map +1 -0
  49. package/dist/dependency/NpmDependency.d.ts +27 -0
  50. package/dist/dependency/NpmDependency.js +91 -0
  51. package/dist/dependency/NpmDependency.js.map +1 -0
  52. package/dist/resolve/AliasCompiler.d.ts +45 -0
  53. package/dist/resolve/AliasCompiler.js +84 -0
  54. package/dist/resolve/AliasCompiler.js.map +1 -0
  55. package/{build/support/PathResolver → dist/resolve}/PathResolver.d.ts +26 -9
  56. package/dist/resolve/PathResolver.js +133 -0
  57. package/dist/resolve/PathResolver.js.map +1 -0
  58. package/dist/resolve/PathRewriter.d.ts +24 -0
  59. package/{build/support/PathResolver → dist/resolve}/PathRewriter.js +21 -11
  60. package/dist/resolve/PathRewriter.js.map +1 -0
  61. package/dist/schema/Config/Builder.d.ts +496 -0
  62. package/dist/schema/Config/Builder.js +78 -0
  63. package/dist/schema/Config/Builder.js.map +1 -0
  64. package/dist/schema/Config/Config.d.ts +673 -0
  65. package/dist/schema/Config/Config.js +62 -0
  66. package/dist/schema/Config/Config.js.map +1 -0
  67. package/dist/schema/Config/Dependency.d.ts +878 -0
  68. package/dist/schema/Config/Dependency.js +80 -0
  69. package/dist/schema/Config/Dependency.js.map +1 -0
  70. package/dist/schema/Config/Extractor.d.ts +157 -0
  71. package/dist/schema/Config/Extractor.js +43 -0
  72. package/dist/schema/Config/Extractor.js.map +1 -0
  73. package/dist/schema/Config/Resolver.d.ts +87 -0
  74. package/dist/schema/Config/Resolver.js +43 -0
  75. package/dist/schema/Config/Resolver.js.map +1 -0
  76. package/dist/schema/Config/Transform.d.ts +90 -0
  77. package/dist/schema/Config/Transform.js +51 -0
  78. package/dist/schema/Config/Transform.js.map +1 -0
  79. package/dist/schema/Defaults.d.ts +20 -0
  80. package/dist/schema/Defaults.js +24 -0
  81. package/dist/schema/Defaults.js.map +1 -0
  82. package/dist/schema/ImportMap.d.ts +30 -0
  83. package/dist/schema/ImportMap.js +28 -0
  84. package/dist/schema/ImportMap.js.map +1 -0
  85. package/dist/schema/TSConfig.d.ts +70 -0
  86. package/dist/schema/TSConfig.js +39 -0
  87. package/dist/schema/TSConfig.js.map +1 -0
  88. package/dist/schema/schema.d.ts +38 -0
  89. package/dist/schema/schema.js +40 -0
  90. package/dist/schema/schema.js.map +1 -0
  91. package/dist/task/Command.d.ts +287 -0
  92. package/dist/task/Command.js +404 -0
  93. package/dist/task/Command.js.map +1 -0
  94. package/dist/task/Group.d.ts +15 -0
  95. package/dist/task/Group.js +29 -0
  96. package/dist/task/Group.js.map +1 -0
  97. package/dist/task/OutputPolicy.d.ts +262 -0
  98. package/dist/task/OutputPolicy.js +364 -0
  99. package/dist/task/OutputPolicy.js.map +1 -0
  100. package/dist/task/Task.d.ts +210 -0
  101. package/dist/task/Task.js +312 -0
  102. package/dist/task/Task.js.map +1 -0
  103. package/package.json +16 -14
  104. package/.gitignore +0 -7
  105. package/build/cli/DepFLowCLI.d.ts +0 -15
  106. package/build/cli/DepFLowCLI.js +0 -223
  107. package/build/cli/DepFLowCLI.js.map +0 -1
  108. package/build/cli/bin.js +0 -41
  109. package/build/cli/bin.js.map +0 -1
  110. package/build/config/Config.d.ts +0 -28
  111. package/build/config/Config.js +0 -46
  112. package/build/config/Config.js.map +0 -1
  113. package/build/config/ImportMap.d.ts +0 -37
  114. package/build/config/ImportMap.js +0 -82
  115. package/build/config/ImportMap.js.map +0 -1
  116. package/build/config/Tsconfig.d.ts +0 -57
  117. package/build/config/Tsconfig.js +0 -100
  118. package/build/config/Tsconfig.js.map +0 -1
  119. package/build/config/schemas.d.ts +0 -1194
  120. package/build/config/schemas.js +0 -66
  121. package/build/config/schemas.js.map +0 -1
  122. package/build/support/Async.d.ts +0 -22
  123. package/build/support/Async.js +0 -62
  124. package/build/support/Async.js.map +0 -1
  125. package/build/support/Builder/Builder.d.ts +0 -36
  126. package/build/support/Builder/Builder.js +0 -89
  127. package/build/support/Builder/Builder.js.map +0 -1
  128. package/build/support/Dependency/Dependency.d.ts +0 -38
  129. package/build/support/Dependency/Dependency.js +0 -14
  130. package/build/support/Dependency/Dependency.js.map +0 -1
  131. package/build/support/Dependency/GitDependency.d.ts +0 -20
  132. package/build/support/Dependency/GitDependency.js +0 -67
  133. package/build/support/Dependency/GitDependency.js.map +0 -1
  134. package/build/support/Dependency/NpmDependency.d.ts +0 -18
  135. package/build/support/Dependency/NpmDependency.js +0 -65
  136. package/build/support/Dependency/NpmDependency.js.map +0 -1
  137. package/build/support/Dependency/Resolver.d.ts +0 -7
  138. package/build/support/Dependency/Resolver.js +0 -4
  139. package/build/support/Dependency/Resolver.js.map +0 -1
  140. package/build/support/Git.d.ts +0 -53
  141. package/build/support/Git.js +0 -86
  142. package/build/support/Git.js.map +0 -1
  143. package/build/support/PathResolver/AliasCompiler.d.ts +0 -25
  144. package/build/support/PathResolver/AliasCompiler.js +0 -39
  145. package/build/support/PathResolver/AliasCompiler.js.map +0 -1
  146. package/build/support/PathResolver/PathResolver.js +0 -104
  147. package/build/support/PathResolver/PathResolver.js.map +0 -1
  148. package/build/support/PathResolver/PathRewriter.d.ts +0 -18
  149. package/build/support/PathResolver/PathRewriter.js.map +0 -1
  150. package/build/support/PathResolver/Utils.d.ts +0 -36
  151. package/build/support/PathResolver/Utils.js +0 -45
  152. package/build/support/PathResolver/Utils.js.map +0 -1
  153. package/build/support/Task/Command.d.ts +0 -49
  154. package/build/support/Task/Command.js +0 -100
  155. package/build/support/Task/Command.js.map +0 -1
  156. package/build/support/Task/Task.d.ts +0 -84
  157. package/build/support/Task/Task.js +0 -145
  158. package/build/support/Task/Task.js.map +0 -1
  159. package/build/support/Utils.d.ts +0 -40
  160. package/build/support/Utils.js +0 -138
  161. package/build/support/Utils.js.map +0 -1
  162. package/build/support/Validator.d.ts +0 -22
  163. package/build/support/Validator.js +0 -28
  164. package/build/support/Validator.js.map +0 -1
  165. /package/{build → dist}/cli/bin.d.ts +0 -0
@@ -0,0 +1,210 @@
1
+ /**
2
+ * @author NetFeez <netfeez.dev@gmail.com>.
3
+ * @description Runs the instructions of a task in sequence over a working directory, owning the single
4
+ * verdict of the run and reporting its progress.
5
+ * @license Apache-2.0
6
+ */
7
+ import { Events } from "@netfeez/common";
8
+ import Command from "./Command.js";
9
+ export declare class Task extends Events<Task.EventMap> {
10
+ protected readonly cwd: string;
11
+ protected readonly instructions: Task.Instruction[];
12
+ protected readonly options: Task.Options;
13
+ protected vResults: Task.commandResult[];
14
+ protected vCurrentStep: number;
15
+ protected vTotalTime: number;
16
+ protected vIsFinished: boolean;
17
+ protected vIsRunning: boolean;
18
+ protected vIsStopped: boolean;
19
+ protected vReason: Task.Reason | null;
20
+ /** The shell the scripts are written to, created only when an instruction needs one. */
21
+ protected shell: Command.Shell | null;
22
+ /** The handshake that silences the shell, awaited before the first instruction is written to it. */
23
+ protected prepared: Promise<void> | null;
24
+ /** The instruction in flight, the only one a timeout or a stop has to take down. */
25
+ protected current: Command | null;
26
+ protected timer: NodeJS.Timeout | null;
27
+ constructor(cwd: string, instructions: Task.Instruction[], options?: Task.Options);
28
+ get currentStep(): number;
29
+ get isFinished(): boolean;
30
+ get isRunning(): boolean;
31
+ get completes(): number;
32
+ get totalTime(): number;
33
+ get successes(): number;
34
+ get results(): Task.commandResult[];
35
+ get fails(): number;
36
+ /**
37
+ * Runs every instruction in sequence and settles the verdict of the task.
38
+ * @returns A promise resolving with the summary of the run, or rejecting with a
39
+ * {@link Task.Failure} carrying it, when the task failed and does not tolerate failures.
40
+ *
41
+ * @remarks This promise is the only verdict of the run: the `finish` event carries the same summary
42
+ * for reporting, and nothing is decided by it.
43
+ *
44
+ * The failure of an instruction does not stop the task, so the remaining instructions still run, and
45
+ * `allowFails` tolerates it. Anything else does stop the task, tolerating nothing, because none of
46
+ * them is the failure of a command: a run that timed out, was stopped, could not start a program or
47
+ * lost its shell did not do what it was asked to do, and `success: false` is not a verdict a caller
48
+ * can act on.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const task = new Task(cwd, [ { executable: 'git', args: ['clone', repo, folder] } ], { maxTimeMs: 30000 });
53
+ * task.on('line', (line) => logger.info(line));
54
+ * const outcome = await task.run();
55
+ * ```
56
+ */
57
+ run(): Promise<Task.FinishData>;
58
+ /**
59
+ * Stops the task, taking down the instruction in flight, if any.
60
+ * @returns void
61
+ *
62
+ * @remarks The pending run rejects with a {@link Task.Failure} of reason `stopped`, so a caller
63
+ * that stops a task never waits for a verdict that will not come.
64
+ */
65
+ stop(): void;
66
+ /**
67
+ * Runs one instruction and turns its verdict into a result of the task.
68
+ * @param instruction - The instruction to run, a script for the shell or a program of its own.
69
+ * @returns A promise resolving with the result of the instruction.
70
+ **/
71
+ protected execute(instruction: Task.Instruction): Promise<Task.commandResult>;
72
+ /**
73
+ * The shell the scripts of this task are written to, started in the working directory of the task.
74
+ * @returns A promise resolving to the shell, or to `null` when the shell of the task is already gone.
75
+ *
76
+ * @remarks The shell is silenced before it is handed over: everything it writes about itself belongs
77
+ * to the shell and not to the first instruction, so the handshake that removes it completes first.
78
+ *
79
+ * @remarks A shell that dies takes down the instruction reading it, and the reason of the run becomes
80
+ * `shell`: the instruction is reported as unfinished because there is no longer anything reading it,
81
+ * and it is the task that owns the shell that says the shell is gone.
82
+ */
83
+ protected getShell(): Promise<Command.Shell | null>;
84
+ /**
85
+ * Arms the deadline of the task, taken from the time it started.
86
+ * @returns void
87
+ **/
88
+ protected arm(): void;
89
+ /** Disarms the deadline of the task. **/
90
+ protected disarm(): void;
91
+ /** Takes down the shell of the task, if it created one. **/
92
+ protected dispose(): void;
93
+ /**
94
+ * Turns the verdict of an instruction into the result the task keeps: the identity of the command,
95
+ * the verdict itself, the output it produced and the diagnostic that explains how it ended.
96
+ *
97
+ * @remarks The output and the error are kept whole, so a caller can show them, save them or search
98
+ * them without a policy having to be present while the command runs. Nothing is added to either
99
+ * buffer, and the diagnostic never carries them: it says what happened, and the buffers say why.
100
+ *
101
+ * @param label - The human readable form of the instruction.
102
+ * @param verdict - The verdict the command settled with.
103
+ * @param ordinal - The position of the instruction inside the task, starting at 1.
104
+ * @returns The result of the instruction.
105
+ **/
106
+ protected static result(label: string, verdict: Command.Verdict, ordinal: number): Task.commandResult;
107
+ /**
108
+ * The one line that explains how an instruction ended, the same in every mode and the only text
109
+ * about the failure that belongs to the result.
110
+ *
111
+ * @remarks A command that failed carries its status, its signal or the reason it could not finish,
112
+ * and never its output: mixing both made the first line of a failure unreadable, and the output is
113
+ * already in the buffers, in the evidence file and, when it is wanted, right under this line.
114
+ *
115
+ * @param label - The human readable form of the instruction.
116
+ * @param verdict - The verdict the command settled with.
117
+ * @returns The diagnostic of the instruction, empty when it succeeded.
118
+ **/
119
+ protected static diagnostic(label: string, verdict: Command.Verdict): string;
120
+ /**
121
+ * The summary of the task execution, which is both the verdict of the run and what the `finish`
122
+ * event reports.
123
+ * @returns The summary of the execution.
124
+ **/
125
+ protected getSummary(): Task.FinishData;
126
+ }
127
+ export declare namespace Task {
128
+ type Emitter = Events.Emitter<EventMap>;
129
+ type Program = Command.Program;
130
+ type Instruction = string | Program;
131
+ type Reason = Command.Reason;
132
+ interface Options {
133
+ /** The deadline of the whole task in milliseconds; a negative value leaves it unbounded. */
134
+ maxTimeMs?: number;
135
+ /** Whether the failure of an instruction is tolerated, so the task still succeeds. */
136
+ allowFails?: boolean;
137
+ }
138
+ /**
139
+ * The events of a task: a line of stdout, a line of stderr, the result of the instruction that just
140
+ * ended, and the summary of the run.
141
+ *
142
+ * @remarks Every line and every result carries the ordinal of the instruction it belongs to, the one
143
+ * the command already knows, so a consumer can attribute both without keeping a counter of its own.
144
+ */
145
+ type EventMap = {
146
+ line: [line: string, ordinal: number];
147
+ err: [line: string, ordinal: number];
148
+ step: [commandResult: commandResult, step: number, time: number];
149
+ error: [commandResult: commandResult, step: number, time: number];
150
+ finish: [data: FinishData];
151
+ };
152
+ /**
153
+ * Everything a task knows about one instruction: who it was, how it ended, and everything it said.
154
+ */
155
+ interface commandResult {
156
+ /** The position of the instruction inside its task, starting at 1. */
157
+ ordinal: number;
158
+ /** The human readable form of the instruction, whole, as it was given. */
159
+ label: string;
160
+ /** Whether the instruction ended as it was asked to. */
161
+ success: boolean;
162
+ /** The exit status, or `null` when there was none. */
163
+ code: number | null;
164
+ /** The signal that took the command down, or `null` when there was none. */
165
+ signal: NodeJS.Signals | null;
166
+ /** Why there is no status at all, or `null` when the command reported one. */
167
+ reason: Reason | null;
168
+ /** The time the instruction took, in milliseconds. */
169
+ time: number;
170
+ /** Everything the instruction wrote to stdout. */
171
+ stdout: string;
172
+ /** Everything the instruction wrote to stderr. */
173
+ stderr: string;
174
+ /** The one line that explains a failure, empty when the instruction succeeded. */
175
+ diagnostic: string;
176
+ }
177
+ interface FinishData {
178
+ success: boolean;
179
+ completes: number;
180
+ fails: number;
181
+ totalTime: number;
182
+ results: commandResult[];
183
+ }
184
+ /**
185
+ * The failure of a task, carrying the summary of the run that produced it.
186
+ *
187
+ * @remarks The message says how the task failed and nothing more. The output of every instruction is
188
+ * in the summary, one result per command, and printing it here duplicated it in every message a
189
+ * caller logged: a task that printed a build log threw the log away once per layer that reported it.
190
+ */
191
+ class Failure extends Error {
192
+ readonly outcome: FinishData;
193
+ readonly reason: Reason | 'command';
194
+ /**
195
+ * Creates the failure of a task.
196
+ * @param outcome - The summary of the run.
197
+ * @param reason - Why the task failed.
198
+ */
199
+ constructor(outcome: FinishData, reason?: Reason | 'command');
200
+ /**
201
+ * The message describing why a task failed: how many instructions failed, and why the run did not
202
+ * get to all of them.
203
+ * @param outcome - The summary of the run.
204
+ * @param reason - Why the task failed.
205
+ * @returns The message of the failure.
206
+ **/
207
+ private static message;
208
+ }
209
+ }
210
+ export default Task;
@@ -0,0 +1,312 @@
1
+ /**
2
+ * @author NetFeez <netfeez.dev@gmail.com>.
3
+ * @description Runs the instructions of a task in sequence over a working directory, owning the single
4
+ * verdict of the run and reporting its progress.
5
+ * @license Apache-2.0
6
+ */
7
+ import { Events } from "@netfeez/common";
8
+ import Command from "./Command.js";
9
+ export class Task extends Events {
10
+ cwd;
11
+ instructions;
12
+ options;
13
+ vResults = [];
14
+ vCurrentStep = 0;
15
+ vTotalTime = 0;
16
+ vIsFinished = false;
17
+ vIsRunning = false;
18
+ vIsStopped = false;
19
+ vReason = null;
20
+ /** The shell the scripts are written to, created only when an instruction needs one. */
21
+ shell = null;
22
+ /** The handshake that silences the shell, awaited before the first instruction is written to it. */
23
+ prepared = null;
24
+ /** The instruction in flight, the only one a timeout or a stop has to take down. */
25
+ current = null;
26
+ timer = null;
27
+ constructor(cwd, instructions, options = {}) {
28
+ super();
29
+ this.cwd = cwd;
30
+ this.instructions = instructions;
31
+ this.options = options;
32
+ }
33
+ get currentStep() { return this.vCurrentStep; }
34
+ get isFinished() { return this.vIsFinished; }
35
+ get isRunning() { return this.vIsRunning; }
36
+ get completes() { return this.vResults.length; }
37
+ get totalTime() { return this.vTotalTime; }
38
+ get successes() { return this.vResults.filter(r => r.success).length; }
39
+ get results() { return this.vResults; }
40
+ get fails() { return this.vResults.filter(r => !r.success).length; }
41
+ /**
42
+ * Runs every instruction in sequence and settles the verdict of the task.
43
+ * @returns A promise resolving with the summary of the run, or rejecting with a
44
+ * {@link Task.Failure} carrying it, when the task failed and does not tolerate failures.
45
+ *
46
+ * @remarks This promise is the only verdict of the run: the `finish` event carries the same summary
47
+ * for reporting, and nothing is decided by it.
48
+ *
49
+ * The failure of an instruction does not stop the task, so the remaining instructions still run, and
50
+ * `allowFails` tolerates it. Anything else does stop the task, tolerating nothing, because none of
51
+ * them is the failure of a command: a run that timed out, was stopped, could not start a program or
52
+ * lost its shell did not do what it was asked to do, and `success: false` is not a verdict a caller
53
+ * can act on.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const task = new Task(cwd, [ { executable: 'git', args: ['clone', repo, folder] } ], { maxTimeMs: 30000 });
58
+ * task.on('line', (line) => logger.info(line));
59
+ * const outcome = await task.run();
60
+ * ```
61
+ */
62
+ async run() {
63
+ if (this.vIsFinished)
64
+ throw new Error('Task has already run.');
65
+ if (this.vIsRunning)
66
+ throw new Error('Task is already running.');
67
+ this.vIsRunning = true;
68
+ this.arm();
69
+ try {
70
+ for (const instruction of this.instructions) {
71
+ if (this.vIsStopped)
72
+ break;
73
+ this.vCurrentStep += 1;
74
+ const result = await this.execute(instruction);
75
+ this.vResults.push(result);
76
+ this.vTotalTime += result.time;
77
+ if (result.success)
78
+ this.emit('step', result, this.vCurrentStep, result.time);
79
+ else
80
+ this.emit('error', result, this.vCurrentStep, result.time);
81
+ if (result.reason && result.reason !== 'stopped')
82
+ this.vReason = result.reason;
83
+ if (result.reason)
84
+ break;
85
+ }
86
+ const summary = this.getSummary();
87
+ if (this.vIsStopped)
88
+ throw new Task.Failure(summary, 'stopped');
89
+ if (this.vReason !== null)
90
+ throw new Task.Failure(summary, this.vReason);
91
+ if (summary.fails > 0 && !this.options.allowFails)
92
+ throw new Task.Failure(summary, 'command');
93
+ return summary;
94
+ }
95
+ finally {
96
+ this.vIsRunning = false;
97
+ this.vIsFinished = true;
98
+ this.disarm();
99
+ this.dispose();
100
+ this.emit('finish', this.getSummary());
101
+ }
102
+ }
103
+ /**
104
+ * Stops the task, taking down the instruction in flight, if any.
105
+ * @returns void
106
+ *
107
+ * @remarks The pending run rejects with a {@link Task.Failure} of reason `stopped`, so a caller
108
+ * that stops a task never waits for a verdict that will not come.
109
+ */
110
+ stop() {
111
+ if (this.vIsFinished)
112
+ return;
113
+ this.vIsStopped = true;
114
+ this.current?.kill('stopped');
115
+ }
116
+ /**
117
+ * Runs one instruction and turns its verdict into a result of the task.
118
+ * @param instruction - The instruction to run, a script for the shell or a program of its own.
119
+ * @returns A promise resolving with the result of the instruction.
120
+ **/
121
+ async execute(instruction) {
122
+ const ordinal = this.vCurrentStep;
123
+ const command = typeof instruction === 'string'
124
+ ? Command.inShell(await this.getShell(), instruction, ordinal)
125
+ : Command.asProgram({ cwd: this.cwd, ...instruction }, ordinal);
126
+ this.current = command;
127
+ if (this.vIsStopped)
128
+ command.kill('stopped');
129
+ return new Promise((resolve) => {
130
+ command.on('log', (line, step) => this.emit('line', line, step));
131
+ command.on('err', (line, step) => this.emit('err', line, step));
132
+ command.once('end', (verdict) => {
133
+ if (this.current === command)
134
+ this.current = null;
135
+ resolve(Task.result(command.label, verdict, ordinal));
136
+ });
137
+ command.exec();
138
+ });
139
+ }
140
+ /**
141
+ * The shell the scripts of this task are written to, started in the working directory of the task.
142
+ * @returns A promise resolving to the shell, or to `null` when the shell of the task is already gone.
143
+ *
144
+ * @remarks The shell is silenced before it is handed over: everything it writes about itself belongs
145
+ * to the shell and not to the first instruction, so the handshake that removes it completes first.
146
+ *
147
+ * @remarks A shell that dies takes down the instruction reading it, and the reason of the run becomes
148
+ * `shell`: the instruction is reported as unfinished because there is no longer anything reading it,
149
+ * and it is the task that owns the shell that says the shell is gone.
150
+ */
151
+ async getShell() {
152
+ if (!this.shell) {
153
+ this.shell = Command.createShell(this.cwd);
154
+ this.shell.stdin.on('error', () => { });
155
+ this.shell.once('error', () => { this.current?.kill('shell'); });
156
+ this.shell.once('exit', () => { this.current?.kill('shell'); });
157
+ this.prepared = Command.prepare(this.shell);
158
+ }
159
+ await this.prepared;
160
+ return this.shell.exitCode === null && this.shell.signalCode === null ? this.shell : null;
161
+ }
162
+ /**
163
+ * Arms the deadline of the task, taken from the time it started.
164
+ * @returns void
165
+ **/
166
+ arm() {
167
+ const limit = this.options.maxTimeMs ?? -1;
168
+ if (limit < 0)
169
+ return;
170
+ this.timer = setTimeout(() => {
171
+ this.vReason = 'timeout';
172
+ this.current?.kill('timeout');
173
+ }, limit);
174
+ this.timer.unref();
175
+ }
176
+ /** Disarms the deadline of the task. **/
177
+ disarm() {
178
+ if (!this.timer)
179
+ return;
180
+ clearTimeout(this.timer);
181
+ this.timer = null;
182
+ }
183
+ /** Takes down the shell of the task, if it created one. **/
184
+ dispose() {
185
+ this.current = null;
186
+ this.prepared = null;
187
+ if (!this.shell)
188
+ return;
189
+ Command.terminate(this.shell);
190
+ this.shell = null;
191
+ }
192
+ /**
193
+ * Turns the verdict of an instruction into the result the task keeps: the identity of the command,
194
+ * the verdict itself, the output it produced and the diagnostic that explains how it ended.
195
+ *
196
+ * @remarks The output and the error are kept whole, so a caller can show them, save them or search
197
+ * them without a policy having to be present while the command runs. Nothing is added to either
198
+ * buffer, and the diagnostic never carries them: it says what happened, and the buffers say why.
199
+ *
200
+ * @param label - The human readable form of the instruction.
201
+ * @param verdict - The verdict the command settled with.
202
+ * @param ordinal - The position of the instruction inside the task, starting at 1.
203
+ * @returns The result of the instruction.
204
+ **/
205
+ static result(label, verdict, ordinal) {
206
+ return {
207
+ ordinal,
208
+ label,
209
+ success: verdict.code === 0 && verdict.reason === null,
210
+ code: verdict.code,
211
+ signal: verdict.signal,
212
+ reason: verdict.reason,
213
+ time: verdict.time,
214
+ stdout: verdict.output,
215
+ stderr: verdict.error,
216
+ diagnostic: Task.diagnostic(label, verdict)
217
+ };
218
+ }
219
+ /**
220
+ * The one line that explains how an instruction ended, the same in every mode and the only text
221
+ * about the failure that belongs to the result.
222
+ *
223
+ * @remarks A command that failed carries its status, its signal or the reason it could not finish,
224
+ * and never its output: mixing both made the first line of a failure unreadable, and the output is
225
+ * already in the buffers, in the evidence file and, when it is wanted, right under this line.
226
+ *
227
+ * @param label - The human readable form of the instruction.
228
+ * @param verdict - The verdict the command settled with.
229
+ * @returns The diagnostic of the instruction, empty when it succeeded.
230
+ **/
231
+ static diagnostic(label, verdict) {
232
+ if (verdict.reason === 'timeout')
233
+ return `Instruction timed out: ${label}`;
234
+ if (verdict.reason === 'stopped')
235
+ return `Instruction stopped: ${label}`;
236
+ if (verdict.reason === 'shell')
237
+ return `The shell exited before the instruction finished: ${label}`;
238
+ if (verdict.reason === 'spawn')
239
+ return `Instruction could not be started: ${label}`;
240
+ if (verdict.reason === 'protocol')
241
+ return `The shell did not report the status of: ${label}`;
242
+ if (verdict.reason !== null || verdict.code === 0)
243
+ return '';
244
+ return verdict.signal
245
+ ? `Command failed with signal ${verdict.signal}: ${label}`
246
+ : `Command failed with status ${verdict.code}: ${label}`;
247
+ }
248
+ /**
249
+ * The summary of the task execution, which is both the verdict of the run and what the `finish`
250
+ * event reports.
251
+ * @returns The summary of the execution.
252
+ **/
253
+ getSummary() {
254
+ return {
255
+ success: this.vReason === null && (this.fails === 0 || this.options.allowFails === true),
256
+ completes: this.completes,
257
+ fails: this.fails,
258
+ totalTime: this.totalTime,
259
+ results: this.results
260
+ };
261
+ }
262
+ }
263
+ (function (Task) {
264
+ /**
265
+ * The failure of a task, carrying the summary of the run that produced it.
266
+ *
267
+ * @remarks The message says how the task failed and nothing more. The output of every instruction is
268
+ * in the summary, one result per command, and printing it here duplicated it in every message a
269
+ * caller logged: a task that printed a build log threw the log away once per layer that reported it.
270
+ */
271
+ class Failure extends Error {
272
+ outcome;
273
+ reason;
274
+ /**
275
+ * Creates the failure of a task.
276
+ * @param outcome - The summary of the run.
277
+ * @param reason - Why the task failed.
278
+ */
279
+ constructor(outcome, reason = 'command') {
280
+ super(Failure.message(outcome, reason));
281
+ this.outcome = outcome;
282
+ this.reason = reason;
283
+ this.name = 'Task.Failure';
284
+ }
285
+ /**
286
+ * The message describing why a task failed: how many instructions failed, and why the run did not
287
+ * get to all of them.
288
+ * @param outcome - The summary of the run.
289
+ * @param reason - Why the task failed.
290
+ * @returns The message of the failure.
291
+ **/
292
+ static message(outcome, reason) {
293
+ const lines = [];
294
+ if (outcome.fails > 0)
295
+ lines.push(`Task failed with ${outcome.fails} failed instruction(s).`);
296
+ if (reason === 'timeout')
297
+ lines.push('Task timed out before completing every instruction.');
298
+ else if (reason === 'stopped')
299
+ lines.push('Task was stopped before completing every instruction.');
300
+ else if (reason === 'shell')
301
+ lines.push('The shell running the task exited unexpectedly.');
302
+ else if (reason === 'spawn')
303
+ lines.push('An instruction could not be started.');
304
+ else if (reason === 'protocol')
305
+ lines.push('The shell did not report the status of an instruction.');
306
+ return lines.join('\n');
307
+ }
308
+ }
309
+ Task.Failure = Failure;
310
+ })(Task || (Task = {}));
311
+ export default Task;
312
+ //# sourceMappingURL=Task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Task.js","sourceRoot":"","sources":["../../src/task/Task.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,MAAM,OAAO,IAAK,SAAQ,MAAqB;IAuBpB,GAAG;IACH,YAAY;IACZ,OAAO;IAxBpB,QAAQ,GAAyB,EAAE,CAAC;IAEpC,YAAY,GAAW,CAAC,CAAC;IACzB,UAAU,GAAW,CAAC,CAAC;IAEvB,WAAW,GAAY,KAAK,CAAC;IAC7B,UAAU,GAAY,KAAK,CAAC;IAC5B,UAAU,GAAY,KAAK,CAAC;IAC5B,OAAO,GAAuB,IAAI,CAAC;IAE7C,wFAAwF;IAC9E,KAAK,GAAyB,IAAI,CAAC;IAE7C,oGAAoG;IAC1F,QAAQ,GAAyB,IAAI,CAAC;IAEhD,oFAAoF;IAC1E,OAAO,GAAmB,IAAI,CAAC;IAE/B,KAAK,GAA0B,IAAI,CAAC;IAE9C,YACuB,GAAW,EACX,YAAgC,EAChC,OAAO,GAAiB,EAAE;QAC7C,KAAK,EAAE,CAAC;mBAHW,GAAG;4BACH,YAAY;uBACZ,OAAO;IACjB,CAAC;IAEd,IAAW,WAAW,KAAa,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAC9D,IAAW,UAAU,KAAc,OAAO,IAAI,CAAC,W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AC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;2BADT,OAAO;0BAA8B,MAAM;YAE1E,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC/B,CAAC;QAED;;;;;;YAMI;QACI,MAAM,CAAC,OAAO,CAAC,OAAmB,EAAE,MAA0B;YAClE,MAAM,KAAK,GAAa,EAAE,CAAC;YAC3B,IAAI,OAAO,CAAC,KAAK,GAAG,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,oBAAoB,OAAO,CAAC,KAAK,yBAAyB,CAAC,CAAC;YAE9F,IAAI,MAAM,KAAK,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;iBACvF,IAAI,MAAM,KAAK,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;iBAC9F,IAAI,MAAM,KAAK,OAAO;gBAAE,KAAK,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;iBACtF,IAAI,MAAM,KAAK,OAAO;gBAAE,KAAK,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;iBAC3E,IAAI,MAAM,KAAK,UAAU;gBAAE,KAAK,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;YACrG,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;KACJ;IA7BY,KAAA,OAAO,UA6BnB,CAAA;AACL,CAAC,EAnGgB,IAAI,KAAJ,IAAI,QAmGpB;AACD,eAAe,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,21 +1,22 @@
1
1
  {
2
2
  "name": "depflow",
3
3
  "description": "is a simple dependency manager based on github repositories",
4
- "version": "3.0.0-dev.1",
5
- "main": "build/bin/bin.js",
4
+ "version": "3.0.0-dev.11",
5
+ "main": "dist/cli/bin.js",
6
6
  "type": "module",
7
7
  "bin": {
8
- "dep": "build/cli/bin.js"
8
+ "dep": "dist/cli/bin.js"
9
9
  },
10
10
  "scripts": {
11
- "dev": "npx tsc --watch",
12
- "compile": "npx tsc",
13
- "prepare": "npm run compile"
11
+ "clean": "node ./scripts/clean.mjs",
12
+ "dev": "npx tsc --watch -p tsconfig.depflow.json",
13
+ "build": "npm run clean && npx tsc -p tsconfig.depflow.json",
14
+ "test": "npx tsc -p tsconfig.test.json && node --import ./tests/_register.mjs dist-test/tests/index.js",
15
+ "prepublishOnly": "npm run build && npm test"
14
16
  },
15
17
  "license": "Apache-2.0",
16
18
  "repository": {
17
- "type": "git",
18
- "url": "https://github.com/NetFeez/DependencyManager.git"
19
+ "url": "git+https://github.com/NetFeez/depflow.git"
19
20
  },
20
21
  "author": {
21
22
  "name": "NetFeez",
@@ -27,18 +28,19 @@
27
28
  "manager"
28
29
  ],
29
30
  "files": [
30
- "build",
31
- ".gitignore",
31
+ "dist",
32
32
  "LICENCE",
33
33
  "README.md"
34
34
  ],
35
35
  "dependencies": {
36
- "@netfeez/common": "^3.0.0",
37
- "@netfeez/common-node": "^3.0.0",
38
- "@netfeez/vterm": "^1.1.0"
36
+ "@netfeez/common": "^4.2.0",
37
+ "@netfeez/common-node": "^3.4.0",
38
+ "@netfeez/schema": "^0.1.0",
39
+ "@netfeez/vterm": "^2.0.0-dev.1",
40
+ "@netfeez/yaml": "^0.2.0"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@types/node": "^25.6.0",
42
- "typescript": "^6.0.2"
44
+ "typescript": "^7.0.2"
43
45
  }
44
46
  }
package/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- # Build setting
2
- **/node_modules/
3
- **/build/
4
- **/.**
5
- **/*.log
6
- **/*.env
7
- !.gitignore
@@ -1,15 +0,0 @@
1
- import { DebugUI } from "@netfeez/vterm";
2
- export declare class DepFlowCLI extends DebugUI {
3
- readonly configPath: string;
4
- protected readonly projectRoot: string;
5
- constructor(configPath?: string);
6
- commandAdd(command: string, args: string[]): Promise<void>;
7
- commandRemove(command: string, args: string[]): Promise<void>;
8
- commandInstall(command: string, args: string[]): Promise<void>;
9
- uninstall(command: string, args: string[]): Promise<void>;
10
- list(command: string, args: string[]): Promise<void>;
11
- rewritePaths(command: string, args: string[]): Promise<void>;
12
- commandSync(command: string, args: string[]): Promise<void>;
13
- }
14
- export declare namespace DepFlowCLI { }
15
- export default DepFlowCLI;