@powerlines/engine 0.47.4 → 0.49.2

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 (249) 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 +28 -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 +24 -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 +24 -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 +27 -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 +68 -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 +27 -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 +70 -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-BgyEi2hF.d.mts +138 -0
  65. package/dist/api-BgyEi2hF.d.mts.map +1 -0
  66. package/dist/api-DcHfCjQK.d.cts +138 -0
  67. package/dist/api-DcHfCjQK.d.cts.map +1 -0
  68. package/dist/api.cjs +39 -1268
  69. package/dist/api.d.cts +11 -300
  70. package/dist/api.d.cts.map +1 -1
  71. package/dist/api.d.mts +11 -300
  72. package/dist/api.d.mts.map +1 -1
  73. package/dist/api.mjs +31 -1264
  74. package/dist/api.mjs.map +1 -1
  75. package/dist/config-ByLyzMI0.d.mts +204 -0
  76. package/dist/config-ByLyzMI0.d.mts.map +1 -0
  77. package/dist/config-DKEmqMrh.d.cts +204 -0
  78. package/dist/config-DKEmqMrh.d.cts.map +1 -0
  79. package/dist/context/engine-context.cjs +177 -0
  80. package/dist/context/engine-context.d.cts +2 -0
  81. package/dist/context/engine-context.d.mts +2 -0
  82. package/dist/context/engine-context.mjs +175 -0
  83. package/dist/context/engine-context.mjs.map +1 -0
  84. package/dist/context/index.cjs +2 -9
  85. package/dist/context/index.d.cts +2 -150
  86. package/dist/context/index.d.mts +2 -150
  87. package/dist/context/index.mjs +2 -4
  88. package/dist/context-D0_a0kRO.d.cts +149 -0
  89. package/dist/context-D0_a0kRO.d.cts.map +1 -0
  90. package/dist/context-DcXV6_GL.d.mts +149 -0
  91. package/dist/context-DcXV6_GL.d.mts.map +1 -0
  92. package/dist/engine-Dz6BvkFY.cjs +590 -0
  93. package/dist/engine-context-B8K6Jtkk.d.cts +53 -0
  94. package/dist/engine-context-B8K6Jtkk.d.cts.map +1 -0
  95. package/dist/engine-context-DKlA5Pgu.d.mts +53 -0
  96. package/dist/engine-context-DKlA5Pgu.d.mts.map +1 -0
  97. package/dist/engine-q6YKXXcB.mjs +571 -0
  98. package/dist/engine-q6YKXXcB.mjs.map +1 -0
  99. package/dist/engine.cjs +6 -0
  100. package/dist/engine.d.cts +143 -0
  101. package/dist/engine.d.cts.map +1 -0
  102. package/dist/engine.d.mts +143 -0
  103. package/dist/engine.d.mts.map +1 -0
  104. package/dist/engine.mjs +3 -0
  105. package/dist/helpers/create-execution-host.cjs +57 -0
  106. package/dist/helpers/create-execution-host.d.cts +20 -0
  107. package/dist/helpers/create-execution-host.d.cts.map +1 -0
  108. package/dist/helpers/create-execution-host.d.mts +20 -0
  109. package/dist/helpers/create-execution-host.d.mts.map +1 -0
  110. package/dist/helpers/create-execution-host.mjs +57 -0
  111. package/dist/helpers/create-execution-host.mjs.map +1 -0
  112. package/dist/helpers/finalize.cjs +26 -0
  113. package/dist/helpers/finalize.d.cts +12 -0
  114. package/dist/helpers/finalize.d.cts.map +1 -0
  115. package/dist/helpers/finalize.d.mts +12 -0
  116. package/dist/helpers/finalize.d.mts.map +1 -0
  117. package/dist/helpers/finalize.mjs +26 -0
  118. package/dist/helpers/finalize.mjs.map +1 -0
  119. package/dist/helpers/index.cjs +12 -0
  120. package/dist/helpers/index.d.cts +5 -0
  121. package/dist/helpers/index.d.mts +5 -0
  122. package/dist/helpers/index.mjs +6 -0
  123. package/dist/helpers/rpc.cjs +139 -0
  124. package/dist/helpers/rpc.d.cts +7 -0
  125. package/dist/helpers/rpc.d.cts.map +1 -0
  126. package/dist/helpers/rpc.d.mts +7 -0
  127. package/dist/helpers/rpc.d.mts.map +1 -0
  128. package/dist/helpers/rpc.mjs +139 -0
  129. package/dist/helpers/rpc.mjs.map +1 -0
  130. package/dist/helpers/stream.cjs +119 -0
  131. package/dist/helpers/stream.d.cts +45 -0
  132. package/dist/helpers/stream.d.cts.map +1 -0
  133. package/dist/helpers/stream.d.mts +45 -0
  134. package/dist/helpers/stream.d.mts.map +1 -0
  135. package/dist/helpers/stream.mjs +117 -0
  136. package/dist/helpers/stream.mjs.map +1 -0
  137. package/dist/index-BVVgDSdq.d.cts +1 -0
  138. package/dist/index-BVVgDSdq.d.mts +1 -0
  139. package/dist/index.cjs +8 -748
  140. package/dist/index.d.cts +6 -140
  141. package/dist/index.d.mts +6 -140
  142. package/dist/index.mjs +4 -747
  143. package/package.json +102 -132
  144. package/dist/_internal/worker.cjs +0 -5192
  145. package/dist/_internal/worker.d.cts +0 -46
  146. package/dist/_internal/worker.d.cts.map +0 -1
  147. package/dist/_internal/worker.d.mts +0 -46
  148. package/dist/_internal/worker.d.mts.map +0 -1
  149. package/dist/_internal/worker.mjs +0 -5153
  150. package/dist/_internal/worker.mjs.map +0 -1
  151. package/dist/base-context-DLemGRbd.cjs +0 -322
  152. package/dist/base-context-DUha4Lz-.mjs +0 -315
  153. package/dist/base-context-DUha4Lz-.mjs.map +0 -1
  154. package/dist/context/index.d.cts.map +0 -1
  155. package/dist/context/index.d.mts.map +0 -1
  156. package/dist/engine-context-BfFiKN53.mjs +0 -86
  157. package/dist/engine-context-BfFiKN53.mjs.map +0 -1
  158. package/dist/engine-context-D0y88i_J.cjs +0 -91
  159. package/dist/execution-context-CE5H90Um.mjs +0 -2845
  160. package/dist/execution-context-CE5H90Um.mjs.map +0 -1
  161. package/dist/execution-context-CnyaM3Ul.cjs +0 -2889
  162. package/dist/execution-context-NyDjVZ6T.d.cts +0 -647
  163. package/dist/execution-context-NyDjVZ6T.d.cts.map +0 -1
  164. package/dist/execution-context-YrjFeD9k.d.mts +0 -647
  165. package/dist/execution-context-YrjFeD9k.d.mts.map +0 -1
  166. package/dist/fs-CeEdzPKE.cjs +0 -262
  167. package/dist/fs-Dcle8lUp.mjs +0 -226
  168. package/dist/fs-Dcle8lUp.mjs.map +0 -1
  169. package/dist/index.d.cts.map +0 -1
  170. package/dist/index.d.mts.map +0 -1
  171. package/dist/index.mjs.map +0 -1
  172. package/dist/rpc/client.cjs +0 -74
  173. package/dist/rpc/client.d.cts +0 -31
  174. package/dist/rpc/client.d.cts.map +0 -1
  175. package/dist/rpc/client.d.mts +0 -31
  176. package/dist/rpc/client.d.mts.map +0 -1
  177. package/dist/rpc/client.mjs +0 -71
  178. package/dist/rpc/client.mjs.map +0 -1
  179. package/dist/rpc/serialization.cjs +0 -82
  180. package/dist/rpc/serialization.d.cts +0 -46
  181. package/dist/rpc/serialization.d.cts.map +0 -1
  182. package/dist/rpc/serialization.d.mts +0 -46
  183. package/dist/rpc/serialization.d.mts.map +0 -1
  184. package/dist/rpc/serialization.mjs +0 -76
  185. package/dist/rpc/serialization.mjs.map +0 -1
  186. package/dist/rpc/server.cjs +0 -69
  187. package/dist/rpc/server.d.cts +0 -29
  188. package/dist/rpc/server.d.cts.map +0 -1
  189. package/dist/rpc/server.d.mts +0 -29
  190. package/dist/rpc/server.d.mts.map +0 -1
  191. package/dist/rpc/server.mjs +0 -66
  192. package/dist/rpc/server.mjs.map +0 -1
  193. package/dist/rpc/types.cjs +0 -0
  194. package/dist/rpc/types.d.cts +0 -70
  195. package/dist/rpc/types.d.cts.map +0 -1
  196. package/dist/rpc/types.d.mts +0 -70
  197. package/dist/rpc/types.d.mts.map +0 -1
  198. package/dist/rpc/types.mjs +0 -1
  199. package/dist/schemas.cjs +0 -9
  200. package/dist/schemas.d.cts +0 -127
  201. package/dist/schemas.d.cts.map +0 -1
  202. package/dist/schemas.d.mts +0 -127
  203. package/dist/schemas.d.mts.map +0 -1
  204. package/dist/schemas.mjs +0 -3
  205. package/dist/storage/base.cjs +0 -216
  206. package/dist/storage/base.d.cts +0 -199
  207. package/dist/storage/base.d.cts.map +0 -1
  208. package/dist/storage/base.d.mts +0 -199
  209. package/dist/storage/base.d.mts.map +0 -1
  210. package/dist/storage/base.mjs +0 -215
  211. package/dist/storage/base.mjs.map +0 -1
  212. package/dist/storage/file-system.cjs +0 -180
  213. package/dist/storage/file-system.d.cts +0 -127
  214. package/dist/storage/file-system.d.cts.map +0 -1
  215. package/dist/storage/file-system.d.mts +0 -127
  216. package/dist/storage/file-system.d.mts.map +0 -1
  217. package/dist/storage/file-system.mjs +0 -179
  218. package/dist/storage/file-system.mjs.map +0 -1
  219. package/dist/storage/helpers.cjs +0 -37
  220. package/dist/storage/helpers.d.cts +0 -25
  221. package/dist/storage/helpers.d.cts.map +0 -1
  222. package/dist/storage/helpers.d.mts +0 -25
  223. package/dist/storage/helpers.d.mts.map +0 -1
  224. package/dist/storage/helpers.mjs +0 -34
  225. package/dist/storage/helpers.mjs.map +0 -1
  226. package/dist/storage/index.cjs +0 -12
  227. package/dist/storage/index.d.cts +0 -5
  228. package/dist/storage/index.d.mts +0 -5
  229. package/dist/storage/index.mjs +0 -6
  230. package/dist/storage/virtual.cjs +0 -98
  231. package/dist/storage/virtual.d.cts +0 -80
  232. package/dist/storage/virtual.d.cts.map +0 -1
  233. package/dist/storage/virtual.d.mts +0 -80
  234. package/dist/storage/virtual.d.mts.map +0 -1
  235. package/dist/storage/virtual.mjs +0 -97
  236. package/dist/storage/virtual.mjs.map +0 -1
  237. package/dist/ts-morph-BbM83PT9.cjs +0 -114
  238. package/dist/ts-morph-C6YBNc46.mjs +0 -102
  239. package/dist/ts-morph-C6YBNc46.mjs.map +0 -1
  240. package/dist/tsconfig-DeKMGasE.cjs +0 -198
  241. package/dist/tsconfig-HzJsMUrr.mjs +0 -155
  242. package/dist/tsconfig-HzJsMUrr.mjs.map +0 -1
  243. package/dist/typescript/index.cjs +0 -13
  244. package/dist/typescript/index.d.cts +0 -106
  245. package/dist/typescript/index.d.cts.map +0 -1
  246. package/dist/typescript/index.d.mts +0 -106
  247. package/dist/typescript/index.d.mts.map +0 -1
  248. package/dist/typescript/index.mjs +0 -4
  249. /package/dist/{chunk-C0xms8kb.cjs → chunk-C_NdSu1c.cjs} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-q6YKXXcB.mjs","names":["#worker","#context","#host"],"sources":["../src/_internal/execution-host-worker.ts","../src/engine.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { InlineConfig, Mode } from \"@powerlines/core\";\nimport { getDefaultMode } from \"@powerlines/core/lib/config\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { resolve } from \"@stryke/fs/resolve\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { AnyFunction } from \"@stryke/types/base\";\nimport { formatDuration } from \"date-fns/formatDuration\";\nimport { createJiti } from \"jiti\";\nimport { pipeline } from \"node:stream\";\nimport { parseArgs } from \"node:util\";\nimport {\n MessageChannel,\n StructuredSerializeOptions\n} from \"node:worker_threads\";\nimport Piscina from \"piscina\";\nimport { MessagePortDuplex } from \"../helpers/stream\";\nimport { ExecutionHost } from \"../types/api\";\nimport { EngineExecutionOptions } from \"../types/config\";\nimport { EngineContext } from \"../types/context\";\n\nconst RESTARTED = Symbol(\"powerlines-worker:restarted\");\n\n/**\n * The debug address is in the form of `[host:]port`. The host is optional.\n */\ninterface DebugAddress {\n host?: string;\n port: number;\n}\n\n/**\n * Formats the debug address into a string.\n */\nconst formatDebugAddress = ({ host, port }: DebugAddress): string => {\n return host ? `${host}:${port}` : `${port}`;\n};\n\nexport type NodeOptions = Record<string, string | boolean | undefined>;\n\n/**\n * Get's the debug address from the `NODE_OPTIONS` environment variable. If the\n * address is not found, it returns the default host (`undefined`) and port\n * (`9229`).\n *\n * @returns An object with the host and port of the debug address.\n */\nconst getParsedDebugAddress = (\n address: string | boolean | undefined\n): DebugAddress => {\n if (!address || !isString(address)) {\n return { host: undefined, port: 9229 };\n }\n\n // The address is in the form of `[host:]port`. Let's parse the address.\n if (address.includes(\":\")) {\n const [host, port] = address.split(\":\");\n if (!host || !port) {\n throw new Error(`Invalid debug address: ${address}`);\n }\n\n return { host, port: Number.parseInt(port, 10) };\n }\n\n return { host: undefined, port: Number.parseInt(address, 10) };\n};\n\ntype NodeInspectType = \"inspect\" | \"inspect-brk\" | undefined;\n\n/**\n * Get the debug type from the `NODE_OPTIONS` environment variable.\n */\nfunction getNodeDebugType(nodeOptions: NodeOptions): NodeInspectType {\n if (nodeOptions.inspect) {\n return \"inspect\";\n }\n if (nodeOptions[\"inspect-brk\"] || nodeOptions.inspect_brk) {\n return \"inspect-brk\";\n }\n\n return undefined;\n}\n\nexport interface ExecutionHostWorkerOptions<\n TExecutionAPI extends ReadonlyArray<string>\n> {\n // /**\n // * `-1` if not inspectable\n // */\n // debuggerPortOffset?: number;\n\n // /**\n // * Whether to enable source maps support in the worker, which can improve the quality of stack traces at the cost of increased memory usage and slower performance. Defaults to `false`.\n // */\n // enableSourceMaps?: boolean;\n\n /**\n * The maximum time in milliseconds a worker can run before being terminated.\n *\n * @defaultValue 900000 (15 minutes)\n */\n timeout?: number;\n\n /**\n * True if `--max-old-space-size` should not be forwarded to the worker.\n */\n isolatedMemory?: boolean;\n\n /**\n * The mode to run the worker in, which can affect how the worker is initialized and how it behaves. This is determined based on the resolved configuration of the engine, and can be used to optimize the worker for different environments (e.g., development, production, etc.).\n */\n mode?: Mode;\n\n /**\n * An optional root to resolve the execution host path from, which can be used to specify a custom root directory for the worker to use when resolving paths and loading configuration files. If this option is not provided, the worker will use the current working directory as the root directory by default.\n */\n root?: string;\n\n /**\n * The context of the {@link @powerlines/engine#Engine | Engine instance}, which can be used to access the engine's state and services within the worker.\n */\n context: EngineContext;\n\n /**\n * An array of method names that the worker exposes. These methods will be available on the Worker instance and can be called to execute tasks in the worker process.\n */\n apiMethods?: TExecutionAPI;\n}\n\nexport class ExecutionHostWorker<TExecutionAPI extends ReadonlyArray<string>> {\n #worker: Piscina | undefined;\n\n /**\n * Creates a new instance of the ExecutionHostWorker class, which manages a worker process for executing tasks related to the Powerlines Engine. The worker is initialized with the specified options and can be used to run tasks in an isolated environment, with support for automatic restarts and activity monitoring.\n *\n * @param apiPath - The path to the Execution Host file.\n * @param options - The options for configuring the worker, including the execution context, exposed methods, timeout, and mode.\n * @returns A promise that resolves to an instance of the ExecutionHostWorker class.\n */\n public static async from<TExecutionAPI extends ReadonlyArray<string>>(\n apiPath: string,\n options: ExecutionHostWorkerOptions<TExecutionAPI>\n ) {\n const mode = await getDefaultMode(options.context.cwd);\n\n const resolvedPath = await resolve(apiPath, {\n paths: [\n options.context.cwd,\n options.root ? appendPath(options.root, options.context.cwd) : undefined\n ].filter(Boolean) as string[]\n });\n if (!resolvedPath) {\n throw new Error(\n `Could not resolve the provided Execution Host path: \\`${apiPath}\\`.`\n );\n }\n\n let exposedMethods = toArray((options.apiMethods ?? []) as string[]);\n if (exposedMethods.length === 0) {\n const jiti = createJiti(import.meta.url, {\n cache: false,\n interopDefault: true,\n tsconfigPaths: true\n });\n const mod: Record<string, AnyFunction> = await jiti.import(\n jiti.esmResolve(resolvedPath)\n );\n if (isFunction(mod)) {\n exposedMethods.push(...exposedMethods, \"default\");\n } else if (isSetObject(mod)) {\n exposedMethods = Object.keys(mod).filter(name => isFunction(mod[name]));\n }\n }\n\n return new ExecutionHostWorker<TExecutionAPI>(\n resolvedPath,\n exposedMethods,\n {\n mode,\n ...options\n }\n ) as unknown as ExecutionHost<TExecutionAPI>;\n }\n\n /**\n * Create a new worker instance.\n *\n * @param executionHostPath - The path to the worker file.\n * @param exposedMethods - An array of method names that the worker exposes.\n * @param options - The options for the worker, including exposed methods, timeout, and hooks for activity and restart.\n */\n public constructor(\n protected executionHostPath: string,\n protected exposedMethods: string[],\n protected options: ExecutionHostWorkerOptions<TExecutionAPI>\n ) {\n const {\n timeout = 900_000,\n isolatedMemory = false,\n mode = \"production\",\n context\n } = this.options;\n\n const logger = context.extendLogger({ category: \"communication\" });\n\n let restartPromise: Promise<typeof RESTARTED>;\n let resolveRestartPromise: (arg: typeof RESTARTED) => void;\n let activeTasks = 0;\n\n this.#worker = undefined;\n\n // ensure we end workers if they weren't before exit\n process.on(\"exit\", () => {\n void this.finalize();\n });\n\n let nodeOptions = {} as {\n [longOption: string]: string | boolean | undefined;\n };\n\n const args: string[] = [...process.execArgv];\n if (process.env.NODE_OPTIONS) {\n let isInString = false;\n let willStartNewArg = true;\n\n const stringifiedNodeOptions = process.env.NODE_OPTIONS.split(\" \").filter(\n part =>\n ((part.startsWith('\"') && part.endsWith('\"')) ||\n (part.startsWith(\"'\") && part.endsWith(\"'\"))) &&\n part\n .replace(/^['\"]|['\"]$/g, \"\")\n .split(\" \")\n .filter(isSetString).length > 0 &&\n part\n .replace(/^['\"]|['\"]$/g, \"\")\n .split(\" \")\n .filter(isSetString)\n .every(p => p.startsWith(\"--\"))\n );\n args.push(\n ...stringifiedNodeOptions.map(part => part.replace(/^['\"]|['\"]$/g, \"\"))\n );\n\n const inputNodeModules = stringifiedNodeOptions.reduce((acc, part) => {\n return acc.replace(part, \"\").trim();\n }, process.env.NODE_OPTIONS);\n for (let i = 0; i < inputNodeModules.length; i++) {\n let char = inputNodeModules[i];\n if (char) {\n // Skip any escaped characters in strings.\n if (char === \"\\\\\" && isInString) {\n // Ensure we don't have an escape character at the end.\n if (inputNodeModules.length === i + 1) {\n throw new Error(\"Invalid escape character at the end.\");\n }\n\n // Skip the next character.\n char = inputNodeModules[++i];\n if (!char) {\n continue;\n }\n }\n // If we find a space outside of a string, we should start a new argument.\n else if (char === \" \" && !isInString) {\n willStartNewArg = true;\n continue;\n }\n\n // If we find a quote, we should toggle the string flag.\n else if (char === '\"') {\n isInString = !isInString;\n continue;\n }\n\n // If we're starting a new argument, we should add it to the array.\n if (willStartNewArg) {\n args.push(char);\n willStartNewArg = false;\n }\n // Otherwise, add it to the last argument.\n else {\n args[args.length - 1] += char;\n }\n }\n }\n\n if (isInString) {\n throw new Error(\"Unterminated string\");\n }\n }\n\n if (args.length > 0) {\n const { values, tokens } = parseArgs({\n args,\n strict: false,\n tokens: true\n });\n nodeOptions = values;\n\n // For the `NODE_OPTIONS`, we support arguments with values without the `=`\n // sign. We need to parse them manually.\n let orphan = null;\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (!token) continue;\n\n if (token.kind === \"option-terminator\") {\n break;\n }\n\n // When we encounter an option, if it's value is undefined, we should check\n // to see if the following tokens are positional parameters. If they are,\n // then the option is orphaned, and we can assign it.\n if (token.kind === \"option\") {\n orphan = !isSet(token.value) ? token : null;\n continue;\n }\n\n // If the token isn't a positional one, then we can't assign it to the found\n // orphaned option.\n if (token.kind !== \"positional\") {\n orphan = null;\n continue;\n }\n\n // If we don't have an orphan, then we can skip this token.\n if (!orphan) {\n continue;\n }\n\n // If the token is a positional one, and it has a value, so add it to the\n // values object. If it already exists, append it with a space.\n if (orphan.name in nodeOptions && isString(nodeOptions[orphan.name])) {\n nodeOptions[orphan.name] += ` ${token.value}`;\n } else {\n nodeOptions[orphan.name] = token.value;\n }\n }\n }\n\n const originalOptions = { ...nodeOptions };\n\n delete nodeOptions.inspect;\n delete nodeOptions[\"inspect-brk\"];\n delete nodeOptions.inspect_brk;\n\n if (mode === \"development\") {\n const nodeDebugType = getNodeDebugType(originalOptions);\n if (nodeDebugType) {\n const debuggerAddress = getParsedDebugAddress(\n originalOptions[nodeDebugType]\n );\n const address: DebugAddress = {\n host: debuggerAddress.host,\n // current process runs on `address.port`\n port: debuggerAddress.port === 0 ? 0 : debuggerAddress.port + 1 + 1\n };\n nodeOptions[nodeDebugType] = formatDebugAddress(address);\n }\n\n nodeOptions[\"enable-source-maps\"] = true;\n }\n\n if (isolatedMemory) {\n delete nodeOptions[\"max-old-space-size\"];\n delete nodeOptions.max_old_space_size;\n }\n\n const execArgv: string[] = [];\n const nodeOptionsParts: string[] = [];\n for (const [key, value] of Object.entries(nodeOptions)) {\n let formatted: string | null = null;\n if (value === true) {\n formatted = `--${key}`;\n } else if (value) {\n formatted = `--${key}=${\n // Values with spaces need to be quoted. We use JSON.stringify to\n // also escape any nested quotes.\n value.includes(\" \") && !value.startsWith('\"')\n ? JSON.stringify(value)\n : value\n }`;\n }\n\n if (formatted === null) {\n continue;\n }\n\n if (\n [\n \"experimental-network-inspection\",\n \"experimental-storage-inspection\",\n \"experimental-worker-inspection\",\n \"experimental-inspector-network-resource\"\n ].includes(key)\n ) {\n execArgv.push(formatted);\n } else {\n nodeOptionsParts.push(formatted);\n }\n }\n\n const onHanging = () => {\n if (!this.#worker) {\n return;\n }\n\n const resolve = resolveRestartPromise;\n // eslint-disable-next-line ts/no-use-before-define\n createWorker();\n\n logger.warn(\n `Sending SIGTERM signal to worker due to timeout${\n timeout ? ` of ${formatDuration({ seconds: timeout / 1000 })}` : \"\"\n }. Subsequent errors may be a result of the worker exiting.`\n );\n\n void this.finalize().then(() => {\n resolve(RESTARTED);\n });\n };\n\n let hangingTimer: NodeJS.Timeout | false = false;\n\n const onActivity = () => {\n if (hangingTimer) {\n clearTimeout(hangingTimer);\n }\n\n hangingTimer = activeTasks > 0 && setTimeout(onHanging, timeout);\n };\n\n const createWorker = () => {\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n NODE_ENV: mode,\n NODE_OPTIONS: nodeOptionsParts.join(\" \"),\n POWERLINES_EXECUTION_HOST_WORKER: \"true\"\n };\n\n if (env.FORCE_COLOR === undefined) {\n // Mirror the enablement heuristic from picocolors (see https://github.com/vercel/next.js/blob/6a40da0345939fe4f7b1ae519b296a86dd103432/packages/next/src/lib/picocolors.ts#L21-L24).\n // Picocolors snapshots `process.env`/`stdout.isTTY` at module load time, so when the worker\n // process bootstraps with piped stdio its own check would disable colors. Re-evaluating the\n // same conditions here lets us opt the worker into color output only when the parent would\n // have seen colors, while still respecting explicit opt-outs like NO_COLOR.\n const supportsColors =\n !env.NO_COLOR &&\n !env.CI &&\n env.TERM !== \"dumb\" &&\n (process.stdout.isTTY || process.stderr?.isTTY);\n\n if (supportsColors) {\n env.FORCE_COLOR = \"1\";\n }\n }\n\n this.#worker = new Piscina({\n filename: executionHostPath,\n execArgv,\n env\n });\n\n restartPromise = new Promise(resolve => {\n resolveRestartPromise = resolve;\n });\n\n this.#worker.on(\"exit\", (code, signal) => {\n logger.debug(\n `Worker process exited with code ${code} and signal ${signal}`\n );\n\n if ((code || (signal && signal !== \"SIGINT\")) && this.#worker) {\n const error = new Error(\n `Execution Host Worker exited unexpectedly with code ${\n code\n } and signal ${signal}`\n );\n logger.error(error);\n\n void this.finalize().then(() => {\n throw error;\n });\n }\n });\n\n this.#worker.on(\"error\", error => {\n logger.error({\n meta: { category: \"communication\" },\n message: `Worker process emitted an error: ${error.message}`,\n error\n });\n });\n\n // if a child process emits a particular message, we track that as activity\n // so the parent process can keep track of progress\n this.#worker.on(\"message\", data => {\n onActivity();\n\n if (Array.isArray(data) && data.length > 1 && isNumber(data[0])) {\n if (data[0] === 0) {\n logger.trace(\n `Received message from worker: ${JSON.stringify(data.slice(1), null, 2)}`\n );\n } else {\n logger.debug(\n `Received error message from worker: ${JSON.stringify(\n data.slice(1),\n null,\n 2\n )}`\n );\n }\n }\n\n logger.trace(\n `Received message from worker: ${JSON.stringify(data, null, 2)}`\n );\n });\n };\n\n createWorker();\n\n for (const method of this.exposedMethods) {\n if (method.startsWith(\"_\")) {\n continue;\n }\n\n const callWorker = async (\n options: EngineExecutionOptions,\n inlineConfig: InlineConfig\n ) => {\n if (!this.#worker) {\n throw new Error(\"Execution Host Worker is not initialized\");\n }\n\n const { port1, port2 } = new MessageChannel();\n const promise = this.#worker.run(\n { options, inlineConfig, port: port2 },\n {\n name: method,\n transferList: [port2] as StructuredSerializeOptions\n }\n );\n\n let aborted = false;\n const onActivityAbort = () => {\n if (!aborted) {\n aborted = true;\n }\n };\n const duplex = new MessagePortDuplex(port1, { onActivityAbort });\n\n pipeline(\n duplex,\n process.stdout,\n (err: NodeJS.ErrnoException | null) => {\n if (err) {\n logger.debug(\n `Received exception message from worker: ${JSON.stringify(\n err,\n null,\n 2\n )}`\n );\n\n throw err;\n }\n }\n );\n\n await promise;\n };\n\n (this as any)[method] = timeout\n ? async (\n options: EngineExecutionOptions,\n inlineConfig: InlineConfig\n ) => {\n activeTasks++;\n try {\n let attempts = 0;\n for (;;) {\n onActivity();\n\n const result = await Promise.race([\n callWorker(options, inlineConfig),\n restartPromise\n ]);\n if (result !== RESTARTED) {\n return result;\n }\n\n logger.warn(\n `Execution Host Worker was restarted while calling method \"${\n method\n }\" (attempt ${attempts++}). Retrying the call...`\n );\n }\n } finally {\n activeTasks--;\n onActivity();\n }\n }\n : callWorker.bind(this);\n }\n }\n\n /**\n * Closes the worker process, terminating it if it's still running. This method should be called when the worker is no longer needed, to free up system resources and ensure a clean shutdown. If the worker has already been terminated, this method will have no effect.\n */\n public async finalize(): Promise<void> {\n const worker = this.#worker;\n if (!worker) {\n return;\n }\n\n await worker.close({\n force: true\n });\n this.#worker = undefined;\n }\n}\n","/* -------------------------------------------------------------------\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 { ExecutionHostWorker } from \"./_internal/execution-host-worker\";\nimport { PowerlinesEngineContext } from \"./context/engine-context\";\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.finalize();\n\n this.context.debug(\"✔ Finalization completed successfully\");\n timer();\n }\n\n /**\n * Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.\n */\n public async [Symbol.asyncDispose]() {\n return this.finalize();\n }\n\n /**\n * Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.\n *\n * @remarks\n * This method will load the executions for the specified command and inline configuration, then execute each one while managing their lifecycle, including handling their completion and any errors that may occur during execution.\n *\n * @param 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](execution.options, inlineConfig);\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 apiPath = \"@powerlines/engine/api\",\n apiMethods?: TExecutionAPI\n) {\n EventEmitter.setMaxListeners(Infinity);\n\n const context = await createContext(options);\n const host = await ExecutionHostWorker.from<TExecutionAPI>(apiPath, {\n root: options.root,\n context,\n apiMethods\n });\n\n return new PowerlinesEngine<TExecutionAPI>(context, host);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAM,YAAY,OAAO,6BAA6B;;;;AAatD,MAAM,sBAAsB,EAAE,MAAM,WAAiC;CACnE,OAAO,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG;AACvC;;;;;;;;AAWA,MAAM,yBACJ,YACiB;CACjB,IAAI,CAAC,WAAW,CAAC,SAAS,OAAO,GAC/B,OAAO;EAAE,MAAM;EAAW,MAAM;CAAK;CAIvC,IAAI,QAAQ,SAAS,GAAG,GAAG;EACzB,MAAM,CAAC,MAAM,QAAQ,QAAQ,MAAM,GAAG;EACtC,IAAI,CAAC,QAAQ,CAAC,MACZ,MAAM,IAAI,MAAM,0BAA0B,SAAS;EAGrD,OAAO;GAAE;GAAM,MAAM,OAAO,SAAS,MAAM,EAAE;EAAE;CACjD;CAEA,OAAO;EAAE,MAAM;EAAW,MAAM,OAAO,SAAS,SAAS,EAAE;CAAE;AAC/D;;;;AAOA,SAAS,iBAAiB,aAA2C;CACnE,IAAI,YAAY,SACd,OAAO;CAET,IAAI,YAAY,kBAAkB,YAAY,aAC5C,OAAO;AAIX;AAgDA,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CAO3C,OAAO,IAAI,iBAAgC,SAAS,MANjC,oBAAoB,KAAoB,SAAS;EAClE,MAAM,QAAQ;EACd;EACA;CACF,CAAC,CAEuD;AAC1D"}
@@ -0,0 +1,6 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_engine = require('./engine-Dz6BvkFY.cjs');
3
+
4
+ exports.PowerlinesEngine = require_engine.PowerlinesEngine;
5
+ exports.createContext = require_engine.createContext;
6
+ exports.createEngine = require_engine.createEngine;
@@ -0,0 +1,143 @@
1
+ import { n as EngineOptions } from "./config-DKEmqMrh.cjs";
2
+ import { t as EngineContext } from "./context-D0_a0kRO.cjs";
3
+ import { n as ExecutionHost, t as Engine } from "./api-DcHfCjQK.cjs";
4
+ import { t as PowerlinesEngineContext } from "./engine-context-B8K6Jtkk.cjs";
5
+ import { BuildInlineConfig, CleanInlineConfig, CreateInlineConfig, DeployInlineConfig, DocsInlineConfig, InlineConfig, LintInlineConfig, PrepareInlineConfig, TestInlineConfig, TypesInlineConfig } from "@powerlines/core";
6
+ import { EXECUTION_API_METHODS } from "@powerlines/core/constants";
7
+
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, apiPath?: string, apiMethods?: TExecutionAPI): Promise<PowerlinesEngine<TExecutionAPI>>;
141
+ //#endregion
142
+ export {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YAAA,EAAc,YAAA,GAAY,OAAA;AAAA;AAAA,iBA+BR,aAAA,CAAc,OAAA,EAAS,aAAA,GAAa,OAAA,CAAA,uBAAA;AAAA,iBAuBpC,YAAA,uBAAmC,aAAA,SAAA,CACvD,OAAA,EAAS,aAAA,EACT,OAAA,WACA,UAAA,GAAa,aAAA,GAAa,OAAA,CAAA,gBAAA,CAAA,aAAA"}
@@ -0,0 +1,143 @@
1
+ import { n as EngineOptions } from "./config-ByLyzMI0.mjs";
2
+ import { t as EngineContext } from "./context-DcXV6_GL.mjs";
3
+ import { n as ExecutionHost, t as Engine } from "./api-BgyEi2hF.mjs";
4
+ import { t as PowerlinesEngineContext } from "./engine-context-DKlA5Pgu.mjs";
5
+ import { BuildInlineConfig, CleanInlineConfig, CreateInlineConfig, DeployInlineConfig, DocsInlineConfig, InlineConfig, LintInlineConfig, PrepareInlineConfig, TestInlineConfig, TypesInlineConfig } from "@powerlines/core";
6
+ import { EXECUTION_API_METHODS } from "@powerlines/core/constants";
7
+
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, apiPath?: string, apiMethods?: TExecutionAPI): Promise<PowerlinesEngine<TExecutionAPI>>;
141
+ //#endregion
142
+ export { PowerlinesEngine, createContext, createEngine };
143
+ //# sourceMappingURL=engine.d.mts.map
@@ -0,0 +1 @@
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AS,aAAA,GAAa,OAAA,CAAA,uBAAA;AAAA,iBAuBpC,YAAA,uBAAmC,aAAA,SAAA,CACvD,OAAA,EAAS,aAAA,EACT,OAAA,WACA,UAAA,GAAa,aAAA,GAAa,OAAA,CAAA,gBAAA,CAAA,aAAA"}
@@ -0,0 +1,3 @@
1
+ import { n as createContext, r as createEngine, t as PowerlinesEngine } from "./engine-q6YKXXcB.mjs";
2
+
3
+ export { PowerlinesEngine, createContext, createEngine };
@@ -0,0 +1,57 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_helpers_rpc = require('./rpc.cjs');
3
+ const require_helpers_stream = require('./stream.cjs');
4
+ let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
5
+ let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
6
+ let _powerlines_core_context_execution_context = require("@powerlines/core/context/execution-context");
7
+ let _powerlines_core_lib_context_helpers = require("@powerlines/core/lib/context-helpers");
8
+ let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
9
+ let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
10
+ let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
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, port } = params;
24
+ const duplex = new require_helpers_stream.MessagePortDuplex(port);
25
+ duplex.setEncoding("utf8");
26
+ duplex.on("data", (chunk) => duplex.write(chunk.toUpperCase()));
27
+ duplex.on("end", () => {
28
+ duplex.end();
29
+ });
30
+ let rpc;
31
+ if (options.baseURL && options.connection) rpc = require_helpers_rpc.createRpcClient(options);
32
+ else throw new Error(`Execution RPC client could not be created - Missing ${!options.baseURL ? `baseURL${options.connection ? ` and connection information` : ""}` : "connection"} or connection information.`);
33
+ const logFn = (meta, message) => {
34
+ (0, _powerlines_core_plugin_utils.consoleLogger)(meta, message);
35
+ if (rpc) rpc.callEvent("powerlines:log", {
36
+ meta: {
37
+ category: "general",
38
+ ...options,
39
+ ...(0, _stryke_type_checks_is_set_object.isSetObject)(meta) ? meta : { type: meta },
40
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
41
+ timestamp: Date.now()
42
+ },
43
+ message
44
+ });
45
+ };
46
+ const context = await _powerlines_core_context_execution_context.PowerlinesExecutionContext.from({
47
+ ...options,
48
+ logFn
49
+ }, (0, _stryke_type_checks_is_function.isFunction)(inlineConfig) ? await Promise.resolve(inlineConfig(params.inlineConfig ?? {})) : (0, defu.defu)(inlineConfig, params.inlineConfig ?? {}), { rpc });
50
+ 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})`);
51
+ await (0, _powerlines_core_lib_context_helpers.resolvePluginConfig)(context);
52
+ await fn(context);
53
+ }]));
54
+ }
55
+
56
+ //#endregion
57
+ exports.createExecutionHost = createExecutionHost;
@@ -0,0 +1,20 @@
1
+ import { r as EngineResolvedConfig } from "../config-DKEmqMrh.cjs";
2
+ import { r as EngineSystemContext } from "../context-D0_a0kRO.cjs";
3
+ import { r as ExecutionHostParams } from "../api-DcHfCjQK.cjs";
4
+ import { ExecutionContext, InlineConfig } from "@powerlines/core";
5
+ import { DeepPartial, MaybePromise } from "@stryke/types/base";
6
+
7
+ //#region src/helpers/create-execution-host.d.ts
8
+ /**
9
+ * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
10
+ *
11
+ * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
12
+ * @param inlineConfig - An optional partial inline configuration object that will be merged with the context's options when creating the execution context for each method.
13
+ * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
14
+ */
15
+ declare function createExecutionHost<TContext extends ExecutionContext<EngineResolvedConfig, EngineSystemContext> = ExecutionContext<EngineResolvedConfig, EngineSystemContext>>(methods: Record<string, (context: TContext) => Promise<void>>, inlineConfig?: DeepPartial<InlineConfig> | ((prev: InlineConfig) => MaybePromise<InlineConfig>)): {
16
+ [k: string]: (params: ExecutionHostParams) => Promise<void>;
17
+ };
18
+ //#endregion
19
+ export { createExecutionHost };
20
+ //# sourceMappingURL=create-execution-host.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-execution-host.d.cts","names":[],"sources":["../../src/helpers/create-execution-host.ts"],"mappings":";;;;;;;;;AA8CA;;;;;iBAAgB,mBAAA,kBACG,gBAAA,CAAiB,oBAAA,EAAsB,mBAAA,IACtD,gBAAA,CAAiB,oBAAA,EAAsB,mBAAA,EAAA,CAEzC,OAAA,EAAS,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA,SAC/C,YAAA,GACI,WAAA,CAAY,YAAA,MACV,IAAA,EAAM,YAAA,KAAiB,YAAA,CAAa,YAAA;EAAA,sBAKvB,mBAAA,KAAmB,OAAA;AAAA"}
@@ -0,0 +1,20 @@
1
+ import { r as EngineResolvedConfig } from "../config-ByLyzMI0.mjs";
2
+ import { r as EngineSystemContext } from "../context-DcXV6_GL.mjs";
3
+ import { r as ExecutionHostParams } from "../api-BgyEi2hF.mjs";
4
+ import { ExecutionContext, InlineConfig } from "@powerlines/core";
5
+ import { DeepPartial, MaybePromise } from "@stryke/types/base";
6
+
7
+ //#region src/helpers/create-execution-host.d.ts
8
+ /**
9
+ * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
10
+ *
11
+ * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
12
+ * @param inlineConfig - An optional partial inline configuration object that will be merged with the context's options when creating the execution context for each method.
13
+ * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
14
+ */
15
+ declare function createExecutionHost<TContext extends ExecutionContext<EngineResolvedConfig, EngineSystemContext> = ExecutionContext<EngineResolvedConfig, EngineSystemContext>>(methods: Record<string, (context: TContext) => Promise<void>>, inlineConfig?: DeepPartial<InlineConfig> | ((prev: InlineConfig) => MaybePromise<InlineConfig>)): {
16
+ [k: string]: (params: ExecutionHostParams) => Promise<void>;
17
+ };
18
+ //#endregion
19
+ export { createExecutionHost };
20
+ //# sourceMappingURL=create-execution-host.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-execution-host.d.mts","names":[],"sources":["../../src/helpers/create-execution-host.ts"],"mappings":";;;;;;;;;AA8CA;;;;;iBAAgB,mBAAA,kBACG,gBAAA,CAAiB,oBAAA,EAAsB,mBAAA,IACtD,gBAAA,CAAiB,oBAAA,EAAsB,mBAAA,EAAA,CAEzC,OAAA,EAAS,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA,SAC/C,YAAA,GACI,WAAA,CAAY,YAAA,MACV,IAAA,EAAM,YAAA,KAAiB,YAAA,CAAa,YAAA;EAAA,sBAKvB,mBAAA,KAAmB,OAAA;AAAA"}
@@ -0,0 +1,57 @@
1
+ import { createRpcClient } from "./rpc.mjs";
2
+ import { MessagePortDuplex } from "./stream.mjs";
3
+ import { consoleLogger } from "@powerlines/core/plugin-utils";
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 { uuid } from "@stryke/unique-id/uuid";
10
+ import { defu } from "defu";
11
+
12
+ //#region src/helpers/create-execution-host.ts
13
+ /**
14
+ * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
15
+ *
16
+ * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.
17
+ * @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.
18
+ * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
19
+ */
20
+ function createExecutionHost(methods, inlineConfig = {}) {
21
+ return Object.fromEntries(Object.entries(methods).map(([method, fn]) => [method, async (params) => {
22
+ const { options, port } = params;
23
+ const duplex = new MessagePortDuplex(port);
24
+ duplex.setEncoding("utf8");
25
+ duplex.on("data", (chunk) => duplex.write(chunk.toUpperCase()));
26
+ duplex.on("end", () => {
27
+ duplex.end();
28
+ });
29
+ let rpc;
30
+ if (options.baseURL && options.connection) rpc = createRpcClient(options);
31
+ else throw new Error(`Execution RPC client could not be created - Missing ${!options.baseURL ? `baseURL${options.connection ? ` and connection information` : ""}` : "connection"} or connection information.`);
32
+ const logFn = (meta, message) => {
33
+ consoleLogger(meta, message);
34
+ if (rpc) rpc.callEvent("powerlines:log", {
35
+ meta: {
36
+ category: "general",
37
+ ...options,
38
+ ...isSetObject(meta) ? meta : { type: meta },
39
+ logId: uuid(),
40
+ timestamp: Date.now()
41
+ },
42
+ message
43
+ });
44
+ };
45
+ const context = await PowerlinesExecutionContext.from({
46
+ ...options,
47
+ logFn
48
+ }, isFunction(inlineConfig) ? await Promise.resolve(inlineConfig(params.inlineConfig ?? {})) : defu(inlineConfig, params.inlineConfig ?? {}), { rpc });
49
+ context.logger.info(`Starting ${titleCase(options.framework?.name) || "Powerlines"} - ${titleCase(method)} execution (${options.executionId})`);
50
+ await resolvePluginConfig(context);
51
+ await fn(context);
52
+ }]));
53
+ }
54
+
55
+ //#endregion
56
+ export { createExecutionHost };
57
+ //# 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 type {\n ExecutionContext,\n InlineConfig,\n LogFnMeta\n} 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 type { DeepPartial, MaybePromise } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { defu } from \"defu\";\nimport type { RpcClient } from \"../types\";\nimport type { ExecutionHostParams } from \"../types/api\";\nimport type { EngineResolvedConfig } from \"../types/config\";\nimport type { EngineSystemContext } from \"../types/context\";\nimport { createRpcClient } from \"./rpc\";\nimport { MessagePortDuplex } from \"./stream\";\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 ExecutionContext<EngineResolvedConfig, EngineSystemContext> =\n ExecutionContext<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, port } = params;\n\n const duplex = new MessagePortDuplex(port);\n duplex.setEncoding(\"utf8\");\n duplex.on(\"data\", (chunk: string) => duplex.write(chunk.toUpperCase()));\n duplex.on(\"end\", () => {\n duplex.end();\n });\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<EngineResolvedConfig, EngineSystemContext>(\n context\n );\n await fn(context);\n }\n ])\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,oBAId,SACA,eAE2D,CAAC,GAC5D;CACA,OAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAC5C,QACA,OAAO,WAAgC;EACrC,MAAM,EAAE,SAAS,SAAS;EAE1B,MAAM,SAAS,IAAI,kBAAkB,IAAI;EACzC,OAAO,YAAY,MAAM;EACzB,OAAO,GAAG,SAAS,UAAkB,OAAO,MAAM,MAAM,YAAY,CAAC,CAAC;EACtE,OAAO,GAAG,aAAa;GACrB,OAAO,IAAI;EACb,CAAC;EAED,IAAI;EACJ,IAAI,QAAQ,WAAW,QAAQ,YAC7B,MAAM,gBAAgB,OAAO;OAE7B,MAAM,IAAI,MACR,uDACE,CAAC,QAAQ,UACL,UAAU,QAAQ,aAAa,gCAAgC,OAC/D,aACL,4BACH;EAGF,MAAM,SAAS,MAAiB,YAAoB;GAClD,cAAc,MAAM,OAAO;GAC3B,IAAI,KACF,AAAK,IAAI,UAAU,kBAAkB;IACnC,MAAM;KACJ,UAAU;KACV,GAAG;KACH,GAAI,YAAY,IAAI,IAAI,OAAO,EAAE,MAAM,KAAK;KAC5C,OAAO,KAAK;KACZ,WAAW,KAAK,IAAI;IACtB;IACA;GACF,CAAC;EAEL;EAEA,MAAM,UAAW,MAAM,2BAA2B,KAIhD;GAAE,GAAG;GAAS;EAAM,GACpB,WAAW,YAAY,IACnB,MAAM,QAAQ,QAAQ,aAAa,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAC5D,KAAK,cAAc,OAAO,gBAAgB,CAAC,CAAC,GACjD,EACE,IACF,CACF;EAEA,QAAQ,OAAO,KACb,YACE,UAAU,QAAQ,WAAW,IAAI,KAAK,aACvC,KAAK,UAAU,MAAM,EAAE,cAAc,QAAQ,YAAY,EAC5D;EAEA,MAAM,oBACJ,OACF;EACA,MAAM,GAAG,OAAO;CAClB,CACF,CAAC,CACH;AACF"}
@@ -0,0 +1,26 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _powerlines_core_lib_environment = require("@powerlines/core/lib/environment");
3
+ let node_fs = require("node:fs");
4
+ let _stryke_fs_helpers = require("@stryke/fs/helpers");
5
+ let _stryke_path_join = require("@stryke/path/join");
6
+ let _stryke_fs_list_files = require("@stryke/fs/list-files");
7
+ let _powerlines_core_lib_hooks = require("@powerlines/core/lib/hooks");
8
+
9
+ //#region src/helpers/finalize.ts
10
+ /**
11
+ * Finalize the execution context by disposing resources and cleaning up.
12
+ *
13
+ * @param context - The execution context to finalize
14
+ */
15
+ async function finalize(context) {
16
+ const timer = context.timer("Finalization");
17
+ await (0, _powerlines_core_lib_environment.executeEnvironments)(context, async (env) => {
18
+ await (0, _powerlines_core_lib_hooks.callHook)(context, "finalize", { environment: env });
19
+ await env.fs.dispose();
20
+ if ((0, node_fs.existsSync)(env.cachePath) && !(await (0, _stryke_fs_list_files.listFiles)((0, _stryke_path_join.joinPaths)(env.cachePath, "**/*")))?.length) await (0, _stryke_fs_helpers.removeDirectory)(env.cachePath);
21
+ });
22
+ timer();
23
+ }
24
+
25
+ //#endregion
26
+ exports.finalize = finalize;