@powerlines/engine 0.47.3 → 0.49.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 (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
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.mjs","names":["resolve","joinPaths","#isDisposed","joinPaths","#context","#normalizePath","#storage","#normalizeId","#getStorage","capnp","#logger","#metadata","#ids","#paths","#resolverCache","#getStorages","Blob","#innerResolve","#innerResolveSync","#isDisposed","#timestamp","createLogger","existsSync","isFile","relativePath","findFilePath","joinPaths","readJsonFile","#tsconfig","#fs","#checksum","#buildId","#releaseId","#configProxy","joinPaths","#parserCache","#requestCache","existsSync","defu","#internal","#hooks","#internal","#environments","#plugins","joinPaths","#context","#context"],"sources":["../../src/_internal/helpers/environment.ts","../../src/_internal/helpers/context.ts","../../src/_internal/helpers/meta.ts","../../src/_internal/ipc/send.ts","../../schemas/fs.ts","../../src/storage/base.ts","../../src/storage/helpers.ts","../../src/storage/file-system.ts","../../src/storage/virtual.ts","../../src/_internal/helpers/constants.ts","../../src/_internal/vfs.ts","../../src/typescript/tsconfig.ts","../../src/_internal/helpers/resolver.ts","../../src/context/base-context.ts","../../src/context/context.ts","../../src/_internal/helpers/hooks.ts","../../src/context/plugin-context.ts","../../src/context/environment-context.ts","../../src/context/execution-context.ts","../../src/typescript/ts-morph.ts","../../src/_internal/helpers/generate-types.ts","../../src/_internal/helpers/install.ts","../../src/_internal/helpers/install-dependencies.ts","../../src/_internal/helpers/resolve-tsconfig.ts","../../src/_internal/execution.ts","../../src/_internal/worker.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 EnvironmentResolvedConfig,\n ResolvedConfig\n} from \"@powerlines/core\";\nimport { DEFAULT_ENVIRONMENT } from \"@powerlines/core/constants\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport defu from \"defu\";\n\nexport function createEnvironment<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>(name: string, config: TResolvedConfig) {\n return defu(config.environments?.[name] ?? {}, {\n id: uuid(),\n name,\n title: config.title ?? titleCase(config.name),\n ssr: false,\n resolve: {\n mainFields:\n config.platform === \"browser\"\n ? [\"browser\", \"module\", \"jsnext:main\", \"jsnext\"]\n : [\"module\", \"jsnext:main\", \"jsnext\"]\n },\n consumer: config.platform === \"browser\" ? \"client\" : \"server\",\n preview:\n config.platform === \"browser\"\n ? {\n port: 5173,\n open: true,\n strictPort: false,\n // https: false,\n host: \"localhost\",\n allowedHosts: [\".\"],\n cors: true,\n headers: {}\n }\n : undefined\n }) as unknown as EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"];\n}\n\nexport function createDefaultEnvironment<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>(config: TResolvedConfig) {\n return createEnvironment<TResolvedConfig>(DEFAULT_ENVIRONMENT, config);\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 { InferOverridableConfig, ResolvedConfig } from \"@powerlines/core\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\n\nexport function getConfigProps<TResolvedConfig extends ResolvedConfig>(\n config:\n | TResolvedConfig[\"initialConfig\"]\n | TResolvedConfig[\"userConfig\"]\n | TResolvedConfig[\"inlineConfig\"]\n | TResolvedConfig[\"pluginConfig\"]\n | InferOverridableConfig<TResolvedConfig> = {}\n) {\n return {\n name: config.name,\n title: config.title,\n description: config.description,\n projectType: config.projectType,\n customLogger: config.customLogger,\n logLevel: config.logLevel,\n tsconfig: config.tsconfig,\n tsconfigRaw: config.tsconfigRaw,\n skipCache: config.skipCache,\n autoInstall: config.autoInstall,\n input: isSetString(config.input) ? [config.input] : config.input,\n plugins: config.plugins,\n mode: config.mode,\n resolve: config.resolve,\n framework: config.framework,\n ...config\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 { Context, MetaInfo } from \"@powerlines/core\";\nimport { ROOT_HASH_LENGTH } from \"@powerlines/core/constants\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFile } from \"@stryke/fs/json\";\nimport { removeFile } from \"@stryke/fs/remove-file\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\n\nexport interface CreateContextOptions {\n name?: string;\n}\n\n/**\n * Generates a prefixed project root hash object.\n *\n * @remarks\n * This function returns a string where the project root hash is prefixed with the project name plus a hyphen. If the total length of this string combination exceeds 45 characters, it will truncate the hash.\n *\n * @param name - The name of the project.\n * @param rootHash - The hash of the project root.\n * @returns An object containing the name and project root hash.\n */\nexport function getPrefixedRootHash(name: string, rootHash: string): string {\n const combined = `${kebabCase(name)}_${rootHash}`;\n\n return combined.length > ROOT_HASH_LENGTH\n ? combined.slice(0, ROOT_HASH_LENGTH)\n : combined;\n}\n\n/**\n * Retrieves the persisted meta information from the context's data path.\n *\n * @param context - The build context.\n * @returns A promise that resolves to the persisted meta information, or undefined if not found.\n */\nexport async function getPersistedMeta(\n context: Context\n): Promise<MetaInfo | undefined> {\n const metaFilePath = joinPaths(context.dataPath, \"meta.json\");\n if (existsSync(metaFilePath)) {\n try {\n return await readJsonFile<MetaInfo>(metaFilePath);\n } catch {\n context.warn(\n `Failed to read meta file at ${metaFilePath}. It may be corrupted.`\n );\n await removeFile(metaFilePath);\n\n context.persistedMeta = undefined;\n }\n }\n\n return undefined;\n}\n\n/**\n * Writes the meta file for the context.\n *\n * @param context - The context to write the meta file for.\n * @returns A promise that resolves when the meta file has been written.\n */\nexport async function writeMetaFile(context: Context): Promise<void> {\n const metaFilePath = joinPaths(context.dataPath, \"meta.json\");\n\n context.debug(`Writing runtime metadata to ${metaFilePath}`);\n\n await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));\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 { Context, LogFnMeta } from \"@powerlines/core\";\nimport { LogCategories } from \"@powerlines/core/constants\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { messageParent } from \"jest-worker\";\nimport { IpcMessage, IpcMessageType } from \"./messages\";\n\nfunction formatWriteLogMessage<TContext extends Context = Context>(\n context: TContext,\n meta: LogFnMeta,\n message: string\n) {\n const combinedMeta = {\n ...context.logger.options,\n ...(isSetObject(meta) ? meta : { type: meta })\n };\n\n return {\n id: uuid(),\n type: IpcMessageType.WRITE_LOG,\n executionId: combinedMeta.executionId || context.options.executionId,\n executionIndex:\n combinedMeta.executionIndex ?? context.options.executionIndex,\n environment: combinedMeta.environment,\n timestamp: Date.now(),\n payload: {\n meta: {\n type: combinedMeta.type,\n category: combinedMeta.category || LogCategories.GENERAL,\n logId: combinedMeta.logId || uuid(),\n timestamp: combinedMeta.timestamp ?? Date.now(),\n name: combinedMeta.name || context.config.name,\n executionId: combinedMeta.executionId || context.options.executionId,\n executionIndex:\n combinedMeta.executionIndex ?? context.options.executionIndex,\n command: combinedMeta.command || context.config.command,\n hook: combinedMeta.hook,\n environment: combinedMeta.environment,\n plugin: combinedMeta.plugin,\n source: combinedMeta.source\n },\n message\n }\n };\n}\n\nfunction childProcessSend(message: IpcMessage) {\n process.send?.(message);\n}\n\nfunction workerThreadSend(message: IpcMessage) {\n messageParent(message);\n}\n\nfunction send(message: IpcMessage) {\n if (process.env.POWERLINES_EXECUTION_THREAD_TYPE === \"child-process\") {\n childProcessSend(message);\n } else if (process.env.POWERLINES_EXECUTION_THREAD_TYPE === \"worker-thread\") {\n workerThreadSend(message);\n } else {\n // eslint-disable-next-line no-console\n console.warn(\"No IPC mechanism available to send message:\", message);\n }\n}\n\nexport function sendWriteLogMessage<TContext extends Context = Context>(\n context: TContext,\n meta: LogFnMeta,\n message: string\n) {\n send(formatWriteLogMessage(context, meta, message));\n}\n","/* eslint-disable */\n// biome-ignore lint: disable\n// Generated by storm-capnpc\n// Note: Do not edit this file manually - it will be overwritten automatically\nimport * as $ from \"@stryke/capnp\";\nexport const _capnpFileId = BigInt(\"0xa56c61324b9d6e49\");\nexport class FileMetadata_KeyValuePair extends $.Struct {\n public static override readonly _capnp = {\n displayName: \"KeyValuePair\",\n id: \"eabb26cf58b2a14c\",\n size: new $.ObjectSize(0, 2),\n };\n get key(): string {\n return $.utils.getText(0, this);\n }\n set key(value: string) {\n $.utils.setText(0, value, this);\n }\n get value(): string {\n return $.utils.getText(1, this);\n }\n set value(value: string) {\n $.utils.setText(1, value, this);\n }\n public override toString(): string { return \"FileMetadata_KeyValuePair_\" + super.toString(); }\n}\n/**\n* The identifier for the file data.\n*\n*/\nexport class FileMetadata extends $.Struct {\n static readonly KeyValuePair = FileMetadata_KeyValuePair;\n public static override readonly _capnp = {\n displayName: \"FileMetadata\",\n id: \"8e2cab5d7e28c7b3\",\n size: new $.ObjectSize(8, 3),\n defaultType: \"normal\"\n };\n static _Properties: $.ListCtor<FileMetadata_KeyValuePair>;\n /**\n* The type of the file.\n*\n*/\n get id(): string {\n return $.utils.getText(0, this);\n }\n set id(value: string) {\n $.utils.setText(0, value, this);\n }\n /**\n* The timestamp representing the file's creation date.\n*\n*/\n get type(): string {\n return $.utils.getText(1, this, FileMetadata._capnp.defaultType);\n }\n set type(value: string) {\n $.utils.setText(1, value, this);\n }\n /**\n* Additional metadata associated with the file.\n*\n*/\n get timestamp(): number {\n return $.utils.getUint32(0, this);\n }\n set timestamp(value: number) {\n $.utils.setUint32(0, value, this);\n }\n _adoptProperties(value: $.Orphan<$.List<FileMetadata_KeyValuePair>>): void {\n $.utils.adopt(value, $.utils.getPointer(2, this));\n }\n _disownProperties(): $.Orphan<$.List<FileMetadata_KeyValuePair>> {\n return $.utils.disown(this.properties);\n }\n get properties(): $.List<FileMetadata_KeyValuePair> {\n return $.utils.getList(2, FileMetadata._Properties, this);\n }\n _hasProperties(): boolean {\n return !$.utils.isNull($.utils.getPointer(2, this));\n }\n _initProperties(length: number): $.List<FileMetadata_KeyValuePair> {\n return $.utils.initList(2, FileMetadata._Properties, length, this);\n }\n set properties(value: $.List<FileMetadata_KeyValuePair>) {\n $.utils.copyFrom(value, $.utils.getPointer(2, this));\n }\n public override toString(): string { return \"FileMetadata_\" + super.toString(); }\n}\n/**\n* An identifier for the file.\n*\n*/\nexport class FileId extends $.Struct {\n public static override readonly _capnp = {\n displayName: \"FileId\",\n id: \"990d6a471072f997\",\n size: new $.ObjectSize(0, 2),\n };\n /**\n* A virtual (or actual) path to the file in the file system.\n*\n*/\n get id(): string {\n return $.utils.getText(0, this);\n }\n set id(value: string) {\n $.utils.setText(0, value, this);\n }\n get path(): string {\n return $.utils.getText(1, this);\n }\n set path(value: string) {\n $.utils.setText(1, value, this);\n }\n public override toString(): string { return \"FileId_\" + super.toString(); }\n}\n/**\n* An identifier for the file.\n*\n*/\nexport class FileStorage extends $.Struct {\n public static override readonly _capnp = {\n displayName: \"FileStorage\",\n id: \"9dca66ac858c9ebe\",\n size: new $.ObjectSize(0, 2),\n };\n /**\n* A virtual (or actual) path to the file in the file system.\n*\n*/\n get path(): string {\n return $.utils.getText(0, this);\n }\n set path(value: string) {\n $.utils.setText(0, value, this);\n }\n get code(): string {\n return $.utils.getText(1, this);\n }\n set code(value: string) {\n $.utils.setText(1, value, this);\n }\n public override toString(): string { return \"FileStorage_\" + super.toString(); }\n}\nexport class FileSystem extends $.Struct {\n public static override readonly _capnp = {\n displayName: \"FileSystem\",\n id: \"ae0c23d43e56abcf\",\n size: new $.ObjectSize(0, 3),\n };\n static _Ids: $.ListCtor<FileId>;\n static _Storage: $.ListCtor<FileStorage>;\n static _Metadata: $.ListCtor<FileMetadata>;\n _adoptIds(value: $.Orphan<$.List<FileId>>): void {\n $.utils.adopt(value, $.utils.getPointer(0, this));\n }\n _disownIds(): $.Orphan<$.List<FileId>> {\n return $.utils.disown(this.ids);\n }\n get ids(): $.List<FileId> {\n return $.utils.getList(0, FileSystem._Ids, this);\n }\n _hasIds(): boolean {\n return !$.utils.isNull($.utils.getPointer(0, this));\n }\n _initIds(length: number): $.List<FileId> {\n return $.utils.initList(0, FileSystem._Ids, length, this);\n }\n set ids(value: $.List<FileId>) {\n $.utils.copyFrom(value, $.utils.getPointer(0, this));\n }\n _adoptStorage(value: $.Orphan<$.List<FileStorage>>): void {\n $.utils.adopt(value, $.utils.getPointer(1, this));\n }\n _disownStorage(): $.Orphan<$.List<FileStorage>> {\n return $.utils.disown(this.storage);\n }\n get storage(): $.List<FileStorage> {\n return $.utils.getList(1, FileSystem._Storage, this);\n }\n _hasStorage(): boolean {\n return !$.utils.isNull($.utils.getPointer(1, this));\n }\n _initStorage(length: number): $.List<FileStorage> {\n return $.utils.initList(1, FileSystem._Storage, length, this);\n }\n set storage(value: $.List<FileStorage>) {\n $.utils.copyFrom(value, $.utils.getPointer(1, this));\n }\n _adoptMetadata(value: $.Orphan<$.List<FileMetadata>>): void {\n $.utils.adopt(value, $.utils.getPointer(2, this));\n }\n _disownMetadata(): $.Orphan<$.List<FileMetadata>> {\n return $.utils.disown(this.metadata);\n }\n get metadata(): $.List<FileMetadata> {\n return $.utils.getList(2, FileSystem._Metadata, this);\n }\n _hasMetadata(): boolean {\n return !$.utils.isNull($.utils.getPointer(2, this));\n }\n _initMetadata(length: number): $.List<FileMetadata> {\n return $.utils.initList(2, FileSystem._Metadata, length, this);\n }\n set metadata(value: $.List<FileMetadata>) {\n $.utils.copyFrom(value, $.utils.getPointer(2, this));\n }\n public override toString(): string { return \"FileSystem_\" + super.toString(); }\n}\nFileMetadata._Properties = $.CompositeList(FileMetadata_KeyValuePair);\nFileSystem._Ids = $.CompositeList(FileId);\nFileSystem._Storage = $.CompositeList(FileStorage);\nFileSystem._Metadata = $.CompositeList(FileMetadata);\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 { Context, StorageAdapter, StoragePreset } from \"@powerlines/core\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { correctPath } from \"@stryke/path/correct-path\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { MaybePromise } from \"@stryke/types/base\";\nimport { resolve } from \"node:path\";\n\nexport interface StorageAdapterOptions {\n base: string;\n isReadOnly?: boolean;\n ignore?: string | string[];\n}\n\n/**\n * Abstract base class for storage adapters, providing a template for storage operations.\n */\nexport abstract class BaseStorageAdapter<\n TOptions extends StorageAdapterOptions = StorageAdapterOptions\n> implements StorageAdapter {\n /**\n * Indicates whether the storage adapter has been disposed.\n */\n #isDisposed = false;\n\n /**\n * A name identifying the storage adapter type.\n */\n public abstract name: string;\n\n /**\n * Configuration options for the storage adapter.\n */\n public options: TOptions;\n\n /**\n * The storage preset for the adapter.\n *\n * @remarks\n * This can be used as an alternate way to identify the type of storage being used.\n */\n public readonly preset?: StoragePreset | null = null;\n\n /**\n * Constructor for the BaseStorageAdapter.\n *\n * @param context - The Powerlines context.\n * @param options - Configuration options for the storage adapter.\n */\n public constructor(\n protected context: Context,\n options: TOptions = { base: \"/\" } as TOptions\n ) {\n this.options = options;\n this.options.base = resolve(options.base);\n this.options.isReadOnly = !!options.isReadOnly;\n }\n\n /**\n * Synchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns Returns `true` if the key exists, otherwise `false`.\n */\n public abstract existsSync(key: string): boolean;\n\n /**\n * Asynchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns A promise that resolves to `true` if the key exists, otherwise `false`.\n */\n public async exists(key: string): Promise<boolean> {\n return this.existsSync(key);\n }\n\n /**\n * Synchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns The value associated with the key, or `null` if the key does not exist.\n */\n public abstract getSync(key: string): string | null;\n\n /**\n * Asynchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.\n */\n public async get(key: string): Promise<string | null> {\n return this.getSync(key);\n }\n\n /**\n * Synchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public abstract setSync(key: string, value: string): void;\n\n /**\n * Asynchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public async set(key: string, value: string): Promise<void> {\n if (!this.isReadOnly && (!this.existsSync(key) || this.overwrite)) {\n this.setSync(key, value);\n }\n }\n\n /**\n * Synchronously creates a directory at the specified path.\n *\n * @param _ - The path of the directory to create.\n */\n public mkdirSync(_: string) {}\n\n /**\n * Creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public async mkdir(dirPath: string): Promise<void> {\n return Promise.resolve(this.mkdirSync(dirPath));\n }\n\n /**\n * Synchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public abstract removeSync(key: string): void;\n\n /**\n * Asynchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public async remove(key: string): Promise<void> {\n if (!this.isReadOnly && this.overwrite) {\n this.removeSync(key);\n }\n }\n\n /**\n * Synchronously removes all entries from the storage that match the provided base path.\n *\n * @param base - The base path to clear keys from.\n */\n public clearSync(base?: string) {\n if (!this.isReadOnly && this.overwrite) {\n const keys = this.listSync(base || this.options.base);\n if (!keys.length) {\n return;\n }\n\n keys.map(key =>\n this.removeSync(\n base && !key.startsWith(base) ? joinPaths(base, key) : key\n )\n );\n }\n }\n\n /**\n * Asynchronously removes all entries from the storage that match the provided base path.\n *\n * @param base - The base path to clear keys from.\n * @returns A promise that resolves when the operation is complete.\n */\n public async clear(base?: string): Promise<void> {\n if (!this.isReadOnly && this.overwrite) {\n const keys = await this.list(base || this.options.base);\n if (!keys.length) {\n return;\n }\n\n await Promise.all(\n keys.map(async key =>\n this.remove(\n base && !key.startsWith(base) ? joinPaths(base, key) : key\n )\n )\n );\n }\n }\n\n /**\n * Lists all keys under a given base path synchronously.\n *\n * @param base - The base path to list keys from.\n * @returns An array of keys under the specified base path.\n */\n public abstract listSync(base?: string): string[];\n\n /**\n * Asynchronously lists all keys under a given base path.\n *\n * @param base - The base path to list keys from.\n * @returns A promise that resolves to an array of keys under the specified base path.\n */\n public async list(base?: string): Promise<string[]> {\n return this.listSync(base);\n }\n\n /**\n * Synchronously checks if the given key is a directory.\n *\n * @param _ - The key to check.\n * @returns `true` if the key is a directory, otherwise `false`.\n */\n public isDirectorySync(_: string): boolean {\n return false;\n }\n\n /**\n * Checks if the given key is a directory.\n *\n * @param key - The key to check.\n * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.\n */\n public async isDirectory(key: string) {\n return Promise.resolve(this.isDirectorySync(key));\n }\n\n /**\n * Synchronously checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a file, otherwise `false`.\n */\n public isFileSync(key: string): boolean {\n return this.existsSync(key) && !this.isDirectorySync(key);\n }\n\n /**\n * Checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.\n */\n public async isFile(key: string) {\n return Promise.resolve(this.isFileSync(key));\n }\n\n /**\n * Disposes of the storage adapter, releasing any held resources.\n *\n * @returns A promise that resolves when the disposal is complete.\n */\n public dispose(): MaybePromise<void> {\n return Promise.resolve();\n }\n\n /**\n * Async dispose method to clean up resources.\n *\n * @returns A promise that resolves when disposal is complete.\n */\n public async [Symbol.asyncDispose]() {\n return this._dispose();\n }\n\n /**\n * Determines if the storage adapter is read-only based on the provided options.\n *\n * @returns `true` if the storage adapter is read-only, otherwise `false`.\n */\n protected get isReadOnly() {\n return !!this.options.isReadOnly;\n }\n\n /**\n * Determines if the storage adapter should overwrite existing keys based on the provided options and context configuration.\n *\n * @returns `true` if the storage adapter should overwrite existing keys, otherwise `false`.\n */\n protected get overwrite() {\n return !this.isReadOnly && this.context.config.output.overwrite !== false;\n }\n\n /**\n * Resolves a given key to its full path within the storage adapter.\n *\n * @param key - The key to resolve.\n * @returns The resolved full path for the key.\n */\n protected resolve(key?: string) {\n if (!key) {\n return this.options.base;\n }\n\n if (/\\.\\.:|\\.\\.$/.test(key)) {\n throw new Error(\n `[${this.name}]: Invalid key: ${JSON.stringify(key)} provided to storage adapter.`\n );\n }\n\n return appendPath(correctPath(key).replace(/:/g, \"/\"), this.options.base);\n }\n\n /**\n * Disposes of the storage adapter, releasing any held resources.\n *\n * @returns A promise that resolves when the disposal is complete.\n */\n protected async _dispose(): Promise<void> {\n if (!this.#isDisposed) {\n await Promise.resolve(this.dispose());\n this.#isDisposed = true;\n }\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 { isError } from \"@stryke/type-checks/is-error\";\n\n/**\n * Checks if an error is a file system error.\n *\n * @param err - The error to check.\n * @returns `true` if the error is a file system error, otherwise `false`.\n */\nexport function isFileError(err: any) {\n return isError(err) && \"code\" in err && err.code;\n}\n\n/**\n * Ignores file not found errors.\n *\n * @param err - The error to check.\n * @returns `null` if the error is a file not found error, otherwise returns the error.\n */\nexport function ignoreNotfound(err: any) {\n return (\n isFileError(err) &&\n (err.code === \"ENOENT\" || err.code === \"EISDIR\" ? null : err)\n );\n}\n\n/**\n * Ignores file exists errors.\n *\n * @param err - The error to check.\n * @returns `null` if the error is a file exists error, otherwise returns the error.\n */\nexport function ignoreExists(err: any) {\n return isFileError(err) && err.code === \"EEXIST\" ? null : err;\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 { Context } from \"@powerlines/core\";\nimport { getFileHeaderWarningText } from \"@powerlines/core/lib/utilities/file-header\";\nimport { exists, existsSync } from \"@stryke/fs/exists\";\nimport { createDirectory, createDirectorySync } from \"@stryke/fs/helpers\";\nimport { isDirectory, isFile } from \"@stryke/fs/is-file\";\nimport { listFiles, listFilesSync } from \"@stryke/fs/list-files\";\nimport { readFile, readFileSync } from \"@stryke/fs/read-file\";\nimport { writeFile, writeFileSync } from \"@stryke/fs/write-file\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { unlinkSync } from \"node:fs\";\nimport { unlink } from \"node:fs/promises\";\nimport { BaseStorageAdapter, StorageAdapterOptions } from \"./base\";\nimport { ignoreNotfound } from \"./helpers\";\n\nexport type SetSyncOptions = Parameters<typeof writeFileSync>[2];\nexport type SetOptions = Parameters<typeof writeFile>[2];\n\n/**\n * File system storage adapter implementation.\n */\nexport class FileSystemStorageAdapter extends BaseStorageAdapter {\n /**\n * A name identifying the storage adapter type.\n */\n public name = \"file-system\";\n\n /**\n * The storage preset for the adapter.\n *\n * @remarks\n * This can be used as an alternate way to identify the type of storage being used.\n */\n public override readonly preset = \"fs\";\n\n /**\n * Constructor for the FileSystemStorageAdapter.\n *\n * @param context - The Powerlines context.\n * @param options - Configuration options for the storage adapter.\n */\n public constructor(context: Context, options?: StorageAdapterOptions) {\n super(context, options);\n }\n\n /**\n * Synchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns Returns `true` if the key exists, otherwise `false`.\n */\n public existsSync(key: string): boolean {\n return existsSync(this.resolve(key));\n }\n\n /**\n * Asynchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns A promise that resolves to `true` if the key exists, otherwise `false`.\n */\n public override async exists(key: string): Promise<boolean> {\n return exists(this.resolve(key));\n }\n\n /**\n * Synchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns The value associated with the key, or `null` if the key does not exist.\n */\n public getSync(key: string): string | null {\n return readFileSync(this.resolve(key));\n }\n\n /**\n * Asynchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.\n */\n public override async get(key: string): Promise<string | null> {\n return readFile(this.resolve(key));\n }\n\n /**\n * Synchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public setSync(key: string, value: string) {\n if (!this.isReadOnly) {\n if (this.existsSync(this.resolve(key)) && !this.overwrite) {\n const existingValue = this.getSync(this.resolve(key));\n if (\n isSetString(existingValue) &&\n existingValue.includes(\n getFileHeaderWarningText(true, this.context.config.framework)\n )\n ) {\n return writeFileSync(\n this.resolve(key),\n existingValue.replace(\n getFileHeaderWarningText(true, this.context.config.framework),\n getFileHeaderWarningText(false, this.context.config.framework)\n )\n );\n }\n } else {\n return writeFileSync(this.resolve(key), value);\n }\n }\n }\n\n /**\n * Asynchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public override async set(key: string, value: string): Promise<void> {\n if (!this.isReadOnly) {\n if (this.existsSync(this.resolve(key)) && !this.overwrite) {\n const existingValue = await this.get(this.resolve(key));\n if (\n isSetString(existingValue) &&\n existingValue.includes(\n getFileHeaderWarningText(true, this.context.config.framework)\n )\n ) {\n return writeFile(\n this.resolve(key),\n existingValue.replace(\n getFileHeaderWarningText(true, this.context.config.framework),\n getFileHeaderWarningText(false, this.context.config.framework)\n )\n );\n }\n } else {\n return writeFile(this.resolve(key), value);\n }\n }\n }\n\n /**\n * Synchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public removeSync(key: string) {\n if (!this.isReadOnly && this.overwrite) {\n try {\n return unlinkSync(this.resolve(key));\n } catch (err) {\n return ignoreNotfound(err);\n }\n }\n }\n\n /**\n * Asynchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public override async remove(key: string): Promise<void> {\n if (!this.isReadOnly && this.overwrite) {\n return unlink(this.resolve(key)).catch(ignoreNotfound);\n }\n }\n\n /**\n * Synchronously creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public override mkdirSync(dirPath: string) {\n createDirectorySync(this.resolve(dirPath));\n }\n\n /**\n * Creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public override async mkdir(dirPath: string): Promise<void> {\n await createDirectory(this.resolve(dirPath));\n }\n\n /**\n * Lists all keys under a given base path synchronously.\n *\n * @param base - The base path to list keys from.\n * @returns An array of keys under the specified base path.\n */\n public listSync(base?: string): string[] {\n try {\n return listFilesSync(this.resolve(base), {\n ignore: this.options.ignore\n });\n } catch (err) {\n return ignoreNotfound(err) ?? [];\n }\n }\n\n /**\n * Asynchronously lists all keys under a given base path.\n *\n * @param base - The base path to list keys from.\n * @returns A promise that resolves to an array of keys under the specified base path.\n */\n public override async list(base?: string): Promise<string[]> {\n return listFiles(this.resolve(base), {\n ignore: this.options.ignore\n })\n .catch(ignoreNotfound)\n .then(r => r || []);\n }\n\n /**\n * Synchronously checks if the given key is a directory.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a directory, otherwise `false`.\n */\n public override isDirectorySync(key: string): boolean {\n return isDirectory(this.resolve(key));\n }\n\n /**\n * Synchronously checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a file, otherwise `false`.\n */\n public override isFileSync(key: string): boolean {\n return isFile(this.resolve(key));\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 { Context } from \"@powerlines/core\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { BaseStorageAdapter, StorageAdapterOptions } from \"./base\";\n\n/**\n * Virtual/in-memory storage adapter implementation.\n */\nexport class VirtualStorageAdapter extends BaseStorageAdapter {\n /**\n * A name identifying the storage adapter type.\n */\n public name = \"virtual\";\n\n /**\n * The storage preset for the adapter.\n *\n * @remarks\n * This can be used as an alternate way to identify the type of storage being used.\n */\n public override readonly preset = \"virtual\";\n\n /**\n * In-memory data storage.\n */\n protected data = new Map<string, any>();\n\n /**\n * Constructor for the VirtualStorageAdapter.\n *\n * @param context - The Powerlines context.\n * @param options - Configuration options for the storage adapter.\n */\n public constructor(context: Context, options?: StorageAdapterOptions) {\n super(context, options);\n }\n\n /**\n * Synchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns Returns `true` if the key exists, otherwise `false`.\n */\n public existsSync(key: string): boolean {\n return this.data.has(this.resolve(key));\n }\n\n /**\n * Synchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns The value associated with the key, or `null` if the key does not exist.\n */\n public getSync(key: string): string | null {\n return this.data.get(this.resolve(key)) ?? null;\n }\n\n /**\n * Synchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public setSync(key: string, value: string) {\n if (!this.isReadOnly && (!this.existsSync(key) || this.overwrite)) {\n this.data.set(this.resolve(key), value);\n }\n }\n\n /**\n * Synchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public removeSync(key: string) {\n if (!this.isReadOnly && this.overwrite) {\n this.data.delete(this.resolve(key));\n }\n }\n\n /**\n * Lists all keys under a given base path synchronously.\n *\n * @param base - The base path to list keys from.\n * @returns An array of keys under the specified base path.\n */\n public listSync(base?: string): string[] {\n return [\n ...this.data\n .keys()\n .filter(key => (!base ? true : isParentPath(key, this.resolve(base))))\n ];\n }\n\n /**\n * Disposes of the storage adapter, releasing any held resources.\n *\n * @returns A promise that resolves when the disposal is complete.\n */\n public override async dispose(): Promise<void> {\n return this.clear();\n }\n\n /**\n * Determines if the storage adapter should overwrite existing keys based on the provided options and context configuration.\n *\n * @returns `true` if the storage adapter should overwrite existing keys, otherwise `false`.\n */\n protected override get overwrite() {\n return !this.isReadOnly;\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\nexport const DEFAULT_EXTENSIONS = [\n \"js\",\n \"ts\",\n \"cjs\",\n \"cts\",\n \"mjs\",\n \"mts\",\n \"tsx\",\n \"jsx\",\n \"json\",\n \"json5\",\n \"jsonc\",\n \"md\",\n \"mdx\"\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 Context,\n Logger,\n ResolveOptions,\n StorageAdapter,\n StoragePort,\n StoragePreset,\n VirtualFileMetadata,\n VirtualFileSystemInterface,\n WriteOptions\n} from \"@powerlines/core\";\nimport { format } from \"@powerlines/core/lib/utilities/format\";\nimport { replacePathTokens } from \"@powerlines/core/plugin-utils\";\nimport * as capnp from \"@stryke/capnp\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport {\n readFileBuffer,\n readFileBufferSync,\n writeFileBuffer\n} from \"@stryke/fs/buffer\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport {\n getResolutionCombinations,\n resolve,\n resolveSync\n} from \"@stryke/fs/resolve\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { correctPath, stripStars } from \"@stryke/path/correct-path\";\nimport {\n findFileExtensionSafe,\n findFileName,\n findFilePath,\n hasFileExtension\n} from \"@stryke/path/file-path-fns\";\nimport { globToRegex } from \"@stryke/path/glob-to-regex\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { slash } from \"@stryke/path/slash\";\nimport { prettyBytes } from \"@stryke/string-format/pretty-bytes\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\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 { AssetGlob } from \"@stryke/types/file\";\nimport { match } from \"bundle-require\";\nimport { create, FlatCache } from \"flat-cache\";\nimport { Blob } from \"node:buffer\";\nimport { PathOrFileDescriptor } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { FileId, FileMetadata, FileSystem } from \"../../schemas/fs\";\nimport { FileSystemStorageAdapter } from \"../storage/file-system\";\nimport { VirtualStorageAdapter } from \"../storage/virtual\";\nimport { DEFAULT_EXTENSIONS } from \"./helpers/constants\";\n\ninterface StorageAdapterState {\n adapter: StorageAdapter;\n relativeKey: string;\n base: string;\n}\n\nfunction toFilePath(path: PathOrFileDescriptor): string {\n return correctPath(slash(path?.toString() || \".\").replace(/^file:\\/\\//, \"\"));\n}\n\n/**\n * Checks if a given file id is valid based on the specified prefix.\n *\n * @param id - The file ID to check.\n * @param prefix - The prefix to use for built-in files. Default is \"powerlines\".\n * @returns `true` if the file ID is valid, otherwise `false`.\n */\nfunction isValidId(id: string, prefix = \"powerlines\"): boolean {\n return id.replace(/^\\\\0/, \"\").startsWith(`${prefix.replace(/:$/, \"\")}`);\n}\n\n/**\n * Formats a file id by removing the file extension and prepended runtime prefix.\n *\n * @param id - The file ID to format.\n * @param prefix - The prefix to use for built-in files. Default is \"powerlines\".\n * @returns The formatted file ID.\n */\nfunction normalizeId(id: string, prefix = \"powerlines\"): string {\n // return `${prefix.replace(/:$/, \"\")}:${toFilePath(id)\n // .replace(new RegExp(`^${prefix.replace(/:$/, \"\")}:`), \"\")\n // .replace(/^\\\\0/, \"\")\n // .replace(findFileDotExtensionSafe(toFilePath(id)), \"\")}`;\n\n return replaceExtension(toFilePath(id))\n .replace(/^\\\\0/, \"\")\n .replace(/^powerlines:/, \"\")\n .replace(new RegExp(`^${prefix.replace(/:$/, \"\")}:`), \"\");\n}\n\n/**\n * Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.\n *\n * @param path - The path to normalize.\n * @param builtinsPath - The path to built-in files.\n * @param prefix - The prefix to use for built-in files. Default is \"powerlines\".\n * @returns The normalized path.\n */\nfunction normalizePath(\n path: string,\n builtinsPath: string,\n prefix = \"powerlines\"\n): string {\n if (!isSetString(path)) {\n if (!isString(path)) {\n throw new Error(\"Path type must be a string or a file descriptor\");\n }\n throw new Error(\"Path cannot be empty\");\n }\n\n return isAbsolutePath(path)\n ? path\n : isValidId(toFilePath(path), prefix)\n ? normalizeId(toFilePath(path), prefix).replace(\n new RegExp(`^${prefix.replace(/:$/, \"\")}:`),\n builtinsPath\n )\n : toFilePath(path);\n}\n\n/**\n * Normalizes glob patterns by resolving them against the workspace root.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param patterns - The glob patterns to normalize.\n * @returns An array of normalized glob patterns.\n */\nfunction normalizeGlobPatterns(\n workspaceRoot: string,\n patterns:\n | string\n | Omit<AssetGlob, \"output\">\n | (string | Omit<AssetGlob, \"output\">)[]\n): string[] {\n return getUnique(\n toArray(patterns)\n .map(pattern => {\n if (\n isSetObject(pattern) &&\n (isSetString(pattern.input) || isSetString(pattern.glob))\n ) {\n return joinPaths(\n pattern.input || workspaceRoot,\n pattern.glob || \"**/*\"\n );\n } else if (!isSetString(pattern)) {\n return undefined;\n }\n\n return pattern;\n })\n .filter(isSetString)\n );\n}\n\n/**\n * Represents a virtual file system (VFS) that stores files and their associated metadata in virtual memory.\n *\n * @remarks\n * This class provides methods to manage virtual files, check their existence, retrieve their content, and manipulate the virtual file system. It allows for efficient file management and retrieval without relying on the actual file system.\n */\nexport class VirtualFileSystem implements VirtualFileSystemInterface {\n /**\n * A map of virtual file IDs to their associated metadata.\n */\n #metadata: Record<string, VirtualFileMetadata>;\n\n /**\n * A map of underlying file paths to their virtual file IDs.\n */\n #ids: Record<string, string>;\n\n /**\n * A map of virtual file IDs to their underlying file paths.\n */\n #paths: Record<string, string>;\n\n /**\n * The unified volume that combines the virtual file system with the real file system.\n *\n * @remarks\n * This volume allows for seamless access to both virtual and real files.\n */\n #storage: StoragePort;\n\n // /**\n // * The resolver factory used during module resolution within the virtual file system.\n // *\n // * @see https://github.com/oxc-project/oxc-resolver\n // */\n // #resolver!: ResolverFactory;\n\n /**\n * A cache for module resolution results.\n */\n #resolverCache!: FlatCache;\n\n /**\n * Indicator specifying if the virtual file system (VFS) is disposed\n */\n #isDisposed = false;\n\n /**\n * The context of the virtual file system.\n */\n #context: Context;\n\n /**\n * The file system's logger client utility.\n */\n #logger: Logger;\n\n /**\n * Normalizes a given module id by resolving it against the built-ins path.\n *\n * @param id - The module id to normalize.\n * @returns The normalized module id.\n */\n #normalizeId(id: string): string {\n let normalized = id;\n if (isParentPath(normalized, this.#context.builtinsPath)) {\n normalized = replacePath(normalized, this.#context.builtinsPath);\n }\n\n return normalizeId(normalized, this.#context.config.framework);\n }\n\n /**\n * Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.\n *\n * @param path - The path to normalize.\n * @returns The normalized path.\n */\n #normalizePath(path: string): string {\n if (!isSetString(path)) {\n if (!isString(path)) {\n throw new Error(\"Path type must be a string or a file descriptor\");\n }\n throw new Error(\"Path cannot be empty\");\n }\n\n return normalizePath(\n path.includes(\"{\") || path.includes(\"}\")\n ? replacePathTokens(this.#context, path)\n : path,\n this.#context.builtinsPath,\n this.#context.config.framework\n );\n }\n\n /**\n * Gets the storage adapter and relative key for a given key.\n *\n * @remarks\n * The `key` can be either a path or a storage adapter name.\n *\n * @param key - The key to get the storage adapter for.\n * @returns The storage adapter and relative key for the given key.\n */\n #getStorage(key: string, preset?: StoragePreset): StorageAdapterState {\n const path = this.resolveSync(this.#normalizePath(key)) || key;\n for (const base of Object.keys(this.#storage)\n .filter(Boolean)\n .sort()\n .reverse()) {\n if (\n (path === base || isParentPath(path, base)) &&\n (!preset ||\n this.#storage[base]?.preset?.toLowerCase() === preset.toLowerCase())\n ) {\n return {\n base,\n relativeKey: replacePath(path, base),\n adapter: this.#storage[base]!\n };\n }\n }\n\n if (\n !preset ||\n this.#storage[\"\"]?.preset?.toLowerCase() === preset.toLowerCase()\n ) {\n return {\n base: \"\",\n relativeKey: path,\n adapter: this.#storage[\"\"]!\n };\n }\n\n this.#storage[path] =\n preset === \"virtual\"\n ? new VirtualStorageAdapter(this.#context, {\n base: path\n })\n : new FileSystemStorageAdapter(this.#context, {\n base: path\n });\n\n return {\n base: path,\n relativeKey: \"\",\n adapter: this.#storage[path]\n };\n }\n\n /**\n * Gets all storage adapters that match a given base key.\n *\n * @param base - The base key to match storage adapters against.\n * @param includeParent - Whether to include parent storage adapters.\n * @returns An array of storage adapters that match the given base key.\n */\n #getStorages(base = \"\", includeParent = false) {\n const baseKey = this.resolveSync(base) || base;\n\n return Object.keys(this.#storage)\n .sort()\n .reverse()\n .filter(\n key =>\n isParentPath(key, baseKey) ||\n (includeParent && isParentPath(baseKey, key)) ||\n (baseKey.includes(\"*\") &&\n (isParentPath(stripStars(baseKey), key) ||\n globToRegex(replaceExtension(baseKey)).test(key)))\n )\n .map(key => ({\n relativeBase:\n baseKey.length > key.length ? baseKey.slice(key.length) : undefined,\n base: key,\n adapter: this.#storage[key]!\n }));\n }\n\n /**\n * A helper function to resolve modules in the virtual file system (VFS).\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolved = await context.resolvePath(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns A promise that resolves to the resolved module path.\n */\n #innerResolve = async (\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): Promise<string | undefined> => {\n let path = id;\n if (path.includes(\"{\") || path.includes(\"}\")) {\n path = replacePathTokens(this.#context, path);\n }\n\n if (options.skipAlias !== true) {\n path = this.resolveAlias(path);\n }\n\n if (\n isAbsolutePath(path) &&\n (!options.isFile || !(await this.isDirectory(path)))\n ) {\n return path;\n }\n\n const resolverCacheKey = murmurhash({\n path: this.#normalizeId(path),\n importer,\n options\n });\n\n let result!: string | undefined;\n if (!this.#context.config.skipCache) {\n result = this.resolverCache.get<string | undefined>(resolverCacheKey);\n if (result) {\n return result;\n }\n }\n\n result = this.paths[this.#normalizeId(path)];\n if (!isSetString(result)) {\n const paths = options.paths ?? [];\n if (importer && !paths.includes(importer)) {\n paths.push(importer);\n }\n\n if (!importer) {\n paths.push(this.#context.config.cwd);\n paths.push(\n appendPath(this.#context.config.root, this.#context.config.cwd)\n );\n paths.push(\n appendPath(\n joinPaths(this.#context.config.root, \"src\"),\n this.#context.config.cwd\n )\n );\n }\n\n paths.push(\n ...(\n Object.keys(this.#context.tsconfig?.options?.paths ?? {})\n .filter(tsconfigPath =>\n path.startsWith(tsconfigPath.replace(/\\*$/, \"\"))\n )\n .map(\n tsconfigPath =>\n this.#context.tsconfig?.options?.paths?.[tsconfigPath]\n )\n .flat()\n .filter(Boolean) as string[]\n ).map(tsconfigPath =>\n appendPath(tsconfigPath, this.#context.config.cwd)\n )\n );\n\n for (const combination of getResolutionCombinations(path, {\n paths: getUnique(paths)\n })) {\n const { relativeKey, adapter } = this.#getStorage(combination);\n if (await adapter.exists(relativeKey)) {\n result = combination;\n break;\n }\n }\n\n if (!isSetString(result)) {\n try {\n result = await resolve(path, { ...options, paths });\n } catch {\n // Do nothing\n }\n\n // if (!result) {\n // let index = 0;\n // do {\n // const resolveResult = await this.resolver.async(\n // (paths.length > index ? paths[index] : undefined) ||\n // this.#context.config.root,\n // path\n // );\n // if (resolveResult.path) {\n // result = resolveResult.path;\n // }\n\n // index++;\n // } while (!result && index < paths.length);\n // }\n }\n }\n\n if (isSetString(result)) {\n if (!this.#context.config.skipCache) {\n this.resolverCache.set(this.#normalizeId(path), result);\n }\n\n return result;\n }\n\n return undefined;\n };\n\n /**\n * A synchronous helper function to resolve modules using the Jiti resolver\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolvedPath = context.resolveSync(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns The resolved module path.\n */\n #innerResolveSync = (\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): string | undefined => {\n let path = id;\n if (path.includes(\"{\") || path.includes(\"}\")) {\n path = replacePathTokens(this.#context, path);\n }\n\n if (options.skipAlias !== true) {\n path = this.resolveAlias(path);\n }\n\n if (\n isAbsolutePath(path) &&\n (!options.isFile || !this.isDirectorySync(path))\n ) {\n return path;\n }\n\n let result!: string | undefined;\n if (!this.#context.config.skipCache) {\n result = this.resolverCache.get<string | undefined>(\n this.#normalizeId(path)\n );\n if (isSetString(result)) {\n return result;\n }\n }\n\n result = this.paths[this.#normalizeId(path)];\n if (!isSetString(result)) {\n const paths = options.paths ?? [];\n if (importer && !paths.includes(importer)) {\n paths.push(importer);\n }\n\n if (!importer) {\n paths.push(this.#context.config.cwd);\n paths.push(\n appendPath(this.#context.config.root, this.#context.config.cwd)\n );\n paths.push(\n appendPath(\n joinPaths(this.#context.config.root, \"src\"),\n this.#context.config.cwd\n )\n );\n }\n\n paths.push(\n ...(\n Object.keys(this.#context.tsconfig?.options?.paths ?? {})\n .filter(tsconfigPath =>\n path.startsWith(tsconfigPath.replace(/\\*$/, \"\"))\n )\n .map(\n tsconfigPath =>\n this.#context.tsconfig?.options?.paths?.[tsconfigPath]\n )\n .flat()\n .filter(Boolean) as string[]\n ).map(tsconfigPath =>\n appendPath(tsconfigPath, this.#context.config.cwd)\n )\n );\n\n for (const combination of getResolutionCombinations(path, { paths })) {\n const { relativeKey, adapter } = this.#getStorage(combination);\n if (adapter.existsSync(relativeKey)) {\n result = combination;\n break;\n }\n }\n\n if (!isSetString(result)) {\n try {\n result = resolveSync(path, { ...options, paths });\n } catch {\n // Do nothing\n }\n\n // if (!result) {\n // let index = 0;\n // do {\n // const resolveResult = this.resolver.sync(\n // (paths.length > index ? paths[index] : undefined) ||\n // this.#context.config.root,\n // path\n // );\n // if (resolveResult.path) {\n // result = resolveResult.path;\n // }\n\n // index++;\n // } while (!result && index < paths.length);\n // }\n }\n }\n\n if (isSetString(result)) {\n if (!this.#context.config.skipCache) {\n this.resolverCache.set(this.#normalizeId(path), result);\n }\n\n return result;\n }\n\n return undefined;\n };\n\n /**\n * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.\n *\n * @param context - The context of the virtual file system, typically containing options and logging functions.\n * @returns A promise that resolves to a new virtual file system instance.\n */\n public static async create(context: Context): Promise<VirtualFileSystem> {\n context.debug(\n \"Starting virtual file system (VFS) initialization processes...\"\n );\n\n let result!: VirtualFileSystem;\n if (\n !context.config.skipCache &&\n existsSync(joinPaths(context.dataPath, \"fs.bin\"))\n ) {\n const buffer = await readFileBuffer(\n joinPaths(context.dataPath, \"fs.bin\")\n );\n\n const message = new capnp.Message(buffer, false);\n const fs = message.getRoot(FileSystem);\n\n result = new VirtualFileSystem(context, fs);\n\n if (fs._hasStorage() && fs.storage.length > 0) {\n await Promise.all(\n fs.storage.values().map(async file => {\n if (file.path && file.code) {\n let id: FileId | undefined;\n if (fs._hasIds()) {\n id = fs.ids.find((fileId: FileId) => fileId.path === file.path);\n }\n\n let metadata: FileMetadata | undefined;\n if (fs._hasMetadata()) {\n metadata = fs.metadata.find(\n (meta: FileMetadata) =>\n meta.id === result.#normalizeId(id?.id ?? file.path)\n );\n }\n\n await result.write(file.path, file.code, {\n meta: {\n id: result.#normalizeId(id?.id ?? metadata?.id ?? file.path),\n type: metadata?.type || \"normal\",\n properties: metadata?._hasProperties()\n ? metadata?.properties.values().reduce(\n (ret, kvp) => {\n ret[kvp.key] = kvp.value;\n return ret;\n },\n {} as Record<string, string>\n )\n : undefined,\n timestamp: metadata?.timestamp\n }\n });\n }\n })\n );\n }\n } else {\n const message = new capnp.Message();\n result = new VirtualFileSystem(context, message.initRoot(FileSystem));\n }\n\n result.#logger.debug(\n \"Successfully completed virtual file system (VFS) initialization.\"\n );\n\n return result;\n }\n\n /**\n * Synchronously creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.\n *\n * @param context - The context of the virtual file system, typically containing options and logging functions.\n * @returns A new virtual file system instance.\n */\n public static createSync(context: Context): VirtualFileSystem {\n context.debug(\n \"Starting virtual file system (VFS) initialization processes...\"\n );\n\n let result!: VirtualFileSystem;\n if (\n !context.config.skipCache &&\n existsSync(joinPaths(context.dataPath, \"fs.bin\"))\n ) {\n const buffer = readFileBufferSync(joinPaths(context.dataPath, \"fs.bin\"));\n\n const message = new capnp.Message(buffer, false);\n const fs = message.getRoot(FileSystem);\n\n result = new VirtualFileSystem(context, fs);\n\n if (fs._hasStorage() && fs.storage.length > 0) {\n fs.storage.values().forEach(file => {\n if (file.path && file.code) {\n let id: FileId | undefined;\n if (fs._hasIds()) {\n id = fs.ids.find((fileId: FileId) => fileId.path === file.path);\n }\n\n let metadata: FileMetadata | undefined;\n if (fs._hasMetadata()) {\n metadata = fs.metadata.find(\n (meta: FileMetadata) =>\n meta.id === result.#normalizeId(id?.id ?? file.path)\n );\n }\n\n result.writeSync(file.path, file.code, {\n meta: {\n id: result.#normalizeId(id?.id ?? metadata?.id ?? file.path),\n type: metadata?.type,\n properties: metadata?._hasProperties()\n ? metadata?.properties.values().reduce(\n (ret, kvp) => {\n ret[kvp.key] = kvp.value;\n return ret;\n },\n {} as Record<string, string>\n )\n : undefined,\n timestamp: metadata?.timestamp\n }\n });\n }\n });\n }\n } else {\n const message = new capnp.Message();\n result = new VirtualFileSystem(context, message.initRoot(FileSystem));\n }\n\n result.#logger.debug(\n \"Successfully completed virtual file system (VFS) initialization.\"\n );\n\n return result;\n }\n\n /**\n * A map of file ids to their metadata.\n */\n public get metadata(): Record<string, VirtualFileMetadata> {\n return new Proxy(this.#metadata, {\n get: (target, prop: string) => {\n return target[this.#normalizeId(prop)];\n },\n set: (target, prop: string, value) => {\n target[this.#normalizeId(prop)] = value;\n return true;\n },\n deleteProperty: (target, prop: string) => {\n delete target[this.#normalizeId(prop)];\n return true;\n },\n has: (target, prop: string) => {\n return this.#normalizeId(prop) in target;\n },\n ownKeys: target => {\n return getUnique(\n Reflect.ownKeys(target).map(key => this.#normalizeId(key as string))\n );\n }\n });\n }\n\n /**\n * A map of file paths to their module ids.\n */\n public get ids(): Record<string, string> {\n return new Proxy(this.#ids, {\n get: (target, prop: string) => {\n return target[this.#normalizePath(prop)];\n },\n set: (target, prop: string, value) => {\n target[this.#normalizePath(prop)] = value;\n return true;\n },\n deleteProperty: (target, prop: string) => {\n delete target[this.#normalizePath(prop)];\n return true;\n },\n has: (target, prop: string) => {\n return this.#normalizePath(prop) in target;\n },\n ownKeys: target => {\n return getUnique(\n Reflect.ownKeys(target).map(key => this.#normalizePath(key as string))\n );\n }\n });\n }\n\n /**\n * A map of module ids to their file paths.\n */\n public get paths(): Record<string, string> {\n return new Proxy(this.#paths, {\n get: (target, prop: string) => {\n return this.#normalizeId(prop) in target\n ? target[this.#normalizeId(prop)]\n : undefined;\n },\n set: (target, prop: string, value) => {\n target[this.#normalizeId(prop)] = value;\n return true;\n },\n deleteProperty: (target, prop: string) => {\n delete target[this.#normalizeId(prop)];\n return true;\n },\n has: (target, prop: string) => {\n return this.#normalizeId(prop) in target;\n },\n ownKeys: target => {\n return getUnique(\n Reflect.ownKeys(target).map(key => this.#normalizeId(key as string))\n );\n }\n });\n }\n\n /**\n * Gets the resolver cache.\n */\n protected get resolverCache(): FlatCache {\n if (!this.#resolverCache) {\n this.#resolverCache = create({\n cacheId: \"module-resolution\",\n cacheDir: this.#context.cachePath,\n ttl: 2.5 * 60 * 1000,\n lruSize: 8000,\n persistInterval: 100\n });\n }\n\n return this.#resolverCache;\n }\n\n // /**\n // * The resolver factory used during module resolution within the virtual file system.\n // *\n // * @remarks\n // * This resolver is configured with the workspace root, project root, TypeScript configuration, alias mappings, and other resolution options specified in the context. It is lazily initialized on first access to optimize performance.\n // *\n // * @see https://github.com/oxc-project/oxc-resolver\n // */\n // protected get resolver(): ResolverFactory {\n // if (!this.#resolver) {\n // this.#resolver = new ResolverFactory({\n // roots: [\n // this.#context.config.cwd,\n // appendPath(\n // this.#context.config.root,\n // this.#context.config.cwd\n // )\n // ],\n // tsconfig: {\n // configFile: this.#context.tsconfig.tsconfigFilePath,\n // references:\n // this.#context.tsconfig.projectReferences &&\n // this.#context.tsconfig.projectReferences.length > 0\n // ? \"auto\"\n // : undefined\n // },\n // alias: Object.fromEntries(\n // Object.entries(this.#context.alias).map(([key, value]) => [\n // key,\n // [value]\n // ])\n // ),\n // extensions: this.#context.config.resolve.extensions,\n // mainFields: this.#context.config.resolve.mainFields,\n // conditionNames: this.#context.config.resolve.conditions,\n // symlinks: this.#context.config.resolve.preserveSymlinks,\n // allowPackageExportsInDirectoryResolve: true\n // });\n // }\n\n // return this.#resolver;\n // }\n\n /**\n * Creates a new instance of the {@link VirtualFileSystem}.\n *\n * @param context - The context of the virtual file system, typically containing options and logging functions.\n * @param fs - A buffer containing the serialized virtual file system data.\n */\n private constructor(context: Context, fs: FileSystem) {\n this.#context = context;\n this.#storage = { \"\": new FileSystemStorageAdapter(context) };\n\n if (isSetObject(this.#context.config.output.storage)) {\n this.#storage = {\n ...this.#storage,\n ...this.#context.config.output.storage\n };\n }\n\n this.#storage.virtual ??= new VirtualStorageAdapter(context, {\n base: \"/_virtual\"\n });\n\n this.#storage[this.#context.config.output.path] ??=\n new FileSystemStorageAdapter(context, {\n base: this.#context.config.output.path\n });\n\n if (\n this.#context.config.output.copy &&\n this.#context.config.output.copy.path\n ) {\n this.#storage[this.#context.config.output.copy.path] ??=\n new FileSystemStorageAdapter(context, {\n base: this.#context.config.output.copy.path\n });\n }\n\n if (this.#context.config.output.storage !== \"fs\") {\n this.#storage[this.#context.artifactsPath] ??= new VirtualStorageAdapter(\n context,\n {\n base: this.#context.artifactsPath\n }\n );\n this.#storage[this.#context.builtinsPath] ??= new VirtualStorageAdapter(\n context,\n {\n base: this.#context.builtinsPath\n }\n );\n this.#storage[this.#context.entryPath] ??= new VirtualStorageAdapter(\n context,\n {\n base: this.#context.entryPath\n }\n );\n }\n\n this.#metadata = {};\n if (fs._hasMetadata()) {\n this.#metadata = fs.metadata.values().reduce(\n (ret, metadata) => {\n ret[metadata.id] = {\n id: metadata.id,\n type: metadata.type,\n timestamp: metadata.timestamp ?? Date.now(),\n properties: metadata._hasProperties()\n ? metadata.properties.values().reduce(\n (ret, item) => {\n ret[item.key] = item.value;\n return ret;\n },\n {} as Record<string, string>\n )\n : {}\n };\n\n return ret;\n },\n {} as Record<string, VirtualFileMetadata>\n );\n }\n\n this.#ids = {};\n this.#paths = {};\n\n if (fs._hasIds()) {\n this.#ids = fs.ids.values().reduce(\n (ret, identifier) => {\n ret[identifier.path] ??= identifier.id;\n\n return ret;\n },\n {} as Record<string, string>\n );\n\n this.#paths = fs.ids.values().reduce(\n (ret, identifier) => {\n ret[identifier.id] ??= identifier.path;\n return ret;\n },\n {} as Record<string, string>\n );\n }\n\n this.#logger = context.extendLogger({ category: \"fs\" });\n }\n\n /**\n * Asynchronously checks if a file exists in the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @returns A promise that resolves to `true` if the file exists, otherwise `false`.\n */\n public async exists(path: string): Promise<boolean> {\n const { relativeKey, adapter } = this.#getStorage(path);\n\n return adapter.exists(relativeKey);\n }\n\n /**\n * Synchronously checks if a file exists in the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @returns `true` if the file exists, otherwise `false`.\n */\n public existsSync(path: string): boolean {\n const { relativeKey, adapter } = this.#getStorage(path);\n\n return adapter.existsSync(relativeKey);\n }\n\n /**\n * Checks if a file is virtual in the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the file is virtual, otherwise `false`.\n */\n public isVirtual(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n const resolved = this.resolveSync(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return (\n this.#getStorage(resolved)?.adapter?.preset === \"virtual\" ||\n resolved.startsWith(`${this.#context.config.framework}:`) ||\n path.startsWith(`${this.#context.config.framework}:`)\n );\n }\n\n /**\n * Checks if a path is a directory in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a directory, otherwise `false`.\n */\n public isDirectorySync(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n const resolved = this.resolveSync(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return !!(\n this.existsSync(resolved) &&\n this.#getStorage(resolved)?.adapter?.isDirectorySync(resolved)\n );\n }\n\n /**\n * Checks if a path is a directory in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a directory, otherwise `false`.\n */\n public async isDirectory(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): Promise<boolean> {\n const resolved = await this.resolve(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return !!(\n (await this.exists(resolved)) &&\n (await this.#getStorage(resolved)?.adapter?.isDirectory(resolved))\n );\n }\n\n /**\n * Checks if a path is a file in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a file, otherwise `false`.\n */\n public isFileSync(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n const resolved = this.resolveSync(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return this.#getStorage(resolved)?.adapter?.isFileSync(resolved) ?? false;\n }\n\n /**\n * Checks if a path is a file in the virtual file system (VFS).\n *\n * @param path - The path to check.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns `true` if the path is a file, otherwise `false`.\n */\n public async isFile(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): Promise<boolean> {\n const resolved = await this.resolve(path, importer, options);\n if (!isSetString(resolved)) {\n if (isSet(resolved)) {\n throw new Error(`Resolved path is not a string: ${String(resolved)}`);\n }\n return false;\n }\n\n return (\n (await this.#getStorage(resolved)?.adapter?.isFile(resolved)) ?? false\n );\n }\n\n /**\n * Checks if a file Id must be resolved by the virtual file system (VFS).\n *\n * @remarks\n * Examples of file Ids that would be considered virtual include:\n * - Ids that start with the framework specific prefix (e.g. `powerlines:`)\n * - Ids that match a configured alias for virtual modules (returned true from {@link VirtualFileSystemInterface.isVirtual})\n *\n * @param path - The path or id of the file.\n * @param importer - An optional path to the importer module, used for resolving the file path.\n * @param options - Additional options for resolving the file path.\n * @returns `true` if the file is virtual, otherwise `false`.\n */\n public isResolvableId(\n path: string,\n importer?: string | undefined,\n options?: ResolveOptions\n ): boolean {\n return (\n path.startsWith(`${this.#context.config.framework}:`) ||\n this.isVirtual(path, importer, options) ||\n this.isAlias(path) ||\n this.isTsconfigPath(path)\n );\n }\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @returns An array of file names in the specified path.\n */\n public listSync(path: string): string[] {\n let resolvedPath = path;\n if (resolvedPath.includes(\"*\")) {\n this.#logger.warn(\n `Invoking \"listSync\" with a glob pattern is not supported. It is likely you meant to use \"globSync\". Path: ${path}`\n );\n resolvedPath = stripStars(resolvedPath);\n }\n\n return getUnique(\n this.#getStorages(resolvedPath, true)\n .map(storage =>\n storage.adapter.listSync(\n storage.relativeBase\n ? storage.base\n ? appendPath(storage.relativeBase, storage.base)\n : storage.relativeBase\n : storage.base\n )\n )\n .flat()\n .filter(Boolean)\n );\n }\n\n /**\n * Lists files in a given path.\n *\n * @param path - The path to list files from.\n * @returns An array of file names in the specified path.\n */\n public async list(path: string): Promise<string[]> {\n let resolvedPath = path;\n if (resolvedPath.includes(\"*\")) {\n this.#logger.warn(\n `Invoking \"list\" with a glob pattern is not supported. It is likely you meant to use \"glob\". Path: ${path}`\n );\n resolvedPath = stripStars(resolvedPath);\n }\n\n return getUnique(\n (\n await Promise.all(\n this.#getStorages(resolvedPath, true).map(async storage =>\n storage.adapter.list(\n storage.relativeBase\n ? storage.base\n ? appendPath(storage.relativeBase, storage.base)\n : storage.relativeBase\n : storage.base\n )\n )\n )\n )\n .flat()\n .filter(Boolean)\n );\n }\n\n /**\n * Removes a file in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n */\n public async remove(path: string): Promise<void> {\n const normalizedPath = this.#normalizePath(path);\n this.#logger.trace(`Removing file: ${normalizedPath}`);\n\n const { relativeKey, adapter } = this.#getStorage(normalizedPath);\n\n if (hasFileExtension(normalizedPath)) {\n await adapter.remove(relativeKey);\n } else {\n await adapter.clear(relativeKey);\n }\n\n const id = this.#ids[normalizedPath];\n if (id && this.#metadata[id]) {\n delete this.#metadata[id];\n delete this.#ids[normalizedPath];\n delete this.#paths[id];\n }\n }\n\n /**\n * Removes a file in the virtual file system (VFS).\n *\n * @param path - The path to create the directory at.\n */\n public removeSync(path: string) {\n const normalizedPath = this.#normalizePath(path);\n this.#logger.trace(`Removing file: ${normalizedPath}`);\n\n const { relativeKey, adapter } = this.#getStorage(normalizedPath);\n\n if (hasFileExtension(normalizedPath)) {\n adapter.removeSync(relativeKey);\n } else {\n adapter.clearSync(relativeKey);\n }\n\n const id = this.#ids[normalizedPath];\n if (id && this.#metadata[id]) {\n delete this.#metadata[id];\n delete this.#ids[normalizedPath];\n delete this.#paths[id];\n }\n }\n\n /**\n * Glob files in the virtual file system (VFS) based on the provided pattern(s).\n *\n * @param patterns - A pattern (or multiple patterns) to use to determine the file paths to return\n * @returns An array of file paths matching the provided pattern(s)\n */\n public async glob(\n patterns:\n | string\n | Omit<AssetGlob, \"output\">\n | (string | Omit<AssetGlob, \"output\">)[]\n ): Promise<string[]> {\n const results: string[] = [];\n for (const pattern of normalizeGlobPatterns(\n this.#context.config.cwd,\n patterns\n )) {\n const normalized = this.#normalizePath(pattern);\n if (!/[*?[\\]{}]/.test(normalized) && !normalized.includes(\"*\")) {\n if (this.isDirectorySync(normalized)) {\n results.push(...(await this.list(normalized)));\n } else {\n const resolved = await this.resolve(normalized);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n } else {\n const absPattern = isAbsolutePath(normalized)\n ? normalized\n : this.#normalizePath(\n appendPath(normalized, this.#context.config.cwd)\n );\n\n await Promise.all(\n (await this.list(stripStars(absPattern))).map(async file => {\n if (globToRegex(absPattern).test(file)) {\n const resolved = await this.resolve(file);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n })\n );\n }\n }\n\n return results;\n }\n\n /**\n * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).\n *\n * @param patterns - A pattern (or multiple patterns) to use to determine the file paths to return\n * @returns An array of file paths matching the provided pattern(s)\n */\n public globSync(\n patterns:\n | string\n | Omit<AssetGlob, \"output\">\n | (string | Omit<AssetGlob, \"output\">)[]\n ): string[] {\n const results: string[] = [];\n for (const pattern of normalizeGlobPatterns(\n this.#context.config.cwd,\n patterns\n )) {\n const normalized = this.#normalizePath(pattern);\n if (!/[*?[\\]{}]/.test(normalized) && !normalized.includes(\"*\")) {\n if (this.isDirectorySync(normalized)) {\n results.push(...this.listSync(normalized));\n } else {\n const resolved = this.resolveSync(normalized);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n } else {\n const absPattern = isAbsolutePath(normalized)\n ? normalized\n : this.#normalizePath(\n appendPath(normalized, this.#context.config.cwd)\n );\n\n const files = this.listSync(stripStars(absPattern));\n for (const file of files) {\n const regex = globToRegex(absPattern);\n if (regex.test(file)) {\n const resolved = this.resolveSync(file);\n if (resolved && !results.includes(resolved)) {\n results.push(resolved);\n }\n }\n }\n }\n }\n\n return results;\n }\n\n /**\n * Copies a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to copy\n * @param destPath - The destination path to copy to\n */\n public async copy(\n srcPath: string | URL | Omit<AssetGlob, \"output\">,\n destPath: string | URL\n ) {\n const src = srcPath instanceof URL ? fileURLToPath(srcPath) : srcPath;\n const dest = destPath instanceof URL ? fileURLToPath(destPath) : destPath;\n\n if (\n (!isSetString(src) && (!isSetObject(src) || !isSetString(src.input))) ||\n !isSetString(dest)\n ) {\n return;\n }\n\n const sourceStr = isString(src)\n ? src\n : src.input\n ? src.input\n : this.#context.config.cwd;\n const source = await this.resolve(sourceStr);\n if (!source) {\n return;\n }\n\n if (\n this.isDirectorySync(source) ||\n (isSetString(src) && src.includes(\"*\")) ||\n (isSetObject(src) && isSetString(src.glob))\n ) {\n await Promise.all(\n (await this.glob(src)).map(async file => {\n return this.copy(\n file,\n appendPath(replacePath(file, sourceStr), dest)\n );\n })\n );\n } else {\n const content = await this.read(source);\n if (content !== undefined) {\n await this.write(this.#normalizePath(dest), content, {\n skipFormat: true\n });\n }\n }\n }\n\n /**\n * Synchronously copies a file from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to copy\n * @param destPath - The destination path to copy to\n */\n public copySync(\n srcPath: string | URL | Omit<AssetGlob, \"output\">,\n destPath: string | URL\n ) {\n const src = srcPath instanceof URL ? fileURLToPath(srcPath) : srcPath;\n const dest = destPath instanceof URL ? fileURLToPath(destPath) : destPath;\n\n if (\n (!isSetString(src) && (!isSetObject(src) || !isSetString(src.input))) ||\n !isSetString(dest)\n ) {\n return;\n }\n\n const sourceStr = isString(src)\n ? src\n : src.input\n ? src.input\n : this.#context.config.cwd;\n const source = this.resolveSync(sourceStr);\n if (!source) {\n return;\n }\n\n if (\n this.isDirectorySync(source) ||\n (isSetString(src) && src.includes(\"*\")) ||\n (isSetObject(src) && isSetString(src.glob))\n ) {\n this.globSync(src).map(file => {\n return this.copySync(\n file,\n appendPath(findFilePath(replacePath(file, sourceStr)), dest)\n );\n });\n } else {\n const content = this.readSync(source);\n if (content !== undefined) {\n this.writeSync(\n this.#normalizePath(\n hasFileExtension(dest)\n ? dest\n : appendPath(findFileName(source), dest)\n ),\n content,\n { skipFormat: true }\n );\n }\n }\n }\n\n /**\n * Moves a file (or files) from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to move\n * @param destPath - The destination path to move to\n */\n public async move(srcPath: string, destPath: string) {\n if (hasFileExtension(srcPath)) {\n await this.copy(srcPath, destPath);\n await this.remove(srcPath);\n } else {\n await Promise.all(\n (await this.list(srcPath)).map(async file => {\n await this.copy(file, destPath);\n await this.remove(file);\n })\n );\n }\n }\n\n /**\n * Synchronously moves a file (or files) from one path to another in the virtual file system (VFS).\n *\n * @param srcPath - The source path to move\n * @param destPath - The destination path to move to\n */\n public moveSync(srcPath: string, destPath: string) {\n if (hasFileExtension(srcPath)) {\n this.copySync(srcPath, destPath);\n this.removeSync(srcPath);\n } else {\n this.listSync(srcPath).forEach(file => {\n this.copySync(file, destPath);\n this.removeSync(file);\n });\n }\n }\n\n /**\n * Asynchronously reads a file from the virtual file system (VFS).\n *\n * @param path - The path or ID of the file to read.\n * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.\n */\n public async read(path: string): Promise<string | undefined> {\n const filePath = await this.resolve(path, undefined, { isFile: true });\n if (!filePath || !this.existsSync(filePath)) {\n return undefined;\n }\n\n const { adapter } = this.#getStorage(filePath);\n this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);\n\n return (await adapter.get(filePath)) ?? undefined;\n }\n\n /**\n * Synchronously reads a file from the virtual file system (VFS).\n *\n * @param path - The path or ID of the file to read.\n * @returns The contents of the file as a string, or undefined if the file does not exist.\n */\n public readSync(path: string): string | undefined {\n const filePath = this.resolveSync(path, undefined, { isFile: true });\n if (!filePath || !this.existsSync(filePath)) {\n return undefined;\n }\n\n const { adapter } = this.#getStorage(filePath);\n this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);\n\n return adapter.getSync(filePath) ?? undefined;\n }\n\n /**\n * Writes a file to the virtual file system (VFS).\n *\n * @param path - The path to the file.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n * @returns A promise that resolves when the file is written.\n */\n public async write(\n path: string,\n data: string = \"\",\n options: WriteOptions = {}\n ): Promise<void> {\n const meta = options.meta ?? {};\n const resolvedPath =\n (await this.resolve(this.#normalizePath(path))) || path;\n\n const { relativeKey, adapter } = this.#getStorage(\n resolvedPath,\n options.storage as StoragePreset\n );\n\n this.#logger.trace(\n `Writing ${resolvedPath} to ${\n adapter.name === \"virtual\"\n ? \"the virtual file system\"\n : adapter.name === \"file-system\"\n ? \"the local file system\"\n : adapter.name\n } (size: ${prettyBytes(new Blob(toArray(data)).size)})`\n );\n\n let code = data;\n try {\n if (!options.skipFormat) {\n code = await format(this.#context, resolvedPath, data);\n }\n } catch (err) {\n // Only warn about formatting errors for certain file types\n if (\n DEFAULT_EXTENSIONS.includes(\n findFileExtensionSafe(resolvedPath, {\n fullExtension: true\n })\n )\n ) {\n this.#logger.warn(\n `Failed to format file ${resolvedPath} before writing: ${(err as Error).message}`\n );\n }\n code = data;\n }\n\n this.#logger.trace(\n `Writing ${resolvedPath} to ${\n adapter.name === \"virtual\"\n ? \"the virtual file system\"\n : adapter.name === \"file-system\"\n ? \"the local file system\"\n : adapter.name\n } (size: ${prettyBytes(new Blob(toArray(code)).size)})`\n );\n\n const id = this.#normalizeId(meta.id || resolvedPath);\n this.metadata[id] = {\n type: \"normal\",\n timestamp: Date.now(),\n ...(this.metadata[id] ?? {}),\n ...meta\n } as VirtualFileMetadata;\n this.paths[id] = resolvedPath;\n this.ids[resolvedPath] = id;\n\n return adapter.set(relativeKey, code);\n }\n\n /**\n * Synchronously writes a file to the virtual file system (VFS).\n *\n * @param path - The file to write.\n * @param data - The contents of the file.\n * @param options - Optional parameters for writing the file.\n */\n public writeSync(\n path: string,\n data: string = \"\",\n options: WriteOptions = {}\n ): void {\n const meta = options.meta ?? {};\n const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;\n\n const { relativeKey, adapter } = this.#getStorage(\n resolvedPath,\n options.storage as StoragePreset\n );\n\n this.#logger.trace(\n `Writing ${resolvedPath} file to ${\n adapter.name === \"virtual\"\n ? \"the virtual file system\"\n : adapter.name === \"file-system\"\n ? \"the local file system\"\n : adapter.name\n } (size: ${prettyBytes(new Blob(toArray(data)).size)})`\n );\n\n const id = this.#normalizeId(meta.id || resolvedPath);\n this.metadata[id] = {\n type: \"normal\",\n timestamp: Date.now(),\n ...(this.metadata[id] ?? {}),\n ...meta\n } as VirtualFileMetadata;\n this.paths[id] = resolvedPath;\n this.ids[resolvedPath] = id;\n\n return adapter.setSync(relativeKey, data);\n }\n\n /**\n * Synchronously creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public mkdirSync(dirPath: string) {\n return this.#getStorage(dirPath)?.adapter?.mkdirSync(dirPath);\n }\n\n /**\n * Creates a directory at the specified path.\n *\n * @param path - The path of the directory to create.\n */\n public async mkdir(path: string): Promise<void> {\n return this.#getStorage(path)?.adapter?.mkdir(path);\n }\n\n /**\n * Retrieves the metadata of a file in the virtual file system (VFS).\n *\n * @param pathOrId - The path or ID of the file to retrieve metadata for.\n * @returns The metadata of the file, or undefined if the file does not exist.\n */\n public getMetadata(pathOrId: string): VirtualFileMetadata | undefined {\n const resolved = this.resolveSync(pathOrId);\n if (resolved && this.metadata[resolved]) {\n return this.metadata[resolved];\n }\n\n return undefined;\n }\n\n /**\n * Resolves a given module ID using the configured aliases.\n *\n * @remarks\n * This function can be used to map module IDs to different paths based on the alias configuration.\n *\n * @param id - The module ID to resolve.\n * @returns The resolved module ID - after applying any configured aliases (this will be the same as the input ID if no aliases match).\n */\n public resolveAlias(id: string): string {\n let path = id;\n\n if (this.#context.config.resolve.alias) {\n if (\n Array.isArray(this.#context.config.resolve.alias) &&\n this.#context.config.resolve.alias.length > 0\n ) {\n const found = this.#context.config.resolve.alias.filter(\n alias =>\n (isSetString(alias.find) &&\n (alias.find === path || path.startsWith(`${alias.find}/`))) ||\n (isRegExp(alias.find) && alias.find.test(path))\n );\n if (found.length > 0) {\n const alias = found.reduce((ret, current) => {\n const retLength = isSetString(ret.find)\n ? ret.find.length\n : isRegExp(ret.find)\n ? ret.find.source.length\n : 0;\n const currentLength = isSetString(current.find)\n ? current.find.length\n : isRegExp(current.find)\n ? current.find.source.length\n : 0;\n\n return retLength > currentLength ? ret : current;\n });\n\n if (isSetString(alias.find)) {\n path = path.replace(\n new RegExp(`^${alias.find}`),\n alias.replacement\n );\n } else if (isRegExp(alias.find)) {\n path = path.replace(alias.find, alias.replacement);\n }\n }\n } else if (isSetObject(this.#context.config.resolve.alias)) {\n const found = Object.keys(\n this.#context.config.resolve.alias as Record<string, string>\n ).filter(key => key === path || path.startsWith(`${key}/`));\n if (found.length > 0) {\n const alias = found.reduce((ret, current) => {\n return ret.length > current.length ? ret : current;\n });\n\n path = path.replace(\n new RegExp(`^${alias}`),\n (this.#context.config.resolve.alias as Record<string, string>)[\n alias\n ]!\n );\n }\n }\n }\n\n return path;\n }\n\n /**\n * Checks if a given module ID is an alias.\n *\n * @remarks\n * This function can be used to determine if a module ID matches any configured aliases.\n *\n * @param id - The module ID to check.\n * @returns A boolean indicating whether the module ID is an alias.\n */\n public isAlias(id: string): boolean {\n const path = id;\n\n if (this.#context.config.resolve.alias) {\n if (\n Array.isArray(this.#context.config.resolve.alias) &&\n this.#context.config.resolve.alias.length > 0\n ) {\n return (\n this.#context.config.resolve.alias.filter(\n alias =>\n (isSetString(alias.find) &&\n (alias.find === path || path.startsWith(`${alias.find}/`))) ||\n (isRegExp(alias.find) && alias.find.test(path))\n ).length > 0\n );\n } else if (isSetObject(this.#context.config.resolve.alias)) {\n return (\n Object.keys(\n this.#context.config.resolve.alias as Record<string, string>\n ).filter(key => key === path || path.startsWith(`${key}/`)).length > 0\n );\n }\n }\n\n return false;\n }\n\n /**\n * Checks if a given module ID is a tsconfig path.\n *\n * @remarks\n * This function can be used to determine if a module ID matches any configured tsconfig paths.\n *\n * @param id - The module ID to check.\n * @returns A boolean indicating whether the module ID is a tsconfig path.\n */\n public isTsconfigPath(id: string): boolean {\n return !!(\n this.#context.tsconfig.options.paths &&\n Object.keys(this.#context.tsconfig.options.paths).length > 0 &&\n match(id, this.#context.resolvePatterns)\n );\n }\n\n /**\n * A helper function to resolve modules in the virtual file system (VFS).\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolved = await context.resolvePath(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns A promise that resolves to the resolved module path.\n */\n public async resolve(\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): Promise<string | undefined> {\n const origResult = await this.#innerResolve(id, importer, options);\n if (origResult && options.isFile && (await this.isDirectory(origResult))) {\n const indexResult = await this.resolve(\n joinPaths(origResult, \"index\"),\n importer,\n options\n );\n if (indexResult) {\n return indexResult;\n }\n\n if (!hasFileExtension(origResult)) {\n for (const ext of DEFAULT_EXTENSIONS) {\n const extResult = await this.resolve(\n `${origResult}.${ext}`,\n importer,\n options\n );\n if (extResult) {\n return extResult;\n }\n }\n }\n\n return undefined;\n }\n\n return origResult;\n }\n\n /**\n * A synchronous helper function to resolve modules using the Jiti resolver\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolvedPath = context.resolveSync(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns The resolved module path.\n */\n public resolveSync(\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): string | undefined {\n const origResult = this.#innerResolveSync(id, importer, options);\n if (origResult && options.isFile && this.isDirectorySync(origResult)) {\n const indexResult = this.resolveSync(\n joinPaths(origResult, \"index\"),\n importer,\n options\n );\n if (indexResult) {\n return indexResult;\n }\n\n if (!hasFileExtension(origResult)) {\n for (const ext of DEFAULT_EXTENSIONS) {\n const extResult = this.resolveSync(\n `${origResult}.${ext}`,\n importer,\n options\n );\n if (extResult) {\n return extResult;\n }\n }\n }\n\n return undefined;\n }\n\n return origResult;\n }\n\n /**\n * Disposes of the virtual file system (VFS) by saving its state to disk.\n */\n public async dispose() {\n if (!this.#isDisposed) {\n this.#isDisposed = true;\n\n this.#logger.debug(\"Disposing virtual file system...\");\n await this.remove(joinPaths(this.#context.dataPath, \"fs.bin\"));\n\n const message = new capnp.Message();\n const fs = message.initRoot(FileSystem);\n\n const storage = fs._initStorage(Object.keys(this.#paths).length);\n await Promise.all(\n Object.values(this.#paths).map(async (path, index) => {\n const code = await this.read(path);\n\n const fd = storage.get(index);\n fd.path = path;\n fd.code = code || \"\";\n })\n );\n\n const ids = fs._initIds(Object.keys(this.#ids).length);\n Object.entries(this.#ids)\n .filter(([, id]) => id)\n .forEach(([path, id], index) => {\n const fileId = ids.get(index);\n fileId.id = id;\n fileId.path = path;\n });\n\n const metadata = fs._initMetadata(Object.keys(this.#metadata).length);\n Object.entries(this.#metadata)\n .filter(([, value]) => value)\n .forEach(([id, value], index) => {\n const fileMetadata = metadata.get(index);\n fileMetadata.id = id;\n fileMetadata.type = value.type;\n fileMetadata.timestamp = value.timestamp ?? Date.now();\n\n if (value.properties) {\n const props = fileMetadata._initProperties(\n Object.keys(value.properties).length\n );\n Object.entries(value.properties)\n .filter(([, val]) => isSetString(val))\n .forEach(([key, val], index) => {\n const prop = props.get(index);\n prop.key = key;\n prop.value = val!;\n });\n }\n });\n\n await writeFileBuffer(\n joinPaths(this.#context.dataPath, \"fs.bin\"),\n message.toArrayBuffer()\n );\n\n if (!this.#context.config.skipCache) {\n this.resolverCache.save(true);\n }\n\n await Promise.all(\n this.#getStorages().map(async storage => storage.adapter.dispose())\n );\n\n this.#logger.trace(\"Virtual file system has been disposed.\");\n }\n }\n\n /**\n * Asynchronously disposes of the virtual file system (VFS) by saving its state to disk.\n *\n * @remarks\n * This method is automatically called when the VFS instance is used within a `using` block, or can be manually invoked to ensure that the VFS state is saved and resources are cleaned up properly.\n */\n public async [Symbol.asyncDispose]() {\n return this.dispose();\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 { ParsedTypeScriptConfig, TSConfig } from \"@powerlines/core\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFileSync } from \"@stryke/fs/json\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { FilterPattern } from \"@stryke/types/file\";\nimport { TsConfigJson } from \"@stryke/types/tsconfig\";\nimport defu from \"defu\";\nimport ts from \"typescript\";\n\n/**\n * Get the path to the tsconfig.json file.\n *\n * @param cwd - The root directory of the workspace.\n * @param root - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @returns The absolute path to the tsconfig.json file.\n * @throws If the tsconfig.json file does not exist.\n */\nexport function getTsconfigFilePath(\n cwd: string,\n root: string,\n tsconfig?: string\n): string {\n let tsconfigFilePath: string | undefined;\n if (tsconfig) {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, tsconfig);\n } else {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, \"tsconfig.app.json\");\n if (!tsconfigFilePath) {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, \"tsconfig.lib.json\");\n if (!tsconfigFilePath) {\n tsconfigFilePath = tryTsconfigFilePath(cwd, root, \"tsconfig.json\");\n }\n }\n }\n\n if (!tsconfigFilePath) {\n throw new Error(\n `Cannot find the \\`tsconfig.json\\` configuration file for the project at ${\n root\n }.`\n );\n }\n\n return tsconfigFilePath;\n}\n\n/**\n * Get the path to the tsconfig.json file.\n *\n * @param cwd - The root directory of the workspace.\n * @param root - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @returns The absolute path to the tsconfig.json file.\n * @throws If the tsconfig.json file does not exist.\n */\nexport function tryTsconfigFilePath(\n cwd: string,\n root: string,\n tsconfig: string\n): string | undefined {\n let tsconfigFilePath = tsconfig;\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = appendPath(tsconfig, root);\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = appendPath(tsconfig, appendPath(root, cwd));\n if (!existsSync(tsconfigFilePath)) {\n return undefined;\n }\n }\n }\n\n return tsconfigFilePath;\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function findMatch(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[],\n extensions: string[] = [\".ts\", \".tsx\", \".d.ts\"]\n): string | RegExp | null | undefined {\n return types.find(\n type =>\n tsconfigType?.toString().toLowerCase() ===\n type?.toString().toLowerCase() ||\n tsconfigType?.toString().toLowerCase() ===\n `./${type?.toString().toLowerCase()}` ||\n `./${tsconfigType?.toString().toLowerCase()}` ===\n type?.toString().toLowerCase() ||\n extensions.some(\n ext =>\n `${tsconfigType?.toString().toLowerCase()}${ext}` ===\n type?.toString().toLowerCase() ||\n `${tsconfigType?.toString().toLowerCase()}${ext}` ===\n `./${type?.toString().toLowerCase()}` ||\n `${type?.toString().toLowerCase()}${ext}` ===\n `./${tsconfigType?.toString().toLowerCase()}` ||\n tsconfigType?.toString().toLowerCase() ===\n `${type?.toString().toLowerCase()}${ext}` ||\n tsconfigType?.toString().toLowerCase() ===\n `./${type?.toString().toLowerCase()}${ext}` ||\n type?.toString().toLowerCase() ===\n `./${tsconfigType?.toString().toLowerCase()}${ext}`\n )\n );\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function findIncludeMatch(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[]\n): string | RegExp | null | undefined {\n return findMatch(tsconfigType, types, [\n \".ts\",\n \".tsx\",\n \".d.ts\",\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".mts\",\n \".cts\",\n \"/*.ts\",\n \"/*.tsx\",\n \"/*.d.ts\",\n \"/*.js\",\n \"/*.jsx\",\n \"/*.mjs\",\n \"/*.cjs\",\n \"/*.mts\",\n \"/*.cts\",\n \"/**/*.ts\",\n \"/**/*.tsx\",\n \"/**/*.d.ts\",\n \"/**/*.js\",\n \"/**/*.jsx\",\n \"/**/*.mjs\",\n \"/**/*.cjs\",\n \"/**/*.mts\",\n \"/**/*.cts\"\n ]);\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function isMatchFound(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[]\n): boolean {\n return findMatch(tsconfigType, types) !== undefined;\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function isIncludeMatchFound(\n tsconfigType: FilterPattern,\n types: FilterPattern[]\n): boolean {\n return (\n findIncludeMatch(\n tsconfigType as string | RegExp | null,\n types as (string | RegExp | null)[]\n ) !== undefined\n );\n}\n\n/**\n * Get the parsed TypeScript configuration.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param projectRoot - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @param tsconfigRaw - The raw tsconfig.json content.\n * @param originalTsconfigJson - The original tsconfig.json content.\n * @param host - The TypeScript parse config host.\n * @returns The resolved TypeScript configuration.\n */\nexport function getParsedTypeScriptConfig(\n workspaceRoot: string,\n projectRoot: string,\n tsconfig?: string,\n tsconfigRaw: TSConfig = {},\n originalTsconfigJson?: TSConfig,\n host: ts.ParseConfigHost = ts.sys\n): ParsedTypeScriptConfig {\n const tsconfigFilePath = getTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n tsconfig\n );\n const tsconfigJson = readJsonFileSync<TSConfig>(tsconfigFilePath);\n if (!tsconfigJson) {\n throw new Error(\n `Cannot find the \\`tsconfig.json\\` configuration file at ${joinPaths(\n projectRoot,\n tsconfig ?? \"tsconfig.json\"\n )}`\n );\n }\n\n const parsedCommandLine = ts.parseJsonConfigFileContent(\n defu(tsconfigRaw ?? {}, tsconfigJson),\n host,\n appendPath(projectRoot, workspaceRoot)\n );\n if (parsedCommandLine.errors.length > 0) {\n const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:\n${parsedCommandLine.errors\n .map(\n error =>\n `- ${\n (error.category !== undefined && error.code\n ? `[${error.category}-${error.code}]: `\n : \"\") + error.messageText.toString()\n }`\n )\n .join(\"\\n\")}\n `;\n\n throw new Error(errorMessage);\n }\n\n return {\n ...parsedCommandLine,\n originalTsconfigJson: (originalTsconfigJson ??\n tsconfigJson) as TsConfigJson,\n tsconfigJson,\n tsconfigFilePath\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 { ResolvedConfig, Resolver } from \"@powerlines/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport { JitiOptions, createJiti } from \"jiti\";\n\nexport type CreateResolverOptions = Omit<\n JitiOptions,\n \"fsCache\" | \"moduleCache\" | \"interopDefault\"\n> &\n Partial<Pick<ResolvedConfig, \"mode\" | \"skipCache\">> & {\n workspaceRoot: string;\n root: string;\n cacheDir: string;\n };\n\n/**\n * Create a Jiti resolver for the given workspace and project root.\n *\n * @param options - The options for creating the resolver.\n * @returns A Jiti instance configured for the specified workspace and project root.\n */\nfunction resolveOptions(options: CreateResolverOptions): JitiOptions {\n return defu(options, {\n interopDefault: true,\n fsCache:\n options.mode !== \"development\"\n ? joinPaths(options.cacheDir, \"jiti\")\n : false,\n moduleCache: options.mode !== \"development\"\n });\n}\n\n/**\n * Create a Jiti resolver for the given workspace and project root.\n *\n * @param options - The options for creating the resolver.\n * @returns A Jiti instance configured for the specified workspace and project root.\n */\nexport function createResolver(options: CreateResolverOptions): Resolver {\n const baseResolver = createJiti(\n joinPaths(options.workspaceRoot, options.root),\n resolveOptions(options)\n ) as Resolver;\n baseResolver.plugin = createJiti(\n joinPaths(options.workspaceRoot, options.root),\n resolveOptions(options)\n );\n\n return baseResolver;\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 BaseContext,\n EngineOptions,\n LogFn,\n Logger,\n LoggerOptions,\n LogLevelResolvedConfig,\n LogMessage,\n Mode,\n ParsedUserConfig,\n Resolver,\n UserConfig,\n WorkspaceConfig\n} from \"@powerlines/core\";\nimport { loadUserConfigFile } from \"@powerlines/core/lib/config\";\nimport { resolveLogLevel } from \"@powerlines/core/plugin-utils\";\nimport {\n createLogger,\n extendLogger\n} from \"@powerlines/core/plugin-utils/logging\";\nimport { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport {\n isDevelopment,\n isProduction,\n isTest\n} from \"@stryke/env/environment-checks\";\nimport { EnvPaths, getEnvPaths } from \"@stryke/env/get-env-paths\";\nimport { isFile, readJsonFile } from \"@stryke/fs\";\nimport { resolvePackage } from \"@stryke/fs/resolve\";\nimport { findFilePath, joinPaths, relativePath } from \"@stryke/path\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { DeepPartial, RequiredKeys } from \"@stryke/types/base\";\nimport { PackageJson } from \"@stryke/types/package-json\";\nimport chalk from \"chalk\";\nimport { formatDistanceToNowStrict } from \"date-fns/formatDistanceToNowStrict\";\nimport defu from \"defu\";\nimport { existsSync } from \"node:fs\";\nimport { createResolver } from \"../_internal/helpers/resolver\";\n\nexport class PowerlinesBaseContext implements BaseContext {\n #timestamp: number = Date.now();\n\n /**\n * The path to the Powerlines package\n */\n public powerlinesPath!: string;\n\n /**\n * The module resolver for the project\n */\n public resolver!: Resolver;\n\n /**\n * The options provided to the Powerlines process, resolved with default values and merged with any configuration provided by plugins or other sources. This is typically the final configuration used during the build process, but may also include additional options that are relevant to the context and its interactions with the Powerlines engine.\n */\n public options!: RequiredKeys<\n EngineOptions,\n \"mode\" | \"cwd\" | \"root\" | \"framework\"\n >;\n\n /**\n * The parsed `package.json` file for the project\n */\n public packageJson!: PackageJson;\n\n /**\n * The parsed `project.json` file for the project\n */\n public projectJson: Record<string, any> | undefined = undefined;\n\n /**\n * The parsed configuration file for the project\n */\n public configFile!: ParsedUserConfig;\n\n /**\n * The logger instance for the context, which can be used to create log messages with consistent formatting and metadata. This logger is extended by plugin contexts to include additional metadata such as the plugin name and category, which can be used to filter and format log messages in a more granular way.\n */\n public get logger(): Logger {\n return this.createLogger({});\n }\n\n /**\n * A timestamp representing when the context was initialized\n */\n public get timestamp(): number {\n return this.#timestamp;\n }\n\n public get logLevel(): LogLevelResolvedConfig {\n return resolveLogLevel(this.options.logLevel, this.options.mode);\n }\n\n /**\n * The environment paths for the project\n */\n public get envPaths(): EnvPaths {\n return getEnvPaths({\n orgId: this.options.organization,\n appId: this.options.framework || \"powerlines\",\n workspaceRoot: this.options.cwd\n });\n }\n\n /**\n * A logging function for fatal messages\n *\n * @param message - The message to log.\n */\n public fatal(message: string | LogMessage) {\n this.logger.error(message);\n }\n\n /**\n * A logging function for error messages\n *\n * @param message - The message to log.\n */\n public error(message: string | LogMessage) {\n this.logger.error(message);\n }\n\n /**\n * A logging function for warning messages\n *\n * @param message - The message to log.\n */\n public warn(message: string | LogMessage) {\n this.logger.warn(message);\n }\n\n /**\n * A logging function for informational messages\n *\n * @param message - The message to log.\n */\n public info(message: string | LogMessage) {\n this.logger.info(message);\n }\n\n /**\n * A logging function for debug messages\n *\n * @param message - The message to log.\n */\n public debug(message: string | LogMessage) {\n this.logger.debug(message);\n }\n\n /**\n * A logging function for trace messages\n *\n * @param message - The message to log.\n */\n public trace(message: string | LogMessage) {\n this.logger.trace(message);\n }\n\n /**\n * A function to create a timer for measuring the duration of asynchronous operations\n *\n * @example\n * ```ts\n * const stopTimer = context.timer(\"Your Async Operation\");\n * await performAsyncOperation();\n * stopTimer(); // \"Your Async Operation completed in 123.45 milliseconds\"\n * ```\n *\n * @param name - The name of the timer.\n * @returns A function that, when called, stops the timer and logs the duration.\n */\n public timer(name: string): () => void {\n const startDate = Date.now();\n const startDuration = performance.now();\n\n return () => {\n const duration = performance.now() - startDuration;\n this.logger.info({\n meta: {\n category: \"performance\"\n },\n message: `${chalk.bold.cyanBright(name)} completed in ${chalk.bold.cyanBright(\n duration < 1000\n ? `${duration.toFixed(2)} milliseconds`\n : formatDistanceToNowStrict(startDate)\n )}`\n });\n };\n }\n\n /**\n * Create a new logger instance\n *\n * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.\n * @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.\n */\n public createLogger(options: LoggerOptions, logFn?: LogFn): Logger {\n return createLogger(\n this.options.name || this.options.root || \"powerlines\",\n { ...this.configFile.config, ...this.options, ...options },\n logFn\n );\n }\n\n /**\n * Extend the base logger with additional configuration options\n *\n * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.\n * @returns A new logger client instance that extends the base logger with the provided configuration options.\n */\n public extendLogger(options: LoggerOptions): Logger {\n return extendLogger(this.logger, options);\n }\n\n /**\n * The input options used to initialize the context, which may be used when cloning the context to ensure the same configuration is applied to the new context\n */\n protected initialOptions: EngineOptions = {};\n\n /**\n * The initial configuration provided when initializing the context, which may be used during the setup process to ensure that the configuration is properly merged and applied to the context. This is typically the user configuration provided in the Powerlines configuration file, but may also include additional configuration options provided by plugins or other sources.\n */\n protected initialConfig: DeepPartial<UserConfig> = {};\n\n /**\n * Initialize the context with the provided configuration options and set up the resolver and user configuration file. This method is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup as the original context.\n *\n * @param options - The configuration options to initialize the context with, which can include properties such as the project root, mode, log level, and other settings that affect the behavior of the context and its plugins.\n * @param initialConfig - The initial configuration to initialize the context with, which is typically the user configuration provided in the Powerlines configuration file. This can also include additional configuration options provided by plugins or other sources that should be merged with the user configuration during initialization\n */\n protected constructor(\n options: EngineOptions,\n initialConfig: DeepPartial<UserConfig> = {}\n ) {\n this.initialOptions = options;\n this.initialConfig = initialConfig;\n }\n\n /**\n * Retrieve the workspace configuration for the current project, if it exists. This function will look for a configuration file in the project root and return its contents as a JavaScript object. If no configuration file is found, it will return undefined.\n *\n * @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.\n */\n protected async getWorkspaceConfig(): Promise<WorkspaceConfig | undefined> {\n return tryGetWorkspaceConfig(\n false,\n this.options || this.initialOptions\n ? {\n cwd:\n this.options?.root || this.initialOptions?.root\n ? appendPath(\n this.options?.root || this.initialOptions?.root || \".\",\n this.options?.cwd || this.initialOptions?.cwd\n )\n : undefined,\n workspaceRoot: this.options?.cwd || this.initialOptions?.cwd\n }\n : undefined\n );\n }\n\n /**\n * Initialize the context with the provided configuration options\n *\n * @remarks\n * This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.\n */\n protected async init() {\n if (!this.powerlinesPath) {\n const powerlinesPath = await resolvePackage(\"powerlines\");\n if (!powerlinesPath) {\n throw new Error(\"Could not resolve `powerlines` package location.\");\n }\n this.powerlinesPath = powerlinesPath;\n }\n\n this.options = defu(this.initialOptions, this.initialConfig, {\n cwd: process.cwd(),\n mode: await this.getDefaultMode(),\n logLevel: await this.getDefaultLogLevel(),\n framework: \"powerlines\"\n }) as RequiredKeys<EngineOptions, \"mode\" | \"cwd\" | \"root\" | \"framework\">;\n\n if (!this.options.root) {\n if (this.options.configFile) {\n const configFile = appendPath(\n this.options.configFile,\n this.options.cwd\n );\n if (!existsSync(configFile)) {\n throw new Error(\n `The user-provided configuration file at \"${\n this.options.configFile\n }\" does not exist. Please ensure this path is correct and try again.`\n );\n }\n if (!isFile(configFile)) {\n throw new Error(\n `The user-provided configuration file at \"${\n this.options.configFile\n }\" is not a file. Please ensure this path is correct and try again.`\n );\n }\n\n this.options.root = relativePath(\n this.options.cwd,\n findFilePath(configFile)\n );\n } else {\n this.options.root = \".\";\n }\n } else {\n this.options.root = replacePath(this.options.root, this.options.cwd);\n }\n\n this.resolver = createResolver({\n workspaceRoot: this.options.cwd,\n root: this.options.root,\n cacheDir: this.envPaths.cache,\n mode: this.options.mode\n });\n\n await this.resolvePackageConfigs();\n\n this.configFile = await loadUserConfigFile(this.options, this.resolver);\n if (this.configFile.config) {\n if (isSetString(this.configFile.configFile)) {\n this.options.configFile ??= replacePath(\n this.configFile.configFile,\n this.options.cwd\n );\n }\n\n if (!this.options.name) {\n if (\n isSetObject(this.configFile.config) &&\n isSetString((this.configFile.config as UserConfig).name)\n ) {\n this.options.name = (this.configFile.config as UserConfig).name;\n } else if (Array.isArray(this.configFile.config)) {\n for (const config of this.configFile.config) {\n if (\n isSetObject(config) &&\n isSetString((config as UserConfig).name)\n ) {\n this.options.name = (config as UserConfig).name;\n break;\n }\n }\n }\n }\n\n if (!this.options.name) {\n this.options.name = this.projectJson?.name || this.packageJson?.name;\n }\n }\n }\n\n /**\n * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.\n *\n * @remarks\n * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.\n *\n * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.\n * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.\n * @returns A promise that resolves when the package configurations have been loaded and stored in the context.\n */\n protected async resolvePackageConfigs(\n cwd: string = this.options.cwd,\n root: string = this.options.root\n ) {\n if (cwd || root) {\n const projectJsonPath = joinPaths(\n appendPath(root || \".\", cwd || \".\"),\n \"project.json\"\n );\n if (existsSync(projectJsonPath)) {\n this.projectJson = await readJsonFile(projectJsonPath);\n }\n\n const packageJsonPath = joinPaths(\n appendPath(root || \".\", cwd || \".\"),\n \"package.json\"\n );\n if (existsSync(packageJsonPath)) {\n this.packageJson = await readJsonFile<PackageJson>(packageJsonPath);\n this.options.organization ??= isSetObject(this.packageJson?.author)\n ? kebabCase(this.packageJson?.author?.name)\n : kebabCase(this.packageJson?.author);\n }\n }\n }\n\n /**\n * Determine the default mode for the current execution based on the environment and workspace configuration. This function will check the `NODE_ENV` environment variable to determine if the current environment is development, production, or test. If `NODE_ENV` is not set, it will look for a `mode` property in the workspace configuration file. If no mode is specified in the workspace configuration, it will default to \"production\".\n *\n * @returns A promise that resolves to the default mode for the current execution, which can be \"development\", \"production\", or \"test\".\n */\n protected async getDefaultMode(): Promise<Mode> {\n const workspaceConfig = await this.getWorkspaceConfig();\n\n return isProduction\n ? \"production\"\n : isDevelopment\n ? \"development\"\n : isTest\n ? \"test\"\n : workspaceConfig?.mode || \"production\";\n }\n\n /**\n * Determine the default log level for the current execution based on the environment and workspace configuration. This function will check the `logLevel` property in the workspace configuration file and resolve it to a `LogLevelResolvedConfig` value. If no log level is specified in the workspace configuration, it will default to \"info\" for development mode and \"warn\" for production mode.\n *\n * @returns A promise that resolves to the default log level for the current execution, which can be \"fatal\", \"error\", \"warn\", \"info\", \"debug\", or \"trace\".\n */\n protected async getDefaultLogLevel(): Promise<LogLevelResolvedConfig> {\n const workspaceConfig = await this.getWorkspaceConfig();\n\n return resolveLogLevel(\n workspaceConfig?.logLevel\n ? workspaceConfig.logLevel === \"success\" ||\n workspaceConfig.logLevel === \"performance\"\n ? \"info\"\n : workspaceConfig.logLevel === \"all\"\n ? \"debug\"\n : workspaceConfig.logLevel === \"fatal\"\n ? \"error\"\n : workspaceConfig.logLevel\n : undefined,\n this.options?.mode ||\n this.initialOptions?.mode ||\n workspaceConfig?.mode ||\n (await this.getDefaultMode())\n );\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 Context,\n CopyConfig,\n EmitEntryOptions,\n EmitOptions,\n ExecutionOptions,\n FetchOptions,\n InferOverridableConfig,\n LogFn,\n LogFnMeta,\n Logger,\n LoggerOptions,\n MetaInfo,\n ParsedTypeScriptConfig,\n ParseOptions,\n PluginConfig,\n ResolvedAssetGlob,\n ResolvedConfig,\n ResolvedCopyConfig,\n ResolvedEntryTypeDefinition,\n ResolvedOutputConfig,\n ResolveOptions,\n ResolveResult,\n TransformResult,\n VirtualFile,\n VirtualFileSystemInterface\n} from \"@powerlines/core\";\nimport { LogLevelResolvedConfig } from \"@powerlines/core\";\nimport {\n CACHE_HASH_LENGTH,\n DEFAULT_DEVELOPMENT_LOG_LEVEL,\n DEFAULT_PRODUCTION_LOG_LEVEL,\n DEFAULT_TEST_LOG_LEVEL,\n ROOT_HASH_LENGTH\n} from \"@powerlines/core/constants\";\nimport {\n getUniqueInputs,\n isTypeDefinition,\n resolveInputsSync\n} from \"@powerlines/core/lib/entry\";\nimport {\n createLogger,\n formatConfig,\n getPackageJsonOrganization,\n isDuplicate,\n isPlugin,\n mergeConfig,\n replacePathTokens,\n resolveLogLevel,\n withCustomLogger,\n withLogFn\n} from \"@powerlines/core/plugin-utils\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { EnvPaths, getEnvPaths } from \"@stryke/env/get-env-paths\";\nimport { relativeToWorkspaceRoot } from \"@stryke/fs/get-workspace-root\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { hashDirectory } from \"@stryke/hash/node\";\nimport { getUnique, getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { fetchRequest } from \"@stryke/http/fetch\";\nimport { appendPath } from \"@stryke/path/append\";\nimport {\n findFileDotExtensionSafe,\n findFileExtensionSafe\n} from \"@stryke/path/file-path-fns\";\nimport { isEqual } from \"@stryke/path/is-equal\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replacePath } from \"@stryke/path/replace\";\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 { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { RequiredKeys } from \"@stryke/types/base\";\nimport { TypeDefinition } from \"@stryke/types/configuration\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { match, tsconfigPathsToRegExp } from \"bundle-require\";\nimport { resolveCompatibilityDates } from \"compatx\";\nimport defu from \"defu\";\nimport { create, FlatCache } from \"flat-cache\";\nimport { existsSync } from \"node:fs\";\nimport { parse, ParseResult } from \"oxc-parser\";\nimport { Range } from \"semver\";\nimport {\n Agent,\n BodyInit,\n interceptors,\n RequestInfo,\n Response,\n setGlobalDispatcher\n} from \"undici\";\nimport { UnpluginBuildContext } from \"unplugin\";\nimport { getConfigProps } from \"../_internal/helpers/context\";\nimport { getPrefixedRootHash } from \"../_internal/helpers/meta\";\nimport { sendWriteLogMessage } from \"../_internal/ipc/send\";\nimport { VirtualFileSystem } from \"../_internal/vfs\";\nimport { getTsconfigFilePath } from \"../typescript/tsconfig\";\nimport { PowerlinesBaseContext } from \"./base-context\";\n\nconst agent = new Agent({ keepAliveTimeout: 10000 });\nsetGlobalDispatcher(\n agent.compose(\n interceptors.retry({\n maxRetries: 3,\n minTimeout: 1000,\n maxTimeout: 10000,\n timeoutFactor: 2,\n retryAfter: true\n })\n )\n);\n\nconst UNRESOLVED_CONFIG_NAMES = [\n \"initialConfig\",\n \"userConfig\",\n \"inlineConfig\",\n \"pluginConfig\",\n \"environmentConfig\"\n];\n\nexport class PowerlinesContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>\n extends PowerlinesBaseContext\n implements Context<TResolvedConfig>\n{\n #checksum: string | null = null;\n\n #buildId: string = uuid();\n\n #releaseId: string = uuid();\n\n #fs!: VirtualFileSystemInterface;\n\n #tsconfig!: ParsedTypeScriptConfig;\n\n #parserCache!: FlatCache;\n\n #requestCache!: FlatCache;\n\n #configProxy!: TResolvedConfig;\n\n /**\n * Create a new context from the workspace root and user config.\n *\n * @param options - The options for resolving the context.\n * @returns A promise that resolves to the new context.\n */\n public static async fromInitialConfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n >(\n options: ExecutionOptions,\n initialConfig: TResolvedConfig[\"initialConfig\"]\n ): Promise<PowerlinesContext<TResolvedConfig>> {\n const context = new PowerlinesContext<TResolvedConfig>(\n options,\n initialConfig\n );\n await context.init();\n\n return context;\n }\n\n /**\n * The options provided to the Powerlines process, resolved with default values and merged with any configuration provided by plugins or other sources. This is typically the final configuration used during the build process, but may also include additional options that are relevant to the context and its interactions with the Powerlines engine.\n */\n public override options: RequiredKeys<\n ExecutionOptions,\n \"mode\" | \"cwd\" | \"root\" | \"framework\" | \"logLevel\"\n > = {} as RequiredKeys<\n ExecutionOptions,\n \"mode\" | \"cwd\" | \"root\" | \"framework\" | \"logLevel\"\n >;\n\n /**\n * An object containing the dependencies that should be installed for the project\n */\n public dependencies: Record<string, string | Range> = {};\n\n /**\n * An object containing the development dependencies that should be installed for the project\n */\n public devDependencies: Record<string, string | Range> = {};\n\n /**\n * The persisted meta information about the current build\n */\n public persistedMeta: MetaInfo | undefined = undefined;\n\n /**\n * The resolved tsconfig file paths for the project\n */\n public resolvePatterns: RegExp[] = [];\n\n /**\n * The input options used to initialize the context, which may be used when cloning the context to ensure the same configuration is applied to the new context\n */\n protected override initialOptions: ExecutionOptions = {} as ExecutionOptions;\n\n /**\n * The resolved configuration for this context\n */\n protected resolvedConfig: TResolvedConfig = {} as TResolvedConfig;\n\n /**\n * The configuration options that were overridden by plugins during the build process, which may include additional properties or modifications made during the configuration loading process.\n */\n protected overriddenConfig: InferOverridableConfig<TResolvedConfig> =\n {} as InferOverridableConfig<TResolvedConfig>;\n\n /**\n * The configuration options provided inline during execution, such as CLI flags or other parameters that may be relevant to the command being executed. These options can be used to override or supplement the configuration options defined in a configuration file on disk, and are typically provided as part of the execution context when running a Powerlines command.\n */\n protected inlineConfig: TResolvedConfig[\"inlineConfig\"] =\n {} as TResolvedConfig[\"inlineConfig\"];\n\n /**\n * The configuration options read from a configuration file on disk, which may be used to resolve the final configuration for the context. This typically includes the user configuration options defined in the `powerlines.config.ts` file, as well as any inline configuration options provided during execution.\n */\n protected userConfig: TResolvedConfig[\"userConfig\"] =\n {} as TResolvedConfig[\"userConfig\"];\n\n /**\n * The configuration options provided by plugins added by the user (and other plugins)\n */\n protected pluginConfig: TResolvedConfig[\"pluginConfig\"] = {};\n\n /**\n * The configuration options provided by the environment\n */\n protected environmentConfig: any = {};\n\n /**\n * The resolved entry type definitions for the project\n */\n public get entry(): ResolvedEntryTypeDefinition[] {\n const entry = this.resolvedEntry;\n\n return resolveInputsSync(\n this,\n entry && entry.length > 0\n ? entry\n : Array.isArray(this.config.input) ||\n (isSetObject(this.config.input) &&\n !isTypeDefinition(this.config.input))\n ? this.config.input\n : toArray(this.config.input).flat()\n );\n }\n\n /**\n * The TypeScript configuration parsed from the tsconfig file\n */\n public get tsconfig(): ParsedTypeScriptConfig {\n if (!this.#tsconfig) {\n this.tsconfig = {\n tsconfigFilePath: this.config.tsconfig\n } as ParsedTypeScriptConfig;\n }\n\n return this.#tsconfig;\n }\n\n /**\n * Sets the TypeScript configuration parsed from the tsconfig file\n */\n public set tsconfig(value: ParsedTypeScriptConfig) {\n this.#tsconfig = value;\n this.resolvePatterns = tsconfigPathsToRegExp(value?.options?.paths ?? {});\n }\n\n /**\n * The virtual file system interface for the project\n */\n public get fs(): VirtualFileSystemInterface {\n if (!this.#fs) {\n this.#fs = VirtualFileSystem.createSync(this);\n }\n\n return this.#fs;\n }\n\n /**\n * Get the checksum of the project's current state\n */\n public get checksum(): string | null {\n return this.#checksum;\n }\n\n /**\n * The meta information about the current build\n */\n public get meta() {\n return {\n buildId: this.#buildId,\n releaseId: this.#releaseId,\n checksum: this.#checksum,\n timestamp: this.timestamp,\n rootHash: murmurhash(\n {\n workspaceRoot: this.options?.cwd,\n root: this.config?.root\n },\n {\n maxLength: ROOT_HASH_LENGTH\n }\n ),\n configHash: murmurhash(this.config, {\n maxLength: CACHE_HASH_LENGTH\n })\n } as MetaInfo;\n }\n\n /**\n * The resolved configuration options\n */\n public get config(): TResolvedConfig {\n if (!this.#configProxy) {\n this.#configProxy = this.createConfigProxy();\n }\n\n return this.#configProxy;\n }\n\n /**\n * Get the path to the artifacts directory for the project\n */\n public get artifactsPath(): string {\n return joinPaths(\n this.config.cwd,\n this.config.root,\n this.config.output?.artifactsPath ||\n `.${this.config.framework || \"powerlines\"}`\n );\n }\n\n /**\n * Get the path to the builtin modules used by the project\n */\n public get builtinsPath(): string {\n return joinPaths(this.artifactsPath, \"builtins\");\n }\n\n /**\n * Get the path to the entry directory for the project\n */\n public get entryPath(): string {\n return joinPaths(this.artifactsPath, \"entry\");\n }\n\n /**\n * Get the path to the infrastructure modules used by the project\n */\n public get infrastructurePath(): string {\n return joinPaths(this.artifactsPath, \"infrastructure\");\n }\n\n /**\n * Get the path to the data directory for the project\n */\n public get dataPath(): string {\n return joinPaths(\n this.envPaths.data,\n \"projects\",\n getPrefixedRootHash(this.config.name, this.meta.rootHash)\n );\n }\n\n /**\n * Get the path to the cache directory for the project\n */\n public get cachePath(): string {\n return joinPaths(\n this.envPaths.cache,\n \"projects\",\n murmurhash(\n {\n checksum: this.#checksum,\n config: this.meta.configHash\n },\n {\n maxLength: CACHE_HASH_LENGTH\n }\n )\n );\n }\n\n /**\n * Get the path to the generated declaration file for the project\n */\n public get typesPath(): string {\n return this.config.output.types\n ? appendPath(this.config.output.types, this.config.cwd)\n : joinPaths(this.config.cwd, this.config.root, \"powerlines.d.ts\");\n }\n\n /**\n * Get the project root relative to the workspace root\n */\n public get relativeToWorkspaceRoot() {\n return relativeToWorkspaceRoot(this.config.root);\n }\n\n /**\n * The builtin module id that exist in the Powerlines virtual file system\n */\n public get builtins(): string[] {\n return Object.values(this.fs.metadata)\n .filter(meta => meta && meta.type === \"builtin\")\n .map(meta => meta?.id)\n .filter(Boolean);\n }\n\n /**\n * Additional arguments provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed.\n */\n public get additionalArgs(): Record<string, string | string[]> {\n return Object.entries(this.config.inlineConfig.additionalArgs ?? {}).reduce(\n (ret, [key, value]) => {\n const formattedKey = key.replace(/^--?/, \"\");\n\n if (ret[formattedKey]) {\n if (Array.isArray(ret[formattedKey])) {\n if (Array.isArray(value)) {\n ret[formattedKey] = [...toArray(ret[formattedKey]), ...value];\n } else {\n ret[formattedKey] = [...toArray(ret[formattedKey]), value];\n }\n } else {\n ret[formattedKey] = [\n ret[formattedKey],\n ...(Array.isArray(value) ? value : [value])\n ];\n }\n } else {\n ret[formattedKey] = value;\n }\n return ret;\n },\n {} as Record<string, string | string[]>\n );\n }\n\n /**\n * The alias mappings for the project used during module resolution\n *\n * @remarks\n * This includes both the built-in module aliases as well as any custom aliases defined in the build configuration.\n */\n public get alias(): Record<string, string> {\n return this.builtins.reduce(\n (ret, id) => {\n const moduleId = `${\n this.config?.framework || \"powerlines\"\n }:${id.replace(/^.*:/, \"\")}`;\n if (!ret[moduleId]) {\n const path = this.fs.paths[id];\n if (path) {\n ret[moduleId] = path;\n }\n }\n\n return ret;\n },\n this.config.resolve.alias\n ? Array.isArray(this.config.resolve.alias)\n ? this.config.resolve.alias.reduce(\n (ret, alias) => {\n if (!ret[alias.find.toString()]) {\n ret[alias.find.toString()] = alias.replacement;\n }\n\n return ret;\n },\n {} as Record<string, string>\n )\n : this.config.resolve.alias\n : {}\n );\n }\n\n /**\n * The log level for the context, which determines the minimum level of log messages that will be emitted by the logger. This is resolved based on the configuration options provided by the user, and can be set to different levels for development, production, and test environments. The log level can also be overridden by plugins or other parts of the build process to provide more granular control over logging output.\n */\n public override get logLevel(): LogLevelResolvedConfig {\n return resolveLogLevel(this.config.logLevel, this.config.mode);\n }\n\n /**\n * The environment paths for the project, which provide the locations of various directories and files used by the Powerlines framework. These paths are resolved based on the organization ID, application ID, and workspace root directory, and can be used to access configuration files, cache directories, and other resources in a consistent manner.\n */\n public override get envPaths(): EnvPaths {\n return getEnvPaths({\n orgId: this.config.organization,\n appId: this.config.framework || \"powerlines\",\n workspaceRoot: this.config.cwd\n });\n }\n\n /**\n * Gets the parser cache.\n */\n protected get parserCache(): FlatCache {\n if (!this.#parserCache) {\n this.#parserCache = create({\n cacheId: \"parser\",\n cacheDir: this.cachePath,\n ttl: 2 * 60 * 60 * 1000,\n lruSize: 5000,\n persistInterval: 250\n });\n }\n\n return this.#parserCache;\n }\n\n /**\n * Gets the request cache.\n */\n protected get requestCache(): FlatCache {\n if (!this.#requestCache) {\n this.#requestCache = create({\n cacheId: \"http\",\n cacheDir: this.cachePath,\n ttl: 6 * 60 * 60 * 1000,\n lruSize: 5000,\n persistInterval: 250\n });\n }\n\n return this.#requestCache;\n }\n\n /**\n * The entry points that exist in the Powerlines virtual file system\n */\n protected get resolvedEntry(): ResolvedEntryTypeDefinition[] {\n return Object.entries(this.fs.metadata)\n .filter(([, meta]) => meta && meta.type === \"entry\")\n .map(([path, meta]) => {\n const typeDefinition = {\n file: path\n } as ResolvedEntryTypeDefinition;\n\n if (meta.properties) {\n if (isSetString(meta.properties.file)) {\n typeDefinition.file = meta.properties.file;\n }\n if (isSetString(meta.properties.name)) {\n typeDefinition.name = meta.properties.name;\n }\n if (\n isSetString(meta.properties[\"input.file\"]) ||\n isSetString(meta.properties[\"input.name\"])\n ) {\n typeDefinition.input ??= {} as TypeDefinition;\n if (isSetString(meta.properties[\"input.file\"])) {\n typeDefinition.input.file = meta.properties[\"input.file\"];\n }\n if (isSetString(meta.properties[\"input.name\"])) {\n typeDefinition.input.name = meta.properties[\"input.name\"];\n }\n }\n if (isSetString(meta.properties.output)) {\n typeDefinition.output = meta.properties.output;\n }\n }\n\n return typeDefinition;\n })\n .filter(Boolean);\n }\n\n /**\n * Creates a new Context instance.\n *\n * @param options - The options to use for creating the context, including the resolved configuration and workspace settings.\n * @param initialConfig - The initial configuration provided by the user, which can be used to resolve the final configuration for the context. This typically includes the user configuration options defined in the `powerlines.config.ts` file, as well as any inline configuration options provided during execution.\n */\n protected constructor(\n options: ExecutionOptions,\n initialConfig: TResolvedConfig[\"initialConfig\"]\n ) {\n super(options, initialConfig);\n this.initialOptions = options;\n this.initialConfig = initialConfig;\n }\n\n /**\n * Create a new logger instance\n *\n * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.\n * @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.\n */\n public override createLogger(options: LoggerOptions, logFn?: LogFn): Logger {\n let logger!: Logger;\n if (isSetString(process.env.POWERLINES_EXECUTION_THREAD_TYPE)) {\n logger = createLogger(\n this.config.name,\n { ...this.options, ...this.config, ...options },\n (meta: LogFnMeta, message: string) =>\n sendWriteLogMessage(this, meta, message)\n );\n } else {\n logger = createLogger(this.config.name, {\n ...this.options,\n ...this.config,\n ...options\n });\n }\n\n if (this.config.customLogger) {\n logger = withCustomLogger(logger, this.config.customLogger);\n }\n\n if (logFn) {\n logger = withLogFn(logger, logFn);\n }\n\n return logger;\n }\n\n /**\n * A function to perform HTTP fetch requests\n *\n * @remarks\n * This function uses a caching layer to avoid duplicate requests during the Powerlines process.\n *\n * @example\n * ```ts\n * const response = await context.fetch(\"https://api.example.com/data\");\n * const data = await response.json();\n * ```\n *\n * @see https://github.com/nodejs/undici\n *\n * @param input - The URL to fetch.\n * @param options - The fetch request options.\n * @returns A promise that resolves to a response returned by the fetch.\n */\n public async fetch(\n input: RequestInfo,\n options: FetchOptions = {}\n ): Promise<Response> {\n const cacheKey = murmurhash({\n input: input.toString(),\n options: JSON.stringify(options)\n });\n\n if (!this.config.skipCache && !options.skipCache) {\n const cached = this.requestCache.get<\n {\n body: BodyInit;\n } & Pick<Response, \"status\" | \"statusText\" | \"headers\">\n >(cacheKey);\n if (cached) {\n return new Response(cached.body, {\n status: cached.status,\n statusText: cached.statusText,\n headers: cached.headers\n });\n }\n }\n\n const logger = this.extendLogger({ category: \"network\" });\n const startTime = Date.now();\n\n logger.trace(\n `Sending fetch request (${\n options.method?.toUpperCase() || \"GET\"\n }): ${input.toString()}`\n );\n\n const response = await fetchRequest(input, { timeout: 12_000, ...options });\n const result = {\n body: await response.text(),\n status: response.status,\n statusText: response.statusText,\n headers: Object.fromEntries(response.headers.entries())\n };\n\n if (!this.config.skipCache && !options.skipCache) {\n try {\n this.requestCache.set(cacheKey, result);\n } catch {\n // Do nothing\n }\n }\n\n logger.trace(\n `Fetch request (${\n options.method?.toUpperCase() || \"GET\"\n }) completed in ${Date.now() - startTime}ms: ${input.toString()} - ${\n response.status\n } / ${response.statusText} \\n - Response Headers: ${JSON.stringify(\n result.headers\n )}\\n - Response Body: ${\n typeof result.body === \"string\"\n ? result.body.length > 1000\n ? `${result.body.slice(0, 1000)}... (truncated, total length: ${\n result.body.length\n })`\n : result.body\n : \"[Non-string body]\"\n }`\n );\n\n return new Response(result.body, {\n status: result.status,\n statusText: result.statusText,\n headers: result.headers\n });\n }\n\n /**\n * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.\n *\n * @remarks\n * This function can be used to parse TypeScript code into an AST for further analysis or transformation.\n *\n * @example\n * ```ts\n * const ast = context.parse(\"const x: number = 42;\");\n * ```\n *\n * @see https://rollupjs.org/plugin-development/#this-parse\n * @see https://github.com/oxc/oxc\n *\n * @param code - The source code to parse.\n * @param options - The options to pass to the parser.\n * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.\n */\n public async parse(code: string, options: ParseOptions = {}) {\n const cacheKey = murmurhash({\n code,\n options\n });\n\n let result!: ParseResult;\n if (!this.config.skipCache) {\n result = this.parserCache.get<ParseResult>(cacheKey);\n if (result) {\n return result;\n }\n }\n\n result = await parse(`source.${options.lang || \"ts\"}`, code, {\n ...options,\n sourceType: \"module\",\n showSemanticErrors: this.config.mode === \"development\"\n });\n\n if (!this.config.skipCache) {\n this.parserCache.set(cacheKey, result);\n }\n\n return result;\n }\n\n /**\n * A helper function to resolve modules in the Virtual File System\n *\n * @remarks\n * This function can be used to resolve modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const resolved = await context.resolve(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to resolve.\n * @param importer - An optional path to the importer module.\n * @param options - Additional resolution options.\n * @returns A promise that resolves to the resolved module path.\n */\n public async resolve(\n id: string,\n importer?: string,\n options: ResolveOptions = {}\n ): Promise<ResolveResult | undefined> {\n let moduleId = id;\n if (this.config.resolve.alias) {\n if (Array.isArray(this.config.resolve.alias)) {\n const alias = this.config.resolve.alias.find(a =>\n match(moduleId, [a.find])\n );\n if (alias) {\n moduleId = alias.replacement;\n }\n } else if (\n isSetObject(this.config.resolve.alias) &&\n this.config.resolve.alias[id]\n ) {\n moduleId = this.config.resolve.alias[id];\n }\n }\n\n if (\n this.fs.isResolvableId(moduleId) ||\n (importer && this.fs.isResolvableId(importer))\n ) {\n let resolvedImporter = importer;\n if (importer && this.fs.isResolvableId(importer)) {\n resolvedImporter = await this.fs.resolve(\n importer,\n undefined,\n defu(\n {\n conditions: this.config.resolve.conditions,\n extensions: this.config.resolve.extensions\n },\n options\n )\n );\n }\n\n const result = await this.fs.resolve(\n moduleId,\n resolvedImporter,\n defu(\n {\n conditions: this.config.resolve.conditions,\n extensions: this.config.resolve.extensions\n },\n options\n )\n );\n if (!result) {\n return undefined;\n }\n\n const external = Boolean(\n !match(moduleId, this.config.resolve.noExternal) &&\n (match(moduleId, this.config.resolve.external) ||\n moduleId.startsWith(\"node:\") ||\n ((!this.fs.isVirtual(moduleId, importer, options) ||\n (this.fs.isVirtual(moduleId, importer, options) &&\n this.config.projectType !== \"application\")) &&\n this.config.resolve.skipNodeModulesBundle &&\n !/^[A-Z]:[/\\\\]|^\\.{0,2}\\/|^\\.{1,2}$/.test(moduleId)))\n );\n\n return {\n id: result,\n external,\n virtual: !external\n };\n }\n\n if (this.config.resolve.skipNodeModulesBundle) {\n if (\n match(moduleId, this.resolvePatterns) ||\n match(moduleId, this.config.resolve.noExternal)\n ) {\n return undefined;\n }\n\n if (\n match(moduleId, this.config.resolve.external) ||\n moduleId.startsWith(\"node:\")\n ) {\n return { id: moduleId, external: true, virtual: false };\n }\n\n // Exclude any other import that looks like a Node module\n if (!/^[A-Z]:[/\\\\]|^\\.{0,2}\\/|^\\.{1,2}$/.test(moduleId)) {\n return {\n id: moduleId,\n external: true,\n virtual: false\n };\n }\n } else {\n if (match(moduleId, this.config.resolve.noExternal)) {\n return undefined;\n }\n\n if (\n match(moduleId, this.config.resolve.external) ||\n moduleId.startsWith(\"node:\")\n ) {\n return { id: moduleId, external: true, virtual: false };\n }\n }\n\n return undefined;\n }\n\n /**\n * A helper function to load modules from the Virtual File System\n *\n * @remarks\n * This function can be used to load modules relative to the project root directory.\n *\n * @example\n * ```ts\n * const module = await context.load(\"some-module\", \"/path/to/importer\");\n * ```\n *\n * @param id - The module to load.\n * @returns A promise that resolves to the loaded module.\n */\n public async load(id: string): Promise<TransformResult | undefined> {\n const resolvedId = await this.fs.resolve(id);\n if (!resolvedId) {\n return undefined;\n }\n\n const code = await this.fs.read(resolvedId);\n if (!code) {\n return undefined;\n }\n\n return { code, map: null };\n }\n\n /**\n * Get the builtin virtual files that exist in the Powerlines virtual file system\n */\n public async getBuiltins() {\n return Promise.all(\n Object.entries(this.fs.metadata)\n .filter(([, meta]) => meta && meta.type === \"builtin\")\n .map(async ([id, meta]) => {\n const code = await this.fs.read(id);\n const path = this.fs.paths[id];\n\n return { ...meta, path, code } as VirtualFile;\n })\n );\n }\n\n /**\n * Resolves a file and writes it to the VFS if it does not already exist\n *\n * @param code - The source code of the file\n * @param path - The path to write the file to\n * @param options - Additional options for writing the file\n */\n public async emit(\n code: string,\n path: string,\n options: EmitOptions = {}\n ): Promise<void> {\n const filePath = options.extension\n ? findFileExtensionSafe(path)\n ? options.extension.startsWith(\".\")\n ? path.replace(findFileDotExtensionSafe(path), options.extension)\n : path.replace(findFileExtensionSafe(path), options.extension)\n : options.extension.startsWith(\".\")\n ? `${path}${options.extension}`\n : `${path}.${options.extension}`\n : findFileExtensionSafe(path)\n ? path\n : `${path}.ts`;\n\n if (\n isFunction((this as unknown as UnpluginBuildContext).emitFile) &&\n options.emitWithBundler\n ) {\n return (this as unknown as UnpluginBuildContext).emitFile({\n needsCodeReference: options.needsCodeReference,\n originalFileName: options.originalFileName,\n fileName: filePath,\n source: code,\n type: \"asset\"\n });\n }\n\n return this.fs.write(filePath, code, options);\n }\n\n /**\n * Synchronously resolves a file and writes it to the VFS if it does not already exist\n *\n * @param code - The source code of the file\n * @param path - The path to write the file to\n * @param options - Additional options for writing the file\n */\n public emitSync(code: string, path: string, options: EmitOptions = {}) {\n const filePath = options.extension\n ? findFileExtensionSafe(path)\n ? options.extension.startsWith(\".\")\n ? path.replace(findFileDotExtensionSafe(path), options.extension)\n : path.replace(findFileExtensionSafe(path), options.extension)\n : options.extension.startsWith(\".\")\n ? `${path}${options.extension}`\n : `${path}.${options.extension}`\n : findFileExtensionSafe(path)\n ? path\n : `${path}.ts`;\n\n if (\n isFunction((this as unknown as UnpluginBuildContext).emitFile) &&\n options.emitWithBundler\n ) {\n return (this as unknown as UnpluginBuildContext).emitFile({\n needsCodeReference: options.needsCodeReference,\n originalFileName: options.originalFileName,\n fileName: filePath,\n source: code,\n type: \"asset\"\n });\n }\n\n return this.fs.writeSync(filePath, code, options);\n }\n\n /**\n * Resolves a entry virtual file and writes it to the VFS if it does not already exist\n *\n * @param code - The source code of the entry file\n * @param path - A path to write the entry file to\n * @param options - Optional write file options\n */\n public async emitEntry(\n code: string,\n path: string,\n options: EmitEntryOptions = {}\n ): Promise<void> {\n return this.emit(\n code,\n appendPath(path, this.entryPath),\n defu(\n {\n meta: {\n type: \"entry\",\n properties: {\n file: appendPath(path, this.entryPath),\n name: options?.name,\n output: options?.output,\n \"input.file\": options?.input?.file,\n \"input.name\": options?.input?.name\n }\n }\n },\n omit(options, [\"name\"])\n )\n );\n }\n\n /**\n * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist\n *\n * @param code - The source code of the entry file\n * @param path - A path to write the entry file to\n * @param options - Optional write file options\n */\n public emitEntrySync(\n code: string,\n path: string,\n options: EmitEntryOptions = {}\n ): void {\n return this.emitSync(\n code,\n appendPath(path, this.entryPath),\n defu(\n {\n meta: {\n type: \"entry\",\n properties: {\n file: appendPath(path, this.entryPath),\n name: options?.name,\n output: options?.output,\n \"input.file\": options?.input?.file,\n \"input.name\": options?.input?.name\n }\n }\n },\n omit(options, [\"name\"])\n )\n );\n }\n\n /**\n * Resolves a builtin virtual file and writes it to the VFS if it does not already exist\n *\n * @param code - The source code of the builtin file\n * @param id - The unique identifier of the builtin file\n * @param options - Optional write file options\n */\n public async emitBuiltin(\n code: string,\n id: string,\n options: EmitOptions = {}\n ): Promise<void> {\n if (!this.builtinsPath) {\n throw new Error(\n `The builtins path is not set. Cannot emit builtin file with id \"${id}\".`\n );\n }\n\n if (!isSetString(id)) {\n throw new Error(\n `The builtin id must be a non-empty string. Received: ${String(id)}`\n );\n }\n\n return this.emit(\n code,\n appendPath(id, this.builtinsPath),\n defu(options, { meta: { type: \"builtin\", id } })\n );\n }\n\n /**\n * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist\n *\n * @param code - The source code of the builtin file\n * @param id - The unique identifier of the builtin file\n * @param options - Optional write file options\n */\n public emitBuiltinSync(code: string, id: string, options: EmitOptions = {}) {\n if (!this.builtinsPath) {\n throw new Error(\n `The builtins path is not set. Cannot emit builtin file with id \"${id}\".`\n );\n }\n\n if (!isSetString(id)) {\n throw new Error(\n `The builtin id must be a non-empty string. Received: ${String(id)}`\n );\n }\n\n return this.emitSync(\n code,\n appendPath(id, this.builtinsPath),\n defu(options, { meta: { type: \"builtin\", id } })\n );\n }\n\n /**\n * Resolves a builtin virtual file and writes it to the VFS if it does not already exist\n *\n * @param code - The source code of the builtin file\n * @param id - The unique identifier of the builtin file\n * @param options - Optional write file options\n */\n public async emitInfrastructure(\n code: string,\n id: string,\n options: EmitOptions = {}\n ): Promise<void> {\n if (!this.infrastructurePath) {\n throw new Error(\n `The infrastructure path is not set. Cannot emit infrastructure file with id \"${id}\".`\n );\n }\n\n if (!isSetString(id)) {\n throw new Error(\n `The infrastructure id must be a non-empty string. Received: ${String(id)}`\n );\n }\n\n return this.emit(\n code,\n appendPath(id, this.infrastructurePath),\n defu(options, { meta: { type: \"infrastructure\", id } })\n );\n }\n\n /**\n * Synchronously resolves an infrastructure virtual file and writes it to the VFS if it does not already exist\n *\n * @param code - The source code of the infrastructure file\n * @param id - The unique identifier of the infrastructure file\n * @param options - Optional write file options\n */\n public emitInfrastructureSync(\n code: string,\n id: string,\n options: EmitOptions = {}\n ) {\n if (!this.infrastructurePath) {\n throw new Error(\n `The infrastructure path is not set. Cannot emit infrastructure file with id \"${id}\".`\n );\n }\n\n if (!isSetString(id)) {\n throw new Error(\n `The infrastructure id must be a non-empty string. Received: ${String(id)}`\n );\n }\n\n return this.emitSync(\n code,\n appendPath(id, this.infrastructurePath),\n defu(options, { meta: { type: \"infrastructure\", id } })\n );\n }\n\n /**\n * Generates a checksum representing the current context state\n *\n * @param path - The root directory of the project to generate the checksum for\n * @returns A promise that resolves to a string representing the checksum\n */\n public async generateChecksum(path?: string): Promise<string> {\n return hashDirectory(\n path || appendPath(this.options.root, this.options.cwd)\n );\n }\n\n /**\n * A setter function to populate the inline config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the inline configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any inline configuration provided during execution.\n *\n * @param config - The inline configuration values to set.\n * @returns A promise that resolves when the inline configuration values have been set.\n */\n public async setInlineConfig(\n config: TResolvedConfig[\"inlineConfig\"]\n ): Promise<void> {\n this.logger.debug({\n meta: { category: \"config\" },\n message: `Updating inline configuration object: \\n${formatConfig(config)}`\n });\n\n this.inlineConfig = config;\n await this.resolveConfig();\n }\n\n /**\n * A setter function to populate the plugin config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the plugin configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any plugin configuration provided during execution.\n *\n * @param config - The plugin configuration values to set.\n * @returns A promise that resolves when the plugin configuration values have been set.\n */\n public async setPluginConfig(\n config: TResolvedConfig[\"pluginConfig\"]\n ): Promise<void> {\n this.logger.debug({\n meta: { category: \"config\" },\n message: `Updating plugin configuration object: \\n${formatConfig(config)}`\n });\n\n this.pluginConfig = config;\n await this.resolveConfig();\n }\n\n /**\n * A function to merge the various configuration objects (initial, user, inline, and plugin) into a single resolved configuration object that can be used throughout the Powerlines process. This function takes into account the different sources of configuration and their respective priorities, ensuring that the final configuration reflects the intended settings for the project. The merged configuration is then returned as a new object that can be accessed through the `config` property of the context.\n *\n * @returns The merged configuration object that combines the initial, user, inline, and plugin configurations.\n */\n protected mergeConfig(): TResolvedConfig {\n return mergeConfig(\n {\n mode: this.initialOptions.mode,\n framework: this.initialOptions.framework,\n logLevel: this.initialOptions.logLevel,\n\n inlineConfig: this.inlineConfig,\n userConfig: this.userConfig,\n initialConfig: this.initialConfig,\n pluginConfig: this.pluginConfig,\n environmentConfig: this.environmentConfig\n },\n getConfigProps<TResolvedConfig>(this.overriddenConfig),\n omit(this.options, [\"name\", \"mode\", \"framework\", \"logLevel\"]),\n getConfigProps<TResolvedConfig>(this.inlineConfig),\n getConfigProps<TResolvedConfig>(this.userConfig),\n getConfigProps<TResolvedConfig>(this.initialConfig),\n getConfigProps<TResolvedConfig>(this.pluginConfig),\n {\n name: this.initialOptions.name,\n version: this.packageJson?.version,\n description: this.packageJson?.description,\n environments: {},\n resolve: {}\n }\n ) as TResolvedConfig;\n }\n\n /**\n * A setter function to populate the user config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the user configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any inline configuration provided during execution.\n *\n * @param config - The user configuration values to set.\n * @returns A promise that resolves when the user configuration values have been set.\n */\n protected async setUserConfig(\n config: TResolvedConfig[\"userConfig\"]\n ): Promise<void> {\n this.logger.debug({\n meta: { category: \"config\" },\n message: `Updating user configuration object: \\n${formatConfig(config)}`\n });\n\n this.userConfig = config;\n await this.resolveConfig();\n }\n\n /**\n * Initialize the context with the provided configuration options\n */\n protected override async init() {\n await super.init();\n\n this.options.executionId = this.initialOptions.executionId || uuid();\n this.options.executionIndex = this.initialOptions.executionIndex ?? 0;\n\n this.#checksum = await this.generateChecksum();\n\n const result =\n this.configFile.config &&\n toArray(this.configFile.config).length > this.options.executionIndex\n ? toArray(this.configFile.config)[this.options.executionIndex]!\n : this.configFile.config;\n if (!result) {\n this.logger.warn(\n `No configuration found in ${\n this.options.configFile\n } for execution index ${this.options.executionIndex}.`\n );\n } else {\n await this.setUserConfig(\n (isFunction(result)\n ? await Promise.resolve(result(this.options))\n : result) as TResolvedConfig[\"userConfig\"]\n );\n }\n }\n\n /**\n * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.\n *\n * @remarks\n * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.\n *\n * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.\n * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.\n * @returns A promise that resolves when the package configurations have been loaded and stored in the context.\n */\n protected override async resolvePackageConfigs(\n cwd: string = this.config.cwd,\n root: string = this.config.root\n ) {\n return super.resolvePackageConfigs(cwd, root);\n }\n\n /**\n * Initialize the context with the provided configuration options\n */\n protected async resolveConfig(): Promise<void> {\n const mergedConfig = this.mergeConfig();\n\n this.logger.trace({\n meta: { category: \"config\" },\n message: `Pre-setup Powerlines configuration object: \\n --- Merged Config --- \\n${formatConfig(\n mergedConfig\n )} \\n\\n --- Initial Options --- \\n${formatConfig(\n this.initialOptions\n )} \\n\\n --- Initial Config --- \\n${formatConfig(\n this.initialConfig\n )} \\n\\n --- User Config --- \\n${formatConfig(\n this.userConfig\n )} \\n\\n --- Inline Config --- \\n${formatConfig(\n this.inlineConfig\n )} \\n\\n --- Plugin Config --- \\n${formatConfig(\n this.pluginConfig\n )} \\n\\n --- Environment Config --- \\n${formatConfig(\n this.environmentConfig\n )} \\n\\n --- Overridden Config --- \\n${formatConfig(\n this.overriddenConfig\n )}`\n });\n\n mergedConfig.output = defu(mergedConfig.output ?? {}, {\n copy: {\n assets: [\n {\n glob: \"LICENSE\"\n },\n {\n input: mergedConfig.root,\n glob: \"*.md\"\n },\n {\n input: mergedConfig.root,\n glob: \"package.json\"\n }\n ]\n },\n dts: true\n }) as ResolvedOutputConfig;\n\n if (isUndefined(mergedConfig.mode)) {\n mergedConfig.mode = await this.getDefaultMode();\n }\n\n if (isUndefined(mergedConfig.framework)) {\n mergedConfig.framework = \"powerlines\";\n }\n\n if (isUndefined(mergedConfig.platform)) {\n mergedConfig.platform = \"neutral\";\n }\n\n mergedConfig.compatibilityDate = resolveCompatibilityDates(\n mergedConfig.compatibilityDate,\n \"latest\"\n );\n\n if (\n (!this.packageJson &&\n existsSync(\n joinPaths(\n appendPath(mergedConfig.root, mergedConfig.cwd),\n \"package.json\"\n )\n )) ||\n (!this.projectJson &&\n existsSync(\n joinPaths(\n appendPath(mergedConfig.root, mergedConfig.cwd),\n \"project.json\"\n )\n ))\n ) {\n await this.resolvePackageConfigs(mergedConfig.cwd, mergedConfig.root);\n\n if (this.packageJson) {\n mergedConfig.organization ??=\n getPackageJsonOrganization(this.packageJson) || \"powerlines\";\n }\n }\n\n if (isUndefined(mergedConfig.projectType)) {\n mergedConfig.projectType = this.projectJson?.projectType || \"application\";\n }\n\n this.resolvedConfig = mergedConfig;\n this.#configProxy = this.createConfigProxy();\n\n mergedConfig.input = getUniqueInputs(mergedConfig.input);\n\n if (\n mergedConfig.name?.startsWith(\"@\") &&\n mergedConfig.name.split(\"/\").filter(Boolean).length > 1\n ) {\n mergedConfig.name = mergedConfig.name.split(\"/\").filter(Boolean)[1]!;\n }\n\n mergedConfig.title ??= titleCase(mergedConfig.name);\n\n if (mergedConfig.resolve.external) {\n mergedConfig.resolve.external = getUnique(mergedConfig.resolve.external);\n }\n if (mergedConfig.resolve.noExternal) {\n mergedConfig.resolve.noExternal = getUnique(\n mergedConfig.resolve.noExternal\n );\n }\n\n mergedConfig.plugins = (mergedConfig.plugins ?? [])\n .flatMap(plugin => toArray(plugin))\n .filter(Boolean)\n .reduce((ret, plugin) => {\n if (\n isPlugin(plugin) &&\n isDuplicate(\n plugin,\n ret.filter(p => isPlugin(p))\n )\n ) {\n return ret;\n }\n\n ret.push(plugin);\n\n return ret;\n }, [] as PluginConfig[]);\n\n if (isUndefined(mergedConfig.logLevel)) {\n if (mergedConfig.mode === \"development\") {\n mergedConfig.logLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;\n } else if (mergedConfig.mode === \"test\") {\n mergedConfig.logLevel = DEFAULT_TEST_LOG_LEVEL;\n } else {\n mergedConfig.logLevel = DEFAULT_PRODUCTION_LOG_LEVEL;\n }\n }\n\n mergedConfig.logLevel = resolveLogLevel(mergedConfig.logLevel);\n\n if (isSetString(mergedConfig.tsconfig)) {\n mergedConfig.tsconfig = replacePath(\n replacePathTokens(this, mergedConfig.tsconfig),\n mergedConfig.cwd\n );\n } else {\n mergedConfig.tsconfig = getTsconfigFilePath(\n mergedConfig.cwd,\n mergedConfig.root\n );\n }\n\n // #region Configure output\n\n mergedConfig.output.format = getUnique(\n toArray(\n mergedConfig.output?.format ??\n (mergedConfig.projectType === \"library\" ? [\"cjs\", \"esm\"] : [\"esm\"])\n )\n );\n\n if (isSetString(mergedConfig.output.path)) {\n mergedConfig.output.path = appendPath(\n replacePathTokens(this, mergedConfig.output.path),\n mergedConfig.cwd\n );\n } else {\n mergedConfig.output.path = appendPath(\n joinPaths(mergedConfig.root, \"dist\"),\n mergedConfig.cwd\n );\n }\n\n mergedConfig.output.copy ??= {} as ResolvedCopyConfig;\n if (mergedConfig.output.copy !== false) {\n if (!mergedConfig.root.replace(/^\\.\\/?/, \"\")) {\n mergedConfig.output.copy.path = isSetString(\n mergedConfig.output.copy.path\n )\n ? appendPath(\n replacePathTokens(this, mergedConfig.output.copy.path),\n mergedConfig.cwd\n )\n : mergedConfig.output.path;\n } else {\n mergedConfig.output.copy.path = appendPath(\n replacePathTokens(\n this,\n isSetString(mergedConfig.output.copy.path)\n ? mergedConfig.output.copy.path\n : joinPaths(\"dist\", mergedConfig.root)\n ),\n mergedConfig.cwd\n );\n }\n }\n\n if (mergedConfig.output.types !== false) {\n mergedConfig.output.types = appendPath(\n replacePathTokens(\n this,\n mergedConfig.output.types ||\n joinPaths(\n mergedConfig.root,\n `${mergedConfig.framework ?? \"powerlines\"}.d.ts`\n )\n ),\n mergedConfig.cwd\n );\n }\n\n if (\n mergedConfig.output.copy &&\n mergedConfig.output.copy.path &&\n mergedConfig.output.copy.assets &&\n Array.isArray(mergedConfig.output.copy.assets)\n ) {\n mergedConfig.output.copy.assets = getUniqueBy(\n mergedConfig.output.copy.assets.map(asset => {\n return {\n glob: isSetObject(asset) ? asset.glob : asset,\n input:\n isString(asset) ||\n !asset.input ||\n asset.input === \".\" ||\n asset.input === \"/\" ||\n asset.input === \"./\"\n ? mergedConfig.cwd\n : isParentPath(asset.input, mergedConfig.cwd) ||\n isEqual(asset.input, mergedConfig.cwd)\n ? asset.input\n : appendPath(asset.input, mergedConfig.cwd),\n output:\n isSetObject(asset) && asset.output\n ? isParentPath(asset.output, mergedConfig.cwd)\n ? asset.output\n : appendPath(\n joinPaths(\n (mergedConfig.output.copy as CopyConfig).path,\n replacePath(\n replacePath(\n asset.output,\n replacePath(\n (mergedConfig.output.copy as CopyConfig).path,\n mergedConfig.cwd\n )\n ),\n (mergedConfig.output.copy as CopyConfig).path\n )\n ),\n mergedConfig.cwd\n )\n : appendPath(\n (mergedConfig.output.copy as CopyConfig).path,\n mergedConfig.cwd\n ),\n ignore:\n isSetObject(asset) && asset.ignore\n ? toArray(asset.ignore)\n : undefined\n };\n }),\n (a: ResolvedAssetGlob) => `${a.input}-${a.glob}-${a.output}`\n );\n }\n\n if (isUndefined(mergedConfig.output?.sourceMap)) {\n if (mergedConfig.mode === \"development\") {\n mergedConfig.output.sourceMap = true;\n } else {\n mergedConfig.output.sourceMap = false;\n }\n }\n\n if (isUndefined(mergedConfig.output?.minify)) {\n if (mergedConfig.mode === \"production\") {\n mergedConfig.output.minify = true;\n } else {\n mergedConfig.output.minify = false;\n }\n }\n\n if (isUndefined(mergedConfig.output?.artifactsPath)) {\n mergedConfig.output.artifactsPath = `.${\n mergedConfig.framework || \"powerlines\"\n }`;\n }\n\n if (mergedConfig.output.copy && mergedConfig.output.copy.assets) {\n mergedConfig.output.copy.assets = mergedConfig.output.copy.assets.map(\n asset => ({\n ...asset,\n glob: replacePathTokens(this, asset.glob),\n ignore: asset.ignore\n ? asset.ignore.map(ignore => replacePathTokens(this, ignore))\n : undefined,\n input: replacePathTokens(this, asset.input),\n output: replacePathTokens(this, asset.output)\n })\n );\n }\n\n if (\n (isSetString(mergedConfig.output?.storage) &&\n mergedConfig.output.storage === \"virtual\") ||\n (isSetObject(mergedConfig.output?.storage) &&\n Object.values(mergedConfig.output.storage).every(\n adapter => adapter.preset === \"virtual\"\n ))\n ) {\n mergedConfig.output.overwrite = true;\n }\n\n // #endregion Configure output\n\n this.resolvedConfig = mergedConfig;\n this.#configProxy = this.createConfigProxy();\n\n this.logger.info({\n meta: { category: \"config\" },\n message: `Resolved Powerlines configuration object: \\n${formatConfig(\n this.resolvedConfig\n )}`\n });\n\n this.#fs ??= await VirtualFileSystem.create(this);\n }\n\n private createConfigProxy(): TResolvedConfig {\n return new Proxy(this.resolvedConfig, {\n /**\n * A trap for the `delete` operator.\n * @param target - The original object which is being proxied.\n * @param key - The name or `Symbol` of the property to delete.\n * @returns A `boolean` indicating whether or not the property was deleted.\n */\n deleteProperty: (target: TResolvedConfig, key) => {\n if (UNRESOLVED_CONFIG_NAMES.includes(key.toString())) {\n throw new Error(\n `Cannot delete property ${key.toString()} from config - it is only intended to be used as a reference.`\n );\n }\n\n Reflect.deleteProperty(this.overriddenConfig, key);\n return Reflect.deleteProperty(target, key);\n },\n\n /**\n * A trap for getting a property value.\n * @param target - The original object which is being proxied.\n * @param key - The name or `Symbol` of the property to get.\n * @param receiver - The proxy or an object that inherits from the proxy.\n */\n get: (target: TResolvedConfig, key, receiver) => {\n if (UNRESOLVED_CONFIG_NAMES.includes(key.toString())) {\n if (key === \"initialConfig\") {\n return this.initialConfig;\n }\n if (key === \"userConfig\") {\n return this.userConfig;\n }\n if (key === \"inlineConfig\") {\n return this.inlineConfig;\n }\n if (key === \"pluginConfig\") {\n return this.pluginConfig;\n }\n if (key === \"environmentConfig\") {\n return this.environmentConfig;\n }\n }\n\n return Reflect.get(target, key, receiver);\n },\n\n /**\n * A trap for the `in` operator.\n * @param target - The original object which is being proxied.\n * @param key - The name or `Symbol` of the property to check for existence.\n */\n has: (target: TResolvedConfig, key: string | symbol): boolean => {\n return (\n Reflect.has(target, key) ||\n UNRESOLVED_CONFIG_NAMES.includes(key.toString())\n );\n },\n\n /**\n * A trap for `Reflect.ownKeys()`.\n * @param target - The original object which is being proxied.\n */\n ownKeys: (target: TResolvedConfig): ArrayLike<string | symbol> => {\n return getUnique([\n ...Reflect.ownKeys(target),\n ...UNRESOLVED_CONFIG_NAMES\n ]);\n },\n\n /**\n * A trap for setting a property value.\n * @param target - The original object which is being proxied.\n * @param key - The name or `Symbol` of the property to set.\n * @param newValue - The new value to assign to the property.\n * @param receiver - The object to which the assignment was originally directed.\n * @returns A `boolean` indicating whether or not the property was set.\n */\n set: (\n target: TResolvedConfig,\n key: string | symbol,\n newValue: any,\n receiver: any\n ): boolean => {\n if (UNRESOLVED_CONFIG_NAMES.includes(key.toString())) {\n throw new Error(\n `Cannot change property ${key.toString()} from config - it is only intended to be used as a reference.`\n );\n }\n\n Reflect.set(this.overriddenConfig, key, newValue, receiver);\n return Reflect.set(target, key, newValue, receiver);\n }\n });\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 CallHookOptions,\n EnvironmentContext,\n HookListOrders,\n HooksList,\n HooksListItem,\n InferHookParameters,\n InferHookReturnType,\n Plugin,\n PluginContext,\n PluginHookFields,\n ResolvedConfig\n} from \"@powerlines/core\";\nimport {\n addPluginHook,\n isPluginHook,\n isPluginHookField,\n mergeConfig\n} from \"@powerlines/core/plugin-utils\";\nimport { colorText } from \"@powerlines/core/plugin-utils/logging\";\nimport { getField } from \"@stryke/helpers/get-field\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\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 { ArrayValues } from \"@stryke/types/array\";\nimport { AnyFunction } from \"@stryke/types/base\";\nimport chalk from \"chalk\";\nimport { defu } from \"defu\";\n\n/**\n * Merges the current hook result with the previous results based on their types.\n *\n * @param currentResult - The current hook result to merge with the previous results.\n * @param previousResults - The previous hook results to merge with the current result.\n * @returns The merged result.\n */\nexport function mergeResults<\n T extends Record<string | number | symbol, any> | string\n>(currentResult: T, previousResults: T[]): T[] {\n if (!previousResults || previousResults.length === 0) {\n return [currentResult];\n }\n\n if (isSetString(currentResult)) {\n previousResults = [\n `${isSetString(previousResults[0]) ? previousResults[0] || \"\" : \"\"}\\n${\n isSetString(previousResults[0])\n ? currentResult.replace(previousResults[0], \"\")\n : currentResult\n }`.trim() as T\n ];\n } else if (isObject(currentResult)) {\n previousResults =\n previousResults.length > 0\n ? [defu(currentResult, previousResults[0])]\n : [currentResult];\n }\n\n return previousResults;\n}\n\n/**\n * Merges multiple hook results together, with special handling for string values and object values.\n *\n * @param currentResult - The current hook result to merge with the previous results.\n * @param previousResults - The previous hook results to merge with the current result.\n * @returns The merged result.\n */\nexport function mergeConfigs<T>(currentResult: T, previousResults: T): T {\n if (isString(currentResult)) {\n previousResults =\n `${isString(previousResults) ? previousResults || \"\" : \"\"}\\n${\n currentResult || \"\"\n }`.trim() as T;\n } else if (isObject(currentResult)) {\n previousResults = mergeConfig(currentResult, previousResults ?? {}) as T;\n }\n\n return previousResults;\n}\n\n/**\n * Calls a hook with the given context, options, and arguments.\n *\n * @param context - The context to use when calling the hook.\n * @param key - The hook to call.\n * @param options - Options for calling the hook.\n * @param args - Arguments to pass to the hook.\n * @returns The return value of the hook.\n */\nexport async function callHook<\n TResolvedConfig extends ResolvedConfig,\n TKey extends string\n>(\n context: EnvironmentContext<TResolvedConfig>,\n key: TKey,\n options: CallHookOptions,\n ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>\n): Promise<\n InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined\n> {\n const hooks = context.selectHooks(key, options);\n if (hooks.length > 0) {\n const logger = context.extendLogger({ category: \"hooks\" });\n\n logger.debug(\n `🧩 Calling ${hooks.length} ${chalk.bold.cyanBright(\n `${key}${options?.order ? ` (${options.order})` : \"\"}`\n )} plugin hook${hooks.length > 1 ? \"s\" : \"\"}:\\n${hooks\n .map((hook, index) => ` ${index + 1}. ${colorText(hook.plugin.name)}`)\n .join(\"\\n\")}`\n );\n\n const invokeHook = async (\n hook: ArrayValues<typeof hooks>,\n hookArgs: InferHookParameters<PluginContext<TResolvedConfig>, TKey>\n ) => {\n return Reflect.apply(hook.handler as AnyFunction, hook.context, hookArgs);\n };\n\n let results = [] as InferHookReturnType<\n PluginContext<TResolvedConfig>,\n TKey\n >[];\n if (options?.sequential === false) {\n results = (await Promise.all(\n hooks.map(async hook => {\n if (!isFunction(hook.handler)) {\n throw new Error(\n `Plugin hook handler for hook \"${key}\" is not a function.`\n );\n }\n\n return invokeHook(hook, [...args]);\n })\n )) as InferHookReturnType<PluginContext<TResolvedConfig>, TKey>[];\n } else {\n for (const hook of hooks) {\n if (!isFunction(hook.handler)) {\n throw new Error(\n `Plugin hook handler for hook \"${key}\" is not a function.`\n );\n }\n\n if (options?.result === \"first\" || options?.asNextParam === false) {\n results.push(\n (await Promise.resolve(\n invokeHook(hook, [...args])\n )) as InferHookReturnType<PluginContext<TResolvedConfig>, TKey>\n );\n if (\n options?.result === \"first\" &&\n isSet(results[results.length - 1])\n ) {\n break;\n }\n } else {\n const sequenceArgs = [...args];\n if (results.length > 0 && sequenceArgs.length > 0) {\n sequenceArgs[0] = isFunction(options.asNextParam)\n ? await Promise.resolve(options.asNextParam(results[0]))\n : results[0];\n }\n\n const result = await Promise.resolve(\n invokeHook(hook, [...sequenceArgs] as InferHookParameters<\n PluginContext<TResolvedConfig>,\n TKey\n >)\n );\n if (result) {\n if (options.result === \"last\") {\n results = [result];\n } else if (options.result === \"merge\" && options.merge) {\n results = [\n results.length > 0 && results[0]\n ? await Promise.resolve(options.merge(result, results[0]))\n : result\n ];\n } else {\n results = mergeResults(result, results);\n }\n }\n }\n }\n }\n\n const definedResults = results.filter(\n (\n result\n ): result is NonNullable<\n InferHookReturnType<PluginContext<TResolvedConfig>, TKey>\n > => isSet(result)\n );\n\n if (definedResults.length > 0) {\n let mergedResult = undefined as\n | InferHookReturnType<PluginContext<TResolvedConfig>, TKey>\n | undefined;\n\n for (const result of definedResults) {\n mergedResult = defu(\n result as Record<string, unknown>,\n mergedResult ?? {}\n ) as InferHookReturnType<PluginContext<TResolvedConfig>, TKey>;\n }\n\n return mergedResult;\n }\n }\n\n return undefined;\n}\n\nexport function extractHooks<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>(\n context: PluginContext<TResolvedConfig>,\n hooks: Record<string, HooksList<PluginContext<TResolvedConfig>>>,\n plugin: Plugin<PluginContext<TResolvedConfig>>,\n key: string,\n parentKey?: string\n): Record<string, HooksList<PluginContext<TResolvedConfig>>> {\n const combinedKey = parentKey ? `${parentKey}:${key}` : key;\n const pluginField = getField(plugin, combinedKey.replace(/:/g, \".\"));\n if (\n isPluginHookField<PluginContext<TResolvedConfig>>(combinedKey) &&\n isPluginHook(pluginField)\n ) {\n const pluginHook = pluginField;\n if (!isPluginHook(pluginHook)) {\n return hooks;\n }\n\n hooks[combinedKey] ??= {\n preEnforced: [] as HooksListItem<PluginContext<TResolvedConfig>>[],\n preOrdered: [] as HooksListItem<PluginContext<TResolvedConfig>>[],\n normal: [] as HooksListItem<PluginContext<TResolvedConfig>>[],\n postEnforced: [] as HooksListItem<PluginContext<TResolvedConfig>>[],\n postOrdered: [] as HooksListItem<PluginContext<TResolvedConfig>>[]\n };\n\n if (plugin.enforce) {\n const hookListOrder = `${plugin.enforce}Enforced` as HookListOrders;\n hooks[combinedKey][hookListOrder] ??= [] as HooksListItem<\n PluginContext<TResolvedConfig>\n >[];\n\n hooks[combinedKey][hookListOrder] = addPluginHook<\n PluginContext<TResolvedConfig>,\n PluginHookFields<PluginContext<TResolvedConfig>>\n >(context, plugin, pluginHook, hooks[combinedKey][hookListOrder]);\n\n return hooks;\n }\n\n if (isFunction(pluginHook) || !pluginHook.order) {\n hooks[combinedKey].normal ??= [];\n\n hooks[combinedKey].normal = addPluginHook<\n PluginContext<TResolvedConfig>,\n PluginHookFields<PluginContext<TResolvedConfig>>\n >(context, plugin, pluginHook, hooks[combinedKey].normal);\n\n return hooks;\n }\n\n const hookListOrder = `${pluginHook.order}Ordered` as HookListOrders;\n hooks[combinedKey][hookListOrder] ??= [];\n\n hooks[combinedKey][hookListOrder] = addPluginHook<\n PluginContext<TResolvedConfig>,\n PluginHookFields<PluginContext<TResolvedConfig>>\n >(context, plugin, pluginHook, hooks[combinedKey][hookListOrder]);\n\n return hooks;\n } else if (isSetObject(pluginField)) {\n return Object.keys(pluginField)\n .map(pluginKey =>\n extractHooks(context, hooks, plugin, pluginKey, combinedKey)\n )\n .reduce((ret, current) => {\n Object.keys(current).forEach(key => {\n ret[key] ??= {\n preEnforced: [] as HooksListItem<PluginContext<TResolvedConfig>>[],\n preOrdered: [] as HooksListItem<PluginContext<TResolvedConfig>>[],\n normal: [] as HooksListItem<PluginContext<TResolvedConfig>>[],\n postEnforced: [] as HooksListItem<PluginContext<TResolvedConfig>>[],\n postOrdered: [] as HooksListItem<PluginContext<TResolvedConfig>>[]\n };\n\n [\n \"preEnforced\",\n \"preOrdered\",\n \"normal\",\n \"postEnforced\",\n \"postOrdered\"\n ].forEach(order => {\n if (\n current[key]?.[\n order as keyof HooksList<PluginContext<TResolvedConfig>>\n ]\n ) {\n ret[key]![\n order as keyof HooksList<PluginContext<TResolvedConfig>>\n ] ??= [];\n ret[key]![\n order as keyof HooksList<PluginContext<TResolvedConfig>>\n ] = ret[key]![\n order as keyof HooksList<PluginContext<TResolvedConfig>>\n ]!.concat(\n current[key][\n order as keyof HooksList<PluginContext<TResolvedConfig>>\n ]!\n );\n }\n });\n });\n\n return ret;\n }, hooks);\n }\n\n return hooks;\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 CallHookOptions,\n EnvironmentContext,\n InferHookParameters,\n InferHookReturnType,\n LoggerMessage,\n LogLevel,\n Plugin,\n PluginContext,\n ResolvedConfig\n} from \"@powerlines/core\";\nimport { Unstable_PluginContext } from \"@powerlines/core/types/_internal\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { UnpluginMessage } from \"unplugin\";\nimport { PowerlinesEnvironmentContext } from \"./environment-context\";\n\n/**\n * Create a Proxy-based PluginContext\n *\n * @param pluginId - The unique identifier of the plugin\n * @param plugin - The plugin instance\n * @param environment - The environment context\n * @returns The proxied plugin context\n */\nexport function createPluginContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>(\n pluginId: string,\n plugin: Plugin<PluginContext<TResolvedConfig>>,\n environment: PowerlinesEnvironmentContext<TResolvedConfig>\n): Unstable_PluginContext<TResolvedConfig> {\n const logger = environment.extendLogger({\n plugin: plugin.name\n });\n\n const normalizeMessage = (\n message: string | UnpluginMessage\n ): LoggerMessage => {\n return {\n meta: {\n ...(isSetObject(message) ? message.meta : {}),\n environment: environment.config.environment.name,\n plugin: plugin.name\n },\n message: isString(message) ? message : message.message\n };\n };\n\n const callHookFn = async <TKey extends string>(\n hook: TKey,\n options: CallHookOptions,\n ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>\n ): Promise<\n InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined\n > => {\n return environment.$$internal.api.callHook(\n hook,\n {\n sequential: true,\n result: \"merge\",\n ...options,\n environment\n } as Parameters<typeof environment.$$internal.api.callHook>[1],\n ...(args as Parameters<typeof environment.$$internal.api.callHook>[2])\n ) as InferHookReturnType<PluginContext<TResolvedConfig>, TKey>;\n };\n\n const meta = {} as Record<string, any>;\n\n return new Proxy({} as Unstable_PluginContext<TResolvedConfig>, {\n get(_, prop) {\n if (prop === \"$$internal\") {\n return {\n ...environment.$$internal,\n environment,\n callHook: callHookFn,\n meta\n };\n }\n\n if (prop === \"api\") {\n return environment.$$internal.api;\n }\n\n if (prop === \"environment\") {\n return environment;\n }\n\n if (prop === \"id\") {\n return pluginId;\n }\n\n if (prop === \"logger\") {\n return logger;\n }\n\n if (prop === \"log\") {\n return (type: LogLevel, message: string | UnpluginMessage) => {\n logger.log(type, normalizeMessage(message));\n };\n }\n\n if (prop === \"fatal\") {\n return (message: string | UnpluginMessage) => {\n logger.error(normalizeMessage(message));\n };\n }\n\n if (prop === \"error\") {\n return (message: string | UnpluginMessage) => {\n logger.error(normalizeMessage(message));\n };\n }\n\n if (prop === \"warn\") {\n return (message: string | UnpluginMessage) => {\n logger.warn(normalizeMessage(message));\n };\n }\n\n if (prop === \"info\") {\n return (message: string | UnpluginMessage) => {\n logger.info(normalizeMessage(message));\n };\n }\n\n if (prop === \"debug\") {\n return (message: string | UnpluginMessage) => {\n logger.debug(normalizeMessage(message));\n };\n }\n\n if (prop === \"trace\") {\n return (message: string | UnpluginMessage) => {\n logger.trace(normalizeMessage(message));\n };\n }\n\n return environment[prop as keyof EnvironmentContext<TResolvedConfig>];\n },\n set(_, prop, value) {\n if (\n [\n \"$$internal\",\n \"id\",\n \"environment\",\n \"config\",\n \"log\",\n \"logger\",\n \"error\",\n \"warn\",\n \"plugins\",\n \"hooks\",\n \"addPlugin\",\n \"selectHooks\"\n ].includes(prop as string)\n ) {\n logger.warn(`Cannot set the read-only \"${String(prop)}\" property`);\n\n return false;\n }\n\n (environment as Record<string, any>)[prop as string] = value;\n return true;\n }\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 EnvironmentContextPlugin,\n EnvironmentResolvedConfig,\n ExecutionOptions,\n HooksList,\n HooksListItem,\n InferOverridableConfig,\n LogFn,\n Logger,\n LoggerOptions,\n Plugin,\n PluginConfig,\n PluginContext,\n ResolvedConfig,\n SelectHookResult,\n SelectHooksOptions\n} from \"@powerlines/core\";\nimport {\n DEFAULT_ENVIRONMENT,\n PLUGIN_NON_HOOK_FIELDS\n} from \"@powerlines/core/constants\";\nimport {\n dedupeHooklist,\n formatConfig,\n isPlugin,\n isPluginConfig,\n isPluginHookField,\n mergeConfig\n} from \"@powerlines/core/plugin-utils\";\nimport {\n Unstable_ContextInternal,\n Unstable_EnvironmentContext\n} from \"@powerlines/core/types/_internal\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { ArrayValues } from \"@stryke/types/array\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { extractHooks } from \"../_internal/helpers/hooks\";\nimport { PowerlinesContext } from \"./context\";\nimport { createPluginContext } from \"./plugin-context\";\n\nexport class PowerlinesEnvironmentContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>\n extends PowerlinesContext<EnvironmentResolvedConfig<TResolvedConfig>>\n implements Unstable_EnvironmentContext<TResolvedConfig>\n{\n /**\n * Internal references storage\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n #internal = {} as Unstable_ContextInternal<TResolvedConfig>;\n\n /**\n * The hooks registered by plugins in this environment\n */\n #hooks: Record<string, HooksList<PluginContext<TResolvedConfig>>> = {};\n\n /**\n * Create a new context from the config.\n *\n * @param initialOptions - The resolved execution options.\n * @param config - The user configuration options.\n * @param overriddenConfig - The configuration options that should override all other configuration sources, such as CLI flags or environment variables. This is used to ensure that certain configuration values take precedence over any other settings defined in the user configuration or environment configuration, allowing for dynamic overrides based on the execution context.\n * @param environment - The resolved environment configuration, which may include additional properties or modifications made during the configuration loading process. This is used to provide context about the environment in which the command is being executed, allowing for environment-specific behavior and configuration resolution.\n * @returns A promise that resolves to an instance of the PowerlinesEnvironmentContext class, initialized with the provided configuration and environment data.\n */\n public static async createEnvironment<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n >(\n initialOptions: ExecutionOptions,\n config: TResolvedConfig,\n overriddenConfig: InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >,\n environment: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n ): Promise<PowerlinesEnvironmentContext<TResolvedConfig>> {\n const context = new PowerlinesEnvironmentContext<TResolvedConfig>(\n initialOptions,\n config,\n overriddenConfig\n );\n await context.setEnvironmentConfig(environment);\n\n return context;\n }\n\n /**\n * The configuration options provided by plugins added by the user (and other plugins)\n */\n protected override environmentConfig: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"] =\n {} as EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"];\n\n /**\n * The list of plugins applied to this environment\n */\n public plugins: EnvironmentContextPlugin<TResolvedConfig>[] = [];\n\n /**\n * Internal context fields and methods\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public get $$internal(): Unstable_ContextInternal<TResolvedConfig> {\n return this.#internal;\n }\n\n /**\n * Internal context fields and methods\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public set $$internal(value: Unstable_ContextInternal<TResolvedConfig>) {\n this.#internal = value;\n }\n\n /**\n * The unique identifier of the environment associated with this context, which can be used for logging and other purposes to distinguish between different environments in the same process.\n */\n public get id(): string {\n return this.config.environment.id;\n }\n\n /**\n * The hooks registered by plugins in this environment\n */\n public get hooks(): Record<\n string,\n HooksList<PluginContext<TResolvedConfig>>\n > {\n return this.#hooks;\n }\n\n /**\n * A setter function to populate the environment config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the environment configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any environment configuration provided during execution.\n *\n * @param config - The environment configuration values to set.\n * @returns A promise that resolves when the environment configuration values have been set.\n */\n protected async setEnvironmentConfig(\n config: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n ): Promise<void> {\n this.logger.debug({\n meta: { category: \"config\" },\n message: `Updating environment configuration object: \\n${formatConfig(config)}`\n });\n\n this.environmentConfig = config;\n await this.resolveConfig();\n }\n\n /**\n * Create a new logger instance\n *\n * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.\n * @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.\n */\n public override createLogger(options: LoggerOptions, logFn?: LogFn): Logger {\n return super.createLogger(\n {\n ...options,\n environment: this.config.environment?.name\n },\n logFn\n );\n }\n\n /**\n * Extend the base logger with additional configuration options\n *\n * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.\n * @returns A new logger client instance that extends the base logger with the provided configuration options.\n */\n public override extendLogger(options: LoggerOptions): Logger {\n return super.extendLogger({\n ...options,\n environment: this.config.environment?.name\n });\n }\n\n public async addPlugin(\n plugin: Plugin<PluginContext<TResolvedConfig>>\n ): Promise<void> {\n let resolvedPlugin = plugin;\n if (isFunction(plugin.applyToEnvironment)) {\n const result = (await Promise.resolve(\n plugin.applyToEnvironment(this.config.environment) as Promise<any>\n )) as boolean | PluginConfig<PluginContext<TResolvedConfig>>;\n\n if (!result || (isObject(result) && Object.keys(result).length === 0)) {\n return;\n }\n\n if (isPluginConfig<PluginContext<TResolvedConfig>>(result)) {\n return this.$$internal.addPlugin(result);\n }\n\n resolvedPlugin = isPlugin<PluginContext<TResolvedConfig>>(result)\n ? result\n : plugin;\n }\n\n const id = uuid();\n const context = createPluginContext<TResolvedConfig>(\n id,\n resolvedPlugin,\n this\n );\n\n this.plugins.push({\n id,\n plugin: resolvedPlugin,\n context\n });\n\n this.#hooks = Object.entries(\n Object.keys(resolvedPlugin)\n .filter(\n key =>\n !PLUGIN_NON_HOOK_FIELDS.includes(\n key as ArrayValues<typeof PLUGIN_NON_HOOK_FIELDS>\n )\n )\n .reduce(\n (ret, key) =>\n extractHooks<TResolvedConfig>(context, ret, resolvedPlugin, key),\n this.hooks\n )\n ).reduce(\n (ret, [key, value]) => {\n if (isSetObject(value)) {\n Object.entries(value).forEach(([type, list]) => {\n ret[key] ??= {};\n ret[key][type as keyof (typeof ret)[typeof key]] =\n dedupeHooklist<PluginContext<TResolvedConfig>>(list);\n });\n }\n\n return ret;\n },\n {} as Record<string, HooksList<PluginContext<TResolvedConfig>>>\n );\n }\n\n /**\n * Retrieves the hook handlers for a specific hook name\n */\n public selectHooks<TKey extends string>(\n key: TKey,\n options?: SelectHooksOptions\n ): SelectHookResult<PluginContext<TResolvedConfig>, TKey> {\n const result = [] as SelectHookResult<PluginContext<TResolvedConfig>, TKey>;\n\n if (\n isPluginHookField<PluginContext<TResolvedConfig>>(key) &&\n this.hooks[key]\n ) {\n if (this.hooks[key]) {\n if (options?.order) {\n const mapHooksToResult = (\n hooksList: HooksListItem<PluginContext<TResolvedConfig>, string>[]\n ): SelectHookResult<PluginContext<TResolvedConfig>, TKey> =>\n hooksList.map(hook => {\n const plugin = this.plugins.find(\n p => p.plugin.name === hook.plugin.name\n );\n if (!plugin) {\n throw new Error(\n `Could not find plugin context for plugin \"${\n hook.plugin.name\n }\".`\n );\n }\n\n return {\n handler: hook.handler,\n plugin: hook.plugin,\n context: plugin.context\n };\n });\n\n if (options?.order === \"pre\") {\n result.push(...mapHooksToResult(this.hooks[key].preOrdered ?? []));\n result.push(...mapHooksToResult(this.hooks[key].preEnforced ?? []));\n } else if (options?.order === \"post\") {\n result.push(...mapHooksToResult(this.hooks[key].postOrdered ?? []));\n result.push(\n ...mapHooksToResult(this.hooks[key].postEnforced ?? [])\n );\n } else {\n result.push(...mapHooksToResult(this.hooks[key].normal ?? []));\n }\n } else {\n result.push(...this.selectHooks(key, { order: \"pre\" }));\n result.push(...this.selectHooks(key, { order: \"normal\" }));\n result.push(...this.selectHooks(key, { order: \"post\" }));\n }\n }\n }\n\n return result;\n }\n\n protected constructor(\n options: ExecutionOptions,\n config: TResolvedConfig,\n overriddenConfig: InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >\n ) {\n super(options, config.initialConfig);\n\n this.userConfig =\n config.userConfig ?? ({} as TResolvedConfig[\"userConfig\"]);\n this.inlineConfig =\n config.inlineConfig ?? ({} as TResolvedConfig[\"inlineConfig\"]);\n this.pluginConfig = config.pluginConfig ?? {};\n this.overriddenConfig = overriddenConfig;\n }\n\n /**\n * A function to merge the various configuration objects (initial, user, inline, and plugin) into a single resolved configuration object that can be used throughout the Powerlines process. This function takes into account the different sources of configuration and their respective priorities, ensuring that the final configuration reflects the intended settings for the project. The merged configuration is then returned as a new object that can be accessed through the `config` property of the context.\n *\n * @returns The merged configuration object that combines the initial, user, inline, and plugin configurations.\n */\n protected override mergeConfig(): EnvironmentResolvedConfig<TResolvedConfig> {\n return mergeConfig(\n {\n ...omit(this.environmentConfig ?? {}, [\n \"name\",\n \"ssr\",\n \"preview\",\n \"consumer\",\n \"runtime\"\n ]),\n environment: {\n name: this.environmentConfig?.name || DEFAULT_ENVIRONMENT\n },\n environmentConfig: this.environmentConfig ?? {}\n },\n super.mergeConfig()\n ) as EnvironmentResolvedConfig<TResolvedConfig>;\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 EnvironmentContext,\n EnvironmentResolvedConfig,\n ExecutionContext,\n InferOverridableConfig,\n LogFn,\n Logger,\n LoggerOptions,\n Plugin,\n PluginContext,\n ResolvedConfig\n} from \"@powerlines/core\";\nimport { ExecutionOptions } from \"@powerlines/core\";\nimport { GLOBAL_ENVIRONMENT } from \"@powerlines/core/constants\";\nimport type {\n Unstable_ContextInternal,\n Unstable_EnvironmentContext\n} from \"@powerlines/core/types/_internal\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFile } from \"@stryke/fs/json\";\nimport { deepClone } from \"@stryke/helpers/deep-clone\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { PackageJson } from \"@stryke/types/package-json\";\nimport chalk from \"chalk\";\nimport {\n createDefaultEnvironment,\n createEnvironment\n} from \"../_internal/helpers/environment\";\nimport { PowerlinesContext } from \"./context\";\nimport { PowerlinesEnvironmentContext } from \"./environment-context\";\n\nexport class PowerlinesExecutionContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>\n extends PowerlinesContext<TResolvedConfig>\n implements ExecutionContext<TResolvedConfig>\n{\n /**\n * Internal references storage\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n #internal = {} as Unstable_ContextInternal<TResolvedConfig>;\n\n /**\n * A record of all environments by name\n */\n #environments: Record<string, Unstable_EnvironmentContext<TResolvedConfig>> =\n {};\n\n /**\n * The plugins added to this execution context, which may be used to track the plugins that have been added to the context and ensure that they are properly registered and executed during the build process. This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n */\n #plugins: Plugin<PluginContext<TResolvedConfig>>[] = [];\n\n /**\n * Create a new Storm context from the workspace root and user config.\n *\n * @param options - The options for resolving the context.\n * @returns A promise that resolves to the new context.\n */\n public static override async fromInitialConfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n >(\n options: ExecutionOptions,\n initialConfig: TResolvedConfig[\"initialConfig\"]\n ): Promise<PowerlinesExecutionContext<TResolvedConfig>> {\n const context = new PowerlinesExecutionContext<TResolvedConfig>(\n options,\n initialConfig\n );\n await context.init();\n\n return context;\n }\n\n /**\n * Create a new Storm context from the workspace root and user config.\n *\n * @param options - The options for resolving the context.\n * @returns A promise that resolves to the new context.\n */\n public static async fromInlineConfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n >(\n options: ExecutionOptions,\n initialConfig: TResolvedConfig[\"initialConfig\"],\n inlineConfig: TResolvedConfig[\"inlineConfig\"]\n ): Promise<PowerlinesExecutionContext<TResolvedConfig>> {\n const context = new PowerlinesExecutionContext<TResolvedConfig>(\n options,\n initialConfig\n );\n await context.init();\n await context.setInlineConfig(inlineConfig);\n\n return context;\n }\n\n /**\n * Internal context fields and methods\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public get $$internal(): Unstable_ContextInternal<TResolvedConfig> {\n return this.#internal;\n }\n\n /**\n * Internal context fields and methods\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public set $$internal(value: Unstable_ContextInternal<TResolvedConfig>) {\n this.#internal = value;\n\n for (const environment of Object.values(this.environments)) {\n environment.$$internal = value;\n }\n }\n\n /**\n * The unique identifier of the execution context, which can be used for logging and other purposes to distinguish between different executions in the same process.\n */\n public get id(): string {\n return this.options.executionId;\n }\n\n /**\n * A record of all environments by name\n */\n public get environments(): Record<\n string,\n Unstable_EnvironmentContext<TResolvedConfig>\n > {\n return this.#environments;\n }\n\n public get plugins(): Array<Plugin<PluginContext<TResolvedConfig>>> {\n return this.#plugins;\n }\n\n /**\n * Creates a new instance.\n *\n * @param options - The options to use for creating the context, including the resolved configuration and workspace settings.\n * @param initialConfig - The initial configuration options to use for the context, which can be used to provide default values for configuration options that may be overridden by user configuration or inline configuration. This is typically the configuration options provided by the user in a configuration file on disk, and can include any relevant settings such as environment definitions, plugin configurations, and other parameters that may be relevant to the execution of a Powerlines command.\n */\n protected constructor(\n options: ExecutionOptions,\n initialConfig: TResolvedConfig[\"initialConfig\"] = {}\n ) {\n super(options, initialConfig);\n this.initialOptions = options;\n this.initialConfig = initialConfig;\n }\n\n /**\n * A setter function to populate the inline config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the inline configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any inline configuration provided during execution.\n *\n * @param config - The inline configuration values to set.\n * @returns A promise that resolves when the inline configuration values have been set.\n */\n public override async setInlineConfig(\n config: TResolvedConfig[\"inlineConfig\"]\n ): Promise<void> {\n await super.setInlineConfig(config);\n if (this.inlineConfig.command === \"new\") {\n const workspacePackageJsonPath = joinPaths(\n this.config.cwd,\n \"package.json\"\n );\n if (!existsSync(workspacePackageJsonPath)) {\n throw new Error(\n `The workspace package.json file could not be found at ${workspacePackageJsonPath}`\n );\n }\n\n this.packageJson = await readJsonFile<PackageJson>(\n workspacePackageJsonPath\n );\n }\n }\n\n /**\n * Create a new logger instance\n *\n * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.\n * @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.\n */\n public override createLogger(options: LoggerOptions, logFn?: LogFn): Logger {\n return super.createLogger(\n {\n ...options,\n executionId: this.id,\n executionIndex: this.options.executionIndex\n },\n logFn\n );\n }\n\n /**\n * Extend the base logger with additional configuration options\n *\n * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.\n * @returns A new logger client instance that extends the base logger with the provided configuration options.\n */\n public override extendLogger(options: LoggerOptions): Logger {\n return super.extendLogger({\n ...options,\n executionId: this.id,\n executionIndex: this.options.executionIndex\n });\n }\n\n /**\n * A function to copy the context and update the fields for a specific environment\n *\n * @param environment - The environment configuration to use.\n * @returns A new context instance with the updated environment.\n */\n public async createEnvironment(\n environment: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n ): Promise<Unstable_EnvironmentContext<TResolvedConfig>> {\n const context =\n await PowerlinesEnvironmentContext.createEnvironment<TResolvedConfig>(\n deepClone(this.initialOptions),\n deepClone(this.config) as TResolvedConfig,\n deepClone(this.overriddenConfig) as InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >,\n deepClone(\n environment\n ) as EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n );\n\n context.$$internal = this.$$internal;\n\n context.dependencies = deepClone<typeof this.dependencies>(\n this.dependencies\n );\n context.devDependencies = deepClone<typeof this.devDependencies>(\n this.devDependencies\n );\n context.persistedMeta = deepClone<typeof this.persistedMeta>(\n this.persistedMeta\n );\n context.resolvePatterns = deepClone<typeof this.resolvePatterns>(\n this.resolvePatterns\n );\n\n context.powerlinesPath ??= this.powerlinesPath;\n context.resolver ??= this.resolver;\n\n context.plugins = [];\n for (const plugin of this.plugins) {\n await context.addPlugin(plugin);\n }\n\n for (const [key, value] of Object.entries(this)) {\n if (\n ![\n \"fs\",\n \"$$internal\",\n \"initialOptions\",\n \"options\",\n \"config\",\n \"initialConfig\",\n \"inlineConfig\",\n \"userConfig\",\n \"pluginConfig\",\n \"overriddenConfig\",\n \"environmentConfig\",\n \"dependencies\",\n \"devDependencies\",\n \"persistedMeta\",\n \"packageJson\",\n \"projectJson\",\n \"tsconfig\",\n \"resolver\",\n \"plugins\",\n \"environments\"\n ].includes(key)\n ) {\n if (isObject(value) || Array.isArray(value)) {\n (context as any)[key] = deepClone(value);\n } else {\n (context as any)[key] = value;\n }\n }\n }\n\n return context;\n }\n\n /**\n * Update the context using a new inline configuration options\n */\n public override async resolveConfig() {\n await super.resolveConfig();\n\n await Promise.all(\n toArray(\n this.config.environments &&\n Object.keys(this.config.environments).length > 0\n ? Object.keys(this.config.environments).map(name =>\n createEnvironment(name, this.config)\n )\n : createDefaultEnvironment(this.config)\n ).map(async env => {\n this.#environments[env.name] = await this.createEnvironment(env);\n })\n );\n }\n\n /**\n * Add a plugin to the API context and all environments\n *\n * @param plugin - The plugin to add.\n */\n public async addPlugin(plugin: Plugin<PluginContext<TResolvedConfig>>) {\n this.plugins.push(plugin);\n\n await Promise.all(\n Object.keys(this.environments).map(async name => {\n await this.environments[name]!.addPlugin(plugin);\n })\n );\n }\n\n /**\n * Get an environment by name, or the default environment if no name is provided\n *\n * @param name - The name of the environment to retrieve.\n * @returns The requested environment context.\n */\n public async getEnvironment(name?: string) {\n let environment: EnvironmentContext<TResolvedConfig> | undefined;\n if (name) {\n environment = this.environments[name];\n }\n\n if (Object.keys(this.environments).length === 1) {\n environment = this.environments[Object.keys(this.environments)[0]!];\n\n this.trace({\n meta: { category: \"plugins\" },\n message: `Applying the only configured environment: ${chalk.bold.cyanBright(\n environment?.config.environment?.name\n )}`\n });\n }\n\n if (!environment) {\n if (name) {\n throw new Error(`Environment \"${name}\" not found.`);\n }\n\n environment =\n await PowerlinesEnvironmentContext.createEnvironment<TResolvedConfig>(\n deepClone(this.options),\n deepClone(this.config) as TResolvedConfig,\n deepClone(this.overriddenConfig) as InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >,\n deepClone(\n createDefaultEnvironment(this.config)\n ) as EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n );\n\n environment.plugins = [];\n for (const plugin of this.plugins) {\n await environment.addPlugin(plugin);\n }\n\n this.warn({\n meta: { category: \"plugins\" },\n message: `No environment specified, and no default environment found. Using a temporary default environment: ${chalk.bold.cyanBright(\n environment.config.environment?.name\n )}`\n });\n }\n\n return environment;\n }\n\n /**\n * A safe version of `getEnvironment` that returns `undefined` if the environment is not found\n *\n * @param name - The name of the environment to retrieve.\n * @returns The requested environment context or `undefined` if not found.\n */\n public async getEnvironmentSafe(\n name?: string\n ): Promise<EnvironmentContext<TResolvedConfig> | undefined> {\n try {\n return await this.getEnvironment(name);\n } catch {\n return undefined;\n }\n }\n\n /**\n * A function to merge all configured environments into a single context.\n *\n * @remarks\n * If only one environment is configured, that environment will be returned directly.\n *\n * @returns A promise that resolves to a merged/global environment context.\n */\n public async toEnvironment(): Promise<EnvironmentContext<TResolvedConfig>> {\n let environment: EnvironmentContext<TResolvedConfig>;\n if (Object.keys(this.environments).length > 1) {\n environment = await this.createEnvironment(\n createEnvironment<TResolvedConfig>(GLOBAL_ENVIRONMENT, this.config)\n );\n\n this.debug({\n meta: { category: \"plugins\" },\n message: `Combined all ${Object.keys(this.environments).length} environments into a single global context.`\n });\n } else {\n environment = await this.getEnvironment();\n }\n\n return environment;\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 { Context } from \"@powerlines/core\";\nimport defu from \"defu\";\nimport {\n CompilerOptions,\n FileSystemHost,\n InMemoryFileSystemHost,\n Project,\n ProjectOptions,\n RuntimeDirEntry\n} from \"ts-morph\";\n\nexport class VirtualFileSystemHost\n extends InMemoryFileSystemHost\n implements FileSystemHost\n{\n #context: Context;\n\n public constructor(context: Context) {\n super();\n\n this.#context = context;\n }\n\n public override deleteSync(path: string) {\n this.#context.fs.removeSync(path);\n }\n\n public override readDirSync(dirPath: string): RuntimeDirEntry[] {\n if (!this.#context.fs.isDirectorySync(dirPath)) {\n return [];\n }\n\n return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {\n const fullPath = this.#context.fs.resolveSync(entry);\n if (fullPath) {\n ret.push({\n name: entry,\n isDirectory: this.#context.fs.isDirectorySync(fullPath),\n isFile: this.#context.fs.isFileSync(fullPath),\n isSymlink: false\n });\n }\n\n return ret;\n }, [] as RuntimeDirEntry[]);\n }\n\n public override async readFile(filePath: string) {\n if (!this.#context.fs.isFileSync(filePath)) {\n return \"\";\n }\n\n return (await this.#context.fs.read(filePath))!;\n }\n\n public override readFileSync(filePath: string) {\n if (!this.#context.fs.isFileSync(filePath)) {\n return \"\";\n }\n\n return this.#context.fs.readSync(filePath)!;\n }\n\n public override async writeFile(filePath: string, fileText: string) {\n return this.#context.fs.write(filePath, fileText);\n }\n\n public override writeFileSync(filePath: string, fileText: string) {\n this.#context.fs.writeSync(filePath, fileText);\n }\n\n public override async mkdir(dirPath: string) {\n await this.#context.fs.mkdir(dirPath);\n }\n\n public override mkdirSync(dirPath: string) {\n this.#context.fs.mkdirSync(dirPath);\n }\n\n public override async move(srcPath: string, destPath: string) {\n await this.#context.fs.move(srcPath, destPath);\n }\n\n public override moveSync(srcPath: string, destPath: string) {\n this.#context.fs.moveSync(srcPath, destPath);\n }\n\n public override async copy(srcPath: string, destPath: string) {\n await this.#context.fs.copy(srcPath, destPath);\n }\n\n public override copySync(srcPath: string, destPath: string) {\n this.#context.fs.copySync(srcPath, destPath);\n }\n\n public override async fileExists(filePath: string) {\n return this.#context.fs.isFile(filePath);\n }\n\n public override fileExistsSync(filePath: string) {\n return this.#context.fs.isFileSync(filePath);\n }\n\n public override async directoryExists(dirPath: string) {\n return this.#context.fs.isDirectory(dirPath);\n }\n\n public override directoryExistsSync(dirPath: string): boolean {\n return this.#context.fs.isDirectorySync(dirPath);\n }\n\n public override realpathSync(path: string) {\n return this.#context.fs.resolveSync(path) || path;\n }\n\n public override getCurrentDirectory() {\n return this.#context.config.cwd;\n }\n\n public override async glob(\n patterns: ReadonlyArray<string>\n ): Promise<string[]> {\n return this.#context.fs.glob(patterns as string[]);\n }\n\n public override globSync(patterns: ReadonlyArray<string>): string[] {\n return this.#context.fs.globSync(patterns as string[]);\n }\n}\n\n/**\n * Create a ts-morph {@link Project} instance used for type reflection and module manipulation during processing\n *\n * @param context - The Powerlines context\n * @returns A ts-morph {@link Project} instance\n */\nexport function createProgram(\n context: Context,\n override: Partial<ProjectOptions>\n): Project {\n context.debug(\n `Creating ts-morph Project instance with configuration from: ${\n context.tsconfig.tsconfigFilePath\n }.`\n );\n\n const project = new Project(\n defu(override ?? {}, {\n skipAddingFilesFromTsConfig: false,\n tsConfigFilePath: context.tsconfig.tsconfigFilePath,\n fileSystem: new VirtualFileSystemHost(context),\n compilerOptions: defu(context.tsconfig.options ?? {}, {\n lib: [\"lib.esnext.full.d.ts\"]\n }) as CompilerOptions\n })\n );\n\n return project;\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 { Context } from \"@powerlines/core\";\nimport { format } from \"@powerlines/core/lib/utilities/format\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { prettyBytes } from \"@stryke/string-format/pretty-bytes\";\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 { DiagnosticCategory, Node, Project, SourceFile } from \"ts-morph\";\nimport { createProgram } from \"../../typescript/ts-morph\";\n\ninterface ModuleExportSpecifier {\n name: string;\n alias?: string;\n default?: boolean;\n type?: boolean;\n}\n\ninterface ModuleReference {\n name?: string;\n specifiers?: ModuleExportSpecifier[];\n all?: boolean;\n}\n\ninterface ImportModuleReference extends ModuleReference {\n name: string;\n ambient?: boolean;\n}\n\ninterface ExportModuleReference extends ModuleReference {\n text: string;\n fullText: string;\n comment?: string;\n}\n\ninterface ModuleDeclaration {\n name: string;\n text: string;\n sourceFile: SourceFile;\n comment?: string;\n exports: (ExportModuleReference | string)[];\n imports: ImportModuleReference[];\n}\n\nexport interface TypegenContext {\n context: Context;\n emitted: Map<string, string>;\n modules: ModuleDeclaration[];\n}\n\n/**\n * Formats the generated TypeScript types source code.\n *\n * @param code - The generated TypeScript code.\n * @returns The formatted TypeScript code.\n */\nexport function formatTypes(code = \"\"): string {\n return code.replaceAll(\"#private;\", \"\").replace(/__Ω/g, \"\");\n}\n\nasync function extractModuleDeclarations(\n ctx: TypegenContext,\n filePath: string,\n name: string,\n text: string\n): Promise<ModuleDeclaration> {\n const imports: ImportModuleReference[] = [];\n const exports: (ExportModuleReference | string)[] = [];\n\n const comment = text\n .match(\n new RegExp(\n `\\\\/\\\\*\\\\*(?s:.)*?@module\\\\s+${\n ctx.context.config.framework\n }:${name}(?s:.)*?\\\\*\\\\/\\\\s+`\n )\n )\n ?.find(comment => isSetString(comment?.trim()));\n\n // Parse the emitted .d.ts content using an in-memory ts-morph project\n const project = new Project({ useInMemoryFileSystem: true });\n const sourceFile = project.createSourceFile(\"module.d.ts\", text);\n\n // Collect /// <reference types=\"...\" /> directives as ambient dependencies\n for (const ref of sourceFile.getTypeReferenceDirectives()) {\n if (\n ref.getFileName() &&\n !ctx.context.builtins.some(builtin => ref.getFileName().endsWith(builtin))\n ) {\n imports.push({\n name: ref.getFileName(),\n ambient: true\n });\n }\n }\n\n for (const statement of sourceFile.getStatements()) {\n // --- Import declarations ---\n if (Node.isImportDeclaration(statement)) {\n const moduleSpec = statement.getModuleSpecifierValue();\n\n // Namespace import: import * as X from '...'\n if (statement.getNamespaceImport()) {\n imports.push({\n name: moduleSpec,\n specifiers: [\n {\n name: statement.getNamespaceImport()!.getText()\n }\n ],\n all: true\n });\n }\n\n // Named imports: import X from '...' or import { A, B as C } from '...'\n else if (\n statement.getNamedImports().length > 0 ||\n statement.getDefaultImport()\n ) {\n const specifiers: ModuleExportSpecifier[] = [];\n if (statement.getDefaultImport()) {\n specifiers.push({\n name: statement.getDefaultImport()!.getText(),\n default: true,\n type: statement.isTypeOnly()\n });\n }\n\n statement.getNamedImports().forEach(named => {\n specifiers.push({\n name: named.getName(),\n alias: named.getAliasNode()?.getText(),\n type: statement.isTypeOnly()\n });\n });\n\n imports.push({\n name: moduleSpec,\n specifiers\n });\n }\n }\n\n // --- Export declarations ---\n else if (Node.isExportDeclaration(statement)) {\n const moduleSpec = statement.getModuleSpecifierValue();\n if (moduleSpec) {\n // Resolve the module specifier\n let resolvedSpec = moduleSpec;\n if (!ctx.context.builtins.includes(moduleSpec)) {\n if (ctx.emitted.has(moduleSpec)) {\n resolvedSpec = ctx.emitted.get(moduleSpec)!;\n } else {\n const resolvedModule = await ctx.context.resolve(\n moduleSpec,\n filePath\n );\n if (isSetString(resolvedModule?.id)) {\n resolvedSpec = resolvedModule.id;\n }\n }\n }\n\n // Re-export from another module\n const namedExports = statement.getNamedExports();\n if (namedExports.length > 0) {\n exports.push({\n name: resolvedSpec,\n text: statement.getText(),\n fullText: statement.getFullText(),\n specifiers: namedExports.map(named => ({\n name: named.getName(),\n alias: named.getAliasNode()?.getText(),\n type: statement.isTypeOnly()\n })),\n comment: statement\n .getLeadingCommentRanges()\n .filter(\n c =>\n isSetString(c.getText().trim()) &&\n !c.getText().includes(\"@module\")\n )\n .map(c => c.getText().trim())\n .join(\"\\n\")\n .trim()\n });\n } else {\n // export * from '...'\n exports.push({\n name: resolvedSpec,\n text: statement.getText(),\n fullText: statement.getFullText(),\n all: true,\n comment: statement\n .getLeadingCommentRanges()\n .filter(\n c =>\n isSetString(c.getText().trim()) &&\n !c.getText().includes(\"@module\")\n )\n .map(c => c.getText().trim())\n .join(\"\\n\")\n .trim()\n });\n }\n } else {\n const specifiers = statement.getNamedExports().map(named => ({\n name: named.getName(),\n alias: named.getAliasNode()?.getText(),\n type: statement.isTypeOnly()\n }));\n if (specifiers.length > 0) {\n exports.push({\n text: statement.getText(),\n fullText: statement.getFullText(),\n specifiers,\n comment: statement\n .getLeadingCommentRanges()\n .filter(\n c =>\n isSetString(c.getText().trim()) &&\n !c.getText().includes(\"@module\")\n )\n .map(c => c.getText().trim())\n .join(\"\\n\")\n });\n }\n }\n }\n\n // --- Export assignments (export default ...) ---\n else if (Node.isExportAssignment(statement)) {\n exports.push({\n text: statement.getText(),\n fullText: statement.getFullText(),\n comment: statement\n .getLeadingCommentRanges()\n .filter(\n c =>\n isSetString(c.getText().trim()) &&\n !c.getText().includes(\"@module\")\n )\n .map(c => c.getText().trim())\n .join(\"\\n\")\n });\n }\n\n // --- Function declarations (export declare function ...) ---\n else if (\n Node.isFunctionDeclaration(statement) &&\n statement.isExported() &&\n statement.getNameNode()\n ) {\n exports.push({\n text: statement.getText(),\n fullText: statement.getFullText(),\n specifiers: [\n {\n name: statement.getNameNode()!.getText()\n }\n ],\n comment: statement\n .getLeadingCommentRanges()\n .filter(\n c =>\n isSetString(c.getText().trim()) &&\n !c.getText().includes(\"@module\")\n )\n .map(c => c.getText().trim())\n .join(\"\\n\")\n });\n }\n\n // --- Variable statements (export declare const ...) ---\n else if (Node.isVariableStatement(statement) && statement.isExported()) {\n exports.push({\n text: statement.getText(),\n fullText: statement.getFullText(),\n specifiers: statement\n .getDeclarationList()\n .getDeclarations()\n .filter(\n decl => decl.getNameNode() && Node.isIdentifier(decl.getNameNode())\n )\n .map(decl => ({ name: decl.getNameNode().getText() })),\n comment: statement\n .getLeadingCommentRanges()\n .filter(\n c =>\n isSetString(c.getText().trim()) &&\n !c.getText().includes(\"@module\")\n )\n .map(c => c.getText().trim())\n .join(\"\\n\")\n });\n }\n\n // --- Class declarations (export declare class ...) ---\n else if (Node.isClassDeclaration(statement) && statement.isExported()) {\n const nameNode = statement.getNameNode();\n exports.push({\n text: statement.getText(),\n fullText: statement.getFullText(),\n specifiers: nameNode ? [{ name: nameNode.getText() }] : undefined,\n comment: statement\n .getLeadingCommentRanges()\n .filter(\n c =>\n isSetString(c.getText().trim()) &&\n !c.getText().includes(\"@module\")\n )\n .map(c => c.getText().trim())\n .join(\"\\n\")\n });\n }\n\n // --- Interface declarations (export declare interface ...) ---\n else if (Node.isInterfaceDeclaration(statement) && statement.isExported()) {\n const nameNode = statement.getNameNode();\n exports.push({\n text: statement.getText(),\n fullText: statement.getFullText(),\n specifiers: nameNode ? [{ name: nameNode.getText() }] : undefined,\n comment: statement\n .getLeadingCommentRanges()\n .filter(\n c =>\n isSetString(c.getText().trim()) &&\n !c.getText().includes(\"@module\")\n )\n .map(c => c.getText().trim())\n .join(\"\\n\")\n });\n }\n\n // --- Type alias declarations (export declare type ...) ---\n else if (Node.isTypeAliasDeclaration(statement) && statement.isExported()) {\n const nameNode = statement.getNameNode();\n exports.push({\n text: statement.getText(),\n fullText: statement.getFullText(),\n specifiers: nameNode ? [{ name: nameNode.getText() }] : undefined,\n comment: statement\n .getLeadingCommentRanges()\n .filter(\n c =>\n isSetString(c.getText().trim()) &&\n !c.getText().includes(\"@module\")\n )\n .map(c => c.getText().trim())\n .join(\"\\n\")\n });\n }\n\n // --- All other statements (declarations) ---\n else if (\n ctx.context.config.output.sourceMap ||\n !statement.getFullText().includes(\"//# sourceMappingURL=\")\n ) {\n exports.push({\n text: statement.getText(),\n fullText: statement.getFullText(),\n comment: statement\n .getLeadingCommentRanges()\n .filter(\n c =>\n isSetString(c.getText().trim()) &&\n !c.getText().includes(\"@module\")\n )\n .map(c => c.getText().trim())\n .join(\"\\n\")\n });\n }\n }\n\n return {\n name,\n text,\n sourceFile,\n comment,\n imports,\n exports\n };\n}\n\n/**\n * Emits TypeScript declaration types for the provided files using the given TypeScript configuration.\n *\n * @param context - The context containing options and environment paths.\n * @param files - The list of files to generate types for.\n * @returns A promise that resolves to the generated TypeScript declaration types.\n */\nexport async function emitBuiltinTypes<TContext extends Context>(\n context: TContext,\n files: string[]\n): Promise<{ code: string; directives: string[] }> {\n if (files.length === 0) {\n context.debug(\n \"No files provided for TypeScript types generation. Typescript compilation for built-in modules will be skipped.\"\n );\n return { code: \"\", directives: [] };\n }\n\n context.debug(\n `Running the TypeScript compiler for ${\n files.length\n } generated built-in module files.`\n );\n\n const program = createProgram(context, {\n skipAddingFilesFromTsConfig: true,\n compilerOptions: {\n declaration: true,\n declarationMap: false,\n emitDeclarationOnly: true,\n sourceMap: false,\n outDir: replacePath(context.builtinsPath, context.config.cwd),\n composite: false,\n incremental: false,\n tsBuildInfoFile: undefined\n }\n });\n\n program.addSourceFilesAtPaths(files);\n const emitResult = program.emitToMemory({ emitOnlyDtsFiles: true });\n\n const diagnostics = emitResult.getDiagnostics();\n if (diagnostics && diagnostics.length > 0) {\n if (diagnostics.some(d => d.getCategory() === DiagnosticCategory.Error)) {\n throw new Error(\n `The Typescript emit process failed while generating built-in types: \\n ${diagnostics\n .filter(d => d.getCategory() === DiagnosticCategory.Error)\n .map(\n d =>\n `-${d.getSourceFile() ? `${d.getSourceFile()?.getFilePath()}:` : \"\"} ${String(\n d.getMessageText()\n )} (at ${d.getStart()}:${d.getLength()})`\n )\n .join(\"\\n\")}`\n );\n } else if (\n diagnostics.some(d => d.getCategory() === DiagnosticCategory.Warning)\n ) {\n context.warn(\n `The Typescript emit process completed with warnings while generating built-in types: \\n ${diagnostics\n .filter(d => d.getCategory() === DiagnosticCategory.Warning)\n .map(\n d =>\n `-${d.getSourceFile() ? `${d.getSourceFile()?.getFilePath()}:` : \"\"} ${String(\n d.getMessageText()\n )} (at ${d.getStart()}:${d.getLength()})`\n )\n .join(\"\\n\")}`\n );\n } else {\n context.debug(\n `The Typescript emit process completed with diagnostic messages while generating built-in types: \\n ${diagnostics\n .map(\n d =>\n `-${d.getSourceFile() ? `${d.getSourceFile()?.getFilePath()}:` : \"\"} ${String(\n d.getMessageText()\n )} (at ${d.getStart()}:${d.getLength()})`\n )\n .join(\"\\n\")}`\n );\n }\n }\n\n const emittedFiles = emitResult.getFiles();\n context.debug(\n `The TypeScript compiler emitted ${\n emittedFiles.length\n } files for built-in types.`\n );\n\n if (emittedFiles.length === 0) {\n context.warn(\n \"The TypeScript compiler did not emit any files for built-in types. This may indicate an issue with the TypeScript configuration or the provided files.\"\n );\n return { code: \"\", directives: [] };\n }\n\n const ctx = {\n context,\n modules: [] as ModuleDeclaration[],\n emitted: new Map<string, string>()\n };\n\n await Promise.all(\n emittedFiles.map(async emittedFile => {\n const filePath = appendPath(emittedFile.filePath, context.config.cwd);\n if (\n !filePath.endsWith(\".map\") &&\n findFileName(filePath) !== \"tsconfig.tsbuildinfo\" &&\n isParentPath(filePath, context.builtinsPath)\n ) {\n const moduleName = replaceExtension(\n replacePath(\n replacePath(filePath, context.builtinsPath),\n replacePath(context.builtinsPath, context.config.cwd)\n ),\n \"\",\n {\n fullExtension: true\n }\n );\n if (context.builtins.includes(moduleName)) {\n ctx.emitted.set(filePath, moduleName);\n ctx.modules.push(\n await extractModuleDeclarations(\n ctx,\n filePath,\n moduleName,\n emittedFile.text\n )\n );\n }\n }\n })\n );\n\n const commonDeclarations = [] as ExportModuleReference[];\n for (const mod of ctx.modules) {\n for (const importRef of mod.imports.filter(importRef =>\n context.builtins.some(builtin => importRef.name.endsWith(`:${builtin}`))\n )) {\n const moduleRef = ctx.modules.find(moduleRef =>\n importRef.name.endsWith(`:${moduleRef.name}`)\n );\n if (moduleRef) {\n let declaration: ExportModuleReference | undefined;\n for (const decl of moduleRef.exports.filter(decl =>\n isSetObject(decl)\n )) {\n const specifiers = decl.specifiers?.filter(specifier =>\n importRef.specifiers?.some(\n s =>\n (specifier.alias ? specifier.alias : specifier.name) ===\n (s.alias ? s.alias : s.name)\n )\n );\n if (specifiers && specifiers.length > 0) {\n importRef.specifiers = importRef.specifiers?.filter(\n s =>\n !specifiers.some(\n specifier =>\n (specifier.alias ? specifier.alias : specifier.name) ===\n (s.alias ? s.alias : s.name)\n )\n );\n if (\n importRef.specifiers &&\n importRef.specifiers.length === 0 &&\n !importRef.all &&\n !importRef.ambient\n ) {\n mod.imports = mod.imports.filter(\n imp => imp.name !== importRef.name\n );\n }\n\n declaration = decl;\n break;\n }\n }\n\n if (declaration) {\n for (const decl of moduleRef.exports.filter(\n decl =>\n isSetObject(decl) &&\n !decl.specifiers?.some(s =>\n declaration?.specifiers?.some(\n specifier =>\n (specifier.alias ? specifier.alias : specifier.name) ===\n (s.alias ? s.alias : s.name)\n )\n )\n )) {\n const exportModuleRef = decl as ExportModuleReference;\n if (\n (exportModuleRef.specifiers?.some(s => s.alias || s.name) ||\n exportModuleRef.name) &&\n new RegExp(\n `(^|\\\\s|\\\\n|\\\\r\\\\n|\\\\(|\\\\)|<|>|{|}|\\\\[|\\\\]|\\\\!|\\\\?|\\\\.|,|\\\\*|&|:)(${\n exportModuleRef.specifiers\n ?.map(s => `${s.alias ? `${s.alias}|` : \"\"}${s.name}`)\n .join(\"|\") || exportModuleRef.name\n })($|\\\\s|\\\\n|\\\\r\\\\n|\\\\(|\\\\)|<|>|{|}|\\\\[|\\\\]|\\\\!|\\\\?|\\\\.|,|\\\\*|&|:|;)`\n ).test(declaration.text)\n ) {\n commonDeclarations.push(exportModuleRef);\n }\n }\n commonDeclarations.push(declaration);\n }\n }\n }\n }\n\n let code = \"\";\n const directives: string[] = [];\n\n for (const commonDeclaration of commonDeclarations) {\n code += formatTypes(\n `${\n commonDeclaration.comment?.trim()\n ? commonDeclaration.comment.trim()\n : \"\"\n }${commonDeclaration.comment?.trim() ? \"\\n\" : \"\"}${formatTypes(\n commonDeclaration.text\n .replace(/\\s*export\\s*/, \"\")\n .replace(/\\s*declare\\s*interface\\s*/, \"interface \")\n .replace(/\\s*declare\\s*type\\s*/, \"type \")\n )}`\n );\n code += \"\\n\\n\";\n }\n\n for (const mod of ctx.modules) {\n code += mod.comment ? `${mod.comment.trim()}\\n` : \"\";\n code += `declare module \"${context.config.framework}:${mod.name}\" { \\n`;\n for (const importRef of mod.imports) {\n if (importRef.ambient) {\n code += directives.push(importRef.name);\n } else if (importRef.all) {\n code += `\\timport * as ${findFileName(importRef.name)} from \"${importRef.name}\";\\n`;\n } else if (importRef.specifiers) {\n const typeOnly = importRef.specifiers.every(s => s.type) ? \" type\" : \"\";\n const specifiers = importRef.specifiers\n .map(s => (s.alias ? `${s.name} as ${s.alias}` : s.name))\n .join(\", \");\n code += `\\timport${typeOnly} { ${specifiers} } from \"${importRef.name}\";\\n`;\n }\n }\n\n if (mod.imports.length > 0) {\n code += \"\\n\";\n }\n\n for (const exportRef of mod.exports.filter(\n e =>\n isString(e) ||\n !e.specifiers ||\n !commonDeclarations.some(\n commonDecl =>\n commonDecl.specifiers &&\n commonDecl.specifiers.some(specifier =>\n e.specifiers?.some(\n s =>\n (s.alias ? s.alias : s.name) ===\n (specifier.alias ? specifier.alias : specifier.name)\n )\n )\n )\n )) {\n if (isSetString(exportRef)) {\n code += `${exportRef}\\n`;\n } else if (exportRef.name) {\n if (exportRef.all) {\n code += `${\n exportRef.comment?.trim() ? exportRef.comment.trim() : \"\"\n }${\n exportRef.comment?.trim() ? \"\\n\" : \"\"\n }export * from \"${exportRef.name}\";\\n`;\n } else if (exportRef.specifiers) {\n if (exportRef.comment?.trim()) {\n code += `${exportRef.comment.trim()}\\n`;\n }\n\n code += `\\texport${\n exportRef.specifiers.every(s => s.type) ? \" type\" : \"\"\n } { ${exportRef.specifiers\n .map(s => (s.alias ? `${s.name} as ${s.alias}` : s.name))\n .join(\", \")} } from \"${exportRef.name}\";\\n`;\n }\n } else {\n code += `${exportRef.comment?.trim() ? exportRef.comment.trim() : \"\"}${\n exportRef.comment?.trim() ? \"\\n\" : \"\"\n }${formatTypes(\n exportRef.text\n .replace(/\\s*export\\s*declare\\s*/, \"export \")\n .replace(/\\s*declare\\s*/, \" \")\n )}\\n`;\n }\n }\n\n mod.exports\n .filter(\n e =>\n !isString(e) &&\n e.specifiers &&\n commonDeclarations.some(\n commonDeclaration =>\n commonDeclaration.specifiers &&\n commonDeclaration.specifiers.some(specifier =>\n e.specifiers?.some(\n s =>\n (s.alias ? s.alias : s.name) ===\n (specifier.alias ? specifier.alias : specifier.name)\n )\n )\n )\n )\n .forEach((e, i, arr) => {\n if (i === 0) {\n code += \"\\nexport { \";\n } else {\n code += \", \";\n }\n\n code += `${\n (e as ExportModuleReference)?.specifiers\n ?.filter(s =>\n commonDeclarations.some(\n commonDeclaration =>\n commonDeclaration.specifiers &&\n commonDeclaration.specifiers.some(\n specifier =>\n (s.alias ? s.alias : s.name) ===\n (specifier.alias ? specifier.alias : specifier.name)\n )\n )\n )\n .map(s => (s.alias ? `${s.name} as ${s.alias}` : s.name))\n .join(\", \") || \"\"\n }`;\n\n if (i === arr.length - 1) {\n code += ` };\\n`;\n }\n });\n\n code += \"}\";\n code += \"\\n\\n\";\n }\n\n code = await format(context, context.typesPath, code);\n\n context.debug(\n `A TypeScript declaration file (size: ${prettyBytes(\n new Blob(toArray(code)).size\n )}) emitted for the built-in modules types.`\n );\n\n return { code, directives };\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 { Context } from \"@powerlines/core\";\nimport { install } from \"@stryke/fs/install\";\nimport {\n doesPackageMatch,\n getPackageListing,\n isPackageListed\n} from \"@stryke/fs/package-fns\";\nimport {\n getPackageName,\n getPackageVersion,\n hasPackageVersion\n} from \"@stryke/string-format/package\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\n\n/**\n * Installs a package if it is not already installed.\n *\n * @param context - The resolved options\n * @param packageName - The name of the package to install\n * @param dev - Whether to install the package as a dev dependency\n */\nexport async function installPackage(\n context: Context,\n packageName: string,\n dev = false\n) {\n if (\n !(await isPackageListed(getPackageName(packageName), {\n cwd: context.config.root\n }))\n ) {\n if (context.config.autoInstall) {\n context.warn(\n `The package \"${packageName}\" is not installed. It will be installed automatically.`\n );\n\n const result = await install(packageName, {\n cwd: context.config.root,\n dev\n });\n if (isNumber(result.exitCode) && result.exitCode > 0) {\n context.error(result.stderr);\n throw new Error(\n `An error occurred while installing the package \"${packageName}\"`\n );\n }\n } else {\n context.warn(\n `The package \"${packageName}\" is not installed. Since the \"autoInstall\" option is set to false, it will not be installed automatically.`\n );\n }\n } else if (\n hasPackageVersion(packageName) &&\n !process.env.POWERLINES_SKIP_VERSION_CHECK\n ) {\n const isMatching = await doesPackageMatch(\n getPackageName(packageName),\n getPackageVersion(packageName)!,\n context.config.root\n );\n if (!isMatching) {\n const packageListing = await getPackageListing(\n getPackageName(packageName),\n {\n cwd: context.config.root\n }\n );\n if (\n !packageListing?.version.startsWith(\"catalog:\") &&\n !packageListing?.version.startsWith(\"workspace:\")\n ) {\n context.warn(\n `The package \"${getPackageName(packageName)}\" is installed but does not match the expected version ${getPackageVersion(\n packageName\n )} (installed version: ${packageListing?.version || \"<Unknown>\"}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the \"STORM_STACK_SKIP_VERSION_CHECK\" environment variable.`\n );\n }\n }\n }\n}\n\n/**\n * Installs a package if it is not already installed.\n *\n * @param context - The resolved options\n * @param packages - The list of packages to install\n */\nexport async function installPackages(\n context: Context,\n packages: Array<{ name: string; dev?: boolean }>\n) {\n return Promise.all(\n packages.map(async pkg => installPackage(context, pkg.name, pkg.dev))\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 { Context } from \"@powerlines/core\";\nimport { getPackageName } from \"@stryke/string-format/package\";\nimport { installPackage } from \"./install\";\n\n/**\n * Install missing project dependencies.\n *\n * @param context - The build context.\n */\nexport async function installDependencies<TContext extends Context = Context>(\n context: TContext\n): Promise<void> {\n context.debug(`Checking and installing missing project dependencies.`);\n\n context.dependencies ??= {};\n context.devDependencies ??= {};\n\n if (\n Object.keys(context.dependencies).length === 0 &&\n Object.keys(context.devDependencies).length === 0\n ) {\n context.debug(\n `No dependencies or devDependencies to install. Skipping installation step.`\n );\n return;\n }\n\n context.debug(\n `The following packages are required: \\nDependencies: \\n${Object.entries(\n context.dependencies\n )\n .map(([name, version]) => `- ${name}@${String(version)}`)\n .join(\" \\n\")}\\n\\nDevDependencies: \\n${Object.entries(\n context.devDependencies\n )\n .map(([name, version]) => `- ${name}@${String(version)}`)\n .join(\" \\n\")}`\n );\n\n await Promise.all([\n Promise.all(\n Object.entries(context.dependencies).map(async ([name, version]) =>\n installPackage(\n context,\n `${getPackageName(name)}@${String(version)}`,\n false\n )\n )\n ),\n Promise.all(\n Object.entries(context.devDependencies).map(async ([name, version]) =>\n installPackage(\n context,\n `${getPackageName(name)}@${String(version)}`,\n true\n )\n )\n )\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 { Diff, ObjectData } from \"@donedeal0/superdiff\";\nimport { getObjectDiff } from \"@donedeal0/superdiff\";\nimport type { EnvironmentContext, ResolvedConfig } from \"@powerlines/core\";\nimport { readJsonFile } from \"@stryke/fs/json\";\nimport { isPackageExists } from \"@stryke/fs/package-fns\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport {\n findFileName,\n findFilePath,\n relativePath\n} from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { TsConfigJson } from \"@stryke/types/tsconfig\";\nimport chalk from \"chalk\";\nimport {\n getParsedTypeScriptConfig,\n getTsconfigFilePath,\n isIncludeMatchFound\n} from \"../../typescript/tsconfig\";\n\nexport function getTsconfigDtsPath<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>(context: EnvironmentContext<TResolvedConfig>): string {\n const dtsRelativePath = joinPaths(\n relativePath(\n joinPaths(context.config.cwd, context.config.root),\n findFilePath(context.typesPath)\n ),\n findFileName(context.typesPath)\n );\n\n return dtsRelativePath;\n}\n\nasync function resolveTsconfigChanges<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n>(context: EnvironmentContext<TResolvedConfig>): Promise<TsConfigJson> {\n const tsconfig = getParsedTypeScriptConfig(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig,\n context.config.tsconfigRaw\n );\n\n const tsconfigFilePath = getTsconfigFilePath(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig\n );\n\n const tsconfigJson = await readJsonFile<TsConfigJson>(tsconfigFilePath);\n tsconfigJson.compilerOptions ??= {};\n\n if (context.config.output.dts !== false) {\n const dtsRelativePath = getTsconfigDtsPath(context);\n\n if (\n !tsconfigJson.include?.some(filePattern =>\n isIncludeMatchFound(filePattern, [context.typesPath, dtsRelativePath])\n )\n ) {\n tsconfigJson.include ??= [];\n tsconfigJson.include.push(\n dtsRelativePath.startsWith(\"./\")\n ? dtsRelativePath.slice(2)\n : dtsRelativePath\n );\n }\n }\n\n if (\n !tsconfig.options.lib?.some(lib =>\n [\n \"lib.esnext.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2022.d.ts\",\n \"lib.es2023.d.ts\"\n ].includes(lib.toLowerCase())\n )\n ) {\n tsconfigJson.compilerOptions.lib ??= [];\n tsconfigJson.compilerOptions.lib.push(\"esnext\");\n }\n\n // if (tsconfig.options.module !== ts.ModuleKind.ESNext) {\n // tsconfigJson.compilerOptions.module = \"ESNext\";\n // }\n\n // if (\n // !tsconfig.options.target ||\n // ![\n // ts.ScriptTarget.ESNext,\n // ts.ScriptTarget.ES2024,\n // ts.ScriptTarget.ES2023,\n // ts.ScriptTarget.ES2022,\n // ts.ScriptTarget.ES2021\n // ].includes(tsconfig.options.target)\n // ) {\n // tsconfigJson.compilerOptions.target = \"ESNext\";\n // }\n\n // if (tsconfig.options.moduleResolution !== ts.ModuleResolutionKind.Bundler) {\n // tsconfigJson.compilerOptions.moduleResolution = \"Bundler\";\n // }\n\n // if (tsconfig.options.moduleDetection !== ts.ModuleDetectionKind.Force) {\n // tsconfigJson.compilerOptions.moduleDetection = \"force\";\n // }\n\n // if (tsconfig.options.allowSyntheticDefaultImports !== true) {\n // tsconfigJson.compilerOptions.allowSyntheticDefaultImports = true;\n // }\n\n // if (tsconfig.options.noImplicitOverride !== true) {\n // tsconfigJson.compilerOptions.noImplicitOverride = true;\n // }\n\n // if (tsconfig.options.noUncheckedIndexedAccess !== true) {\n // tsconfigJson.compilerOptions.noUncheckedIndexedAccess = true;\n // }\n\n // if (tsconfig.options.skipLibCheck !== true) {\n // tsconfigJson.compilerOptions.skipLibCheck = true;\n // }\n\n // if (tsconfig.options.resolveJsonModule !== true) {\n // tsconfigJson.compilerOptions.resolveJsonModule = true;\n // }\n\n // if (tsconfig.options.verbatimModuleSyntax !== false) {\n // tsconfigJson.compilerOptions.verbatimModuleSyntax = false;\n // }\n\n // if (tsconfig.options.allowJs !== true) {\n // tsconfigJson.compilerOptions.allowJs = true;\n // }\n\n // if (tsconfig.options.declaration !== true) {\n // tsconfigJson.compilerOptions.declaration = true;\n // }\n\n if (tsconfig.options.esModuleInterop !== true) {\n tsconfigJson.compilerOptions.esModuleInterop = true;\n }\n\n if (tsconfig.options.isolatedModules !== true) {\n tsconfigJson.compilerOptions.isolatedModules = true;\n }\n\n if (context.config.platform === \"node\") {\n if (\n !tsconfig.options.types?.some(\n type =>\n type.toLowerCase() === \"node\" || type.toLowerCase() === \"@types/node\"\n )\n ) {\n tsconfigJson.compilerOptions.types ??= [];\n tsconfigJson.compilerOptions.types.push(\"node\");\n }\n }\n\n return tsconfigJson;\n}\n\nexport async function initializeTsconfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TContext extends EnvironmentContext<TResolvedConfig> =\n EnvironmentContext<TResolvedConfig>\n>(context: TContext): Promise<void> {\n context.debug(\n \"Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.\"\n );\n\n if (!isPackageExists(\"typescript\")) {\n throw new Error(\n 'The TypeScript package is not installed. Please install the package using the command: \"npm install typescript --save-dev\"'\n );\n }\n\n const tsconfigFilePath = getTsconfigFilePath(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig\n );\n\n context.tsconfig.originalTsconfigJson =\n await readJsonFile<TsConfigJson>(tsconfigFilePath);\n\n context.tsconfig.tsconfigJson =\n await resolveTsconfigChanges<TResolvedConfig>(context);\n\n context.debug(\n \"Writing updated TypeScript configuration (tsconfig.json) file to disk.\"\n );\n\n await context.fs.write(\n tsconfigFilePath,\n StormJSON.stringify(context.tsconfig.tsconfigJson)\n );\n\n context.tsconfig = getParsedTypeScriptConfig(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig,\n context.config.tsconfigRaw,\n context.tsconfig.originalTsconfigJson\n );\n}\n\nexport async function resolveTsconfig<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TContext extends EnvironmentContext<TResolvedConfig> =\n EnvironmentContext<TResolvedConfig>\n>(context: TContext): Promise<void> {\n const updateTsconfigJson = await readJsonFile<TsConfigJson>(\n context.tsconfig.tsconfigFilePath\n );\n if (\n updateTsconfigJson?.compilerOptions?.types &&\n Array.isArray(updateTsconfigJson.compilerOptions.types) &&\n !updateTsconfigJson.compilerOptions.types.length\n ) {\n // If the types array is empty, we can safely remove it\n delete updateTsconfigJson.compilerOptions.types;\n }\n\n const result = getObjectDiff(\n context.tsconfig.originalTsconfigJson as NonNullable<ObjectData>,\n updateTsconfigJson as ObjectData,\n {\n ignoreArrayOrder: true,\n showOnly: {\n statuses: [\"added\", \"deleted\", \"updated\"],\n granularity: \"deep\"\n }\n }\n );\n\n const changes = [] as {\n field: string;\n status: \"added\" | \"deleted\" | \"updated\";\n previous: string;\n current: string;\n }[];\n const getChanges = (difference: Diff, property?: string) => {\n if (\n difference.status === \"added\" ||\n difference.status === \"deleted\" ||\n difference.status === \"updated\"\n ) {\n if (difference.diff) {\n for (const diff of difference.diff) {\n getChanges(\n diff,\n property\n ? `${property}.${difference.property}`\n : difference.property\n );\n }\n } else {\n changes.push({\n field: property\n ? `${property}.${difference.property}`\n : difference.property,\n status: difference.status,\n previous:\n difference.status === \"added\"\n ? \"---\"\n : StormJSON.stringify(difference.previousValue),\n current:\n difference.status === \"deleted\"\n ? \"---\"\n : StormJSON.stringify(difference.currentValue)\n });\n }\n }\n };\n\n for (const diff of result.diff) {\n getChanges(diff);\n }\n\n if (changes.length > 0) {\n context.warn(\n `Updating the following configuration values in \"${context.tsconfig.tsconfigFilePath}\" file:\n\n ${changes\n .map(\n (change, i) => `${chalk.bold.whiteBright(\n `${i + 1}. ${titleCase(change.status)} the ${change.field} field: `\n )}\n ${chalk.red(` - Previous: ${change.previous} `)}\n ${chalk.green(` - Updated: ${change.current} `)}\n `\n )\n .join(\"\\n\")}\n `\n );\n }\n\n await context.fs.write(\n context.tsconfig.tsconfigFilePath,\n StormJSON.stringify(updateTsconfigJson)\n );\n\n context.tsconfig = getParsedTypeScriptConfig(\n context.config.cwd,\n context.config.root,\n context.config.tsconfig\n );\n if (!context.tsconfig) {\n throw new Error(\"Failed to parse the TypeScript configuration file.\");\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 CallHookOptions,\n CleanInlineConfig,\n DeployInlineConfig,\n DocsInlineConfig,\n EnvironmentContext,\n EnvironmentResolvedConfig,\n Execution,\n InferHookParameters,\n LintInlineConfig,\n NewInlineConfig,\n Plugin,\n PluginConfig,\n PluginConfigObject,\n PluginConfigTuple,\n PluginContext,\n PluginFactory,\n PrepareInlineConfig,\n ResolvedConfig,\n TestInlineConfig,\n TypesInlineConfig,\n TypesResult\n} from \"@powerlines/core\";\nimport { ExecutionOptions } from \"@powerlines/core\";\nimport { getTypescriptFileHeader } from \"@powerlines/core/lib/utilities/file-header\";\nimport { format, formatFolder } from \"@powerlines/core/lib/utilities/format\";\nimport {\n findInvalidPluginConfig,\n formatConfig,\n isDuplicate,\n isPlugin,\n isPluginConfig,\n isPluginConfigObject,\n isPluginConfigTuple\n} from \"@powerlines/core/plugin-utils\";\nimport { colorText } from \"@powerlines/core/plugin-utils/logging\";\nimport { formatLogMessage } from \"@storm-software/config-tools/logger/console\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { copyFiles } from \"@stryke/fs/copy-file\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { createDirectory, removeDirectory } from \"@stryke/fs/helpers\";\nimport { install } from \"@stryke/fs/install\";\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { isPackageExists } from \"@stryke/fs/package-fns\";\nimport { resolvePackage } from \"@stryke/fs/resolve\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isError } from \"@stryke/type-checks/is-error\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isPromiseLike } from \"@stryke/type-checks/is-promise\";\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 { MaybePromise, PartialKeys } from \"@stryke/types/base\";\nimport chalk from \"chalk\";\nimport defu from \"defu\";\nimport Handlebars from \"handlebars\";\nimport { PowerlinesExecutionContext } from \"../context/execution-context\";\nimport { emitBuiltinTypes, formatTypes } from \"./helpers/generate-types\";\nimport { callHook, mergeConfigs } from \"./helpers/hooks\";\nimport { installDependencies } from \"./helpers/install-dependencies\";\nimport { writeMetaFile } from \"./helpers/meta\";\nimport {\n initializeTsconfig,\n resolveTsconfig\n} from \"./helpers/resolve-tsconfig\";\n\n/**\n * The Powerlines Execution API class\n *\n * @remarks\n * This class is responsible for managing the Powerlines project lifecycle, including initialization, building, and finalization.\n *\n * @internal\n */\nexport class PowerlinesExecution<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n> implements Execution {\n /**\n * The Powerlines context\n */\n #context: PowerlinesExecutionContext<TResolvedConfig>;\n\n /**\n * Initialize a Powerlines API instance\n *\n * @param options - The options to initialize the API with\n * @returns A new instance of the Powerlines API\n */\n public static async from<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig\n >(\n options: ExecutionOptions,\n initialConfig?: TResolvedConfig[\"initialConfig\"]\n ): Promise<PowerlinesExecution<TResolvedConfig>> {\n const api = new PowerlinesExecution<TResolvedConfig>(\n await PowerlinesExecutionContext.fromInitialConfig<TResolvedConfig>(\n options,\n initialConfig ?? {}\n )\n );\n await api.init();\n\n return api;\n }\n\n /**\n * The Powerlines context\n */\n public get context(): PowerlinesExecutionContext<TResolvedConfig> {\n return this.#context;\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(\n inlineConfig: PartialKeys<TypesInlineConfig, \"command\"> = {\n command: \"types\"\n }\n ) {\n this.context.debug(\n \" Aggregating configuration options for the Powerlines project\"\n );\n\n inlineConfig.command ??= \"types\";\n await this.context.setInlineConfig(\n inlineConfig as TResolvedConfig[\"inlineConfig\"]\n );\n\n await this.executeEnvironments(async context => {\n context.debug(\n `Initializing the processing options for the Powerlines project.`\n );\n\n await this.callHook(\"configResolved\", {\n environment: context,\n order: \"pre\"\n });\n\n await initializeTsconfig<TResolvedConfig>(context);\n\n await this.callHook(\"configResolved\", {\n environment: context,\n order: \"normal\"\n });\n\n if (context.entry.length > 0) {\n context.debug(\n `The configuration provided ${\n isObject(context.config.input)\n ? Object.keys(context.config.input).length\n : toArray(context.config.input).length\n } entry point(s), Powerlines has found ${\n context.entry.length\n } entry files(s) for the ${context.config.title} project${\n context.entry.length > 0 && context.entry.length < 10\n ? `: \\n${context.entry\n .map(\n entry =>\n `- ${entry.file}${\n entry.output ? ` -> ${entry.output}` : \"\"\n }`\n )\n .join(\" \\n\")}`\n : \"\"\n }`\n );\n } else {\n context.warn(\n `No entry files were found for the ${\n context.config.title\n } project. Please ensure this is correct. Powerlines plugins generally require at least one entry point to function properly.`\n );\n }\n\n await resolveTsconfig<TResolvedConfig>(context);\n await installDependencies(context);\n\n await this.callHook(\"configResolved\", {\n environment: context,\n order: \"post\"\n });\n\n context.trace(\n `Powerlines configuration has been resolved: \\n\\n${formatLogMessage({\n ...context.config,\n userConfig: isSetObject(context.config.userConfig)\n ? omit(context.config.userConfig, [\"plugins\"])\n : undefined,\n inlineConfig: isSetObject(context.config.inlineConfig)\n ? omit(context.config.inlineConfig, [\"plugins\"])\n : undefined,\n plugins: context.plugins.map(plugin => plugin.plugin.name)\n })}`\n );\n\n if (!context.fs.existsSync(context.cachePath)) {\n await createDirectory(context.cachePath);\n }\n\n if (!context.fs.existsSync(context.dataPath)) {\n await createDirectory(context.dataPath);\n }\n\n if (\n context.config.skipCache === true ||\n context.persistedMeta?.checksum !== context.meta.checksum\n ) {\n context.debug(\n `Using previously prepared files as the meta checksum has not changed.`\n );\n } else {\n context.info(\n `Running \\`prepare\\` command as the meta checksum has changed since the last run.`\n );\n\n await this.prepare(\n defu(\n {\n output: {\n types: false\n }\n },\n inlineConfig\n ) as Parameters<typeof this.prepare>[0]\n );\n }\n\n await this.handleTypes(context);\n\n this.context.debug(\"Formatting files generated during the types step.\");\n\n await format(\n context,\n context.typesPath,\n (await context.fs.read(context.typesPath)) ?? \"\"\n );\n\n await writeMetaFile(context);\n context.persistedMeta = context.meta;\n });\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(\n inlineConfig:\n | PartialKeys<PrepareInlineConfig, \"command\">\n | PartialKeys<TypesInlineConfig, \"command\">\n | PartialKeys<NewInlineConfig, \"command\">\n | PartialKeys<CleanInlineConfig, \"command\">\n | PartialKeys<BuildInlineConfig, \"command\">\n | PartialKeys<LintInlineConfig, \"command\">\n | PartialKeys<TestInlineConfig, \"command\">\n | PartialKeys<DocsInlineConfig, \"command\">\n | PartialKeys<DeployInlineConfig, \"command\"> = { command: \"prepare\" }\n ) {\n inlineConfig.command ??= \"prepare\";\n await this.context.setInlineConfig(\n inlineConfig as TResolvedConfig[\"inlineConfig\"]\n );\n\n await this.executeEnvironments(async context => {\n context.debug(\n `Initializing the processing options for the Powerlines project.`\n );\n\n await this.callHook(\"configResolved\", {\n environment: context,\n order: \"pre\"\n });\n\n await initializeTsconfig<TResolvedConfig>(context);\n\n await this.callHook(\"configResolved\", {\n environment: context,\n order: \"normal\"\n });\n\n if (context.entry.length > 0) {\n context.debug(\n `The configuration provided ${\n isObject(context.config.input)\n ? Object.keys(context.config.input).length\n : toArray(context.config.input).length\n } entry point(s), Powerlines has found ${\n context.entry.length\n } entry files(s) for the ${context.config.title} project${\n context.entry.length > 0 && context.entry.length < 10\n ? `: \\n${context.entry\n .map(\n entry =>\n `- ${entry.file}${\n entry.output ? ` -> ${entry.output}` : \"\"\n }`\n )\n .join(\" \\n\")}`\n : \"\"\n }`\n );\n } else {\n context.warn(\n `No entry files were found for the ${\n context.config.title\n } project. Please ensure this is correct. Powerlines plugins generally require at least one entry point to function properly.`\n );\n }\n\n await resolveTsconfig<TResolvedConfig>(context);\n await installDependencies(context);\n\n await this.callHook(\"configResolved\", {\n environment: context,\n order: \"post\"\n });\n\n context.trace({\n meta: {\n category: \"config\"\n },\n message: `Powerlines configuration after configResolved hook: \\n${formatConfig(\n context.config\n )}`\n });\n\n if (!context.fs.existsSync(context.cachePath)) {\n await createDirectory(context.cachePath);\n }\n\n if (!context.fs.existsSync(context.dataPath)) {\n await createDirectory(context.dataPath);\n }\n\n await this.callHook(\"prepare\", {\n environment: context,\n order: \"pre\"\n });\n await this.callHook(\"prepare\", {\n environment: context,\n order: \"normal\"\n });\n\n await this.callHook(\"prepare\", {\n environment: context,\n order: \"post\"\n });\n\n if (context.config.output.types !== false) {\n await this.handleTypes(context);\n }\n\n this.context.debug(\"Formatting files generated during the prepare step.\");\n\n await Promise.all([\n formatFolder(context, context.builtinsPath),\n formatFolder(context, context.entryPath)\n ]);\n\n await writeMetaFile(context);\n context.persistedMeta = context.meta;\n });\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 new command\n * @returns A promise that resolves when the project has been created\n */\n public async new(inlineConfig: PartialKeys<NewInlineConfig, \"command\">) {\n inlineConfig.command ??= \"new\";\n await this.prepare(inlineConfig);\n\n await this.executeEnvironments(async context => {\n context.debug(\n \"Initializing the processing options for the Powerlines project.\"\n );\n\n await this.callHook(\"new\", {\n environment: context,\n order: \"pre\"\n });\n\n const files = await listFiles(\n joinPaths(context.powerlinesPath, \"files/common/**/*.hbs\")\n );\n for (const file of files) {\n context.trace(`Adding template file to project: ${file}`);\n\n const template = Handlebars.compile(file);\n await context.fs.write(\n joinPaths(context.config.root, file.replace(\".hbs\", \"\")),\n template(context)\n );\n }\n\n await this.callHook(\"new\", {\n environment: context,\n order: \"normal\"\n });\n\n if (context.config.projectType === \"application\") {\n const files = await listFiles(\n joinPaths(context.powerlinesPath, \"files/application/**/*.hbs\")\n );\n for (const file of files) {\n context.trace(`Adding application template file: ${file}`);\n\n const template = Handlebars.compile(file);\n await context.fs.write(\n joinPaths(context.config.root, file.replace(\".hbs\", \"\")),\n template(context)\n );\n }\n } else {\n const files = await listFiles(\n joinPaths(context.powerlinesPath, \"files/library/**/*.hbs\")\n );\n for (const file of files) {\n context.trace(`Adding library template file: ${file}`);\n\n const template = Handlebars.compile(file);\n await context.fs.write(\n joinPaths(context.config.root, file.replace(\".hbs\", \"\")),\n template(context)\n );\n }\n }\n\n await this.callHook(\"new\", {\n environment: context,\n order: \"post\"\n });\n });\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(\n inlineConfig:\n | PartialKeys<CleanInlineConfig, \"command\">\n | PartialKeys<PrepareInlineConfig, \"command\"> = {\n command: \"clean\"\n }\n ) {\n inlineConfig.command ??= \"clean\";\n await this.prepare(inlineConfig);\n\n await this.executeEnvironments(async context => {\n context.debug(\"Cleaning the project's dist and artifacts directories.\");\n\n await context.fs.remove(\n joinPaths(context.config.cwd, context.config.output.path)\n );\n await context.fs.remove(\n joinPaths(\n context.config.cwd,\n context.config.root,\n context.config.output.artifactsPath\n )\n );\n\n await this.callHook(\"clean\", {\n environment: context,\n sequential: false\n });\n });\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(\n inlineConfig:\n | PartialKeys<LintInlineConfig, \"command\">\n | PartialKeys<BuildInlineConfig, \"command\"> = { command: \"lint\" }\n ) {\n inlineConfig.command ??= \"lint\";\n await this.prepare(inlineConfig);\n\n await this.executeEnvironments(async context => {\n await this.callHook(\"lint\", {\n environment: context,\n sequential: false\n });\n });\n }\n\n /**\n * Test the project source code\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(\n inlineConfig:\n | PartialKeys<TestInlineConfig, \"command\">\n | PartialKeys<BuildInlineConfig, \"command\"> = { command: \"test\" }\n ) {\n inlineConfig.command ??= \"test\";\n await this.prepare(inlineConfig);\n\n await this.executeEnvironments(async context => {\n await this.callHook(\"test\", {\n environment: context,\n sequential: false\n });\n });\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(\n inlineConfig: PartialKeys<BuildInlineConfig, \"command\"> = {\n command: \"build\"\n }\n ) {\n inlineConfig.command ??= \"build\";\n await this.context.setInlineConfig(\n inlineConfig as TResolvedConfig[\"inlineConfig\"]\n );\n\n await this.context.generateChecksum();\n if (\n this.context.meta.checksum !== this.context.persistedMeta?.checksum ||\n this.context.config.skipCache\n ) {\n this.context.info(\n !this.context.persistedMeta?.checksum\n ? \"No previous build cache found. Preparing the project for the initial build.\"\n : this.context.meta.checksum !== this.context.persistedMeta.checksum\n ? \"The project has been modified since the last time `prepare` was ran. Re-preparing the project.\"\n : \"The project is configured to skip cache. Re-preparing the project.\"\n );\n\n await this.prepare(inlineConfig);\n }\n\n if (this.context.config.singleBuild) {\n await this.handleBuild(await this.#context.toEnvironment());\n } else {\n await this.executeEnvironments(async context => {\n await this.handleBuild(context);\n });\n }\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 = { command: \"docs\" }) {\n inlineConfig.command ??= \"docs\";\n await this.context.setInlineConfig(inlineConfig);\n\n await this.prepare(inlineConfig);\n await this.executeEnvironments(async context => {\n context.debug(\n \"Writing documentation for the Powerlines project artifacts.\"\n );\n\n await this.callHook(\"docs\", {\n environment: context\n });\n });\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 */\n public async deploy(\n inlineConfig: PartialKeys<DeployInlineConfig, \"command\"> = {\n command: \"deploy\"\n }\n ) {\n inlineConfig.command ??= \"deploy\";\n await this.context.setInlineConfig(\n inlineConfig as TResolvedConfig[\"inlineConfig\"]\n );\n\n await this.prepare(inlineConfig);\n await this.executeEnvironments(async context => {\n await this.callHook(\"deploy\", { environment: context });\n });\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 await this.executeEnvironments(async context => {\n await this.callHook(\"finalize\", { environment: context });\n await context.fs.dispose();\n\n if (\n existsSync(context.cachePath) &&\n !(await listFiles(joinPaths(context.cachePath, \"**/*\")))?.length\n ) {\n await removeDirectory(context.cachePath);\n }\n });\n }\n\n /**\n * Invokes the configured plugin hooks\n *\n * @remarks\n * By default, it will call the `\"pre\"`, `\"normal\"`, and `\"post\"` ordered hooks in sequence\n *\n * @param hook - The hook to call\n * @param options - The options to provide to the hook\n * @param args - The arguments to pass to the hook\n * @returns The result of the hook call\n */\n public async callHook<TKey extends string>(\n hook: TKey,\n options: CallHookOptions & {\n environment?: string | EnvironmentContext<TResolvedConfig>;\n },\n ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>\n ) {\n return callHook<TResolvedConfig, TKey>(\n isSetObject(options?.environment)\n ? options.environment\n : await this.#context.getEnvironment(options?.environment),\n hook,\n { sequential: true, ...options },\n ...args\n );\n }\n\n /**\n * Create a new Powerlines API instance\n *\n * @param context - The Powerlines context\n */\n protected constructor(context: PowerlinesExecutionContext<TResolvedConfig>) {\n this.#context = context;\n }\n\n /**\n * Initialize the execution API with the provided configuration options\n */\n protected async init() {\n this.#context.$$internal = {\n api: this,\n addPlugin: this.addPlugin.bind(this)\n };\n\n const timer = this.#context.timer(\"Initialization\");\n\n for (const plugin of this.#context.config.plugins.flatMap(p =>\n toArray(p)\n ) ?? []) {\n await this.addPlugin(plugin);\n }\n\n if (this.#context.plugins.length === 0) {\n this.#context.warn({\n meta: {\n category: \"plugins\"\n },\n message:\n \"No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.\"\n });\n } else {\n this.#context.info({\n meta: {\n category: \"plugins\"\n },\n message: `Loaded ${this.#context.plugins.length} ${titleCase(\n this.#context.config.framework\n )} plugin${this.#context.plugins.length > 1 ? \"s\" : \"\"}: \\n${this.#context.plugins\n .map((plugin, index) => ` ${index + 1}. ${colorText(plugin.name)}`)\n .join(\"\\n\")}`\n });\n }\n\n const pluginConfig = await this.callHook(\"config\", {\n environment: await this.#context.getEnvironment(),\n sequential: true,\n result: \"merge\",\n merge: mergeConfigs\n });\n if (pluginConfig) {\n await this.context.setPluginConfig(\n pluginConfig as TResolvedConfig[\"pluginConfig\"]\n );\n } else {\n this.context.debug({\n meta: {\n category: \"config\"\n },\n message: \"No plugin configuration was returned from the config hook.\"\n });\n }\n\n timer();\n }\n\n /**\n * Add a Powerlines plugin used in the build process\n *\n * @param config - The import path of the plugin to add\n */\n protected async addPlugin(\n config: PluginConfig<PluginContext<TResolvedConfig>>\n ) {\n if (config) {\n const result = await this.initPlugin(config);\n if (!result) {\n return;\n }\n\n for (const plugin of result) {\n this.context.debug({\n meta: {\n category: \"plugins\"\n },\n message: `Successfully initialized the ${chalk.bold.cyanBright(\n plugin.name\n )} plugin`\n });\n\n await this.context.addPlugin(plugin);\n }\n }\n }\n\n /**\n * Get the configured environments\n *\n * @returns The configured environments\n */\n private async getEnvironments() {\n if (\n !this.context.config.environments ||\n Object.keys(this.context.config.environments).length <= 1\n ) {\n this.context.debug({\n meta: {\n category: \"config\"\n },\n message:\n \"No environments are configured for this Powerlines project. Using the default environment.\"\n });\n\n return [await this.context.getEnvironment()];\n }\n\n this.context.debug({\n meta: {\n category: \"config\"\n },\n message: `Found ${\n Object.keys(this.context.config.environments).length\n } configured environment(s) for this Powerlines project.`\n });\n\n return (\n await Promise.all(\n Object.entries(this.context.config.environments).map(\n async ([name, config]) => {\n const environment = await this.context.getEnvironmentSafe(name);\n if (!environment) {\n const resolvedEnvironment = await this.callHook(\n \"configEnvironment\",\n {\n environment: name\n },\n name,\n config\n );\n\n if (resolvedEnvironment) {\n this.context.environments[name] =\n await this.context.createEnvironment(\n resolvedEnvironment as EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n );\n }\n }\n\n return this.context.environments[name];\n }\n )\n )\n ).filter(context => isSet(context));\n }\n\n /**\n * Execute a handler function for each environment\n *\n * @param handle - The handler function to execute for each environment\n */\n private async executeEnvironments(\n handle: (context: EnvironmentContext<TResolvedConfig>) => MaybePromise<void>\n ) {\n await Promise.all(\n (await this.getEnvironments()).map(async context => {\n return Promise.resolve(handle(context));\n })\n );\n }\n\n /**\n * Initialize a Powerlines plugin\n *\n * @param config - The configuration for the plugin\n * @returns The initialized plugin instance, or null if the plugin was a duplicate\n * @throws Will throw an error if the plugin cannot be found or is invalid\n */\n private async initPlugin(\n config: PluginConfig<PluginContext<TResolvedConfig>>\n ): Promise<Plugin<PluginContext<TResolvedConfig>>[] | null> {\n let awaited = config;\n if (isPromiseLike(config)) {\n awaited = (await Promise.resolve(config as Promise<any>)) as PluginConfig<\n PluginContext<TResolvedConfig>\n >;\n }\n\n if (!isPluginConfig<PluginContext<TResolvedConfig>>(awaited)) {\n const invalid = findInvalidPluginConfig(awaited);\n\n throw new Error(\n `Invalid ${\n invalid && invalid.length > 1 ? \"plugins\" : \"plugin\"\n } specified in the configuration - ${\n invalid && invalid.length > 0\n ? JSON.stringify(awaited)\n : invalid?.join(\"\\n\\n\")\n } \\n\\nPlease ensure the value is one of the following: \\n - an instance of \\`Plugin\\` \\n - a plugin name \\n - an object with the \\`plugin\\` and \\`options\\` properties \\n - a tuple array with the plugin and options \\n - a factory function that returns a plugin or array of plugins \\n - an array of plugins or plugin configurations`\n );\n }\n\n let plugins!: Plugin<PluginContext<TResolvedConfig>>[];\n if (isPlugin<PluginContext<TResolvedConfig>>(awaited)) {\n plugins = [awaited];\n } else if (isFunction(awaited)) {\n plugins = toArray(await Promise.resolve(awaited()));\n } else if (isString(awaited)) {\n const resolved = await this.resolvePlugin(awaited);\n if (isFunction(resolved)) {\n plugins = toArray(await Promise.resolve(resolved()));\n } else {\n plugins = toArray(resolved);\n }\n } else if (\n Array.isArray(awaited) &&\n (awaited as PluginContext<TResolvedConfig>[]).every(\n isPlugin<PluginContext<TResolvedConfig>>\n )\n ) {\n plugins = awaited as Plugin<PluginContext<TResolvedConfig>>[];\n } else if (\n Array.isArray(awaited) &&\n (awaited as PluginConfig<PluginContext<TResolvedConfig>>[]).every(\n isPluginConfig<PluginContext<TResolvedConfig>>\n )\n ) {\n plugins = [];\n for (const pluginConfig of awaited as PluginConfig<\n PluginContext<TResolvedConfig>\n >[]) {\n const initialized = await this.initPlugin(pluginConfig);\n if (initialized) {\n plugins.push(...initialized);\n }\n }\n } else if (\n isPluginConfigTuple<PluginContext<TResolvedConfig>>(awaited) ||\n isPluginConfigObject<PluginContext<TResolvedConfig>>(awaited)\n ) {\n let pluginConfig!:\n | string\n | PluginFactory<PluginContext<TResolvedConfig>>\n | Plugin<PluginContext<TResolvedConfig>>;\n let pluginOptions: any;\n\n if (isPluginConfigTuple<PluginContext<TResolvedConfig>>(awaited)) {\n pluginConfig = awaited[0] as Plugin<PluginContext<TResolvedConfig>>;\n pluginOptions =\n (awaited as PluginConfigTuple)?.length === 2 ? awaited[1] : undefined;\n } else {\n pluginConfig = (awaited as PluginConfigObject).plugin as Plugin<\n PluginContext<TResolvedConfig>\n >;\n pluginOptions = (awaited as PluginConfigObject).options;\n }\n\n if (isSetString(pluginConfig)) {\n const resolved = await this.resolvePlugin(pluginConfig);\n if (isFunction(resolved)) {\n plugins = toArray(\n await Promise.resolve(\n pluginOptions ? resolved(pluginOptions) : resolved()\n )\n );\n } else {\n plugins = toArray(resolved);\n }\n } else if (isFunction(pluginConfig)) {\n plugins = toArray(await Promise.resolve(pluginConfig(pluginOptions)));\n } else if (\n Array.isArray(pluginConfig) &&\n pluginConfig.every(isPlugin<PluginContext<TResolvedConfig>>)\n ) {\n plugins = pluginConfig;\n } else if (isPlugin<PluginContext<TResolvedConfig>>(pluginConfig)) {\n plugins = toArray(pluginConfig);\n }\n }\n\n if (!plugins) {\n throw new Error(\n `The plugin configuration ${JSON.stringify(awaited)} is invalid. This configuration must point to a valid Powerlines plugin module.`\n );\n }\n\n if (\n plugins.length > 0 &&\n !plugins.every(isPlugin<PluginContext<TResolvedConfig>>)\n ) {\n throw new Error(\n `The plugin option ${JSON.stringify(plugins)} does not export a valid module. This configuration must point to a valid Powerlines plugin module.`\n );\n }\n\n const result = [] as Plugin<PluginContext<TResolvedConfig>>[];\n for (const plugin of plugins) {\n if (isDuplicate<TResolvedConfig>(plugin, this.context.plugins)) {\n this.context.trace({\n meta: {\n category: \"plugins\"\n },\n message: `Duplicate ${chalk.bold.cyanBright(\n plugin.name\n )} plugin dependency detected - Skipping initialization.`\n });\n } else {\n result.push(plugin);\n\n this.context.trace({\n meta: {\n category: \"plugins\"\n },\n message: `Initializing the ${chalk.bold.cyanBright(plugin.name)} plugin...`\n });\n }\n }\n\n return result;\n }\n\n private async resolvePlugin<TOptions>(\n pluginPath: string\n ): Promise<\n | Plugin<PluginContext<TResolvedConfig>>\n | Plugin<PluginContext<TResolvedConfig>>[]\n | ((\n options?: TOptions\n ) => MaybePromise<\n | Plugin<PluginContext<TResolvedConfig>>\n | Plugin<PluginContext<TResolvedConfig>>[]\n >)\n > {\n if (\n pluginPath.startsWith(\"@\") &&\n pluginPath.split(\"/\").filter(Boolean).length > 2\n ) {\n const splits = pluginPath.split(\"/\").filter(Boolean);\n pluginPath = `${splits[0]}/${splits[1]}`;\n }\n\n const isInstalled = isPackageExists(pluginPath, {\n paths: [this.context.config.cwd, this.context.config.root]\n });\n if (!isInstalled && this.context.config.autoInstall) {\n this.#context.warn(\n `The plugin package \"${\n pluginPath\n }\" is not installed. It will be installed automatically.`\n );\n\n const result = await install(pluginPath, {\n cwd: this.context.config.root\n });\n if (isNumber(result.exitCode) && result.exitCode > 0) {\n this.#context.error(result.stderr);\n\n throw new Error(\n `An error occurred while installing the build plugin package \"${\n pluginPath\n }\" `\n );\n }\n }\n\n try {\n // First check if the package has a \"plugin\" subdirectory - @scope/package/plugin\n const module = await this.context.resolver.plugin.import<{\n plugin?:\n | Plugin<PluginContext<TResolvedConfig>>\n | ((\n options?: TOptions\n ) => MaybePromise<Plugin<PluginContext<TResolvedConfig>>>);\n default?:\n | Plugin<PluginContext<TResolvedConfig>>\n | ((\n options?: TOptions\n ) => MaybePromise<Plugin<PluginContext<TResolvedConfig>>>);\n }>(\n this.context.resolver.plugin.esmResolve(joinPaths(pluginPath, \"plugin\"))\n );\n\n const result = module.plugin ?? module.default;\n if (!result) {\n throw new Error(\n `The plugin package \"${pluginPath}\" does not export a valid module.`\n );\n }\n\n return result;\n } catch (error) {\n try {\n const module = await this.context.resolver.plugin.import<{\n plugin?:\n | Plugin<PluginContext<TResolvedConfig>>\n | ((\n options?: TOptions\n ) => MaybePromise<Plugin<PluginContext<TResolvedConfig>>>);\n default?:\n | Plugin<PluginContext<TResolvedConfig>>\n | ((\n options?: TOptions\n ) => MaybePromise<Plugin<PluginContext<TResolvedConfig>>>);\n }>(this.context.resolver.plugin.esmResolve(pluginPath));\n\n const result = module.plugin ?? module.default;\n if (!result) {\n throw new Error(\n `The plugin package \"${pluginPath}\" does not export a valid module.`\n );\n }\n\n return result;\n } catch {\n if (!isInstalled) {\n throw new Error(\n `The plugin package \"${\n pluginPath\n }\" is not installed. Please install the package using the command: \"npm install ${\n pluginPath\n } --save-dev\"`\n );\n } else {\n throw new Error(\n `An error occurred while importing the build plugin package \"${\n pluginPath\n }\":\n${isError(error) ? error.message : String(error)}\n\nNote: Please ensure the plugin package's default export is a class that extends \\`Plugin\\` with a constructor that excepts a single arguments of type \\`PluginOptions\\`.`\n );\n }\n }\n }\n }\n\n private async handleBuild(context: EnvironmentContext<TResolvedConfig>) {\n await this.callHook(\"build\", {\n environment: context,\n order: \"pre\"\n });\n\n context.debug(\n \"Formatting the generated entry files before the build process starts.\"\n );\n await formatFolder(context, context.entryPath);\n\n await this.callHook(\"build\", {\n environment: context,\n order: \"normal\"\n });\n\n if (context.config.output.copy) {\n context.debug(\"Copying project's files from build output directory.\");\n\n const destinationPath = isParentPath(\n appendPath(context.config.output.path, context.config.cwd),\n appendPath(context.config.root, context.config.cwd)\n )\n ? joinPaths(\n context.config.output.copy.path,\n relativePath(\n appendPath(context.config.root, context.config.cwd),\n appendPath(context.config.output.path, context.config.cwd)\n )\n )\n : joinPaths(context.config.output.copy.path, \"dist\");\n const sourcePath = context.config.output.path;\n\n if (existsSync(sourcePath) && sourcePath !== destinationPath) {\n context.debug(\n `Copying files from project's build output directory (${\n context.config.output.path\n }) to the project's copy/publish directory (${destinationPath}).`\n );\n\n await copyFiles(sourcePath, destinationPath);\n } else {\n context.warn(\n `The source path for the copy operation ${\n !existsSync(sourcePath)\n ? \"does not exist\"\n : \"is the same as the destination path\"\n }. Source: ${sourcePath}, Destination: ${\n destinationPath\n }. Skipping copying of build output files.`\n );\n }\n\n if (\n context.config.output.copy.assets &&\n Array.isArray(context.config.output.copy.assets)\n ) {\n await Promise.all(\n context.config.output.copy.assets.map(async asset => {\n context.trace(\n `Copying asset(s): ${chalk.redBright(\n context.config.cwd === asset.input\n ? asset.glob\n : appendPath(\n asset.glob,\n replacePath(asset.input, context.config.cwd)\n )\n )} -> ${chalk.greenBright(\n appendPath(\n asset.glob,\n replacePath(asset.output, context.config.cwd)\n )\n )} ${\n Array.isArray(asset.ignore) && asset.ignore.length > 0\n ? ` (ignoring: ${asset.ignore\n .map(i => chalk.yellowBright(i))\n .join(\", \")})`\n : \"\"\n }`\n );\n\n await context.fs.copy(asset, asset.output);\n })\n );\n }\n } else {\n context.debug(\n \"No copy configuration found for the project output. Skipping the copying of build output files.\"\n );\n }\n\n await this.callHook(\"build\", {\n environment: context,\n order: \"post\"\n });\n }\n\n /**\n * Generate the Powerlines TypeScript declaration file\n *\n * @remarks\n * This method will generate the TypeScript declaration file for the Powerlines project, including any types provided by plugins.\n *\n * @param context - The environment context to use for generating the TypeScript declaration file\n * @returns A promise that resolves when the TypeScript declaration file has been generated\n */\n private async handleTypes(context: EnvironmentContext<TResolvedConfig>) {\n context.debug(\n `Preparing the TypeScript definitions for the Powerlines project.`\n );\n\n if (context.fs.existsSync(context.typesPath)) {\n await context.fs.remove(context.typesPath);\n }\n\n const typescriptPath = await resolvePackage(\"typescript\");\n if (!typescriptPath) {\n throw new Error(\n \"Could not resolve TypeScript package location. Please ensure TypeScript is installed.\"\n );\n }\n\n context.debug(\n \"Running TypeScript compiler for built-in runtime module files.\"\n );\n\n let { code, directives } = await emitBuiltinTypes(\n context,\n (await context.getBuiltins()).reduce<string[]>((ret, builtin) => {\n const formatted = replacePath(builtin.path, context.config.cwd);\n if (!ret.includes(formatted)) {\n ret.push(formatted);\n }\n\n return ret;\n }, [])\n );\n\n context.debug(\n `Generating TypeScript declaration file ${context.typesPath}.`\n );\n\n const merge = async (\n currentResult: string | TypesResult,\n previousResult: string | TypesResult\n ): Promise<string | TypesResult> => {\n if (\n !isSetString(currentResult) &&\n !isSetObject(currentResult) &&\n !isSetString(previousResult) &&\n !isSetObject(previousResult)\n ) {\n return { code, directives };\n }\n\n const previous = (\n await format(\n context,\n context.typesPath,\n isSetString(previousResult)\n ? previousResult\n : isSetObject(previousResult)\n ? previousResult.code\n : \"\"\n )\n )\n .trim()\n .replace(code, \"\")\n .trim();\n const current = (\n await format(\n context,\n context.typesPath,\n isSetString(currentResult)\n ? currentResult\n : isSetObject(currentResult)\n ? currentResult.code\n : \"\"\n )\n )\n .trim()\n .replace(previous, \"\")\n .trim()\n .replace(code, \"\")\n .trim();\n\n return {\n directives: [\n ...(isSetObject(currentResult) && currentResult.directives\n ? currentResult.directives\n : []),\n ...(isSetObject(previousResult) && previousResult.directives\n ? previousResult.directives\n : [])\n ],\n code: await format(\n context,\n context.typesPath,\n `${\n !previous.includes(getTypescriptFileHeader(context)) &&\n !current.includes(getTypescriptFileHeader(context))\n ? `${code}\\n`\n : \"\"\n }${previous}\\n${current}`.trim()\n )\n };\n };\n const asNextParam = (\n previousResult: string | TypesResult | null | undefined\n ) => (isObject(previousResult) ? previousResult.code : previousResult);\n\n let result = await this.callHook(\n \"types\",\n {\n environment: context,\n sequential: true,\n order: \"pre\",\n result: \"merge\",\n merge,\n asNextParam\n },\n code\n );\n if (result) {\n if (isSetObject(result)) {\n code = result.code;\n if (Array.isArray(result.directives) && result.directives.length > 0) {\n directives = getUnique([...directives, ...result.directives]).filter(\n Boolean\n );\n }\n } else if (isSetString(result)) {\n code = result;\n }\n }\n\n result = await this.callHook(\n \"types\",\n {\n environment: context,\n sequential: true,\n order: \"normal\",\n result: \"merge\",\n merge,\n asNextParam\n },\n code\n );\n if (result) {\n if (isSetObject(result)) {\n code = result.code;\n if (Array.isArray(result.directives) && result.directives.length > 0) {\n directives = getUnique([...directives, ...result.directives]).filter(\n Boolean\n );\n }\n } else if (isSetString(result)) {\n code = result;\n }\n }\n\n result = await this.callHook(\n \"types\",\n {\n environment: context,\n sequential: true,\n order: \"post\",\n result: \"merge\",\n merge,\n asNextParam\n },\n code\n );\n if (result) {\n if (isSetObject(result)) {\n code = result.code;\n if (Array.isArray(result.directives) && result.directives.length > 0) {\n directives = getUnique([...directives, ...result.directives]).filter(\n Boolean\n );\n }\n } else if (isSetString(result)) {\n code = result;\n }\n }\n\n if (isSetString(code?.trim()) || directives.length > 0) {\n await context.fs.write(\n context.typesPath,\n `${\n directives.length > 0\n ? `${directives.map(directive => `/// <reference types=\"${directive}\" />`).join(\"\\n\")}\n\n`\n : \"\"\n }${getTypescriptFileHeader(context, { directive: null, prettierIgnore: false })}\n\n${formatTypes(code)}\n`\n );\n }\n\n // else {\n // const dtsRelativePath = getTsconfigDtsPath(context);\n // if (\n // context.tsconfig.tsconfigJson.include &&\n // isIncludeMatchFound(\n // dtsRelativePath,\n // context.tsconfig.tsconfigJson.include\n // )\n // ) {\n // const normalizedDtsRelativePath = dtsRelativePath.startsWith(\"./\")\n // ? dtsRelativePath.slice(2)\n // : dtsRelativePath;\n // context.tsconfig.tsconfigJson.include =\n // context.tsconfig.tsconfigJson.include.filter(\n // includeValue =>\n // includeValue?.toString() !== normalizedDtsRelativePath\n // );\n\n // await context.fs.write(\n // context.tsconfig.tsconfigFilePath,\n // JSON.stringify(context.tsconfig.tsconfigJson, null, 2)\n // );\n // }\n // }\n\n // // Re-resolve the tsconfig to ensure it is up to date\n // context.tsconfig = getParsedTypeScriptConfig(\n // context.config.cwd,\n // context.config.root,\n // context.config.tsconfig\n // );\n // if (!context.tsconfig) {\n // throw new Error(\"Failed to parse the TypeScript configuration file.\");\n // }\n }\n}\n","#!/usr/bin/env -S NODE_OPTIONS=--enable-source-maps node\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 DeployInlineConfig,\n DocsInlineConfig,\n ExecutionWorkerParams,\n LintInlineConfig,\n PrepareInlineConfig,\n TestInlineConfig,\n TypesInlineConfig\n} from \"@powerlines/core\";\nimport { PowerlinesExecution } from \"./execution\";\n\nexport async function clean({\n options,\n initialConfig,\n inlineConfig\n}: ExecutionWorkerParams): Promise<void> {\n const execution = await PowerlinesExecution.from(options, initialConfig);\n\n await execution.clean(inlineConfig as CleanInlineConfig);\n}\n\nexport async function prepare({\n options,\n initialConfig,\n inlineConfig\n}: ExecutionWorkerParams): Promise<void> {\n const execution = await PowerlinesExecution.from(options, initialConfig);\n\n await execution.prepare(inlineConfig as PrepareInlineConfig);\n}\n\nexport async function types({\n options,\n initialConfig,\n inlineConfig\n}: ExecutionWorkerParams): Promise<void> {\n const execution = await PowerlinesExecution.from(options, initialConfig);\n\n await execution.types(inlineConfig as TypesInlineConfig);\n}\n\nexport async function lint({\n options,\n initialConfig,\n inlineConfig\n}: ExecutionWorkerParams): Promise<void> {\n const execution = await PowerlinesExecution.from(options, initialConfig);\n\n await execution.lint(inlineConfig as LintInlineConfig);\n}\n\nexport async function test({\n options,\n initialConfig,\n inlineConfig\n}: ExecutionWorkerParams): Promise<void> {\n const execution = await PowerlinesExecution.from(options, initialConfig);\n\n await execution.test(inlineConfig as TestInlineConfig);\n}\n\nexport async function build({\n options,\n initialConfig,\n inlineConfig\n}: ExecutionWorkerParams): Promise<void> {\n const execution = await PowerlinesExecution.from(options, initialConfig);\n\n await execution.build(inlineConfig as BuildInlineConfig);\n}\n\nexport async function docs({\n options,\n initialConfig,\n inlineConfig\n}: ExecutionWorkerParams): Promise<void> {\n const execution = await PowerlinesExecution.from(options, initialConfig);\n\n await execution.docs(inlineConfig as DocsInlineConfig);\n}\n\nexport async function deploy({\n options,\n initialConfig,\n inlineConfig\n}: ExecutionWorkerParams): Promise<void> {\n const execution = await PowerlinesExecution.from(options, initialConfig);\n\n await execution.deploy(inlineConfig as DeployInlineConfig);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,kBAEd,MAAc,QAAyB;AACvC,QAAO,KAAK,OAAO,eAAe,SAAS,EAAE,EAAE;EAC7C,IAAI,MA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