powerlines 0.14.0 → 0.14.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 (728) hide show
  1. package/README.md +30 -21
  2. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  3. package/dist/_virtual/_rolldown/runtime.mjs +36 -0
  4. package/dist/api.cjs +10 -0
  5. package/dist/api.d.cts +2 -0
  6. package/dist/api.d.mts +2 -0
  7. package/dist/api.mjs +3 -0
  8. package/dist/astro.cjs +24 -28
  9. package/dist/astro.d.cts +14 -47
  10. package/dist/astro.d.cts.map +1 -0
  11. package/dist/astro.d.mts +25 -0
  12. package/dist/astro.d.mts.map +1 -0
  13. package/dist/astro.mjs +25 -0
  14. package/dist/astro.mjs.map +1 -0
  15. package/dist/config.cjs +9 -0
  16. package/dist/config.d.cts +1 -0
  17. package/dist/config.d.mts +1 -0
  18. package/dist/config.mjs +3 -0
  19. package/dist/constants.cjs +9 -0
  20. package/dist/constants.d.cts +1 -0
  21. package/dist/constants.d.mts +1 -0
  22. package/dist/constants.mjs +3 -0
  23. package/dist/context.cjs +9 -0
  24. package/dist/context.d.cts +1 -0
  25. package/dist/context.d.mts +1 -0
  26. package/dist/context.mjs +3 -0
  27. package/dist/engine.cjs +30 -0
  28. package/dist/engine.d.cts +24 -0
  29. package/dist/engine.d.cts.map +1 -0
  30. package/dist/engine.d.mts +24 -0
  31. package/dist/engine.d.mts.map +1 -0
  32. package/dist/engine.mjs +29 -0
  33. package/dist/engine.mjs.map +1 -0
  34. package/dist/esbuild.cjs +51 -23
  35. package/dist/esbuild.d.cts +13 -45
  36. package/dist/esbuild.d.cts.map +1 -0
  37. package/dist/esbuild.d.mts +25 -0
  38. package/dist/esbuild.d.mts.map +1 -0
  39. package/dist/esbuild.mjs +43 -0
  40. package/dist/esbuild.mjs.map +1 -0
  41. package/dist/farm.cjs +26 -18
  42. package/dist/farm.d.cts +15 -47
  43. package/dist/farm.d.cts.map +1 -0
  44. package/dist/farm.d.mts +25 -0
  45. package/dist/farm.d.mts.map +1 -0
  46. package/dist/farm.mjs +26 -0
  47. package/dist/farm.mjs.map +1 -0
  48. package/dist/index.cjs +40 -91
  49. package/dist/index.d.cts +21 -60
  50. package/dist/index.d.cts.map +1 -0
  51. package/dist/index.d.mts +26 -0
  52. package/dist/index.d.mts.map +1 -0
  53. package/dist/index.mjs +34 -0
  54. package/dist/index.mjs.map +1 -0
  55. package/dist/next.cjs +35 -27
  56. package/dist/next.d.cts +6 -4
  57. package/dist/next.d.cts.map +1 -0
  58. package/dist/{next.d.ts → next.d.mts} +6 -4
  59. package/dist/next.d.mts.map +1 -0
  60. package/dist/next.mjs +36 -0
  61. package/dist/next.mjs.map +1 -0
  62. package/dist/nuxt.cjs +44 -29
  63. package/dist/nuxt.d.cts +19 -10
  64. package/dist/nuxt.d.cts.map +1 -0
  65. package/dist/nuxt.d.mts +29 -0
  66. package/dist/nuxt.d.mts.map +1 -0
  67. package/dist/nuxt.mjs +44 -0
  68. package/dist/nuxt.mjs.map +1 -0
  69. package/dist/package.cjs +18 -0
  70. package/dist/package.mjs +7 -0
  71. package/dist/package.mjs.map +1 -0
  72. package/dist/plugin-utils.cjs +9 -0
  73. package/dist/plugin-utils.d.cts +1 -0
  74. package/dist/plugin-utils.d.mts +1 -0
  75. package/dist/plugin-utils.mjs +3 -0
  76. package/dist/rolldown.cjs +43 -22
  77. package/dist/rolldown.d.cts +10 -43
  78. package/dist/rolldown.d.cts.map +1 -0
  79. package/dist/rolldown.d.mts +24 -0
  80. package/dist/rolldown.d.mts.map +1 -0
  81. package/dist/rolldown.mjs +35 -0
  82. package/dist/rolldown.mjs.map +1 -0
  83. package/dist/rollup.cjs +34 -22
  84. package/dist/rollup.d.cts +11 -43
  85. package/dist/rollup.d.cts.map +1 -0
  86. package/dist/rollup.d.mts +25 -0
  87. package/dist/rollup.d.mts.map +1 -0
  88. package/dist/rollup.mjs +26 -0
  89. package/dist/rollup.mjs.map +1 -0
  90. package/dist/rspack.cjs +34 -22
  91. package/dist/rspack.d.cts +14 -46
  92. package/dist/rspack.d.cts.map +1 -0
  93. package/dist/rspack.d.mts +25 -0
  94. package/dist/rspack.d.mts.map +1 -0
  95. package/dist/rspack.mjs +26 -0
  96. package/dist/rspack.mjs.map +1 -0
  97. package/dist/schemas.cjs +9 -0
  98. package/dist/schemas.d.cts +1 -0
  99. package/dist/schemas.d.mts +1 -0
  100. package/dist/schemas.mjs +3 -0
  101. package/dist/storage.cjs +9 -0
  102. package/dist/storage.d.cts +1 -0
  103. package/dist/storage.d.mts +1 -0
  104. package/dist/storage.mjs +3 -0
  105. package/dist/tsdown.cjs +96 -0
  106. package/dist/tsdown.d.cts +31 -0
  107. package/dist/tsdown.d.cts.map +1 -0
  108. package/dist/tsdown.d.mts +31 -0
  109. package/dist/tsdown.d.mts.map +1 -0
  110. package/dist/tsdown.mjs +82 -0
  111. package/dist/tsdown.mjs.map +1 -0
  112. package/dist/tsup.cjs +67 -24
  113. package/dist/tsup.d.cts +12 -8
  114. package/dist/tsup.d.cts.map +1 -0
  115. package/dist/{tsup.d.ts → tsup.d.mts} +12 -8
  116. package/dist/tsup.d.mts.map +1 -0
  117. package/dist/tsup.mjs +59 -0
  118. package/dist/tsup.mjs.map +1 -0
  119. package/dist/types.cjs +0 -0
  120. package/dist/types.d.cts +8 -0
  121. package/dist/types.d.cts.map +1 -0
  122. package/dist/types.d.mts +8 -0
  123. package/dist/types.d.mts.map +1 -0
  124. package/dist/types.mjs +1 -0
  125. package/dist/typescript.cjs +9 -0
  126. package/dist/typescript.d.cts +1 -0
  127. package/dist/typescript.d.mts +1 -0
  128. package/dist/typescript.mjs +3 -0
  129. package/dist/unbuild.cjs +17 -0
  130. package/dist/unbuild.d.cts +2 -0
  131. package/dist/unbuild.d.mts +2 -0
  132. package/dist/unbuild.mjs +3 -0
  133. package/dist/unloader.cjs +23 -26
  134. package/dist/unloader.d.cts +11 -45
  135. package/dist/unloader.d.cts.map +1 -0
  136. package/dist/unloader.d.mts +22 -0
  137. package/dist/unloader.d.mts.map +1 -0
  138. package/dist/unloader.mjs +23 -0
  139. package/dist/unloader.mjs.map +1 -0
  140. package/dist/unplugin.cjs +105 -37
  141. package/dist/unplugin.d.cts +9 -69
  142. package/dist/unplugin.d.cts.map +1 -0
  143. package/dist/unplugin.d.mts +17 -0
  144. package/dist/unplugin.d.mts.map +1 -0
  145. package/dist/unplugin.mjs +101 -0
  146. package/dist/unplugin.mjs.map +1 -0
  147. package/dist/utils.cjs +25 -0
  148. package/dist/utils.d.cts +3 -0
  149. package/dist/utils.d.mts +3 -0
  150. package/dist/utils.mjs +7 -0
  151. package/dist/vite.cjs +76 -24
  152. package/dist/vite.d.cts +12 -44
  153. package/dist/vite.d.cts.map +1 -0
  154. package/dist/vite.d.mts +25 -0
  155. package/dist/vite.d.mts.map +1 -0
  156. package/dist/vite.mjs +66 -0
  157. package/dist/vite.mjs.map +1 -0
  158. package/dist/webpack.cjs +34 -23
  159. package/dist/webpack.d.cts +10 -43
  160. package/dist/webpack.d.cts.map +1 -0
  161. package/dist/webpack.d.mts +24 -0
  162. package/dist/webpack.d.mts.map +1 -0
  163. package/dist/webpack.mjs +25 -0
  164. package/dist/webpack.mjs.map +1 -0
  165. package/files/application/README.md.hbs +16 -42
  166. package/files/application/package.json.hbs +7 -28
  167. package/files/common/jest.config.ts.hbs +2 -3
  168. package/files/common/tsconfig.json.hbs +5 -10
  169. package/files/common/tsconfig.spec.json.hbs +3 -13
  170. package/files/library/README.md.hbs +11 -34
  171. package/files/library/package.json.hbs +9 -32
  172. package/package.json +253 -342
  173. package/schemas/fs.capnp +42 -0
  174. package/dist/astro.d.ts +0 -58
  175. package/dist/astro.js +0 -11
  176. package/dist/babel-types.d.ts +0 -292
  177. package/dist/chunk-22K72CJ5.cjs +0 -18
  178. package/dist/chunk-2VIXD2XB.js +0 -3
  179. package/dist/chunk-4AKYOJXA.cjs +0 -20
  180. package/dist/chunk-4HGQJ4KR.js +0 -11
  181. package/dist/chunk-4JCNAKOE.cjs +0 -4
  182. package/dist/chunk-5VPVJHJO.cjs +0 -18
  183. package/dist/chunk-6TJGZR5X.js +0 -46
  184. package/dist/chunk-6ZGIV2SU.cjs +0 -4
  185. package/dist/chunk-7BZQBW77.cjs +0 -4
  186. package/dist/chunk-7MTW3KR2.cjs +0 -12
  187. package/dist/chunk-7QVYU63E.js +0 -6
  188. package/dist/chunk-7UIYU6SC.js +0 -39
  189. package/dist/chunk-7WMWRX2S.cjs +0 -12
  190. package/dist/chunk-A3BBPLTY.js +0 -9
  191. package/dist/chunk-AFJCY3R6.js +0 -3
  192. package/dist/chunk-APVMN2H7.cjs +0 -14
  193. package/dist/chunk-AXIRZAL7.js +0 -3
  194. package/dist/chunk-BHP6KBGK.js +0 -16
  195. package/dist/chunk-BOIEJ5I6.js +0 -109
  196. package/dist/chunk-DELRP3WY.js +0 -31
  197. package/dist/chunk-DFLNRC3B.cjs +0 -4
  198. package/dist/chunk-DS7OM4NX.cjs +0 -4
  199. package/dist/chunk-DURCSSLV.js +0 -3
  200. package/dist/chunk-EBMELFCF.js +0 -12
  201. package/dist/chunk-ELHJY5WG.cjs +0 -34
  202. package/dist/chunk-FANQC345.cjs +0 -116
  203. package/dist/chunk-GC3BRYAK.cjs +0 -13
  204. package/dist/chunk-GIE6OE3X.js +0 -3
  205. package/dist/chunk-GV3S7ZR3.cjs +0 -34
  206. package/dist/chunk-HJW7OH6E.js +0 -3
  207. package/dist/chunk-IHUNA3MO.cjs +0 -4
  208. package/dist/chunk-KMLFL4CW.js +0 -14
  209. package/dist/chunk-L3DAMAEC.js +0 -21
  210. package/dist/chunk-LC6FLEJS.cjs +0 -12
  211. package/dist/chunk-LO77RPRV.js +0 -16
  212. package/dist/chunk-MAEKW52U.js +0 -31
  213. package/dist/chunk-MXJWCZDP.cjs +0 -12
  214. package/dist/chunk-NGKWITCO.js +0 -9
  215. package/dist/chunk-OC7CCD5M.cjs +0 -19
  216. package/dist/chunk-OYASPHNL.js +0 -3
  217. package/dist/chunk-P4BOYWXT.js +0 -3570
  218. package/dist/chunk-PJRHRDLS.cjs +0 -3602
  219. package/dist/chunk-PK6SKIKE.cjs +0 -8
  220. package/dist/chunk-Q7EJVZVI.cjs +0 -4
  221. package/dist/chunk-RBRFT2R6.js +0 -9
  222. package/dist/chunk-RU6BHTIP.cjs +0 -24
  223. package/dist/chunk-SIZKRND7.js +0 -12
  224. package/dist/chunk-SNARILEC.cjs +0 -24
  225. package/dist/chunk-SY7N6FC3.js +0 -9
  226. package/dist/chunk-TLHFXGYV.js +0 -3
  227. package/dist/chunk-UZQYBO6Z.cjs +0 -52
  228. package/dist/chunk-V5D5NVV7.cjs +0 -42
  229. package/dist/chunk-V7LXFIGK.js +0 -199
  230. package/dist/chunk-VNRXLY2T.js +0 -3
  231. package/dist/chunk-VQCQRLGM.cjs +0 -4
  232. package/dist/chunk-WCTOTE3T.cjs +0 -201
  233. package/dist/chunk-WD4363UW.cjs +0 -12
  234. package/dist/chunk-XBF43VLE.cjs +0 -4
  235. package/dist/chunk-XZO6ZJQP.cjs +0 -4
  236. package/dist/chunk-YIWHO6SW.cjs +0 -14
  237. package/dist/chunk-YZCTXGFH.js +0 -11
  238. package/dist/chunk-Z5H7LD6W.js +0 -3
  239. package/dist/chunk-ZP5QLZQ2.js +0 -21
  240. package/dist/chunk-ZQ7U35QZ.js +0 -9
  241. package/dist/define-config.cjs +0 -13
  242. package/dist/define-config.d.cts +0 -50
  243. package/dist/define-config.d.ts +0 -50
  244. package/dist/define-config.js +0 -4
  245. package/dist/esbuild.d.ts +0 -57
  246. package/dist/esbuild.js +0 -10
  247. package/dist/extend-plugin.cjs +0 -13
  248. package/dist/extend-plugin.d.cts +0 -48
  249. package/dist/extend-plugin.d.ts +0 -48
  250. package/dist/extend-plugin.js +0 -4
  251. package/dist/farm.d.ts +0 -57
  252. package/dist/farm.js +0 -14
  253. package/dist/hooks-Wrj1dKJ9.d.cts +0 -28
  254. package/dist/hooks-q1Az_C64.d.ts +0 -28
  255. package/dist/index.d.ts +0 -65
  256. package/dist/index.js +0 -40
  257. package/dist/internal/api.cjs +0 -16
  258. package/dist/internal/api.cjs.map +0 -1
  259. package/dist/internal/api.d.cts +0 -192
  260. package/dist/internal/api.d.ts +0 -192
  261. package/dist/internal/api.js +0 -7
  262. package/dist/internal/api.js.map +0 -1
  263. package/dist/lib/build/esbuild.cjs +0 -22
  264. package/dist/lib/build/esbuild.cjs.map +0 -1
  265. package/dist/lib/build/esbuild.d.cts +0 -51
  266. package/dist/lib/build/esbuild.d.ts +0 -51
  267. package/dist/lib/build/esbuild.js +0 -5
  268. package/dist/lib/build/esbuild.js.map +0 -1
  269. package/dist/lib/build/index.cjs +0 -82
  270. package/dist/lib/build/index.cjs.map +0 -1
  271. package/dist/lib/build/index.d.cts +0 -41
  272. package/dist/lib/build/index.d.ts +0 -41
  273. package/dist/lib/build/index.js +0 -13
  274. package/dist/lib/build/index.js.map +0 -1
  275. package/dist/lib/build/rolldown.cjs +0 -14
  276. package/dist/lib/build/rolldown.cjs.map +0 -1
  277. package/dist/lib/build/rolldown.d.cts +0 -42
  278. package/dist/lib/build/rolldown.d.ts +0 -42
  279. package/dist/lib/build/rolldown.js +0 -5
  280. package/dist/lib/build/rolldown.js.map +0 -1
  281. package/dist/lib/build/rollup.cjs +0 -17
  282. package/dist/lib/build/rollup.cjs.map +0 -1
  283. package/dist/lib/build/rollup.d.cts +0 -49
  284. package/dist/lib/build/rollup.d.ts +0 -49
  285. package/dist/lib/build/rollup.js +0 -4
  286. package/dist/lib/build/rollup.js.map +0 -1
  287. package/dist/lib/build/rspack.cjs +0 -13
  288. package/dist/lib/build/rspack.cjs.map +0 -1
  289. package/dist/lib/build/rspack.d.cts +0 -42
  290. package/dist/lib/build/rspack.d.ts +0 -42
  291. package/dist/lib/build/rspack.js +0 -4
  292. package/dist/lib/build/rspack.js.map +0 -1
  293. package/dist/lib/build/tsup.cjs +0 -23
  294. package/dist/lib/build/tsup.cjs.map +0 -1
  295. package/dist/lib/build/tsup.d.cts +0 -51
  296. package/dist/lib/build/tsup.d.ts +0 -51
  297. package/dist/lib/build/tsup.js +0 -6
  298. package/dist/lib/build/tsup.js.map +0 -1
  299. package/dist/lib/build/unbuild.cjs +0 -23
  300. package/dist/lib/build/unbuild.cjs.map +0 -1
  301. package/dist/lib/build/unbuild.d.cts +0 -63
  302. package/dist/lib/build/unbuild.d.ts +0 -63
  303. package/dist/lib/build/unbuild.js +0 -6
  304. package/dist/lib/build/unbuild.js.map +0 -1
  305. package/dist/lib/build/vite.cjs +0 -19
  306. package/dist/lib/build/vite.cjs.map +0 -1
  307. package/dist/lib/build/vite.d.cts +0 -43
  308. package/dist/lib/build/vite.d.ts +0 -43
  309. package/dist/lib/build/vite.js +0 -6
  310. package/dist/lib/build/vite.js.map +0 -1
  311. package/dist/lib/build/webpack.cjs +0 -13
  312. package/dist/lib/build/webpack.cjs.map +0 -1
  313. package/dist/lib/build/webpack.d.cts +0 -42
  314. package/dist/lib/build/webpack.d.ts +0 -42
  315. package/dist/lib/build/webpack.js +0 -4
  316. package/dist/lib/build/webpack.js.map +0 -1
  317. package/dist/lib/chunk-35EO5Y7R.js +0 -50
  318. package/dist/lib/chunk-35EO5Y7R.js.map +0 -1
  319. package/dist/lib/chunk-367E23MI.js +0 -48
  320. package/dist/lib/chunk-367E23MI.js.map +0 -1
  321. package/dist/lib/chunk-3GMJQ5G3.cjs +0 -4
  322. package/dist/lib/chunk-3GMJQ5G3.cjs.map +0 -1
  323. package/dist/lib/chunk-3I2YOM2E.js +0 -58
  324. package/dist/lib/chunk-3I2YOM2E.js.map +0 -1
  325. package/dist/lib/chunk-4BPHC6QQ.js +0 -3
  326. package/dist/lib/chunk-4BPHC6QQ.js.map +0 -1
  327. package/dist/lib/chunk-4XUVP2LL.cjs +0 -39
  328. package/dist/lib/chunk-4XUVP2LL.cjs.map +0 -1
  329. package/dist/lib/chunk-56LQSSQ3.js +0 -62
  330. package/dist/lib/chunk-56LQSSQ3.js.map +0 -1
  331. package/dist/lib/chunk-5PNLONNN.cjs +0 -30
  332. package/dist/lib/chunk-5PNLONNN.cjs.map +0 -1
  333. package/dist/lib/chunk-62ZJYXT3.cjs +0 -54
  334. package/dist/lib/chunk-62ZJYXT3.cjs.map +0 -1
  335. package/dist/lib/chunk-632PWWU7.cjs +0 -57
  336. package/dist/lib/chunk-632PWWU7.cjs.map +0 -1
  337. package/dist/lib/chunk-6BRTJXZ2.js +0 -3333
  338. package/dist/lib/chunk-6BRTJXZ2.js.map +0 -1
  339. package/dist/lib/chunk-6IJTWIVJ.cjs +0 -107
  340. package/dist/lib/chunk-6IJTWIVJ.cjs.map +0 -1
  341. package/dist/lib/chunk-7EAV6Q7B.cjs +0 -78
  342. package/dist/lib/chunk-7EAV6Q7B.cjs.map +0 -1
  343. package/dist/lib/chunk-7LLECRBP.cjs +0 -41
  344. package/dist/lib/chunk-7LLECRBP.cjs.map +0 -1
  345. package/dist/lib/chunk-7QVYU63E.js +0 -6
  346. package/dist/lib/chunk-7QVYU63E.js.map +0 -1
  347. package/dist/lib/chunk-7R23HVGQ.js +0 -27
  348. package/dist/lib/chunk-7R23HVGQ.js.map +0 -1
  349. package/dist/lib/chunk-BEKLDCTV.cjs +0 -95
  350. package/dist/lib/chunk-BEKLDCTV.cjs.map +0 -1
  351. package/dist/lib/chunk-BW3VFCTS.cjs +0 -110
  352. package/dist/lib/chunk-BW3VFCTS.cjs.map +0 -1
  353. package/dist/lib/chunk-CAPN4FSS.js +0 -152
  354. package/dist/lib/chunk-CAPN4FSS.js.map +0 -1
  355. package/dist/lib/chunk-ESYYL5UH.js +0 -105
  356. package/dist/lib/chunk-ESYYL5UH.js.map +0 -1
  357. package/dist/lib/chunk-GJNFAFKR.cjs +0 -66
  358. package/dist/lib/chunk-GJNFAFKR.cjs.map +0 -1
  359. package/dist/lib/chunk-GWYTWFZE.cjs +0 -72
  360. package/dist/lib/chunk-GWYTWFZE.cjs.map +0 -1
  361. package/dist/lib/chunk-HJWJNSSZ.js +0 -3
  362. package/dist/lib/chunk-HJWJNSSZ.js.map +0 -1
  363. package/dist/lib/chunk-HQ6TGY34.js +0 -27
  364. package/dist/lib/chunk-HQ6TGY34.js.map +0 -1
  365. package/dist/lib/chunk-IK3ABDPP.cjs +0 -64
  366. package/dist/lib/chunk-IK3ABDPP.cjs.map +0 -1
  367. package/dist/lib/chunk-JTUL3477.cjs +0 -137
  368. package/dist/lib/chunk-JTUL3477.cjs.map +0 -1
  369. package/dist/lib/chunk-KOCDKJDJ.js +0 -96
  370. package/dist/lib/chunk-KOCDKJDJ.js.map +0 -1
  371. package/dist/lib/chunk-KSBESEOF.js +0 -169
  372. package/dist/lib/chunk-KSBESEOF.js.map +0 -1
  373. package/dist/lib/chunk-LBMMBFQE.js +0 -65
  374. package/dist/lib/chunk-LBMMBFQE.js.map +0 -1
  375. package/dist/lib/chunk-LEIOWD2W.js +0 -28
  376. package/dist/lib/chunk-LEIOWD2W.js.map +0 -1
  377. package/dist/lib/chunk-LJZEN4HP.cjs +0 -110
  378. package/dist/lib/chunk-LJZEN4HP.cjs.map +0 -1
  379. package/dist/lib/chunk-LTVWU4J2.js +0 -47
  380. package/dist/lib/chunk-LTVWU4J2.js.map +0 -1
  381. package/dist/lib/chunk-LYD5OTBI.cjs +0 -3362
  382. package/dist/lib/chunk-LYD5OTBI.cjs.map +0 -1
  383. package/dist/lib/chunk-MAHHHINV.js +0 -67
  384. package/dist/lib/chunk-MAHHHINV.js.map +0 -1
  385. package/dist/lib/chunk-MFC7UJHT.cjs +0 -30
  386. package/dist/lib/chunk-MFC7UJHT.cjs.map +0 -1
  387. package/dist/lib/chunk-MGEZC2RV.cjs +0 -69
  388. package/dist/lib/chunk-MGEZC2RV.cjs.map +0 -1
  389. package/dist/lib/chunk-MVQSM5WM.cjs +0 -73
  390. package/dist/lib/chunk-MVQSM5WM.cjs.map +0 -1
  391. package/dist/lib/chunk-NANLYIUO.cjs +0 -70
  392. package/dist/lib/chunk-NANLYIUO.cjs.map +0 -1
  393. package/dist/lib/chunk-NE46WXNJ.js +0 -58
  394. package/dist/lib/chunk-NE46WXNJ.js.map +0 -1
  395. package/dist/lib/chunk-ODJBZ6PS.js +0 -39
  396. package/dist/lib/chunk-ODJBZ6PS.js.map +0 -1
  397. package/dist/lib/chunk-OF5IJ4WG.js +0 -65
  398. package/dist/lib/chunk-OF5IJ4WG.js.map +0 -1
  399. package/dist/lib/chunk-OO4BIM7N.js +0 -98
  400. package/dist/lib/chunk-OO4BIM7N.js.map +0 -1
  401. package/dist/lib/chunk-PEZXLKQD.cjs +0 -4
  402. package/dist/lib/chunk-PEZXLKQD.cjs.map +0 -1
  403. package/dist/lib/chunk-PK6SKIKE.cjs +0 -8
  404. package/dist/lib/chunk-PK6SKIKE.cjs.map +0 -1
  405. package/dist/lib/chunk-PXSRMP4E.js +0 -39
  406. package/dist/lib/chunk-PXSRMP4E.js.map +0 -1
  407. package/dist/lib/chunk-Q2L3FNJO.js +0 -120
  408. package/dist/lib/chunk-Q2L3FNJO.js.map +0 -1
  409. package/dist/lib/chunk-Q3KJZ3B5.js +0 -161
  410. package/dist/lib/chunk-Q3KJZ3B5.js.map +0 -1
  411. package/dist/lib/chunk-RK2VVGL6.cjs +0 -107
  412. package/dist/lib/chunk-RK2VVGL6.cjs.map +0 -1
  413. package/dist/lib/chunk-RLMEYZ5I.cjs +0 -167
  414. package/dist/lib/chunk-RLMEYZ5I.cjs.map +0 -1
  415. package/dist/lib/chunk-RQICHHZM.cjs +0 -29
  416. package/dist/lib/chunk-RQICHHZM.cjs.map +0 -1
  417. package/dist/lib/chunk-RXQWNSZX.js +0 -37
  418. package/dist/lib/chunk-RXQWNSZX.js.map +0 -1
  419. package/dist/lib/chunk-STAKGAWR.js +0 -86
  420. package/dist/lib/chunk-STAKGAWR.js.map +0 -1
  421. package/dist/lib/chunk-U36VZLW6.cjs +0 -172
  422. package/dist/lib/chunk-U36VZLW6.cjs.map +0 -1
  423. package/dist/lib/chunk-UGRFAVAJ.js +0 -93
  424. package/dist/lib/chunk-UGRFAVAJ.js.map +0 -1
  425. package/dist/lib/chunk-UQJWVRRE.cjs +0 -47
  426. package/dist/lib/chunk-UQJWVRRE.cjs.map +0 -1
  427. package/dist/lib/chunk-V2T4H24I.js +0 -156
  428. package/dist/lib/chunk-V2T4H24I.js.map +0 -1
  429. package/dist/lib/chunk-V5OY4ALI.cjs +0 -56
  430. package/dist/lib/chunk-V5OY4ALI.cjs.map +0 -1
  431. package/dist/lib/chunk-VJN72T2O.js +0 -50
  432. package/dist/lib/chunk-VJN72T2O.js.map +0 -1
  433. package/dist/lib/chunk-W4OMKQ7W.cjs +0 -128
  434. package/dist/lib/chunk-W4OMKQ7W.cjs.map +0 -1
  435. package/dist/lib/chunk-XGH6JWRO.js +0 -3
  436. package/dist/lib/chunk-XGH6JWRO.js.map +0 -1
  437. package/dist/lib/chunk-XQMVE2NH.cjs +0 -4
  438. package/dist/lib/chunk-XQMVE2NH.cjs.map +0 -1
  439. package/dist/lib/chunk-XZD7S5TU.cjs +0 -53
  440. package/dist/lib/chunk-XZD7S5TU.cjs.map +0 -1
  441. package/dist/lib/chunk-YBIWVB66.js +0 -76
  442. package/dist/lib/chunk-YBIWVB66.js.map +0 -1
  443. package/dist/lib/chunk-YF3YHK4X.js +0 -127
  444. package/dist/lib/chunk-YF3YHK4X.js.map +0 -1
  445. package/dist/lib/chunk-YVDJCVE5.cjs +0 -160
  446. package/dist/lib/chunk-YVDJCVE5.cjs.map +0 -1
  447. package/dist/lib/chunk-ZP7PDTVE.cjs +0 -167
  448. package/dist/lib/chunk-ZP7PDTVE.cjs.map +0 -1
  449. package/dist/lib/compiler-CuQLTmTB.d.cts +0 -32
  450. package/dist/lib/compiler-CuQLTmTB.d.ts +0 -32
  451. package/dist/lib/config-DnifzkPt.d.ts +0 -1474
  452. package/dist/lib/config-Ro14HmyO.d.cts +0 -1474
  453. package/dist/lib/config-file.cjs +0 -17
  454. package/dist/lib/config-file.cjs.map +0 -1
  455. package/dist/lib/config-file.d.cts +0 -57
  456. package/dist/lib/config-file.d.ts +0 -57
  457. package/dist/lib/config-file.js +0 -4
  458. package/dist/lib/config-file.js.map +0 -1
  459. package/dist/lib/create-program.cjs +0 -13
  460. package/dist/lib/create-program.cjs.map +0 -1
  461. package/dist/lib/create-program.d.cts +0 -42
  462. package/dist/lib/create-program.d.ts +0 -42
  463. package/dist/lib/create-program.js +0 -4
  464. package/dist/lib/create-program.js.map +0 -1
  465. package/dist/lib/entry.cjs +0 -41
  466. package/dist/lib/entry.cjs.map +0 -1
  467. package/dist/lib/entry.d.cts +0 -69
  468. package/dist/lib/entry.d.ts +0 -69
  469. package/dist/lib/entry.js +0 -4
  470. package/dist/lib/entry.js.map +0 -1
  471. package/dist/lib/hooks-B6Ow5MtE.d.ts +0 -28
  472. package/dist/lib/hooks-CM-BbMzz.d.cts +0 -28
  473. package/dist/lib/index.cjs +0 -281
  474. package/dist/lib/index.cjs.map +0 -1
  475. package/dist/lib/index.d.cts +0 -57
  476. package/dist/lib/index.d.ts +0 -57
  477. package/dist/lib/index.js +0 -28
  478. package/dist/lib/index.js.map +0 -1
  479. package/dist/lib/logger.cjs +0 -17
  480. package/dist/lib/logger.cjs.map +0 -1
  481. package/dist/lib/logger.d.cts +0 -51
  482. package/dist/lib/logger.d.ts +0 -51
  483. package/dist/lib/logger.js +0 -4
  484. package/dist/lib/logger.js.map +0 -1
  485. package/dist/lib/tsconfig-Bz-CiFqD.d.cts +0 -68
  486. package/dist/lib/tsconfig-Bz-CiFqD.d.ts +0 -68
  487. package/dist/lib/typescript/compiler-host.cjs +0 -166
  488. package/dist/lib/typescript/compiler-host.cjs.map +0 -1
  489. package/dist/lib/typescript/compiler-host.d.cts +0 -64
  490. package/dist/lib/typescript/compiler-host.d.ts +0 -64
  491. package/dist/lib/typescript/compiler-host.js +0 -158
  492. package/dist/lib/typescript/compiler-host.js.map +0 -1
  493. package/dist/lib/typescript/import-transformer.cjs +0 -51
  494. package/dist/lib/typescript/import-transformer.cjs.map +0 -1
  495. package/dist/lib/typescript/import-transformer.d.cts +0 -36
  496. package/dist/lib/typescript/import-transformer.d.ts +0 -36
  497. package/dist/lib/typescript/import-transformer.js +0 -49
  498. package/dist/lib/typescript/import-transformer.js.map +0 -1
  499. package/dist/lib/typescript/index.cjs +0 -60
  500. package/dist/lib/typescript/index.cjs.map +0 -1
  501. package/dist/lib/typescript/index.d.cts +0 -35
  502. package/dist/lib/typescript/index.d.ts +0 -35
  503. package/dist/lib/typescript/index.js +0 -7
  504. package/dist/lib/typescript/index.js.map +0 -1
  505. package/dist/lib/typescript/isolated-decl.cjs +0 -13
  506. package/dist/lib/typescript/isolated-decl.cjs.map +0 -1
  507. package/dist/lib/typescript/isolated-decl.d.cts +0 -11
  508. package/dist/lib/typescript/isolated-decl.d.ts +0 -11
  509. package/dist/lib/typescript/isolated-decl.js +0 -4
  510. package/dist/lib/typescript/isolated-decl.js.map +0 -1
  511. package/dist/lib/typescript/program.cjs +0 -29
  512. package/dist/lib/typescript/program.cjs.map +0 -1
  513. package/dist/lib/typescript/program.d.cts +0 -69
  514. package/dist/lib/typescript/program.d.ts +0 -69
  515. package/dist/lib/typescript/program.js +0 -4
  516. package/dist/lib/typescript/program.js.map +0 -1
  517. package/dist/lib/typescript/tsconfig.cjs +0 -33
  518. package/dist/lib/typescript/tsconfig.cjs.map +0 -1
  519. package/dist/lib/typescript/tsconfig.d.cts +0 -61
  520. package/dist/lib/typescript/tsconfig.d.ts +0 -61
  521. package/dist/lib/typescript/tsconfig.js +0 -4
  522. package/dist/lib/typescript/tsconfig.js.map +0 -1
  523. package/dist/lib/unplugin/factory.cjs +0 -23
  524. package/dist/lib/unplugin/factory.cjs.map +0 -1
  525. package/dist/lib/unplugin/factory.d.cts +0 -200
  526. package/dist/lib/unplugin/factory.d.ts +0 -200
  527. package/dist/lib/unplugin/factory.js +0 -14
  528. package/dist/lib/unplugin/factory.js.map +0 -1
  529. package/dist/lib/unplugin/index.cjs +0 -33
  530. package/dist/lib/unplugin/index.cjs.map +0 -1
  531. package/dist/lib/unplugin/index.d.cts +0 -36
  532. package/dist/lib/unplugin/index.d.ts +0 -36
  533. package/dist/lib/unplugin/index.js +0 -16
  534. package/dist/lib/unplugin/index.js.map +0 -1
  535. package/dist/lib/unplugin/plugin.cjs +0 -16
  536. package/dist/lib/unplugin/plugin.cjs.map +0 -1
  537. package/dist/lib/unplugin/plugin.d.cts +0 -55
  538. package/dist/lib/unplugin/plugin.d.ts +0 -55
  539. package/dist/lib/unplugin/plugin.js +0 -7
  540. package/dist/lib/unplugin/plugin.js.map +0 -1
  541. package/dist/lib/unplugin/resolve-id.cjs +0 -13
  542. package/dist/lib/unplugin/resolve-id.cjs.map +0 -1
  543. package/dist/lib/unplugin/resolve-id.d.cts +0 -60
  544. package/dist/lib/unplugin/resolve-id.d.ts +0 -60
  545. package/dist/lib/unplugin/resolve-id.js +0 -4
  546. package/dist/lib/unplugin/resolve-id.js.map +0 -1
  547. package/dist/lib/utilities/bundle.cjs +0 -16
  548. package/dist/lib/utilities/bundle.cjs.map +0 -1
  549. package/dist/lib/utilities/bundle.d.cts +0 -44
  550. package/dist/lib/utilities/bundle.d.ts +0 -44
  551. package/dist/lib/utilities/bundle.js +0 -7
  552. package/dist/lib/utilities/bundle.js.map +0 -1
  553. package/dist/lib/utilities/cache.cjs +0 -18
  554. package/dist/lib/utilities/cache.cjs.map +0 -1
  555. package/dist/lib/utilities/cache.d.cts +0 -7
  556. package/dist/lib/utilities/cache.d.ts +0 -7
  557. package/dist/lib/utilities/cache.js +0 -5
  558. package/dist/lib/utilities/cache.js.map +0 -1
  559. package/dist/lib/utilities/file-header.cjs +0 -17
  560. package/dist/lib/utilities/file-header.cjs.map +0 -1
  561. package/dist/lib/utilities/file-header.d.cts +0 -42
  562. package/dist/lib/utilities/file-header.d.ts +0 -42
  563. package/dist/lib/utilities/file-header.js +0 -4
  564. package/dist/lib/utilities/file-header.js.map +0 -1
  565. package/dist/lib/utilities/index.cjs +0 -159
  566. package/dist/lib/utilities/index.cjs.map +0 -1
  567. package/dist/lib/utilities/index.d.cts +0 -45
  568. package/dist/lib/utilities/index.d.ts +0 -45
  569. package/dist/lib/utilities/index.js +0 -18
  570. package/dist/lib/utilities/index.js.map +0 -1
  571. package/dist/lib/utilities/meta.cjs +0 -37
  572. package/dist/lib/utilities/meta.cjs.map +0 -1
  573. package/dist/lib/utilities/meta.d.cts +0 -68
  574. package/dist/lib/utilities/meta.d.ts +0 -68
  575. package/dist/lib/utilities/meta.js +0 -4
  576. package/dist/lib/utilities/meta.js.map +0 -1
  577. package/dist/lib/utilities/plugin-helpers.cjs +0 -61
  578. package/dist/lib/utilities/plugin-helpers.cjs.map +0 -1
  579. package/dist/lib/utilities/plugin-helpers.d.cts +0 -153
  580. package/dist/lib/utilities/plugin-helpers.d.ts +0 -153
  581. package/dist/lib/utilities/plugin-helpers.js +0 -4
  582. package/dist/lib/utilities/plugin-helpers.js.map +0 -1
  583. package/dist/lib/utilities/resolve-path.cjs +0 -13
  584. package/dist/lib/utilities/resolve-path.cjs.map +0 -1
  585. package/dist/lib/utilities/resolve-path.d.cts +0 -43
  586. package/dist/lib/utilities/resolve-path.d.ts +0 -43
  587. package/dist/lib/utilities/resolve-path.js +0 -4
  588. package/dist/lib/utilities/resolve-path.js.map +0 -1
  589. package/dist/lib/utilities/resolve.cjs +0 -17
  590. package/dist/lib/utilities/resolve.cjs.map +0 -1
  591. package/dist/lib/utilities/resolve.d.cts +0 -44
  592. package/dist/lib/utilities/resolve.d.ts +0 -44
  593. package/dist/lib/utilities/resolve.js +0 -8
  594. package/dist/lib/utilities/resolve.js.map +0 -1
  595. package/dist/lib/utilities/source-file.cjs +0 -21
  596. package/dist/lib/utilities/source-file.cjs.map +0 -1
  597. package/dist/lib/utilities/source-file.d.cts +0 -28
  598. package/dist/lib/utilities/source-file.d.ts +0 -28
  599. package/dist/lib/utilities/source-file.js +0 -4
  600. package/dist/lib/utilities/source-file.js.map +0 -1
  601. package/dist/lib/utilities/source-map.cjs +0 -13
  602. package/dist/lib/utilities/source-map.cjs.map +0 -1
  603. package/dist/lib/utilities/source-map.d.cts +0 -14
  604. package/dist/lib/utilities/source-map.d.ts +0 -14
  605. package/dist/lib/utilities/source-map.js +0 -4
  606. package/dist/lib/utilities/source-map.js.map +0 -1
  607. package/dist/lib/utilities/worker.cjs +0 -18
  608. package/dist/lib/utilities/worker.cjs.map +0 -1
  609. package/dist/lib/utilities/worker.d.cts +0 -58
  610. package/dist/lib/utilities/worker.d.ts +0 -58
  611. package/dist/lib/utilities/worker.js +0 -5
  612. package/dist/lib/utilities/worker.js.map +0 -1
  613. package/dist/lib/utilities/write-file.cjs +0 -13
  614. package/dist/lib/utilities/write-file.cjs.map +0 -1
  615. package/dist/lib/utilities/write-file.d.cts +0 -44
  616. package/dist/lib/utilities/write-file.d.ts +0 -44
  617. package/dist/lib/utilities/write-file.js +0 -4
  618. package/dist/lib/utilities/write-file.js.map +0 -1
  619. package/dist/next.js +0 -10
  620. package/dist/nuxt.d.ts +0 -20
  621. package/dist/nuxt.js +0 -12
  622. package/dist/resolved-DtY60yLh.d.cts +0 -1351
  623. package/dist/resolved-wPXZS7aW.d.ts +0 -1351
  624. package/dist/rolldown.d.ts +0 -57
  625. package/dist/rolldown.js +0 -9
  626. package/dist/rollup.d.ts +0 -57
  627. package/dist/rollup.js +0 -9
  628. package/dist/rspack.d.ts +0 -57
  629. package/dist/rspack.js +0 -9
  630. package/dist/tsup.js +0 -11
  631. package/dist/types/babel.cjs +0 -6
  632. package/dist/types/babel.cjs.map +0 -1
  633. package/dist/types/babel.d.cts +0 -38
  634. package/dist/types/babel.d.ts +0 -38
  635. package/dist/types/babel.js +0 -3
  636. package/dist/types/babel.js.map +0 -1
  637. package/dist/types/build.cjs +0 -6
  638. package/dist/types/build.cjs.map +0 -1
  639. package/dist/types/build.d.cts +0 -111
  640. package/dist/types/build.d.ts +0 -111
  641. package/dist/types/build.js +0 -3
  642. package/dist/types/build.js.map +0 -1
  643. package/dist/types/commands.cjs +0 -13
  644. package/dist/types/commands.cjs.map +0 -1
  645. package/dist/types/commands.d.cts +0 -38
  646. package/dist/types/commands.d.ts +0 -38
  647. package/dist/types/commands.js +0 -4
  648. package/dist/types/commands.js.map +0 -1
  649. package/dist/types/compiler.cjs +0 -6
  650. package/dist/types/compiler.cjs.map +0 -1
  651. package/dist/types/compiler.d.cts +0 -38
  652. package/dist/types/compiler.d.ts +0 -38
  653. package/dist/types/compiler.js +0 -3
  654. package/dist/types/compiler.js.map +0 -1
  655. package/dist/types/config.cjs +0 -6
  656. package/dist/types/config.cjs.map +0 -1
  657. package/dist/types/config.d.cts +0 -38
  658. package/dist/types/config.d.ts +0 -38
  659. package/dist/types/config.js +0 -3
  660. package/dist/types/config.js.map +0 -1
  661. package/dist/types/context.cjs +0 -13
  662. package/dist/types/context.cjs.map +0 -1
  663. package/dist/types/context.d.cts +0 -38
  664. package/dist/types/context.d.ts +0 -38
  665. package/dist/types/context.js +0 -4
  666. package/dist/types/context.js.map +0 -1
  667. package/dist/types/hooks.cjs +0 -6
  668. package/dist/types/hooks.cjs.map +0 -1
  669. package/dist/types/hooks.d.cts +0 -38
  670. package/dist/types/hooks.d.ts +0 -38
  671. package/dist/types/hooks.js +0 -3
  672. package/dist/types/hooks.js.map +0 -1
  673. package/dist/types/index.cjs +0 -58
  674. package/dist/types/index.cjs.map +0 -1
  675. package/dist/types/index.d.cts +0 -42
  676. package/dist/types/index.d.ts +0 -42
  677. package/dist/types/index.js +0 -17
  678. package/dist/types/index.js.map +0 -1
  679. package/dist/types/internal.cjs +0 -4
  680. package/dist/types/internal.cjs.map +0 -1
  681. package/dist/types/internal.d.cts +0 -61
  682. package/dist/types/internal.d.ts +0 -61
  683. package/dist/types/internal.js +0 -3
  684. package/dist/types/internal.js.map +0 -1
  685. package/dist/types/plugin.cjs +0 -13
  686. package/dist/types/plugin.cjs.map +0 -1
  687. package/dist/types/plugin.d.cts +0 -38
  688. package/dist/types/plugin.d.ts +0 -38
  689. package/dist/types/plugin.js +0 -4
  690. package/dist/types/plugin.js.map +0 -1
  691. package/dist/types/resolved.cjs +0 -6
  692. package/dist/types/resolved.cjs.map +0 -1
  693. package/dist/types/resolved.d.cts +0 -38
  694. package/dist/types/resolved.d.ts +0 -38
  695. package/dist/types/resolved.js +0 -3
  696. package/dist/types/resolved.js.map +0 -1
  697. package/dist/types/tsconfig.cjs +0 -6
  698. package/dist/types/tsconfig.cjs.map +0 -1
  699. package/dist/types/tsconfig.d.cts +0 -75
  700. package/dist/types/tsconfig.d.ts +0 -75
  701. package/dist/types/tsconfig.js +0 -3
  702. package/dist/types/tsconfig.js.map +0 -1
  703. package/dist/types/typedoc.cjs +0 -6
  704. package/dist/types/typedoc.cjs.map +0 -1
  705. package/dist/types/typedoc.d.cts +0 -25
  706. package/dist/types/typedoc.d.ts +0 -25
  707. package/dist/types/typedoc.js +0 -3
  708. package/dist/types/typedoc.js.map +0 -1
  709. package/dist/types/unplugin.cjs +0 -6
  710. package/dist/types/unplugin.cjs.map +0 -1
  711. package/dist/types/unplugin.d.cts +0 -54
  712. package/dist/types/unplugin.d.ts +0 -54
  713. package/dist/types/unplugin.js +0 -3
  714. package/dist/types/unplugin.js.map +0 -1
  715. package/dist/types/vfs.cjs +0 -33
  716. package/dist/types/vfs.cjs.map +0 -1
  717. package/dist/types/vfs.d.cts +0 -408
  718. package/dist/types/vfs.d.ts +0 -408
  719. package/dist/types/vfs.js +0 -4
  720. package/dist/types/vfs.js.map +0 -1
  721. package/dist/unloader.d.ts +0 -56
  722. package/dist/unloader.js +0 -9
  723. package/dist/unplugin.d.ts +0 -77
  724. package/dist/unplugin.js +0 -21
  725. package/dist/vite.d.ts +0 -57
  726. package/dist/vite.js +0 -10
  727. package/dist/webpack.d.ts +0 -57
  728. package/dist/webpack.js +0 -9
@@ -1,3602 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkAPVMN2H7_cjs = require('./chunk-APVMN2H7.cjs');
4
- var chunk22K72CJ5_cjs = require('./chunk-22K72CJ5.cjs');
5
- var chunk5VPVJHJO_cjs = require('./chunk-5VPVJHJO.cjs');
6
- var chunkPK6SKIKE_cjs = require('./chunk-PK6SKIKE.cjs');
7
- var console = require('@storm-software/config-tools/logger/console');
8
- var types = require('@storm-software/config-tools/types');
9
- var toArray = require('@stryke/convert/to-array');
10
- var copyFile = require('@stryke/fs/copy-file');
11
- var exists = require('@stryke/fs/exists');
12
- var helpers = require('@stryke/fs/helpers');
13
- var install = require('@stryke/fs/install');
14
- var listFiles = require('@stryke/fs/list-files');
15
- var packageFns = require('@stryke/fs/package-fns');
16
- var joinPaths = require('@stryke/path/join-paths');
17
- var replace = require('@stryke/path/replace');
18
- var isError = require('@stryke/type-checks/is-error');
19
- var isFunction = require('@stryke/type-checks/is-function');
20
- var isNumber = require('@stryke/type-checks/is-number');
21
- var isPromise = require('@stryke/type-checks/is-promise');
22
- var isSet = require('@stryke/type-checks/is-set');
23
- var isSetObject = require('@stryke/type-checks/is-set-object');
24
- var isSetString = require('@stryke/type-checks/is-set-string');
25
- var chalk5 = require('chalk');
26
- var Handlebars = require('handlebars');
27
- var json = require('@stryke/fs/json');
28
- var append = require('@stryke/path/append');
29
- var defu5 = require('defu');
30
- var ts2 = require('typescript');
31
- require('@stryke/fs/remove-file');
32
- var hashFiles = require('@stryke/hash/hash-files');
33
- var getUnique = require('@stryke/helpers/get-unique');
34
- var filePathFns = require('@stryke/path/file-path-fns');
35
- var kebabCase = require('@stryke/string-format/kebab-case');
36
- var isUndefined = require('@stryke/type-checks/is-undefined');
37
- var writeFile$1 = require('@stryke/fs/write-file');
38
- var prettier = require('prettier');
39
- var resolve = require('@stryke/fs/resolve');
40
- var getConfig = require('@storm-software/config-tools/get-config');
41
- var c12 = require('c12');
42
- var titleCase = require('@stryke/string-format/title-case');
43
- var getEnvPaths = require('@stryke/env/get-env-paths');
44
- var getWorkspaceRoot = require('@stryke/fs/get-workspace-root');
45
- var murmurhash = require('@stryke/hash/murmurhash');
46
- var omit = require('@stryke/helpers/omit');
47
- var isType = require('@stryke/path/is-type');
48
- var join = require('@stryke/path/join');
49
- var isNull = require('@stryke/type-checks/is-null');
50
- var isString = require('@stryke/type-checks/is-string');
51
- var uuid = require('@stryke/unique-id/uuid');
52
- var oxcParser = require('oxc-parser');
53
- var parseTypeDefinition = require('@stryke/convert/parse-type-definition');
54
- var logger = require('@storm-software/config-tools/logger');
55
- var colors = require('@storm-software/config-tools/utilities/colors');
56
- var noop = require('@stryke/helpers/noop');
57
- var jiti = require('jiti');
58
- var bufferToString = require('@stryke/convert/buffer-to-string');
59
- var isParentPath = require('@stryke/path/is-parent-path');
60
- var prettyBytes = require('@stryke/string-format/pretty-bytes');
61
- var isBuffer = require('@stryke/type-checks/is-buffer');
62
- var memfs = require('memfs');
63
- var buffer = require('buffer');
64
- var fs = require('fs');
65
- var unionfs = require('unionfs');
66
- var isObject = require('@stryke/type-checks/is-object');
67
- var core = require('@babel/core');
68
- var readFile = require('@stryke/fs/read-file');
69
- var MagicString = require('magic-string');
70
- var helperPluginUtils = require('@babel/helper-plugin-utils');
71
- var t = require('@babel/types');
72
- var _package = require('@stryke/string-format/package');
73
- var superdiff = require('@donedeal0/superdiff');
74
- var tsconfig = require('@stryke/fs/tsconfig');
75
- var stormJson = require('@stryke/json/storm-json');
76
-
77
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
78
-
79
- function _interopNamespace(e) {
80
- if (e && e.__esModule) return e;
81
- var n = Object.create(null);
82
- if (e) {
83
- Object.keys(e).forEach(function (k) {
84
- if (k !== 'default') {
85
- var d = Object.getOwnPropertyDescriptor(e, k);
86
- Object.defineProperty(n, k, d.get ? d : {
87
- enumerable: true,
88
- get: function () { return e[k]; }
89
- });
90
- }
91
- });
92
- }
93
- n.default = e;
94
- return Object.freeze(n);
95
- }
96
-
97
- var chalk5__default = /*#__PURE__*/_interopDefault(chalk5);
98
- var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
99
- var defu5__default = /*#__PURE__*/_interopDefault(defu5);
100
- var ts2__default = /*#__PURE__*/_interopDefault(ts2);
101
- var fs__default = /*#__PURE__*/_interopDefault(fs);
102
- var MagicString__default = /*#__PURE__*/_interopDefault(MagicString);
103
- var t__namespace = /*#__PURE__*/_interopNamespace(t);
104
-
105
- function getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig = "tsconfig.json") {
106
- let tsconfigFilePath = tsconfig;
107
- if (!exists.existsSync(tsconfigFilePath)) {
108
- tsconfigFilePath = append.appendPath(tsconfig, projectRoot);
109
- if (!exists.existsSync(tsconfigFilePath)) {
110
- tsconfigFilePath = append.appendPath(tsconfig, workspaceRoot);
111
- if (!exists.existsSync(tsconfigFilePath)) {
112
- tsconfigFilePath = append.appendPath(tsconfig, joinPaths.joinPaths(workspaceRoot, projectRoot));
113
- if (!exists.existsSync(tsconfigFilePath)) {
114
- throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${tsconfig}, ${append.appendPath(tsconfig, projectRoot)}, ${append.appendPath(tsconfig, workspaceRoot)}, or ${tsconfigFilePath}`);
115
- }
116
- }
117
- }
118
- }
119
- return tsconfigFilePath;
120
- }
121
- chunkPK6SKIKE_cjs.__name(getTsconfigFilePath, "getTsconfigFilePath");
122
- function findMatch(tsconfigType, types, extensions = [
123
- ".ts",
124
- ".tsx",
125
- ".d.ts"
126
- ]) {
127
- return types.find((type) => tsconfigType?.toString().toLowerCase() === type?.toString().toLowerCase() || tsconfigType?.toString().toLowerCase() === `./${type?.toString().toLowerCase()}` || `./${tsconfigType?.toString().toLowerCase()}` === type?.toString().toLowerCase() || extensions.some((ext) => `${tsconfigType?.toString().toLowerCase()}${ext}` === type?.toString().toLowerCase() || `${tsconfigType?.toString().toLowerCase()}${ext}` === `./${type?.toString().toLowerCase()}` || `${type?.toString().toLowerCase()}${ext}` === `./${tsconfigType?.toString().toLowerCase()}` || tsconfigType?.toString().toLowerCase() === `${type?.toString().toLowerCase()}${ext}` || tsconfigType?.toString().toLowerCase() === `./${type?.toString().toLowerCase()}${ext}` || type?.toString().toLowerCase() === `./${tsconfigType?.toString().toLowerCase()}${ext}`));
128
- }
129
- chunkPK6SKIKE_cjs.__name(findMatch, "findMatch");
130
- function findIncludeMatch(tsconfigType, types) {
131
- return findMatch(tsconfigType, types, [
132
- ".ts",
133
- ".tsx",
134
- ".d.ts",
135
- ".js",
136
- ".jsx",
137
- ".mjs",
138
- ".cjs",
139
- ".mts",
140
- ".cts",
141
- "/*.ts",
142
- "/*.tsx",
143
- "/*.d.ts",
144
- "/*.js",
145
- "/*.jsx",
146
- "/*.mjs",
147
- "/*.cjs",
148
- "/*.mts",
149
- "/*.cts",
150
- "/**/*.ts",
151
- "/**/*.tsx",
152
- "/**/*.d.ts",
153
- "/**/*.js",
154
- "/**/*.jsx",
155
- "/**/*.mjs",
156
- "/**/*.cjs",
157
- "/**/*.mts",
158
- "/**/*.cts"
159
- ]);
160
- }
161
- chunkPK6SKIKE_cjs.__name(findIncludeMatch, "findIncludeMatch");
162
- function isIncludeMatchFound(tsconfigType, types) {
163
- return findIncludeMatch(tsconfigType, types) !== void 0;
164
- }
165
- chunkPK6SKIKE_cjs.__name(isIncludeMatchFound, "isIncludeMatchFound");
166
- function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfigRaw = {}, originalTsconfigJson, host = ts2__default.default.sys) {
167
- const tsconfigFilePath = getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig);
168
- const tsconfigJson = json.readJsonFileSync(tsconfigFilePath);
169
- if (!tsconfigJson) {
170
- throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${joinPaths.joinPaths(projectRoot, tsconfig ?? "tsconfig.json")}`);
171
- }
172
- const parsedCommandLine = ts2__default.default.parseJsonConfigFileContent(defu5__default.default(tsconfigRaw ?? {}, tsconfigJson), host, append.appendPath(projectRoot, workspaceRoot));
173
- if (parsedCommandLine.errors.length > 0) {
174
- const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:
175
- ${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && error.code ? `[${error.category}-${error.code}]: ` : "") + error.messageText.toString()}`).join("\n")}
176
- `;
177
- throw new Error(errorMessage);
178
- }
179
- return {
180
- ...parsedCommandLine,
181
- originalTsconfigJson: originalTsconfigJson ?? tsconfigJson,
182
- tsconfigJson,
183
- tsconfigFilePath
184
- };
185
- }
186
- chunkPK6SKIKE_cjs.__name(getParsedTypeScriptConfig, "getParsedTypeScriptConfig");
187
- var PROJECT_ROOT_HASH_LENGTH = 45;
188
- var CACHE_HASH_LENGTH = 62;
189
- function getPrefixedProjectRootHash(name, projectRootHash) {
190
- const combined = `${kebabCase.kebabCase(name)}_${projectRootHash}`;
191
- return combined.length > PROJECT_ROOT_HASH_LENGTH ? combined.slice(0, PROJECT_ROOT_HASH_LENGTH) : combined;
192
- }
193
- chunkPK6SKIKE_cjs.__name(getPrefixedProjectRootHash, "getPrefixedProjectRootHash");
194
- async function getChecksum(path) {
195
- return hashFiles.hashDirectory(path, {
196
- ignore: [
197
- "node_modules",
198
- ".git",
199
- ".nx",
200
- ".cache",
201
- ".storm",
202
- "tmp",
203
- "dist"
204
- ]
205
- });
206
- }
207
- chunkPK6SKIKE_cjs.__name(getChecksum, "getChecksum");
208
- async function writeMetaFile(context) {
209
- const metaFilePath = joinPaths.joinPaths(context.dataPath, "meta.json");
210
- context.log(types.LogLevelLabel.DEBUG, `Writing runtime metadata to ${metaFilePath}`);
211
- await context.fs.writeFile(metaFilePath, JSON.stringify({
212
- ...context.meta,
213
- virtualFiles: context.fs[chunk22K72CJ5_cjs.__VFS_VIRTUAL__].toJSON(context.artifactsPath),
214
- virtualFilesMeta: context.fs.getPartialMeta()
215
- }, null, 2), {
216
- mode: "fs"
217
- });
218
- }
219
- chunkPK6SKIKE_cjs.__name(writeMetaFile, "writeMetaFile");
220
- function isPlugin(value) {
221
- return isSetObject.isSetObject(value) && "name" in value && isSetString.isSetString(value.name) && (isUndefined.isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction.isFunction(value.applyToEnvironment)) && (isUndefined.isUndefined(value.dedupe) || "dedupe" in value && isFunction.isFunction(value.dedupe)) && (isUndefined.isUndefined(value.dependsOn) || "dependsOn" in value && Array.isArray(value.dependsOn) && value.dependsOn.every(isPluginConfig)) && chunk5VPVJHJO_cjs.SUPPORTED_COMMANDS.every((command) => isUndefined.isUndefined(value[command]) || command in value && (isFunction.isFunction(value[command]) || isSetObject.isSetObject(value[command]) && "handler" in value[command] && isFunction.isFunction(value[command].handler)));
222
- }
223
- chunkPK6SKIKE_cjs.__name(isPlugin, "isPlugin");
224
- function isPluginConfigObject(value) {
225
- return isSetObject.isSetObject(value) && "plugin" in value && ((isSetString.isSetString(value.plugin) || isFunction.isFunction(value.plugin)) && "options" in value && isSetObject.isSetObject(value.options) || isPlugin(value.plugin));
226
- }
227
- chunkPK6SKIKE_cjs.__name(isPluginConfigObject, "isPluginConfigObject");
228
- function isPluginConfigTuple(value) {
229
- return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString.isSetString(value[0]) || isFunction.isFunction(value[0])) && value.length > 1 && isSetObject.isSetObject(value[1]) || isPlugin(value[0]));
230
- }
231
- chunkPK6SKIKE_cjs.__name(isPluginConfigTuple, "isPluginConfigTuple");
232
- function isPluginConfig(value) {
233
- return isSetString.isSetString(value) || isFunction.isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
234
- }
235
- chunkPK6SKIKE_cjs.__name(isPluginConfig, "isPluginConfig");
236
- function isPluginHookFunction(value) {
237
- return isFunction.isFunction(value) || isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
238
- }
239
- chunkPK6SKIKE_cjs.__name(isPluginHookFunction, "isPluginHookFunction");
240
- function isPluginHookObject(value) {
241
- return isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
242
- }
243
- chunkPK6SKIKE_cjs.__name(isPluginHookObject, "isPluginHookObject");
244
- function isPluginHook(value) {
245
- return isPluginHookFunction(value) || isPluginHookObject(value);
246
- }
247
- chunkPK6SKIKE_cjs.__name(isPluginHook, "isPluginHook");
248
- function getHookHandler(pluginHook) {
249
- return isFunction.isFunction(pluginHook) ? pluginHook : pluginHook.handler;
250
- }
251
- chunkPK6SKIKE_cjs.__name(getHookHandler, "getHookHandler");
252
- function isHookExternal(hook) {
253
- return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
254
- }
255
- chunkPK6SKIKE_cjs.__name(isHookExternal, "isHookExternal");
256
- function checkDedupe(plugin, plugins) {
257
- return plugin.dedupe === false || plugins.some((p) => p.dedupe !== false && (isFunction.isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
258
- }
259
- chunkPK6SKIKE_cjs.__name(checkDedupe, "checkDedupe");
260
- function addPluginHook(context, plugin, pluginHook, hooksList) {
261
- if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
262
- hooksList.push(isFunction.isFunction(pluginHook) ? {
263
- plugin,
264
- handler: getHookHandler(pluginHook).bind(context)
265
- } : {
266
- plugin,
267
- ...pluginHook,
268
- handler: getHookHandler(pluginHook).bind(context)
269
- });
270
- }
271
- }
272
- chunkPK6SKIKE_cjs.__name(addPluginHook, "addPluginHook");
273
- async function writeFile(log, filepath, content, skipFormat = false) {
274
- try {
275
- if (skipFormat) {
276
- await writeFile$1.writeFile(filepath, content);
277
- } else {
278
- const config = await prettier.resolveConfig(filepath);
279
- const formatted = await prettier.format(content, {
280
- ...config ?? {},
281
- filepath
282
- });
283
- await writeFile$1.writeFile(filepath, formatted || "");
284
- }
285
- } catch (error) {
286
- log(types.LogLevelLabel.ERROR, `Failed to write file ${filepath} to disk
287
- ${error?.message ? error.message : ""}`);
288
- }
289
- }
290
- chunkPK6SKIKE_cjs.__name(writeFile, "writeFile");
291
- async function loadWorkspaceConfig(workspaceRoot, cwd) {
292
- return defu5__default.default({
293
- workspaceRoot
294
- }, await getConfig.getWorkspaceConfig(true, {
295
- cwd,
296
- workspaceRoot,
297
- useDefault: true
298
- }));
299
- }
300
- chunkPK6SKIKE_cjs.__name(loadWorkspaceConfig, "loadWorkspaceConfig");
301
- async function loadUserConfigFile(projectRoot, jiti, command, mode, configFile) {
302
- let resolvedUserConfig = {};
303
- const resolvedUserConfigFile = configFile && exists.existsSync(configFile) ? configFile : configFile && exists.existsSync(joinPaths.joinPaths(projectRoot, configFile)) ? joinPaths.joinPaths(projectRoot, configFile) : exists.existsSync(joinPaths.joinPaths(projectRoot, "powerlines.config.ts")) ? joinPaths.joinPaths(projectRoot, "powerlines.config.ts") : exists.existsSync(joinPaths.joinPaths(projectRoot, "powerlines.config.js")) ? joinPaths.joinPaths(projectRoot, "powerlines.config.js") : exists.existsSync(joinPaths.joinPaths(projectRoot, "powerlines.config.mts")) ? joinPaths.joinPaths(projectRoot, "powerlines.config.mts") : exists.existsSync(joinPaths.joinPaths(projectRoot, "powerlines.config.mjs")) ? joinPaths.joinPaths(projectRoot, "powerlines.config.mjs") : void 0;
304
- if (resolvedUserConfigFile) {
305
- const resolved = await jiti.import(jiti.esmResolve(resolvedUserConfigFile));
306
- if (resolved) {
307
- let config = {};
308
- if (isFunction.isFunction(resolved)) {
309
- config = await Promise.resolve(resolved({
310
- command,
311
- mode: mode || "production",
312
- isSsrBuild: false,
313
- isPreview: false
314
- }));
315
- }
316
- if (isSetObject.isSetObject(config)) {
317
- resolvedUserConfig = {
318
- ...config,
319
- config,
320
- configFile: resolvedUserConfigFile
321
- };
322
- }
323
- }
324
- }
325
- const result = await c12.loadConfig({
326
- cwd: projectRoot,
327
- name: "powerlines",
328
- envName: mode,
329
- globalRc: true,
330
- packageJson: true,
331
- dotenv: true,
332
- jiti
333
- });
334
- return defu5__default.default(resolvedUserConfig, isSetObject.isSetObject(result?.config) ? {
335
- ...result.config,
336
- ...result
337
- } : {});
338
- }
339
- chunkPK6SKIKE_cjs.__name(loadUserConfigFile, "loadUserConfigFile");
340
- var DEFAULT_ENVIRONMENT = "default";
341
- function createEnvironment(name, userConfig) {
342
- return defu5__default.default(userConfig.environments?.[name] ?? {}, {
343
- name,
344
- title: userConfig.title || titleCase.titleCase(userConfig.name),
345
- ssr: false,
346
- mainFields: userConfig.build?.platform === "browser" ? [
347
- "browser",
348
- "module",
349
- "jsnext:main",
350
- "jsnext"
351
- ] : [
352
- "module",
353
- "jsnext:main",
354
- "jsnext"
355
- ],
356
- extensions: [
357
- ".mjs",
358
- ".js",
359
- ".mts",
360
- ".ts",
361
- ".jsx",
362
- ".tsx",
363
- ".json"
364
- ],
365
- consumer: userConfig.build?.platform === "browser" ? "client" : "server",
366
- preview: userConfig.build?.platform === "browser" ? {
367
- port: 5173,
368
- open: true,
369
- strictPort: false,
370
- // https: false,
371
- host: "localhost",
372
- allowedHosts: [
373
- "."
374
- ],
375
- cors: true,
376
- headers: {}
377
- } : void 0
378
- }, userConfig);
379
- }
380
- chunkPK6SKIKE_cjs.__name(createEnvironment, "createEnvironment");
381
- function createDefaultEnvironment(userConfig) {
382
- return createEnvironment(DEFAULT_ENVIRONMENT, userConfig);
383
- }
384
- chunkPK6SKIKE_cjs.__name(createDefaultEnvironment, "createDefaultEnvironment");
385
- function resolveEntryInputFile(context, typeDefinition) {
386
- return replace.replacePath(typeDefinition.file, joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot));
387
- }
388
- chunkPK6SKIKE_cjs.__name(resolveEntryInputFile, "resolveEntryInputFile");
389
- function resolveEntryInput(context, typeDefinition) {
390
- return {
391
- file: resolveEntryInputFile(context, typeDefinition),
392
- name: typeDefinition.name
393
- };
394
- }
395
- chunkPK6SKIKE_cjs.__name(resolveEntryInput, "resolveEntryInput");
396
- function resolveEntryOutput(context, typeDefinition) {
397
- return joinPaths.joinPaths(replace.replacePath(replace.replacePath(replace.replacePath(replace.replacePath(typeDefinition.file, joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.sourceRoot)), joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot)), context.config.sourceRoot), context.config.projectRoot)).replace(`.${filePathFns.findFileExtensionSafe(typeDefinition.file)}`, "");
398
- }
399
- chunkPK6SKIKE_cjs.__name(resolveEntryOutput, "resolveEntryOutput");
400
- function resolveEntry(context, typeDefinition) {
401
- const input = resolveEntryInput(context, typeDefinition);
402
- return {
403
- ...input,
404
- input,
405
- output: resolveEntryOutput(context, typeDefinition)
406
- };
407
- }
408
- chunkPK6SKIKE_cjs.__name(resolveEntry, "resolveEntry");
409
- function resolveEntriesSync(context, typeDefinitions) {
410
- return typeDefinitions.map((typeDefinition) => {
411
- const parsed = parseTypeDefinition.parseTypeDefinition(typeDefinition);
412
- return listFiles.listFilesSync(append.appendPath(parsed.file, context.config.projectRoot)).map((file) => resolveEntry(context, {
413
- file,
414
- name: parsed.name
415
- }));
416
- }).flat().filter(Boolean);
417
- }
418
- chunkPK6SKIKE_cjs.__name(resolveEntriesSync, "resolveEntriesSync");
419
- function getUniqueEntries(entries = []) {
420
- return getUnique.getUniqueBy(toArray.toArray(entries), (item) => isSetString.isSetString(item) ? item : murmurhash.murmurhash(item ?? {}, {
421
- maxLength: 24
422
- }));
423
- }
424
- chunkPK6SKIKE_cjs.__name(getUniqueEntries, "getUniqueEntries");
425
- var createLog = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((name, options = {}) => {
426
- const logLevel = options.logLevel === null ? types.LogLevelLabel.SILENT : options.logLevel || types.LogLevelLabel.INFO;
427
- if (logLevel === types.LogLevelLabel.SILENT) {
428
- return noop.noop;
429
- }
430
- if (options.customLogger) {
431
- return options.customLogger;
432
- }
433
- return (type, ...args) => logger.getLogFn(logger.getLogLevel(type), {
434
- ...options,
435
- logLevel
436
- })(`${chalk5__default.default.bold.hex(colors.getColor("brand", options))(`powerlines${name ? `:${name}` : ""}${options.name ? ` ${chalk5__default.default.gray("> ")}${options.name}` : ""} ${chalk5__default.default.gray("> ")}`)}${args.join(" ")} `.trim());
437
- }, "createLog");
438
- var BADGE_COLORS = [
439
- "#00A0DD",
440
- "#6FCE4E",
441
- "#FBBF24",
442
- "#F43F5E",
443
- "#3B82F6",
444
- "#A855F7",
445
- "#469592",
446
- "#288EDF",
447
- "#10B981",
448
- "#EF4444",
449
- "#F0EC56",
450
- "#F472B6",
451
- "#22D3EE",
452
- "#EAB308",
453
- "#84CC16",
454
- "#F87171",
455
- "#0EA5E9",
456
- "#D946EF",
457
- "#FACC15",
458
- "#34D399"
459
- ];
460
- var extendLog = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((logFn, name) => {
461
- return (type, ...args) => logFn(type, ` ${chalk5__default.default.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase.titleCase(name)} `)} ${args.join(" ")} `);
462
- }, "extendLog");
463
- function resolveOptions(options) {
464
- return defu5__default.default(options, {
465
- interopDefault: true,
466
- fsCache: options.mode !== "development" ? joinPaths.joinPaths(options.cacheDir, "jiti") : false,
467
- moduleCache: options.mode !== "development"
468
- });
469
- }
470
- chunkPK6SKIKE_cjs.__name(resolveOptions, "resolveOptions");
471
- function createPluginResolver(options) {
472
- return jiti.createJiti(joinPaths.joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions({
473
- ...options
474
- }));
475
- }
476
- chunkPK6SKIKE_cjs.__name(createPluginResolver, "createPluginResolver");
477
- function createResolver(options) {
478
- const baseResolver = jiti.createJiti(joinPaths.joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions(options));
479
- baseResolver.plugin = createPluginResolver(options);
480
- return baseResolver;
481
- }
482
- chunkPK6SKIKE_cjs.__name(createResolver, "createResolver");
483
- function isBufferEncoding(options) {
484
- return isSetString.isSetString(options) || options === null;
485
- }
486
- chunkPK6SKIKE_cjs.__name(isBufferEncoding, "isBufferEncoding");
487
- function isPowerlinesWriteFileOptions(options) {
488
- return !isBufferEncoding(options) && isSetObject.isSetObject(options) && ("skipFormat" in options || "mode" in options && (options.mode === "fs" || options.mode === "virtual"));
489
- }
490
- chunkPK6SKIKE_cjs.__name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
491
- function isNodeWriteFileOptions(options) {
492
- return !isUndefined.isUndefined(options) && (isBufferEncoding(options) || !isPowerlinesWriteFileOptions(options));
493
- }
494
- chunkPK6SKIKE_cjs.__name(isNodeWriteFileOptions, "isNodeWriteFileOptions");
495
- function isPowerLinesWriteFileData(data) {
496
- return !!(isSetObject.isSetObject(data) && "code" in data && data.code);
497
- }
498
- chunkPK6SKIKE_cjs.__name(isPowerLinesWriteFileData, "isPowerLinesWriteFileData");
499
- var FILE_PREFIX = "file://";
500
- function toFilePath(pathOrUrl) {
501
- if (!pathOrUrl) {
502
- throw new Error("No Path or URL provided to Virtual File System");
503
- }
504
- let result = pathOrUrl.toString();
505
- if (result.startsWith(FILE_PREFIX)) {
506
- result = result.slice(FILE_PREFIX.length);
507
- }
508
- return result;
509
- }
510
- chunkPK6SKIKE_cjs.__name(toFilePath, "toFilePath");
511
- var FS_METHODS = [
512
- "mkdir",
513
- "mkdirSync",
514
- "rmdir",
515
- "rmdirSync",
516
- "unlink",
517
- "unlinkSync",
518
- "existsSync",
519
- "realpathSync",
520
- "writeFileSync",
521
- "readFileSync",
522
- "readdirSync",
523
- "createWriteStream",
524
- "WriteStream",
525
- "createReadStream",
526
- "ReadStream"
527
- ];
528
- var FS_PROMISE_METHODS = [
529
- "mkdir",
530
- "rm",
531
- "rmdir",
532
- "unlink",
533
- "writeFile",
534
- "readFile",
535
- "readdir",
536
- "stat",
537
- "lstat"
538
- ];
539
- function cloneFS(originalFS) {
540
- const clonedFS = {
541
- ...originalFS,
542
- promises: {
543
- ...originalFS.promises ?? {}
544
- }
545
- };
546
- for (const method of FS_METHODS) {
547
- if (originalFS[method]) {
548
- clonedFS[method] = originalFS[method];
549
- }
550
- }
551
- originalFS.promises ??= {};
552
- for (const method of FS_PROMISE_METHODS) {
553
- if (originalFS.promises[method]) {
554
- clonedFS.promises ??= {};
555
- clonedFS.promises[method] = originalFS.promises[method];
556
- clonedFS[method] = originalFS.promises[method];
557
- }
558
- }
559
- for (const prop in clonedFS) {
560
- if (isFunction.isFunction(clonedFS[prop])) {
561
- clonedFS[prop] = clonedFS[prop].bind(originalFS);
562
- if (isFunction.isFunction(clonedFS.promises[prop])) {
563
- clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
564
- }
565
- }
566
- }
567
- for (const prop in clonedFS.promises) {
568
- if (isFunction.isFunction(clonedFS.promises[prop])) {
569
- clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
570
- }
571
- }
572
- return clonedFS;
573
- }
574
- chunkPK6SKIKE_cjs.__name(cloneFS, "cloneFS");
575
- function patchFS(originalFS, vfs) {
576
- const clonedFS = cloneFS(originalFS);
577
- originalFS.mkdirSync = (file, options) => vfs.mkdirSync(toFilePath(file), options);
578
- originalFS.mkdir = (file, options, callback) => vfs.mkdir(toFilePath(file), options, callback);
579
- originalFS.promises.mkdir = async (file, options) => vfs.mkdir(toFilePath(file), options);
580
- originalFS.unlinkSync = (file) => vfs.unlinkSync(toFilePath(file));
581
- originalFS.promises.rm = async (file, options) => vfs.rm(toFilePath(file), options);
582
- originalFS.promises.unlink = async (file) => vfs.unlink(toFilePath(file));
583
- originalFS.existsSync = (file) => vfs.existsSync(toFilePath(file));
584
- Object.defineProperty(originalFS, "realpathSync", {
585
- value: /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((file, options) => vfs.realpathSync(toFilePath(file), options), "value")
586
- });
587
- originalFS.writeFileSync = (file, data, options) => vfs.writeFileSync(toFilePath(file), data, options);
588
- originalFS.promises.writeFile = async (file, data, options) => vfs.writeFile(toFilePath(file), data, options);
589
- originalFS.readFileSync = (file, options) => vfs.readFileSync(toFilePath(file), options);
590
- originalFS.promises.readFile = (file, options) => vfs.readFile(toFilePath(file), options);
591
- originalFS.readdirSync = (file, options) => vfs.readdirSync(toFilePath(file), options);
592
- originalFS.promises.readdir = (file, options) => vfs.readdir(toFilePath(file), options);
593
- Object.defineProperty(originalFS, "statSync", {
594
- value: /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((file, options) => vfs.statSync(toFilePath(file), options), "value")
595
- });
596
- originalFS.stat = (file, options) => vfs.statSync(toFilePath(file), options);
597
- originalFS.promises.stat = (file, options) => vfs.stat(toFilePath(file), options);
598
- Object.defineProperty(originalFS, "lstatSync", {
599
- value: /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((file, options) => vfs.lstatSync(toFilePath(file), options), "value")
600
- });
601
- originalFS.lstat = (file, options) => vfs.lstatSync(toFilePath(file), options);
602
- originalFS.promises.lstat = (file, options) => vfs.lstat(toFilePath(file), options);
603
- return () => {
604
- originalFS.mkdirSync = clonedFS.mkdirSync;
605
- originalFS.mkdir = clonedFS.mkdir;
606
- originalFS.promises.mkdir = clonedFS.promises.mkdir;
607
- originalFS.unlinkSync = clonedFS.unlinkSync;
608
- originalFS.promises.rm = clonedFS.promises.rm;
609
- originalFS.promises.unlink = clonedFS.promises.unlink;
610
- originalFS.existsSync = clonedFS.existsSync;
611
- originalFS.realpathSync = clonedFS.realpathSync;
612
- originalFS.writeFileSync = clonedFS.writeFileSync;
613
- originalFS.promises.writeFile = clonedFS.promises.writeFile;
614
- originalFS.readFileSync = clonedFS.readFileSync;
615
- originalFS.promises.readFile = clonedFS.promises.readFile;
616
- originalFS.readdirSync = clonedFS.readdirSync;
617
- originalFS.promises.readdir = clonedFS.promises.readdir;
618
- Object.defineProperty(originalFS, "statSync", {
619
- value: clonedFS.statSync
620
- });
621
- originalFS.stat = clonedFS.stat;
622
- originalFS.promises.stat = clonedFS.promises.stat;
623
- Object.defineProperty(originalFS, "lstatSync", {
624
- value: clonedFS.lstatSync
625
- });
626
- originalFS.lstat = clonedFS.lstat;
627
- originalFS.promises.lstat = clonedFS.promises.lstat;
628
- };
629
- }
630
- chunkPK6SKIKE_cjs.__name(patchFS, "patchFS");
631
- var VirtualFileSystem = class {
632
- static {
633
- chunkPK6SKIKE_cjs.__name(this, "VirtualFileSystem");
634
- }
635
- /**
636
- * The internal map of virtual files.
637
- */
638
- #meta = {};
639
- /**
640
- * A map of unique identifiers to their virtual file paths.
641
- */
642
- #ids = {};
643
- /**
644
- * A map of virtual file paths to their underlying file content.
645
- */
646
- #cachedFS = /* @__PURE__ */ new Map();
647
- /**
648
- * A map of virtual file paths to their underlying file content.
649
- */
650
- #cachedResolver = /* @__PURE__ */ new Map();
651
- /**
652
- * The internal map of virtual files.
653
- */
654
- #virtualFS = new memfs.Volume();
655
- /**
656
- * The physical file system.
657
- */
658
- #fs = cloneFS(fs__default.default);
659
- /**
660
- * The unified volume that combines the virtual file system with the real file system.
661
- *
662
- * @remarks
663
- * This volume allows for seamless access to both virtual and real files.
664
- */
665
- #unifiedFS = new unionfs.Union();
666
- /**
667
- * Indicator specifying if the file system module is patched
668
- */
669
- #isPatched = false;
670
- /**
671
- * Function to revert require patch
672
- */
673
- #revert;
674
- /**
675
- * The context of the virtual file system.
676
- */
677
- #context;
678
- /**
679
- * The file system's logging function.
680
- */
681
- #log;
682
- /**
683
- * Checks if a path exists in the virtual file system (VFS).
684
- *
685
- * @param path - The path to check.
686
- * @returns `true` if the path exists, otherwise `false`.
687
- */
688
- #existsSync(path) {
689
- const formattedPath = this.formatPath(path);
690
- return this.#virtualFS.existsSync(formattedPath) || this.#fs.existsSync(formattedPath) || this.resolveFS(path).existsSync(formattedPath);
691
- }
692
- /**
693
- * Exposes the internal VFS map for advanced usage.
694
- */
695
- get [chunk22K72CJ5_cjs.__VFS_CACHE__]() {
696
- return this.#cachedFS;
697
- }
698
- /**
699
- * Exposes the internal VFS resolver cache for advanced usage.
700
- */
701
- get [chunk22K72CJ5_cjs.__VFS_RESOLVER__]() {
702
- return this.#cachedResolver;
703
- }
704
- /**
705
- * Exposes the internal VFS map for advanced usage.
706
- */
707
- get [chunk22K72CJ5_cjs.__VFS_VIRTUAL__]() {
708
- return this.#virtualFS;
709
- }
710
- /**
711
- * Exposes the internal UFS map for advanced usage.
712
- */
713
- get [chunk22K72CJ5_cjs.__VFS_UNIFIED__]() {
714
- return this.#unifiedFS;
715
- }
716
- /**
717
- * A proxy to access the underlying file metadata.
718
- */
719
- get meta() {
720
- return new Proxy(this.#meta, {
721
- get: /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((target, prop) => {
722
- if (target[prop]) {
723
- return {
724
- id: prop,
725
- mode: this.#virtualFS.existsSync(prop) ? "virtual" : this.#fs.existsSync(prop) ? "fs" : this.#context.config.output.mode,
726
- details: {},
727
- variant: "normal",
728
- ...target[prop]
729
- };
730
- }
731
- return void 0;
732
- }, "get"),
733
- set: /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((target, prop, value) => {
734
- target[prop] = value;
735
- this.#ids[value.id || prop] = prop;
736
- return true;
737
- }, "set"),
738
- deleteProperty: /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((target, prop) => {
739
- delete this.#ids[target[prop]?.id || prop];
740
- delete target[prop];
741
- return true;
742
- }, "deleteProperty")
743
- });
744
- }
745
- /**
746
- * A map of module ids to their file paths.
747
- */
748
- get ids() {
749
- return this.#ids;
750
- }
751
- /**
752
- * Creates a new instance of the VirtualFileSystem.
753
- *
754
- * @param context - The context of the virtual file system, typically containing options and logging functions.
755
- * @param serialized - A map of files/file contents to populate in cache
756
- */
757
- constructor(context, serialized = {}) {
758
- this.#context = context;
759
- this.#cachedFS = /* @__PURE__ */ new Map();
760
- this.#meta = Object.fromEntries(Object.entries(serialized.virtualFilesMeta ?? {}));
761
- this.#ids = Object.fromEntries(Object.entries(this.#meta).map(([path, data]) => [
762
- data.id || path,
763
- path
764
- ]));
765
- if (!this.#fs.existsSync(this.#context.dataPath)) {
766
- this.#fs.mkdirSync(this.#context.dataPath, {
767
- recursive: true
768
- });
769
- }
770
- if (!this.#fs.existsSync(this.#context.cachePath)) {
771
- this.#fs.mkdirSync(this.#context.cachePath, {
772
- recursive: true
773
- });
774
- }
775
- if (!this.#fs.existsSync(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
776
- this.#fs.mkdirSync(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath), {
777
- recursive: true
778
- });
779
- }
780
- this.#unifiedFS = this.#unifiedFS.use(this.#fs);
781
- if (this.#context.config.output.mode !== "fs") {
782
- if (serialized?.virtualFiles && Object.keys(serialized.virtualFiles).length > 0) {
783
- this.#virtualFS = memfs.Volume.fromJSON(serialized.virtualFiles);
784
- }
785
- if (!this.#virtualFS.existsSync(this.#context.artifactsPath)) {
786
- this.#virtualFS.mkdirSync(this.#context.artifactsPath, {
787
- recursive: true
788
- });
789
- }
790
- if (!this.#virtualFS.existsSync(this.#context.builtinsPath)) {
791
- this.#virtualFS.mkdirSync(this.#context.builtinsPath, {
792
- recursive: true
793
- });
794
- }
795
- if (!this.#virtualFS.existsSync(this.#context.entryPath)) {
796
- this.#virtualFS.mkdirSync(this.#context.entryPath, {
797
- recursive: true
798
- });
799
- }
800
- if (!this.#virtualFS.existsSync(this.#context.dtsPath)) {
801
- this.#virtualFS.mkdirSync(this.#context.dtsPath, {
802
- recursive: true
803
- });
804
- }
805
- this.#unifiedFS = this.#unifiedFS.use(this.#virtualFS);
806
- } else if (this.#context.config.projectType === "application") {
807
- if (!this.#fs.existsSync(this.#context.artifactsPath)) {
808
- this.#fs.mkdirSync(this.#context.artifactsPath, {
809
- recursive: true
810
- });
811
- }
812
- if (!this.#fs.existsSync(this.#context.builtinsPath)) {
813
- this.#fs.mkdirSync(this.#context.builtinsPath, {
814
- recursive: true
815
- });
816
- }
817
- if (!this.#fs.existsSync(this.#context.entryPath)) {
818
- this.#fs.mkdirSync(this.#context.entryPath, {
819
- recursive: true
820
- });
821
- }
822
- if (!this.#fs.existsSync(this.#context.dtsPath)) {
823
- this.#fs.mkdirSync(this.#context.dtsPath, {
824
- recursive: true
825
- });
826
- }
827
- }
828
- this.#log = extendLog(this.#context.log, "virtual-file-system");
829
- }
830
- [chunk22K72CJ5_cjs.__VFS_INIT__]() {
831
- if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
832
- this.#revert = patchFS(fs__default.default, this);
833
- this.#isPatched = true;
834
- }
835
- }
836
- [chunk22K72CJ5_cjs.__VFS_REVERT__]() {
837
- if (this.#isPatched && this.#context.config.output.mode !== "fs") {
838
- if (!this.#revert) {
839
- throw new Error("Attempting to revert File System patch prior to calling `__init__` function");
840
- }
841
- this.#revert?.();
842
- this.#isPatched = false;
843
- }
844
- }
845
- /**
846
- * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
847
- *
848
- * @param pathOrId - The path or id to check.
849
- * @param options - Optional parameters for resolving the path.
850
- * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
851
- */
852
- isVirtual(pathOrId, options = {}) {
853
- if (!pathOrId) {
854
- return false;
855
- }
856
- const resolvedPath = this.resolve(pathOrId, {
857
- ...options,
858
- type: "file"
859
- });
860
- if (!resolvedPath) {
861
- return false;
862
- }
863
- return this.meta[resolvedPath]?.mode === "virtual";
864
- }
865
- /**
866
- * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
867
- *
868
- * @param pathOrId - The path or id to check.
869
- * @param options - Optional parameters for resolving the path.
870
- * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
871
- */
872
- isFs(pathOrId, options = {}) {
873
- if (!pathOrId) {
874
- return false;
875
- }
876
- const resolvedPath = this.resolve(pathOrId, {
877
- ...options,
878
- type: "file"
879
- });
880
- if (!resolvedPath) {
881
- return false;
882
- }
883
- return this.meta[resolvedPath]?.mode === "fs";
884
- }
885
- /**
886
- * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.
887
- *
888
- * @see https://www.typescriptlang.org/tsconfig#paths
889
- *
890
- * @param pathOrId - The path or ID to check.
891
- * @returns Whether the path or ID corresponds to a virtual file.
892
- */
893
- isTsconfigPath(pathOrId) {
894
- return !!this.#context.tsconfig.options.paths && Object.keys(this.#context.tsconfig.options.paths).some((path) => pathOrId.startsWith(path.replaceAll("*", "")));
895
- }
896
- /**
897
- * Lists files in a given path.
898
- *
899
- * @param path - The path to list files from.
900
- * @param options - Options for listing files, such as encoding and recursion.
901
- * @returns An array of file names in the specified path.
902
- */
903
- readdirSync(path, options = "utf8") {
904
- return this.resolveFS(path).readdirSync(toFilePath(path), options);
905
- }
906
- /**
907
- * Removes a file in the virtual file system (VFS).
908
- *
909
- * @param path - The path to create the directory at.
910
- */
911
- unlinkSync(path, options) {
912
- const formattedPath = toFilePath(path);
913
- if (!this.isFile(formattedPath)) {
914
- return;
915
- }
916
- this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${formattedPath}`);
917
- this.resolveFS(path, options).unlinkSync(formattedPath);
918
- this.#cachedFS.delete(formattedPath);
919
- this.clearResolverCache(formattedPath);
920
- }
921
- /**
922
- * Removes a file in the virtual file system (VFS).
923
- *
924
- * @param path - The path to create the directory at.
925
- */
926
- async unlink(path, options) {
927
- const formattedPath = toFilePath(path);
928
- if (!this.isFile(formattedPath)) {
929
- return;
930
- }
931
- this.#log(types.LogLevelLabel.TRACE, `Removing file: ${formattedPath}`);
932
- if (isFunction.isFunction(this.resolveFS(path, options).promises.unlink)) {
933
- await this.resolveFS(path, options).promises.unlink(formattedPath);
934
- this.#cachedFS.delete(formattedPath);
935
- this.clearResolverCache(formattedPath);
936
- } else {
937
- this.unlinkSync(formattedPath, options);
938
- }
939
- }
940
- /**
941
- * Removes a directory in the virtual file system (VFS).
942
- *
943
- * @param path - The path to create the directory at.
944
- * @param options - Options for creating the directory.
945
- */
946
- rmdirSync(path, options = {}) {
947
- const formattedPath = toFilePath(path);
948
- if (!this.isDirectory(formattedPath)) {
949
- return;
950
- }
951
- this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${formattedPath}`);
952
- this.resolveFS(path, options).rmdirSync(formattedPath, defu5__default.default(options, {
953
- recursive: true
954
- }));
955
- this.#cachedFS.delete(formattedPath);
956
- this.clearResolverCache(formattedPath);
957
- }
958
- /**
959
- * Removes a directory in the virtual file system (VFS).
960
- *
961
- * @param path - The path to create the directory at.
962
- * @param options - Options for creating the directory.
963
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
964
- */
965
- async rmdir(path, options = {}) {
966
- const formattedPath = toFilePath(path);
967
- if (!this.isDirectory(formattedPath)) {
968
- return;
969
- }
970
- this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${formattedPath}`);
971
- if (isFunction.isFunction(this.resolveFS(path, options).promises.rm)) {
972
- await this.resolveFS(path, options).promises.rm(formattedPath, defu5__default.default(options, {
973
- force: true,
974
- recursive: true
975
- }));
976
- this.#cachedFS.delete(formattedPath);
977
- this.clearResolverCache(formattedPath);
978
- } else {
979
- this.rmdirSync(formattedPath, defu5__default.default(options ?? {}, {
980
- force: true,
981
- recursive: true
982
- }));
983
- }
984
- }
985
- /**
986
- * Removes a file in the virtual file system (VFS).
987
- *
988
- * @param path - The path to the file to remove.
989
- * @param options - Options for removing the file.
990
- * @returns A promise that resolves when the file is removed.
991
- */
992
- async rm(path, options = {}) {
993
- this.#log(types.LogLevelLabel.TRACE, `Removing: ${toFilePath(path)}`);
994
- if (this.isDirectory(path)) {
995
- return this.rmdir(path, options);
996
- }
997
- return this.unlink(path, options);
998
- }
999
- /**
1000
- * Synchronously removes a file or directory in the virtual file system (VFS).
1001
- *
1002
- * @param path - The path to the file or directory to remove.
1003
- * @param options - Options for removing the file or directory.
1004
- */
1005
- rmSync(path, options = {}) {
1006
- this.#log(types.LogLevelLabel.TRACE, `Removing: ${toFilePath(path)}`);
1007
- if (this.isDirectory(path)) {
1008
- return this.rmdirSync(path, options);
1009
- }
1010
- return this.unlinkSync(path, options);
1011
- }
1012
- /**
1013
- * Creates a directory in the virtual file system (VFS).
1014
- *
1015
- * @param path - The path to create the directory at.
1016
- * @param options - Options for creating the directory.
1017
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1018
- */
1019
- mkdirSync(path, options = {}) {
1020
- const filePath = toFilePath(path);
1021
- this.clearResolverCache(filePath);
1022
- return this.resolveFS(filePath, options).mkdirSync(filePath, defu5__default.default(options ?? {}, {
1023
- recursive: true
1024
- }));
1025
- }
1026
- /**
1027
- * Creates a directory in the virtual file system (VFS).
1028
- *
1029
- * @param path - The path to create the directory at.
1030
- * @param options - Options for creating the directory.
1031
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1032
- */
1033
- async mkdir(path, options = {}) {
1034
- let result;
1035
- const filePath = toFilePath(path);
1036
- if (isFunction.isFunction(this.resolveFS(filePath, options).promises.mkdir)) {
1037
- result = await this.resolveFS(filePath, options).promises.mkdir(filePath, defu5__default.default(options ?? {}, {
1038
- recursive: true
1039
- }));
1040
- } else {
1041
- result = this.resolveFS(filePath, options).mkdirSync(filePath, defu5__default.default(options ?? {}, {
1042
- recursive: true
1043
- }));
1044
- }
1045
- this.clearResolverCache(filePath);
1046
- return result;
1047
- }
1048
- /**
1049
- * Glob files in the virtual file system (VFS) based on the provided pattern(s).
1050
- *
1051
- * @param patterns - A pattern (or multiple patterns) to use to determine the file paths to return
1052
- * @returns An array of file paths matching the provided pattern(s)
1053
- */
1054
- async glob(patterns) {
1055
- const results = [];
1056
- for (const pattern of toArray.toArray(patterns)) {
1057
- const normalized = this.formatPath(pattern);
1058
- if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
1059
- const resolved = this.resolve(normalized, {
1060
- type: "file"
1061
- });
1062
- if (resolved && !results.includes(resolved)) {
1063
- results.push(resolved);
1064
- }
1065
- continue;
1066
- }
1067
- const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
1068
- const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
1069
- const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
1070
- const stack = [
1071
- baseDir && isType.isAbsolutePath(baseDir) ? baseDir : this.#context.workspaceConfig.workspaceRoot
1072
- ];
1073
- while (stack.length) {
1074
- const dir = stack.pop();
1075
- let entries = [];
1076
- try {
1077
- entries = await this.readdir(dir);
1078
- } catch {
1079
- continue;
1080
- }
1081
- for (const entry of entries) {
1082
- const full = this.formatPath(joinPaths.joinPaths(dir, entry));
1083
- let stats;
1084
- try {
1085
- stats = this.#unifiedFS.lstatSync(full);
1086
- } catch {
1087
- stats = void 0;
1088
- }
1089
- if (!stats) continue;
1090
- if (stats.isDirectory()) {
1091
- stack.push(full);
1092
- } else if (stats.isFile()) {
1093
- if (this.buildRegex(absPattern).test(full)) {
1094
- const resolved = this.resolve(full, {
1095
- type: "file"
1096
- });
1097
- if (resolved && !results.includes(resolved)) {
1098
- results.push(resolved);
1099
- }
1100
- }
1101
- }
1102
- }
1103
- }
1104
- }
1105
- return results;
1106
- }
1107
- /**
1108
- * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).
1109
- *
1110
- * @param patterns - A pattern (or multiple patterns) to use to determine the file paths to return
1111
- * @returns An array of file paths matching the provided pattern(s)
1112
- */
1113
- globSync(patterns) {
1114
- const results = [];
1115
- for (const pattern of toArray.toArray(patterns)) {
1116
- const normalized = this.formatPath(pattern);
1117
- if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
1118
- const resolved = this.resolve(normalized, {
1119
- type: "file"
1120
- });
1121
- if (resolved && !results.includes(resolved)) {
1122
- results.push(resolved);
1123
- }
1124
- continue;
1125
- }
1126
- const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
1127
- const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
1128
- const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
1129
- const stack = [
1130
- baseDir && isType.isAbsolutePath(baseDir) ? baseDir : this.#context.workspaceConfig.workspaceRoot
1131
- ];
1132
- while (stack.length) {
1133
- const dir = stack.pop();
1134
- let entries = [];
1135
- try {
1136
- entries = this.readdirSync(dir);
1137
- } catch {
1138
- continue;
1139
- }
1140
- for (const entry of entries) {
1141
- const full = this.formatPath(joinPaths.joinPaths(dir, entry));
1142
- let stats;
1143
- try {
1144
- stats = this.#unifiedFS.lstatSync(full);
1145
- } catch {
1146
- stats = void 0;
1147
- }
1148
- if (!stats) continue;
1149
- if (stats.isDirectory()) {
1150
- stack.push(full);
1151
- } else if (stats.isFile()) {
1152
- if (this.buildRegex(absPattern).test(full)) {
1153
- const resolved = this.resolve(full, {
1154
- type: "file"
1155
- });
1156
- if (resolved && !results.includes(resolved)) {
1157
- results.push(resolved);
1158
- }
1159
- }
1160
- }
1161
- }
1162
- }
1163
- }
1164
- return results;
1165
- }
1166
- /**
1167
- * Moves a file from one path to another in the virtual file system (VFS).
1168
- *
1169
- * @param srcPath - The source path to move
1170
- * @param destPath - The destination path to move to
1171
- */
1172
- async move(srcPath, destPath) {
1173
- const content = await this.readFile(srcPath);
1174
- await this.writeFile(destPath, content);
1175
- await this.rm(srcPath);
1176
- }
1177
- /**
1178
- * Synchronously moves a file from one path to another in the virtual file system (VFS).
1179
- *
1180
- * @param srcPath - The source path to move
1181
- * @param destPath - The destination path to move to
1182
- */
1183
- moveSync(srcPath, destPath) {
1184
- const content = this.readFileSync(srcPath);
1185
- this.writeFileSync(destPath, content);
1186
- this.rmSync(srcPath);
1187
- }
1188
- /**
1189
- * Copies a file from one path to another in the virtual file system (VFS).
1190
- *
1191
- * @param srcPath - The source path to copy
1192
- * @param destPath - The destination path to copy to
1193
- */
1194
- async copy(srcPath, destPath) {
1195
- const content = await this.readFile(srcPath);
1196
- await this.writeFile(destPath, content);
1197
- }
1198
- /**
1199
- * Synchronously copies a file from one path to another in the virtual file system (VFS).
1200
- *
1201
- * @param srcPath - The source path to copy
1202
- * @param destPath - The destination path to copy to
1203
- */
1204
- copySync(srcPath, destPath) {
1205
- const content = this.readFileSync(srcPath);
1206
- this.writeFileSync(destPath, content);
1207
- }
1208
- /**
1209
- * Lists files in a given path.
1210
- *
1211
- * @param pathOrId - The path to list files from.
1212
- * @param options - Options for listing files, such as encoding and recursion.
1213
- * @returns An array of file names in the specified path.
1214
- */
1215
- async readdir(pathOrId, options = "utf8") {
1216
- return this.resolveFS(pathOrId).promises.readdir(toFilePath(pathOrId), options);
1217
- }
1218
- /**
1219
- * Asynchronously reads a file from the virtual file system (VFS).
1220
- *
1221
- * @param pathOrId - The path or ID of the file to read.
1222
- * @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
1223
- */
1224
- async readFile(pathOrId, options = "utf8") {
1225
- if (!pathOrId) {
1226
- return void 0;
1227
- }
1228
- const filePath = this.resolve(toFilePath(pathOrId), {
1229
- type: "file"
1230
- });
1231
- if (filePath) {
1232
- if (this.#cachedFS.has(filePath)) {
1233
- return this.#cachedFS.get(filePath);
1234
- }
1235
- let result;
1236
- if (isFunction.isFunction(this.resolveFS(filePath).promises.readFile)) {
1237
- result = (await this.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
1238
- } else {
1239
- result = this.resolveFS(filePath).readFileSync(filePath, options);
1240
- }
1241
- const content = isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
1242
- this.#cachedFS.set(filePath, content);
1243
- return content;
1244
- }
1245
- return void 0;
1246
- }
1247
- /**
1248
- * Synchronously reads a file from the virtual file system (VFS).
1249
- *
1250
- * @param pathOrId - The path or ID of the file to read.
1251
- * @returns The contents of the file as a string, or undefined if the file does not exist.
1252
- */
1253
- readFileSync(pathOrId, options = "utf8") {
1254
- if (!pathOrId) {
1255
- return void 0;
1256
- }
1257
- const filePath = this.resolve(toFilePath(pathOrId), {
1258
- type: "file"
1259
- });
1260
- if (filePath) {
1261
- if (this.#cachedFS.has(filePath)) {
1262
- return this.#cachedFS.get(filePath);
1263
- }
1264
- const result = this.resolveFS(filePath).readFileSync(filePath, options);
1265
- const content = isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
1266
- this.#cachedFS.set(filePath, content);
1267
- return content;
1268
- }
1269
- return void 0;
1270
- }
1271
- /**
1272
- * Writes a file to the virtual file system (VFS).
1273
- *
1274
- * @param path - The path to the file.
1275
- * @param data - The contents of the file.
1276
- * @param options - Optional parameters for writing the file.
1277
- * @returns A promise that resolves when the file is written.
1278
- */
1279
- async writeFile(path, data = "", options = "utf8") {
1280
- const formattedPath = this.formatPath(path);
1281
- if (!this.isDirectory(filePathFns.findFilePath(formattedPath))) {
1282
- await this.mkdir(filePathFns.findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
1283
- }
1284
- let code = isPowerLinesWriteFileData(data) ? data.code : data;
1285
- if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString.isSetString(code)) {
1286
- const resolvedConfig = await prettier.resolveConfig(formattedPath);
1287
- if (resolvedConfig) {
1288
- code = await prettier.format(code, {
1289
- absolutePath: formattedPath,
1290
- ...resolvedConfig
1291
- });
1292
- }
1293
- }
1294
- const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1295
- this.#log(types.LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer.Blob(toArray.toArray(code)).size)})`);
1296
- this.meta[formattedPath] = {
1297
- path: formattedPath,
1298
- code,
1299
- mode: outputMode,
1300
- variant: "normal",
1301
- ...isPowerLinesWriteFileData(data) ? data : {}
1302
- };
1303
- this.clearResolverCache(formattedPath);
1304
- const ifs = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1305
- if (isFunction.isFunction(ifs.promises.writeFile)) {
1306
- return ifs.promises.writeFile(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
1307
- }
1308
- return ifs.writeFileSync(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
1309
- }
1310
- /**
1311
- * Synchronously writes a file to the virtual file system (VFS).
1312
- *
1313
- * @param path - The file to write.
1314
- * @param data - The contents of the file.
1315
- * @param options - Optional parameters for writing the file.
1316
- */
1317
- writeFileSync(path, data = "", options = "utf8") {
1318
- const formattedPath = this.formatPath(path);
1319
- if (!this.isDirectory(filePathFns.findFilePath(formattedPath))) {
1320
- this.mkdirSync(filePathFns.findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
1321
- }
1322
- const code = isPowerLinesWriteFileData(data) ? data.code : data;
1323
- const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1324
- this.#log(types.LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer.Blob(toArray.toArray(code)).size)})`);
1325
- this.meta[formattedPath] = {
1326
- path: formattedPath,
1327
- code,
1328
- mode: outputMode,
1329
- variant: "normal",
1330
- ...isPowerLinesWriteFileData(data) ? data : {}
1331
- };
1332
- this.clearResolverCache(formattedPath);
1333
- const writeStream = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
1334
- try {
1335
- writeStream.write(code);
1336
- } finally {
1337
- writeStream.close();
1338
- }
1339
- }
1340
- /**
1341
- * Synchronously checks if a file exists in the virtual file system (VFS).
1342
- *
1343
- * @param pathOrId - The path or ID of the file to check.
1344
- * @returns `true` if the file exists, otherwise `false`.
1345
- */
1346
- existsSync(pathOrId) {
1347
- return this.resolve(pathOrId) !== false;
1348
- }
1349
- /**
1350
- * Retrieves the metadata of a file in the virtual file system (VFS).
1351
- *
1352
- * @param pathOrId - The path or ID of the file to retrieve metadata for.
1353
- * @returns The metadata of the file, or undefined if the file does not exist.
1354
- */
1355
- getMetadata(pathOrId) {
1356
- const resolved = this.resolve(pathOrId);
1357
- if (resolved && this.meta[resolved]) {
1358
- return this.meta[resolved];
1359
- }
1360
- return void 0;
1361
- }
1362
- /**
1363
- * Checks if a file exists in the virtual file system (VFS).
1364
- *
1365
- * @remarks
1366
- * This is a base method used by {@link existsSync} - it does not try to resolve the path prior to checking if it exists or not.
1367
- *
1368
- * @param pathOrId - The path of the file to check.
1369
- * @returns `true` if the file exists, otherwise `false`.
1370
- */
1371
- isFile(pathOrId) {
1372
- const resolved = this.resolve(pathOrId);
1373
- return !!(resolved && (this.#virtualFS.existsSync(resolved) && this.#virtualFS.lstatSync(resolved).isFile() || this.#fs.existsSync(resolved) && this.#fs.lstatSync(resolved).isFile() || this.resolveFS(resolved).existsSync(resolved) && this.resolveFS(resolved).lstatSync(resolved).isFile()));
1374
- }
1375
- /**
1376
- * Checks if a directory exists in the virtual file system (VFS).
1377
- *
1378
- * @param pathOrId - The path of the directory to check.
1379
- * @returns `true` if the directory exists, otherwise `false`.
1380
- */
1381
- isDirectory(pathOrId) {
1382
- const resolved = this.resolve(pathOrId);
1383
- return !!(resolved && (this.#virtualFS.existsSync(resolved) && this.#virtualFS.lstatSync(resolved).isDirectory() || this.#fs.existsSync(resolved) && this.#fs.lstatSync(resolved).isDirectory() || this.resolveFS(resolved).existsSync(resolved) && this.resolveFS(resolved).lstatSync(resolved).isDirectory()));
1384
- }
1385
- /**
1386
- * Retrieves the status of a file in the virtual file system (VFS).
1387
- *
1388
- * @param pathOrId - The path or ID of the file to retrieve status for.
1389
- * @returns A promise that resolves to the file's status information, or false if the file does not exist.
1390
- */
1391
- async stat(pathOrId, options) {
1392
- return this.resolveFS(pathOrId).promises.stat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1393
- }
1394
- /**
1395
- * Synchronously retrieves the status of a file in the virtual file system (VFS).
1396
- *
1397
- * @param pathOrId - The path or ID of the file to retrieve status for.
1398
- * @returns The file's status information, or false if the file does not exist.
1399
- */
1400
- statSync(pathOrId) {
1401
- return this.resolveFS(pathOrId).statSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId));
1402
- }
1403
- /**
1404
- * Retrieves the status of a symbolic link in the virtual file system (VFS).
1405
- *
1406
- * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1407
- * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
1408
- */
1409
- async lstat(pathOrId, options) {
1410
- return this.resolveFS(pathOrId).promises.lstat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1411
- }
1412
- /**
1413
- * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
1414
- *
1415
- * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1416
- * @returns The symbolic link's status information, or false if the link does not exist.
1417
- */
1418
- lstatSync(pathOrId, options) {
1419
- return this.resolveFS(pathOrId).lstatSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1420
- }
1421
- /**
1422
- * Resolves a path based on TypeScript's `tsconfig.json` paths.
1423
- *
1424
- * @see https://www.typescriptlang.org/tsconfig#paths
1425
- *
1426
- * @param path - The path to check.
1427
- * @returns The resolved file path if it exists, otherwise undefined.
1428
- */
1429
- resolveTsconfigPath(path) {
1430
- if (this.#context.tsconfig.options.paths) {
1431
- for (const tsconfigPathKey of Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")))) {
1432
- const resolvedPath = this.#context.tsconfig.options.paths[tsconfigPathKey]?.find((tsconfigPath) => this.resolvePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, tsconfigPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), ""))) || this.formatPath(tsconfigPath) === this.formatPath(path));
1433
- if (resolvedPath) {
1434
- return this.formatPath(resolvedPath) === this.formatPath(path) ? this.formatPath(resolvedPath) : this.resolvePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, resolvedPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), "")));
1435
- }
1436
- }
1437
- }
1438
- return false;
1439
- }
1440
- /**
1441
- * Resolves a path based on TypeScript's `tsconfig.json` paths.
1442
- *
1443
- * @see https://www.typescriptlang.org/tsconfig#paths
1444
- *
1445
- * @param path - The path to check.
1446
- * @returns The resolved file path if it exists, otherwise undefined.
1447
- */
1448
- resolveTsconfigPathPackage(path) {
1449
- if (this.#context.tsconfig.options.paths) {
1450
- const tsconfigPathKeys = Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")));
1451
- if (tsconfigPathKeys.length > 0 && tsconfigPathKeys[0]) {
1452
- return tsconfigPathKeys[0].replace(/\/\*$/, "");
1453
- }
1454
- }
1455
- return false;
1456
- }
1457
- /**
1458
- * Resolves a path or ID to its real path in the virtual file system (VFS).
1459
- *
1460
- * @param pathOrId - The path or ID to resolve.
1461
- * @returns The resolved real path if it exists, otherwise undefined.
1462
- */
1463
- realpathSync(pathOrId) {
1464
- const filePath = this.resolve(toFilePath(pathOrId));
1465
- if (!filePath) {
1466
- throw new Error(`File not found: ${toFilePath(pathOrId)}`);
1467
- }
1468
- return filePath;
1469
- }
1470
- /**
1471
- * Resolves a path or ID parameter to a corresponding virtual file path in the virtual file system (VFS).
1472
- *
1473
- * @param pathOrId - The path or ID to resolve.
1474
- * @param options - Optional parameters for resolving the path, such as whether to include the file extension.
1475
- * @returns The resolved file path if it exists, otherwise undefined.
1476
- */
1477
- resolve(pathOrId, options = {}) {
1478
- const formattedPathOrId = toFilePath(pathOrId);
1479
- const resolverKey = `${formattedPathOrId}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash.murmurhash(options.paths)}` : ""}${options.type ? `-${options.type}` : ""}`;
1480
- if (this.#cachedResolver.has(resolverKey)) {
1481
- return this.#cachedResolver.get(resolverKey);
1482
- }
1483
- let result = this.resolveId(formattedPathOrId);
1484
- if (!result) {
1485
- result = this.resolvePath(formattedPathOrId, options);
1486
- }
1487
- if (!result) {
1488
- result = false;
1489
- }
1490
- if (result && options.withExtension === false) {
1491
- return result.replace(/\.[m|c]?[t|j]sx?$/, "");
1492
- }
1493
- this.#cachedResolver.set(resolverKey, result);
1494
- return result;
1495
- }
1496
- /**
1497
- * Retrieves the partial metadata for all files in the virtual file system (VFS).
1498
- *
1499
- * @returns A record containing the partial metadata for all files.
1500
- */
1501
- getPartialMeta() {
1502
- return Object.fromEntries(Object.entries(this.#meta).filter(([_, data]) => isSetObject.isSetObject(data)));
1503
- }
1504
- buildRegex(strPattern) {
1505
- const token = "::GLOBSTAR::";
1506
- return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
1507
- }
1508
- /**
1509
- * Converts a relative path to an absolute path based on the workspace and project root.
1510
- *
1511
- * @param path - The relative path to convert.
1512
- * @returns The absolute path.
1513
- */
1514
- formatPath(path) {
1515
- const formattedPath = toFilePath(path);
1516
- if (isType.isAbsolutePath(formattedPath) || formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)) {
1517
- return formattedPath;
1518
- } else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
1519
- return joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, formattedPath);
1520
- }
1521
- return formattedPath;
1522
- }
1523
- /**
1524
- * Formats a file id by removing the file extension and prepending the runtime prefix.
1525
- *
1526
- * @param id - The file ID to format.
1527
- * @returns The formatted file ID.
1528
- */
1529
- formatId(id) {
1530
- const formattedId = toFilePath(id);
1531
- return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(formattedId), "")}`;
1532
- }
1533
- /**
1534
- * Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
1535
- *
1536
- * @param id - The id to resolve.
1537
- * @returns The resolved file id if it exists, otherwise undefined.
1538
- */
1539
- resolveId(id) {
1540
- if (this.#ids[this.formatId(id)]) {
1541
- return this.#ids[this.formatId(id)] || false;
1542
- }
1543
- return false;
1544
- }
1545
- /**
1546
- * Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
1547
- *
1548
- * @param path - The path to resolve.
1549
- * @param options - Optional parameters for resolving the path.
1550
- * @returns The resolved file path if it exists, otherwise undefined.
1551
- */
1552
- resolvePath(path, options = {}) {
1553
- if (isType.isAbsolutePath(path)) {
1554
- if (this.#existsSync(path)) {
1555
- return path;
1556
- }
1557
- const result = this.checkVariants(path);
1558
- if (result) {
1559
- return result;
1560
- }
1561
- }
1562
- for (const parentPath of this.resolveParentPaths(path, options.paths)) {
1563
- const request = joinPaths.joinPaths(parentPath, path);
1564
- if (this.#existsSync(request)) {
1565
- return request;
1566
- }
1567
- const result = this.checkVariants(request);
1568
- if (result) {
1569
- return result;
1570
- }
1571
- }
1572
- return false;
1573
- }
1574
- resolveParentPaths(request, parents = []) {
1575
- let paths = [
1576
- this.#context.workspaceConfig.workspaceRoot,
1577
- joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
1578
- ];
1579
- if (this.#context.tsconfig.options.paths) {
1580
- paths = this.#context.tsconfig.options.paths ? Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => request.startsWith(tsconfigPath.replaceAll("*", ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().reduce((ret, path) => {
1581
- if (path && !ret.includes(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path))) {
1582
- ret.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path));
1583
- }
1584
- return ret;
1585
- }, paths) : paths;
1586
- }
1587
- return paths.reduce((ret, path) => {
1588
- if (!ret.includes(path)) {
1589
- ret.push(path);
1590
- }
1591
- return ret;
1592
- }, parents.filter(Boolean).map((p) => this.formatPath(p)));
1593
- }
1594
- /**
1595
- * Select the file system module to use for the operation based on the path or URL.
1596
- *
1597
- * @param pathOrUrl - The path to perform the file system operation on.
1598
- * @param options - Options for the operation, such as output mode.
1599
- * @returns The file system module used for the operation.
1600
- */
1601
- resolveFS(pathOrUrl, options = {}) {
1602
- const mode = this.resolveOutputMode(pathOrUrl, options);
1603
- if (mode === "virtual") {
1604
- return this.#virtualFS;
1605
- } else if (mode === "fs") {
1606
- return this.#fs;
1607
- }
1608
- return this.#unifiedFS;
1609
- }
1610
- /**
1611
- * Select the file system module to use for the operation based on the path or URL.
1612
- *
1613
- * @param pathOrUrl - The path to perform the file system operation on.
1614
- * @param options - Options for the operation, such as output mode.
1615
- * @returns The file system module used for the operation.
1616
- */
1617
- resolveOutputMode(pathOrUrl, options = {}) {
1618
- if (options.mode === "virtual" && this.#context.config.output.mode !== "fs" && isParentPath.isParentPath(toFilePath(pathOrUrl), this.#context.artifactsPath)) {
1619
- return "virtual";
1620
- } else if (options.mode === "fs" || this.#context.config.output.mode === "fs" || isParentPath.isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) || isParentPath.isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) || isParentPath.isParentPath(toFilePath(pathOrUrl), joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
1621
- return "fs";
1622
- }
1623
- return void 0;
1624
- }
1625
- /**
1626
- * Clears the resolver cache for a given path.
1627
- *
1628
- * @param path - The path to clear the resolver cache for.
1629
- */
1630
- clearResolverCache(path) {
1631
- this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
1632
- }
1633
- /**
1634
- * Check if the file exists with different variants (index, extensions).
1635
- *
1636
- * @param request - The request path to check.
1637
- * @param parentPath - An optional parent path to prepend to the request.
1638
- * @returns The file path if it exists, otherwise false.
1639
- */
1640
- checkVariants(request, parentPath) {
1641
- const path = parentPath ? joinPaths.joinPaths(parentPath, request) : request;
1642
- let file = this.checkExtensions(path);
1643
- if (file) {
1644
- return file;
1645
- }
1646
- file = this.checkIndex(path);
1647
- if (file) {
1648
- return file;
1649
- }
1650
- return false;
1651
- }
1652
- /**
1653
- * Check if the index file exists in the given request path.
1654
- *
1655
- * @param request - The request path to check.
1656
- * @returns The index file path if it exists, otherwise false.
1657
- */
1658
- checkIndex(request) {
1659
- let file = joinPaths.joinPaths(request, "index");
1660
- if (this.#existsSync(file)) {
1661
- return file;
1662
- }
1663
- file = this.checkExtensions(file);
1664
- if (file) {
1665
- return file;
1666
- }
1667
- return false;
1668
- }
1669
- /**
1670
- * Check if the file exists with different extensions.
1671
- *
1672
- * @param request - The request path to check.
1673
- * @param vfs - The file system module to use for checking file existence.
1674
- * @returns The file path if it exists with any of the checked extensions, otherwise false.
1675
- */
1676
- checkExtensions(request) {
1677
- let file = `${request}.ts`;
1678
- if (this.#existsSync(file)) {
1679
- return file;
1680
- }
1681
- file = `${request}.mts`;
1682
- if (this.#existsSync(file)) {
1683
- return file;
1684
- }
1685
- file = `${request}.cts`;
1686
- if (this.#existsSync(file)) {
1687
- return file;
1688
- }
1689
- file = `${request}.tsx`;
1690
- if (this.#existsSync(file)) {
1691
- return file;
1692
- }
1693
- file = `${request}.js`;
1694
- if (this.#existsSync(file)) {
1695
- return file;
1696
- }
1697
- file = `${request}.mjs`;
1698
- if (this.#existsSync(file)) {
1699
- return file;
1700
- }
1701
- file = `${request}.cjs`;
1702
- if (this.#existsSync(file)) {
1703
- return file;
1704
- }
1705
- file = `${request}.jsx`;
1706
- if (this.#existsSync(file)) {
1707
- return file;
1708
- }
1709
- file = `${request}.json`;
1710
- if (this.#existsSync(file)) {
1711
- return file;
1712
- }
1713
- file = `${request}.d.ts`;
1714
- if (this.#existsSync(file)) {
1715
- return file;
1716
- }
1717
- return false;
1718
- }
1719
- };
1720
- function createVfs(context) {
1721
- const vfs = new VirtualFileSystem(context);
1722
- return vfs;
1723
- }
1724
- chunkPK6SKIKE_cjs.__name(createVfs, "createVfs");
1725
-
1726
- // src/internal/contexts/context.ts
1727
- var configCache = /* @__PURE__ */ new WeakMap();
1728
- var parseCache = /* @__PURE__ */ new WeakMap();
1729
- var PowerlinesContext = class _PowerlinesContext {
1730
- static {
1731
- chunkPK6SKIKE_cjs.__name(this, "PowerlinesContext");
1732
- }
1733
- #workspaceConfig;
1734
- #checksum = null;
1735
- #buildId = uuid.uuid();
1736
- #releaseId = uuid.uuid();
1737
- #timestamp = Date.now();
1738
- #envPaths;
1739
- #fs;
1740
- #tsconfig;
1741
- #getConfigProps(config = {}) {
1742
- return {
1743
- variant: config.build?.variant,
1744
- projectType: config.type,
1745
- projectRoot: config.root,
1746
- name: config.name,
1747
- title: config.title,
1748
- description: config.description,
1749
- sourceRoot: config.sourceRoot,
1750
- configFile: config.configFile,
1751
- customLogger: config.customLogger,
1752
- logLevel: config.logLevel,
1753
- tsconfig: config.tsconfig,
1754
- tsconfigRaw: config.tsconfigRaw,
1755
- skipCache: config.skipCache,
1756
- skipInstalls: config.skipInstalls,
1757
- entry: config.entry,
1758
- output: config.output,
1759
- plugins: config.plugins,
1760
- mode: config.mode,
1761
- lint: config.lint,
1762
- transform: config.transform,
1763
- build: config.build,
1764
- override: config.override,
1765
- framework: config.framework
1766
- };
1767
- }
1768
- /**
1769
- * Create a new Storm context from the workspace root and user config.
1770
- *
1771
- * @param workspaceRoot - The root directory of the workspace.
1772
- * @param config - The user configuration options.
1773
- * @returns A promise that resolves to the new context.
1774
- */
1775
- static async from(workspaceRoot, config) {
1776
- const context = new _PowerlinesContext(await loadWorkspaceConfig(workspaceRoot, config.root));
1777
- await context.withUserConfig(config);
1778
- context.powerlinesPath = await resolve.resolvePackage("powerlines");
1779
- if (!context.powerlinesPath) {
1780
- throw new Error("Could not resolve `powerlines` package location.");
1781
- }
1782
- return context;
1783
- }
1784
- /**
1785
- * An object containing the dependencies that should be installed for the project
1786
- */
1787
- dependencies = {};
1788
- /**
1789
- * An object containing the development dependencies that should be installed for the project
1790
- */
1791
- devDependencies = {};
1792
- /**
1793
- * The persisted meta information about the current build
1794
- */
1795
- persistedMeta = void 0;
1796
- /**
1797
- * The path to the Powerlines package
1798
- */
1799
- powerlinesPath;
1800
- /**
1801
- * The parsed `package.json` file for the project
1802
- */
1803
- packageJson;
1804
- /**
1805
- * The parsed `project.json` file for the project
1806
- */
1807
- projectJson = void 0;
1808
- /**
1809
- * The module resolver for the project
1810
- */
1811
- resolver;
1812
- /**
1813
- * The resolved entry type definitions for the project
1814
- */
1815
- get entry() {
1816
- return resolveEntriesSync(this, toArray.toArray(this.config.entry));
1817
- }
1818
- /**
1819
- * The TypeScript configuration parsed from the tsconfig file
1820
- */
1821
- get tsconfig() {
1822
- if (!this.#tsconfig) {
1823
- this.#tsconfig = {
1824
- tsconfigFilePath: this.config.tsconfig
1825
- };
1826
- }
1827
- return this.#tsconfig;
1828
- }
1829
- /**
1830
- * Sets the TypeScript configuration parsed from the tsconfig file
1831
- */
1832
- set tsconfig(value) {
1833
- this.#tsconfig = value;
1834
- }
1835
- /**
1836
- * The virtual file system interface for the project
1837
- */
1838
- get fs() {
1839
- if (!this.#fs) {
1840
- this.#fs = createVfs(this);
1841
- }
1842
- return this.#fs;
1843
- }
1844
- /**
1845
- * Get the checksum of the project's current state
1846
- */
1847
- get checksum() {
1848
- return this.#checksum;
1849
- }
1850
- /**
1851
- * The meta information about the current build
1852
- */
1853
- get meta() {
1854
- return {
1855
- buildId: this.#buildId,
1856
- releaseId: this.#releaseId,
1857
- checksum: this.#checksum,
1858
- timestamp: this.#timestamp,
1859
- projectRootHash: murmurhash.murmurhash({
1860
- workspaceRoot: this.workspaceConfig?.workspaceRoot,
1861
- projectRoot: this.config?.projectRoot
1862
- }, {
1863
- maxLength: PROJECT_ROOT_HASH_LENGTH
1864
- }),
1865
- configHash: murmurhash.murmurhash(this.config, {
1866
- maxLength: CACHE_HASH_LENGTH
1867
- }),
1868
- builtinIdMap: {},
1869
- virtualFiles: {}
1870
- };
1871
- }
1872
- /**
1873
- * The resolved configuration options
1874
- */
1875
- get config() {
1876
- return this.resolvedConfig ?? {};
1877
- }
1878
- /**
1879
- * The logger function
1880
- */
1881
- get log() {
1882
- if (!this.logFn) {
1883
- this.logFn = this.createLog();
1884
- }
1885
- return this.logFn;
1886
- }
1887
- /**
1888
- * The workspace configuration
1889
- */
1890
- get workspaceConfig() {
1891
- return this.#workspaceConfig;
1892
- }
1893
- /**
1894
- * The environment paths for the project
1895
- */
1896
- get envPaths() {
1897
- if (!this.#envPaths) {
1898
- this.#envPaths = getEnvPaths.getEnvPaths({
1899
- orgId: "storm-software",
1900
- appId: "powerlines",
1901
- workspaceRoot: this.workspaceConfig.workspaceRoot
1902
- });
1903
- }
1904
- return this.#envPaths;
1905
- }
1906
- /**
1907
- * Get the path to the artifacts directory for the project
1908
- */
1909
- get artifactsPath() {
1910
- return join.joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.artifactsFolder);
1911
- }
1912
- /**
1913
- * Get the path to the builtin modules used by the project
1914
- */
1915
- get builtinsPath() {
1916
- return join.joinPaths(this.artifactsPath, "builtins");
1917
- }
1918
- /**
1919
- * Get the path to the entry directory for the project
1920
- */
1921
- get entryPath() {
1922
- return join.joinPaths(this.artifactsPath, "entry");
1923
- }
1924
- /**
1925
- * Get the path to the data directory for the project
1926
- */
1927
- get dataPath() {
1928
- return join.joinPaths(this.envPaths.data, "projects", getPrefixedProjectRootHash(this.config.name, this.meta.projectRootHash));
1929
- }
1930
- /**
1931
- * Get the path to the cache directory for the project
1932
- */
1933
- get cachePath() {
1934
- return join.joinPaths(this.envPaths.cache, "projects", murmurhash.murmurhash({
1935
- checksum: this.#checksum,
1936
- config: this.meta.configHash
1937
- }, {
1938
- maxLength: CACHE_HASH_LENGTH
1939
- }));
1940
- }
1941
- /**
1942
- * Get the path to the generated declaration file for the project
1943
- */
1944
- get dtsPath() {
1945
- return this.config.output.dts ? append.appendPath(this.config.output.dts, this.workspaceConfig.workspaceRoot) : join.joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, "storm.d.ts");
1946
- }
1947
- /**
1948
- * Get the project root relative to the workspace root
1949
- */
1950
- get relativeToWorkspaceRoot() {
1951
- return getWorkspaceRoot.relativeToWorkspaceRoot(this.config.projectRoot);
1952
- }
1953
- /**
1954
- * The builtin module id that exist in the Powerlines virtual file system
1955
- */
1956
- get builtins() {
1957
- return Object.values(this.fs.meta).filter((meta) => meta && meta.variant === "builtin").map((meta) => meta?.id).filter(Boolean);
1958
- }
1959
- /**
1960
- * Get the project root relative to the workspace root
1961
- */
1962
- async getBuiltins() {
1963
- return Promise.all(Object.entries(this.fs.meta).filter(([, meta]) => meta && meta.variant === "builtin").map(async ([path, meta]) => {
1964
- const code = await this.fs.readFile(path);
1965
- return {
1966
- ...meta,
1967
- path,
1968
- code
1969
- };
1970
- }));
1971
- }
1972
- /**
1973
- * Resolves a entry virtual file and writes it to the VFS if it does not already exist
1974
- *
1975
- * @param code - The source code of the entry file
1976
- * @param path - A path to write the entry file to
1977
- * @param options - Optional write file options
1978
- */
1979
- async writeEntry(code, path, options = {}) {
1980
- return this.fs.writeFile(isType.isAbsolute(path) ? path : append.appendPath(path, this.entryPath), {
1981
- code,
1982
- variant: "entry"
1983
- }, defu5__default.default(options, {
1984
- mode: this.config.output.mode
1985
- }));
1986
- }
1987
- /**
1988
- * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
1989
- *
1990
- * @param code - The source code of the builtin file
1991
- * @param id - The unique identifier of the builtin file
1992
- * @param path - An optional path to write the builtin file to
1993
- * @param options - Optional write file options
1994
- */
1995
- async writeBuiltin(code, id, path, options = {}) {
1996
- return this.fs.writeFile(path ? isType.isAbsolute(path) ? path : join.joinPaths(this.builtinsPath, path) : append.appendPath(id, this.builtinsPath), {
1997
- id,
1998
- code,
1999
- variant: "builtin"
2000
- }, defu5__default.default(options, {
2001
- mode: this.config.output.mode
2002
- }));
2003
- }
2004
- /**
2005
- * Parses the source code and returns a {@link ParseResult} object.
2006
- *
2007
- * @param code - The source code to parse.
2008
- * @param id - The unique identifier for the source file.
2009
- * @param options - Optional parser options.
2010
- * @returns The parsed {@link ParseResult} object.
2011
- */
2012
- async parse(code, id, options = {}) {
2013
- if (parseCache.has({
2014
- code,
2015
- options
2016
- })) {
2017
- return parseCache.get({
2018
- code,
2019
- options
2020
- });
2021
- }
2022
- const result = await oxcParser.parseAsync(id, code, defu5__default.default(options ?? {}, {
2023
- lang: filePathFns.hasFileExtension(id) ? void 0 : "ts",
2024
- astType: filePathFns.hasFileExtension(id) ? void 0 : "ts",
2025
- sourceType: "module",
2026
- showSemanticErrors: false
2027
- }));
2028
- if (result.errors && result.errors.length > 0) {
2029
- throw new Error(`Powerlines parsing errors in file: ${id}
2030
- ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.codeframe ? ` (${error.codeframe})` : ""}${error.helpMessage ? `
2031
- Help: ${error.helpMessage}` : ""}`).join("\n")}`);
2032
- }
2033
- parseCache.set({
2034
- code,
2035
- options
2036
- }, result);
2037
- return result;
2038
- }
2039
- /**
2040
- * Update the context using a new user configuration options
2041
- *
2042
- * @param userConfig - The new user configuration options.
2043
- */
2044
- async withUserConfig(userConfig, options = {
2045
- isHighPriority: true
2046
- }) {
2047
- this.mergeUserConfig(userConfig);
2048
- await this.init(this.config.userConfig, options);
2049
- }
2050
- /**
2051
- * Update the context using a new inline configuration options
2052
- *
2053
- * @param inlineConfig - The new inline configuration options.
2054
- */
2055
- async withInlineConfig(inlineConfig, options = {
2056
- isHighPriority: true
2057
- }) {
2058
- this.config.inlineConfig = inlineConfig;
2059
- if (inlineConfig.command === "new") {
2060
- const workspacePackageJsonPath = join.joinPaths(this.workspaceConfig.workspaceRoot, "package.json");
2061
- if (!exists.existsSync(workspacePackageJsonPath)) {
2062
- throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
2063
- }
2064
- this.packageJson = await json.readJsonFile(workspacePackageJsonPath);
2065
- this.workspaceConfig.repository ??= isSetString.isSetString(this.packageJson?.repository) ? this.packageJson.repository : this.packageJson?.repository?.url;
2066
- }
2067
- await this.init(this.config.inlineConfig, options);
2068
- }
2069
- /**
2070
- * Create a new logger instance
2071
- *
2072
- * @param name - The name to use for the logger instance
2073
- * @returns A logger function
2074
- */
2075
- createLog(name = null) {
2076
- return createLog(name, {
2077
- ...this.config,
2078
- logLevel: isNull.isNull(this.config.logLevel) ? "silent" : this.config.logLevel
2079
- });
2080
- }
2081
- /**
2082
- * Extend the current logger instance with a new name
2083
- *
2084
- * @param name - The name to use for the extended logger instance
2085
- * @returns A logger function
2086
- */
2087
- extendLog(name) {
2088
- return extendLog(this.log, name);
2089
- }
2090
- /**
2091
- * Creates a new StormContext instance.
2092
- *
2093
- * @param workspaceConfig - The workspace configuration.
2094
- */
2095
- constructor(workspaceConfig) {
2096
- this.#workspaceConfig = workspaceConfig;
2097
- this.#envPaths = getEnvPaths.getEnvPaths({
2098
- orgId: "storm-software",
2099
- appId: "powerlines",
2100
- workspaceRoot: workspaceConfig.workspaceRoot
2101
- });
2102
- }
2103
- /**
2104
- * The resolved configuration for this context
2105
- */
2106
- resolvedConfig = {};
2107
- /**
2108
- * A logger function specific to this context
2109
- */
2110
- logFn;
2111
- /**
2112
- * Initialize the context with the provided configuration options
2113
- *
2114
- * @param config - The partial user configuration to use for initialization.
2115
- */
2116
- async init(config = {}, options = {
2117
- isHighPriority: true
2118
- }) {
2119
- const cacheKey = {
2120
- projectRoot: config.root ?? this.config.projectRoot ?? this.config.userConfig?.root ?? this.config.inlineConfig?.root,
2121
- mode: (config.mode ?? this.config.mode) || this.workspaceConfig.mode,
2122
- skipCache: config.skipCache ?? this.config.skipCache ?? false,
2123
- configFile: config.configFile ?? this.config.configFile,
2124
- command: this.config.inlineConfig?.command
2125
- };
2126
- if (configCache.has(cacheKey)) {
2127
- const result = configCache.get(cacheKey);
2128
- this.projectJson = result.projectJson;
2129
- this.packageJson = result.packageJson;
2130
- this.#checksum = result.checksum;
2131
- this.resolver = result.resolver;
2132
- this.mergeUserConfig(result.userConfig.config, this.config.userConfig);
2133
- } else {
2134
- const projectJsonPath = join.joinPaths(cacheKey.projectRoot, "project.json");
2135
- if (exists.existsSync(projectJsonPath)) {
2136
- this.projectJson = await json.readJsonFile(projectJsonPath);
2137
- }
2138
- const packageJsonPath = join.joinPaths(cacheKey.projectRoot, "package.json");
2139
- if (exists.existsSync(packageJsonPath)) {
2140
- this.packageJson = await json.readJsonFile(packageJsonPath);
2141
- }
2142
- this.#checksum = await getChecksum(cacheKey.projectRoot);
2143
- this.resolver = createResolver({
2144
- workspaceRoot: this.workspaceConfig.workspaceRoot,
2145
- projectRoot: cacheKey.projectRoot,
2146
- cacheDir: this.cachePath,
2147
- mode: cacheKey.mode,
2148
- skipCache: cacheKey.skipCache
2149
- });
2150
- const userConfig = await loadUserConfigFile(cacheKey.projectRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile);
2151
- this.mergeUserConfig(userConfig.config);
2152
- configCache.set(cacheKey, {
2153
- projectJson: this.projectJson,
2154
- packageJson: this.packageJson,
2155
- checksum: this.#checksum,
2156
- resolver: this.resolver,
2157
- userConfig
2158
- });
2159
- }
2160
- if (isSetObject.isSetObject(config)) {
2161
- this.resolvedConfig = defu5__default.default({
2162
- inlineConfig: this.config.inlineConfig,
2163
- userConfig: this.config.userConfig
2164
- }, options.isHighPriority ? this.#getConfigProps(config) : {}, {
2165
- command: this.config.inlineConfig?.command,
2166
- ...this.#getConfigProps(this.config.inlineConfig)
2167
- }, this.#getConfigProps(this.config.userConfig), {
2168
- mode: this.workspaceConfig?.mode,
2169
- logLevel: this.workspaceConfig?.logLevel,
2170
- skipCache: this.workspaceConfig?.skipCache
2171
- }, {
2172
- name: this.projectJson?.name || this.packageJson?.name,
2173
- version: this.packageJson?.version,
2174
- description: this.packageJson?.description,
2175
- tsconfig: append.appendPath("tsconfig.json", cacheKey.projectRoot),
2176
- sourceRoot: this.projectJson?.sourceRoot || append.appendPath("src", cacheKey.projectRoot),
2177
- output: {
2178
- outputPath: join.joinPaths("dist", cacheKey.projectRoot),
2179
- mode: "virtual",
2180
- dts: join.joinPaths(cacheKey.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
2181
- builtinPrefix: config.framework ?? "powerlines",
2182
- artifactsFolder: join.joinPaths(cacheKey.projectRoot, `.${config.framework ?? "powerlines"}`),
2183
- assets: [
2184
- {
2185
- glob: "LICENSE"
2186
- },
2187
- {
2188
- input: cacheKey.projectRoot,
2189
- glob: "*.md"
2190
- },
2191
- {
2192
- input: cacheKey.projectRoot,
2193
- glob: "package.json"
2194
- }
2195
- ]
2196
- }
2197
- }, options.isHighPriority ? {} : this.#getConfigProps(config), {
2198
- inlineConfig: {},
2199
- userConfig: {},
2200
- framework: "powerlines",
2201
- platform: "neutral",
2202
- mode: "production",
2203
- projectType: "application",
2204
- logLevel: "info",
2205
- preview: false,
2206
- environments: {},
2207
- transform: {
2208
- babel: {
2209
- plugins: [],
2210
- presets: []
2211
- }
2212
- },
2213
- lint: {
2214
- eslint: {}
2215
- },
2216
- build: {
2217
- target: "esnext"
2218
- },
2219
- override: {}
2220
- });
2221
- }
2222
- this.config.entry = getUniqueEntries(this.config.entry);
2223
- if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) {
2224
- this.config.name = this.config.name.split("/").filter(Boolean)[1];
2225
- }
2226
- this.config.title ??= titleCase.titleCase(this.config.name);
2227
- if (this.config.build.external) {
2228
- this.config.build.external = getUnique.getUnique(this.config.build.external);
2229
- }
2230
- if (this.config.build.noExternal) {
2231
- this.config.build.noExternal = getUnique.getUnique(this.config.build.noExternal);
2232
- }
2233
- this.config.output.format = getUnique.getUnique(toArray.toArray(this.config.output?.format ?? (this.config.projectType === "library" ? [
2234
- "cjs",
2235
- "esm"
2236
- ] : [
2237
- "esm"
2238
- ])));
2239
- this.config.output.outputPath ??= join.joinPaths("dist", this.config.projectRoot || ".");
2240
- this.config.output.assets = getUnique.getUnique(this.config.output.assets.map((asset) => {
2241
- return {
2242
- glob: isSetObject.isSetObject(asset) ? asset.glob : asset,
2243
- input: isString.isString(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.workspaceConfig.workspaceRoot : append.appendPath(asset.input, this.workspaceConfig.workspaceRoot),
2244
- output: append.appendPath(isSetObject.isSetObject(asset) && asset.output ? join.joinPaths(this.config.output.outputPath, replace.replacePath(asset.output, this.config.output.outputPath)) : this.config.output.outputPath, this.workspaceConfig.workspaceRoot),
2245
- ignore: isSetObject.isSetObject(asset) && asset.ignore ? toArray.toArray(asset.ignore) : void 0
2246
- };
2247
- }));
2248
- this.config.plugins = (this.config.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
2249
- if (isPlugin(plugin) && checkDedupe(plugin, ret.filter((p) => isPlugin(p)))) {
2250
- return ret;
2251
- }
2252
- ret.push(plugin);
2253
- return ret;
2254
- }, []);
2255
- }
2256
- mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
2257
- this.config.userConfig = defu5__default.default({
2258
- entry: Array.isArray(from.entry) && from.entry.length > 0 ? from.entry : Array.isArray(into?.entry) && into.entry.length > 0 ? into.entry : []
2259
- }, omit.omit(from ?? {}, [
2260
- "entry"
2261
- ]), omit.omit(into ?? {}, [
2262
- "entry"
2263
- ]));
2264
- if (this.config.userConfig.output?.format) {
2265
- this.config.userConfig.output.format = getUnique.getUnique(toArray.toArray(this.config.userConfig.output?.format));
2266
- }
2267
- this.config.userConfig.plugins = (this.config.userConfig.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
2268
- if (isPlugin(plugin) && checkDedupe(plugin, ret.filter((p) => isPlugin(p)))) {
2269
- return ret;
2270
- }
2271
- ret.push(plugin);
2272
- return ret;
2273
- }, []);
2274
- }
2275
- };
2276
- async function callHook(context, hook, options, ...args) {
2277
- const handlers = context.selectHooks(hook, options);
2278
- if (handlers.length > 0) {
2279
- context.log(types.LogLevelLabel.DEBUG, ` \u{1F9E9} Calling plugin hook: ${chalk5__default.default.bold.cyanBright(`${hook}${options?.order ? ` (${options.order})` : ""}`)}`);
2280
- let results = [];
2281
- if (options?.sequential === false) {
2282
- results = await Promise.all(handlers.map(async (handler) => {
2283
- if (!isFunction.isFunction(handler)) {
2284
- throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
2285
- }
2286
- return Promise.resolve(handler.apply(null, ...args));
2287
- }));
2288
- } else {
2289
- for (const handler of handlers) {
2290
- if (!isFunction.isFunction(handler)) {
2291
- throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
2292
- }
2293
- results.push(await Promise.resolve(handler.apply(null, ...args)));
2294
- if (options?.result === "first" && isSet.isSet(results[results.length - 1])) {
2295
- break;
2296
- }
2297
- }
2298
- }
2299
- const definedResults = results.filter((result) => isSet.isSet(result));
2300
- if (definedResults.length > 0) {
2301
- let mergedResult = void 0;
2302
- for (const result of definedResults) {
2303
- mergedResult = defu5.defu(result, mergedResult ?? {});
2304
- }
2305
- return mergedResult;
2306
- }
2307
- }
2308
- return void 0;
2309
- }
2310
- chunkPK6SKIKE_cjs.__name(callHook, "callHook");
2311
-
2312
- // src/internal/contexts/plugin-context.ts
2313
- function createPluginContext(plugin, environment) {
2314
- const normalizeMessage = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((message) => {
2315
- return isString.isString(message) ? message : message.message;
2316
- }, "normalizeMessage");
2317
- const log = environment.extendLog(plugin.name);
2318
- const callHookFn = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name(async (hook, options, ...args) => {
2319
- return callHook(environment, hook, {
2320
- sequential: true,
2321
- ...options
2322
- }, ...args);
2323
- }, "callHookFn");
2324
- return new Proxy({}, {
2325
- get(_, prop) {
2326
- if (prop === "$$internal") {
2327
- return {
2328
- environment,
2329
- callHook: callHookFn
2330
- };
2331
- }
2332
- if (prop === "log" || prop === "logger") {
2333
- return log;
2334
- }
2335
- if (prop === "error") {
2336
- return (message) => {
2337
- log(types.LogLevelLabel.ERROR, normalizeMessage(message));
2338
- };
2339
- }
2340
- if (prop === "warn") {
2341
- return (message) => {
2342
- log(types.LogLevelLabel.WARN, normalizeMessage(message));
2343
- };
2344
- }
2345
- return environment[prop];
2346
- },
2347
- set(_, prop, value) {
2348
- if ([
2349
- "$$internal",
2350
- "environment",
2351
- "config",
2352
- "log",
2353
- "logger",
2354
- "error",
2355
- "warn",
2356
- "plugins",
2357
- "hooks",
2358
- "addPlugin",
2359
- "selectHooks"
2360
- ].includes(prop)) {
2361
- log(types.LogLevelLabel.WARN, `Cannot set read-only property "${String(prop)}"`);
2362
- return false;
2363
- }
2364
- environment[prop] = value;
2365
- return true;
2366
- }
2367
- });
2368
- }
2369
- chunkPK6SKIKE_cjs.__name(createPluginContext, "createPluginContext");
2370
-
2371
- // src/internal/contexts/environment-context.ts
2372
- var PowerlinesEnvironmentContext = class _PowerlinesEnvironmentContext extends PowerlinesContext {
2373
- static {
2374
- chunkPK6SKIKE_cjs.__name(this, "PowerlinesEnvironmentContext");
2375
- }
2376
- #hooks = {};
2377
- /**
2378
- * Create a new Storm context from the workspace root and user config.
2379
- *
2380
- * @param workspaceConfig - The root directory of the workspace.
2381
- * @param config - The user configuration options.
2382
- * @returns A promise that resolves to the new context.
2383
- */
2384
- static async fromConfig(workspaceConfig, config) {
2385
- const context = new _PowerlinesEnvironmentContext(config, workspaceConfig);
2386
- await context.init();
2387
- context.powerlinesPath = await resolve.resolvePackage("powerlines");
2388
- if (!context.powerlinesPath) {
2389
- throw new Error("Could not resolve `powerlines` package location.");
2390
- }
2391
- return context;
2392
- }
2393
- environment;
2394
- plugins = [];
2395
- /**
2396
- * The resolved configuration options
2397
- */
2398
- get config() {
2399
- return super.config;
2400
- }
2401
- get hooks() {
2402
- return this.#hooks;
2403
- }
2404
- async addPlugin(plugin) {
2405
- let resolvedPlugin = plugin;
2406
- if (plugin.applyToEnvironment) {
2407
- const result = await Promise.resolve(plugin.applyToEnvironment(this.environment));
2408
- if (!result || isObject.isObject(result) && Object.keys(result).length === 0) {
2409
- return;
2410
- }
2411
- resolvedPlugin = isPlugin(result) ? result : plugin;
2412
- }
2413
- const context = createPluginContext(resolvedPlugin, this);
2414
- this.plugins.push({
2415
- plugin: resolvedPlugin,
2416
- context
2417
- });
2418
- this.#hooks = Object.keys(resolvedPlugin).filter((key) => !chunkAPVMN2H7_cjs.PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => {
2419
- const hook = key;
2420
- const pluginHook = resolvedPlugin[hook];
2421
- if (!isPluginHook(pluginHook)) {
2422
- return ret;
2423
- }
2424
- if (!isHookExternal(hook)) {
2425
- ret[hook] ??= {};
2426
- if (resolvedPlugin.enforce) {
2427
- ret[hook][`${resolvedPlugin.enforce}Enforced`] ??= [];
2428
- addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][`${resolvedPlugin.enforce}Enforced`]);
2429
- return ret;
2430
- }
2431
- if (isFunction.isFunction(pluginHook) || !pluginHook.order) {
2432
- ret[hook].normal ??= [];
2433
- addPluginHook(context, resolvedPlugin, pluginHook, ret[hook].normal);
2434
- return ret;
2435
- }
2436
- ret[hook][`${pluginHook.order}Ordered`] ??= [];
2437
- addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][`${pluginHook.order}Ordered`]);
2438
- } else {
2439
- ret[hook] ??= [];
2440
- ret[hook].push({
2441
- plugin: resolvedPlugin,
2442
- hook: getHookHandler(pluginHook).bind(context)
2443
- });
2444
- }
2445
- return ret;
2446
- }, this.hooks);
2447
- }
2448
- /**
2449
- * Retrieves the hook handlers for a specific hook name
2450
- */
2451
- selectHooks(hook, options) {
2452
- const handlers = [];
2453
- if (this.hooks[hook]) {
2454
- if (!isHookExternal(hook)) {
2455
- const hooks = this.hooks[hook];
2456
- if (options?.order) {
2457
- if (options?.order === "pre") {
2458
- handlers.push(...(hooks.preOrdered ?? []).map((h) => h.handler));
2459
- handlers.push(...(hooks.preEnforced ?? []).map((h) => h.handler));
2460
- } else if (options?.order === "post") {
2461
- handlers.push(...(hooks.postOrdered ?? []).map((h) => h.handler));
2462
- handlers.push(...(hooks.postEnforced ?? []).map((h) => h.handler));
2463
- } else {
2464
- handlers.push(...(hooks.normal ?? []).map((h) => h.handler));
2465
- }
2466
- } else {
2467
- handlers.push(...this.selectHooks(hook, {
2468
- order: "pre"
2469
- }));
2470
- handlers.push(...this.selectHooks(hook, {
2471
- order: "normal"
2472
- }));
2473
- handlers.push(...this.selectHooks(hook, {
2474
- order: "post"
2475
- }));
2476
- }
2477
- } else {
2478
- handlers.push(...this.hooks[hook].map((h) => h.handler));
2479
- }
2480
- }
2481
- return handlers;
2482
- }
2483
- constructor(config, workspaceConfig) {
2484
- super(workspaceConfig);
2485
- this.resolvedConfig = config;
2486
- }
2487
- };
2488
-
2489
- // src/internal/contexts/api-context.ts
2490
- var PowerlinesAPIContext = class _PowerlinesAPIContext extends PowerlinesContext {
2491
- static {
2492
- chunkPK6SKIKE_cjs.__name(this, "PowerlinesAPIContext");
2493
- }
2494
- #environments = {};
2495
- #plugins = [];
2496
- #log;
2497
- /**
2498
- * Create a new Storm context from the workspace root and user config.
2499
- *
2500
- * @param workspaceRoot - The root directory of the workspace.
2501
- * @param config - The user configuration options.
2502
- * @returns A promise that resolves to the new context.
2503
- */
2504
- static async from(workspaceRoot, config) {
2505
- const context = new _PowerlinesAPIContext(await loadWorkspaceConfig(workspaceRoot, config.root));
2506
- await context.withUserConfig(config);
2507
- context.powerlinesPath = await resolve.resolvePackage("powerlines");
2508
- if (!context.powerlinesPath) {
2509
- throw new Error("Could not resolve `powerlines` package location.");
2510
- }
2511
- return context;
2512
- }
2513
- /**
2514
- * A record of all environments by name
2515
- */
2516
- get environments() {
2517
- return this.#environments;
2518
- }
2519
- get log() {
2520
- if (!this.#log) {
2521
- this.#log = this.createLog("engine");
2522
- }
2523
- return this.#log;
2524
- }
2525
- get plugins() {
2526
- return this.#plugins;
2527
- }
2528
- constructor(workspaceConfig) {
2529
- super(workspaceConfig);
2530
- }
2531
- /**
2532
- * Initialize the context with the provided configuration options
2533
- *
2534
- * @param config - The partial user configuration to use for initialization.
2535
- */
2536
- async init(config = {}) {
2537
- await super.init(config);
2538
- await Promise.all(toArray.toArray(this.config.userConfig.environments && Object.keys(this.config.userConfig.environments).length > 0 ? Object.keys(this.config.userConfig.environments).map((name) => createEnvironment(name, this.config.userConfig)) : createDefaultEnvironment(this.config.userConfig)).map(async (env) => {
2539
- this.#environments[env.name] = await this.in(env);
2540
- }));
2541
- }
2542
- /**
2543
- * A function to copy the context and update the fields for a specific environment
2544
- *
2545
- * @param environment - The environment configuration to use.
2546
- * @returns A new context instance with the updated environment.
2547
- */
2548
- async in(environment) {
2549
- let context;
2550
- if (this.environments[environment.name]) {
2551
- context = this.environments[environment.name];
2552
- } else {
2553
- context = await PowerlinesEnvironmentContext.fromConfig(this.workspaceConfig, this.config);
2554
- }
2555
- if (isSetObject.isSetObject(this.config.inlineConfig)) {
2556
- await context.withInlineConfig(this.config.inlineConfig);
2557
- }
2558
- context.environment = environment;
2559
- context.plugins = [];
2560
- for (const plugin of this.plugins) {
2561
- await context.addPlugin(plugin);
2562
- }
2563
- return context;
2564
- }
2565
- async addPlugin(plugin) {
2566
- this.plugins.push(plugin);
2567
- await Promise.all(Object.keys(this.environments).map(async (name) => {
2568
- await this.environments[name].addPlugin(plugin);
2569
- }));
2570
- }
2571
- async getEnvironment(name) {
2572
- let environment;
2573
- if (name) {
2574
- environment = this.environments[name];
2575
- }
2576
- if (Object.keys(this.environments).length === 1) {
2577
- environment = this.environments[Object.keys(this.environments)[0]];
2578
- this.log(types.LogLevelLabel.DEBUG, `Applying the only configured environment: ${chalk5__default.default.bold.cyanBright(environment?.environment.name)}`);
2579
- }
2580
- if (!environment) {
2581
- if (name) {
2582
- throw new Error(`Environment "${name}" not found.`);
2583
- }
2584
- environment = await this.in(createDefaultEnvironment(this.config.userConfig));
2585
- this.log(types.LogLevelLabel.WARN, `No environment specified, and no default environment found. Using a temporary default environment: ${chalk5__default.default.bold.cyanBright(environment?.environment.name)}`);
2586
- }
2587
- return environment;
2588
- }
2589
- async getEnvironmentSafe(name) {
2590
- try {
2591
- return await this.getEnvironment(name);
2592
- } catch {
2593
- return void 0;
2594
- }
2595
- }
2596
- };
2597
- function getBaseFileHeader(context) {
2598
- return `
2599
- // Generated with ${titleCase.titleCase(context.config.framework)}
2600
- // Note: Do not edit this file manually - it will be overwritten automatically
2601
- `;
2602
- }
2603
- chunkPK6SKIKE_cjs.__name(getBaseFileHeader, "getBaseFileHeader");
2604
- function getFileHeader(context, options = {}) {
2605
- const { directive = null, prettierIgnore = false } = options;
2606
- return `/* eslint-disable */
2607
- // biome-ignore lint: disable
2608
- ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `
2609
-
2610
- ${directive}
2611
- ` : "\n"}
2612
- ${getBaseFileHeader(context)}
2613
-
2614
- `;
2615
- }
2616
- chunkPK6SKIKE_cjs.__name(getFileHeader, "getFileHeader");
2617
- function getString(code) {
2618
- if (!code) {
2619
- return "";
2620
- }
2621
- if (isString.isString(code)) {
2622
- return code;
2623
- }
2624
- if (isSetObject.isSetObject(code) && "code" in code) {
2625
- return code.code;
2626
- }
2627
- return code.toString();
2628
- }
2629
- chunkPK6SKIKE_cjs.__name(getString, "getString");
2630
- function getMagicString(code) {
2631
- if (isString.isString(code)) {
2632
- return new MagicString__default.default(code);
2633
- }
2634
- return code;
2635
- }
2636
- chunkPK6SKIKE_cjs.__name(getMagicString, "getMagicString");
2637
- function getSourceFile(code, id) {
2638
- const content = code ?? readFile.readFileIfExistingSync(id);
2639
- return {
2640
- id,
2641
- code: getMagicString(content),
2642
- env: []
2643
- };
2644
- }
2645
- chunkPK6SKIKE_cjs.__name(getSourceFile, "getSourceFile");
2646
- function resolveModulePath(nodePath, state) {
2647
- if (!t__namespace.isStringLiteral(nodePath.node)) {
2648
- return;
2649
- }
2650
- const sourcePath = nodePath.node.value;
2651
- const resolvedPath = state.context?.fs.resolve(sourcePath);
2652
- if (resolvedPath) {
2653
- nodePath.replaceWith(t__namespace.stringLiteral(
2654
- // Remove the file extension if it exists
2655
- resolvedPath.replace(/\.(?:ts|mts|cts)x?$/, "")
2656
- ));
2657
- }
2658
- }
2659
- chunkPK6SKIKE_cjs.__name(resolveModulePath, "resolveModulePath");
2660
- var TRANSFORM_FUNCTIONS = [
2661
- "require",
2662
- "require.resolve",
2663
- "System.import",
2664
- // Jest methods
2665
- "jest.genMockFromModule",
2666
- "jest.mock",
2667
- "jest.unmock",
2668
- "jest.doMock",
2669
- // eslint-disable-next-line @cspell/spellchecker
2670
- "jest.dontMock",
2671
- "jest.setMock",
2672
- "jest.requireActual",
2673
- "jest.requireMock",
2674
- // Older Jest methods
2675
- "require.requireActual",
2676
- "require.requireMock"
2677
- ];
2678
- function matchesPattern(state, calleePath, pattern) {
2679
- const { node } = calleePath;
2680
- if (t__namespace.isMemberExpression(node)) {
2681
- return calleePath.matchesPattern(pattern);
2682
- }
2683
- if (!t__namespace.isIdentifier(node) || pattern.includes(".")) {
2684
- return false;
2685
- }
2686
- const name = pattern.split(".")[0];
2687
- return node.name === name;
2688
- }
2689
- chunkPK6SKIKE_cjs.__name(matchesPattern, "matchesPattern");
2690
- var importVisitors = {
2691
- CallExpression: /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((nodePath, state) => {
2692
- if (state.moduleResolverVisited.has(nodePath)) {
2693
- return;
2694
- }
2695
- const calleePath = nodePath.get("callee");
2696
- if (calleePath && TRANSFORM_FUNCTIONS.some((pattern) => matchesPattern(state, calleePath, pattern)) || t__namespace.isImport(nodePath.node.callee)) {
2697
- state.moduleResolverVisited.add(nodePath);
2698
- resolveModulePath(nodePath.get("arguments.0"), state);
2699
- }
2700
- }, "CallExpression"),
2701
- // eslint-disable-next-line ts/naming-convention
2702
- "ImportDeclaration|ExportDeclaration|ExportAllDeclaration": /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((nodePath, state) => {
2703
- if (!nodePath || !nodePath.get("source") || state.moduleResolverVisited.has(nodePath)) {
2704
- return;
2705
- }
2706
- state.moduleResolverVisited.add(nodePath);
2707
- resolveModulePath(nodePath.get("source"), state);
2708
- }, "ImportDeclaration|ExportDeclaration|ExportAllDeclaration")
2709
- };
2710
- var moduleResolverBabelPlugin = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((context) => {
2711
- return helperPluginUtils.declare(/* @__PURE__ */ chunkPK6SKIKE_cjs.__name(function builder(api) {
2712
- let moduleResolverVisited = /* @__PURE__ */ new Set();
2713
- return {
2714
- name: "powerlines:module-resolver",
2715
- manipulateOptions(opts) {
2716
- opts.filename ??= "unknown";
2717
- },
2718
- pre() {
2719
- moduleResolverVisited = /* @__PURE__ */ new Set();
2720
- },
2721
- visitor: {
2722
- Program: {
2723
- enter(programPath, state) {
2724
- programPath.traverse(importVisitors, {
2725
- ...state,
2726
- context,
2727
- moduleResolverVisited,
2728
- api
2729
- });
2730
- },
2731
- exit(programPath, state) {
2732
- programPath.traverse(importVisitors, {
2733
- ...state,
2734
- context,
2735
- moduleResolverVisited,
2736
- api
2737
- });
2738
- }
2739
- }
2740
- },
2741
- post() {
2742
- moduleResolverVisited.clear();
2743
- }
2744
- };
2745
- }, "builder"));
2746
- }, "moduleResolverBabelPlugin");
2747
-
2748
- // src/internal/helpers/generate-types.ts
2749
- async function generateTypes(context) {
2750
- context.log(types.LogLevelLabel.TRACE, `Preparing the TypeScript definitions for the Powerlines project.`);
2751
- context.log(types.LogLevelLabel.TRACE, "Transforming built-ins runtime modules files.");
2752
- const builtinFiles = await context.getBuiltins();
2753
- const builtinFilePaths = await Promise.all(builtinFiles.map(async (file) => {
2754
- const result = await core.transformAsync(file.code.toString(), {
2755
- highlightCode: true,
2756
- code: true,
2757
- ast: false,
2758
- cloneInputAst: false,
2759
- comments: true,
2760
- sourceType: "module",
2761
- configFile: false,
2762
- babelrc: false,
2763
- envName: context.config.mode,
2764
- caller: {
2765
- name: "powerlines"
2766
- },
2767
- ...context.config.transform.babel,
2768
- filename: file.path,
2769
- plugins: [
2770
- [
2771
- "@babel/plugin-syntax-typescript"
2772
- ],
2773
- [
2774
- moduleResolverBabelPlugin(context)
2775
- ]
2776
- ]
2777
- });
2778
- if (!result?.code) {
2779
- throw new Error(`Powerlines - Generate Types failed to compile ${file.id}`);
2780
- }
2781
- context.log(types.LogLevelLabel.TRACE, `Writing transformed built-in runtime file ${file.id}.`);
2782
- await context.writeBuiltin(result.code, file.id, file.path);
2783
- return file.path;
2784
- }));
2785
- const typescriptPath = await resolve.resolvePackage("typescript");
2786
- if (!typescriptPath) {
2787
- throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
2788
- }
2789
- const files = builtinFilePaths.reduce((ret, fileName) => {
2790
- const formatted = replace.replacePath(fileName, context.workspaceConfig.workspaceRoot);
2791
- if (!ret.includes(formatted)) {
2792
- ret.push(formatted);
2793
- }
2794
- return ret;
2795
- }, [
2796
- joinPaths.joinPaths(typescriptPath, "lib", "lib.esnext.full.d.ts")
2797
- ]);
2798
- context.log(types.LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
2799
- const resolvedTsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu5__default.default({
2800
- compilerOptions: {
2801
- strict: false,
2802
- noEmit: false,
2803
- declaration: true,
2804
- declarationMap: false,
2805
- emitDeclarationOnly: true,
2806
- skipLibCheck: true
2807
- },
2808
- exclude: [
2809
- "node_modules",
2810
- "dist"
2811
- ],
2812
- include: files
2813
- }, context.config.tsconfigRaw ?? {}));
2814
- resolvedTsconfig.options.configFilePath = joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.tsconfig.tsconfigFilePath);
2815
- resolvedTsconfig.options.pathsBasePath = context.workspaceConfig.workspaceRoot;
2816
- resolvedTsconfig.options.suppressOutputPathCheck = true;
2817
- context.log(types.LogLevelLabel.TRACE, "Creating the TypeScript compiler host");
2818
- const program = ts2.createProgram(files, resolvedTsconfig.options, ts2.createCompilerHost(resolvedTsconfig.options));
2819
- context.log(types.LogLevelLabel.TRACE, `Running TypeScript compiler on ${builtinFiles.length} built-in runtime files.`);
2820
- let builtinModules = "";
2821
- const emitResult = program.emit(void 0, (fileName, text, _, __, sourceFiles, _data) => {
2822
- const sourceFile2 = sourceFiles?.[0];
2823
- if (sourceFile2?.fileName && !fileName.endsWith(".map")) {
2824
- if (builtinFiles.some((file) => file.id === sourceFile2.fileName || file.path === sourceFile2.fileName)) {
2825
- builtinModules += `
2826
- declare module "${context.fs.resolve(sourceFile2.fileName)}" {
2827
- ${text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
2828
- }
2829
- `;
2830
- }
2831
- }
2832
- }, void 0, true);
2833
- const diagnostics = ts2.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
2834
- const diagnosticMessages = [];
2835
- diagnostics.forEach((diagnostic) => {
2836
- if (diagnostic.file) {
2837
- const { line, character } = ts2.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
2838
- const message = ts2.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
2839
- diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
2840
- } else {
2841
- const message = ts2.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
2842
- diagnosticMessages.push(message);
2843
- }
2844
- });
2845
- const diagnosticMessage = diagnosticMessages.join("\n");
2846
- if (diagnosticMessage) {
2847
- throw new Error(`TypeScript compilation failed:
2848
-
2849
- ${diagnosticMessage.length > 5e3 ? `${diagnosticMessage.slice(0, 5e3)}...` : diagnosticMessage}`);
2850
- }
2851
- context.log(types.LogLevelLabel.TRACE, `Generating TypeScript declaration file in ${context.config.output.dts}.`);
2852
- const sourceFile = getSourceFile(String(context.config.output.dts), `/// <reference types="powerlines/shared" />${context.config.build.platform !== "neutral" ? `
2853
- /// <reference types="powerlines/${context.config.build.platform}" />` : ""}
2854
-
2855
- ${getFileHeader(context, {
2856
- directive: null,
2857
- prettierIgnore: false
2858
- })}
2859
-
2860
- ${builtinModules}`.replace(
2861
- // eslint-disable-next-line regexp/no-super-linear-backtracking
2862
- /import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g,
2863
- ""
2864
- ).replaceAll("#private;", "").replace(/__Ω/g, ""));
2865
- await context.fs.writeFile(sourceFile.id, getString(sourceFile.code), {
2866
- mode: "fs"
2867
- });
2868
- }
2869
- chunkPK6SKIKE_cjs.__name(generateTypes, "generateTypes");
2870
- async function installPackage(context, packageName, dev = false) {
2871
- if (!await packageFns.isPackageListed(_package.getPackageName(packageName), {
2872
- cwd: context.config.projectRoot
2873
- })) {
2874
- if (context.config.skipInstalls !== true && !process.env.POWERLINES_LOCAL) {
2875
- context.log(types.LogLevelLabel.WARN, `The package "${packageName}" is not installed. It will be installed automatically.`);
2876
- const result = await install.install(packageName, {
2877
- cwd: context.config.projectRoot,
2878
- dev
2879
- });
2880
- if (isNumber.isNumber(result.exitCode) && result.exitCode > 0) {
2881
- context.log(types.LogLevelLabel.ERROR, result.stderr);
2882
- throw new Error(`An error occurred while installing the package "${packageName}"`);
2883
- }
2884
- } else {
2885
- 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.`);
2886
- }
2887
- } else if (_package.hasPackageVersion(packageName) && !process.env.POWERLINES_SKIP_VERSION_CHECK) {
2888
- const isMatching = await packageFns.doesPackageMatch(_package.getPackageName(packageName), _package.getPackageVersion(packageName), context.config.projectRoot);
2889
- if (!isMatching) {
2890
- const packageListing = await packageFns.getPackageListing(_package.getPackageName(packageName), {
2891
- cwd: context.config.projectRoot
2892
- });
2893
- if (!packageListing?.version.startsWith("catalog:") && !packageListing?.version.startsWith("workspace:")) {
2894
- 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.`);
2895
- }
2896
- }
2897
- }
2898
- }
2899
- chunkPK6SKIKE_cjs.__name(installPackage, "installPackage");
2900
-
2901
- // src/internal/helpers/install-dependencies.ts
2902
- async function installDependencies(context) {
2903
- context.log(types.LogLevelLabel.TRACE, `Checking and installing missing project dependencies.`);
2904
- context.dependencies ??= {};
2905
- context.log(types.LogLevelLabel.TRACE, `The following packages are required:
2906
- Dependencies:
2907
- ${Object.entries(context.dependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}
2908
-
2909
- DevDependencies:
2910
- ${Object.entries(context.devDependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}`);
2911
- await Promise.all([
2912
- Promise.all(Object.entries(context.dependencies).map(async ([name, version]) => installPackage(context, `${_package.getPackageName(name)}@${String(version)}`, false))),
2913
- Promise.all(Object.entries(context.devDependencies).map(async ([name, version]) => installPackage(context, `${_package.getPackageName(name)}@${String(version)}`, true)))
2914
- ]);
2915
- }
2916
- chunkPK6SKIKE_cjs.__name(installDependencies, "installDependencies");
2917
- async function resolveTsconfigChanges(context) {
2918
- const tsconfig$1 = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw);
2919
- const tsconfigFilePath = getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
2920
- const tsconfigJson = await json.readJsonFile(tsconfigFilePath);
2921
- tsconfigJson.compilerOptions ??= {};
2922
- const extendedTsconfig = await tsconfig.loadTsConfig(tsconfigFilePath);
2923
- extendedTsconfig.compilerOptions ??= {};
2924
- if (tsconfigJson.reflection !== true) {
2925
- tsconfigJson.reflection = true;
2926
- }
2927
- if (tsconfig$1.options.experimentalDecorators !== true) {
2928
- tsconfigJson.compilerOptions.experimentalDecorators = true;
2929
- }
2930
- if (tsconfig$1.options.emitDecoratorMetadata !== true) {
2931
- tsconfigJson.compilerOptions.emitDecoratorMetadata = true;
2932
- }
2933
- if (context.config.output.dts) {
2934
- 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");
2935
- const dtsRelativePath = joinPaths.joinPaths(filePathFns.relativePath(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot), filePathFns.findFilePath(dtsFilePath)), filePathFns.findFileName(dtsFilePath));
2936
- if (!tsconfigJson.include?.some((filePattern) => isIncludeMatchFound(filePattern, [
2937
- dtsFilePath,
2938
- dtsRelativePath,
2939
- "storm.d.ts"
2940
- ]))) {
2941
- tsconfigJson.include ??= [];
2942
- tsconfigJson.include.push(dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath);
2943
- }
2944
- }
2945
- if (!tsconfig$1.options.lib?.some((lib) => [
2946
- "lib.esnext.d.ts",
2947
- "lib.es2021.d.ts",
2948
- "lib.es2022.d.ts",
2949
- "lib.es2023.d.ts"
2950
- ].includes(lib.toLowerCase()))) {
2951
- tsconfigJson.compilerOptions.lib ??= [];
2952
- tsconfigJson.compilerOptions.lib.push("esnext");
2953
- }
2954
- if (tsconfig$1.options.module !== ts2__default.default.ModuleKind.ESNext) {
2955
- tsconfigJson.compilerOptions.module = "ESNext";
2956
- }
2957
- if (!tsconfig$1.options.target || ![
2958
- ts2__default.default.ScriptTarget.ESNext,
2959
- ts2__default.default.ScriptTarget.ES2024,
2960
- ts2__default.default.ScriptTarget.ES2023,
2961
- ts2__default.default.ScriptTarget.ES2022,
2962
- ts2__default.default.ScriptTarget.ES2021
2963
- ].includes(tsconfig$1.options.target)) {
2964
- tsconfigJson.compilerOptions.target = "ESNext";
2965
- }
2966
- if (tsconfig$1.options.moduleResolution !== ts2__default.default.ModuleResolutionKind.Bundler) {
2967
- tsconfigJson.compilerOptions.moduleResolution = "Bundler";
2968
- }
2969
- if (tsconfig$1.options.moduleDetection !== ts2__default.default.ModuleDetectionKind.Force) {
2970
- tsconfigJson.compilerOptions.moduleDetection = "force";
2971
- }
2972
- if (tsconfig$1.options.allowSyntheticDefaultImports !== true) {
2973
- tsconfigJson.compilerOptions.allowSyntheticDefaultImports = true;
2974
- }
2975
- if (tsconfig$1.options.noImplicitOverride !== true) {
2976
- tsconfigJson.compilerOptions.noImplicitOverride = true;
2977
- }
2978
- if (tsconfig$1.options.noUncheckedIndexedAccess !== true) {
2979
- tsconfigJson.compilerOptions.noUncheckedIndexedAccess = true;
2980
- }
2981
- if (tsconfig$1.options.skipLibCheck !== true) {
2982
- tsconfigJson.compilerOptions.skipLibCheck = true;
2983
- }
2984
- if (tsconfig$1.options.resolveJsonModule !== true) {
2985
- tsconfigJson.compilerOptions.resolveJsonModule = true;
2986
- }
2987
- if (tsconfig$1.options.isolatedModules !== true) {
2988
- tsconfigJson.compilerOptions.isolatedModules = true;
2989
- }
2990
- if (tsconfig$1.options.verbatimModuleSyntax !== false) {
2991
- tsconfigJson.compilerOptions.verbatimModuleSyntax = false;
2992
- }
2993
- if (tsconfig$1.options.allowJs !== true) {
2994
- tsconfigJson.compilerOptions.allowJs = true;
2995
- }
2996
- if (tsconfig$1.options.esModuleInterop !== true) {
2997
- tsconfigJson.compilerOptions.esModuleInterop = true;
2998
- }
2999
- if (tsconfig$1.options.declaration !== true) {
3000
- tsconfigJson.compilerOptions.declaration = true;
3001
- }
3002
- if (context.environment.consumer === "client") {
3003
- if (tsconfig$1.options.jsx !== ts2__default.default.JsxEmit.ReactJSX) {
3004
- tsconfigJson.compilerOptions.jsx = "react-jsx";
3005
- }
3006
- if (!tsconfig$1.options.lib?.some((lib) => lib.toLowerCase() !== "dom")) {
3007
- tsconfigJson.compilerOptions.lib ??= [];
3008
- tsconfigJson.compilerOptions.lib.push("dom");
3009
- }
3010
- if (!tsconfig$1.options.lib?.some((lib) => lib.toLowerCase() !== "dom.iterable")) {
3011
- tsconfigJson.compilerOptions.lib ??= [];
3012
- tsconfigJson.compilerOptions.lib.push("dom.iterable");
3013
- }
3014
- } else if (context.config.build.platform === "node") {
3015
- if (!tsconfig$1.options.types?.some((type) => type.toLowerCase() === "node" || type.toLowerCase() === "@types/node")) {
3016
- tsconfigJson.compilerOptions.types ??= [];
3017
- tsconfigJson.compilerOptions.types.push("node");
3018
- }
3019
- }
3020
- return tsconfigJson;
3021
- }
3022
- chunkPK6SKIKE_cjs.__name(resolveTsconfigChanges, "resolveTsconfigChanges");
3023
- async function initializeTsconfig(context) {
3024
- context.log(types.LogLevelLabel.TRACE, "Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.");
3025
- if (!packageFns.isPackageExists("typescript")) {
3026
- throw new Error('The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"');
3027
- }
3028
- const tsconfigFilePath = getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
3029
- context.tsconfig.originalTsconfigJson = await json.readJsonFile(tsconfigFilePath);
3030
- context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
3031
- await context.fs.writeFile(tsconfigFilePath, stormJson.StormJSON.stringify(context.tsconfig.tsconfigJson), {
3032
- mode: "fs"
3033
- });
3034
- context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
3035
- }
3036
- chunkPK6SKIKE_cjs.__name(initializeTsconfig, "initializeTsconfig");
3037
- async function resolveTsconfig(context) {
3038
- const updateTsconfigJson = await json.readJsonFile(context.tsconfig.tsconfigFilePath);
3039
- if (updateTsconfigJson?.compilerOptions?.types && Array.isArray(updateTsconfigJson.compilerOptions.types) && !updateTsconfigJson.compilerOptions.types.length) {
3040
- delete updateTsconfigJson.compilerOptions.types;
3041
- }
3042
- const result = superdiff.getObjectDiff(context.tsconfig.originalTsconfigJson, updateTsconfigJson, {
3043
- ignoreArrayOrder: true,
3044
- showOnly: {
3045
- statuses: [
3046
- "added",
3047
- "deleted",
3048
- "updated"
3049
- ],
3050
- granularity: "deep"
3051
- }
3052
- });
3053
- const changes = [];
3054
- const getChanges = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((difference, property) => {
3055
- if (difference.status === "added" || difference.status === "deleted" || difference.status === "updated") {
3056
- if (difference.diff) {
3057
- for (const diff of difference.diff) {
3058
- getChanges(diff, property ? `${property}.${difference.property}` : difference.property);
3059
- }
3060
- } else {
3061
- changes.push({
3062
- field: property ? `${property}.${difference.property}` : difference.property,
3063
- status: difference.status,
3064
- previous: difference.status === "added" ? "---" : stormJson.StormJSON.stringify(difference.previousValue),
3065
- current: difference.status === "deleted" ? "---" : stormJson.StormJSON.stringify(difference.currentValue)
3066
- });
3067
- }
3068
- }
3069
- }, "getChanges");
3070
- for (const diff of result.diff) {
3071
- getChanges(diff);
3072
- }
3073
- if (changes.length > 0) {
3074
- context.log(types.LogLevelLabel.WARN, `Updating the following configuration values in "${context.tsconfig.tsconfigFilePath}" file:
3075
-
3076
- ${changes.map((change, i) => `${chalk5__default.default.bold.whiteBright(`${i + 1}. ${titleCase.titleCase(change.status)} the ${change.field} field: `)}
3077
- ${chalk5__default.default.red(` - Previous: ${change.previous} `)}
3078
- ${chalk5__default.default.green(` - Updated: ${change.current} `)}
3079
- `).join("\n")}
3080
- `);
3081
- }
3082
- await writeFile(context.log, context.tsconfig.tsconfigFilePath, stormJson.StormJSON.stringify(updateTsconfigJson));
3083
- context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
3084
- if (!context.tsconfig) {
3085
- throw new Error("Failed to parse the TypeScript configuration file.");
3086
- }
3087
- context.tsconfig.tsconfigJson.compilerOptions ??= {};
3088
- context.tsconfig.tsconfigJson.compilerOptions.strict = false;
3089
- }
3090
- chunkPK6SKIKE_cjs.__name(resolveTsconfig, "resolveTsconfig");
3091
-
3092
- // src/internal/api.ts
3093
- var PowerlinesAPI = class _PowerlinesAPI {
3094
- static {
3095
- chunkPK6SKIKE_cjs.__name(this, "PowerlinesAPI");
3096
- }
3097
- /**
3098
- * The Powerlines context
3099
- */
3100
- #context;
3101
- /**
3102
- * The Powerlines context
3103
- */
3104
- get context() {
3105
- return this.#context;
3106
- }
3107
- /**
3108
- * Create a new Powerlines API instance
3109
- *
3110
- * @param context - The Powerlines context
3111
- */
3112
- constructor(context) {
3113
- this.#context = context;
3114
- }
3115
- /**
3116
- * Initialize the Powerlines API
3117
- */
3118
- static async from(workspaceRoot, config) {
3119
- const api = new _PowerlinesAPI(await PowerlinesAPIContext.from(workspaceRoot, config));
3120
- for (const plugin of api.context.config.plugins ?? []) {
3121
- await api.#addPlugin(plugin);
3122
- }
3123
- if (api.context.plugins.length === 0) {
3124
- 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.");
3125
- }
3126
- const pluginConfig = await callHook(await api.context.getEnvironment(), "config", {
3127
- sequential: true,
3128
- result: "merge"
3129
- });
3130
- await api.context.withUserConfig(pluginConfig, {
3131
- isHighPriority: false
3132
- });
3133
- return api;
3134
- }
3135
- /**
3136
- * Prepare the Powerlines API
3137
- */
3138
- async prepare(inlineConfig = {
3139
- command: "prepare"
3140
- }) {
3141
- this.context.log(types.LogLevelLabel.TRACE, " \u{1F3D7}\uFE0F Preparing the Powerlines project");
3142
- this.context.log(types.LogLevelLabel.TRACE, " \u2699\uFE0F Aggregating configuration options for the Powerlines project");
3143
- await this.context.withInlineConfig(inlineConfig);
3144
- await this.#executeEnvironments(async (context) => {
3145
- context.log(types.LogLevelLabel.TRACE, `Initializing the processing options for the Powerlines project.`);
3146
- await this.callPreHook(context, "configResolved");
3147
- await initializeTsconfig(context);
3148
- await this.callNormalHook(context, "configResolved");
3149
- 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 ? `:
3150
- ${context.entry.map((entry) => `- ${entry.input.file || entry.file}${entry.output ? ` -> ${entry.output}` : ""}`).join(" \n")}` : ""}.`);
3151
- await resolveTsconfig(context);
3152
- await installDependencies(context);
3153
- await this.callPostHook(context, "configResolved");
3154
- context.log(types.LogLevelLabel.TRACE, `Powerlines configuration has been resolved:
3155
-
3156
- ${console.formatLogMessage(context.config)}`);
3157
- context.fs[chunk22K72CJ5_cjs.__VFS_INIT__]();
3158
- await writeMetaFile(context);
3159
- context.persistedMeta = context.meta;
3160
- if (!exists.existsSync(context.cachePath)) {
3161
- await helpers.createDirectory(context.cachePath);
3162
- }
3163
- if (!exists.existsSync(context.dataPath)) {
3164
- await helpers.createDirectory(context.dataPath);
3165
- }
3166
- await this.callPreHook(context, "prepare");
3167
- if (context.config.projectType === "application") {
3168
- context.log(types.LogLevelLabel.TRACE, "Generating built-in barrel file");
3169
- }
3170
- if (context.config.output.dts !== false) {
3171
- await generateTypes(context);
3172
- }
3173
- await this.callNormalHook(context, "prepare");
3174
- context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
3175
- if (!context.tsconfig) {
3176
- throw new Error("Failed to parse the TypeScript configuration file.");
3177
- }
3178
- await this.callPostHook(context, "prepare");
3179
- await writeMetaFile(context);
3180
- context.fs[chunk22K72CJ5_cjs.__VFS_REVERT__]();
3181
- });
3182
- this.context.log(types.LogLevelLabel.INFO, "Powerlines API has been prepared successfully");
3183
- }
3184
- /**
3185
- * Create a new Powerlines project
3186
- *
3187
- * @remarks
3188
- * This method will create a new Powerlines project in the current directory.
3189
- *
3190
- * @param inlineConfig - The inline configuration for the new command
3191
- * @returns A promise that resolves when the project has been created
3192
- */
3193
- async new(inlineConfig) {
3194
- this.context.log(types.LogLevelLabel.INFO, "\u{1F195} Creating a new Powerlines project");
3195
- await this.prepare(inlineConfig);
3196
- await this.#executeEnvironments(async (context) => {
3197
- context.log(types.LogLevelLabel.TRACE, `Initializing the processing options for the Powerlines project.`);
3198
- await this.callPreHook(context, "new");
3199
- const files = await listFiles.listFiles(joinPaths.joinPaths(context.powerlinesPath, "files/common/**/*.hbs"));
3200
- for (const file of files) {
3201
- context.log(types.LogLevelLabel.TRACE, `Adding template file: ${file}`);
3202
- const template = Handlebars__default.default.compile(file);
3203
- await writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3204
- }
3205
- await this.callNormalHook(context, "new");
3206
- if (context.config.projectType === "application") {
3207
- const files2 = await listFiles.listFiles(joinPaths.joinPaths(context.powerlinesPath, "files/application/**/*.hbs"));
3208
- for (const file of files2) {
3209
- context.log(types.LogLevelLabel.TRACE, `Adding application template file: ${file}`);
3210
- const template = Handlebars__default.default.compile(file);
3211
- await writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3212
- }
3213
- } else {
3214
- const files2 = await listFiles.listFiles(joinPaths.joinPaths(context.powerlinesPath, "files/library/**/*.hbs"));
3215
- for (const file of files2) {
3216
- context.log(types.LogLevelLabel.TRACE, `Adding library template file: ${file}`);
3217
- const template = Handlebars__default.default.compile(file);
3218
- await writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3219
- }
3220
- }
3221
- await this.callPostHook(context, "new");
3222
- });
3223
- this.context.log(types.LogLevelLabel.TRACE, "Powerlines - New command completed");
3224
- }
3225
- /**
3226
- * Clean any previously prepared artifacts
3227
- *
3228
- * @remarks
3229
- * This method will remove the previous Powerlines artifacts from the project.
3230
- *
3231
- * @param inlineConfig - The inline configuration for the clean command
3232
- * @returns A promise that resolves when the clean command has completed
3233
- */
3234
- async clean(inlineConfig = {
3235
- command: "clean"
3236
- }) {
3237
- this.context.log(types.LogLevelLabel.INFO, "\u{1F9F9} Cleaning the previous Powerlines artifacts");
3238
- await this.prepare(inlineConfig);
3239
- await this.#executeEnvironments(async (context) => {
3240
- await callHook(context, "clean", {
3241
- sequential: true
3242
- });
3243
- });
3244
- this.context.log(types.LogLevelLabel.TRACE, "Powerlines - Clean command completed");
3245
- }
3246
- /**
3247
- * Lint the project
3248
- *
3249
- * @param inlineConfig - The inline configuration for the lint command
3250
- * @returns A promise that resolves when the lint command has completed
3251
- */
3252
- async lint(inlineConfig = {
3253
- command: "lint"
3254
- }) {
3255
- this.context.log(types.LogLevelLabel.INFO, "\u{1F4CB} Linting the Powerlines project");
3256
- await this.prepare(inlineConfig);
3257
- await this.#executeEnvironments(async (context) => {
3258
- if (context.config.lint !== false) {
3259
- await this.callHook(context, "lint");
3260
- }
3261
- });
3262
- this.context.log(types.LogLevelLabel.TRACE, "Powerlines linting completed");
3263
- }
3264
- /**
3265
- * Build the project
3266
- *
3267
- * @remarks
3268
- * This method will build the Powerlines project, generating the necessary artifacts.
3269
- *
3270
- * @param inlineConfig - The inline configuration for the build command
3271
- * @returns A promise that resolves when the build command has completed
3272
- */
3273
- async build(inlineConfig = {
3274
- command: "build"
3275
- }) {
3276
- this.context.log(types.LogLevelLabel.INFO, "\u{1F4E6} Building the Powerlines project");
3277
- await this.prepare(inlineConfig);
3278
- await this.#executeEnvironments(async (context) => {
3279
- await this.callPreHook(context, "build");
3280
- await this.callNormalHook(context, "build");
3281
- await Promise.all(context.config.output.assets.map(async (asset) => {
3282
- context.log(types.LogLevelLabel.DEBUG, `Copying asset(s): ${chalk5__default.default.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : joinPaths.joinPaths(replace.replacePath(asset.input, context.workspaceConfig.workspaceRoot), asset.glob))} -> ${chalk5__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) => chalk5__default.default.yellowBright(i)).join(", ")})` : ""}`);
3283
- await copyFile.copyFiles(asset, asset.output);
3284
- }));
3285
- await this.callPostHook(context, "build");
3286
- });
3287
- this.context.log(types.LogLevelLabel.TRACE, "Powerlines build completed");
3288
- }
3289
- /**
3290
- * Prepare the documentation for the project
3291
- *
3292
- * @param inlineConfig - The inline configuration for the docs command
3293
- * @returns A promise that resolves when the documentation generation has completed
3294
- */
3295
- async docs(inlineConfig = {
3296
- command: "docs"
3297
- }) {
3298
- this.context.log(types.LogLevelLabel.INFO, "\u{1F4D3} Generating documentation for the Powerlines project");
3299
- await this.prepare(inlineConfig);
3300
- await this.#executeEnvironments(async (context) => {
3301
- context.log(types.LogLevelLabel.TRACE, "Writing documentation for the Powerlines project artifacts.");
3302
- await this.prepare(inlineConfig);
3303
- await this.#executeEnvironments(async (context2) => {
3304
- await this.callHook(context2, "docs");
3305
- });
3306
- });
3307
- this.#context.log(types.LogLevelLabel.TRACE, "Powerlines documentation generation completed");
3308
- }
3309
- /**
3310
- * Release the project
3311
- *
3312
- * @remarks
3313
- * This method will prepare and build the Powerlines project, generating the necessary artifacts for release.
3314
- *
3315
- * @param inlineConfig - The inline configuration for the release command
3316
- */
3317
- async release(inlineConfig = {
3318
- command: "release"
3319
- }) {
3320
- this.context.log(types.LogLevelLabel.INFO, "\u{1F4E6} Releasing the Powerlines project");
3321
- await this.prepare(inlineConfig);
3322
- await this.#executeEnvironments(async (context) => {
3323
- await this.callHook(context, "release");
3324
- });
3325
- this.context.log(types.LogLevelLabel.TRACE, "Powerlines release completed");
3326
- }
3327
- /**
3328
- * Finalization process
3329
- *
3330
- * @remarks
3331
- * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
3332
- *
3333
- * @returns A promise that resolves when the finalization process has completed
3334
- */
3335
- async finalize() {
3336
- this.context.log(types.LogLevelLabel.TRACE, "Powerlines finalize execution started");
3337
- await this.#executeEnvironments(async (context) => {
3338
- await this.callHook(context, "finalize");
3339
- context.fs[chunk22K72CJ5_cjs.__VFS_REVERT__]();
3340
- });
3341
- this.context.log(types.LogLevelLabel.TRACE, "Powerlines finalize execution completed");
3342
- }
3343
- /**
3344
- * Calls a hook in parallel
3345
- *
3346
- * @param hook - The hook to call
3347
- * @param options - Options for calling the hook
3348
- * @param args - The arguments to pass to the hook
3349
- * @returns The result of the hook call
3350
- */
3351
- async callHookParallel(hook, options, ...args) {
3352
- return callHook(isSetObject.isSetObject(options?.environment) ? options.environment : await this.#context.getEnvironment(options?.environment), hook, {
3353
- ...options,
3354
- sequential: false
3355
- }, ...args);
3356
- }
3357
- /**
3358
- * Calls a hook in sequence
3359
- *
3360
- * @param hook - The hook to call
3361
- * @param options - Options for calling the hook
3362
- * @param args - The arguments to pass to the hook
3363
- * @returns The result of the hook call
3364
- */
3365
- async callHookSequential(hook, options, ...args) {
3366
- return callHook(isSetObject.isSetObject(options?.environment) ? options.environment : await this.#context.getEnvironment(options?.environment), hook, {
3367
- ...options,
3368
- sequential: true
3369
- }, ...args);
3370
- }
3371
- /**
3372
- * Calls the `"pre"` ordered hooks in sequence
3373
- *
3374
- * @param environment - The environment to use for the hook call
3375
- * @param hook - The hook to call
3376
- * @param args - The arguments to pass to the hook
3377
- * @returns The result of the hook call
3378
- */
3379
- async callPreHook(environment, hook, ...args) {
3380
- return this.callHookSequential(hook, {
3381
- order: "pre",
3382
- environment
3383
- }, ...args);
3384
- }
3385
- /**
3386
- * Calls the `"post"` ordered hooks in sequence
3387
- *
3388
- * @param environment - The environment to use for the hook call
3389
- * @param hook - The hook to call
3390
- * @param args - The arguments to pass to the hook
3391
- * @returns The result of the hook call
3392
- */
3393
- async callPostHook(environment, hook, ...args) {
3394
- return this.callHookSequential(hook, {
3395
- order: "post",
3396
- environment
3397
- }, ...args);
3398
- }
3399
- /**
3400
- * Calls a hook in sequence
3401
- *
3402
- * @param environment - The environment to use for the hook call
3403
- * @param hook - The hook to call
3404
- * @param args - The arguments to pass to the hook
3405
- * @returns The result of the hook call
3406
- */
3407
- async callNormalHook(environment, hook, ...args) {
3408
- return this.callHookSequential(hook, {
3409
- order: "normal",
3410
- environment
3411
- }, ...args);
3412
- }
3413
- /**
3414
- * Calls the `"pre"` and `"post"` ordered hooks, as well as the normal hooks in sequence
3415
- *
3416
- * @param environment - The environment to use for the hook call
3417
- * @param hook - The hook to call
3418
- * @param args - The arguments to pass to the hook
3419
- * @returns The result of the hook call
3420
- */
3421
- async callHook(environment, hook, ...args) {
3422
- return this.callHookSequential(hook, {
3423
- environment
3424
- }, ...args);
3425
- }
3426
- async [Symbol.asyncDispose]() {
3427
- await this.finalize();
3428
- }
3429
- /**
3430
- * Get the configured environments
3431
- *
3432
- * @returns The configured environments
3433
- */
3434
- async #getEnvironments() {
3435
- if (!this.context.config.environments || Object.keys(this.context.config.environments).length <= 1) {
3436
- this.context.log(types.LogLevelLabel.DEBUG, "No environments are configured for this Powerlines project. Using the default environment.");
3437
- return [
3438
- await this.context.getEnvironment()
3439
- ];
3440
- }
3441
- this.context.log(types.LogLevelLabel.DEBUG, `Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`);
3442
- return (await Promise.all(Object.entries(this.context.config.environments).map(async ([name, config]) => {
3443
- const environment = await this.context.getEnvironmentSafe(name);
3444
- if (!environment) {
3445
- const resolvedEnvironment = await this.callHookParallel("configEnvironment", {
3446
- environment: name
3447
- }, name, config);
3448
- if (resolvedEnvironment) {
3449
- this.context.environments[name] = await this.context.in(resolvedEnvironment);
3450
- }
3451
- }
3452
- return this.context.environments[name];
3453
- }))).filter((context) => isSet.isSet(context));
3454
- }
3455
- /**
3456
- * Execute a handler function for each environment
3457
- *
3458
- * @param handle - The handler function to execute for each environment
3459
- */
3460
- async #executeEnvironments(handle) {
3461
- await Promise.all((await this.#getEnvironments()).map(async (context) => {
3462
- return Promise.resolve(handle(context));
3463
- }));
3464
- }
3465
- /**
3466
- * Add a Powerlines plugin used in the build process
3467
- *
3468
- * @param config - The import path of the plugin to add
3469
- */
3470
- async #addPlugin(config) {
3471
- if (config) {
3472
- const plugin = await this.#initPlugin(config);
3473
- if (!plugin) {
3474
- return;
3475
- }
3476
- if (plugin.dependsOn) {
3477
- for (const required of plugin.dependsOn) {
3478
- await this.#addPlugin(required);
3479
- }
3480
- }
3481
- this.context.log(types.LogLevelLabel.DEBUG, `Successfully initialized the ${chalk5__default.default.bold.cyanBright(plugin.name)} plugin`);
3482
- await this.context.addPlugin(plugin);
3483
- }
3484
- }
3485
- /**
3486
- * Initialize a Powerlines plugin
3487
- *
3488
- * @param config - The configuration for the plugin
3489
- * @returns The initialized plugin instance, or null if the plugin was a duplicate
3490
- * @throws Will throw an error if the plugin cannot be found or is invalid
3491
- */
3492
- async #initPlugin(config) {
3493
- let awaited = config;
3494
- if (isPromise.isPromiseLike(config)) {
3495
- awaited = await Promise.resolve(config);
3496
- }
3497
- if (!isPluginConfig(awaited)) {
3498
- 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\`.`);
3499
- }
3500
- let plugin;
3501
- if (isPlugin(awaited)) {
3502
- plugin = awaited;
3503
- } else if (isFunction.isFunction(awaited)) {
3504
- plugin = await Promise.resolve(awaited());
3505
- } else if (isSetString.isSetString(awaited)) {
3506
- const resolved = await this.#resolvePlugin(awaited);
3507
- if (isFunction.isFunction(resolved)) {
3508
- plugin = await Promise.resolve(resolved());
3509
- } else {
3510
- plugin = resolved;
3511
- }
3512
- } else if (isPluginConfigTuple(awaited) || isPluginConfigObject(awaited)) {
3513
- let pluginConfig;
3514
- let pluginOptions;
3515
- if (isPluginConfigTuple(awaited)) {
3516
- pluginConfig = awaited[0];
3517
- pluginOptions = awaited?.length === 2 ? awaited[1] : void 0;
3518
- } else {
3519
- pluginConfig = awaited.plugin;
3520
- pluginOptions = awaited.options;
3521
- }
3522
- if (isSetString.isSetString(pluginConfig)) {
3523
- const resolved = await this.#resolvePlugin(pluginConfig);
3524
- if (isFunction.isFunction(resolved)) {
3525
- plugin = await Promise.resolve(pluginOptions ? resolved(pluginOptions) : resolved());
3526
- } else {
3527
- plugin = resolved;
3528
- }
3529
- } else if (isFunction.isFunction(pluginConfig)) {
3530
- plugin = await Promise.resolve(pluginConfig(pluginOptions));
3531
- } else if (isPlugin(pluginConfig)) {
3532
- plugin = pluginConfig;
3533
- }
3534
- }
3535
- if (!plugin) {
3536
- throw new Error(`The plugin configuration ${JSON.stringify(awaited)} is invalid. This configuration must point to a valid Powerlines plugin module.`);
3537
- }
3538
- if (!isPlugin(plugin)) {
3539
- 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.`);
3540
- }
3541
- if (checkDedupe(plugin, this.context.plugins)) {
3542
- this.context.log(types.LogLevelLabel.TRACE, `Duplicate ${chalk5__default.default.bold.cyanBright(plugin.name)} plugin dependency detected - Skipping initialization.`);
3543
- return null;
3544
- }
3545
- this.context.log(types.LogLevelLabel.TRACE, `Initializing the ${chalk5__default.default.bold.cyanBright(plugin.name)} plugin...`);
3546
- return plugin;
3547
- }
3548
- async #resolvePlugin(pluginPath) {
3549
- if (pluginPath.startsWith("@") && pluginPath.split("/").filter(Boolean).length > 2) {
3550
- const splits = pluginPath.split("/").filter(Boolean);
3551
- pluginPath = `${splits[0]}/${splits[1]}`;
3552
- }
3553
- const isInstalled = packageFns.isPackageExists(pluginPath, {
3554
- paths: [
3555
- this.context.workspaceConfig.workspaceRoot,
3556
- this.context.config.projectRoot
3557
- ]
3558
- });
3559
- if (!isInstalled && this.context.config.skipInstalls !== true) {
3560
- this.#context.log(types.LogLevelLabel.WARN, `The plugin package "${pluginPath}" is not installed. It will be installed automatically.`);
3561
- const result = await install.install(pluginPath, {
3562
- cwd: this.context.config.projectRoot
3563
- });
3564
- if (isNumber.isNumber(result.exitCode) && result.exitCode > 0) {
3565
- this.#context.log(types.LogLevelLabel.ERROR, result.stderr);
3566
- throw new Error(`An error occurred while installing the build plugin package "${pluginPath}" `);
3567
- }
3568
- }
3569
- try {
3570
- const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(joinPaths.joinPaths(pluginPath, "plugin")));
3571
- const result = module.plugin ?? module.default;
3572
- if (!result) {
3573
- throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
3574
- }
3575
- return result;
3576
- } catch (error) {
3577
- try {
3578
- const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(pluginPath));
3579
- const result = module.plugin ?? module.default;
3580
- if (!result) {
3581
- throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
3582
- }
3583
- return result;
3584
- } catch {
3585
- if (!isInstalled) {
3586
- throw new Error(`The plugin package "${pluginPath}" is not installed. Please install the package using the command: "npm install ${pluginPath} --save-dev"`);
3587
- } else {
3588
- throw new Error(`An error occurred while importing the build plugin package "${pluginPath}":
3589
- ${isError.isError(error) ? error.message : String(error)}
3590
-
3591
- 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\`.`);
3592
- }
3593
- }
3594
- }
3595
- }
3596
- };
3597
-
3598
- exports.PowerlinesAPI = PowerlinesAPI;
3599
- exports.createLog = createLog;
3600
- exports.getString = getString;
3601
- //# sourceMappingURL=chunk-PJRHRDLS.cjs.map
3602
- //# sourceMappingURL=chunk-PJRHRDLS.cjs.map