@powerlines/engine 0.49.12 → 0.49.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-DcHfCjQK.d.cts → api-D1r7WAQA.d.cts} +13 -13
- package/dist/api-D1r7WAQA.d.cts.map +1 -0
- package/dist/{api-BgyEi2hF.d.mts → api-DRcC7Ry-.d.mts} +13 -13
- package/dist/api-DRcC7Ry-.d.mts.map +1 -0
- package/dist/api.cjs +3 -21
- package/dist/api.d.cts +5 -12
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +5 -11
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +21 -30
- package/dist/api.mjs.map +1 -1
- package/dist/engine-BLp7JcAB.d.mts +199 -0
- package/dist/engine-BLp7JcAB.d.mts.map +1 -0
- package/dist/{engine-q6YKXXcB.mjs → engine-CDFOkhKj.mjs} +114 -123
- package/dist/engine-CDFOkhKj.mjs.map +1 -0
- package/dist/engine-DFKgU8-G.d.cts +199 -0
- package/dist/engine-DFKgU8-G.d.cts.map +1 -0
- package/dist/{engine-Dz6BvkFY.cjs → engine-DlOFwFgt.cjs} +113 -122
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +2 -143
- package/dist/engine.d.mts +2 -143
- package/dist/engine.mjs +1 -1
- package/dist/helpers/{create-execution-host.cjs → create-api.cjs} +14 -13
- package/dist/helpers/create-api.d.cts +18 -0
- package/dist/helpers/create-api.d.cts.map +1 -0
- package/dist/helpers/create-api.d.mts +18 -0
- package/dist/helpers/create-api.d.mts.map +1 -0
- package/dist/helpers/{create-execution-host.mjs → create-api.mjs} +15 -14
- package/dist/helpers/create-api.mjs.map +1 -0
- package/dist/helpers/index.cjs +2 -2
- package/dist/helpers/index.d.cts +2 -2
- package/dist/helpers/index.d.mts +2 -2
- package/dist/helpers/index.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/package.json +23 -23
- package/dist/api-BgyEi2hF.d.mts.map +0 -1
- package/dist/api-DcHfCjQK.d.cts.map +0 -1
- package/dist/engine-q6YKXXcB.mjs.map +0 -1
- package/dist/engine.d.cts.map +0 -1
- package/dist/engine.d.mts.map +0 -1
- package/dist/helpers/create-execution-host.d.cts +0 -20
- package/dist/helpers/create-execution-host.d.cts.map +0 -1
- package/dist/helpers/create-execution-host.d.mts +0 -20
- package/dist/helpers/create-execution-host.d.mts.map +0 -1
- package/dist/helpers/create-execution-host.mjs.map +0 -1
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { MessagePortDuplex } from "./helpers/stream.mjs";
|
|
2
2
|
import { PowerlinesEngineContext } from "./context/engine-context.mjs";
|
|
3
3
|
import { appendPath } from "@stryke/path/append";
|
|
4
|
-
import { toArray } from "@stryke/convert/to-array";
|
|
5
|
-
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
6
|
-
import { isFunction } from "@stryke/type-checks/is-function";
|
|
7
4
|
import { isNumber } from "@stryke/type-checks/is-number";
|
|
8
5
|
import { isSet } from "@stryke/type-checks/is-set";
|
|
9
6
|
import { EventEmitter } from "node:events";
|
|
@@ -17,12 +14,11 @@ import { resolve } from "@stryke/fs/resolve";
|
|
|
17
14
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
18
15
|
import { isString } from "@stryke/type-checks/is-string";
|
|
19
16
|
import { formatDuration } from "date-fns/formatDuration";
|
|
20
|
-
import { createJiti } from "jiti";
|
|
21
17
|
import { parseArgs } from "node:util";
|
|
22
18
|
import { MessageChannel } from "node:worker_threads";
|
|
23
19
|
import Piscina from "piscina";
|
|
24
20
|
|
|
25
|
-
//#region src/_internal/execution-
|
|
21
|
+
//#region src/_internal/execution-api-worker.ts
|
|
26
22
|
const RESTARTED = Symbol("powerlines-worker:restarted");
|
|
27
23
|
/**
|
|
28
24
|
* Formats the debug address into a string.
|
|
@@ -62,54 +58,57 @@ function getNodeDebugType(nodeOptions) {
|
|
|
62
58
|
if (nodeOptions.inspect) return "inspect";
|
|
63
59
|
if (nodeOptions["inspect-brk"] || nodeOptions.inspect_brk) return "inspect-brk";
|
|
64
60
|
}
|
|
65
|
-
var
|
|
66
|
-
|
|
67
|
-
exposedMethods;
|
|
61
|
+
var ExecutionApiWorker = class ExecutionApiWorker {
|
|
62
|
+
executionApiPath;
|
|
68
63
|
options;
|
|
69
64
|
#worker;
|
|
65
|
+
#logger;
|
|
66
|
+
#activeTasks = 0;
|
|
67
|
+
#restartPromise = null;
|
|
68
|
+
#resolveRestartPromise = null;
|
|
69
|
+
#hangingTimer = false;
|
|
70
|
+
#createWorker;
|
|
71
|
+
get restartPromise() {
|
|
72
|
+
if (!this.#restartPromise) this.#restartPromise = new Promise((resolve) => {
|
|
73
|
+
this.#resolveRestartPromise = resolve;
|
|
74
|
+
});
|
|
75
|
+
return this.#restartPromise;
|
|
76
|
+
}
|
|
77
|
+
resolveRestartPromise() {
|
|
78
|
+
if (this.#resolveRestartPromise) {
|
|
79
|
+
this.#resolveRestartPromise(RESTARTED);
|
|
80
|
+
this.#restartPromise = null;
|
|
81
|
+
this.#resolveRestartPromise = null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
70
84
|
/**
|
|
71
|
-
* Creates a new instance of the
|
|
85
|
+
* Creates a new instance of the Execution API Worker class, which manages a worker process for executing tasks related to the Powerlines Engine. The worker is initialized with the specified options and can be used to run tasks in an isolated environment, with support for automatic restarts and activity monitoring.
|
|
72
86
|
*
|
|
73
|
-
* @param apiPath - The path to the Execution
|
|
87
|
+
* @param apiPath - The path to the Execution API file.
|
|
74
88
|
* @param options - The options for configuring the worker, including the execution context, exposed methods, timeout, and mode.
|
|
75
|
-
* @returns A promise that resolves to an instance of the
|
|
89
|
+
* @returns A promise that resolves to an instance of the ExecutionApiWorker class.
|
|
76
90
|
*/
|
|
77
91
|
static async from(apiPath, options) {
|
|
78
92
|
const mode = await getDefaultMode(options.context.cwd);
|
|
79
93
|
const resolvedPath = await resolve(apiPath, { paths: [options.context.cwd, options.root ? appendPath(options.root, options.context.cwd) : void 0].filter(Boolean) });
|
|
80
|
-
if (!resolvedPath) throw new Error(`Could not resolve the provided Execution
|
|
81
|
-
|
|
82
|
-
if (exposedMethods.length === 0) {
|
|
83
|
-
const jiti = createJiti(import.meta.url, {
|
|
84
|
-
cache: false,
|
|
85
|
-
interopDefault: true,
|
|
86
|
-
tsconfigPaths: true
|
|
87
|
-
});
|
|
88
|
-
const mod = await jiti.import(jiti.esmResolve(resolvedPath));
|
|
89
|
-
if (isFunction(mod)) exposedMethods.push(...exposedMethods, "default");
|
|
90
|
-
else if (isSetObject(mod)) exposedMethods = Object.keys(mod).filter((name) => isFunction(mod[name]));
|
|
91
|
-
}
|
|
92
|
-
return new ExecutionHostWorker(resolvedPath, exposedMethods, {
|
|
94
|
+
if (!resolvedPath) throw new Error(`Could not resolve the provided Execution API path: \`${apiPath}\`.`);
|
|
95
|
+
return new ExecutionApiWorker(resolvedPath, {
|
|
93
96
|
mode,
|
|
94
97
|
...options
|
|
95
98
|
});
|
|
96
99
|
}
|
|
97
100
|
/**
|
|
98
|
-
* Create a new worker instance.
|
|
101
|
+
* Create a new API worker instance.
|
|
99
102
|
*
|
|
100
|
-
* @param
|
|
101
|
-
* @param
|
|
102
|
-
* @param options - The options for the worker, including exposed methods, timeout, and hooks for activity and restart.
|
|
103
|
+
* @param executionApiPath - The path to the worker file.
|
|
104
|
+
* @param options - The options for the worker, including exposed commands, timeout, and hooks for activity and restart.
|
|
103
105
|
*/
|
|
104
|
-
constructor(
|
|
105
|
-
this.
|
|
106
|
-
this.exposedMethods = exposedMethods;
|
|
106
|
+
constructor(executionApiPath, options) {
|
|
107
|
+
this.executionApiPath = executionApiPath;
|
|
107
108
|
this.options = options;
|
|
108
|
-
const {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
let resolveRestartPromise;
|
|
112
|
-
let activeTasks = 0;
|
|
109
|
+
const { isolatedMemory = false, mode = "production", context } = this.options;
|
|
110
|
+
this.options.timeout ??= 9e5;
|
|
111
|
+
this.#logger = context.extendLogger({ category: "communication" });
|
|
113
112
|
this.#worker = void 0;
|
|
114
113
|
process.on("exit", () => {
|
|
115
114
|
this.finalize();
|
|
@@ -206,104 +205,64 @@ var ExecutionHostWorker = class ExecutionHostWorker {
|
|
|
206
205
|
].includes(key)) execArgv.push(formatted);
|
|
207
206
|
else nodeOptionsParts.push(formatted);
|
|
208
207
|
}
|
|
209
|
-
|
|
210
|
-
if (!this.#worker) return;
|
|
211
|
-
const resolve = resolveRestartPromise;
|
|
212
|
-
createWorker();
|
|
213
|
-
logger.warn(`Sending SIGTERM signal to worker due to timeout${timeout ? ` of ${formatDuration({ seconds: timeout / 1e3 })}` : ""}. Subsequent errors may be a result of the worker exiting.`);
|
|
214
|
-
this.finalize().then(() => {
|
|
215
|
-
resolve(RESTARTED);
|
|
216
|
-
});
|
|
217
|
-
};
|
|
218
|
-
let hangingTimer = false;
|
|
219
|
-
const onActivity = () => {
|
|
220
|
-
if (hangingTimer) clearTimeout(hangingTimer);
|
|
221
|
-
hangingTimer = activeTasks > 0 && setTimeout(onHanging, timeout);
|
|
222
|
-
};
|
|
223
|
-
const createWorker = () => {
|
|
208
|
+
this.#createWorker = () => {
|
|
224
209
|
const env = {
|
|
225
210
|
...process.env,
|
|
226
211
|
NODE_ENV: mode,
|
|
227
212
|
NODE_OPTIONS: nodeOptionsParts.join(" "),
|
|
228
|
-
|
|
213
|
+
POWERLINES_EXECUTION_WORKER: "true"
|
|
229
214
|
};
|
|
230
|
-
if (env.FORCE_COLOR === void 0)
|
|
231
|
-
|
|
232
|
-
}
|
|
215
|
+
if (env.FORCE_COLOR === void 0 && !env.NO_COLOR && !env.CI && env.TERM !== "dumb" && (process.stdout.isTTY || process.stderr?.isTTY)) env.FORCE_COLOR = "1";
|
|
216
|
+
this.#logger.debug(`Creating worker from file ${executionApiPath} with execution arguments: ${JSON.stringify(execArgv, null, 2)}`);
|
|
233
217
|
this.#worker = new Piscina({
|
|
234
|
-
filename:
|
|
218
|
+
filename: executionApiPath,
|
|
235
219
|
execArgv,
|
|
236
220
|
env
|
|
237
221
|
});
|
|
238
|
-
restartPromise = new Promise((resolve) => {
|
|
239
|
-
resolveRestartPromise = resolve;
|
|
222
|
+
this.#restartPromise = new Promise((resolve) => {
|
|
223
|
+
this.#resolveRestartPromise = resolve;
|
|
240
224
|
});
|
|
241
225
|
this.#worker.on("exit", (code, signal) => {
|
|
242
|
-
logger.debug(`Worker process exited with code ${code} and signal ${signal}`);
|
|
226
|
+
this.#logger.debug(`Worker process exited with code ${code} and signal ${signal}`);
|
|
243
227
|
if ((code || signal && signal !== "SIGINT") && this.#worker) {
|
|
244
228
|
const error = /* @__PURE__ */ new Error(`Execution Host Worker exited unexpectedly with code ${code} and signal ${signal}`);
|
|
245
|
-
logger.error(error);
|
|
229
|
+
this.#logger.error(error);
|
|
246
230
|
this.finalize().then(() => {
|
|
247
231
|
throw error;
|
|
248
232
|
});
|
|
249
233
|
}
|
|
250
234
|
});
|
|
251
235
|
this.#worker.on("error", (error) => {
|
|
252
|
-
logger.error({
|
|
236
|
+
this.#logger.error({
|
|
253
237
|
meta: { category: "communication" },
|
|
254
238
|
message: `Worker process emitted an error: ${error.message}`,
|
|
255
239
|
error
|
|
256
240
|
});
|
|
257
241
|
});
|
|
258
242
|
this.#worker.on("message", (data) => {
|
|
259
|
-
onActivity();
|
|
260
|
-
if (Array.isArray(data) && data.length > 1 && isNumber(data[0])) if (data[0] === 0) logger.trace(`Received message from worker: ${JSON.stringify(data.slice(1), null, 2)}`);
|
|
261
|
-
else logger.debug(`Received error message from worker: ${JSON.stringify(data.slice(1), null, 2)}`);
|
|
262
|
-
logger.trace(`Received message from worker: ${JSON.stringify(data, null, 2)}`);
|
|
243
|
+
this.onActivity();
|
|
244
|
+
if (Array.isArray(data) && data.length > 1 && isNumber(data[0])) if (data[0] === 0) this.#logger.trace(`Received message from worker: ${JSON.stringify(data.slice(1), null, 2)}`);
|
|
245
|
+
else this.#logger.debug(`Received error message from worker: ${JSON.stringify(data.slice(1), null, 2)}`);
|
|
246
|
+
this.#logger.trace(`Received message from worker: ${JSON.stringify(data, null, 2)}`);
|
|
263
247
|
});
|
|
264
248
|
};
|
|
265
|
-
createWorker();
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
name: method,
|
|
277
|
-
transferList: [port2]
|
|
278
|
-
});
|
|
279
|
-
let aborted = false;
|
|
280
|
-
const onActivityAbort = () => {
|
|
281
|
-
if (!aborted) aborted = true;
|
|
282
|
-
};
|
|
283
|
-
pipeline(new MessagePortDuplex(port1, { onActivityAbort }), process.stdout, (err) => {
|
|
284
|
-
if (err) {
|
|
285
|
-
logger.debug(`Received exception message from worker: ${JSON.stringify(err, null, 2)}`);
|
|
286
|
-
throw err;
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
await promise;
|
|
290
|
-
};
|
|
291
|
-
this[method] = timeout ? async (options, inlineConfig) => {
|
|
292
|
-
activeTasks++;
|
|
293
|
-
try {
|
|
294
|
-
let attempts = 0;
|
|
295
|
-
for (;;) {
|
|
296
|
-
onActivity();
|
|
297
|
-
const result = await Promise.race([callWorker(options, inlineConfig), restartPromise]);
|
|
298
|
-
if (result !== RESTARTED) return result;
|
|
299
|
-
logger.warn(`Execution Host Worker was restarted while calling method "${method}" (attempt ${attempts++}). Retrying the call...`);
|
|
300
|
-
}
|
|
301
|
-
} finally {
|
|
302
|
-
activeTasks--;
|
|
303
|
-
onActivity();
|
|
249
|
+
this.#createWorker();
|
|
250
|
+
}
|
|
251
|
+
async execute(command, options, inlineConfig) {
|
|
252
|
+
if (this.options.timeout) {
|
|
253
|
+
this.#activeTasks++;
|
|
254
|
+
try {
|
|
255
|
+
let attempts = 0;
|
|
256
|
+
for (;;) {
|
|
257
|
+
this.onActivity();
|
|
258
|
+
if (await Promise.race([this.innerExecute(command, options, inlineConfig), this.#restartPromise]) !== RESTARTED) return;
|
|
259
|
+
this.#logger.warn(`Execution Host Worker was restarted while calling method "${command}" (attempt ${attempts++}). Retrying the call...`);
|
|
304
260
|
}
|
|
305
|
-
}
|
|
306
|
-
|
|
261
|
+
} finally {
|
|
262
|
+
this.#activeTasks--;
|
|
263
|
+
this.onActivity();
|
|
264
|
+
}
|
|
265
|
+
} else await this.innerExecute(command, options, inlineConfig);
|
|
307
266
|
}
|
|
308
267
|
/**
|
|
309
268
|
* Closes the worker process, terminating it if it's still running. This method should be called when the worker is no longer needed, to free up system resources and ensure a clean shutdown. If the worker has already been terminated, this method will have no effect.
|
|
@@ -314,6 +273,39 @@ var ExecutionHostWorker = class ExecutionHostWorker {
|
|
|
314
273
|
await worker.close({ force: true });
|
|
315
274
|
this.#worker = void 0;
|
|
316
275
|
}
|
|
276
|
+
onHanging() {
|
|
277
|
+
if (!this.#worker) return;
|
|
278
|
+
this.#createWorker();
|
|
279
|
+
this.#logger.warn(`Sending SIGTERM signal to worker due to timeout${this.options.timeout ? ` of ${formatDuration({ seconds: this.options.timeout / 1e3 })}` : ""}. Subsequent errors may be a result of the worker exiting.`);
|
|
280
|
+
this.finalize().then(() => {
|
|
281
|
+
this.#resolveRestartPromise?.(RESTARTED);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
onActivity() {
|
|
285
|
+
if (this.#hangingTimer) clearTimeout(this.#hangingTimer);
|
|
286
|
+
this.#hangingTimer = this.#activeTasks > 0 && setTimeout(() => this.onHanging(), this.options.timeout);
|
|
287
|
+
}
|
|
288
|
+
async innerExecute(command, options, inlineConfig) {
|
|
289
|
+
if (!this.#worker) throw new Error("Execution Host Worker is not initialized");
|
|
290
|
+
const { port1, port2 } = new MessageChannel();
|
|
291
|
+
const promise = this.#worker.run({
|
|
292
|
+
command,
|
|
293
|
+
options,
|
|
294
|
+
inlineConfig,
|
|
295
|
+
port: port2
|
|
296
|
+
}, { transferList: [port2] });
|
|
297
|
+
let aborted = false;
|
|
298
|
+
const onActivityAbort = () => {
|
|
299
|
+
if (!aborted) aborted = true;
|
|
300
|
+
};
|
|
301
|
+
pipeline(new MessagePortDuplex(port1, { onActivityAbort }), process.stdout, (err) => {
|
|
302
|
+
if (err) {
|
|
303
|
+
this.#logger.debug(`Received exception message from worker: ${JSON.stringify(err, null, 2)}`);
|
|
304
|
+
throw err;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
await promise;
|
|
308
|
+
}
|
|
317
309
|
};
|
|
318
310
|
|
|
319
311
|
//#endregion
|
|
@@ -331,7 +323,7 @@ var PowerlinesEngine = class {
|
|
|
331
323
|
/**
|
|
332
324
|
* The execution host, which provides methods to call the execution API functions from the engine context. This allows the engine to invoke commands and other API functions during the execution of Powerlines commands, enabling communication between the engine and the execution contexts.
|
|
333
325
|
*/
|
|
334
|
-
#
|
|
326
|
+
#api;
|
|
335
327
|
/**
|
|
336
328
|
* The Powerlines context
|
|
337
329
|
*/
|
|
@@ -341,19 +333,19 @@ var PowerlinesEngine = class {
|
|
|
341
333
|
/**
|
|
342
334
|
* The execution host, which provides methods to call the execution API functions from the engine context. This allows the engine to invoke commands and other API functions during the execution of Powerlines commands, enabling communication between the engine and the execution contexts.
|
|
343
335
|
*/
|
|
344
|
-
get
|
|
345
|
-
return this.#
|
|
336
|
+
get api() {
|
|
337
|
+
return this.#api;
|
|
346
338
|
}
|
|
347
339
|
/**
|
|
348
340
|
* Create a new Powerlines Engine instance
|
|
349
341
|
*
|
|
350
342
|
* @param context - The Powerlines context
|
|
351
|
-
* @param
|
|
343
|
+
* @param api - The API host for the execution workers
|
|
352
344
|
* @returns A new instance of the Powerlines Engine
|
|
353
345
|
*/
|
|
354
|
-
constructor(context,
|
|
346
|
+
constructor(context, api) {
|
|
355
347
|
this.#context = context;
|
|
356
|
-
this.#
|
|
348
|
+
this.#api = api;
|
|
357
349
|
}
|
|
358
350
|
/**
|
|
359
351
|
* Create a new Powerlines project
|
|
@@ -502,7 +494,7 @@ var PowerlinesEngine = class {
|
|
|
502
494
|
async finalize() {
|
|
503
495
|
const timer = this.context.timer("Finalize");
|
|
504
496
|
this.context.info("🏁 Finalization processes started");
|
|
505
|
-
await this.
|
|
497
|
+
await this.api.finalize();
|
|
506
498
|
this.context.debug("✔ Finalization completed successfully");
|
|
507
499
|
timer();
|
|
508
500
|
}
|
|
@@ -518,16 +510,16 @@ var PowerlinesEngine = class {
|
|
|
518
510
|
* @remarks
|
|
519
511
|
* This method will load the executions for the specified command and inline configuration, then execute each one while managing their lifecycle, including handling their completion and any errors that may occur during execution.
|
|
520
512
|
*
|
|
521
|
-
* @param
|
|
513
|
+
* @param command - The path to the execution configuration to load and run, which can be used to specify different execution configurations for different commands or scenarios.
|
|
522
514
|
* @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.
|
|
523
515
|
* @returns A promise that resolves when all executions for the specified command have completed
|
|
524
516
|
*/
|
|
525
|
-
async execute(
|
|
526
|
-
await Promise.all((await this.context.loadExecutions(
|
|
517
|
+
async execute(command, inlineConfig) {
|
|
518
|
+
await Promise.all((await this.context.loadExecutions(command, inlineConfig)).map(async (execution) => {
|
|
527
519
|
try {
|
|
528
|
-
await this.
|
|
520
|
+
await this.api.execute(command, execution.options, inlineConfig);
|
|
529
521
|
} catch (error) {
|
|
530
|
-
this.context.error(`Execution of method "${
|
|
522
|
+
this.context.error(`Execution of method "${command}" failed for execution with invocation ID "${execution.invocationId}" and execution ID "${execution.options.executionId}": \n\n${error instanceof Error ? error.stack || error.message : String(error)}`);
|
|
531
523
|
throw error;
|
|
532
524
|
} finally {
|
|
533
525
|
this.context.completeExecution(execution.invocationId, execution.options.executionId);
|
|
@@ -556,16 +548,15 @@ async function createContext(options) {
|
|
|
556
548
|
websocket: port
|
|
557
549
|
});
|
|
558
550
|
}
|
|
559
|
-
async function createEngine(options, apiPath = "@powerlines/engine/api"
|
|
551
|
+
async function createEngine(options, apiPath = "@powerlines/engine/api") {
|
|
560
552
|
EventEmitter.setMaxListeners(Infinity);
|
|
561
553
|
const context = await createContext(options);
|
|
562
|
-
return new PowerlinesEngine(context, await
|
|
554
|
+
return new PowerlinesEngine(context, await ExecutionApiWorker.from(apiPath, {
|
|
563
555
|
root: options.root,
|
|
564
|
-
context
|
|
565
|
-
apiMethods
|
|
556
|
+
context
|
|
566
557
|
}));
|
|
567
558
|
}
|
|
568
559
|
|
|
569
560
|
//#endregion
|
|
570
561
|
export { createContext as n, createEngine as r, PowerlinesEngine as t };
|
|
571
|
-
//# sourceMappingURL=engine-
|
|
562
|
+
//# sourceMappingURL=engine-CDFOkhKj.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-CDFOkhKj.mjs","names":["#restartPromise","#resolveRestartPromise","#logger","#worker","#createWorker","#activeTasks","#hangingTimer","#context","#api"],"sources":["../src/_internal/execution-api-worker.ts","../src/engine.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { InlineConfig, Logger, Mode } from \"@powerlines/core\";\nimport { getDefaultMode } from \"@powerlines/core/lib/config\";\nimport { resolve } from \"@stryke/fs/resolve\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { formatDuration } from \"date-fns/formatDuration\";\nimport { pipeline } from \"node:stream\";\nimport { parseArgs } from \"node:util\";\nimport {\n MessageChannel,\n StructuredSerializeOptions\n} from \"node:worker_threads\";\nimport Piscina from \"piscina\";\nimport { MessagePortDuplex } from \"../helpers/stream\";\nimport { ExecutionApiWorkerInterface } from \"../types\";\nimport { EngineExecutionOptions } from \"../types/config\";\nimport { EngineContext } from \"../types/context\";\n\nconst RESTARTED = Symbol(\"powerlines-worker:restarted\");\n\n/**\n * The debug address is in the form of `[host:]port`. The host is optional.\n */\ninterface DebugAddress {\n host?: string;\n port: number;\n}\n\n/**\n * Formats the debug address into a string.\n */\nconst formatDebugAddress = ({ host, port }: DebugAddress): string => {\n return host ? `${host}:${port}` : `${port}`;\n};\n\nexport type NodeOptions = Record<string, string | boolean | undefined>;\n\n/**\n * Get's the debug address from the `NODE_OPTIONS` environment variable. If the\n * address is not found, it returns the default host (`undefined`) and port\n * (`9229`).\n *\n * @returns An object with the host and port of the debug address.\n */\nconst getParsedDebugAddress = (\n address: string | boolean | undefined\n): DebugAddress => {\n if (!address || !isString(address)) {\n return { host: undefined, port: 9229 };\n }\n\n // The address is in the form of `[host:]port`. Let's parse the address.\n if (address.includes(\":\")) {\n const [host, port] = address.split(\":\");\n if (!host || !port) {\n throw new Error(`Invalid debug address: ${address}`);\n }\n\n return { host, port: Number.parseInt(port, 10) };\n }\n\n return { host: undefined, port: Number.parseInt(address, 10) };\n};\n\ntype NodeInspectType = \"inspect\" | \"inspect-brk\" | undefined;\n\n/**\n * Get the debug type from the `NODE_OPTIONS` environment variable.\n */\nfunction getNodeDebugType(nodeOptions: NodeOptions): NodeInspectType {\n if (nodeOptions.inspect) {\n return \"inspect\";\n }\n if (nodeOptions[\"inspect-brk\"] || nodeOptions.inspect_brk) {\n return \"inspect-brk\";\n }\n\n return undefined;\n}\n\nexport interface ExecutionApiWorkerOptions {\n // /**\n // * `-1` if not inspectable\n // */\n // debuggerPortOffset?: number;\n\n // /**\n // * Whether to enable source maps support in the worker, which can improve the quality of stack traces at the cost of increased memory usage and slower performance. Defaults to `false`.\n // */\n // enableSourceMaps?: boolean;\n\n /**\n * The maximum time in milliseconds a worker can run before being terminated.\n *\n * @defaultValue 900000 (15 minutes)\n */\n timeout?: number;\n\n /**\n * True if `--max-old-space-size` should not be forwarded to the worker.\n */\n isolatedMemory?: boolean;\n\n /**\n * The mode to run the worker in, which can affect how the worker is initialized and how it behaves. This is determined based on the resolved configuration of the engine, and can be used to optimize the worker for different environments (e.g., development, production, etc.).\n */\n mode?: Mode;\n\n /**\n * An optional root to resolve the execution host path from, which can be used to specify a custom root directory for the worker to use when resolving paths and loading configuration files. If this option is not provided, the worker will use the current working directory as the root directory by default.\n */\n root?: string;\n\n /**\n * The context of the {@link @powerlines/engine#Engine | Engine instance}, which can be used to access the engine's state and services within the worker.\n */\n context: EngineContext;\n}\n\nexport class ExecutionApiWorker implements ExecutionApiWorkerInterface {\n #worker: Piscina | undefined;\n\n #logger: Logger;\n\n #activeTasks = 0;\n\n #restartPromise: Promise<typeof RESTARTED> | null = null;\n\n #resolveRestartPromise: ((arg: typeof RESTARTED) => void) | null = null;\n\n #hangingTimer: NodeJS.Timeout | false = false;\n\n #createWorker: () => void;\n\n protected get restartPromise() {\n if (!this.#restartPromise) {\n this.#restartPromise = new Promise(resolve => {\n this.#resolveRestartPromise = resolve;\n });\n }\n return this.#restartPromise;\n }\n\n protected resolveRestartPromise() {\n if (this.#resolveRestartPromise) {\n this.#resolveRestartPromise(RESTARTED);\n this.#restartPromise = null;\n this.#resolveRestartPromise = null;\n }\n }\n\n /**\n * Creates a new instance of the Execution API Worker class, which manages a worker process for executing tasks related to the Powerlines Engine. The worker is initialized with the specified options and can be used to run tasks in an isolated environment, with support for automatic restarts and activity monitoring.\n *\n * @param apiPath - The path to the Execution API file.\n * @param options - The options for configuring the worker, including the execution context, exposed methods, timeout, and mode.\n * @returns A promise that resolves to an instance of the ExecutionApiWorker class.\n */\n public static async from(\n apiPath: string,\n options: ExecutionApiWorkerOptions\n ) {\n const mode = await getDefaultMode(options.context.cwd);\n\n const resolvedPath = await resolve(apiPath, {\n paths: [\n options.context.cwd,\n options.root ? appendPath(options.root, options.context.cwd) : undefined\n ].filter(Boolean) as string[]\n });\n if (!resolvedPath) {\n throw new Error(\n `Could not resolve the provided Execution API path: \\`${apiPath}\\`.`\n );\n }\n\n // let commands = toArray((options.commands ?? []) as string[]);\n // if (commands.length === 0) {\n // const jiti = createJiti(import.meta.url, {\n // cache: false,\n // interopDefault: true,\n // tsconfigPaths: true\n // });\n // const mod: Record<string, AnyFunction> = await jiti.import(\n // jiti.esmResolve(resolvedPath),\n // { default: true }\n // );\n // if (isSetObject(mod)) {\n // commands = Object.keys(mod).filter(name => isFunction(mod[name]));\n // }\n // }\n\n return new ExecutionApiWorker(resolvedPath, {\n mode,\n ...options\n });\n }\n\n /**\n * Create a new API worker instance.\n *\n * @param executionApiPath - The path to the worker file.\n * @param options - The options for the worker, including exposed commands, timeout, and hooks for activity and restart.\n */\n protected constructor(\n protected executionApiPath: string,\n protected options: ExecutionApiWorkerOptions\n ) {\n const {\n isolatedMemory = false,\n mode = \"production\",\n context\n } = this.options;\n\n this.options.timeout ??= 900_000;\n\n this.#logger = context.extendLogger({ category: \"communication\" });\n this.#worker = undefined;\n\n // ensure we end workers if they weren't before exit\n process.on(\"exit\", () => {\n void this.finalize();\n });\n\n let nodeOptions = {} as {\n [longOption: string]: string | boolean | undefined;\n };\n\n const args: string[] = [...process.execArgv];\n if (process.env.NODE_OPTIONS) {\n let isInString = false;\n let willStartNewArg = true;\n\n const stringifiedNodeOptions = process.env.NODE_OPTIONS.split(\" \").filter(\n part =>\n ((part.startsWith('\"') && part.endsWith('\"')) ||\n (part.startsWith(\"'\") && part.endsWith(\"'\"))) &&\n part\n .replace(/^['\"]|['\"]$/g, \"\")\n .split(\" \")\n .filter(isSetString).length > 0 &&\n part\n .replace(/^['\"]|['\"]$/g, \"\")\n .split(\" \")\n .filter(isSetString)\n .every(p => p.startsWith(\"--\"))\n );\n args.push(\n ...stringifiedNodeOptions.map(part => part.replace(/^['\"]|['\"]$/g, \"\"))\n );\n\n const inputNodeModules = stringifiedNodeOptions.reduce((acc, part) => {\n return acc.replace(part, \"\").trim();\n }, process.env.NODE_OPTIONS);\n for (let i = 0; i < inputNodeModules.length; i++) {\n let char = inputNodeModules[i];\n if (char) {\n // Skip any escaped characters in strings.\n if (char === \"\\\\\" && isInString) {\n // Ensure we don't have an escape character at the end.\n if (inputNodeModules.length === i + 1) {\n throw new Error(\"Invalid escape character at the end.\");\n }\n\n // Skip the next character.\n char = inputNodeModules[++i];\n if (!char) {\n continue;\n }\n }\n // If we find a space outside of a string, we should start a new argument.\n else if (char === \" \" && !isInString) {\n willStartNewArg = true;\n continue;\n }\n\n // If we find a quote, we should toggle the string flag.\n else if (char === '\"') {\n isInString = !isInString;\n continue;\n }\n\n // If we're starting a new argument, we should add it to the array.\n if (willStartNewArg) {\n args.push(char);\n willStartNewArg = false;\n }\n // Otherwise, add it to the last argument.\n else {\n args[args.length - 1] += char;\n }\n }\n }\n\n if (isInString) {\n throw new Error(\"Unterminated string\");\n }\n }\n\n if (args.length > 0) {\n const { values, tokens } = parseArgs({\n args,\n strict: false,\n tokens: true\n });\n nodeOptions = values;\n\n // For the `NODE_OPTIONS`, we support arguments with values without the `=`\n // sign. We need to parse them manually.\n let orphan = null;\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (!token) continue;\n\n if (token.kind === \"option-terminator\") {\n break;\n }\n\n // When we encounter an option, if it's value is undefined, we should check\n // to see if the following tokens are positional parameters. If they are,\n // then the option is orphaned, and we can assign it.\n if (token.kind === \"option\") {\n orphan = !isSet(token.value) ? token : null;\n continue;\n }\n\n // If the token isn't a positional one, then we can't assign it to the found\n // orphaned option.\n if (token.kind !== \"positional\") {\n orphan = null;\n continue;\n }\n\n // If we don't have an orphan, then we can skip this token.\n if (!orphan) {\n continue;\n }\n\n // If the token is a positional one, and it has a value, so add it to the\n // values object. If it already exists, append it with a space.\n if (orphan.name in nodeOptions && isString(nodeOptions[orphan.name])) {\n nodeOptions[orphan.name] += ` ${token.value}`;\n } else {\n nodeOptions[orphan.name] = token.value;\n }\n }\n }\n\n const originalOptions = { ...nodeOptions };\n\n delete nodeOptions.inspect;\n delete nodeOptions[\"inspect-brk\"];\n delete nodeOptions.inspect_brk;\n\n if (mode === \"development\") {\n const nodeDebugType = getNodeDebugType(originalOptions);\n if (nodeDebugType) {\n const debuggerAddress = getParsedDebugAddress(\n originalOptions[nodeDebugType]\n );\n const address: DebugAddress = {\n host: debuggerAddress.host,\n // current process runs on `address.port`\n port: debuggerAddress.port === 0 ? 0 : debuggerAddress.port + 1 + 1\n };\n nodeOptions[nodeDebugType] = formatDebugAddress(address);\n }\n\n nodeOptions[\"enable-source-maps\"] = true;\n }\n\n if (isolatedMemory) {\n delete nodeOptions[\"max-old-space-size\"];\n delete nodeOptions.max_old_space_size;\n }\n\n const execArgv: string[] = [];\n const nodeOptionsParts: string[] = [];\n for (const [key, value] of Object.entries(nodeOptions)) {\n let formatted: string | null = null;\n if (value === true) {\n formatted = `--${key}`;\n } else if (value) {\n formatted = `--${key}=${\n // Values with spaces need to be quoted. We use JSON.stringify to\n // also escape any nested quotes.\n value.includes(\" \") && !value.startsWith('\"')\n ? JSON.stringify(value)\n : value\n }`;\n }\n\n if (formatted === null) {\n continue;\n }\n\n if (\n [\n \"experimental-network-inspection\",\n \"experimental-storage-inspection\",\n \"experimental-worker-inspection\",\n \"experimental-inspector-network-resource\"\n ].includes(key)\n ) {\n execArgv.push(formatted);\n } else {\n nodeOptionsParts.push(formatted);\n }\n }\n\n this.#createWorker = () => {\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n NODE_ENV: mode,\n NODE_OPTIONS: nodeOptionsParts.join(\" \"),\n POWERLINES_EXECUTION_WORKER: \"true\"\n };\n\n // Mirror the enablement heuristic from picocolors (see https://github.com/vercel/next.js/blob/6a40da0345939fe4f7b1ae519b296a86dd103432/packages/next/src/lib/picocolors.ts#L21-L24).\n // Picocolors snapshots `process.env`/`stdout.isTTY` at module load time, so when the worker\n // process bootstraps with piped stdio its own check would disable colors. Re-evaluating the\n // same conditions here lets us opt the worker into color output only when the parent would\n // have seen colors, while still respecting explicit opt-outs like NO_COLOR.\n if (\n env.FORCE_COLOR === undefined &&\n !env.NO_COLOR &&\n !env.CI &&\n env.TERM !== \"dumb\" &&\n (process.stdout.isTTY || process.stderr?.isTTY)\n ) {\n env.FORCE_COLOR = \"1\";\n }\n\n this.#logger.debug(\n `Creating worker from file ${\n executionApiPath\n } with execution arguments: ${JSON.stringify(execArgv, null, 2)}`\n );\n\n this.#worker = new Piscina({\n filename: executionApiPath,\n execArgv,\n env\n });\n\n this.#restartPromise = new Promise(resolve => {\n this.#resolveRestartPromise = resolve;\n });\n\n this.#worker.on(\"exit\", (code, signal) => {\n this.#logger.debug(\n `Worker process exited with code ${code} and signal ${signal}`\n );\n\n if ((code || (signal && signal !== \"SIGINT\")) && this.#worker) {\n const error = new Error(\n `Execution Host Worker exited unexpectedly with code ${\n code\n } and signal ${signal}`\n );\n this.#logger.error(error);\n\n void this.finalize().then(() => {\n throw error;\n });\n }\n });\n\n this.#worker.on(\"error\", error => {\n this.#logger.error({\n meta: { category: \"communication\" },\n message: `Worker process emitted an error: ${error.message}`,\n error\n });\n });\n\n // if a child process emits a particular message, we track that as activity\n // so the parent process can keep track of progress\n this.#worker.on(\"message\", data => {\n this.onActivity();\n\n if (Array.isArray(data) && data.length > 1 && isNumber(data[0])) {\n if (data[0] === 0) {\n this.#logger.trace(\n `Received message from worker: ${JSON.stringify(data.slice(1), null, 2)}`\n );\n } else {\n this.#logger.debug(\n `Received error message from worker: ${JSON.stringify(\n data.slice(1),\n null,\n 2\n )}`\n );\n }\n }\n\n this.#logger.trace(\n `Received message from worker: ${JSON.stringify(data, null, 2)}`\n );\n });\n };\n\n this.#createWorker();\n }\n\n public async execute(\n command: string,\n options: EngineExecutionOptions,\n inlineConfig: InlineConfig\n ) {\n if (this.options.timeout) {\n this.#activeTasks++;\n try {\n let attempts = 0;\n for (;;) {\n this.onActivity();\n\n const result = await Promise.race([\n this.innerExecute(command, options, inlineConfig),\n this.#restartPromise\n ]);\n if (result !== RESTARTED) {\n return;\n }\n\n this.#logger.warn(\n `Execution Host Worker was restarted while calling method \"${\n command\n }\" (attempt ${attempts++}). Retrying the call...`\n );\n }\n } finally {\n this.#activeTasks--;\n this.onActivity();\n }\n } else {\n await this.innerExecute(command, options, inlineConfig);\n }\n }\n\n /**\n * Closes the worker process, terminating it if it's still running. This method should be called when the worker is no longer needed, to free up system resources and ensure a clean shutdown. If the worker has already been terminated, this method will have no effect.\n */\n public async finalize(): Promise<void> {\n const worker = this.#worker;\n if (!worker) {\n return;\n }\n\n await worker.close({\n force: true\n });\n this.#worker = undefined;\n }\n\n protected onHanging() {\n if (!this.#worker) {\n return;\n }\n\n this.#createWorker();\n\n this.#logger.warn(\n `Sending SIGTERM signal to worker due to timeout${\n this.options.timeout\n ? ` of ${formatDuration({ seconds: this.options.timeout / 1000 })}`\n : \"\"\n }. Subsequent errors may be a result of the worker exiting.`\n );\n\n void this.finalize().then(() => {\n this.#resolveRestartPromise?.(RESTARTED);\n });\n }\n\n protected onActivity() {\n if (this.#hangingTimer) {\n clearTimeout(this.#hangingTimer);\n }\n\n this.#hangingTimer =\n this.#activeTasks > 0 &&\n setTimeout(() => this.onHanging(), this.options.timeout);\n }\n\n protected async innerExecute(\n command: string,\n options: EngineExecutionOptions,\n inlineConfig: InlineConfig\n ) {\n if (!this.#worker) {\n throw new Error(\"Execution Host Worker is not initialized\");\n }\n\n const { port1, port2 } = new MessageChannel();\n const promise = this.#worker.run(\n { command, options, inlineConfig, port: port2 },\n {\n transferList: [port2] as StructuredSerializeOptions\n }\n );\n\n let aborted = false;\n const onActivityAbort = () => {\n if (!aborted) {\n aborted = true;\n }\n };\n const duplex = new MessagePortDuplex(port1, { onActivityAbort });\n\n pipeline(duplex, process.stdout, (err: NodeJS.ErrnoException | null) => {\n if (err) {\n this.#logger.debug(\n `Received exception message from worker: ${JSON.stringify(\n err,\n null,\n 2\n )}`\n );\n\n throw err;\n }\n });\n\n await promise;\n }\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n BuildInlineConfig,\n CleanInlineConfig,\n CreateInlineConfig,\n DeployInlineConfig,\n DocsInlineConfig,\n InlineConfig,\n LintInlineConfig,\n PrepareInlineConfig,\n TestInlineConfig,\n TypesInlineConfig\n} from \"@powerlines/core\";\nimport { createH3DevToolsHost } from \"devframe/node\";\nimport { getPort } from \"get-port-please\";\nimport { createApp, fromNodeMiddleware } from \"h3\";\nimport { EventEmitter } from \"node:events\";\nimport sirv from \"sirv\";\nimport { ExecutionApiWorker } from \"./_internal/execution-api-worker\";\nimport { PowerlinesEngineContext } from \"./context/engine-context\";\nimport { Engine } from \"./types/api\";\nimport { EngineOptions } from \"./types/config\";\nimport { EngineContext } from \"./types/context\";\n\n/**\n * The Powerlines process' orchestration and coordination API.\n *\n * @public\n */\nexport class PowerlinesEngine implements Engine, AsyncDisposable {\n /**\n * The Powerlines context\n */\n #context: EngineContext;\n\n /**\n * The execution host, which provides methods to call the execution API functions from the engine context. This allows the engine to invoke commands and other API functions during the execution of Powerlines commands, enabling communication between the engine and the execution contexts.\n */\n #api: ExecutionApiWorker;\n\n /**\n * The Powerlines context\n */\n public get context(): EngineContext {\n return this.#context;\n }\n\n /**\n * The execution host, which provides methods to call the execution API functions from the engine context. This allows the engine to invoke commands and other API functions during the execution of Powerlines commands, enabling communication between the engine and the execution contexts.\n */\n public get api(): ExecutionApiWorker {\n return this.#api;\n }\n\n /**\n * Create a new Powerlines Engine instance\n *\n * @param context - The Powerlines context\n * @param api - The API host for the execution workers\n * @returns A new instance of the Powerlines Engine\n */\n public constructor(context: EngineContext, api: ExecutionApiWorker) {\n this.#context = context;\n this.#api = api;\n }\n\n /**\n * Create a new Powerlines project\n *\n * @remarks\n * This method will create a new Powerlines project in the current directory.\n *\n * @param inlineConfig - The inline configuration for the create command\n * @returns A promise that resolves when the project has been created\n */\n public async create(inlineConfig: CreateInlineConfig) {\n const timer = this.context.timer(\"Create\");\n this.context.info(\"🆕 Creating a new project\");\n\n await this.execute(\"create\", inlineConfig);\n\n this.context.debug(\"✔ Create command completed successfully\");\n timer();\n }\n\n /**\n * Generate the Powerlines typescript declaration file\n *\n * @remarks\n * This method will only generate the typescript declaration file for the Powerlines project. It is generally recommended to run the full `prepare` command, which will run this method as part of its process.\n *\n * @param inlineConfig - The inline configuration for the types command\n */\n public async types(inlineConfig: TypesInlineConfig) {\n const timer = this.context.timer(\"Types\");\n this.context.info(\"🏗️ Generating typescript declarations for the project\");\n\n await this.execute(\"types\", inlineConfig);\n\n this.context.debug(\"✔ Types generation has completed successfully\");\n timer();\n }\n\n /**\n * Prepare the Powerlines API\n *\n * @remarks\n * This method will prepare the Powerlines API for use, initializing any necessary resources.\n *\n * @param inlineConfig - The inline configuration for the prepare command\n */\n public async prepare(inlineConfig: PrepareInlineConfig) {\n const timer = this.context.timer(\"Prepare\");\n this.context.info(\"🏗️ Preparing the project\");\n\n await this.execute(\"prepare\", inlineConfig);\n\n this.context.debug(\"✔ Preparation has completed successfully\");\n timer();\n }\n\n /**\n * Clean any previously prepared artifacts\n *\n * @remarks\n * This method will remove the previous Powerlines artifacts from the project.\n *\n * @param inlineConfig - The inline configuration for the clean command\n * @returns A promise that resolves when the clean command has completed\n */\n public async clean(inlineConfig: CleanInlineConfig) {\n const timer = this.context.timer(\"Clean\");\n this.context.info(\"🧹 Cleaning the previous artifacts\");\n\n await this.execute(\"clean\", inlineConfig);\n\n this.context.debug(\"✔ Cleaning completed successfully\");\n timer();\n }\n\n /**\n * Lint the project\n *\n * @param inlineConfig - The inline configuration for the lint command\n * @returns A promise that resolves when the lint command has completed\n */\n public async lint(inlineConfig: LintInlineConfig) {\n const timer = this.context.timer(\"Lint\");\n this.context.info(\"📝 Linting the project\");\n\n await this.execute(\"lint\", inlineConfig);\n\n this.context.debug(\"✔ Linting completed successfully\");\n timer();\n }\n\n /**\n * Test the project\n *\n * @remarks\n * This method will run the tests for the Powerlines project.\n *\n * @param inlineConfig - The inline configuration for the test command\n * @returns A promise that resolves when the test command has completed\n */\n public async test(inlineConfig: TestInlineConfig) {\n const timer = this.context.timer(\"Test\");\n this.context.info(\"🧪 Running tests for the project\");\n\n await this.execute(\"test\", inlineConfig);\n\n this.context.debug(\"✔ Testing completed successfully\");\n timer();\n }\n\n /**\n * Build the project\n *\n * @remarks\n * This method will build the Powerlines project, generating the necessary artifacts.\n *\n * @param inlineConfig - The inline configuration for the build command\n * @returns A promise that resolves when the build command has completed\n */\n public async build(inlineConfig: BuildInlineConfig) {\n const timer = this.context.timer(\"Build\");\n this.context.info(\"📦 Building the project\");\n\n await this.execute(\"build\", inlineConfig);\n\n this.context.debug(\"✔ Build completed successfully\");\n timer();\n }\n\n /**\n * Prepare the documentation for the project\n *\n * @param inlineConfig - The inline configuration for the docs command\n * @returns A promise that resolves when the documentation generation has completed\n */\n public async docs(inlineConfig: DocsInlineConfig) {\n const timer = this.context.timer(\"Docs\");\n this.context.info(\"📓 Generating documentation for the project\");\n\n await this.execute(\"docs\", inlineConfig);\n\n this.context.debug(\"✔ Documentation generation completed successfully\");\n timer();\n }\n\n /**\n * Deploy the project source code\n *\n * @remarks\n * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.\n *\n * @param inlineConfig - The inline configuration for the deploy command\n * @returns A promise that resolves when the deploy command has completed\n */\n public async deploy(inlineConfig: DeployInlineConfig) {\n const timer = this.context.timer(\"Deploy\");\n this.context.info(\"🚀 Deploying the project\");\n\n await this.execute(\"deploy\", inlineConfig);\n\n this.context.debug(\"✔ Deployment completed successfully\");\n timer();\n }\n\n /**\n * Finalization/cleanup processing for the Powerlines API\n *\n * @remarks\n * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.\n *\n * @returns A promise that resolves when the finalization process has completed\n */\n public async finalize() {\n const timer = this.context.timer(\"Finalize\");\n this.context.info(\"🏁 Finalization processes started\");\n\n await this.api.finalize();\n\n this.context.debug(\"✔ Finalization completed successfully\");\n timer();\n }\n\n /**\n * Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.\n */\n public async [Symbol.asyncDispose]() {\n return this.finalize();\n }\n\n /**\n * Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.\n *\n * @remarks\n * This method will load the executions for the specified command and inline configuration, then execute each one while managing their lifecycle, including handling their completion and any errors that may occur during execution.\n *\n * @param command - The path to the execution configuration to load and run, which can be used to specify different execution configurations for different commands or scenarios.\n * @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.\n * @returns A promise that resolves when all executions for the specified command have completed\n */\n protected async execute(command: string, inlineConfig: InlineConfig) {\n await Promise.all(\n (await this.context.loadExecutions(command, inlineConfig)).map(\n async execution => {\n try {\n await this.api.execute(command, execution.options, inlineConfig);\n } catch (error) {\n this.context.error(\n `Execution of method \"${command}\" failed for execution with invocation ID \"${\n execution.invocationId\n }\" and execution ID \"${execution.options.executionId}\": \\n\\n${\n error instanceof Error\n ? error.stack || error.message\n : String(error)\n }`\n );\n\n throw error;\n } finally {\n this.context.completeExecution(\n execution.invocationId,\n execution.options.executionId\n );\n }\n }\n )\n );\n }\n}\n\nexport async function createContext(options: EngineOptions) {\n const port =\n options.port ??\n (await getPort({\n host: options.host || \"localhost\",\n random: true\n }));\n\n const app = createApp();\n const host = createH3DevToolsHost({\n appName: options.framework?.name || \"powerlines\",\n origin: `http://${options.host || \"localhost\"}:${port}`,\n mount: (base, dir) => {\n app.use(base, fromNodeMiddleware(sirv(dir, { dev: true, single: true })));\n }\n });\n\n return PowerlinesEngineContext.from(options, host, {\n backend: \"websocket\",\n websocket: port\n });\n}\n\nexport async function createEngine(\n options: EngineOptions,\n apiPath = \"@powerlines/engine/api\"\n) {\n EventEmitter.setMaxListeners(Infinity);\n\n const context = await createContext(options);\n const host = await ExecutionApiWorker.from(apiPath, {\n root: options.root,\n context\n });\n\n return new PowerlinesEngine(context, host);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,YAAY,OAAO,6BAA6B;;;;AAatD,MAAM,sBAAsB,EAAE,MAAM,WAAiC;CACnE,OAAO,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG;AACvC;;;;;;;;AAWA,MAAM,yBACJ,YACiB;CACjB,IAAI,CAAC,WAAW,CAAC,SAAS,OAAO,GAC/B,OAAO;EAAE,MAAM;EAAW,MAAM;CAAK;CAIvC,IAAI,QAAQ,SAAS,GAAG,GAAG;EACzB,MAAM,CAAC,MAAM,QAAQ,QAAQ,MAAM,GAAG;EACtC,IAAI,CAAC,QAAQ,CAAC,MACZ,MAAM,IAAI,MAAM,0BAA0B,SAAS;EAGrD,OAAO;GAAE;GAAM,MAAM,OAAO,SAAS,MAAM,EAAE;EAAE;CACjD;CAEA,OAAO;EAAE,MAAM;EAAW,MAAM,OAAO,SAAS,SAAS,EAAE;CAAE;AAC/D;;;;AAOA,SAAS,iBAAiB,aAA2C;CACnE,IAAI,YAAY,SACd,OAAO;CAET,IAAI,YAAY,kBAAkB,YAAY,aAC5C,OAAO;AAIX;AAyCA,IAAa,qBAAb,MAAa,mBAA0D;CAsFzD;CACA;CAtFZ;CAEA;CAEA,eAAe;CAEf,kBAAoD;CAEpD,yBAAmE;CAEnE,gBAAwC;CAExC;CAEA,IAAc,iBAAiB;EAC7B,IAAI,CAAC,KAAKA,iBACR,KAAKA,kB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