@powerlines/engine 0.0.24 โ†’ 0.9.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 (191) 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-Bw-RpQgX.d.cts +134 -0
  65. package/dist/api-Bw-RpQgX.d.cts.map +1 -0
  66. package/dist/api-D9bpSxPB.d.mts +134 -0
  67. package/dist/api-D9bpSxPB.d.mts.map +1 -0
  68. package/dist/config-B_E_HMcT.d.cts +200 -0
  69. package/dist/config-B_E_HMcT.d.cts.map +1 -0
  70. package/dist/config-FB8Zqjjz.d.mts +200 -0
  71. package/dist/config-FB8Zqjjz.d.mts.map +1 -0
  72. package/dist/context/index.cjs +2 -9
  73. package/dist/context/index.d.cts +2 -660
  74. package/dist/context/index.d.mts +2 -660
  75. package/dist/context/index.mjs +2 -4
  76. package/dist/context-C_P-KYJX.d.cts +149 -0
  77. package/dist/context-C_P-KYJX.d.cts.map +1 -0
  78. package/dist/context-DrNGEC0b.d.mts +149 -0
  79. package/dist/context-DrNGEC0b.d.mts.map +1 -0
  80. package/dist/engine-context-BXjBJuHe.d.mts +54 -0
  81. package/dist/engine-context-BXjBJuHe.d.mts.map +1 -0
  82. package/dist/engine-context-CPYw-aGB.d.cts +54 -0
  83. package/dist/engine-context-CPYw-aGB.d.cts.map +1 -0
  84. package/dist/engine-context-SEzTm1aq.cjs +179 -0
  85. package/dist/engine-context-f72fUF0N.mjs +173 -0
  86. package/dist/engine-context-f72fUF0N.mjs.map +1 -0
  87. package/dist/engine.cjs +267 -0
  88. package/dist/engine.d.cts +143 -0
  89. package/dist/engine.d.cts.map +1 -0
  90. package/dist/engine.d.mts +143 -0
  91. package/dist/engine.d.mts.map +1 -0
  92. package/dist/engine.mjs +263 -0
  93. package/dist/engine.mjs.map +1 -0
  94. package/dist/helpers/create-execution-host.cjs +23 -0
  95. package/dist/helpers/create-execution-host.d.cts +18 -0
  96. package/dist/helpers/create-execution-host.d.cts.map +1 -0
  97. package/dist/helpers/create-execution-host.d.mts +18 -0
  98. package/dist/helpers/create-execution-host.d.mts.map +1 -0
  99. package/dist/helpers/create-execution-host.mjs +22 -0
  100. package/dist/helpers/create-execution-host.mjs.map +1 -0
  101. package/dist/helpers/execution-host-worker.cjs +307 -0
  102. package/dist/helpers/execution-host-worker.d.cts +64 -0
  103. package/dist/helpers/execution-host-worker.d.cts.map +1 -0
  104. package/dist/helpers/execution-host-worker.d.mts +64 -0
  105. package/dist/helpers/execution-host-worker.d.mts.map +1 -0
  106. package/dist/helpers/execution-host-worker.mjs +306 -0
  107. package/dist/helpers/execution-host-worker.mjs.map +1 -0
  108. package/dist/helpers/finalize.cjs +27 -0
  109. package/dist/helpers/finalize.d.cts +12 -0
  110. package/dist/helpers/finalize.d.cts.map +1 -0
  111. package/dist/helpers/finalize.d.mts +12 -0
  112. package/dist/helpers/finalize.d.mts.map +1 -0
  113. package/dist/helpers/finalize.mjs +26 -0
  114. package/dist/helpers/finalize.mjs.map +1 -0
  115. package/dist/helpers/rpc.cjs +140 -0
  116. package/dist/helpers/rpc.d.cts +7 -0
  117. package/dist/helpers/rpc.d.cts.map +1 -0
  118. package/dist/helpers/rpc.d.mts +7 -0
  119. package/dist/helpers/rpc.d.mts.map +1 -0
  120. package/dist/helpers/rpc.mjs +139 -0
  121. package/dist/helpers/rpc.mjs.map +1 -0
  122. package/dist/index.cjs +4 -567
  123. package/dist/index.d.cts +5 -126
  124. package/dist/index.d.mts +5 -126
  125. package/dist/index.mjs +2 -567
  126. package/dist/worker/execution-host.cjs +419 -0
  127. package/dist/worker/execution-host.d.cts +26 -0
  128. package/dist/worker/execution-host.d.cts.map +1 -0
  129. package/dist/worker/execution-host.d.mts +26 -0
  130. package/dist/worker/execution-host.d.mts.map +1 -0
  131. package/dist/worker/execution-host.mjs +382 -0
  132. package/dist/worker/execution-host.mjs.map +1 -0
  133. package/package.json +88 -124
  134. package/dist/_internal/worker.cjs +0 -4844
  135. package/dist/_internal/worker.d.cts +0 -38
  136. package/dist/_internal/worker.d.cts.map +0 -1
  137. package/dist/_internal/worker.d.mts +0 -38
  138. package/dist/_internal/worker.d.mts.map +0 -1
  139. package/dist/_internal/worker.mjs +0 -4805
  140. package/dist/_internal/worker.mjs.map +0 -1
  141. package/dist/api.cjs +0 -1274
  142. package/dist/api.d.cts +0 -265
  143. package/dist/api.d.cts.map +0 -1
  144. package/dist/api.d.mts +0 -265
  145. package/dist/api.d.mts.map +0 -1
  146. package/dist/api.mjs +0 -1270
  147. package/dist/api.mjs.map +0 -1
  148. package/dist/base-context-BUnL_9z8.mjs +0 -241
  149. package/dist/base-context-BUnL_9z8.mjs.map +0 -1
  150. package/dist/base-context-CFvO2N9I.cjs +0 -248
  151. package/dist/context/index.d.cts.map +0 -1
  152. package/dist/context/index.d.mts.map +0 -1
  153. package/dist/engine-context-BuD9AGfd.mjs +0 -41
  154. package/dist/engine-context-BuD9AGfd.mjs.map +0 -1
  155. package/dist/engine-context-NO6enYev.cjs +0 -45
  156. package/dist/execution-context-Cq9cjr28.mjs +0 -2571
  157. package/dist/execution-context-Cq9cjr28.mjs.map +0 -1
  158. package/dist/execution-context-CyDSAifN.cjs +0 -2615
  159. package/dist/fs-D1nIP45P.mjs +0 -226
  160. package/dist/fs-D1nIP45P.mjs.map +0 -1
  161. package/dist/fs-XogSgMqT.cjs +0 -262
  162. package/dist/index.d.cts.map +0 -1
  163. package/dist/index.d.mts.map +0 -1
  164. package/dist/index.mjs.map +0 -1
  165. package/dist/schemas.cjs +0 -9
  166. package/dist/schemas.d.cts +0 -127
  167. package/dist/schemas.d.cts.map +0 -1
  168. package/dist/schemas.d.mts +0 -127
  169. package/dist/schemas.d.mts.map +0 -1
  170. package/dist/schemas.mjs +0 -3
  171. package/dist/storage/index.cjs +0 -9
  172. package/dist/storage/index.d.cts +0 -419
  173. package/dist/storage/index.d.cts.map +0 -1
  174. package/dist/storage/index.d.mts +0 -419
  175. package/dist/storage/index.d.mts.map +0 -1
  176. package/dist/storage/index.mjs +0 -3
  177. package/dist/ts-morph-BaLPVAdB.cjs +0 -114
  178. package/dist/ts-morph-D0CaA37w.mjs +0 -102
  179. package/dist/ts-morph-D0CaA37w.mjs.map +0 -1
  180. package/dist/tsconfig-Cstsoprg.mjs +0 -155
  181. package/dist/tsconfig-Cstsoprg.mjs.map +0 -1
  182. package/dist/tsconfig-DeyWQC2N.cjs +0 -198
  183. package/dist/typescript/index.cjs +0 -13
  184. package/dist/typescript/index.d.cts +0 -106
  185. package/dist/typescript/index.d.cts.map +0 -1
  186. package/dist/typescript/index.d.mts +0 -106
  187. package/dist/typescript/index.d.mts.map +0 -1
  188. package/dist/typescript/index.mjs +0 -4
  189. package/dist/virtual-BNdKVkRw.cjs +0 -548
  190. package/dist/virtual-gIlTc3Lj.mjs +0 -513
  191. package/dist/virtual-gIlTc3Lj.mjs.map +0 -1
@@ -0,0 +1,143 @@
1
+ import { n as EngineOptions } from "./config-FB8Zqjjz.mjs";
2
+ import { t as EngineContext } from "./context-DrNGEC0b.mjs";
3
+ import { t as PowerlinesEngineContext } from "./engine-context-BXjBJuHe.mjs";
4
+ import { n as ExecutionHost, t as Engine } from "./api-D9bpSxPB.mjs";
5
+ import { EXECUTION_API_METHODS } from "@powerlines/core/constants";
6
+ import { BuildInlineConfig, CleanInlineConfig, CreateInlineConfig, DeployInlineConfig, DocsInlineConfig, InlineConfig, LintInlineConfig, PrepareInlineConfig, TestInlineConfig, TypesInlineConfig } from "@powerlines/core";
7
+
8
+ //#region src/engine.d.ts
9
+ /**
10
+ * The Powerlines process' orchestration and coordination API.
11
+ *
12
+ * @public
13
+ */
14
+ declare class PowerlinesEngine<TExecutionAPI extends ReadonlyArray<string> = typeof EXECUTION_API_METHODS> implements Engine<TExecutionAPI>, AsyncDisposable {
15
+ #private;
16
+ /**
17
+ * The Powerlines context
18
+ */
19
+ get context(): EngineContext;
20
+ /**
21
+ * The execution host, which provides methods to call the execution API functions from the engine context. This allows the engine to invoke commands and other API functions during the execution of Powerlines commands, enabling communication between the engine and the execution contexts.
22
+ */
23
+ get host(): ExecutionHost<TExecutionAPI>;
24
+ /**
25
+ * Create a new Powerlines Engine instance
26
+ *
27
+ * @param context - The Powerlines context
28
+ * @param host - The API host for the execution workers
29
+ * @returns A new instance of the Powerlines Engine
30
+ */
31
+ constructor(context: EngineContext, host: ExecutionHost<TExecutionAPI>);
32
+ /**
33
+ * Create a new Powerlines project
34
+ *
35
+ * @remarks
36
+ * This method will create a new Powerlines project in the current directory.
37
+ *
38
+ * @param inlineConfig - The inline configuration for the create command
39
+ * @returns A promise that resolves when the project has been created
40
+ */
41
+ create(inlineConfig: CreateInlineConfig): Promise<void>;
42
+ /**
43
+ * Generate the Powerlines typescript declaration file
44
+ *
45
+ * @remarks
46
+ * 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.
47
+ *
48
+ * @param inlineConfig - The inline configuration for the types command
49
+ */
50
+ types(inlineConfig: TypesInlineConfig): Promise<void>;
51
+ /**
52
+ * Prepare the Powerlines API
53
+ *
54
+ * @remarks
55
+ * This method will prepare the Powerlines API for use, initializing any necessary resources.
56
+ *
57
+ * @param inlineConfig - The inline configuration for the prepare command
58
+ */
59
+ prepare(inlineConfig: PrepareInlineConfig): Promise<void>;
60
+ /**
61
+ * Clean any previously prepared artifacts
62
+ *
63
+ * @remarks
64
+ * This method will remove the previous Powerlines artifacts from the project.
65
+ *
66
+ * @param inlineConfig - The inline configuration for the clean command
67
+ * @returns A promise that resolves when the clean command has completed
68
+ */
69
+ clean(inlineConfig: CleanInlineConfig): Promise<void>;
70
+ /**
71
+ * Lint the project
72
+ *
73
+ * @param inlineConfig - The inline configuration for the lint command
74
+ * @returns A promise that resolves when the lint command has completed
75
+ */
76
+ lint(inlineConfig: LintInlineConfig): Promise<void>;
77
+ /**
78
+ * Test the project
79
+ *
80
+ * @remarks
81
+ * This method will run the tests for the Powerlines project.
82
+ *
83
+ * @param inlineConfig - The inline configuration for the test command
84
+ * @returns A promise that resolves when the test command has completed
85
+ */
86
+ test(inlineConfig: TestInlineConfig): Promise<void>;
87
+ /**
88
+ * Build the project
89
+ *
90
+ * @remarks
91
+ * This method will build the Powerlines project, generating the necessary artifacts.
92
+ *
93
+ * @param inlineConfig - The inline configuration for the build command
94
+ * @returns A promise that resolves when the build command has completed
95
+ */
96
+ build(inlineConfig: BuildInlineConfig): Promise<void>;
97
+ /**
98
+ * Prepare the documentation for the project
99
+ *
100
+ * @param inlineConfig - The inline configuration for the docs command
101
+ * @returns A promise that resolves when the documentation generation has completed
102
+ */
103
+ docs(inlineConfig: DocsInlineConfig): Promise<void>;
104
+ /**
105
+ * Deploy the project source code
106
+ *
107
+ * @remarks
108
+ * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
109
+ *
110
+ * @param inlineConfig - The inline configuration for the deploy command
111
+ * @returns A promise that resolves when the deploy command has completed
112
+ */
113
+ deploy(inlineConfig: DeployInlineConfig): Promise<void>;
114
+ /**
115
+ * Finalization/cleanup processing for the Powerlines API
116
+ *
117
+ * @remarks
118
+ * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
119
+ *
120
+ * @returns A promise that resolves when the finalization process has completed
121
+ */
122
+ finalize(): Promise<void>;
123
+ /**
124
+ * Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.
125
+ */
126
+ [Symbol.asyncDispose](): Promise<void>;
127
+ /**
128
+ * Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.
129
+ *
130
+ * @remarks
131
+ * 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.
132
+ *
133
+ * @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.
134
+ * @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.
135
+ * @returns A promise that resolves when all executions for the specified command have completed
136
+ */
137
+ protected execute(method: TExecutionAPI[number], inlineConfig: InlineConfig): Promise<void>;
138
+ }
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>>;
141
+ //#endregion
142
+ export { PowerlinesEngine, createContext, createEngine };
143
+ //# sourceMappingURL=engine.d.mts.map
@@ -0,0 +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,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;;;;AAkCJ;;;;EA/De,QAAA,CAAA,GAAQ,OAAA;EA+DmC;;;EAAA,CAlD1C,MAAA,CAAO,YAAA,KAAa,OAAA;EAkDA;;;;;AAuBpC;;;;;EAvBoC,UApClB,OAAA,CACd,MAAA,EAAQ,aAAA,UACR,YAAA,EAAc,YAAA,GAAY,OAAA;AAAA;AAAA,iBAkCR,aAAA,CAAc,OAAA,EAAS,aAAA,GAAa,OAAA,CAAA,uBAAA;AAAA,iBAuBpC,YAAA,uBAAmC,aAAA,SAAA,CACvD,OAAA,EAAS,aAAA,EACT,iBAAA,WACA,gBAAA,GAAkB,aAAA,GAAiE,OAAA,CAAA,gBAAA,CAAA,aAAA"}
@@ -0,0 +1,263 @@
1
+ import { t as PowerlinesEngineContext } from "./engine-context-f72fUF0N.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
+ context,
257
+ executionMethods
258
+ }));
259
+ }
260
+
261
+ //#endregion
262
+ export { PowerlinesEngine, createContext, createEngine };
263
+ //# 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 context,\n executionMethods\n }\n );\n\n return new PowerlinesEngine<TExecutionAPI>(context, host);\n}\n"],"mappings":"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"}
@@ -0,0 +1,23 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_chunk = require('../chunk-C0xms8kb.cjs');
3
+ let _powerlines_core_context_execution_context = require("@powerlines/core/context/execution-context");
4
+ let _powerlines_core_lib_context_helpers = require("@powerlines/core/lib/context-helpers");
5
+
6
+ //#region src/helpers/create-execution-host.ts
7
+ /**
8
+ * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
9
+ *
10
+ * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
11
+ * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
12
+ */
13
+ function createExecutionHost(methods) {
14
+ return Object.fromEntries(Object.entries(methods).map(([method, fn]) => [method, async (params) => {
15
+ const context = await _powerlines_core_context_execution_context.PowerlinesExecutionContext.from(params.options, params.inlineConfig ?? {});
16
+ context.logger.info(`Starting ${method} execution (${params.options.executionId})`);
17
+ await (0, _powerlines_core_lib_context_helpers.resolvePluginConfig)(context);
18
+ await fn(context);
19
+ }]));
20
+ }
21
+
22
+ //#endregion
23
+ exports.createExecutionHost = createExecutionHost;
@@ -0,0 +1,18 @@
1
+ import { r as EngineResolvedConfig } from "../config-B_E_HMcT.cjs";
2
+ import { r as EngineSystemContext } from "../context-C_P-KYJX.cjs";
3
+ import { r as ExecutionHostParams } from "../api-Bw-RpQgX.cjs";
4
+ import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-context";
5
+
6
+ //#region src/helpers/create-execution-host.d.ts
7
+ /**
8
+ * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
9
+ *
10
+ * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
11
+ * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
12
+ */
13
+ declare function createExecutionHost<TContext extends PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext> = PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext>>(methods: Record<string, (context: TContext) => Promise<void>>): {
14
+ [k: string]: (params: ExecutionHostParams) => Promise<void>;
15
+ };
16
+ //#endregion
17
+ export { createExecutionHost };
18
+ //# 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":";;;;;;;;AA8BA;;;;iBAAgB,mBAAA,kBACG,0BAAA,CACf,oBAAA,EACA,mBAAA,IACE,0BAAA,CAA2B,oBAAA,EAAsB,mBAAA,EAAA,CACrD,OAAA,EAAS,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA;EAAA,sBAI5B,mBAAA,KAAmB,OAAA;AAAA"}
@@ -0,0 +1,18 @@
1
+ import { r as EngineResolvedConfig } from "../config-FB8Zqjjz.mjs";
2
+ import { r as EngineSystemContext } from "../context-DrNGEC0b.mjs";
3
+ import { r as ExecutionHostParams } from "../api-D9bpSxPB.mjs";
4
+ import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-context";
5
+
6
+ //#region src/helpers/create-execution-host.d.ts
7
+ /**
8
+ * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
9
+ *
10
+ * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
11
+ * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
12
+ */
13
+ declare function createExecutionHost<TContext extends PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext> = PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext>>(methods: Record<string, (context: TContext) => Promise<void>>): {
14
+ [k: string]: (params: ExecutionHostParams) => Promise<void>;
15
+ };
16
+ //#endregion
17
+ export { createExecutionHost };
18
+ //# 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":";;;;;;;;AA8BA;;;;iBAAgB,mBAAA,kBACG,0BAAA,CACf,oBAAA,EACA,mBAAA,IACE,0BAAA,CAA2B,oBAAA,EAAsB,mBAAA,EAAA,CACrD,OAAA,EAAS,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA;EAAA,sBAI5B,mBAAA,KAAmB,OAAA;AAAA"}
@@ -0,0 +1,22 @@
1
+ import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-context";
2
+ import { resolvePluginConfig } from "@powerlines/core/lib/context-helpers";
3
+
4
+ //#region src/helpers/create-execution-host.ts
5
+ /**
6
+ * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
7
+ *
8
+ * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
9
+ * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
10
+ */
11
+ function createExecutionHost(methods) {
12
+ return Object.fromEntries(Object.entries(methods).map(([method, fn]) => [method, async (params) => {
13
+ const context = await PowerlinesExecutionContext.from(params.options, params.inlineConfig ?? {});
14
+ context.logger.info(`Starting ${method} execution (${params.options.executionId})`);
15
+ await resolvePluginConfig(context);
16
+ await fn(context);
17
+ }]));
18
+ }
19
+
20
+ //#endregion
21
+ export { createExecutionHost };
22
+ //# 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 { PowerlinesExecutionContext } from \"@powerlines/core/context/execution-context\";\nimport { resolvePluginConfig } from \"@powerlines/core/lib/context-helpers\";\nimport { ExecutionHostParams } from \"../types/api\";\nimport { EngineResolvedConfig } from \"../types/config\";\nimport { EngineSystemContext } from \"../types/context\";\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 * @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>(methods: Record<string, (context: TContext) => Promise<void>>) {\n return Object.fromEntries(\n Object.entries(methods).map(([method, fn]) => [\n method,\n async (params: ExecutionHostParams) => {\n const context = (await PowerlinesExecutionContext.from(\n params.options,\n params.inlineConfig ?? {}\n )) as TContext;\n context.logger.info(\n `Starting ${method} execution (${params.options.executionId})`\n );\n\n await resolvePluginConfig(context as PowerlinesExecutionContext<any>);\n\n await fn(context);\n }\n ])\n );\n}\n"],"mappings":";;;;;;;;;;AA8BA,SAAgB,oBAKd,SAA+D;AAC/D,QAAO,OAAO,YACZ,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,QAAQ,QAAQ,CAC5C,QACA,OAAO,WAAgC;EACrC,MAAM,UAAW,MAAM,2BAA2B,KAChD,OAAO,SACP,OAAO,gBAAgB,EAAE,CAC1B;AACD,UAAQ,OAAO,KACb,YAAY,OAAO,cAAc,OAAO,QAAQ,YAAY,GAC7D;AAED,QAAM,oBAAoB,QAA2C;AAErE,QAAM,GAAG,QAAQ;GAEpB,CAAC,CACH"}