@powerlines/engine 0.14.5 → 0.15.1

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 (195) hide show
  1. package/dist/api/build.cjs +66 -0
  2. package/dist/api/build.d.cts +14 -0
  3. package/dist/api/build.d.cts.map +1 -0
  4. package/dist/api/build.d.mts +14 -0
  5. package/dist/api/build.d.mts.map +1 -0
  6. package/dist/api/build.mjs +64 -0
  7. package/dist/api/build.mjs.map +1 -0
  8. package/dist/api/clean.cjs +29 -0
  9. package/dist/api/clean.d.cts +14 -0
  10. package/dist/api/clean.d.cts.map +1 -0
  11. package/dist/api/clean.d.mts +14 -0
  12. package/dist/api/clean.d.mts.map +1 -0
  13. package/dist/api/clean.mjs +28 -0
  14. package/dist/api/clean.mjs.map +1 -0
  15. package/dist/api/create.cjs +59 -0
  16. package/dist/api/create.d.cts +14 -0
  17. package/dist/api/create.d.cts.map +1 -0
  18. package/dist/api/create.d.mts +14 -0
  19. package/dist/api/create.d.mts.map +1 -0
  20. package/dist/api/create.mjs +57 -0
  21. package/dist/api/create.mjs.map +1 -0
  22. package/dist/api/deploy.cjs +25 -0
  23. package/dist/api/deploy.d.cts +17 -0
  24. package/dist/api/deploy.d.cts.map +1 -0
  25. package/dist/api/deploy.d.mts +17 -0
  26. package/dist/api/deploy.d.mts.map +1 -0
  27. package/dist/api/deploy.mjs +24 -0
  28. package/dist/api/deploy.mjs.map +1 -0
  29. package/dist/api/docs.cjs +25 -0
  30. package/dist/api/docs.d.cts +17 -0
  31. package/dist/api/docs.d.cts.map +1 -0
  32. package/dist/api/docs.d.mts +17 -0
  33. package/dist/api/docs.d.mts.map +1 -0
  34. package/dist/api/docs.mjs +24 -0
  35. package/dist/api/docs.mjs.map +1 -0
  36. package/dist/api/lint.cjs +28 -0
  37. package/dist/api/lint.d.cts +17 -0
  38. package/dist/api/lint.d.cts.map +1 -0
  39. package/dist/api/lint.d.mts +17 -0
  40. package/dist/api/lint.d.mts.map +1 -0
  41. package/dist/api/lint.mjs +27 -0
  42. package/dist/api/lint.mjs.map +1 -0
  43. package/dist/api/prepare.cjs +69 -0
  44. package/dist/api/prepare.d.cts +14 -0
  45. package/dist/api/prepare.d.cts.map +1 -0
  46. package/dist/api/prepare.d.mts +14 -0
  47. package/dist/api/prepare.d.mts.map +1 -0
  48. package/dist/api/prepare.mjs +68 -0
  49. package/dist/api/prepare.mjs.map +1 -0
  50. package/dist/api/test.cjs +28 -0
  51. package/dist/api/test.d.cts +17 -0
  52. package/dist/api/test.d.cts.map +1 -0
  53. package/dist/api/test.d.mts +17 -0
  54. package/dist/api/test.d.mts.map +1 -0
  55. package/dist/api/test.mjs +27 -0
  56. package/dist/api/test.mjs.map +1 -0
  57. package/dist/api/types.cjs +71 -0
  58. package/dist/api/types.d.cts +17 -0
  59. package/dist/api/types.d.cts.map +1 -0
  60. package/dist/api/types.d.mts +17 -0
  61. package/dist/api/types.d.mts.map +1 -0
  62. package/dist/api/types.mjs +70 -0
  63. package/dist/api/types.mjs.map +1 -0
  64. package/dist/api-6w4hZL6n.d.cts +135 -0
  65. package/dist/api-6w4hZL6n.d.cts.map +1 -0
  66. package/dist/api-Cdw4v0W4.d.mts +135 -0
  67. package/dist/api-Cdw4v0W4.d.mts.map +1 -0
  68. package/dist/config-BNe23XHx.d.mts +204 -0
  69. package/dist/config-BNe23XHx.d.mts.map +1 -0
  70. package/dist/config-D6xUniHh.d.cts +204 -0
  71. package/dist/config-D6xUniHh.d.cts.map +1 -0
  72. package/dist/context/engine-context.cjs +175 -0
  73. package/dist/context/engine-context.d.cts +2 -0
  74. package/dist/context/engine-context.d.mts +2 -0
  75. package/dist/context/engine-context.mjs +173 -0
  76. package/dist/context/engine-context.mjs.map +1 -0
  77. package/dist/context/index.cjs +2 -9
  78. package/dist/context/index.d.cts +2 -660
  79. package/dist/context/index.d.mts +2 -660
  80. package/dist/context/index.mjs +2 -4
  81. package/dist/context-DzgsMSWr.d.mts +149 -0
  82. package/dist/context-DzgsMSWr.d.mts.map +1 -0
  83. package/dist/context-epL7NPvL.d.cts +149 -0
  84. package/dist/context-epL7NPvL.d.cts.map +1 -0
  85. package/dist/engine-context-DEotmVzB.d.mts +54 -0
  86. package/dist/engine-context-DEotmVzB.d.mts.map +1 -0
  87. package/dist/engine-context-Dw8odBCo.d.cts +54 -0
  88. package/dist/engine-context-Dw8odBCo.d.cts.map +1 -0
  89. package/dist/engine.cjs +268 -0
  90. package/dist/engine.d.cts +143 -0
  91. package/dist/engine.d.cts.map +1 -0
  92. package/dist/engine.d.mts +143 -0
  93. package/dist/engine.d.mts.map +1 -0
  94. package/dist/engine.mjs +264 -0
  95. package/dist/engine.mjs.map +1 -0
  96. package/dist/execution-host.cjs +44 -0
  97. package/dist/execution-host.d.cts +14 -0
  98. package/dist/execution-host.d.cts.map +1 -0
  99. package/dist/execution-host.d.mts +14 -0
  100. package/dist/execution-host.d.mts.map +1 -0
  101. package/dist/execution-host.mjs +36 -0
  102. package/dist/execution-host.mjs.map +1 -0
  103. package/dist/helpers/create-execution-host.cjs +51 -0
  104. package/dist/helpers/create-execution-host.d.cts +21 -0
  105. package/dist/helpers/create-execution-host.d.cts.map +1 -0
  106. package/dist/helpers/create-execution-host.d.mts +21 -0
  107. package/dist/helpers/create-execution-host.d.mts.map +1 -0
  108. package/dist/helpers/create-execution-host.mjs +50 -0
  109. package/dist/helpers/create-execution-host.mjs.map +1 -0
  110. package/dist/helpers/execution-host-worker.cjs +308 -0
  111. package/dist/helpers/execution-host-worker.d.cts +68 -0
  112. package/dist/helpers/execution-host-worker.d.cts.map +1 -0
  113. package/dist/helpers/execution-host-worker.d.mts +68 -0
  114. package/dist/helpers/execution-host-worker.d.mts.map +1 -0
  115. package/dist/helpers/execution-host-worker.mjs +307 -0
  116. package/dist/helpers/execution-host-worker.mjs.map +1 -0
  117. package/dist/helpers/finalize.cjs +27 -0
  118. package/dist/helpers/finalize.d.cts +12 -0
  119. package/dist/helpers/finalize.d.cts.map +1 -0
  120. package/dist/helpers/finalize.d.mts +12 -0
  121. package/dist/helpers/finalize.d.mts.map +1 -0
  122. package/dist/helpers/finalize.mjs +26 -0
  123. package/dist/helpers/finalize.mjs.map +1 -0
  124. package/dist/helpers/rpc.cjs +140 -0
  125. package/dist/helpers/rpc.d.cts +7 -0
  126. package/dist/helpers/rpc.d.cts.map +1 -0
  127. package/dist/helpers/rpc.d.mts +7 -0
  128. package/dist/helpers/rpc.d.mts.map +1 -0
  129. package/dist/helpers/rpc.mjs +139 -0
  130. package/dist/helpers/rpc.mjs.map +1 -0
  131. package/dist/index-CNgSR_kt.d.mts +1 -0
  132. package/dist/index-D_TYgLX3.d.cts +1 -0
  133. package/dist/index.cjs +13 -567
  134. package/dist/index.d.cts +9 -126
  135. package/dist/index.d.mts +9 -126
  136. package/dist/index.mjs +7 -567
  137. package/package.json +101 -129
  138. package/dist/_internal/worker.cjs +0 -4843
  139. package/dist/_internal/worker.d.cts +0 -38
  140. package/dist/_internal/worker.d.cts.map +0 -1
  141. package/dist/_internal/worker.d.mts +0 -38
  142. package/dist/_internal/worker.d.mts.map +0 -1
  143. package/dist/_internal/worker.mjs +0 -4804
  144. package/dist/_internal/worker.mjs.map +0 -1
  145. package/dist/api.cjs +0 -1274
  146. package/dist/api.d.cts +0 -265
  147. package/dist/api.d.cts.map +0 -1
  148. package/dist/api.d.mts +0 -265
  149. package/dist/api.d.mts.map +0 -1
  150. package/dist/api.mjs +0 -1270
  151. package/dist/api.mjs.map +0 -1
  152. package/dist/base-context-BUnL_9z8.mjs +0 -241
  153. package/dist/base-context-BUnL_9z8.mjs.map +0 -1
  154. package/dist/base-context-CFvO2N9I.cjs +0 -248
  155. package/dist/context/index.d.cts.map +0 -1
  156. package/dist/context/index.d.mts.map +0 -1
  157. package/dist/engine-context-BuD9AGfd.mjs +0 -41
  158. package/dist/engine-context-BuD9AGfd.mjs.map +0 -1
  159. package/dist/engine-context-NO6enYev.cjs +0 -45
  160. package/dist/execution-context-BgGV4xyW.cjs +0 -2614
  161. package/dist/execution-context-D_CXpe9I.mjs +0 -2570
  162. package/dist/execution-context-D_CXpe9I.mjs.map +0 -1
  163. package/dist/fs-D1nIP45P.mjs +0 -226
  164. package/dist/fs-D1nIP45P.mjs.map +0 -1
  165. package/dist/fs-XogSgMqT.cjs +0 -262
  166. package/dist/index.d.cts.map +0 -1
  167. package/dist/index.d.mts.map +0 -1
  168. package/dist/index.mjs.map +0 -1
  169. package/dist/schemas.cjs +0 -9
  170. package/dist/schemas.d.cts +0 -127
  171. package/dist/schemas.d.cts.map +0 -1
  172. package/dist/schemas.d.mts +0 -127
  173. package/dist/schemas.d.mts.map +0 -1
  174. package/dist/schemas.mjs +0 -3
  175. package/dist/storage/index.cjs +0 -9
  176. package/dist/storage/index.d.cts +0 -419
  177. package/dist/storage/index.d.cts.map +0 -1
  178. package/dist/storage/index.d.mts +0 -419
  179. package/dist/storage/index.d.mts.map +0 -1
  180. package/dist/storage/index.mjs +0 -3
  181. package/dist/ts-morph-BaLPVAdB.cjs +0 -114
  182. package/dist/ts-morph-D0CaA37w.mjs +0 -102
  183. package/dist/ts-morph-D0CaA37w.mjs.map +0 -1
  184. package/dist/tsconfig-Cstsoprg.mjs +0 -155
  185. package/dist/tsconfig-Cstsoprg.mjs.map +0 -1
  186. package/dist/tsconfig-DeyWQC2N.cjs +0 -198
  187. package/dist/typescript/index.cjs +0 -13
  188. package/dist/typescript/index.d.cts +0 -106
  189. package/dist/typescript/index.d.cts.map +0 -1
  190. package/dist/typescript/index.d.mts +0 -106
  191. package/dist/typescript/index.d.mts.map +0 -1
  192. package/dist/typescript/index.mjs +0 -4
  193. package/dist/virtual-BNdKVkRw.cjs +0 -548
  194. package/dist/virtual-gIlTc3Lj.mjs +0 -513
  195. package/dist/virtual-gIlTc3Lj.mjs.map +0 -1
@@ -0,0 +1,264 @@
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";
9
+
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.mjs","names":["#context","#host"],"sources":["../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 {\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 { EXECUTION_API_METHODS } from \"@powerlines/core/constants\";\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 { PowerlinesEngineContext } from \"./context/engine-context\";\nimport { ExecutionHostWorker } from \"./helpers/execution-host-worker\";\nimport { Engine, ExecutionHost } 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<\n TExecutionAPI extends ReadonlyArray<string> = typeof EXECUTION_API_METHODS\n>\n implements Engine<TExecutionAPI>, AsyncDisposable\n{\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 #host: ExecutionHost<TExecutionAPI>;\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 host(): ExecutionHost<TExecutionAPI> {\n return this.#host;\n }\n\n /**\n * Create a new Powerlines Engine instance\n *\n * @param context - The Powerlines context\n * @param host - The API host for the execution workers\n * @returns A new instance of the Powerlines Engine\n */\n public constructor(\n context: EngineContext,\n host: ExecutionHost<TExecutionAPI>\n ) {\n this.#context = context;\n this.#host = host;\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.host.end();\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 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.\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(\n method: TExecutionAPI[number],\n inlineConfig: InlineConfig\n ) {\n await Promise.all(\n (await this.context.loadExecutions(method, inlineConfig)).map(\n async execution => {\n try {\n await this.host[method]({\n options: execution.options,\n inlineConfig\n });\n } catch (error) {\n this.context.error(\n `Execution of method \"${method}\" 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<TExecutionAPI extends ReadonlyArray<string>>(\n options: EngineOptions,\n executionHostPath = \"@powerlines/engine/execution-host\",\n executionMethods: TExecutionAPI = EXECUTION_API_METHODS as unknown as TExecutionAPI\n) {\n EventEmitter.setMaxListeners(100);\n\n const context = await createContext(options);\n const host = await ExecutionHostWorker.from<TExecutionAPI>(\n executionHostPath,\n {\n root: options.root,\n context,\n executionMethods\n }\n );\n\n return new PowerlinesEngine<TExecutionAPI>(context, host);\n}\n"],"mappings":"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"}
@@ -0,0 +1,44 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_api_prepare = require('./api/prepare.cjs');
3
+ const require_api_build = require('./api/build.cjs');
4
+ const require_api_clean = require('./api/clean.cjs');
5
+ const require_api_create = require('./api/create.cjs');
6
+ const require_api_deploy = require('./api/deploy.cjs');
7
+ const require_api_docs = require('./api/docs.cjs');
8
+ const require_api_lint = require('./api/lint.cjs');
9
+ const require_api_test = require('./api/test.cjs');
10
+ const require_api_types = require('./api/types.cjs');
11
+ const require_helpers_create_execution_host = require('./helpers/create-execution-host.cjs');
12
+
13
+ //#region src/execution-host.ts
14
+ const executionHost = require_helpers_create_execution_host.createExecutionHost({
15
+ types: require_api_types.types,
16
+ prepare: require_api_prepare.prepare,
17
+ create: require_api_create.create,
18
+ clean: require_api_clean.clean,
19
+ lint: require_api_lint.lint,
20
+ test: require_api_test.test,
21
+ build: require_api_build.build,
22
+ docs: require_api_docs.docs,
23
+ deploy: require_api_deploy.deploy
24
+ });
25
+ const types = executionHost.types;
26
+ const prepare = executionHost.prepare;
27
+ const create = executionHost.create;
28
+ const clean = executionHost.clean;
29
+ const lint = executionHost.lint;
30
+ const test = executionHost.test;
31
+ const build = executionHost.build;
32
+ const docs = executionHost.docs;
33
+ const deploy = executionHost.deploy;
34
+
35
+ //#endregion
36
+ exports.build = build;
37
+ exports.clean = clean;
38
+ exports.create = create;
39
+ exports.deploy = deploy;
40
+ exports.docs = docs;
41
+ exports.lint = lint;
42
+ exports.prepare = prepare;
43
+ exports.test = test;
44
+ exports.types = types;
@@ -0,0 +1,14 @@
1
+ import { r as ExecutionHostParams } from "./api-6w4hZL6n.cjs";
2
+ //#region src/execution-host.d.ts
3
+ declare const types: ((params: ExecutionHostParams) => Promise<void>) | undefined;
4
+ declare const prepare: ((params: ExecutionHostParams) => Promise<void>) | undefined;
5
+ declare const create: ((params: ExecutionHostParams) => Promise<void>) | undefined;
6
+ declare const clean: ((params: ExecutionHostParams) => Promise<void>) | undefined;
7
+ declare const lint: ((params: ExecutionHostParams) => Promise<void>) | undefined;
8
+ declare const test: ((params: ExecutionHostParams) => Promise<void>) | undefined;
9
+ declare const build: ((params: ExecutionHostParams) => Promise<void>) | undefined;
10
+ declare const docs: ((params: ExecutionHostParams) => Promise<void>) | undefined;
11
+ declare const deploy: ((params: ExecutionHostParams) => Promise<void>) | undefined;
12
+ //#endregion
13
+ export { build, clean, create, deploy, docs, lint, prepare, test, types };
14
+ //# sourceMappingURL=execution-host.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-host.d.cts","names":[],"sources":["../src/execution-host.ts"],"mappings":";;cAyCa,KAAA,IAAK,MAAA,EAAsB,mBAAA,KAAtB,OAAA;AAAA,cACL,OAAA,IAAO,MAAA,EAAwB,mBAAA,KAAxB,OAAA;AAAA,cACP,MAAA,IAAM,MAAA,EAAuB,mBAAA,KAAvB,OAAA;AAAA,cACN,KAAA,IAAK,MAAA,EAAsB,mBAAA,KAAtB,OAAA;AAAA,cACL,IAAA,IAAI,MAAA,EAAqB,mBAAA,KAArB,OAAA;AAAA,cACJ,IAAA,IAAI,MAAA,EAAqB,mBAAA,KAArB,OAAA;AAAA,cACJ,KAAA,IAAK,MAAA,EAAsB,mBAAA,KAAtB,OAAA;AAAA,cACL,IAAA,IAAI,MAAA,EAAqB,mBAAA,KAArB,OAAA;AAAA,cACJ,MAAA,IAAM,MAAA,EAAuB,mBAAA,KAAvB,OAAA"}
@@ -0,0 +1,14 @@
1
+ import { r as ExecutionHostParams } from "./api-Cdw4v0W4.mjs";
2
+ //#region src/execution-host.d.ts
3
+ declare const types: ((params: ExecutionHostParams) => Promise<void>) | undefined;
4
+ declare const prepare: ((params: ExecutionHostParams) => Promise<void>) | undefined;
5
+ declare const create: ((params: ExecutionHostParams) => Promise<void>) | undefined;
6
+ declare const clean: ((params: ExecutionHostParams) => Promise<void>) | undefined;
7
+ declare const lint: ((params: ExecutionHostParams) => Promise<void>) | undefined;
8
+ declare const test: ((params: ExecutionHostParams) => Promise<void>) | undefined;
9
+ declare const build: ((params: ExecutionHostParams) => Promise<void>) | undefined;
10
+ declare const docs: ((params: ExecutionHostParams) => Promise<void>) | undefined;
11
+ declare const deploy: ((params: ExecutionHostParams) => Promise<void>) | undefined;
12
+ //#endregion
13
+ export { build, clean, create, deploy, docs, lint, prepare, test, types };
14
+ //# sourceMappingURL=execution-host.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-host.d.mts","names":[],"sources":["../src/execution-host.ts"],"mappings":";;cAyCa,KAAA,IAAK,MAAA,EAAsB,mBAAA,KAAtB,OAAA;AAAA,cACL,OAAA,IAAO,MAAA,EAAwB,mBAAA,KAAxB,OAAA;AAAA,cACP,MAAA,IAAM,MAAA,EAAuB,mBAAA,KAAvB,OAAA;AAAA,cACN,KAAA,IAAK,MAAA,EAAsB,mBAAA,KAAtB,OAAA;AAAA,cACL,IAAA,IAAI,MAAA,EAAqB,mBAAA,KAArB,OAAA;AAAA,cACJ,IAAA,IAAI,MAAA,EAAqB,mBAAA,KAArB,OAAA;AAAA,cACJ,KAAA,IAAK,MAAA,EAAsB,mBAAA,KAAtB,OAAA;AAAA,cACL,IAAA,IAAI,MAAA,EAAqB,mBAAA,KAArB,OAAA;AAAA,cACJ,MAAA,IAAM,MAAA,EAAuB,mBAAA,KAAvB,OAAA"}
@@ -0,0 +1,36 @@
1
+ import { prepare as prepare$1 } from "./api/prepare.mjs";
2
+ import { build as build$1 } from "./api/build.mjs";
3
+ import { clean as clean$1 } from "./api/clean.mjs";
4
+ import { create as create$1 } from "./api/create.mjs";
5
+ import { deploy as deploy$1 } from "./api/deploy.mjs";
6
+ import { docs as docs$1 } from "./api/docs.mjs";
7
+ import { lint as lint$1 } from "./api/lint.mjs";
8
+ import { test as test$1 } from "./api/test.mjs";
9
+ import { types as types$1 } from "./api/types.mjs";
10
+ import { createExecutionHost } from "./helpers/create-execution-host.mjs";
11
+
12
+ //#region src/execution-host.ts
13
+ const executionHost = createExecutionHost({
14
+ types: types$1,
15
+ prepare: prepare$1,
16
+ create: create$1,
17
+ clean: clean$1,
18
+ lint: lint$1,
19
+ test: test$1,
20
+ build: build$1,
21
+ docs: docs$1,
22
+ deploy: deploy$1
23
+ });
24
+ const types = executionHost.types;
25
+ const prepare = executionHost.prepare;
26
+ const create = executionHost.create;
27
+ const clean = executionHost.clean;
28
+ const lint = executionHost.lint;
29
+ const test = executionHost.test;
30
+ const build = executionHost.build;
31
+ const docs = executionHost.docs;
32
+ const deploy = executionHost.deploy;
33
+
34
+ //#endregion
35
+ export { build, clean, create, deploy, docs, lint, prepare, test, types };
36
+ //# sourceMappingURL=execution-host.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-host.mjs","names":["executeTypes","executePrepare","executeCreate","executeClean","executeLint","executeTest","executeBuild","executeDocs","executeDeploy"],"sources":["../src/execution-host.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 { build as executeBuild } from \"./api/build\";\nimport { clean as executeClean } from \"./api/clean\";\nimport { create as executeCreate } from \"./api/create\";\nimport { deploy as executeDeploy } from \"./api/deploy\";\nimport { docs as executeDocs } from \"./api/docs\";\nimport { lint as executeLint } from \"./api/lint\";\nimport { prepare as executePrepare } from \"./api/prepare\";\nimport { test as executeTest } from \"./api/test\";\nimport { types as executeTypes } from \"./api/types\";\nimport { createExecutionHost } from \"./helpers/create-execution-host\";\n\nconst executionHost = createExecutionHost({\n types: executeTypes,\n prepare: executePrepare,\n create: executeCreate,\n clean: executeClean,\n lint: executeLint,\n test: executeTest,\n build: executeBuild,\n docs: executeDocs,\n deploy: executeDeploy\n});\n\nexport const types = executionHost.types;\nexport const prepare = executionHost.prepare;\nexport const create = executionHost.create;\nexport const clean = executionHost.clean;\nexport const lint = executionHost.lint;\nexport const test = executionHost.test;\nexport const build = executionHost.build;\nexport const docs = executionHost.docs;\nexport const deploy = executionHost.deploy;\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,gBAAgB,oBAAoB;CACxC,OAAOA;CACP,SAASC;CACT,QAAQC;CACR,OAAOC;CACP,MAAMC;CACN,MAAMC;CACN,OAAOC;CACP,MAAMC;CACN,QAAQC;CACT,CAAC;AAEF,MAAa,QAAQ,cAAc;AACnC,MAAa,UAAU,cAAc;AACrC,MAAa,SAAS,cAAc;AACpC,MAAa,QAAQ,cAAc;AACnC,MAAa,OAAO,cAAc;AAClC,MAAa,OAAO,cAAc;AAClC,MAAa,QAAQ,cAAc;AACnC,MAAa,OAAO,cAAc;AAClC,MAAa,SAAS,cAAc"}
@@ -0,0 +1,51 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_chunk = require('../chunk-C0xms8kb.cjs');
3
+ const require_helpers_rpc = require('./rpc.cjs');
4
+ 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_set_object = require("@stryke/type-checks/is-set-object");
7
+ let _powerlines_core_context_execution_context = require("@powerlines/core/context/execution-context");
8
+ let _powerlines_core_lib_context_helpers = require("@powerlines/core/lib/context-helpers");
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 defu = require("defu");
12
+
13
+ //#region src/helpers/create-execution-host.ts
14
+ /**
15
+ * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
16
+ *
17
+ * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
18
+ * @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.
19
+ * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
20
+ */
21
+ function createExecutionHost(methods, inlineConfig = {}) {
22
+ return Object.fromEntries(Object.entries(methods).map(([method, fn]) => [method, async (params) => {
23
+ const { options } = params;
24
+ let rpc;
25
+ if (options.baseURL && options.connection) rpc = require_helpers_rpc.createRpcClient(options);
26
+ else throw new Error(`Execution RPC client could not be created - Missing ${!options.baseURL ? `baseURL${options.connection ? ` and connection information` : ""}` : "connection"} or connection information.`);
27
+ const logFn = (meta, message) => {
28
+ (0, _powerlines_core_plugin_utils.consoleLogger)(meta, message);
29
+ if (rpc) rpc.callEvent("powerlines:log", {
30
+ meta: {
31
+ category: "general",
32
+ ...options,
33
+ ...(0, _stryke_type_checks_is_set_object.isSetObject)(meta) ? meta : { type: meta },
34
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
35
+ timestamp: Date.now()
36
+ },
37
+ message
38
+ });
39
+ };
40
+ const context = await _powerlines_core_context_execution_context.PowerlinesExecutionContext.from({
41
+ ...options,
42
+ logFn
43
+ }, (0, _stryke_type_checks_is_function.isFunction)(inlineConfig) ? await Promise.resolve(inlineConfig(params.inlineConfig ?? {})) : (0, defu.defu)(inlineConfig, params.inlineConfig ?? {}), { rpc });
44
+ context.logger.info(`Starting ${(0, _stryke_string_format_title_case.titleCase)(options.framework?.name) || "Powerlines"} - ${(0, _stryke_string_format_title_case.titleCase)(method)} execution (${options.executionId})`);
45
+ await (0, _powerlines_core_lib_context_helpers.resolvePluginConfig)(context);
46
+ await fn(context);
47
+ }]));
48
+ }
49
+
50
+ //#endregion
51
+ exports.createExecutionHost = createExecutionHost;
@@ -0,0 +1,21 @@
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-6w4hZL6n.cjs";
4
+ import { InlineConfig } from "@powerlines/core";
5
+ import { DeepPartial, MaybePromise } from "@stryke/types/base";
6
+ import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-context";
7
+
8
+ //#region src/helpers/create-execution-host.d.ts
9
+ /**
10
+ * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
11
+ *
12
+ * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
13
+ * @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.
14
+ * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
15
+ */
16
+ declare function createExecutionHost<TContext extends PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext> = PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext>>(methods: Record<string, (context: TContext) => Promise<void>>, inlineConfig?: DeepPartial<InlineConfig> | ((prev: InlineConfig) => MaybePromise<InlineConfig>)): {
17
+ [k: string]: (params: ExecutionHostParams) => Promise<void>;
18
+ };
19
+ //#endregion
20
+ export { createExecutionHost };
21
+ //# 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":";;;;;;;;;;AAyCA;;;;;iBAAgB,mBAAA,kBACG,0BAAA,CACf,oBAAA,EACA,mBAAA,IACE,0BAAA,CAA2B,oBAAA,EAAsB,mBAAA,EAAA,CAErD,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"}
@@ -0,0 +1,21 @@
1
+ import { r as EngineResolvedConfig } from "../config-BNe23XHx.mjs";
2
+ import { r as EngineSystemContext } from "../context-DzgsMSWr.mjs";
3
+ import { r as ExecutionHostParams } from "../api-Cdw4v0W4.mjs";
4
+ import { InlineConfig } from "@powerlines/core";
5
+ import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-context";
6
+ import { DeepPartial, MaybePromise } from "@stryke/types/base";
7
+
8
+ //#region src/helpers/create-execution-host.d.ts
9
+ /**
10
+ * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
11
+ *
12
+ * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
13
+ * @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.
14
+ * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
15
+ */
16
+ declare function createExecutionHost<TContext extends PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext> = PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext>>(methods: Record<string, (context: TContext) => Promise<void>>, inlineConfig?: DeepPartial<InlineConfig> | ((prev: InlineConfig) => MaybePromise<InlineConfig>)): {
17
+ [k: string]: (params: ExecutionHostParams) => Promise<void>;
18
+ };
19
+ //#endregion
20
+ export { createExecutionHost };
21
+ //# sourceMappingURL=create-execution-host.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-execution-host.d.mts","names":[],"sources":["../../src/helpers/create-execution-host.ts"],"mappings":";;;;;;;;;;AAyCA;;;;;iBAAgB,mBAAA,kBACG,0BAAA,CACf,oBAAA,EACA,mBAAA,IACE,0BAAA,CAA2B,oBAAA,EAAsB,mBAAA,EAAA,CAErD,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"}
@@ -0,0 +1,50 @@
1
+ import { createRpcClient } from "./rpc.mjs";
2
+ import { consoleLogger } from "@powerlines/core/plugin-utils";
3
+ import { uuid } from "@stryke/unique-id/uuid";
4
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
5
+ import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-context";
6
+ import { resolvePluginConfig } from "@powerlines/core/lib/context-helpers";
7
+ import { titleCase } from "@stryke/string-format/title-case";
8
+ import { isFunction } from "@stryke/type-checks/is-function";
9
+ import { defu } from "defu";
10
+
11
+ //#region src/helpers/create-execution-host.ts
12
+ /**
13
+ * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
14
+ *
15
+ * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
16
+ * @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.
17
+ * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
18
+ */
19
+ function createExecutionHost(methods, inlineConfig = {}) {
20
+ return Object.fromEntries(Object.entries(methods).map(([method, fn]) => [method, async (params) => {
21
+ const { options } = params;
22
+ let rpc;
23
+ if (options.baseURL && options.connection) rpc = createRpcClient(options);
24
+ else throw new Error(`Execution RPC client could not be created - Missing ${!options.baseURL ? `baseURL${options.connection ? ` and connection information` : ""}` : "connection"} or connection information.`);
25
+ const logFn = (meta, message) => {
26
+ consoleLogger(meta, message);
27
+ if (rpc) rpc.callEvent("powerlines:log", {
28
+ meta: {
29
+ category: "general",
30
+ ...options,
31
+ ...isSetObject(meta) ? meta : { type: meta },
32
+ logId: uuid(),
33
+ timestamp: Date.now()
34
+ },
35
+ message
36
+ });
37
+ };
38
+ const context = await PowerlinesExecutionContext.from({
39
+ ...options,
40
+ logFn
41
+ }, isFunction(inlineConfig) ? await Promise.resolve(inlineConfig(params.inlineConfig ?? {})) : defu(inlineConfig, params.inlineConfig ?? {}), { rpc });
42
+ context.logger.info(`Starting ${titleCase(options.framework?.name) || "Powerlines"} - ${titleCase(method)} execution (${options.executionId})`);
43
+ await resolvePluginConfig(context);
44
+ await fn(context);
45
+ }]));
46
+ }
47
+
48
+ //#endregion
49
+ export { createExecutionHost };
50
+ //# sourceMappingURL=create-execution-host.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-execution-host.mjs","names":[],"sources":["../../src/helpers/create-execution-host.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 { InlineConfig, LogFnMeta } from \"@powerlines/core\";\nimport { PowerlinesExecutionContext } from \"@powerlines/core/context/execution-context\";\nimport { resolvePluginConfig } from \"@powerlines/core/lib/context-helpers\";\nimport { consoleLogger } from \"@powerlines/core/plugin-utils\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { DeepPartial, MaybePromise } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { defu } from \"defu\";\nimport { RpcClient } from \"../types\";\nimport { ExecutionHostParams } from \"../types/api\";\nimport { EngineResolvedConfig } from \"../types/config\";\nimport { EngineSystemContext } from \"../types/context\";\nimport { createRpcClient } from \"./rpc\";\n\n/**\n * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.\n *\n * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.\n * @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.\n * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.\n */\nexport function createExecutionHost<\n TContext extends PowerlinesExecutionContext<\n EngineResolvedConfig,\n EngineSystemContext\n > = PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext>\n>(\n methods: Record<string, (context: TContext) => Promise<void>>,\n inlineConfig:\n | DeepPartial<InlineConfig>\n | ((prev: InlineConfig) => MaybePromise<InlineConfig>) = {}\n) {\n return Object.fromEntries(\n Object.entries(methods).map(([method, fn]) => [\n method,\n async (params: ExecutionHostParams) => {\n const { options } = params;\n\n let rpc!: RpcClient;\n if (options.baseURL && options.connection) {\n rpc = createRpcClient(options);\n } else {\n throw new Error(\n `Execution RPC client could not be created - Missing ${\n !options.baseURL\n ? `baseURL${options.connection ? ` and connection information` : \"\"}`\n : \"connection\"\n } or connection information.`\n );\n }\n\n const logFn = (meta: LogFnMeta, message: string) => {\n consoleLogger(meta, message);\n if (rpc) {\n void rpc.callEvent(\"powerlines:log\", {\n meta: {\n category: \"general\",\n ...options,\n ...(isSetObject(meta) ? meta : { type: meta }),\n logId: uuid(),\n timestamp: Date.now()\n },\n message\n });\n }\n };\n\n const context = (await PowerlinesExecutionContext.from<\n EngineResolvedConfig,\n EngineSystemContext\n >(\n { ...options, logFn },\n isFunction(inlineConfig)\n ? await Promise.resolve(inlineConfig(params.inlineConfig ?? {}))\n : (defu(inlineConfig, params.inlineConfig ?? {}) as InlineConfig),\n {\n rpc\n }\n )) as TContext;\n\n context.logger.info(\n `Starting ${\n titleCase(options.framework?.name) || \"Powerlines\"\n } - ${titleCase(method)} execution (${options.executionId})`\n );\n\n await resolvePluginConfig(context as PowerlinesExecutionContext<any>);\n\n await fn(context);\n }\n ])\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyCA,SAAgB,oBAMd,SACA,eAE2D,EAAE,EAC7D;AACA,QAAO,OAAO,YACZ,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,QAAQ,QAAQ,CAC5C,QACA,OAAO,WAAgC;EACrC,MAAM,EAAE,YAAY;EAEpB,IAAI;AACJ,MAAI,QAAQ,WAAW,QAAQ,WAC7B,OAAM,gBAAgB,QAAQ;MAE9B,OAAM,IAAI,MACR,uDACE,CAAC,QAAQ,UACL,UAAU,QAAQ,aAAa,gCAAgC,OAC/D,aACL,6BACF;EAGH,MAAM,SAAS,MAAiB,YAAoB;AAClD,iBAAc,MAAM,QAAQ;AAC5B,OAAI,IACF,CAAK,IAAI,UAAU,kBAAkB;IACnC,MAAM;KACJ,UAAU;KACV,GAAG;KACH,GAAI,YAAY,KAAK,GAAG,OAAO,EAAE,MAAM,MAAM;KAC7C,OAAO,MAAM;KACb,WAAW,KAAK,KAAK;KACtB;IACD;IACD,CAAC;;EAIN,MAAM,UAAW,MAAM,2BAA2B,KAIhD;GAAE,GAAG;GAAS;GAAO,EACrB,WAAW,aAAa,GACpB,MAAM,QAAQ,QAAQ,aAAa,OAAO,gBAAgB,EAAE,CAAC,CAAC,GAC7D,KAAK,cAAc,OAAO,gBAAgB,EAAE,CAAC,EAClD,EACE,KACD,CACF;AAED,UAAQ,OAAO,KACb,YACE,UAAU,QAAQ,WAAW,KAAK,IAAI,aACvC,KAAK,UAAU,OAAO,CAAC,cAAc,QAAQ,YAAY,GAC3D;AAED,QAAM,oBAAoB,QAA2C;AAErE,QAAM,GAAG,QAAQ;GAEpB,CAAC,CACH"}