@powerlines/engine 0.15.19 → 0.15.21
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/build.cjs +1 -1
- package/dist/api/build.d.mts +2 -2
- package/dist/api/build.mjs +1 -1
- package/dist/api/build.mjs.map +1 -1
- package/dist/api/clean.d.mts +2 -2
- package/dist/api/clean.mjs.map +1 -1
- package/dist/api/create.d.mts +2 -2
- package/dist/api/create.mjs.map +1 -1
- package/dist/api/deploy.d.mts +2 -2
- package/dist/api/deploy.mjs.map +1 -1
- package/dist/api/docs.d.mts +2 -2
- package/dist/api/docs.mjs.map +1 -1
- package/dist/api/lint.d.mts +2 -2
- package/dist/api/lint.mjs.map +1 -1
- package/dist/api/prepare.cjs +2 -2
- package/dist/api/prepare.d.mts +2 -2
- package/dist/api/prepare.mjs +2 -2
- package/dist/api/prepare.mjs.map +1 -1
- package/dist/api/test.d.mts +2 -2
- package/dist/api/test.mjs.map +1 -1
- package/dist/api/types.cjs +2 -2
- package/dist/api/types.d.mts +2 -2
- package/dist/api/types.mjs +2 -2
- package/dist/api/types.mjs.map +1 -1
- package/dist/{api-Cdw4v0W4.d.mts → api-B2dWvRMM.d.mts} +10 -7
- package/dist/api-B2dWvRMM.d.mts.map +1 -0
- package/dist/{api-6w4hZL6n.d.cts → api-DgxYwNuZ.d.cts} +8 -5
- package/dist/api-DgxYwNuZ.d.cts.map +1 -0
- package/dist/{execution-host.cjs → api.cjs} +1 -1
- package/dist/{execution-host.d.mts → api.d.cts} +3 -3
- package/dist/api.d.cts.map +1 -0
- package/dist/{execution-host.d.cts → api.d.mts} +3 -3
- package/dist/api.d.mts.map +1 -0
- package/dist/{execution-host.mjs → api.mjs} +2 -2
- package/dist/api.mjs.map +1 -0
- package/dist/{config-BNe23XHx.d.mts → config-C9AD-erz.d.mts} +1 -1
- package/dist/config-C9AD-erz.d.mts.map +1 -0
- package/dist/config-D6xUniHh.d.cts.map +1 -1
- package/dist/context/engine-context.cjs +6 -4
- package/dist/context/engine-context.d.cts +1 -1
- package/dist/context/engine-context.d.mts +1 -1
- package/dist/context/engine-context.mjs +6 -4
- package/dist/context/engine-context.mjs.map +1 -1
- package/dist/context/index.d.cts +1 -1
- package/dist/context/index.d.mts +1 -1
- package/dist/{context-DzgsMSWr.d.mts → context-S3XH2DWP.d.mts} +2 -2
- package/dist/context-S3XH2DWP.d.mts.map +1 -0
- package/dist/context-epL7NPvL.d.cts.map +1 -1
- package/dist/engine-Ct0OGdyp.mjs +571 -0
- package/dist/engine-Ct0OGdyp.mjs.map +1 -0
- package/dist/{engine-context-DEotmVzB.d.mts → engine-context-Cc93ql_I.d.mts} +5 -6
- package/dist/engine-context-Cc93ql_I.d.mts.map +1 -0
- package/dist/{engine-context-Dw8odBCo.d.cts → engine-context-lrWc13AH.d.cts} +2 -3
- package/dist/engine-context-lrWc13AH.d.cts.map +1 -0
- package/dist/engine-ntih8wNh.cjs +590 -0
- package/dist/engine.cjs +4 -265
- package/dist/engine.d.cts +3 -3
- package/dist/engine.d.cts.map +1 -1
- package/dist/engine.d.mts +5 -5
- package/dist/engine.d.mts.map +1 -1
- package/dist/engine.mjs +2 -262
- package/dist/helpers/create-execution-host.cjs +10 -3
- package/dist/helpers/create-execution-host.d.cts +20 -2
- package/dist/helpers/create-execution-host.d.cts.map +1 -0
- package/dist/helpers/create-execution-host.d.mts +20 -2
- package/dist/helpers/create-execution-host.d.mts.map +1 -0
- package/dist/helpers/create-execution-host.mjs +10 -3
- package/dist/helpers/create-execution-host.mjs.map +1 -1
- package/dist/helpers/finalize.d.cts +12 -2
- package/dist/helpers/finalize.d.cts.map +1 -0
- package/dist/helpers/finalize.d.mts +12 -2
- package/dist/helpers/finalize.d.mts.map +1 -0
- package/dist/helpers/finalize.mjs.map +1 -1
- package/dist/helpers/index.cjs +4 -2
- package/dist/helpers/index.d.cts +5 -5
- package/dist/helpers/index.d.mts +5 -5
- package/dist/helpers/index.mjs +2 -2
- package/dist/helpers/rpc.cjs +2 -2
- package/dist/helpers/rpc.d.cts +7 -2
- package/dist/helpers/rpc.d.cts.map +1 -0
- package/dist/helpers/rpc.d.mts +7 -2
- package/dist/helpers/rpc.d.mts.map +1 -0
- package/dist/helpers/rpc.mjs +2 -2
- package/dist/helpers/rpc.mjs.map +1 -1
- package/dist/helpers/stream.cjs +120 -0
- package/dist/helpers/stream.d.cts +45 -0
- package/dist/helpers/stream.d.cts.map +1 -0
- package/dist/helpers/stream.d.mts +45 -0
- package/dist/helpers/stream.d.mts.map +1 -0
- package/dist/helpers/stream.mjs +117 -0
- package/dist/helpers/stream.mjs.map +1 -0
- package/dist/index.cjs +2 -11
- package/dist/index.d.cts +3 -7
- package/dist/index.d.mts +5 -9
- package/dist/index.mjs +2 -7
- package/package.json +10 -12
- package/dist/api-6w4hZL6n.d.cts.map +0 -1
- package/dist/api-Cdw4v0W4.d.mts.map +0 -1
- package/dist/config-BNe23XHx.d.mts.map +0 -1
- package/dist/context-DzgsMSWr.d.mts.map +0 -1
- package/dist/create-execution-host-CdpuL_YG.d.mts +0 -20
- package/dist/create-execution-host-CdpuL_YG.d.mts.map +0 -1
- package/dist/create-execution-host-DbOCE5bd.d.cts +0 -20
- package/dist/create-execution-host-DbOCE5bd.d.cts.map +0 -1
- package/dist/engine-context-DEotmVzB.d.mts.map +0 -1
- package/dist/engine-context-Dw8odBCo.d.cts.map +0 -1
- package/dist/engine.mjs.map +0 -1
- package/dist/execution-host-worker-D7LinO52.d.cts +0 -70
- package/dist/execution-host-worker-D7LinO52.d.cts.map +0 -1
- package/dist/execution-host-worker-zpQqaW_W.d.mts +0 -70
- package/dist/execution-host-worker-zpQqaW_W.d.mts.map +0 -1
- package/dist/execution-host.d.cts.map +0 -1
- package/dist/execution-host.d.mts.map +0 -1
- package/dist/execution-host.mjs.map +0 -1
- package/dist/finalize-CW0cO75l.d.cts +0 -12
- package/dist/finalize-CW0cO75l.d.cts.map +0 -1
- package/dist/finalize-DeSY1r74.d.mts +0 -12
- package/dist/finalize-DeSY1r74.d.mts.map +0 -1
- package/dist/helpers/execution-host-worker.cjs +0 -327
- package/dist/helpers/execution-host-worker.d.cts +0 -2
- package/dist/helpers/execution-host-worker.d.mts +0 -2
- package/dist/helpers/execution-host-worker.mjs +0 -326
- package/dist/helpers/execution-host-worker.mjs.map +0 -1
- package/dist/rpc-BsFxzyAK.d.cts +0 -7
- package/dist/rpc-BsFxzyAK.d.cts.map +0 -1
- package/dist/rpc-xwbFMMNu.d.mts +0 -7
- package/dist/rpc-xwbFMMNu.d.mts.map +0 -1
- /package/dist/{index-D_TYgLX3.d.cts → index-DDRpa5CJ.d.cts} +0 -0
package/dist/engine.cjs
CHANGED
|
@@ -1,267 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const require_context_engine_context = require('./context/engine-context.cjs');
|
|
4
|
-
const require_helpers_execution_host_worker = require('./helpers/execution-host-worker.cjs');
|
|
5
|
-
let devframe_node = require("devframe/node");
|
|
6
|
-
let get_port_please = require("get-port-please");
|
|
7
|
-
let h3 = require("h3");
|
|
8
|
-
let node_events = require("node:events");
|
|
9
|
-
let sirv = require("sirv");
|
|
10
|
-
sirv = require_chunk.__toESM(sirv, 1);
|
|
2
|
+
const require_engine = require('./engine-ntih8wNh.cjs');
|
|
11
3
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
var PowerlinesEngine = class {
|
|
19
|
-
/**
|
|
20
|
-
* The Powerlines context
|
|
21
|
-
*/
|
|
22
|
-
#context;
|
|
23
|
-
/**
|
|
24
|
-
* 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.
|
|
25
|
-
*/
|
|
26
|
-
#host;
|
|
27
|
-
/**
|
|
28
|
-
* The Powerlines context
|
|
29
|
-
*/
|
|
30
|
-
get context() {
|
|
31
|
-
return this.#context;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 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.
|
|
35
|
-
*/
|
|
36
|
-
get host() {
|
|
37
|
-
return this.#host;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Create a new Powerlines Engine instance
|
|
41
|
-
*
|
|
42
|
-
* @param context - The Powerlines context
|
|
43
|
-
* @param host - The API host for the execution workers
|
|
44
|
-
* @returns A new instance of the Powerlines Engine
|
|
45
|
-
*/
|
|
46
|
-
constructor(context, host) {
|
|
47
|
-
this.#context = context;
|
|
48
|
-
this.#host = host;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Create a new Powerlines project
|
|
52
|
-
*
|
|
53
|
-
* @remarks
|
|
54
|
-
* This method will create a new Powerlines project in the current directory.
|
|
55
|
-
*
|
|
56
|
-
* @param inlineConfig - The inline configuration for the create command
|
|
57
|
-
* @returns A promise that resolves when the project has been created
|
|
58
|
-
*/
|
|
59
|
-
async create(inlineConfig) {
|
|
60
|
-
const timer = this.context.timer("Create");
|
|
61
|
-
this.context.info("🆕 Creating a new project");
|
|
62
|
-
await this.execute("create", inlineConfig);
|
|
63
|
-
this.context.debug("✔ Create command completed successfully");
|
|
64
|
-
timer();
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Generate the Powerlines typescript declaration file
|
|
68
|
-
*
|
|
69
|
-
* @remarks
|
|
70
|
-
* 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.
|
|
71
|
-
*
|
|
72
|
-
* @param inlineConfig - The inline configuration for the types command
|
|
73
|
-
*/
|
|
74
|
-
async types(inlineConfig) {
|
|
75
|
-
const timer = this.context.timer("Types");
|
|
76
|
-
this.context.info("🏗️ Generating typescript declarations for the project");
|
|
77
|
-
await this.execute("types", inlineConfig);
|
|
78
|
-
this.context.debug("✔ Types generation has completed successfully");
|
|
79
|
-
timer();
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Prepare the Powerlines API
|
|
83
|
-
*
|
|
84
|
-
* @remarks
|
|
85
|
-
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
86
|
-
*
|
|
87
|
-
* @param inlineConfig - The inline configuration for the prepare command
|
|
88
|
-
*/
|
|
89
|
-
async prepare(inlineConfig) {
|
|
90
|
-
const timer = this.context.timer("Prepare");
|
|
91
|
-
this.context.info("🏗️ Preparing the project");
|
|
92
|
-
await this.execute("prepare", inlineConfig);
|
|
93
|
-
this.context.debug("✔ Preparation has completed successfully");
|
|
94
|
-
timer();
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Clean any previously prepared artifacts
|
|
98
|
-
*
|
|
99
|
-
* @remarks
|
|
100
|
-
* This method will remove the previous Powerlines artifacts from the project.
|
|
101
|
-
*
|
|
102
|
-
* @param inlineConfig - The inline configuration for the clean command
|
|
103
|
-
* @returns A promise that resolves when the clean command has completed
|
|
104
|
-
*/
|
|
105
|
-
async clean(inlineConfig) {
|
|
106
|
-
const timer = this.context.timer("Clean");
|
|
107
|
-
this.context.info("🧹 Cleaning the previous artifacts");
|
|
108
|
-
await this.execute("clean", inlineConfig);
|
|
109
|
-
this.context.debug("✔ Cleaning completed successfully");
|
|
110
|
-
timer();
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Lint the project
|
|
114
|
-
*
|
|
115
|
-
* @param inlineConfig - The inline configuration for the lint command
|
|
116
|
-
* @returns A promise that resolves when the lint command has completed
|
|
117
|
-
*/
|
|
118
|
-
async lint(inlineConfig) {
|
|
119
|
-
const timer = this.context.timer("Lint");
|
|
120
|
-
this.context.info("📝 Linting the project");
|
|
121
|
-
await this.execute("lint", inlineConfig);
|
|
122
|
-
this.context.debug("✔ Linting completed successfully");
|
|
123
|
-
timer();
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Test the project
|
|
127
|
-
*
|
|
128
|
-
* @remarks
|
|
129
|
-
* This method will run the tests for the Powerlines project.
|
|
130
|
-
*
|
|
131
|
-
* @param inlineConfig - The inline configuration for the test command
|
|
132
|
-
* @returns A promise that resolves when the test command has completed
|
|
133
|
-
*/
|
|
134
|
-
async test(inlineConfig) {
|
|
135
|
-
const timer = this.context.timer("Test");
|
|
136
|
-
this.context.info("🧪 Running tests for the project");
|
|
137
|
-
await this.execute("test", inlineConfig);
|
|
138
|
-
this.context.debug("✔ Testing completed successfully");
|
|
139
|
-
timer();
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Build the project
|
|
143
|
-
*
|
|
144
|
-
* @remarks
|
|
145
|
-
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
146
|
-
*
|
|
147
|
-
* @param inlineConfig - The inline configuration for the build command
|
|
148
|
-
* @returns A promise that resolves when the build command has completed
|
|
149
|
-
*/
|
|
150
|
-
async build(inlineConfig) {
|
|
151
|
-
const timer = this.context.timer("Build");
|
|
152
|
-
this.context.info("📦 Building the project");
|
|
153
|
-
await this.execute("build", inlineConfig);
|
|
154
|
-
this.context.debug("✔ Build completed successfully");
|
|
155
|
-
timer();
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Prepare the documentation for the project
|
|
159
|
-
*
|
|
160
|
-
* @param inlineConfig - The inline configuration for the docs command
|
|
161
|
-
* @returns A promise that resolves when the documentation generation has completed
|
|
162
|
-
*/
|
|
163
|
-
async docs(inlineConfig) {
|
|
164
|
-
const timer = this.context.timer("Docs");
|
|
165
|
-
this.context.info("📓 Generating documentation for the project");
|
|
166
|
-
await this.execute("docs", inlineConfig);
|
|
167
|
-
this.context.debug("✔ Documentation generation completed successfully");
|
|
168
|
-
timer();
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Deploy the project source code
|
|
172
|
-
*
|
|
173
|
-
* @remarks
|
|
174
|
-
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
175
|
-
*
|
|
176
|
-
* @param inlineConfig - The inline configuration for the deploy command
|
|
177
|
-
* @returns A promise that resolves when the deploy command has completed
|
|
178
|
-
*/
|
|
179
|
-
async deploy(inlineConfig) {
|
|
180
|
-
const timer = this.context.timer("Deploy");
|
|
181
|
-
this.context.info("🚀 Deploying the project");
|
|
182
|
-
await this.execute("deploy", inlineConfig);
|
|
183
|
-
this.context.debug("✔ Deployment completed successfully");
|
|
184
|
-
timer();
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Finalization/cleanup processing for the Powerlines API
|
|
188
|
-
*
|
|
189
|
-
* @remarks
|
|
190
|
-
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
191
|
-
*
|
|
192
|
-
* @returns A promise that resolves when the finalization process has completed
|
|
193
|
-
*/
|
|
194
|
-
async finalize() {
|
|
195
|
-
const timer = this.context.timer("Finalize");
|
|
196
|
-
this.context.info("🏁 Finalization processes started");
|
|
197
|
-
await this.host.end();
|
|
198
|
-
this.context.debug("✔ Finalization completed successfully");
|
|
199
|
-
timer();
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.
|
|
203
|
-
*/
|
|
204
|
-
async [Symbol.asyncDispose]() {
|
|
205
|
-
return this.finalize();
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.
|
|
209
|
-
*
|
|
210
|
-
* @remarks
|
|
211
|
-
* 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.
|
|
212
|
-
*
|
|
213
|
-
* @param method - The path to the execution configuration to load and run, which can be used to specify different execution configurations for different commands or scenarios.
|
|
214
|
-
* @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.
|
|
215
|
-
* @returns A promise that resolves when all executions for the specified command have completed
|
|
216
|
-
*/
|
|
217
|
-
async execute(method, inlineConfig) {
|
|
218
|
-
await Promise.all((await this.context.loadExecutions(method, inlineConfig)).map(async (execution) => {
|
|
219
|
-
try {
|
|
220
|
-
await this.host[method]({
|
|
221
|
-
options: execution.options,
|
|
222
|
-
inlineConfig
|
|
223
|
-
});
|
|
224
|
-
} catch (error) {
|
|
225
|
-
this.context.error(`Execution of method "${method}" 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)}`);
|
|
226
|
-
throw error;
|
|
227
|
-
} finally {
|
|
228
|
-
this.context.completeExecution(execution.invocationId, execution.options.executionId);
|
|
229
|
-
}
|
|
230
|
-
}));
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
async function createContext(options) {
|
|
234
|
-
const port = options.port ?? await (0, get_port_please.getPort)({
|
|
235
|
-
host: options.host || "localhost",
|
|
236
|
-
random: true
|
|
237
|
-
});
|
|
238
|
-
const app = (0, h3.createApp)();
|
|
239
|
-
const host = (0, devframe_node.createH3DevToolsHost)({
|
|
240
|
-
appName: options.framework?.name || "powerlines",
|
|
241
|
-
origin: `http://${options.host || "localhost"}:${port}`,
|
|
242
|
-
mount: (base, dir) => {
|
|
243
|
-
app.use(base, (0, h3.fromNodeMiddleware)((0, sirv.default)(dir, {
|
|
244
|
-
dev: true,
|
|
245
|
-
single: true
|
|
246
|
-
})));
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
return require_context_engine_context.PowerlinesEngineContext.from(options, host, {
|
|
250
|
-
backend: "websocket",
|
|
251
|
-
websocket: port
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
async function createEngine(options, executionHostPath = "@powerlines/engine/execution-host", executionMethods) {
|
|
255
|
-
node_events.EventEmitter.setMaxListeners(100);
|
|
256
|
-
const context = await createContext(options);
|
|
257
|
-
return new PowerlinesEngine(context, await require_helpers_execution_host_worker.ExecutionHostWorker.from(executionHostPath, {
|
|
258
|
-
root: options.root,
|
|
259
|
-
context,
|
|
260
|
-
executionMethods
|
|
261
|
-
}));
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
//#endregion
|
|
265
|
-
exports.PowerlinesEngine = PowerlinesEngine;
|
|
266
|
-
exports.createContext = createContext;
|
|
267
|
-
exports.createEngine = createEngine;
|
|
4
|
+
exports.PowerlinesEngine = require_engine.PowerlinesEngine;
|
|
5
|
+
exports.createContext = require_engine.createContext;
|
|
6
|
+
exports.createEngine = require_engine.createEngine;
|
package/dist/engine.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as EngineOptions } from "./config-D6xUniHh.cjs";
|
|
2
2
|
import { t as EngineContext } from "./context-epL7NPvL.cjs";
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
3
|
+
import { n as ExecutionHost, t as Engine } from "./api-DgxYwNuZ.cjs";
|
|
4
|
+
import { t as PowerlinesEngineContext } from "./engine-context-lrWc13AH.cjs";
|
|
5
5
|
import { BuildInlineConfig, CleanInlineConfig, CreateInlineConfig, DeployInlineConfig, DocsInlineConfig, InlineConfig, LintInlineConfig, PrepareInlineConfig, TestInlineConfig, TypesInlineConfig } from "@powerlines/core";
|
|
6
6
|
import { EXECUTION_API_METHODS } from "@powerlines/core/constants";
|
|
7
7
|
|
|
@@ -137,7 +137,7 @@ declare class PowerlinesEngine<TExecutionAPI extends ReadonlyArray<string> = typ
|
|
|
137
137
|
protected execute(method: TExecutionAPI[number], inlineConfig: InlineConfig): Promise<void>;
|
|
138
138
|
}
|
|
139
139
|
declare function createContext(options: EngineOptions): Promise<PowerlinesEngineContext<unknown>>;
|
|
140
|
-
declare function createEngine<TExecutionAPI extends ReadonlyArray<string>>(options: EngineOptions,
|
|
140
|
+
declare function createEngine<TExecutionAPI extends ReadonlyArray<string>>(options: EngineOptions, apiPath?: string, apiMethods?: TExecutionAPI): Promise<PowerlinesEngine<TExecutionAPI>>;
|
|
141
141
|
//#endregion
|
|
142
142
|
export { PowerlinesEngine, createContext, createEngine };
|
|
143
143
|
//# sourceMappingURL=engine.d.cts.map
|
package/dist/engine.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.cts","names":[],"sources":["../src/engine.ts"],"mappings":";;;;;;;;;;AA+CA;;;cAAa,gBAAA,uBACW,aAAA,kBAA+B,qBAAA,aAE1C,MAAA,CAAO,aAAA,GAAgB,eAAA;EAAA;EAAhB;;;EAAA,IAeP,OAAA,CAAA,GAAW,aAAA;EAmBX;;;EAAA,IAZA,IAAA,CAAA,GAAQ,aAAA,CAAc,aAAA;EA4BmB;;;;;;;cAhBlD,OAAA,EAAS,aAAA,EACT,IAAA,EAAM,aAAA,CAAc,aAAA;EAsF0B;;;;;;;;;EAvEnC,MAAA,CAAO,YAAA,EAAc,kBAAA,GAAkB,OAAA;EA+KlB;;;;;;;;EA7JrB,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAtElD;;;;;;;;EAwFa,OAAA,CAAQ,YAAA,EAAc,mBAAA,GAAmB,OAAA;EAhE3C;;;;;;;;;EAmFE,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAvDhB;;;;;;EAuErB,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAnCnC;;;;;;;;;EAsDA,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAnB9B;;;;;;;;;EAsCL,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAgBrC;;;;;;EAAA,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAmBI;;;;;;;;;EAAvC,MAAA,CAAO,YAAA,EAAc,kBAAA,GAAkB,OAAA;EA+ClD;;;;
|
|
1
|
+
{"version":3,"file":"engine.d.cts","names":[],"sources":["../src/engine.ts"],"mappings":";;;;;;;;;;AA+CA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AA,CACvD,OAAA,EAAS,aAAA,EACT,OAAA,WACA,UAAA,GAAa,aAAA,GAAa,OAAA,CAAA,gBAAA,CAAA,aAAA"}
|
package/dist/engine.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as EngineOptions } from "./config-
|
|
2
|
-
import { t as EngineContext } from "./context-
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
1
|
+
import { n as EngineOptions } from "./config-C9AD-erz.mjs";
|
|
2
|
+
import { t as EngineContext } from "./context-S3XH2DWP.mjs";
|
|
3
|
+
import { n as ExecutionHost, t as Engine } from "./api-B2dWvRMM.mjs";
|
|
4
|
+
import { t as PowerlinesEngineContext } from "./engine-context-Cc93ql_I.mjs";
|
|
5
5
|
import { BuildInlineConfig, CleanInlineConfig, CreateInlineConfig, DeployInlineConfig, DocsInlineConfig, InlineConfig, LintInlineConfig, PrepareInlineConfig, TestInlineConfig, TypesInlineConfig } from "@powerlines/core";
|
|
6
6
|
import { EXECUTION_API_METHODS } from "@powerlines/core/constants";
|
|
7
7
|
|
|
@@ -137,7 +137,7 @@ declare class PowerlinesEngine<TExecutionAPI extends ReadonlyArray<string> = typ
|
|
|
137
137
|
protected execute(method: TExecutionAPI[number], inlineConfig: InlineConfig): Promise<void>;
|
|
138
138
|
}
|
|
139
139
|
declare function createContext(options: EngineOptions): Promise<PowerlinesEngineContext<unknown>>;
|
|
140
|
-
declare function createEngine<TExecutionAPI extends ReadonlyArray<string>>(options: EngineOptions,
|
|
140
|
+
declare function createEngine<TExecutionAPI extends ReadonlyArray<string>>(options: EngineOptions, apiPath?: string, apiMethods?: TExecutionAPI): Promise<PowerlinesEngine<TExecutionAPI>>;
|
|
141
141
|
//#endregion
|
|
142
142
|
export { PowerlinesEngine, createContext, createEngine };
|
|
143
143
|
//# sourceMappingURL=engine.d.mts.map
|
package/dist/engine.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.mts","names":[],"sources":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js";
|
|
3
|
-
import { createH3DevToolsHost } from "devframe/node";
|
|
4
|
-
import { getPort } from "get-port-please";
|
|
5
|
-
import { createApp, fromNodeMiddleware } from "h3";
|
|
6
|
-
import { EventEmitter } from "node:events";
|
|
7
|
-
import sirv from "sirv";
|
|
1
|
+
import { n as createContext, r as createEngine, t as PowerlinesEngine } from "./engine-Ct0OGdyp.mjs";
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The Powerlines process' orchestration and coordination API.
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
var PowerlinesEngine = class {
|
|
16
|
-
/**
|
|
17
|
-
* The Powerlines context
|
|
18
|
-
*/
|
|
19
|
-
#context;
|
|
20
|
-
/**
|
|
21
|
-
* 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.
|
|
22
|
-
*/
|
|
23
|
-
#host;
|
|
24
|
-
/**
|
|
25
|
-
* The Powerlines context
|
|
26
|
-
*/
|
|
27
|
-
get context() {
|
|
28
|
-
return this.#context;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* 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.
|
|
32
|
-
*/
|
|
33
|
-
get host() {
|
|
34
|
-
return this.#host;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Create a new Powerlines Engine instance
|
|
38
|
-
*
|
|
39
|
-
* @param context - The Powerlines context
|
|
40
|
-
* @param host - The API host for the execution workers
|
|
41
|
-
* @returns A new instance of the Powerlines Engine
|
|
42
|
-
*/
|
|
43
|
-
constructor(context, host) {
|
|
44
|
-
this.#context = context;
|
|
45
|
-
this.#host = host;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Create a new Powerlines project
|
|
49
|
-
*
|
|
50
|
-
* @remarks
|
|
51
|
-
* This method will create a new Powerlines project in the current directory.
|
|
52
|
-
*
|
|
53
|
-
* @param inlineConfig - The inline configuration for the create command
|
|
54
|
-
* @returns A promise that resolves when the project has been created
|
|
55
|
-
*/
|
|
56
|
-
async create(inlineConfig) {
|
|
57
|
-
const timer = this.context.timer("Create");
|
|
58
|
-
this.context.info("🆕 Creating a new project");
|
|
59
|
-
await this.execute("create", inlineConfig);
|
|
60
|
-
this.context.debug("✔ Create command completed successfully");
|
|
61
|
-
timer();
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Generate the Powerlines typescript declaration file
|
|
65
|
-
*
|
|
66
|
-
* @remarks
|
|
67
|
-
* 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.
|
|
68
|
-
*
|
|
69
|
-
* @param inlineConfig - The inline configuration for the types command
|
|
70
|
-
*/
|
|
71
|
-
async types(inlineConfig) {
|
|
72
|
-
const timer = this.context.timer("Types");
|
|
73
|
-
this.context.info("🏗️ Generating typescript declarations for the project");
|
|
74
|
-
await this.execute("types", inlineConfig);
|
|
75
|
-
this.context.debug("✔ Types generation has completed successfully");
|
|
76
|
-
timer();
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Prepare the Powerlines API
|
|
80
|
-
*
|
|
81
|
-
* @remarks
|
|
82
|
-
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
83
|
-
*
|
|
84
|
-
* @param inlineConfig - The inline configuration for the prepare command
|
|
85
|
-
*/
|
|
86
|
-
async prepare(inlineConfig) {
|
|
87
|
-
const timer = this.context.timer("Prepare");
|
|
88
|
-
this.context.info("🏗️ Preparing the project");
|
|
89
|
-
await this.execute("prepare", inlineConfig);
|
|
90
|
-
this.context.debug("✔ Preparation has completed successfully");
|
|
91
|
-
timer();
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Clean any previously prepared artifacts
|
|
95
|
-
*
|
|
96
|
-
* @remarks
|
|
97
|
-
* This method will remove the previous Powerlines artifacts from the project.
|
|
98
|
-
*
|
|
99
|
-
* @param inlineConfig - The inline configuration for the clean command
|
|
100
|
-
* @returns A promise that resolves when the clean command has completed
|
|
101
|
-
*/
|
|
102
|
-
async clean(inlineConfig) {
|
|
103
|
-
const timer = this.context.timer("Clean");
|
|
104
|
-
this.context.info("🧹 Cleaning the previous artifacts");
|
|
105
|
-
await this.execute("clean", inlineConfig);
|
|
106
|
-
this.context.debug("✔ Cleaning completed successfully");
|
|
107
|
-
timer();
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Lint the project
|
|
111
|
-
*
|
|
112
|
-
* @param inlineConfig - The inline configuration for the lint command
|
|
113
|
-
* @returns A promise that resolves when the lint command has completed
|
|
114
|
-
*/
|
|
115
|
-
async lint(inlineConfig) {
|
|
116
|
-
const timer = this.context.timer("Lint");
|
|
117
|
-
this.context.info("📝 Linting the project");
|
|
118
|
-
await this.execute("lint", inlineConfig);
|
|
119
|
-
this.context.debug("✔ Linting completed successfully");
|
|
120
|
-
timer();
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Test the project
|
|
124
|
-
*
|
|
125
|
-
* @remarks
|
|
126
|
-
* This method will run the tests for the Powerlines project.
|
|
127
|
-
*
|
|
128
|
-
* @param inlineConfig - The inline configuration for the test command
|
|
129
|
-
* @returns A promise that resolves when the test command has completed
|
|
130
|
-
*/
|
|
131
|
-
async test(inlineConfig) {
|
|
132
|
-
const timer = this.context.timer("Test");
|
|
133
|
-
this.context.info("🧪 Running tests for the project");
|
|
134
|
-
await this.execute("test", inlineConfig);
|
|
135
|
-
this.context.debug("✔ Testing completed successfully");
|
|
136
|
-
timer();
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Build the project
|
|
140
|
-
*
|
|
141
|
-
* @remarks
|
|
142
|
-
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
143
|
-
*
|
|
144
|
-
* @param inlineConfig - The inline configuration for the build command
|
|
145
|
-
* @returns A promise that resolves when the build command has completed
|
|
146
|
-
*/
|
|
147
|
-
async build(inlineConfig) {
|
|
148
|
-
const timer = this.context.timer("Build");
|
|
149
|
-
this.context.info("📦 Building the project");
|
|
150
|
-
await this.execute("build", inlineConfig);
|
|
151
|
-
this.context.debug("✔ Build completed successfully");
|
|
152
|
-
timer();
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Prepare the documentation for the project
|
|
156
|
-
*
|
|
157
|
-
* @param inlineConfig - The inline configuration for the docs command
|
|
158
|
-
* @returns A promise that resolves when the documentation generation has completed
|
|
159
|
-
*/
|
|
160
|
-
async docs(inlineConfig) {
|
|
161
|
-
const timer = this.context.timer("Docs");
|
|
162
|
-
this.context.info("📓 Generating documentation for the project");
|
|
163
|
-
await this.execute("docs", inlineConfig);
|
|
164
|
-
this.context.debug("✔ Documentation generation completed successfully");
|
|
165
|
-
timer();
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Deploy the project source code
|
|
169
|
-
*
|
|
170
|
-
* @remarks
|
|
171
|
-
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
172
|
-
*
|
|
173
|
-
* @param inlineConfig - The inline configuration for the deploy command
|
|
174
|
-
* @returns A promise that resolves when the deploy command has completed
|
|
175
|
-
*/
|
|
176
|
-
async deploy(inlineConfig) {
|
|
177
|
-
const timer = this.context.timer("Deploy");
|
|
178
|
-
this.context.info("🚀 Deploying the project");
|
|
179
|
-
await this.execute("deploy", inlineConfig);
|
|
180
|
-
this.context.debug("✔ Deployment completed successfully");
|
|
181
|
-
timer();
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Finalization/cleanup processing for the Powerlines API
|
|
185
|
-
*
|
|
186
|
-
* @remarks
|
|
187
|
-
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
188
|
-
*
|
|
189
|
-
* @returns A promise that resolves when the finalization process has completed
|
|
190
|
-
*/
|
|
191
|
-
async finalize() {
|
|
192
|
-
const timer = this.context.timer("Finalize");
|
|
193
|
-
this.context.info("🏁 Finalization processes started");
|
|
194
|
-
await this.host.end();
|
|
195
|
-
this.context.debug("✔ Finalization completed successfully");
|
|
196
|
-
timer();
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.
|
|
200
|
-
*/
|
|
201
|
-
async [Symbol.asyncDispose]() {
|
|
202
|
-
return this.finalize();
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.
|
|
206
|
-
*
|
|
207
|
-
* @remarks
|
|
208
|
-
* 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.
|
|
209
|
-
*
|
|
210
|
-
* @param method - The path to the execution configuration to load and run, which can be used to specify different execution configurations for different commands or scenarios.
|
|
211
|
-
* @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.
|
|
212
|
-
* @returns A promise that resolves when all executions for the specified command have completed
|
|
213
|
-
*/
|
|
214
|
-
async execute(method, inlineConfig) {
|
|
215
|
-
await Promise.all((await this.context.loadExecutions(method, inlineConfig)).map(async (execution) => {
|
|
216
|
-
try {
|
|
217
|
-
await this.host[method]({
|
|
218
|
-
options: execution.options,
|
|
219
|
-
inlineConfig
|
|
220
|
-
});
|
|
221
|
-
} catch (error) {
|
|
222
|
-
this.context.error(`Execution of method "${method}" 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)}`);
|
|
223
|
-
throw error;
|
|
224
|
-
} finally {
|
|
225
|
-
this.context.completeExecution(execution.invocationId, execution.options.executionId);
|
|
226
|
-
}
|
|
227
|
-
}));
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
async function createContext(options) {
|
|
231
|
-
const port = options.port ?? await getPort({
|
|
232
|
-
host: options.host || "localhost",
|
|
233
|
-
random: true
|
|
234
|
-
});
|
|
235
|
-
const app = createApp();
|
|
236
|
-
const host = createH3DevToolsHost({
|
|
237
|
-
appName: options.framework?.name || "powerlines",
|
|
238
|
-
origin: `http://${options.host || "localhost"}:${port}`,
|
|
239
|
-
mount: (base, dir) => {
|
|
240
|
-
app.use(base, fromNodeMiddleware(sirv(dir, {
|
|
241
|
-
dev: true,
|
|
242
|
-
single: true
|
|
243
|
-
})));
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
return PowerlinesEngineContext.from(options, host, {
|
|
247
|
-
backend: "websocket",
|
|
248
|
-
websocket: port
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
async function createEngine(options, executionHostPath = "@powerlines/engine/execution-host", executionMethods) {
|
|
252
|
-
EventEmitter.setMaxListeners(100);
|
|
253
|
-
const context = await createContext(options);
|
|
254
|
-
return new PowerlinesEngine(context, await ExecutionHostWorker.from(executionHostPath, {
|
|
255
|
-
root: options.root,
|
|
256
|
-
context,
|
|
257
|
-
executionMethods
|
|
258
|
-
}));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
//#endregion
|
|
262
|
-
export { PowerlinesEngine, createContext, createEngine };
|
|
263
|
-
//# sourceMappingURL=engine.mjs.map
|
|
3
|
+
export { PowerlinesEngine, createContext, createEngine };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_chunk = require('../chunk-C0xms8kb.cjs');
|
|
3
3
|
const require_helpers_rpc = require('./rpc.cjs');
|
|
4
|
+
const require_helpers_stream = require('./stream.cjs');
|
|
4
5
|
let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
|
|
5
|
-
let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
|
|
6
|
-
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
7
6
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
8
7
|
let _powerlines_core_context_execution_context = require("@powerlines/core/context/execution-context");
|
|
9
8
|
let _powerlines_core_lib_context_helpers = require("@powerlines/core/lib/context-helpers");
|
|
10
9
|
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
10
|
+
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
11
|
+
let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
|
|
11
12
|
let defu = require("defu");
|
|
12
13
|
|
|
13
14
|
//#region src/helpers/create-execution-host.ts
|
|
@@ -20,7 +21,13 @@ let defu = require("defu");
|
|
|
20
21
|
*/
|
|
21
22
|
function createExecutionHost(methods, inlineConfig = {}) {
|
|
22
23
|
return Object.fromEntries(Object.entries(methods).map(([method, fn]) => [method, async (params) => {
|
|
23
|
-
const { options } = params;
|
|
24
|
+
const { options, port } = params;
|
|
25
|
+
const duplex = new require_helpers_stream.MessagePortDuplex(port);
|
|
26
|
+
duplex.setEncoding("utf8");
|
|
27
|
+
duplex.on("data", (chunk) => duplex.write(chunk.toUpperCase()));
|
|
28
|
+
duplex.on("end", () => {
|
|
29
|
+
duplex.end();
|
|
30
|
+
});
|
|
24
31
|
let rpc;
|
|
25
32
|
if (options.baseURL && options.connection) rpc = require_helpers_rpc.createRpcClient(options);
|
|
26
33
|
else throw new Error(`Execution RPC client could not be created - Missing ${!options.baseURL ? `baseURL${options.connection ? ` and connection information` : ""}` : "connection"} or connection information.`);
|
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { r as EngineResolvedConfig } from "../config-D6xUniHh.cjs";
|
|
2
|
+
import { r as EngineSystemContext } from "../context-epL7NPvL.cjs";
|
|
3
|
+
import { r as ExecutionHostParams } from "../api-DgxYwNuZ.cjs";
|
|
4
|
+
import { ExecutionContext, InlineConfig } from "@powerlines/core";
|
|
5
|
+
import { DeepPartial, MaybePromise } from "@stryke/types/base";
|
|
6
|
+
|
|
7
|
+
//#region src/helpers/create-execution-host.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
|
|
10
|
+
*
|
|
11
|
+
* @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
|
|
12
|
+
* @param inlineConfig - An optional partial inline configuration object that will be merged with the context's options when creating the execution context for each method.
|
|
13
|
+
* @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
|
|
14
|
+
*/
|
|
15
|
+
declare function createExecutionHost<TContext extends ExecutionContext<EngineResolvedConfig, EngineSystemContext> = ExecutionContext<EngineResolvedConfig, EngineSystemContext>>(methods: Record<string, (context: TContext) => Promise<void>>, inlineConfig?: DeepPartial<InlineConfig> | ((prev: InlineConfig) => MaybePromise<InlineConfig>)): {
|
|
16
|
+
[k: string]: (params: ExecutionHostParams) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { createExecutionHost };
|
|
20
|
+
//# sourceMappingURL=create-execution-host.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-execution-host.d.cts","names":[],"sources":["../../src/helpers/create-execution-host.ts"],"mappings":";;;;;;;;;AA8CA;;;;;iBAAgB,mBAAA,kBACG,gBAAA,CAAiB,oBAAA,EAAsB,mBAAA,IACtD,gBAAA,CAAiB,oBAAA,EAAsB,mBAAA,EAAA,CAEzC,OAAA,EAAS,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA,SAC/C,YAAA,GACI,WAAA,CAAY,YAAA,MACV,IAAA,EAAM,YAAA,KAAiB,YAAA,CAAa,YAAA;EAAA,sBAKvB,mBAAA,KAAmB,OAAA;AAAA"}
|