@powerlines/engine 0.15.18 → 0.15.20

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 (110) hide show
  1. package/dist/api/build.cjs +1 -1
  2. package/dist/api/build.d.mts +2 -2
  3. package/dist/api/build.mjs +1 -1
  4. package/dist/api/clean.d.mts +2 -2
  5. package/dist/api/create.d.mts +2 -2
  6. package/dist/api/deploy.d.mts +2 -2
  7. package/dist/api/docs.d.mts +2 -2
  8. package/dist/api/lint.d.mts +2 -2
  9. package/dist/api/prepare.cjs +2 -2
  10. package/dist/api/prepare.d.mts +2 -2
  11. package/dist/api/prepare.mjs +2 -2
  12. package/dist/api/test.d.mts +2 -2
  13. package/dist/api/types.cjs +2 -2
  14. package/dist/api/types.d.mts +2 -2
  15. package/dist/api/types.mjs +2 -2
  16. package/dist/{api-Cdw4v0W4.d.mts → api-B2dWvRMM.d.mts} +10 -7
  17. package/dist/api-B2dWvRMM.d.mts.map +1 -0
  18. package/dist/{api-6w4hZL6n.d.cts → api-DgxYwNuZ.d.cts} +8 -5
  19. package/dist/api-DgxYwNuZ.d.cts.map +1 -0
  20. package/dist/{execution-host.cjs → api.cjs} +1 -1
  21. package/dist/{execution-host.d.mts → api.d.cts} +3 -3
  22. package/dist/api.d.cts.map +1 -0
  23. package/dist/{execution-host.d.cts → api.d.mts} +3 -3
  24. package/dist/api.d.mts.map +1 -0
  25. package/dist/{execution-host.mjs → api.mjs} +2 -2
  26. package/dist/api.mjs.map +1 -0
  27. package/dist/{config-BNe23XHx.d.mts → config-C9AD-erz.d.mts} +1 -1
  28. package/dist/{config-BNe23XHx.d.mts.map → config-C9AD-erz.d.mts.map} +1 -1
  29. package/dist/context/engine-context.cjs +4 -4
  30. package/dist/context/engine-context.d.cts +1 -1
  31. package/dist/context/engine-context.d.mts +1 -1
  32. package/dist/context/engine-context.mjs +4 -4
  33. package/dist/context/index.d.cts +1 -1
  34. package/dist/context/index.d.mts +1 -1
  35. package/dist/{context-DzgsMSWr.d.mts → context-S3XH2DWP.d.mts} +2 -2
  36. package/dist/{context-DzgsMSWr.d.mts.map → context-S3XH2DWP.d.mts.map} +1 -1
  37. package/dist/engine-DELjWFmN.mjs +564 -0
  38. package/dist/engine-DELjWFmN.mjs.map +1 -0
  39. package/dist/engine-DTKq6gFT.cjs +583 -0
  40. package/dist/{engine-context-Dw8odBCo.d.cts → engine-context-5-_EGiKp.d.cts} +1 -1
  41. package/dist/{engine-context-DEotmVzB.d.mts.map → engine-context-5-_EGiKp.d.cts.map} +1 -1
  42. package/dist/{engine-context-DEotmVzB.d.mts → engine-context-zsn1PoRl.d.mts} +5 -5
  43. package/dist/{engine-context-Dw8odBCo.d.cts.map → engine-context-zsn1PoRl.d.mts.map} +1 -1
  44. package/dist/engine.cjs +4 -266
  45. package/dist/engine.d.cts +3 -3
  46. package/dist/engine.d.cts.map +1 -1
  47. package/dist/engine.d.mts +6 -6
  48. package/dist/engine.d.mts.map +1 -1
  49. package/dist/engine.mjs +2 -263
  50. package/dist/helpers/create-execution-host.cjs +9 -2
  51. package/dist/helpers/create-execution-host.d.cts +20 -2
  52. package/dist/helpers/create-execution-host.d.cts.map +1 -0
  53. package/dist/helpers/create-execution-host.d.mts +20 -2
  54. package/dist/helpers/create-execution-host.d.mts.map +1 -0
  55. package/dist/helpers/create-execution-host.mjs +9 -2
  56. package/dist/helpers/create-execution-host.mjs.map +1 -1
  57. package/dist/helpers/finalize.d.cts +12 -2
  58. package/dist/helpers/finalize.d.cts.map +1 -0
  59. package/dist/helpers/finalize.d.mts +12 -2
  60. package/dist/helpers/finalize.d.mts.map +1 -0
  61. package/dist/helpers/index.cjs +4 -2
  62. package/dist/helpers/index.d.cts +5 -5
  63. package/dist/helpers/index.d.mts +5 -5
  64. package/dist/helpers/index.mjs +2 -2
  65. package/dist/helpers/rpc.cjs +2 -2
  66. package/dist/helpers/rpc.d.cts +7 -2
  67. package/dist/helpers/rpc.d.cts.map +1 -0
  68. package/dist/helpers/rpc.d.mts +7 -2
  69. package/dist/helpers/rpc.d.mts.map +1 -0
  70. package/dist/helpers/rpc.mjs +2 -2
  71. package/dist/helpers/stream.cjs +120 -0
  72. package/dist/helpers/stream.d.cts +45 -0
  73. package/dist/helpers/stream.d.cts.map +1 -0
  74. package/dist/helpers/stream.d.mts +45 -0
  75. package/dist/helpers/stream.d.mts.map +1 -0
  76. package/dist/helpers/stream.mjs +117 -0
  77. package/dist/helpers/stream.mjs.map +1 -0
  78. package/dist/index.cjs +2 -11
  79. package/dist/index.d.cts +3 -7
  80. package/dist/index.d.mts +5 -9
  81. package/dist/index.mjs +2 -7
  82. package/package.json +10 -12
  83. package/dist/api-6w4hZL6n.d.cts.map +0 -1
  84. package/dist/api-Cdw4v0W4.d.mts.map +0 -1
  85. package/dist/create-execution-host-CdpuL_YG.d.mts +0 -20
  86. package/dist/create-execution-host-CdpuL_YG.d.mts.map +0 -1
  87. package/dist/create-execution-host-DbOCE5bd.d.cts +0 -20
  88. package/dist/create-execution-host-DbOCE5bd.d.cts.map +0 -1
  89. package/dist/engine.mjs.map +0 -1
  90. package/dist/execution-host-worker-B8TS4clU.d.mts +0 -68
  91. package/dist/execution-host-worker-B8TS4clU.d.mts.map +0 -1
  92. package/dist/execution-host-worker-BjXO7l3Q.d.cts +0 -68
  93. package/dist/execution-host-worker-BjXO7l3Q.d.cts.map +0 -1
  94. package/dist/execution-host.d.cts.map +0 -1
  95. package/dist/execution-host.d.mts.map +0 -1
  96. package/dist/execution-host.mjs.map +0 -1
  97. package/dist/finalize-CW0cO75l.d.cts +0 -12
  98. package/dist/finalize-CW0cO75l.d.cts.map +0 -1
  99. package/dist/finalize-DeSY1r74.d.mts +0 -12
  100. package/dist/finalize-DeSY1r74.d.mts.map +0 -1
  101. package/dist/helpers/execution-host-worker.cjs +0 -315
  102. package/dist/helpers/execution-host-worker.d.cts +0 -2
  103. package/dist/helpers/execution-host-worker.d.mts +0 -2
  104. package/dist/helpers/execution-host-worker.mjs +0 -314
  105. package/dist/helpers/execution-host-worker.mjs.map +0 -1
  106. package/dist/rpc-BsFxzyAK.d.cts +0 -7
  107. package/dist/rpc-BsFxzyAK.d.cts.map +0 -1
  108. package/dist/rpc-xwbFMMNu.d.mts +0 -7
  109. package/dist/rpc-xwbFMMNu.d.mts.map +0 -1
  110. /package/dist/{index-D_TYgLX3.d.cts → index-DDRpa5CJ.d.cts} +0 -0
package/dist/engine.cjs CHANGED
@@ -1,268 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_chunk = require('./chunk-C0xms8kb.cjs');
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 _powerlines_core_constants = require("@powerlines/core/constants");
6
- let devframe_node = require("devframe/node");
7
- let get_port_please = require("get-port-please");
8
- let h3 = require("h3");
9
- let node_events = require("node:events");
10
- let sirv = require("sirv");
11
- sirv = require_chunk.__toESM(sirv, 1);
2
+ const require_engine = require('./engine-DTKq6gFT.cjs');
12
3
 
13
- //#region src/engine.ts
14
- /**
15
- * The Powerlines process' orchestration and coordination API.
16
- *
17
- * @public
18
- */
19
- var PowerlinesEngine = class {
20
- /**
21
- * The Powerlines context
22
- */
23
- #context;
24
- /**
25
- * 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.
26
- */
27
- #host;
28
- /**
29
- * The Powerlines context
30
- */
31
- get context() {
32
- return this.#context;
33
- }
34
- /**
35
- * 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.
36
- */
37
- get host() {
38
- return this.#host;
39
- }
40
- /**
41
- * Create a new Powerlines Engine instance
42
- *
43
- * @param context - The Powerlines context
44
- * @param host - The API host for the execution workers
45
- * @returns A new instance of the Powerlines Engine
46
- */
47
- constructor(context, host) {
48
- this.#context = context;
49
- this.#host = host;
50
- }
51
- /**
52
- * Create a new Powerlines project
53
- *
54
- * @remarks
55
- * This method will create a new Powerlines project in the current directory.
56
- *
57
- * @param inlineConfig - The inline configuration for the create command
58
- * @returns A promise that resolves when the project has been created
59
- */
60
- async create(inlineConfig) {
61
- const timer = this.context.timer("Create");
62
- this.context.info("🆕 Creating a new project");
63
- await this.execute("create", inlineConfig);
64
- this.context.debug("✔ Create command completed successfully");
65
- timer();
66
- }
67
- /**
68
- * Generate the Powerlines typescript declaration file
69
- *
70
- * @remarks
71
- * 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.
72
- *
73
- * @param inlineConfig - The inline configuration for the types command
74
- */
75
- async types(inlineConfig) {
76
- const timer = this.context.timer("Types");
77
- this.context.info("🏗️ Generating typescript declarations for the project");
78
- await this.execute("types", inlineConfig);
79
- this.context.debug("✔ Types generation has completed successfully");
80
- timer();
81
- }
82
- /**
83
- * Prepare the Powerlines API
84
- *
85
- * @remarks
86
- * This method will prepare the Powerlines API for use, initializing any necessary resources.
87
- *
88
- * @param inlineConfig - The inline configuration for the prepare command
89
- */
90
- async prepare(inlineConfig) {
91
- const timer = this.context.timer("Prepare");
92
- this.context.info("🏗️ Preparing the project");
93
- await this.execute("prepare", inlineConfig);
94
- this.context.debug("✔ Preparation has completed successfully");
95
- timer();
96
- }
97
- /**
98
- * Clean any previously prepared artifacts
99
- *
100
- * @remarks
101
- * This method will remove the previous Powerlines artifacts from the project.
102
- *
103
- * @param inlineConfig - The inline configuration for the clean command
104
- * @returns A promise that resolves when the clean command has completed
105
- */
106
- async clean(inlineConfig) {
107
- const timer = this.context.timer("Clean");
108
- this.context.info("🧹 Cleaning the previous artifacts");
109
- await this.execute("clean", inlineConfig);
110
- this.context.debug("✔ Cleaning completed successfully");
111
- timer();
112
- }
113
- /**
114
- * Lint the project
115
- *
116
- * @param inlineConfig - The inline configuration for the lint command
117
- * @returns A promise that resolves when the lint command has completed
118
- */
119
- async lint(inlineConfig) {
120
- const timer = this.context.timer("Lint");
121
- this.context.info("📝 Linting the project");
122
- await this.execute("lint", inlineConfig);
123
- this.context.debug("✔ Linting completed successfully");
124
- timer();
125
- }
126
- /**
127
- * Test the project
128
- *
129
- * @remarks
130
- * This method will run the tests for the Powerlines project.
131
- *
132
- * @param inlineConfig - The inline configuration for the test command
133
- * @returns A promise that resolves when the test command has completed
134
- */
135
- async test(inlineConfig) {
136
- const timer = this.context.timer("Test");
137
- this.context.info("🧪 Running tests for the project");
138
- await this.execute("test", inlineConfig);
139
- this.context.debug("✔ Testing completed successfully");
140
- timer();
141
- }
142
- /**
143
- * Build the project
144
- *
145
- * @remarks
146
- * This method will build the Powerlines project, generating the necessary artifacts.
147
- *
148
- * @param inlineConfig - The inline configuration for the build command
149
- * @returns A promise that resolves when the build command has completed
150
- */
151
- async build(inlineConfig) {
152
- const timer = this.context.timer("Build");
153
- this.context.info("📦 Building the project");
154
- await this.execute("build", inlineConfig);
155
- this.context.debug("✔ Build completed successfully");
156
- timer();
157
- }
158
- /**
159
- * Prepare the documentation for the project
160
- *
161
- * @param inlineConfig - The inline configuration for the docs command
162
- * @returns A promise that resolves when the documentation generation has completed
163
- */
164
- async docs(inlineConfig) {
165
- const timer = this.context.timer("Docs");
166
- this.context.info("📓 Generating documentation for the project");
167
- await this.execute("docs", inlineConfig);
168
- this.context.debug("✔ Documentation generation completed successfully");
169
- timer();
170
- }
171
- /**
172
- * Deploy the project source code
173
- *
174
- * @remarks
175
- * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
176
- *
177
- * @param inlineConfig - The inline configuration for the deploy command
178
- * @returns A promise that resolves when the deploy command has completed
179
- */
180
- async deploy(inlineConfig) {
181
- const timer = this.context.timer("Deploy");
182
- this.context.info("🚀 Deploying the project");
183
- await this.execute("deploy", inlineConfig);
184
- this.context.debug("✔ Deployment completed successfully");
185
- timer();
186
- }
187
- /**
188
- * Finalization/cleanup processing for the Powerlines API
189
- *
190
- * @remarks
191
- * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
192
- *
193
- * @returns A promise that resolves when the finalization process has completed
194
- */
195
- async finalize() {
196
- const timer = this.context.timer("Finalize");
197
- this.context.info("🏁 Finalization processes started");
198
- await this.host.end();
199
- this.context.debug("✔ Finalization completed successfully");
200
- timer();
201
- }
202
- /**
203
- * Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.
204
- */
205
- async [Symbol.asyncDispose]() {
206
- return this.finalize();
207
- }
208
- /**
209
- * Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.
210
- *
211
- * @remarks
212
- * 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.
213
- *
214
- * @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.
215
- * @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.
216
- * @returns A promise that resolves when all executions for the specified command have completed
217
- */
218
- async execute(method, inlineConfig) {
219
- await Promise.all((await this.context.loadExecutions(method, inlineConfig)).map(async (execution) => {
220
- try {
221
- await this.host[method]({
222
- options: execution.options,
223
- inlineConfig
224
- });
225
- } catch (error) {
226
- 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)}`);
227
- throw error;
228
- } finally {
229
- this.context.completeExecution(execution.invocationId, execution.options.executionId);
230
- }
231
- }));
232
- }
233
- };
234
- async function createContext(options) {
235
- const port = options.port ?? await (0, get_port_please.getPort)({
236
- host: options.host || "localhost",
237
- random: true
238
- });
239
- const app = (0, h3.createApp)();
240
- const host = (0, devframe_node.createH3DevToolsHost)({
241
- appName: options.framework?.name || "powerlines",
242
- origin: `http://${options.host || "localhost"}:${port}`,
243
- mount: (base, dir) => {
244
- app.use(base, (0, h3.fromNodeMiddleware)((0, sirv.default)(dir, {
245
- dev: true,
246
- single: true
247
- })));
248
- }
249
- });
250
- return require_context_engine_context.PowerlinesEngineContext.from(options, host, {
251
- backend: "websocket",
252
- websocket: port
253
- });
254
- }
255
- async function createEngine(options, executionHostPath = "@powerlines/engine/execution-host", executionMethods = _powerlines_core_constants.EXECUTION_API_METHODS) {
256
- node_events.EventEmitter.setMaxListeners(100);
257
- const context = await createContext(options);
258
- return new PowerlinesEngine(context, await require_helpers_execution_host_worker.ExecutionHostWorker.from(executionHostPath, {
259
- root: options.root,
260
- context,
261
- executionMethods
262
- }));
263
- }
264
-
265
- //#endregion
266
- exports.PowerlinesEngine = PowerlinesEngine;
267
- exports.createContext = createContext;
268
- 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 PowerlinesEngineContext } from "./engine-context-Dw8odBCo.cjs";
4
- import { n as ExecutionHost, t as Engine } from "./api-6w4hZL6n.cjs";
3
+ import { n as ExecutionHost, t as Engine } from "./api-DgxYwNuZ.cjs";
4
+ import { t as PowerlinesEngineContext } from "./engine-context-5-_EGiKp.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, executionHostPath?: string, executionMethods?: TExecutionAPI): Promise<PowerlinesEngine<TExecutionAPI>>;
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
@@ -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,YA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;;;;;;;;;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;;;;AA+BJ;;;;EA5De,QAAA,CAAA,GAAQ,OAAA;EA4DmC;;;EAAA,CA/C1C,MAAA,CAAO,YAAA,KAAa,OAAA;EA+CA;;;;;AAuBpC;;;;;EAvBoC,UAjClB,OAAA,CACd,MAAA,EAAQ,aAAA,UACR,YAAA,EAAc,YAAA,GAAY,OAAA;AAAA;AAAA,iBA+BR,aAAA,CAAc,OAAA,EAAS,aAAA,GAAa,OAAA,CAAA,uBAAA;AAAA,iBAuBpC,YAAA,uBAAmC,aAAA,SAAA,CACvD,OAAA,EAAS,aAAA,EACT,OAAA,WACA,UAAA,GAAa,aAAA,GAAa,OAAA,CAAA,gBAAA,CAAA,aAAA"}
package/dist/engine.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { n as EngineOptions } from "./config-BNe23XHx.mjs";
2
- import { t as EngineContext } from "./context-DzgsMSWr.mjs";
3
- import { t as PowerlinesEngineContext } from "./engine-context-DEotmVzB.mjs";
4
- import { n as ExecutionHost, t as Engine } from "./api-Cdw4v0W4.mjs";
5
- import { EXECUTION_API_METHODS } from "@powerlines/core/constants";
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-zsn1PoRl.mjs";
6
5
  import { BuildInlineConfig, CleanInlineConfig, CreateInlineConfig, DeployInlineConfig, DocsInlineConfig, InlineConfig, LintInlineConfig, PrepareInlineConfig, TestInlineConfig, TypesInlineConfig } from "@powerlines/core";
6
+ import { EXECUTION_API_METHODS } from "@powerlines/core/constants";
7
7
 
8
8
  //#region src/engine.d.ts
9
9
  /**
@@ -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, executionHostPath?: string, executionMethods?: TExecutionAPI): Promise<PowerlinesEngine<TExecutionAPI>>;
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
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.mts","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,OAA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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;;;;AA+BJ;;;;EA5De,QAAA,CAAA,GAAQ,OAAA;EA4DmC;;;EAAA,CA/C1C,MAAA,CAAO,YAAA,KAAa,OAAA;EA+CA;;;;;AAuBpC;;;;;EAvBoC,UAjClB,OAAA,CACd,MAAA,EAAQ,aAAA,UACR,YAAA,EAAc,YAAA,GAAY,OAAA;AAAA;AAAA,iBA+BR,aAAA,CAAc,OAAA,EAAS,aAAA,GAAa,OAAA,CAAA,uBAAA;AAAA,iBAuBpC,YAAA,uBAAmC,aAAA,SAAA,CACvD,OAAA,EAAS,aAAA,EACT,OAAA,WACA,UAAA,GAAa,aAAA,GAAa,OAAA,CAAA,gBAAA,CAAA,aAAA"}
package/dist/engine.mjs CHANGED
@@ -1,264 +1,3 @@
1
- import { PowerlinesEngineContext } from "./context/engine-context.mjs";
2
- import { ExecutionHostWorker } from "./helpers/execution-host-worker.mjs";
3
- import { EXECUTION_API_METHODS } from "@powerlines/core/constants";
4
- import { createH3DevToolsHost } from "devframe/node";
5
- import { getPort } from "get-port-please";
6
- import { createApp, fromNodeMiddleware } from "h3";
7
- import { EventEmitter } from "node:events";
8
- import sirv from "sirv";
1
+ import { n as createContext, r as createEngine, t as PowerlinesEngine } from "./engine-DELjWFmN.mjs";
9
2
 
10
- //#region src/engine.ts
11
- /**
12
- * The Powerlines process' orchestration and coordination API.
13
- *
14
- * @public
15
- */
16
- var PowerlinesEngine = class {
17
- /**
18
- * The Powerlines context
19
- */
20
- #context;
21
- /**
22
- * 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.
23
- */
24
- #host;
25
- /**
26
- * The Powerlines context
27
- */
28
- get context() {
29
- return this.#context;
30
- }
31
- /**
32
- * 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.
33
- */
34
- get host() {
35
- return this.#host;
36
- }
37
- /**
38
- * Create a new Powerlines Engine instance
39
- *
40
- * @param context - The Powerlines context
41
- * @param host - The API host for the execution workers
42
- * @returns A new instance of the Powerlines Engine
43
- */
44
- constructor(context, host) {
45
- this.#context = context;
46
- this.#host = host;
47
- }
48
- /**
49
- * Create a new Powerlines project
50
- *
51
- * @remarks
52
- * This method will create a new Powerlines project in the current directory.
53
- *
54
- * @param inlineConfig - The inline configuration for the create command
55
- * @returns A promise that resolves when the project has been created
56
- */
57
- async create(inlineConfig) {
58
- const timer = this.context.timer("Create");
59
- this.context.info("🆕 Creating a new project");
60
- await this.execute("create", inlineConfig);
61
- this.context.debug("✔ Create command completed successfully");
62
- timer();
63
- }
64
- /**
65
- * Generate the Powerlines typescript declaration file
66
- *
67
- * @remarks
68
- * 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.
69
- *
70
- * @param inlineConfig - The inline configuration for the types command
71
- */
72
- async types(inlineConfig) {
73
- const timer = this.context.timer("Types");
74
- this.context.info("🏗️ Generating typescript declarations for the project");
75
- await this.execute("types", inlineConfig);
76
- this.context.debug("✔ Types generation has completed successfully");
77
- timer();
78
- }
79
- /**
80
- * Prepare the Powerlines API
81
- *
82
- * @remarks
83
- * This method will prepare the Powerlines API for use, initializing any necessary resources.
84
- *
85
- * @param inlineConfig - The inline configuration for the prepare command
86
- */
87
- async prepare(inlineConfig) {
88
- const timer = this.context.timer("Prepare");
89
- this.context.info("🏗️ Preparing the project");
90
- await this.execute("prepare", inlineConfig);
91
- this.context.debug("✔ Preparation has completed successfully");
92
- timer();
93
- }
94
- /**
95
- * Clean any previously prepared artifacts
96
- *
97
- * @remarks
98
- * This method will remove the previous Powerlines artifacts from the project.
99
- *
100
- * @param inlineConfig - The inline configuration for the clean command
101
- * @returns A promise that resolves when the clean command has completed
102
- */
103
- async clean(inlineConfig) {
104
- const timer = this.context.timer("Clean");
105
- this.context.info("🧹 Cleaning the previous artifacts");
106
- await this.execute("clean", inlineConfig);
107
- this.context.debug("✔ Cleaning completed successfully");
108
- timer();
109
- }
110
- /**
111
- * Lint the project
112
- *
113
- * @param inlineConfig - The inline configuration for the lint command
114
- * @returns A promise that resolves when the lint command has completed
115
- */
116
- async lint(inlineConfig) {
117
- const timer = this.context.timer("Lint");
118
- this.context.info("📝 Linting the project");
119
- await this.execute("lint", inlineConfig);
120
- this.context.debug("✔ Linting completed successfully");
121
- timer();
122
- }
123
- /**
124
- * Test the project
125
- *
126
- * @remarks
127
- * This method will run the tests for the Powerlines project.
128
- *
129
- * @param inlineConfig - The inline configuration for the test command
130
- * @returns A promise that resolves when the test command has completed
131
- */
132
- async test(inlineConfig) {
133
- const timer = this.context.timer("Test");
134
- this.context.info("🧪 Running tests for the project");
135
- await this.execute("test", inlineConfig);
136
- this.context.debug("✔ Testing completed successfully");
137
- timer();
138
- }
139
- /**
140
- * Build the project
141
- *
142
- * @remarks
143
- * This method will build the Powerlines project, generating the necessary artifacts.
144
- *
145
- * @param inlineConfig - The inline configuration for the build command
146
- * @returns A promise that resolves when the build command has completed
147
- */
148
- async build(inlineConfig) {
149
- const timer = this.context.timer("Build");
150
- this.context.info("📦 Building the project");
151
- await this.execute("build", inlineConfig);
152
- this.context.debug("✔ Build completed successfully");
153
- timer();
154
- }
155
- /**
156
- * Prepare the documentation for the project
157
- *
158
- * @param inlineConfig - The inline configuration for the docs command
159
- * @returns A promise that resolves when the documentation generation has completed
160
- */
161
- async docs(inlineConfig) {
162
- const timer = this.context.timer("Docs");
163
- this.context.info("📓 Generating documentation for the project");
164
- await this.execute("docs", inlineConfig);
165
- this.context.debug("✔ Documentation generation completed successfully");
166
- timer();
167
- }
168
- /**
169
- * Deploy the project source code
170
- *
171
- * @remarks
172
- * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
173
- *
174
- * @param inlineConfig - The inline configuration for the deploy command
175
- * @returns A promise that resolves when the deploy command has completed
176
- */
177
- async deploy(inlineConfig) {
178
- const timer = this.context.timer("Deploy");
179
- this.context.info("🚀 Deploying the project");
180
- await this.execute("deploy", inlineConfig);
181
- this.context.debug("✔ Deployment completed successfully");
182
- timer();
183
- }
184
- /**
185
- * Finalization/cleanup processing for the Powerlines API
186
- *
187
- * @remarks
188
- * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
189
- *
190
- * @returns A promise that resolves when the finalization process has completed
191
- */
192
- async finalize() {
193
- const timer = this.context.timer("Finalize");
194
- this.context.info("🏁 Finalization processes started");
195
- await this.host.end();
196
- this.context.debug("✔ Finalization completed successfully");
197
- timer();
198
- }
199
- /**
200
- * Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.
201
- */
202
- async [Symbol.asyncDispose]() {
203
- return this.finalize();
204
- }
205
- /**
206
- * Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.
207
- *
208
- * @remarks
209
- * 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.
210
- *
211
- * @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.
212
- * @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.
213
- * @returns A promise that resolves when all executions for the specified command have completed
214
- */
215
- async execute(method, inlineConfig) {
216
- await Promise.all((await this.context.loadExecutions(method, inlineConfig)).map(async (execution) => {
217
- try {
218
- await this.host[method]({
219
- options: execution.options,
220
- inlineConfig
221
- });
222
- } catch (error) {
223
- 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)}`);
224
- throw error;
225
- } finally {
226
- this.context.completeExecution(execution.invocationId, execution.options.executionId);
227
- }
228
- }));
229
- }
230
- };
231
- async function createContext(options) {
232
- const port = options.port ?? await getPort({
233
- host: options.host || "localhost",
234
- random: true
235
- });
236
- const app = createApp();
237
- const host = createH3DevToolsHost({
238
- appName: options.framework?.name || "powerlines",
239
- origin: `http://${options.host || "localhost"}:${port}`,
240
- mount: (base, dir) => {
241
- app.use(base, fromNodeMiddleware(sirv(dir, {
242
- dev: true,
243
- single: true
244
- })));
245
- }
246
- });
247
- return PowerlinesEngineContext.from(options, host, {
248
- backend: "websocket",
249
- websocket: port
250
- });
251
- }
252
- async function createEngine(options, executionHostPath = "@powerlines/engine/execution-host", executionMethods = EXECUTION_API_METHODS) {
253
- EventEmitter.setMaxListeners(100);
254
- const context = await createContext(options);
255
- return new PowerlinesEngine(context, await ExecutionHostWorker.from(executionHostPath, {
256
- root: options.root,
257
- context,
258
- executionMethods
259
- }));
260
- }
261
-
262
- //#endregion
263
- export { PowerlinesEngine, createContext, createEngine };
264
- //# 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
6
  let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
7
7
  let _powerlines_core_context_execution_context = require("@powerlines/core/context/execution-context");
8
8
  let _powerlines_core_lib_context_helpers = require("@powerlines/core/lib/context-helpers");
9
9
  let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
10
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 { t as createExecutionHost } from "../create-execution-host-DbOCE5bd.cjs";
2
- export { createExecutionHost };
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"}