powerlines 0.23.2 → 0.23.4

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 (297) hide show
  1. package/dist/api--9pVSIbm.d.cts +168 -0
  2. package/dist/api-DxPACGY4.d.ts +168 -0
  3. package/dist/api.cjs +3 -3
  4. package/dist/api.d.cts +16 -7
  5. package/dist/api.d.ts +16 -7
  6. package/dist/api.js +2 -2
  7. package/dist/astro.cjs +8 -8
  8. package/dist/astro.d.cts +3 -5
  9. package/dist/astro.d.ts +3 -5
  10. package/dist/astro.js +5 -5
  11. package/dist/{chunk-ZFO3FUM4.cjs → chunk-2FLICTDF.cjs} +2 -2
  12. package/dist/{chunk-JAJ4CI2F.cjs → chunk-3OQXZ5MM.cjs} +2 -2
  13. package/dist/{chunk-KFRKOIP3.js → chunk-5B6P2VUG.js} +1 -1
  14. package/dist/{chunk-GNNF5SG6.cjs → chunk-6ACGI52O.cjs} +2 -2
  15. package/dist/{chunk-JZAQW55G.cjs → chunk-AF5VNWZD.cjs} +2 -2
  16. package/dist/{chunk-J7MZRPLN.cjs → chunk-AIC2EHPW.cjs} +5 -4
  17. package/dist/{chunk-3WDMXRK6.cjs → chunk-AYKZK666.cjs} +1 -1
  18. package/dist/chunk-CHNKTBUA.cjs +32 -0
  19. package/dist/{chunk-M4QJ2474.cjs → chunk-CTSSNO5L.cjs} +4 -4
  20. package/dist/{chunk-5A7FM72H.cjs → chunk-GP6XGAJ4.cjs} +2 -2
  21. package/dist/{chunk-DUYZ3TCT.js → chunk-HLQGKQZY.js} +1 -1
  22. package/dist/{chunk-LKN52AAX.js → chunk-HNJC47JM.js} +1 -1
  23. package/dist/{chunk-IGWSCIES.js → chunk-ISLX4Z3L.js} +3 -2
  24. package/dist/{chunk-J5LKLH5Z.js → chunk-KFSVTJMR.js} +1 -1
  25. package/dist/{chunk-RWVNX2CP.js → chunk-MI3U2GAT.js} +1 -1
  26. package/dist/{chunk-4ODWTALP.js → chunk-N3F54RFW.js} +2 -2
  27. package/dist/{chunk-Q7HBETZW.js → chunk-O2WB6QZ6.js} +1 -1
  28. package/dist/{chunk-DWV5QAGZ.cjs → chunk-OEKSQ22R.cjs} +2997 -2710
  29. package/dist/{chunk-WSLPUUGZ.js → chunk-PTZB4LWS.js} +1 -1
  30. package/dist/{chunk-CPRXGMH2.js → chunk-QSNFMINQ.js} +1 -1
  31. package/dist/{chunk-YQ76DZYD.cjs → chunk-QUZ4T5AX.cjs} +2 -2
  32. package/dist/chunk-UTAJPBVT.js +29 -0
  33. package/dist/{chunk-WG55ZHJL.cjs → chunk-UW3MXOWV.cjs} +2 -2
  34. package/dist/{chunk-F6BDL4HD.js → chunk-VDBKZJV6.js} +1 -1
  35. package/dist/{chunk-J3LN5HOC.cjs → chunk-VFLCP3SA.cjs} +2 -2
  36. package/dist/{chunk-FM4ABZQ2.js → chunk-VT7NVLLU.js} +1 -1
  37. package/dist/{chunk-WDBPA4RQ.cjs → chunk-VXAKPZ3A.cjs} +2 -2
  38. package/dist/{chunk-WXU3KLBP.cjs → chunk-XOI5CY62.cjs} +2 -2
  39. package/dist/{chunk-NH7U3PTV.js → chunk-ZQ7PDXYO.js} +1 -1
  40. package/dist/{chunk-TNYZH6EG.js → chunk-ZYCPZLIG.js} +2982 -2700
  41. package/dist/config.d.cts +3 -5
  42. package/dist/config.d.ts +3 -5
  43. package/dist/esbuild.cjs +7 -7
  44. package/dist/esbuild.d.cts +3 -5
  45. package/dist/esbuild.d.ts +3 -5
  46. package/dist/esbuild.js +4 -4
  47. package/dist/farm.cjs +4 -4
  48. package/dist/farm.d.cts +3 -5
  49. package/dist/farm.d.ts +3 -5
  50. package/dist/farm.js +3 -3
  51. package/dist/index.cjs +54 -33
  52. package/dist/index.d.cts +191 -39
  53. package/dist/index.d.ts +191 -39
  54. package/dist/index.js +18 -17
  55. package/dist/lib/api-B6hfFxVS.d.ts +167 -0
  56. package/dist/lib/api-CD2QlMig.d.cts +167 -0
  57. package/dist/lib/build/esbuild.d.cts +2 -4
  58. package/dist/lib/build/esbuild.d.ts +2 -4
  59. package/dist/lib/build/index.d.cts +4 -5
  60. package/dist/lib/build/index.d.ts +4 -5
  61. package/dist/lib/build/rolldown.d.cts +2 -4
  62. package/dist/lib/build/rolldown.d.ts +2 -4
  63. package/dist/lib/build/rollup.d.cts +2 -4
  64. package/dist/lib/build/rollup.d.ts +2 -4
  65. package/dist/lib/build/rspack.d.cts +2 -4
  66. package/dist/lib/build/rspack.d.ts +2 -4
  67. package/dist/lib/build/tsup.d.cts +2 -4
  68. package/dist/lib/build/tsup.d.ts +2 -4
  69. package/dist/lib/build/unbuild.d.cts +4 -23
  70. package/dist/lib/build/unbuild.d.ts +4 -23
  71. package/dist/lib/build/vite.d.cts +2 -4
  72. package/dist/lib/build/vite.d.ts +2 -4
  73. package/dist/lib/build/webpack.d.cts +2 -4
  74. package/dist/lib/build/webpack.d.ts +2 -4
  75. package/dist/lib/chunk-32Q2PG5D.js +9 -0
  76. package/dist/lib/chunk-35FGUJFD.cjs +2 -0
  77. package/dist/lib/{chunk-LIN4KAV3.js → chunk-52VDUP5J.js} +5 -7
  78. package/dist/lib/chunk-B3EE3VHZ.cjs +127 -0
  79. package/dist/lib/{chunk-UWHGJ4JS.js → chunk-BLNW3ZQA.js} +483 -1776
  80. package/dist/lib/chunk-DX2VAXZB.cjs +11 -0
  81. package/dist/lib/{chunk-VGSV2BEL.cjs → chunk-EFYMNU53.cjs} +6 -12
  82. package/dist/lib/chunk-FBQIPNRV.cjs +146 -0
  83. package/dist/lib/chunk-FFT4PWRM.js +1 -0
  84. package/dist/lib/{chunk-L4NEN725.js → chunk-G7S5PIAC.js} +1 -1
  85. package/dist/lib/chunk-KFJCWNVG.js +120 -0
  86. package/dist/lib/chunk-M2U6XIQ2.js +144 -0
  87. package/dist/lib/chunk-MVIKYHBX.cjs +2 -0
  88. package/dist/lib/chunk-NYNHNTHT.js +1 -0
  89. package/dist/lib/{chunk-A5SB72VO.cjs → chunk-PYQADZVV.cjs} +493 -1779
  90. package/dist/lib/chunk-QP6WX3Q3.js +1190 -0
  91. package/dist/lib/chunk-S7LLEDQM.cjs +1218 -0
  92. package/dist/lib/chunk-UHGGYHSK.cjs +175 -0
  93. package/dist/lib/chunk-YNKFRPUY.js +168 -0
  94. package/dist/lib/{chunk-ULJVBW4L.cjs → chunk-ZBDVQVUK.cjs} +1 -1
  95. package/dist/lib/{config-BoGlIhnH.d.cts → config-DTSdCZsw.d.cts} +650 -633
  96. package/dist/lib/{config-CTej7RMP.d.ts → config-DeUaQYc_.d.ts} +650 -633
  97. package/dist/lib/config-file.d.cts +4 -5
  98. package/dist/lib/config-file.d.ts +4 -5
  99. package/dist/lib/contexts/api-context.cjs +18 -0
  100. package/dist/lib/contexts/api-context.d.cts +69 -0
  101. package/dist/lib/contexts/api-context.d.ts +69 -0
  102. package/dist/lib/contexts/api-context.js +9 -0
  103. package/dist/lib/contexts/context.cjs +15 -0
  104. package/dist/lib/contexts/context.d.cts +255 -0
  105. package/dist/lib/contexts/context.d.ts +255 -0
  106. package/dist/lib/contexts/context.js +6 -0
  107. package/dist/lib/contexts/environment-context.cjs +17 -0
  108. package/dist/lib/contexts/environment-context.d.cts +65 -0
  109. package/dist/lib/contexts/environment-context.d.ts +65 -0
  110. package/dist/lib/contexts/environment-context.js +8 -0
  111. package/dist/lib/contexts/index.cjs +31 -0
  112. package/dist/lib/contexts/index.d.cts +35 -0
  113. package/dist/lib/contexts/index.d.ts +35 -0
  114. package/dist/lib/contexts/index.js +10 -0
  115. package/dist/lib/contexts/plugin-context.cjs +11 -0
  116. package/dist/lib/contexts/plugin-context.d.cts +42 -0
  117. package/dist/lib/contexts/plugin-context.d.ts +42 -0
  118. package/dist/lib/contexts/plugin-context.js +2 -0
  119. package/dist/lib/entry.d.cts +2 -4
  120. package/dist/lib/entry.d.ts +2 -4
  121. package/dist/lib/index.cjs +96 -74
  122. package/dist/lib/index.d.cts +26 -23
  123. package/dist/lib/index.d.ts +26 -23
  124. package/dist/lib/index.js +18 -12
  125. package/dist/lib/internal-CpVMJCaU.d.ts +39 -0
  126. package/dist/lib/internal-ypnrUNZy.d.cts +39 -0
  127. package/dist/lib/logger.d.cts +4 -5
  128. package/dist/lib/logger.d.ts +4 -5
  129. package/dist/lib/typescript/compiler-host.cjs +1 -1
  130. package/dist/lib/typescript/compiler-host.d.cts +5 -5
  131. package/dist/lib/typescript/compiler-host.d.ts +5 -5
  132. package/dist/lib/typescript/compiler-host.js +1 -1
  133. package/dist/lib/typescript/import-transformer.d.cts +2 -4
  134. package/dist/lib/typescript/import-transformer.d.ts +2 -4
  135. package/dist/lib/typescript/index.cjs +29 -24
  136. package/dist/lib/typescript/index.d.cts +6 -6
  137. package/dist/lib/typescript/index.d.ts +6 -6
  138. package/dist/lib/typescript/index.js +3 -2
  139. package/dist/lib/typescript/isolated-decl.d.cts +2 -1
  140. package/dist/lib/typescript/isolated-decl.d.ts +2 -1
  141. package/dist/lib/typescript/program.d.cts +5 -5
  142. package/dist/lib/typescript/program.d.ts +5 -5
  143. package/dist/lib/typescript/ts-morph.cjs +11 -0
  144. package/dist/lib/{create-program.d.ts → typescript/ts-morph.d.cts} +3 -5
  145. package/dist/lib/{create-program.d.cts → typescript/ts-morph.d.ts} +3 -5
  146. package/dist/lib/typescript/ts-morph.js +2 -0
  147. package/dist/lib/unplugin/factory.cjs +8 -4
  148. package/dist/lib/unplugin/factory.d.cts +27 -10
  149. package/dist/lib/unplugin/factory.d.ts +27 -10
  150. package/dist/lib/unplugin/factory.js +7 -3
  151. package/dist/lib/unplugin/helpers.cjs +11 -0
  152. package/dist/lib/unplugin/helpers.d.cts +128 -0
  153. package/dist/lib/unplugin/helpers.d.ts +128 -0
  154. package/dist/lib/unplugin/helpers.js +2 -0
  155. package/dist/lib/unplugin/index.cjs +12 -7
  156. package/dist/lib/unplugin/index.d.cts +6 -8
  157. package/dist/lib/unplugin/index.d.ts +6 -8
  158. package/dist/lib/unplugin/index.js +9 -4
  159. package/dist/lib/unplugin/plugin.cjs +4 -3
  160. package/dist/lib/unplugin/plugin.d.cts +4 -5
  161. package/dist/lib/unplugin/plugin.d.ts +4 -5
  162. package/dist/lib/unplugin/plugin.js +3 -2
  163. package/dist/lib/unplugin/resolve-id.cjs +2 -2
  164. package/dist/lib/unplugin/resolve-id.d.cts +5 -5
  165. package/dist/lib/unplugin/resolve-id.d.ts +5 -5
  166. package/dist/lib/unplugin/resolve-id.js +1 -1
  167. package/dist/lib/utilities/bundle.d.cts +2 -4
  168. package/dist/lib/utilities/bundle.d.ts +2 -4
  169. package/dist/lib/utilities/cache.d.cts +2 -4
  170. package/dist/lib/utilities/cache.d.ts +2 -4
  171. package/dist/lib/utilities/file-header.d.cts +4 -5
  172. package/dist/lib/utilities/file-header.d.ts +4 -5
  173. package/dist/lib/utilities/index.cjs +18 -18
  174. package/dist/lib/utilities/index.d.cts +5 -7
  175. package/dist/lib/utilities/index.d.ts +5 -7
  176. package/dist/lib/utilities/index.js +4 -4
  177. package/dist/lib/utilities/meta.d.cts +4 -5
  178. package/dist/lib/utilities/meta.d.ts +4 -5
  179. package/dist/lib/utilities/resolve-path.d.cts +2 -4
  180. package/dist/lib/utilities/resolve-path.d.ts +2 -4
  181. package/dist/lib/utilities/resolve.d.cts +2 -4
  182. package/dist/lib/utilities/resolve.d.ts +2 -4
  183. package/dist/lib/utilities/source-file.d.cts +2 -4
  184. package/dist/lib/utilities/source-file.d.ts +2 -4
  185. package/dist/lib/utilities/source-map.d.cts +2 -4
  186. package/dist/lib/utilities/source-map.d.ts +2 -4
  187. package/dist/lib/utilities/worker.d.cts +4 -5
  188. package/dist/lib/utilities/worker.d.ts +4 -5
  189. package/dist/lib/utilities/write-file.d.cts +2 -4
  190. package/dist/lib/utilities/write-file.d.ts +2 -4
  191. package/dist/next.cjs +8 -8
  192. package/dist/next.js +5 -5
  193. package/dist/nuxt.cjs +9 -9
  194. package/dist/nuxt.js +6 -6
  195. package/dist/plugin-utils/{context-D1I2JQgs.d.cts → context-DRFZE3XI.d.cts} +535 -518
  196. package/dist/plugin-utils/{context-D1I2JQgs.d.ts → context-DRFZE3XI.d.ts} +535 -518
  197. package/dist/plugin-utils/context-helpers.d.cts +2 -4
  198. package/dist/plugin-utils/context-helpers.d.ts +2 -4
  199. package/dist/plugin-utils/enforce.d.cts +2 -4
  200. package/dist/plugin-utils/enforce.d.ts +2 -4
  201. package/dist/plugin-utils/extend.d.cts +2 -4
  202. package/dist/plugin-utils/extend.d.ts +2 -4
  203. package/dist/plugin-utils/get-config-path.d.cts +2 -4
  204. package/dist/plugin-utils/get-config-path.d.ts +2 -4
  205. package/dist/plugin-utils/helpers.d.cts +2 -4
  206. package/dist/plugin-utils/helpers.d.ts +2 -4
  207. package/dist/plugin-utils/index.d.cts +3 -5
  208. package/dist/plugin-utils/index.d.ts +3 -5
  209. package/dist/plugin-utils/merge.d.cts +4 -5
  210. package/dist/plugin-utils/merge.d.ts +4 -5
  211. package/dist/plugin-utils/paths.d.cts +2 -4
  212. package/dist/plugin-utils/paths.d.ts +2 -4
  213. package/dist/{resolved-DYLxPDut.d.cts → resolved-C00CJgsk.d.cts} +128 -9
  214. package/dist/{resolved-D1ySEdUv.d.ts → resolved-DKFZ11S7.d.ts} +128 -9
  215. package/dist/rolldown.cjs +7 -7
  216. package/dist/rolldown.d.cts +3 -5
  217. package/dist/rolldown.d.ts +3 -5
  218. package/dist/rolldown.js +4 -4
  219. package/dist/rollup.cjs +7 -7
  220. package/dist/rollup.d.cts +3 -5
  221. package/dist/rollup.d.ts +3 -5
  222. package/dist/rollup.js +4 -4
  223. package/dist/rspack.cjs +7 -7
  224. package/dist/rspack.d.cts +3 -5
  225. package/dist/rspack.d.ts +3 -5
  226. package/dist/rspack.js +4 -4
  227. package/dist/tsup.cjs +8 -8
  228. package/dist/tsup.js +5 -5
  229. package/dist/types/api.cjs +4 -0
  230. package/dist/types/api.d.cts +36 -0
  231. package/dist/types/api.d.ts +36 -0
  232. package/dist/types/api.js +1 -0
  233. package/dist/types/babel.d.cts +3 -5
  234. package/dist/types/babel.d.ts +3 -5
  235. package/dist/types/build.d.cts +26 -1
  236. package/dist/types/build.d.ts +26 -1
  237. package/dist/types/commands.d.cts +3 -5
  238. package/dist/types/commands.d.ts +3 -5
  239. package/dist/types/config.d.cts +3 -5
  240. package/dist/types/config.d.ts +3 -5
  241. package/dist/types/context.d.cts +3 -5
  242. package/dist/types/context.d.ts +3 -5
  243. package/dist/types/{vfs.cjs → fs.cjs} +3 -3
  244. package/dist/types/{vfs.d.cts → fs.d.cts} +54 -35
  245. package/dist/types/{vfs.d.ts → fs.d.ts} +54 -35
  246. package/dist/types/fs.js +2 -0
  247. package/dist/types/hooks.d.cts +3 -5
  248. package/dist/types/hooks.d.ts +3 -5
  249. package/dist/types/index.cjs +9 -8
  250. package/dist/types/index.d.cts +8 -9
  251. package/dist/types/index.d.ts +8 -9
  252. package/dist/types/index.js +3 -2
  253. package/dist/types/internal.d.cts +46 -9
  254. package/dist/types/internal.d.ts +46 -9
  255. package/dist/types/plugin.d.cts +3 -5
  256. package/dist/types/plugin.d.ts +3 -5
  257. package/dist/types/resolved.d.cts +3 -5
  258. package/dist/types/resolved.d.ts +3 -5
  259. package/dist/types/tsconfig.d.cts +8 -1
  260. package/dist/types/tsconfig.d.ts +8 -1
  261. package/dist/types/typedoc.d.cts +3 -1
  262. package/dist/types/typedoc.d.ts +3 -1
  263. package/dist/types/unplugin.d.cts +22 -11
  264. package/dist/types/unplugin.d.ts +22 -11
  265. package/dist/unloader.cjs +7 -7
  266. package/dist/unloader.d.cts +12 -14
  267. package/dist/unloader.d.ts +12 -14
  268. package/dist/unloader.js +4 -4
  269. package/dist/unplugin.cjs +18 -18
  270. package/dist/unplugin.d.cts +6 -9
  271. package/dist/unplugin.d.ts +6 -9
  272. package/dist/unplugin.js +15 -15
  273. package/dist/vite.cjs +7 -7
  274. package/dist/vite.d.cts +3 -5
  275. package/dist/vite.d.ts +3 -5
  276. package/dist/vite.js +4 -4
  277. package/dist/webpack.cjs +7 -7
  278. package/dist/webpack.d.cts +3 -5
  279. package/dist/webpack.d.ts +3 -5
  280. package/dist/webpack.js +4 -4
  281. package/package.json +39 -11
  282. package/schemas/fs.capnp +73 -15
  283. package/dist/chunk-RODEAGIJ.cjs +0 -32
  284. package/dist/chunk-SKLSRHBU.js +0 -29
  285. package/dist/hooks-D2UGCryi.d.ts +0 -28
  286. package/dist/hooks-DJG3B-Hw.d.cts +0 -28
  287. package/dist/lib/create-program.cjs +0 -11
  288. package/dist/lib/create-program.js +0 -2
  289. package/dist/lib/hooks-CDLPWf7j.d.cts +0 -28
  290. package/dist/lib/hooks-Cn-IqwYp.d.ts +0 -28
  291. package/dist/types/vfs.js +0 -2
  292. /package/dist/{chunk-KIKTWMI3.cjs → chunk-2NCILNCH.cjs} +0 -0
  293. /package/dist/{chunk-XVLT2RQ2.js → chunk-BLNT5INX.js} +0 -0
  294. /package/dist/{lib/chunk-RJ4277VZ.cjs → chunk-GRU7B3QM.cjs} +0 -0
  295. /package/dist/{lib/chunk-ZBLDAREE.js → chunk-T2P533I5.js} +0 -0
  296. /package/dist/lib/{chunk-CGYAL3S2.cjs → chunk-4EIXDLFP.cjs} +0 -0
  297. /package/dist/lib/{chunk-CXRSMYEX.js → chunk-RD5AUWXN.js} +0 -0
@@ -0,0 +1,1218 @@
1
+ 'use strict';
2
+
3
+ var chunk2NZADVP5_cjs = require('./chunk-2NZADVP5.cjs');
4
+ var chunk4NHFXDTQ_cjs = require('./chunk-4NHFXDTQ.cjs');
5
+ var chunkZBDVQVUK_cjs = require('./chunk-ZBDVQVUK.cjs');
6
+ var chunkBQU53ZNB_cjs = require('./chunk-BQU53ZNB.cjs');
7
+ var chunkUHGGYHSK_cjs = require('./chunk-UHGGYHSK.cjs');
8
+ var chunkB3EE3VHZ_cjs = require('./chunk-B3EE3VHZ.cjs');
9
+ var chunkPYQADZVV_cjs = require('./chunk-PYQADZVV.cjs');
10
+ var chunk7XHBIYIN_cjs = require('./chunk-7XHBIYIN.cjs');
11
+ var chunkJA4HSQRN_cjs = require('./chunk-JA4HSQRN.cjs');
12
+ var chunk3OCI4TH7_cjs = require('./chunk-3OCI4TH7.cjs');
13
+ var chunkISBHXSDH_cjs = require('./chunk-ISBHXSDH.cjs');
14
+ var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
15
+ var types = require('@storm-software/config-tools/types');
16
+ var getWorkspaceRoot = require('@stryke/fs/get-workspace-root');
17
+ var bundleRequire = require('bundle-require');
18
+ var core = require('@babel/core');
19
+ var console = require('@storm-software/config-tools/logger/console');
20
+ var toArray = require('@stryke/convert/to-array');
21
+ var copyFile = require('@stryke/fs/copy-file');
22
+ var exists = require('@stryke/fs/exists');
23
+ var helpers = require('@stryke/fs/helpers');
24
+ var install = require('@stryke/fs/install');
25
+ var listFiles = require('@stryke/fs/list-files');
26
+ var packageFns = require('@stryke/fs/package-fns');
27
+ var resolve = require('@stryke/fs/resolve');
28
+ var append = require('@stryke/path/append');
29
+ var joinPaths = require('@stryke/path/join-paths');
30
+ var replace = require('@stryke/path/replace');
31
+ var isError = require('@stryke/type-checks/is-error');
32
+ var isFunction = require('@stryke/type-checks/is-function');
33
+ var isNumber = require('@stryke/type-checks/is-number');
34
+ var isPromise = require('@stryke/type-checks/is-promise');
35
+ var isSet = require('@stryke/type-checks/is-set');
36
+ var isSetObject = require('@stryke/type-checks/is-set-object');
37
+ var isSetString = require('@stryke/type-checks/is-set-string');
38
+ var chalk2 = require('chalk');
39
+ var defu = require('defu');
40
+ var Handlebars = require('handlebars');
41
+ var helperPluginUtils = require('@babel/helper-plugin-utils');
42
+ var t = require('@babel/types');
43
+ var ts = require('typescript');
44
+ var _package = require('@stryke/string-format/package');
45
+ var superdiff = require('@donedeal0/superdiff');
46
+ var json = require('@stryke/fs/json');
47
+ var tsconfig = require('@stryke/fs/tsconfig');
48
+ var stormJson = require('@stryke/json/storm-json');
49
+ var filePathFns = require('@stryke/path/file-path-fns');
50
+ var titleCase = require('@stryke/string-format/title-case');
51
+
52
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
53
+
54
+ function _interopNamespace(e) {
55
+ if (e && e.__esModule) return e;
56
+ var n = Object.create(null);
57
+ if (e) {
58
+ Object.keys(e).forEach(function (k) {
59
+ if (k !== 'default') {
60
+ var d = Object.getOwnPropertyDescriptor(e, k);
61
+ Object.defineProperty(n, k, d.get ? d : {
62
+ enumerable: true,
63
+ get: function () { return e[k]; }
64
+ });
65
+ }
66
+ });
67
+ }
68
+ n.default = e;
69
+ return Object.freeze(n);
70
+ }
71
+
72
+ var chalk2__default = /*#__PURE__*/_interopDefault(chalk2);
73
+ var defu__default = /*#__PURE__*/_interopDefault(defu);
74
+ var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
75
+ var t__namespace = /*#__PURE__*/_interopNamespace(t);
76
+ var ts__default = /*#__PURE__*/_interopDefault(ts);
77
+
78
+ function resolveModulePath(nodePath, state) {
79
+ if (!t__namespace.isStringLiteral(nodePath.node)) {
80
+ return;
81
+ }
82
+ const sourcePath = nodePath.node.value;
83
+ const resolvedPath = state.context?.fs.resolve(sourcePath);
84
+ if (resolvedPath) {
85
+ nodePath.replaceWith(t__namespace.stringLiteral(
86
+ // Remove the file extension if it exists
87
+ resolvedPath.replace(/\.(?:ts|mts|cts)x?$/, "")
88
+ ));
89
+ }
90
+ }
91
+ chunkUSNT2KNT_cjs.__name(resolveModulePath, "resolveModulePath");
92
+ var TRANSFORM_FUNCTIONS = [
93
+ "require",
94
+ "require.resolve",
95
+ "System.import",
96
+ // Jest methods
97
+ "jest.genMockFromModule",
98
+ "jest.mock",
99
+ "jest.unmock",
100
+ "jest.doMock",
101
+ // eslint-disable-next-line @cspell/spellchecker
102
+ "jest.dontMock",
103
+ "jest.setMock",
104
+ "jest.requireActual",
105
+ "jest.requireMock",
106
+ // Older Jest methods
107
+ "require.requireActual",
108
+ "require.requireMock"
109
+ ];
110
+ function matchesPattern(state, calleePath, pattern) {
111
+ const { node } = calleePath;
112
+ if (t__namespace.isMemberExpression(node)) {
113
+ return calleePath.matchesPattern(pattern);
114
+ }
115
+ if (!t__namespace.isIdentifier(node) || pattern.includes(".")) {
116
+ return false;
117
+ }
118
+ const name = pattern.split(".")[0];
119
+ return node.name === name;
120
+ }
121
+ chunkUSNT2KNT_cjs.__name(matchesPattern, "matchesPattern");
122
+ var importVisitors = {
123
+ CallExpression: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((nodePath, state) => {
124
+ if (state.moduleResolverVisited.has(nodePath)) {
125
+ return;
126
+ }
127
+ const calleePath = nodePath.get("callee");
128
+ if (calleePath && TRANSFORM_FUNCTIONS.some((pattern) => matchesPattern(state, calleePath, pattern)) || t__namespace.isImport(nodePath.node.callee)) {
129
+ state.moduleResolverVisited.add(nodePath);
130
+ resolveModulePath(nodePath.get("arguments.0"), state);
131
+ }
132
+ }, "CallExpression"),
133
+ // eslint-disable-next-line ts/naming-convention
134
+ "ImportDeclaration|ExportDeclaration|ExportAllDeclaration": /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((nodePath, state) => {
135
+ if (!nodePath || !nodePath.get("source") || state.moduleResolverVisited.has(nodePath)) {
136
+ return;
137
+ }
138
+ state.moduleResolverVisited.add(nodePath);
139
+ resolveModulePath(nodePath.get("source"), state);
140
+ }, "ImportDeclaration|ExportDeclaration|ExportAllDeclaration")
141
+ };
142
+ var moduleResolverBabelPlugin = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((context) => {
143
+ return helperPluginUtils.declare(/* @__PURE__ */ chunkUSNT2KNT_cjs.__name(function builder(api) {
144
+ let moduleResolverVisited = /* @__PURE__ */ new Set();
145
+ return {
146
+ name: "powerlines:module-resolver",
147
+ manipulateOptions(opts) {
148
+ opts.filename ??= "unknown";
149
+ },
150
+ pre() {
151
+ moduleResolverVisited = /* @__PURE__ */ new Set();
152
+ },
153
+ visitor: {
154
+ Program: {
155
+ enter(programPath, state) {
156
+ programPath.traverse(importVisitors, {
157
+ ...state,
158
+ context,
159
+ moduleResolverVisited,
160
+ api
161
+ });
162
+ },
163
+ exit(programPath, state) {
164
+ programPath.traverse(importVisitors, {
165
+ ...state,
166
+ context,
167
+ moduleResolverVisited,
168
+ api
169
+ });
170
+ }
171
+ }
172
+ },
173
+ post() {
174
+ moduleResolverVisited.clear();
175
+ }
176
+ };
177
+ }, "builder"));
178
+ }, "moduleResolverBabelPlugin");
179
+ function formatTypes(code) {
180
+ return code.replace(
181
+ // eslint-disable-next-line regexp/no-super-linear-backtracking
182
+ /import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g,
183
+ ""
184
+ ).replaceAll("#private;", "").replace(/__Ω/g, "");
185
+ }
186
+ chunkUSNT2KNT_cjs.__name(formatTypes, "formatTypes");
187
+ async function emitTypes(context, tsconfig, files) {
188
+ context.log(types.LogLevelLabel.TRACE, "Creating the TypeScript compiler host");
189
+ const program = ts.createProgram(files, tsconfig.options, ts.createCompilerHost(tsconfig.options));
190
+ context.log(types.LogLevelLabel.TRACE, `Running the TypeScript compiler for ${context.builtins.length} built-in runtime files.`);
191
+ let builtinModules = "";
192
+ const emitResult = program.emit(void 0, (fileName, text, _, __, sourceFiles, _data) => {
193
+ const sourceFile = sourceFiles?.[0];
194
+ if (sourceFile?.fileName && !fileName.endsWith(".map")) {
195
+ if (context.builtins.some((file) => file === sourceFile.fileName || context.fs.metadata[file]?.id && context.fs.metadata[file]?.id === sourceFile.fileName)) {
196
+ builtinModules += `
197
+ declare module "${context.fs.resolve(sourceFile.fileName)}" {
198
+ ${text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
199
+ }
200
+ `;
201
+ }
202
+ }
203
+ }, void 0, true);
204
+ const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
205
+ const diagnosticMessages = [];
206
+ diagnostics.forEach((diagnostic) => {
207
+ if (diagnostic.file) {
208
+ const { line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
209
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
210
+ diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
211
+ } else {
212
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
213
+ diagnosticMessages.push(message);
214
+ }
215
+ });
216
+ const diagnosticMessage = diagnosticMessages.join("\n");
217
+ if (diagnosticMessage) {
218
+ throw new Error(`TypeScript compilation failed:
219
+
220
+ ${diagnosticMessage.length > 5e3 ? `${diagnosticMessage.slice(0, 5e3)}...` : diagnosticMessage}`);
221
+ }
222
+ return formatTypes(builtinModules);
223
+ }
224
+ chunkUSNT2KNT_cjs.__name(emitTypes, "emitTypes");
225
+ async function installPackage(context, packageName, dev = false) {
226
+ if (!await packageFns.isPackageListed(_package.getPackageName(packageName), {
227
+ cwd: context.config.projectRoot
228
+ })) {
229
+ if (context.config.skipInstalls !== true && !process.env.POWERLINES_LOCAL) {
230
+ context.log(types.LogLevelLabel.WARN, `The package "${packageName}" is not installed. It will be installed automatically.`);
231
+ const result = await install.install(packageName, {
232
+ cwd: context.config.projectRoot,
233
+ dev
234
+ });
235
+ if (isNumber.isNumber(result.exitCode) && result.exitCode > 0) {
236
+ context.log(types.LogLevelLabel.ERROR, result.stderr);
237
+ throw new Error(`An error occurred while installing the package "${packageName}"`);
238
+ }
239
+ } else {
240
+ context.log(types.LogLevelLabel.WARN, `The package "${packageName}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`);
241
+ }
242
+ } else if (_package.hasPackageVersion(packageName) && !process.env.POWERLINES_SKIP_VERSION_CHECK) {
243
+ const isMatching = await packageFns.doesPackageMatch(_package.getPackageName(packageName), _package.getPackageVersion(packageName), context.config.projectRoot);
244
+ if (!isMatching) {
245
+ const packageListing = await packageFns.getPackageListing(_package.getPackageName(packageName), {
246
+ cwd: context.config.projectRoot
247
+ });
248
+ if (!packageListing?.version.startsWith("catalog:") && !packageListing?.version.startsWith("workspace:")) {
249
+ context.log(types.LogLevelLabel.WARN, `The package "${_package.getPackageName(packageName)}" is installed but does not match the expected version ${_package.getPackageVersion(packageName)} (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.`);
250
+ }
251
+ }
252
+ }
253
+ }
254
+ chunkUSNT2KNT_cjs.__name(installPackage, "installPackage");
255
+
256
+ // src/internal/helpers/install-dependencies.ts
257
+ async function installDependencies(context) {
258
+ context.log(types.LogLevelLabel.TRACE, `Checking and installing missing project dependencies.`);
259
+ context.dependencies ??= {};
260
+ context.devDependencies ??= {};
261
+ if (Object.keys(context.dependencies).length === 0 && Object.keys(context.devDependencies).length === 0) {
262
+ context.log(types.LogLevelLabel.TRACE, `No dependencies or devDependencies to install. Skipping installation step.`);
263
+ return;
264
+ }
265
+ context.log(types.LogLevelLabel.DEBUG, `The following packages are required:
266
+ Dependencies:
267
+ ${Object.entries(context.dependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}
268
+
269
+ DevDependencies:
270
+ ${Object.entries(context.devDependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}`);
271
+ await Promise.all([
272
+ Promise.all(Object.entries(context.dependencies).map(async ([name, version]) => installPackage(context, `${_package.getPackageName(name)}@${String(version)}`, false))),
273
+ Promise.all(Object.entries(context.devDependencies).map(async ([name, version]) => installPackage(context, `${_package.getPackageName(name)}@${String(version)}`, true)))
274
+ ]);
275
+ }
276
+ chunkUSNT2KNT_cjs.__name(installDependencies, "installDependencies");
277
+ async function resolveTsconfigChanges(context) {
278
+ const tsconfig$1 = chunkBQU53ZNB_cjs.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw);
279
+ const tsconfigFilePath = chunkBQU53ZNB_cjs.getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
280
+ const tsconfigJson = await json.readJsonFile(tsconfigFilePath);
281
+ tsconfigJson.compilerOptions ??= {};
282
+ const extendedTsconfig = await tsconfig.loadTsConfig(tsconfigFilePath);
283
+ extendedTsconfig.compilerOptions ??= {};
284
+ if (tsconfigJson.reflection !== true) {
285
+ tsconfigJson.reflection = true;
286
+ }
287
+ if (tsconfig$1.options.experimentalDecorators !== true) {
288
+ tsconfigJson.compilerOptions.experimentalDecorators = true;
289
+ }
290
+ if (tsconfig$1.options.emitDecoratorMetadata !== true) {
291
+ tsconfigJson.compilerOptions.emitDecoratorMetadata = true;
292
+ }
293
+ if (context.config.output.dts) {
294
+ const dtsFilePath = context.config.output.dts ? context.config.output.dts.startsWith(context.workspaceConfig.workspaceRoot) ? context.config.output.dts : joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.output.dts) : joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, "storm.d.ts");
295
+ const dtsRelativePath = joinPaths.joinPaths(filePathFns.relativePath(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot), filePathFns.findFilePath(dtsFilePath)), filePathFns.findFileName(dtsFilePath));
296
+ if (!tsconfigJson.include?.some((filePattern) => chunkBQU53ZNB_cjs.isIncludeMatchFound(filePattern, [
297
+ dtsFilePath,
298
+ dtsRelativePath,
299
+ "storm.d.ts"
300
+ ]))) {
301
+ tsconfigJson.include ??= [];
302
+ tsconfigJson.include.push(dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath);
303
+ }
304
+ }
305
+ if (!tsconfig$1.options.lib?.some((lib) => [
306
+ "lib.esnext.d.ts",
307
+ "lib.es2021.d.ts",
308
+ "lib.es2022.d.ts",
309
+ "lib.es2023.d.ts"
310
+ ].includes(lib.toLowerCase()))) {
311
+ tsconfigJson.compilerOptions.lib ??= [];
312
+ tsconfigJson.compilerOptions.lib.push("esnext");
313
+ }
314
+ if (tsconfig$1.options.module !== ts__default.default.ModuleKind.ESNext) {
315
+ tsconfigJson.compilerOptions.module = "ESNext";
316
+ }
317
+ if (!tsconfig$1.options.target || ![
318
+ ts__default.default.ScriptTarget.ESNext,
319
+ ts__default.default.ScriptTarget.ES2024,
320
+ ts__default.default.ScriptTarget.ES2023,
321
+ ts__default.default.ScriptTarget.ES2022,
322
+ ts__default.default.ScriptTarget.ES2021
323
+ ].includes(tsconfig$1.options.target)) {
324
+ tsconfigJson.compilerOptions.target = "ESNext";
325
+ }
326
+ if (tsconfig$1.options.moduleResolution !== ts__default.default.ModuleResolutionKind.Bundler) {
327
+ tsconfigJson.compilerOptions.moduleResolution = "Bundler";
328
+ }
329
+ if (tsconfig$1.options.moduleDetection !== ts__default.default.ModuleDetectionKind.Force) {
330
+ tsconfigJson.compilerOptions.moduleDetection = "force";
331
+ }
332
+ if (tsconfig$1.options.allowSyntheticDefaultImports !== true) {
333
+ tsconfigJson.compilerOptions.allowSyntheticDefaultImports = true;
334
+ }
335
+ if (tsconfig$1.options.noImplicitOverride !== true) {
336
+ tsconfigJson.compilerOptions.noImplicitOverride = true;
337
+ }
338
+ if (tsconfig$1.options.noUncheckedIndexedAccess !== true) {
339
+ tsconfigJson.compilerOptions.noUncheckedIndexedAccess = true;
340
+ }
341
+ if (tsconfig$1.options.skipLibCheck !== true) {
342
+ tsconfigJson.compilerOptions.skipLibCheck = true;
343
+ }
344
+ if (tsconfig$1.options.resolveJsonModule !== true) {
345
+ tsconfigJson.compilerOptions.resolveJsonModule = true;
346
+ }
347
+ if (tsconfig$1.options.isolatedModules !== true) {
348
+ tsconfigJson.compilerOptions.isolatedModules = true;
349
+ }
350
+ if (tsconfig$1.options.verbatimModuleSyntax !== false) {
351
+ tsconfigJson.compilerOptions.verbatimModuleSyntax = false;
352
+ }
353
+ if (tsconfig$1.options.allowJs !== true) {
354
+ tsconfigJson.compilerOptions.allowJs = true;
355
+ }
356
+ if (tsconfig$1.options.esModuleInterop !== true) {
357
+ tsconfigJson.compilerOptions.esModuleInterop = true;
358
+ }
359
+ if (tsconfig$1.options.declaration !== true) {
360
+ tsconfigJson.compilerOptions.declaration = true;
361
+ }
362
+ if (context.environment.consumer === "client") {
363
+ if (tsconfig$1.options.jsx !== ts__default.default.JsxEmit.ReactJSX) {
364
+ tsconfigJson.compilerOptions.jsx = "react-jsx";
365
+ }
366
+ if (!tsconfig$1.options.lib?.some((lib) => lib.toLowerCase() !== "dom")) {
367
+ tsconfigJson.compilerOptions.lib ??= [];
368
+ tsconfigJson.compilerOptions.lib.push("dom");
369
+ }
370
+ if (!tsconfig$1.options.lib?.some((lib) => lib.toLowerCase() !== "dom.iterable")) {
371
+ tsconfigJson.compilerOptions.lib ??= [];
372
+ tsconfigJson.compilerOptions.lib.push("dom.iterable");
373
+ }
374
+ } else if (context.config.build.platform === "node") {
375
+ if (!tsconfig$1.options.types?.some((type) => type.toLowerCase() === "node" || type.toLowerCase() === "@types/node")) {
376
+ tsconfigJson.compilerOptions.types ??= [];
377
+ tsconfigJson.compilerOptions.types.push("node");
378
+ }
379
+ }
380
+ return tsconfigJson;
381
+ }
382
+ chunkUSNT2KNT_cjs.__name(resolveTsconfigChanges, "resolveTsconfigChanges");
383
+ async function initializeTsconfig(context) {
384
+ context.log(types.LogLevelLabel.TRACE, "Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.");
385
+ if (!packageFns.isPackageExists("typescript")) {
386
+ throw new Error('The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"');
387
+ }
388
+ const tsconfigFilePath = chunkBQU53ZNB_cjs.getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
389
+ context.tsconfig.originalTsconfigJson = await json.readJsonFile(tsconfigFilePath);
390
+ context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
391
+ await context.fs.writeFile(tsconfigFilePath, stormJson.StormJSON.stringify(context.tsconfig.tsconfigJson), {
392
+ mode: "fs"
393
+ });
394
+ context.tsconfig = chunkBQU53ZNB_cjs.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
395
+ }
396
+ chunkUSNT2KNT_cjs.__name(initializeTsconfig, "initializeTsconfig");
397
+ async function resolveTsconfig(context) {
398
+ const updateTsconfigJson = await json.readJsonFile(context.tsconfig.tsconfigFilePath);
399
+ if (updateTsconfigJson?.compilerOptions?.types && Array.isArray(updateTsconfigJson.compilerOptions.types) && !updateTsconfigJson.compilerOptions.types.length) {
400
+ delete updateTsconfigJson.compilerOptions.types;
401
+ }
402
+ const result = superdiff.getObjectDiff(context.tsconfig.originalTsconfigJson, updateTsconfigJson, {
403
+ ignoreArrayOrder: true,
404
+ showOnly: {
405
+ statuses: [
406
+ "added",
407
+ "deleted",
408
+ "updated"
409
+ ],
410
+ granularity: "deep"
411
+ }
412
+ });
413
+ const changes = [];
414
+ const getChanges = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((difference, property) => {
415
+ if (difference.status === "added" || difference.status === "deleted" || difference.status === "updated") {
416
+ if (difference.diff) {
417
+ for (const diff of difference.diff) {
418
+ getChanges(diff, property ? `${property}.${difference.property}` : difference.property);
419
+ }
420
+ } else {
421
+ changes.push({
422
+ field: property ? `${property}.${difference.property}` : difference.property,
423
+ status: difference.status,
424
+ previous: difference.status === "added" ? "---" : stormJson.StormJSON.stringify(difference.previousValue),
425
+ current: difference.status === "deleted" ? "---" : stormJson.StormJSON.stringify(difference.currentValue)
426
+ });
427
+ }
428
+ }
429
+ }, "getChanges");
430
+ for (const diff of result.diff) {
431
+ getChanges(diff);
432
+ }
433
+ if (changes.length > 0) {
434
+ context.log(types.LogLevelLabel.WARN, `Updating the following configuration values in "${context.tsconfig.tsconfigFilePath}" file:
435
+
436
+ ${changes.map((change, i) => `${chalk2__default.default.bold.whiteBright(`${i + 1}. ${titleCase.titleCase(change.status)} the ${change.field} field: `)}
437
+ ${chalk2__default.default.red(` - Previous: ${change.previous} `)}
438
+ ${chalk2__default.default.green(` - Updated: ${change.current} `)}
439
+ `).join("\n")}
440
+ `);
441
+ }
442
+ await chunk2NZADVP5_cjs.writeFile(context.log, context.tsconfig.tsconfigFilePath, stormJson.StormJSON.stringify(updateTsconfigJson));
443
+ context.tsconfig = chunkBQU53ZNB_cjs.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
444
+ if (!context.tsconfig) {
445
+ throw new Error("Failed to parse the TypeScript configuration file.");
446
+ }
447
+ context.tsconfig.tsconfigJson.compilerOptions ??= {};
448
+ context.tsconfig.tsconfigJson.compilerOptions.strict = false;
449
+ }
450
+ chunkUSNT2KNT_cjs.__name(resolveTsconfig, "resolveTsconfig");
451
+
452
+ // src/api.ts
453
+ var PowerlinesAPI = class _PowerlinesAPI {
454
+ static {
455
+ chunkUSNT2KNT_cjs.__name(this, "PowerlinesAPI");
456
+ }
457
+ /**
458
+ * The Powerlines context
459
+ */
460
+ #context;
461
+ /**
462
+ * The Powerlines context
463
+ */
464
+ get context() {
465
+ return this.#context;
466
+ }
467
+ /**
468
+ * Create a new Powerlines API instance
469
+ *
470
+ * @param context - The Powerlines context
471
+ */
472
+ constructor(context) {
473
+ this.#context = context;
474
+ }
475
+ /**
476
+ * Initialize the Powerlines API
477
+ */
478
+ static async from(workspaceRoot, config) {
479
+ const api = new _PowerlinesAPI(await chunkUHGGYHSK_cjs.PowerlinesAPIContext.from(workspaceRoot, config));
480
+ api.#context.$$internal.api = api;
481
+ for (const plugin of api.context.config.plugins ?? []) {
482
+ await api.#addPlugin(plugin);
483
+ }
484
+ if (api.context.plugins.length === 0) {
485
+ api.context.log(types.LogLevelLabel.WARN, "No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.");
486
+ }
487
+ const pluginConfig = await chunkB3EE3VHZ_cjs.callHook(await api.context.getEnvironment(), "config", {
488
+ sequential: true,
489
+ result: "merge"
490
+ });
491
+ await api.context.withUserConfig(pluginConfig, {
492
+ isHighPriority: false
493
+ });
494
+ return api;
495
+ }
496
+ /**
497
+ * Prepare the Powerlines API
498
+ *
499
+ * @remarks
500
+ * This method will prepare the Powerlines API for use, initializing any necessary resources.
501
+ *
502
+ * @param inlineConfig - The inline configuration for the prepare command
503
+ */
504
+ async prepare(inlineConfig = {
505
+ command: "prepare"
506
+ }) {
507
+ this.context.log(types.LogLevelLabel.TRACE, " \u{1F3D7}\uFE0F Preparing the Powerlines project");
508
+ this.context.log(types.LogLevelLabel.TRACE, " \u2699\uFE0F Aggregating configuration options for the Powerlines project");
509
+ await this.context.withInlineConfig(inlineConfig);
510
+ await this.#executeEnvironments(async (context) => {
511
+ context.log(types.LogLevelLabel.TRACE, `Initializing the processing options for the Powerlines project.`);
512
+ await this.callPreHook(context, "configResolved");
513
+ await initializeTsconfig(context);
514
+ await this.callNormalHook(context, "configResolved");
515
+ context.log(types.LogLevelLabel.DEBUG, `The configuration provided ${toArray.toArray(context.config.entry).length} entry point(s), Powerlines has found ${context.entry.length} entry files(s) for the ${context.config.title} project${context.entry.length > 0 && context.entry.length < 10 ? `:
516
+ ${context.entry.map((entry) => `- ${entry.input.file || entry.file}${entry.output ? ` -> ${entry.output}` : ""}`).join(" \n")}` : ""}.`);
517
+ await resolveTsconfig(context);
518
+ await installDependencies(context);
519
+ await this.callPostHook(context, "configResolved");
520
+ if (context.config.build.polyfill) {
521
+ context.config.build.polyfill = context.config.build.polyfill.map((polyfill) => chunkISBHXSDH_cjs.replacePathTokens(context, polyfill));
522
+ }
523
+ context.log(types.LogLevelLabel.TRACE, `Powerlines configuration has been resolved:
524
+
525
+ ${console.formatLogMessage(context.config)}`);
526
+ context.fs[chunkPYQADZVV_cjs.__VFS_PATCH__]();
527
+ await chunk7XHBIYIN_cjs.writeMetaFile(context);
528
+ context.persistedMeta = context.meta;
529
+ if (!exists.existsSync(context.cachePath)) {
530
+ await helpers.createDirectory(context.cachePath);
531
+ }
532
+ if (!exists.existsSync(context.dataPath)) {
533
+ await helpers.createDirectory(context.dataPath);
534
+ }
535
+ await this.callPreHook(context, "prepare");
536
+ await this.callNormalHook(context, "prepare");
537
+ if (context.config.output.dts !== false) {
538
+ context.log(types.LogLevelLabel.TRACE, `Preparing the TypeScript definitions for the Powerlines project.`);
539
+ context.log(types.LogLevelLabel.TRACE, "Transforming built-ins runtime modules files.");
540
+ const builtinFilePaths = await Promise.all((await context.getBuiltins()).map(async (file) => {
541
+ const result2 = await core.transformAsync(file.code.toString(), {
542
+ highlightCode: true,
543
+ code: true,
544
+ ast: false,
545
+ cloneInputAst: false,
546
+ comments: true,
547
+ sourceType: "module",
548
+ configFile: false,
549
+ babelrc: false,
550
+ envName: context.config.mode,
551
+ caller: {
552
+ name: "powerlines"
553
+ },
554
+ ...context.config.transform.babel,
555
+ filename: file.path,
556
+ plugins: [
557
+ [
558
+ "@babel/plugin-syntax-typescript"
559
+ ],
560
+ [
561
+ moduleResolverBabelPlugin(context)
562
+ ]
563
+ ]
564
+ });
565
+ if (!result2?.code) {
566
+ throw new Error(`Powerlines - Generate Types failed to compile ${file.id}`);
567
+ }
568
+ context.log(types.LogLevelLabel.TRACE, `Writing transformed built-in runtime file ${file.id}.`);
569
+ await context.emitBuiltin(result2.code, file.id, file.path);
570
+ return file.path;
571
+ }));
572
+ const typescriptPath = await resolve.resolvePackage("typescript");
573
+ if (!typescriptPath) {
574
+ throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
575
+ }
576
+ const files = builtinFilePaths.reduce((ret, fileName) => {
577
+ const formatted = replace.replacePath(fileName, context.workspaceConfig.workspaceRoot);
578
+ if (!ret.includes(formatted)) {
579
+ ret.push(formatted);
580
+ }
581
+ return ret;
582
+ }, [
583
+ joinPaths.joinPaths(typescriptPath, "lib", "lib.esnext.full.d.ts")
584
+ ]);
585
+ context.log(types.LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
586
+ const resolvedTsconfig = chunkBQU53ZNB_cjs.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu__default.default({
587
+ compilerOptions: {
588
+ strict: false,
589
+ noEmit: false,
590
+ declaration: true,
591
+ declarationMap: false,
592
+ emitDeclarationOnly: true,
593
+ skipLibCheck: true
594
+ },
595
+ exclude: [
596
+ "node_modules",
597
+ "dist"
598
+ ],
599
+ include: files
600
+ }, context.config.tsconfigRaw ?? {}));
601
+ resolvedTsconfig.options.configFilePath = joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.tsconfig.tsconfigFilePath);
602
+ resolvedTsconfig.options.pathsBasePath = context.workspaceConfig.workspaceRoot;
603
+ resolvedTsconfig.options.suppressOutputPathCheck = true;
604
+ let generatedTypes = await emitTypes(context, resolvedTsconfig, files);
605
+ context.log(types.LogLevelLabel.TRACE, `Generating TypeScript declaration file in ${context.config.output.dts}.`);
606
+ const directives = [];
607
+ let result = await this.callPreHook(context, "generateTypes", generatedTypes);
608
+ if (result) {
609
+ if (isSetObject.isSetObject(result)) {
610
+ generatedTypes = result.code;
611
+ if (Array.isArray(result.directives) && result.directives.length > 0) {
612
+ directives.push(...result.directives);
613
+ }
614
+ } else if (isSetString.isSetString(result)) {
615
+ generatedTypes = result;
616
+ }
617
+ }
618
+ result = await this.callNormalHook(context, "generateTypes", generatedTypes);
619
+ if (result) {
620
+ if (isSetObject.isSetObject(result)) {
621
+ generatedTypes = result.code;
622
+ if (Array.isArray(result.directives) && result.directives.length > 0) {
623
+ directives.push(...result.directives);
624
+ }
625
+ } else if (isSetString.isSetString(result)) {
626
+ generatedTypes = result;
627
+ }
628
+ }
629
+ result = await this.callPostHook(context, "generateTypes", generatedTypes);
630
+ if (result) {
631
+ if (isSetObject.isSetObject(result)) {
632
+ generatedTypes = result.code;
633
+ if (Array.isArray(result.directives) && result.directives.length > 0) {
634
+ directives.push(...result.directives);
635
+ }
636
+ } else if (isSetString.isSetString(result)) {
637
+ generatedTypes = result;
638
+ }
639
+ }
640
+ await context.fs.writeFile(context.config.output.dts, `${directives ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
641
+
642
+ ` : ""}${chunk4NHFXDTQ_cjs.getFileHeader(context, {
643
+ directive: null,
644
+ prettierIgnore: false
645
+ })}
646
+
647
+ ${formatTypes(generatedTypes)}
648
+ `, {
649
+ mode: "fs"
650
+ });
651
+ }
652
+ context.tsconfig = chunkBQU53ZNB_cjs.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
653
+ if (!context.tsconfig) {
654
+ throw new Error("Failed to parse the TypeScript configuration file.");
655
+ }
656
+ await this.callPostHook(context, "prepare");
657
+ await chunk7XHBIYIN_cjs.writeMetaFile(context);
658
+ context.fs[chunkPYQADZVV_cjs.__VFS_REVERT__]();
659
+ });
660
+ this.context.log(types.LogLevelLabel.INFO, "Powerlines API has been prepared successfully");
661
+ }
662
+ /**
663
+ * Create a new Powerlines project
664
+ *
665
+ * @remarks
666
+ * This method will create a new Powerlines project in the current directory.
667
+ *
668
+ * @param inlineConfig - The inline configuration for the new command
669
+ * @returns A promise that resolves when the project has been created
670
+ */
671
+ async new(inlineConfig) {
672
+ this.context.log(types.LogLevelLabel.INFO, "\u{1F195} Creating a new Powerlines project");
673
+ await this.prepare(inlineConfig);
674
+ await this.#executeEnvironments(async (context) => {
675
+ context.log(types.LogLevelLabel.TRACE, `Initializing the processing options for the Powerlines project.`);
676
+ await this.callPreHook(context, "new");
677
+ const files = await listFiles.listFiles(joinPaths.joinPaths(context.powerlinesPath, "files/common/**/*.hbs"));
678
+ for (const file of files) {
679
+ context.log(types.LogLevelLabel.TRACE, `Adding template file: ${file}`);
680
+ const template = Handlebars__default.default.compile(file);
681
+ await chunk2NZADVP5_cjs.writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
682
+ }
683
+ await this.callNormalHook(context, "new");
684
+ if (context.config.projectType === "application") {
685
+ const files2 = await listFiles.listFiles(joinPaths.joinPaths(context.powerlinesPath, "files/application/**/*.hbs"));
686
+ for (const file of files2) {
687
+ context.log(types.LogLevelLabel.TRACE, `Adding application template file: ${file}`);
688
+ const template = Handlebars__default.default.compile(file);
689
+ await chunk2NZADVP5_cjs.writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
690
+ }
691
+ } else {
692
+ const files2 = await listFiles.listFiles(joinPaths.joinPaths(context.powerlinesPath, "files/library/**/*.hbs"));
693
+ for (const file of files2) {
694
+ context.log(types.LogLevelLabel.TRACE, `Adding library template file: ${file}`);
695
+ const template = Handlebars__default.default.compile(file);
696
+ await chunk2NZADVP5_cjs.writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
697
+ }
698
+ }
699
+ await this.callPostHook(context, "new");
700
+ });
701
+ this.context.log(types.LogLevelLabel.TRACE, "Powerlines - New command completed");
702
+ }
703
+ /**
704
+ * Clean any previously prepared artifacts
705
+ *
706
+ * @remarks
707
+ * This method will remove the previous Powerlines artifacts from the project.
708
+ *
709
+ * @param inlineConfig - The inline configuration for the clean command
710
+ * @returns A promise that resolves when the clean command has completed
711
+ */
712
+ async clean(inlineConfig = {
713
+ command: "clean"
714
+ }) {
715
+ this.context.log(types.LogLevelLabel.INFO, "\u{1F9F9} Cleaning the previous Powerlines artifacts");
716
+ await this.prepare(inlineConfig);
717
+ await this.#executeEnvironments(async (context) => {
718
+ this.context.log(types.LogLevelLabel.TRACE, "Cleaning the project's dist and artifacts directories.");
719
+ await context.fs.rmdir(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.output.distPath));
720
+ await context.fs.rmdir(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.output.artifactsFolder));
721
+ await chunkB3EE3VHZ_cjs.callHook(context, "clean", {
722
+ sequential: true
723
+ });
724
+ });
725
+ this.context.log(types.LogLevelLabel.TRACE, "Powerlines - Clean command completed");
726
+ }
727
+ /**
728
+ * Lint the project
729
+ *
730
+ * @param inlineConfig - The inline configuration for the lint command
731
+ * @returns A promise that resolves when the lint command has completed
732
+ */
733
+ async lint(inlineConfig = {
734
+ command: "lint"
735
+ }) {
736
+ this.context.log(types.LogLevelLabel.INFO, "\u{1F4CB} Linting the Powerlines project");
737
+ await this.prepare(inlineConfig);
738
+ await this.#executeEnvironments(async (context) => {
739
+ if (context.config.lint !== false) {
740
+ await this.callHook(context, "lint");
741
+ }
742
+ });
743
+ this.context.log(types.LogLevelLabel.TRACE, "Powerlines linting completed");
744
+ }
745
+ /**
746
+ * Build the project
747
+ *
748
+ * @remarks
749
+ * This method will build the Powerlines project, generating the necessary artifacts.
750
+ *
751
+ * @param inlineConfig - The inline configuration for the build command
752
+ * @returns A promise that resolves when the build command has completed
753
+ */
754
+ async build(inlineConfig = {
755
+ command: "build"
756
+ }) {
757
+ this.context.log(types.LogLevelLabel.INFO, "\u{1F4E6} Building the Powerlines project");
758
+ await this.prepare(inlineConfig);
759
+ await this.#executeEnvironments(async (context) => {
760
+ await this.callPreHook(context, "build");
761
+ await this.callNormalHook(context, "build");
762
+ if (context.config.output.distPath !== context.config.output.outputPath) {
763
+ const sourcePath = append.appendPath(context.config.output.distPath, context.workspaceConfig.workspaceRoot);
764
+ const destinationPath = joinPaths.joinPaths(append.appendPath(context.config.output.outputPath, context.workspaceConfig.workspaceRoot), "dist");
765
+ if (sourcePath !== destinationPath) {
766
+ context.log(types.LogLevelLabel.INFO, `Copying build output files from project's build directory (${context.config.output.distPath}) to the workspace's output directory (${context.config.output.outputPath}).`);
767
+ await copyFile.copyFiles({
768
+ input: sourcePath,
769
+ glob: "**/*"
770
+ }, destinationPath);
771
+ }
772
+ }
773
+ await Promise.all(context.config.output.assets.map(async (asset) => {
774
+ context.log(types.LogLevelLabel.DEBUG, `Copying asset(s): ${chalk2__default.default.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : joinPaths.joinPaths(replace.replacePath(asset.input, context.workspaceConfig.workspaceRoot), asset.glob))} -> ${chalk2__default.default.greenBright(joinPaths.joinPaths(replace.replacePath(asset.output, context.workspaceConfig.workspaceRoot), asset.glob))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk2__default.default.yellowBright(i)).join(", ")})` : ""}`);
775
+ await copyFile.copyFiles(asset, asset.output);
776
+ }));
777
+ await this.callPostHook(context, "build");
778
+ });
779
+ this.context.log(types.LogLevelLabel.TRACE, "Powerlines build completed");
780
+ }
781
+ /**
782
+ * Prepare the documentation for the project
783
+ *
784
+ * @param inlineConfig - The inline configuration for the docs command
785
+ * @returns A promise that resolves when the documentation generation has completed
786
+ */
787
+ async docs(inlineConfig = {
788
+ command: "docs"
789
+ }) {
790
+ this.context.log(types.LogLevelLabel.INFO, "\u{1F4D3} Generating documentation for the Powerlines project");
791
+ await this.prepare(inlineConfig);
792
+ await this.#executeEnvironments(async (context) => {
793
+ context.log(types.LogLevelLabel.TRACE, "Writing documentation for the Powerlines project artifacts.");
794
+ await this.prepare(inlineConfig);
795
+ await this.#executeEnvironments(async (context2) => {
796
+ await this.callHook(context2, "docs");
797
+ });
798
+ });
799
+ this.#context.log(types.LogLevelLabel.TRACE, "Powerlines documentation generation completed");
800
+ }
801
+ /**
802
+ * Deploy the project source code
803
+ *
804
+ * @remarks
805
+ * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
806
+ *
807
+ * @param inlineConfig - The inline configuration for the deploy command
808
+ */
809
+ async deploy(inlineConfig = {
810
+ command: "deploy"
811
+ }) {
812
+ this.context.log(types.LogLevelLabel.INFO, "\u{1F4E6} Deploying the Powerlines project");
813
+ await this.prepare(inlineConfig);
814
+ await this.#executeEnvironments(async (context) => {
815
+ await this.callHook(context, "deploy");
816
+ });
817
+ this.context.log(types.LogLevelLabel.TRACE, "Powerlines deploy completed");
818
+ }
819
+ /**
820
+ * Finalization process
821
+ *
822
+ * @remarks
823
+ * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
824
+ *
825
+ * @returns A promise that resolves when the finalization process has completed
826
+ */
827
+ async finalize() {
828
+ this.context.log(types.LogLevelLabel.TRACE, "Powerlines finalize execution started");
829
+ await this.#executeEnvironments(async (context) => {
830
+ await this.callHook(context, "finalize");
831
+ context.fs[chunkPYQADZVV_cjs.__VFS_REVERT__]();
832
+ await context.fs.dispose();
833
+ });
834
+ this.context.log(types.LogLevelLabel.TRACE, "Powerlines finalize execution completed");
835
+ }
836
+ /**
837
+ * Calls a hook in parallel
838
+ *
839
+ * @param hook - The hook to call
840
+ * @param options - Options for calling the hook
841
+ * @param args - The arguments to pass to the hook
842
+ * @returns The result of the hook call
843
+ */
844
+ async callHookParallel(hook, options, ...args) {
845
+ return chunkB3EE3VHZ_cjs.callHook(isSetObject.isSetObject(options?.environment) ? options.environment : await this.#context.getEnvironment(options?.environment), hook, {
846
+ ...options,
847
+ sequential: false
848
+ }, ...args);
849
+ }
850
+ /**
851
+ * Calls a hook in sequence
852
+ *
853
+ * @param hook - The hook to call
854
+ * @param options - Options for calling the hook
855
+ * @param args - The arguments to pass to the hook
856
+ * @returns The result of the hook call
857
+ */
858
+ async callHookSequential(hook, options, ...args) {
859
+ return chunkB3EE3VHZ_cjs.callHook(isSetObject.isSetObject(options?.environment) ? options.environment : await this.#context.getEnvironment(options?.environment), hook, {
860
+ ...options,
861
+ sequential: true
862
+ }, ...args);
863
+ }
864
+ /**
865
+ * Calls the `"pre"` ordered hooks in sequence
866
+ *
867
+ * @param environment - The environment to use for the hook call
868
+ * @param hook - The hook to call
869
+ * @param args - The arguments to pass to the hook
870
+ * @returns The result of the hook call
871
+ */
872
+ async callPreHook(environment, hook, ...args) {
873
+ return this.callHookSequential(hook, {
874
+ order: "pre",
875
+ environment
876
+ }, ...args);
877
+ }
878
+ /**
879
+ * Calls the `"post"` ordered hooks in sequence
880
+ *
881
+ * @param environment - The environment to use for the hook call
882
+ * @param hook - The hook to call
883
+ * @param args - The arguments to pass to the hook
884
+ * @returns The result of the hook call
885
+ */
886
+ async callPostHook(environment, hook, ...args) {
887
+ return this.callHookSequential(hook, {
888
+ order: "post",
889
+ environment
890
+ }, ...args);
891
+ }
892
+ /**
893
+ * Calls a hook in sequence
894
+ *
895
+ * @param environment - The environment to use for the hook call
896
+ * @param hook - The hook to call
897
+ * @param args - The arguments to pass to the hook
898
+ * @returns The result of the hook call
899
+ */
900
+ async callNormalHook(environment, hook, ...args) {
901
+ return this.callHookSequential(hook, {
902
+ order: "normal",
903
+ environment
904
+ }, ...args);
905
+ }
906
+ /**
907
+ * Calls the `"pre"` and `"post"` ordered hooks, as well as the normal hooks in sequence
908
+ *
909
+ * @param environment - The environment to use for the hook call
910
+ * @param hook - The hook to call
911
+ * @param args - The arguments to pass to the hook
912
+ * @returns The result of the hook call
913
+ */
914
+ async callHook(environment, hook, ...args) {
915
+ return this.callHookSequential(hook, {
916
+ environment
917
+ }, ...args);
918
+ }
919
+ /**
920
+ * Dispose of the Powerlines API instance
921
+ *
922
+ * @remarks
923
+ * This method will finalize the Powerlines API instance, cleaning up any resources used.
924
+ */
925
+ async [Symbol.asyncDispose]() {
926
+ await this.finalize();
927
+ }
928
+ /**
929
+ * Get the configured environments
930
+ *
931
+ * @returns The configured environments
932
+ */
933
+ async #getEnvironments() {
934
+ if (!this.context.config.environments || Object.keys(this.context.config.environments).length <= 1) {
935
+ this.context.log(types.LogLevelLabel.DEBUG, "No environments are configured for this Powerlines project. Using the default environment.");
936
+ return [
937
+ await this.context.getEnvironment()
938
+ ];
939
+ }
940
+ this.context.log(types.LogLevelLabel.DEBUG, `Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`);
941
+ return (await Promise.all(Object.entries(this.context.config.environments).map(async ([name, config]) => {
942
+ const environment = await this.context.getEnvironmentSafe(name);
943
+ if (!environment) {
944
+ const resolvedEnvironment = await this.callHookParallel("configEnvironment", {
945
+ environment: name
946
+ }, name, config);
947
+ if (resolvedEnvironment) {
948
+ this.context.environments[name] = await this.context.in(resolvedEnvironment);
949
+ }
950
+ }
951
+ return this.context.environments[name];
952
+ }))).filter((context) => isSet.isSet(context));
953
+ }
954
+ /**
955
+ * Execute a handler function for each environment
956
+ *
957
+ * @param handle - The handler function to execute for each environment
958
+ */
959
+ async #executeEnvironments(handle) {
960
+ await Promise.all((await this.#getEnvironments()).map(async (context) => {
961
+ return Promise.resolve(handle(context));
962
+ }));
963
+ }
964
+ /**
965
+ * Add a Powerlines plugin used in the build process
966
+ *
967
+ * @param config - The import path of the plugin to add
968
+ */
969
+ async #addPlugin(config) {
970
+ if (config) {
971
+ const plugin = await this.#initPlugin(config);
972
+ if (!plugin) {
973
+ return;
974
+ }
975
+ if (plugin.dependsOn) {
976
+ for (const required of plugin.dependsOn) {
977
+ await this.#addPlugin(required);
978
+ }
979
+ }
980
+ this.context.log(types.LogLevelLabel.DEBUG, `Successfully initialized the ${chalk2__default.default.bold.cyanBright(plugin.name)} plugin`);
981
+ await this.context.addPlugin(plugin);
982
+ }
983
+ }
984
+ /**
985
+ * Initialize a Powerlines plugin
986
+ *
987
+ * @param config - The configuration for the plugin
988
+ * @returns The initialized plugin instance, or null if the plugin was a duplicate
989
+ * @throws Will throw an error if the plugin cannot be found or is invalid
990
+ */
991
+ async #initPlugin(config) {
992
+ let awaited = config;
993
+ if (isPromise.isPromiseLike(config)) {
994
+ awaited = await Promise.resolve(config);
995
+ }
996
+ if (!chunkPYQADZVV_cjs.isPluginConfig(awaited)) {
997
+ throw new Error(`Invalid plugin specified in the configuration - ${JSON.stringify(awaited)}. Please ensure the value is a plugin name, an object with the \`plugin\` and \`props\` properties, or an instance of \`Plugin\`.`);
998
+ }
999
+ let plugin;
1000
+ if (chunkPYQADZVV_cjs.isPlugin(awaited)) {
1001
+ plugin = awaited;
1002
+ } else if (isFunction.isFunction(awaited)) {
1003
+ plugin = await Promise.resolve(awaited());
1004
+ } else if (isSetString.isSetString(awaited)) {
1005
+ const resolved = await this.#resolvePlugin(awaited);
1006
+ if (isFunction.isFunction(resolved)) {
1007
+ plugin = await Promise.resolve(resolved());
1008
+ } else {
1009
+ plugin = resolved;
1010
+ }
1011
+ } else if (chunkPYQADZVV_cjs.isPluginConfigTuple(awaited) || chunkPYQADZVV_cjs.isPluginConfigObject(awaited)) {
1012
+ let pluginConfig;
1013
+ let pluginOptions;
1014
+ if (chunkPYQADZVV_cjs.isPluginConfigTuple(awaited)) {
1015
+ pluginConfig = awaited[0];
1016
+ pluginOptions = awaited?.length === 2 ? awaited[1] : void 0;
1017
+ } else {
1018
+ pluginConfig = awaited.plugin;
1019
+ pluginOptions = awaited.options;
1020
+ }
1021
+ if (isSetString.isSetString(pluginConfig)) {
1022
+ const resolved = await this.#resolvePlugin(pluginConfig);
1023
+ if (isFunction.isFunction(resolved)) {
1024
+ plugin = await Promise.resolve(pluginOptions ? resolved(pluginOptions) : resolved());
1025
+ } else {
1026
+ plugin = resolved;
1027
+ }
1028
+ } else if (isFunction.isFunction(pluginConfig)) {
1029
+ plugin = await Promise.resolve(pluginConfig(pluginOptions));
1030
+ } else if (chunkPYQADZVV_cjs.isPlugin(pluginConfig)) {
1031
+ plugin = pluginConfig;
1032
+ }
1033
+ }
1034
+ if (!plugin) {
1035
+ throw new Error(`The plugin configuration ${JSON.stringify(awaited)} is invalid. This configuration must point to a valid Powerlines plugin module.`);
1036
+ }
1037
+ if (!chunkPYQADZVV_cjs.isPlugin(plugin)) {
1038
+ throw new Error(`The plugin option ${JSON.stringify(plugin)} does not export a valid module. This configuration must point to a valid Powerlines plugin module.`);
1039
+ }
1040
+ if (chunkPYQADZVV_cjs.checkDedupe(plugin, this.context.plugins)) {
1041
+ this.context.log(types.LogLevelLabel.TRACE, `Duplicate ${chalk2__default.default.bold.cyanBright(plugin.name)} plugin dependency detected - Skipping initialization.`);
1042
+ return null;
1043
+ }
1044
+ this.context.log(types.LogLevelLabel.TRACE, `Initializing the ${chalk2__default.default.bold.cyanBright(plugin.name)} plugin...`);
1045
+ return plugin;
1046
+ }
1047
+ async #resolvePlugin(pluginPath) {
1048
+ if (pluginPath.startsWith("@") && pluginPath.split("/").filter(Boolean).length > 2) {
1049
+ const splits = pluginPath.split("/").filter(Boolean);
1050
+ pluginPath = `${splits[0]}/${splits[1]}`;
1051
+ }
1052
+ const isInstalled = packageFns.isPackageExists(pluginPath, {
1053
+ paths: [
1054
+ this.context.workspaceConfig.workspaceRoot,
1055
+ this.context.config.projectRoot
1056
+ ]
1057
+ });
1058
+ if (!isInstalled && this.context.config.skipInstalls !== true) {
1059
+ this.#context.log(types.LogLevelLabel.WARN, `The plugin package "${pluginPath}" is not installed. It will be installed automatically.`);
1060
+ const result = await install.install(pluginPath, {
1061
+ cwd: this.context.config.projectRoot
1062
+ });
1063
+ if (isNumber.isNumber(result.exitCode) && result.exitCode > 0) {
1064
+ this.#context.log(types.LogLevelLabel.ERROR, result.stderr);
1065
+ throw new Error(`An error occurred while installing the build plugin package "${pluginPath}" `);
1066
+ }
1067
+ }
1068
+ try {
1069
+ const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(joinPaths.joinPaths(pluginPath, "plugin")));
1070
+ const result = module.plugin ?? module.default;
1071
+ if (!result) {
1072
+ throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
1073
+ }
1074
+ return result;
1075
+ } catch (error) {
1076
+ try {
1077
+ const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(pluginPath));
1078
+ const result = module.plugin ?? module.default;
1079
+ if (!result) {
1080
+ throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
1081
+ }
1082
+ return result;
1083
+ } catch {
1084
+ if (!isInstalled) {
1085
+ throw new Error(`The plugin package "${pluginPath}" is not installed. Please install the package using the command: "npm install ${pluginPath} --save-dev"`);
1086
+ } else {
1087
+ throw new Error(`An error occurred while importing the build plugin package "${pluginPath}":
1088
+ ${isError.isError(error) ? error.message : String(error)}
1089
+
1090
+ Note: 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\`.`);
1091
+ }
1092
+ }
1093
+ }
1094
+ }
1095
+ };
1096
+
1097
+ // src/lib/unplugin/factory.ts
1098
+ function createUnpluginFactory(variant, decorate) {
1099
+ return (config, meta) => {
1100
+ const log = chunkJA4HSQRN_cjs.createLog("unplugin", config);
1101
+ log(types.LogLevelLabel.DEBUG, "Initializing Unplugin");
1102
+ try {
1103
+ const userConfig = {
1104
+ ...config,
1105
+ variant,
1106
+ unplugin: meta
1107
+ };
1108
+ let api;
1109
+ let resolvePatterns = [];
1110
+ async function buildStart() {
1111
+ log(types.LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
1112
+ const workspaceRoot = getWorkspaceRoot.getWorkspaceRoot(process.cwd());
1113
+ api = await PowerlinesAPI.from(workspaceRoot, userConfig);
1114
+ if (api.context.config.build.skipNodeModulesBundle) {
1115
+ resolvePatterns = bundleRequire.tsconfigPathsToRegExp(api.context.tsconfig.options.paths ?? []);
1116
+ }
1117
+ log(types.LogLevelLabel.DEBUG, "Preparing build artifacts for the Powerlines project...");
1118
+ await api.prepare({
1119
+ command: "build"
1120
+ });
1121
+ }
1122
+ chunkUSNT2KNT_cjs.__name(buildStart, "buildStart");
1123
+ async function resolveId(id, importer, options = {
1124
+ isEntry: false
1125
+ }) {
1126
+ return chunkZBDVQVUK_cjs.handleResolveId(api.context, {
1127
+ id,
1128
+ importer,
1129
+ options
1130
+ }, {
1131
+ skipNodeModulesBundle: api.context.config.build.skipNodeModulesBundle,
1132
+ external: api.context.config.build.external,
1133
+ noExternal: api.context.config.build.noExternal,
1134
+ resolvePatterns
1135
+ });
1136
+ }
1137
+ chunkUSNT2KNT_cjs.__name(resolveId, "resolveId");
1138
+ async function load(id) {
1139
+ const environment = await api.context.getEnvironment();
1140
+ if (id) {
1141
+ const resolvedPath = environment.fs.resolve(id);
1142
+ if (resolvedPath) {
1143
+ return environment.fs.readFile(resolvedPath);
1144
+ }
1145
+ }
1146
+ let result2 = await api.callPreHook(environment, "load", id);
1147
+ if (result2) {
1148
+ return result2;
1149
+ }
1150
+ result2 = await api.callNormalHook(environment, "load", id);
1151
+ if (result2) {
1152
+ return result2;
1153
+ }
1154
+ return api.callPostHook(environment, "load", id);
1155
+ }
1156
+ chunkUSNT2KNT_cjs.__name(load, "load");
1157
+ async function transform(code, id) {
1158
+ const environment = await api.context.getEnvironment();
1159
+ let transformed = code;
1160
+ let result2 = await api.callPreHook(environment, "transform", chunk3OCI4TH7_cjs.getString(transformed), id);
1161
+ if (result2) {
1162
+ transformed = result2;
1163
+ }
1164
+ result2 = await api.callNormalHook(environment, "transform", chunk3OCI4TH7_cjs.getString(transformed), id);
1165
+ if (result2) {
1166
+ transformed = result2;
1167
+ }
1168
+ result2 = await api.callPostHook(environment, "transform", chunk3OCI4TH7_cjs.getString(transformed), id);
1169
+ if (result2) {
1170
+ transformed = result2;
1171
+ }
1172
+ return transformed;
1173
+ }
1174
+ chunkUSNT2KNT_cjs.__name(transform, "transform");
1175
+ async function writeBundle() {
1176
+ log(types.LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
1177
+ const environment = await api.context.getEnvironment();
1178
+ await api.callHook(environment, "writeBundle");
1179
+ }
1180
+ chunkUSNT2KNT_cjs.__name(writeBundle, "writeBundle");
1181
+ const result = {
1182
+ name: "powerlines",
1183
+ api,
1184
+ resolveId: {
1185
+ filter: {
1186
+ id: {
1187
+ include: [
1188
+ /.*/
1189
+ ]
1190
+ }
1191
+ },
1192
+ handler: resolveId
1193
+ },
1194
+ load: {
1195
+ filter: {
1196
+ id: {
1197
+ include: [
1198
+ /.*/,
1199
+ /^storm:/
1200
+ ]
1201
+ }
1202
+ },
1203
+ handler: load
1204
+ },
1205
+ transform,
1206
+ buildStart,
1207
+ writeBundle
1208
+ };
1209
+ return decorate ? decorate(api, result) : result;
1210
+ } catch (error) {
1211
+ log(types.LogLevelLabel.FATAL, error?.message);
1212
+ throw error;
1213
+ }
1214
+ };
1215
+ }
1216
+ chunkUSNT2KNT_cjs.__name(createUnpluginFactory, "createUnpluginFactory");
1217
+
1218
+ exports.createUnpluginFactory = createUnpluginFactory;