powerlines 0.24.9 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-C32Buv5_.d.ts → api-DEktSZK8.d.cts} +1 -1
- package/dist/{api-wzd5AREv.d.cts → api-j14_4IBd.d.ts} +1 -1
- package/dist/api.cjs +8 -6
- package/dist/api.d.cts +20 -22
- package/dist/api.d.ts +20 -22
- package/dist/api.js +7 -5
- package/dist/astro.cjs +12 -10
- package/dist/astro.d.cts +19 -21
- package/dist/astro.d.ts +19 -21
- package/dist/astro.js +10 -8
- package/dist/{chunk-JKBJF3UI.js → chunk-2MYPFASJ.js} +2 -0
- package/dist/chunk-2VIXD2XB.js +3 -0
- package/dist/chunk-4JCNAKOE.cjs +4 -0
- package/dist/{chunk-JQCWV4DT.js → chunk-57XOTOOZ.js} +2 -0
- package/dist/{chunk-ABWNIXFZ.js → chunk-67XQ6U3Z.js} +5 -3
- package/dist/chunk-6ZGIV2SU.cjs +4 -0
- package/dist/chunk-7BZQBW77.cjs +4 -0
- package/dist/{chunk-SHUYVCID.js → chunk-7QVYU63E.js} +2 -0
- package/dist/{chunk-PVUETJ3T.cjs → chunk-AEGD6URX.cjs} +9 -7
- package/dist/chunk-AFJCY3R6.js +3 -0
- package/dist/chunk-AXIRZAL7.js +3 -0
- package/dist/{chunk-S5YGX5GU.js → chunk-BGVUPIUF.js} +3 -1
- package/dist/chunk-BTNHSS2P.cjs +13 -0
- package/dist/chunk-DFLNRC3B.cjs +4 -0
- package/dist/chunk-DS7OM4NX.cjs +4 -0
- package/dist/{chunk-W5X3ZEZ5.js → chunk-EBXVKPUX.js} +2 -0
- package/dist/chunk-GIE6OE3X.js +3 -0
- package/dist/chunk-HJW7OH6E.js +3 -0
- package/dist/{chunk-5IBA5HC2.cjs → chunk-HTJKPEWU.cjs} +6 -4
- package/dist/chunk-HY5THHOG.cjs +12 -0
- package/dist/chunk-IHUNA3MO.cjs +4 -0
- package/dist/chunk-JU2HWIWS.js +12 -0
- package/dist/{chunk-4ZYG5R5M.cjs → chunk-KRKQGXVU.cjs} +13 -11
- package/dist/{chunk-357MDCVI.js → chunk-LZFTQGQG.js} +901 -932
- package/dist/chunk-MBBNZS6K.cjs +16 -0
- package/dist/chunk-OYASPHNL.js +3 -0
- package/dist/chunk-PCCFAZML.js +3 -0
- package/dist/{chunk-USNT2KNT.cjs → chunk-PK6SKIKE.cjs} +2 -0
- package/dist/chunk-Q7EJVZVI.cjs +4 -0
- package/dist/{chunk-CJSGAITR.js → chunk-S7MXT5A2.js} +3 -1
- package/dist/{chunk-UWEARQIV.js → chunk-SWN5KDZD.js} +6 -4
- package/dist/{chunk-C4CJ7YAI.js → chunk-T64XX2K5.js} +4 -2
- package/dist/chunk-TLHFXGYV.js +3 -0
- package/dist/chunk-VNRXLY2T.js +3 -0
- package/dist/chunk-VQCQRLGM.cjs +4 -0
- package/dist/{chunk-ETKZMGLN.cjs → chunk-XH2XKGPW.cjs} +2 -0
- package/dist/chunk-XZO6ZJQP.cjs +4 -0
- package/dist/{chunk-Q4DVMLUP.cjs → chunk-YTLBMDJR.cjs} +9 -7
- package/dist/{chunk-XP7OML7S.cjs → chunk-YUX7LOBU.cjs} +2 -0
- package/dist/{chunk-PT24UOCD.cjs → chunk-YWJHR2FX.cjs} +970 -1004
- package/dist/chunk-YZZUOOPS.cjs +4 -0
- package/dist/chunk-Z5H7LD6W.js +3 -0
- package/dist/{chunk-VBR53KGY.js → chunk-Z5UEYORO.js} +5 -3
- package/dist/{chunk-PAMSESZV.cjs → chunk-Z6ARQDHR.cjs} +2 -0
- package/dist/config.cjs +5 -3
- package/dist/config.d.cts +19 -21
- package/dist/config.d.ts +19 -21
- package/dist/config.js +4 -2
- package/dist/{resolved-CSqGKlA5.d.cts → context-BEIQBYYw.d.cts} +850 -851
- package/dist/{resolved-BABoCnXm.d.ts → context-C0ODYfUe.d.ts} +850 -851
- package/dist/esbuild.cjs +13 -11
- package/dist/esbuild.d.cts +19 -21
- package/dist/esbuild.d.ts +19 -21
- package/dist/esbuild.js +10 -8
- package/dist/farm.cjs +9 -7
- package/dist/farm.d.cts +19 -21
- package/dist/farm.d.ts +19 -21
- package/dist/farm.js +8 -6
- package/dist/index.cjs +39 -41
- package/dist/index.d.cts +30 -55
- package/dist/index.d.ts +30 -55
- package/dist/index.js +20 -18
- package/dist/lib/{api-DcMDyPIg.d.ts → api-_Nk6Y2ez.d.cts} +1 -1
- package/dist/lib/{api-B7dqvw6M.d.cts → api-_X9QoW9Y.d.ts} +1 -1
- package/dist/lib/build/esbuild.cjs +5 -5
- package/dist/lib/build/esbuild.d.cts +2 -2
- package/dist/lib/build/esbuild.d.ts +2 -2
- package/dist/lib/build/esbuild.js +2 -2
- package/dist/lib/build/index.cjs +25 -25
- package/dist/lib/build/index.d.cts +4 -4
- package/dist/lib/build/index.d.ts +4 -4
- package/dist/lib/build/index.js +9 -9
- package/dist/lib/build/rolldown.cjs +3 -3
- package/dist/lib/build/rolldown.d.cts +2 -2
- package/dist/lib/build/rolldown.d.ts +2 -2
- package/dist/lib/build/rolldown.js +2 -2
- package/dist/lib/build/rollup.cjs +3 -3
- package/dist/lib/build/rollup.d.cts +2 -2
- package/dist/lib/build/rollup.d.ts +2 -2
- package/dist/lib/build/rollup.js +1 -1
- package/dist/lib/build/rspack.cjs +2 -2
- package/dist/lib/build/rspack.d.cts +2 -2
- package/dist/lib/build/rspack.d.ts +2 -2
- package/dist/lib/build/rspack.js +1 -1
- package/dist/lib/build/tsup.cjs +6 -6
- package/dist/lib/build/tsup.d.cts +2 -2
- package/dist/lib/build/tsup.d.ts +2 -2
- package/dist/lib/build/tsup.js +3 -3
- package/dist/lib/build/unbuild.cjs +5 -5
- package/dist/lib/build/unbuild.d.cts +4 -4
- package/dist/lib/build/unbuild.d.ts +4 -4
- package/dist/lib/build/unbuild.js +2 -2
- package/dist/lib/build/vite.cjs +5 -5
- package/dist/lib/build/vite.d.cts +2 -2
- package/dist/lib/build/vite.d.ts +2 -2
- package/dist/lib/build/vite.js +3 -3
- package/dist/lib/build/webpack.cjs +2 -2
- package/dist/lib/build/webpack.d.cts +2 -2
- package/dist/lib/build/webpack.d.ts +2 -2
- package/dist/lib/build/webpack.js +1 -1
- package/dist/lib/chunk-3T56KQ7U.cjs +49 -0
- package/dist/lib/{chunk-PZLO6FZW.js → chunk-3W53W5J2.js} +2 -2
- package/dist/lib/chunk-4W6WV35V.js +108 -0
- package/dist/lib/chunk-6OYSDQXE.cjs +139 -0
- package/dist/lib/{chunk-EV357RFB.cjs → chunk-7MHUTBEC.cjs} +1 -3
- package/dist/lib/{chunk-A2NFSQ5K.js → chunk-7OVZZWGY.js} +1 -1
- package/dist/lib/chunk-A2NW7WAN.js +47 -0
- package/dist/lib/chunk-D6MI2V6R.cjs +115 -0
- package/dist/lib/{chunk-VHLINWXG.js → chunk-DLVVEHMU.js} +1 -1
- package/dist/lib/{chunk-XLYMVIVD.cjs → chunk-DNQBXFNE.cjs} +10 -10
- package/dist/lib/{chunk-UGVHYKKN.js → chunk-DYLE5FD3.js} +39 -2
- package/dist/lib/{chunk-AKBAX4FH.js → chunk-EN52JYUK.js} +1 -1
- package/dist/lib/{chunk-JYDGFQIV.cjs → chunk-F2CXZUSB.cjs} +1 -1
- package/dist/lib/{chunk-7VJ42H2I.cjs → chunk-HRRI4KOM.cjs} +1 -3
- package/dist/lib/{chunk-LPRZ3HD4.cjs → chunk-IXTLRVAK.cjs} +3 -3
- package/dist/lib/{chunk-SYF7QG2J.js → chunk-J3BW52BU.js} +1 -1
- package/dist/lib/chunk-KFDNKOXM.js +56 -0
- package/dist/lib/chunk-L56XA427.js +137 -0
- package/dist/lib/{chunk-6PPZCPME.cjs → chunk-LOW2TIQ6.cjs} +2 -2
- package/dist/lib/{chunk-TMZCGC5U.js → chunk-MI55FDCZ.js} +1 -1
- package/dist/lib/{chunk-DUZJ7ZF2.cjs → chunk-MKKWFHGE.cjs} +2 -2
- package/dist/lib/{chunk-ISBHXSDH.cjs → chunk-N5XEKCVW.cjs} +1 -1
- package/dist/lib/{chunk-XZFEHPYE.js → chunk-N5YLKWC2.js} +1 -1
- package/dist/lib/chunk-NIRFKQAD.js +845 -0
- package/dist/lib/{chunk-YMHOAMCU.cjs → chunk-NLJR4WIX.cjs} +41 -4
- package/dist/lib/{chunk-L3HESXYF.cjs → chunk-NUE5DIH3.cjs} +3 -3
- package/dist/lib/chunk-OBA5U4Y2.js +1059 -0
- package/dist/lib/{chunk-FQLZZYYO.js → chunk-OEF6EHQV.js} +1 -3
- package/dist/lib/{chunk-WTTBXYFQ.js → chunk-OFXWRM3U.js} +2 -2
- package/dist/lib/chunk-ONETLSPO.js +85 -0
- package/dist/lib/{chunk-2OV26JXJ.cjs → chunk-PQRWG64T.cjs} +3 -3
- package/dist/lib/chunk-R33US3PV.cjs +1081 -0
- package/dist/lib/{chunk-Z74G7RN3.cjs → chunk-SFEEJZLK.cjs} +32 -38
- package/dist/lib/{chunk-H6EOZSIZ.js → chunk-TAVG226Z.js} +1 -1
- package/dist/lib/{chunk-DALRRHB4.cjs → chunk-TSFG3WEA.cjs} +1 -1
- package/dist/lib/{chunk-RMA2PMP7.cjs → chunk-TZCC5IWH.cjs} +3 -3
- package/dist/lib/chunk-VHCBD2IS.js +149 -0
- package/dist/lib/{chunk-HY6DNFCT.js → chunk-VODWHWD6.js} +2 -2
- package/dist/lib/{chunk-2X5DUDNT.js → chunk-W6GWSJ22.js} +2 -2
- package/dist/lib/chunk-WBSA6OG6.cjs +860 -0
- package/dist/lib/{chunk-TOCNXURI.cjs → chunk-WCXA5WFX.cjs} +4 -4
- package/dist/lib/{chunk-6I5PL7H2.js → chunk-WGSZ4X6N.js} +1 -3
- package/dist/lib/{chunk-FBRJW4AY.js → chunk-WLDQUTFD.js} +23 -29
- package/dist/lib/{chunk-AOHJEL2Q.js → chunk-WOKPJMGJ.js} +3 -3
- package/dist/lib/{chunk-TDJNFAOV.cjs → chunk-X6JDYLWM.cjs} +1 -1
- package/dist/lib/chunk-XLHFUATD.cjs +151 -0
- package/dist/lib/chunk-XUYQYUWZ.cjs +87 -0
- package/dist/lib/chunk-YYEAV24J.cjs +67 -0
- package/dist/lib/{config-Cobl3YxA.d.ts → config-B1TbvPos.d.ts} +60 -477
- package/dist/lib/config-file.d.cts +2 -2
- package/dist/lib/config-file.d.ts +2 -2
- package/dist/lib/{config-BgeSOU_x.d.cts → config-k7pxzq2C.d.cts} +60 -477
- package/dist/lib/contexts/api-context.cjs +12 -7
- package/dist/lib/contexts/api-context.d.cts +27 -4
- package/dist/lib/contexts/api-context.d.ts +27 -4
- package/dist/lib/contexts/api-context.js +11 -6
- package/dist/lib/contexts/context.cjs +10 -5
- package/dist/lib/contexts/context.d.cts +7 -7
- package/dist/lib/contexts/context.d.ts +7 -7
- package/dist/lib/contexts/context.js +9 -4
- package/dist/lib/contexts/environment-context.cjs +11 -6
- package/dist/lib/contexts/environment-context.d.cts +4 -4
- package/dist/lib/contexts/environment-context.d.ts +4 -4
- package/dist/lib/contexts/environment-context.js +10 -5
- package/dist/lib/contexts/index.cjs +14 -9
- package/dist/lib/contexts/index.d.cts +4 -4
- package/dist/lib/contexts/index.d.ts +4 -4
- package/dist/lib/contexts/index.js +11 -6
- package/dist/lib/contexts/plugin-context.d.cts +4 -4
- package/dist/lib/contexts/plugin-context.d.ts +4 -4
- package/dist/lib/entry.cjs +9 -9
- package/dist/lib/entry.d.cts +2 -2
- package/dist/lib/entry.d.ts +2 -2
- package/dist/lib/entry.js +1 -1
- package/dist/lib/fs/helpers.cjs +47 -0
- package/dist/lib/fs/helpers.d.cts +74 -0
- package/dist/lib/fs/helpers.d.ts +74 -0
- package/dist/lib/fs/helpers.js +2 -0
- package/dist/lib/fs/index.cjs +17 -0
- package/dist/lib/fs/index.d.cts +33 -0
- package/dist/lib/fs/index.d.ts +33 -0
- package/dist/lib/fs/index.js +8 -0
- package/dist/lib/fs/storage/base.cjs +11 -0
- package/dist/lib/fs/storage/base.d.cts +138 -0
- package/dist/lib/fs/storage/base.d.ts +138 -0
- package/dist/lib/fs/storage/base.js +2 -0
- package/dist/lib/fs/storage/file-system.cjs +13 -0
- package/dist/lib/fs/storage/file-system.d.cts +90 -0
- package/dist/lib/fs/storage/file-system.d.ts +90 -0
- package/dist/lib/fs/storage/file-system.js +4 -0
- package/dist/lib/fs/storage/index.cjs +22 -0
- package/dist/lib/fs/storage/index.d.cts +6 -0
- package/dist/lib/fs/storage/index.d.ts +6 -0
- package/dist/lib/fs/storage/index.js +5 -0
- package/dist/lib/fs/storage/virtual.cjs +12 -0
- package/dist/lib/fs/storage/virtual.d.cts +66 -0
- package/dist/lib/fs/storage/virtual.d.ts +66 -0
- package/dist/lib/fs/storage/virtual.js +3 -0
- package/dist/lib/fs/vfs.cjs +16 -0
- package/dist/lib/fs/vfs.d.cts +247 -0
- package/dist/lib/fs/vfs.d.ts +247 -0
- package/dist/lib/fs/vfs.js +7 -0
- package/dist/lib/fs-Dg-aTfiN.d.cts +378 -0
- package/dist/lib/fs-Dg-aTfiN.d.ts +378 -0
- package/dist/lib/index.cjs +70 -76
- package/dist/lib/index.d.cts +18 -356
- package/dist/lib/index.d.ts +18 -356
- package/dist/lib/index.js +21 -15
- package/dist/lib/{internal-C4LRBm2o.d.cts → internal-BL418sdB.d.cts} +2 -2
- package/dist/lib/{internal-BgqhTTai.d.ts → internal-mNVkKh_3.d.ts} +2 -2
- package/dist/lib/logger.d.cts +2 -2
- package/dist/lib/logger.d.ts +2 -2
- package/dist/lib/typescript/import-transformer.cjs +7 -45
- package/dist/lib/typescript/import-transformer.d.cts +2 -2
- package/dist/lib/typescript/import-transformer.d.ts +2 -2
- package/dist/lib/typescript/import-transformer.js +2 -47
- package/dist/lib/typescript/index.cjs +10 -22
- package/dist/lib/typescript/index.d.cts +4 -4
- package/dist/lib/typescript/index.d.ts +4 -4
- package/dist/lib/typescript/index.js +2 -2
- package/dist/lib/typescript/ts-morph.cjs +6 -2
- package/dist/lib/typescript/ts-morph.d.cts +28 -4
- package/dist/lib/typescript/ts-morph.d.ts +28 -4
- package/dist/lib/typescript/ts-morph.js +1 -1
- package/dist/lib/unplugin/factory.cjs +14 -9
- package/dist/lib/unplugin/factory.d.cts +4 -4
- package/dist/lib/unplugin/factory.d.ts +4 -4
- package/dist/lib/unplugin/factory.js +13 -8
- package/dist/lib/unplugin/helpers.d.cts +2 -2
- package/dist/lib/unplugin/helpers.d.ts +2 -2
- package/dist/lib/unplugin/index.cjs +17 -12
- package/dist/lib/unplugin/index.d.cts +4 -4
- package/dist/lib/unplugin/index.d.ts +4 -4
- package/dist/lib/unplugin/index.js +15 -10
- package/dist/lib/unplugin/plugin.cjs +2 -2
- package/dist/lib/unplugin/plugin.d.cts +4 -4
- package/dist/lib/unplugin/plugin.d.ts +4 -4
- package/dist/lib/unplugin/plugin.js +1 -1
- package/dist/lib/{unplugin-BjKSIVn4.d.cts → unplugin-D2hRHNBc.d.cts} +2 -2
- package/dist/lib/{unplugin-CFcDbneD.d.ts → unplugin-_98FcnXX.d.ts} +2 -2
- package/dist/lib/utilities/bundle.cjs +4 -4
- package/dist/lib/utilities/bundle.d.cts +2 -2
- package/dist/lib/utilities/bundle.d.ts +2 -2
- package/dist/lib/utilities/bundle.js +3 -3
- package/dist/lib/utilities/cache.d.cts +2 -2
- package/dist/lib/utilities/cache.d.ts +2 -2
- package/dist/lib/utilities/file-header.d.cts +2 -2
- package/dist/lib/utilities/file-header.d.ts +2 -2
- package/dist/lib/utilities/index.cjs +27 -27
- package/dist/lib/utilities/index.d.cts +2 -2
- package/dist/lib/utilities/index.d.ts +2 -2
- package/dist/lib/utilities/index.js +6 -6
- package/dist/lib/utilities/meta.cjs +7 -7
- package/dist/lib/utilities/meta.d.cts +2 -2
- package/dist/lib/utilities/meta.d.ts +2 -2
- package/dist/lib/utilities/meta.js +1 -1
- package/dist/lib/utilities/resolve.cjs +5 -5
- package/dist/lib/utilities/resolve.d.cts +2 -2
- package/dist/lib/utilities/resolve.d.ts +2 -2
- package/dist/lib/utilities/resolve.js +4 -4
- package/dist/lib/utilities/source-file.d.cts +2 -2
- package/dist/lib/utilities/source-file.d.ts +2 -2
- package/dist/lib/utilities/source-map.d.cts +2 -2
- package/dist/lib/utilities/source-map.d.ts +2 -2
- package/dist/lib/utilities/worker.d.cts +2 -2
- package/dist/lib/utilities/worker.d.ts +2 -2
- package/dist/lib/utilities/write-file.d.cts +2 -2
- package/dist/lib/utilities/write-file.d.ts +2 -2
- package/dist/next.cjs +11 -9
- package/dist/next.js +9 -7
- package/dist/nuxt.cjs +13 -11
- package/dist/nuxt.js +11 -9
- package/dist/plugin-utils/{chunk-JHTLGE4X.js → chunk-K2GWRZPV.js} +1 -1
- package/dist/plugin-utils/{chunk-HSYQWNIH.cjs → chunk-VWFJOPKC.cjs} +1 -1
- package/dist/plugin-utils/{context-BITGF5LZ.d.ts → context-BEwPhwiP.d.cts} +189 -232
- package/dist/plugin-utils/{context-BITGF5LZ.d.cts → context-BEwPhwiP.d.ts} +189 -232
- package/dist/plugin-utils/context-helpers.d.cts +1 -2
- package/dist/plugin-utils/context-helpers.d.ts +1 -2
- package/dist/plugin-utils/enforce.d.cts +1 -2
- package/dist/plugin-utils/enforce.d.ts +1 -2
- package/dist/plugin-utils/extend.d.cts +1 -2
- package/dist/plugin-utils/extend.d.ts +1 -2
- package/dist/plugin-utils/get-config-path.d.cts +1 -2
- package/dist/plugin-utils/get-config-path.d.ts +1 -2
- package/dist/plugin-utils/helpers.d.cts +1 -2
- package/dist/plugin-utils/helpers.d.ts +1 -2
- package/dist/plugin-utils/index.cjs +2 -2
- package/dist/plugin-utils/index.d.cts +1 -2
- package/dist/plugin-utils/index.d.ts +1 -2
- package/dist/plugin-utils/index.js +1 -1
- package/dist/plugin-utils/merge.d.cts +1 -2
- package/dist/plugin-utils/merge.d.ts +1 -2
- package/dist/plugin-utils/paths.cjs +2 -2
- package/dist/plugin-utils/paths.d.cts +2 -3
- package/dist/plugin-utils/paths.d.ts +2 -3
- package/dist/plugin-utils/paths.js +1 -1
- package/dist/rolldown.cjs +9 -7
- package/dist/rolldown.d.cts +19 -21
- package/dist/rolldown.d.ts +19 -21
- package/dist/rolldown.js +8 -6
- package/dist/rollup.cjs +9 -7
- package/dist/rollup.d.cts +19 -21
- package/dist/rollup.d.ts +19 -21
- package/dist/rollup.js +8 -6
- package/dist/rspack.cjs +9 -7
- package/dist/rspack.d.cts +18 -20
- package/dist/rspack.d.ts +18 -20
- package/dist/rspack.js +8 -6
- package/dist/tsup.cjs +12 -10
- package/dist/tsup.js +10 -8
- package/dist/types/api.cjs +3 -1
- package/dist/types/api.cjs.map +1 -0
- package/dist/types/api.d.cts +20 -22
- package/dist/types/api.d.ts +20 -22
- package/dist/types/api.js +3 -1
- package/dist/types/api.js.map +1 -0
- package/dist/types/babel.cjs +3 -1
- package/dist/types/babel.cjs.map +1 -0
- package/dist/types/babel.d.cts +17 -19
- package/dist/types/babel.d.ts +17 -19
- package/dist/types/babel.js +3 -1
- package/dist/types/babel.js.map +1 -0
- package/dist/types/build.cjs +3 -1
- package/dist/types/build.cjs.map +1 -0
- package/dist/types/build.js +3 -1
- package/dist/types/build.js.map +1 -0
- package/dist/types/commands.cjs +5 -3
- package/dist/types/commands.cjs.map +1 -0
- package/dist/types/commands.d.cts +18 -20
- package/dist/types/commands.d.ts +18 -20
- package/dist/types/commands.js +4 -2
- package/dist/types/commands.js.map +1 -0
- package/dist/types/config.cjs +3 -1
- package/dist/types/config.cjs.map +1 -0
- package/dist/types/config.d.cts +2 -4
- package/dist/types/config.d.ts +2 -4
- package/dist/types/config.js +3 -1
- package/dist/types/config.js.map +1 -0
- package/dist/types/context.cjs +5 -3
- package/dist/types/context.cjs.map +1 -0
- package/dist/types/context.d.cts +8 -10
- package/dist/types/context.d.ts +8 -10
- package/dist/types/context.js +4 -2
- package/dist/types/context.js.map +1 -0
- package/dist/types/fs.cjs +10 -4
- package/dist/types/fs.cjs.map +1 -0
- package/dist/types/fs.d.cts +138 -184
- package/dist/types/fs.d.ts +138 -184
- package/dist/types/fs.js +4 -2
- package/dist/types/fs.js.map +1 -0
- package/dist/types/hooks.cjs +3 -1
- package/dist/types/hooks.cjs.map +1 -0
- package/dist/types/hooks.d.cts +19 -21
- package/dist/types/hooks.d.ts +19 -21
- package/dist/types/hooks.js +3 -1
- package/dist/types/hooks.js.map +1 -0
- package/dist/types/index.cjs +26 -20
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +13 -15
- package/dist/types/index.d.ts +13 -15
- package/dist/types/index.js +17 -15
- package/dist/types/index.js.map +1 -0
- package/dist/types/internal.cjs +2 -0
- package/dist/types/internal.cjs.map +1 -0
- package/dist/types/internal.d.cts +20 -22
- package/dist/types/internal.d.ts +20 -22
- package/dist/types/internal.js +2 -0
- package/dist/types/internal.js.map +1 -0
- package/dist/types/plugin.cjs +5 -3
- package/dist/types/plugin.cjs.map +1 -0
- package/dist/types/plugin.d.cts +9 -11
- package/dist/types/plugin.d.ts +9 -11
- package/dist/types/plugin.js +4 -2
- package/dist/types/plugin.js.map +1 -0
- package/dist/types/resolved.cjs +3 -1
- package/dist/types/resolved.cjs.map +1 -0
- package/dist/types/resolved.d.cts +7 -9
- package/dist/types/resolved.d.ts +7 -9
- package/dist/types/resolved.js +3 -1
- package/dist/types/resolved.js.map +1 -0
- package/dist/types/tsconfig.cjs +3 -1
- package/dist/types/tsconfig.cjs.map +1 -0
- package/dist/types/tsconfig.js +3 -1
- package/dist/types/tsconfig.js.map +1 -0
- package/dist/types/typedoc.cjs +3 -1
- package/dist/types/typedoc.cjs.map +1 -0
- package/dist/types/typedoc.js +3 -1
- package/dist/types/typedoc.js.map +1 -0
- package/dist/types/unplugin.cjs +3 -1
- package/dist/types/unplugin.cjs.map +1 -0
- package/dist/types/unplugin.d.cts +11 -13
- package/dist/types/unplugin.d.ts +11 -13
- package/dist/types/unplugin.js +3 -1
- package/dist/types/unplugin.js.map +1 -0
- package/dist/unloader.cjs +9 -7
- package/dist/unloader.d.cts +19 -21
- package/dist/unloader.d.ts +19 -21
- package/dist/unloader.js +8 -6
- package/dist/unplugin.cjs +20 -20
- package/dist/unplugin.d.cts +19 -21
- package/dist/unplugin.d.ts +19 -21
- package/dist/unplugin.js +10 -10
- package/dist/vite.cjs +13 -11
- package/dist/vite.d.cts +19 -21
- package/dist/vite.d.ts +19 -21
- package/dist/vite.js +10 -8
- package/dist/webpack.cjs +12 -10
- package/dist/webpack.d.cts +19 -21
- package/dist/webpack.d.ts +19 -21
- package/dist/webpack.js +9 -7
- package/package.json +78 -25
- package/schemas/fs.capnp +4 -59
- package/dist/chunk-2NO7N5OW.cjs +0 -2
- package/dist/chunk-7GYTTM4M.cjs +0 -2
- package/dist/chunk-AENPRFWJ.cjs +0 -2
- package/dist/chunk-AYKZK666.cjs +0 -8
- package/dist/chunk-BUR2JQ6G.cjs +0 -11
- package/dist/chunk-DRXFQCNC.js +0 -1
- package/dist/chunk-DTXP5O7S.cjs +0 -10
- package/dist/chunk-FNZDWE4L.js +0 -1
- package/dist/chunk-GHJU2KGP.cjs +0 -2
- package/dist/chunk-GRU7B3QM.cjs +0 -2
- package/dist/chunk-HQFZ64VC.cjs +0 -2
- package/dist/chunk-J4BQZHTQ.js +0 -1
- package/dist/chunk-JGB5YQ2U.js +0 -1
- package/dist/chunk-KALR2O2F.cjs +0 -2
- package/dist/chunk-OO3YXM72.js +0 -1
- package/dist/chunk-QE3WGMAP.js +0 -1
- package/dist/chunk-SMNKPH4T.js +0 -1
- package/dist/chunk-T2P533I5.js +0 -1
- package/dist/chunk-V3MLQDZQ.js +0 -1
- package/dist/chunk-VT7NVLLU.js +0 -5
- package/dist/chunk-YRJ4MLVL.cjs +0 -2
- package/dist/chunk-ZC43PZXS.cjs +0 -2
- package/dist/lib/chunk-3MZQ4MQX.cjs +0 -2360
- package/dist/lib/chunk-5JAFU45Z.js +0 -2324
- package/dist/lib/chunk-HAXL7QE7.js +0 -154
- package/dist/lib/chunk-SAS5EPBD.cjs +0 -107
- package/dist/lib/chunk-WUYK74EH.cjs +0 -165
- package/dist/lib/chunk-YQ3ODCHV.js +0 -105
- package/dist/lib/typescript/compiler-host.cjs +0 -164
- package/dist/lib/typescript/compiler-host.d.cts +0 -63
- package/dist/lib/typescript/compiler-host.d.ts +0 -63
- package/dist/lib/typescript/compiler-host.js +0 -156
- package/dist/lib/typescript/program.cjs +0 -27
- package/dist/lib/typescript/program.d.cts +0 -68
- package/dist/lib/typescript/program.d.ts +0 -68
- package/dist/lib/typescript/program.js +0 -2
- /package/dist/{chunk-2NCILNCH.cjs → lib/chunk-K2SFTPN3.cjs} +0 -0
- /package/dist/{chunk-BLNT5INX.js → lib/chunk-NQAHFTUW.js} +0 -0
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { PLUGIN_NON_HOOK_FIELDS } from './chunk-
|
|
2
|
-
import { SUPPORTED_COMMANDS } from './chunk-
|
|
3
|
-
import {
|
|
4
|
-
import { __name } from './chunk-
|
|
1
|
+
import { PLUGIN_NON_HOOK_FIELDS } from './chunk-57XOTOOZ.js';
|
|
2
|
+
import { SUPPORTED_COMMANDS } from './chunk-2MYPFASJ.js';
|
|
3
|
+
import { StoragePreset } from './chunk-JU2HWIWS.js';
|
|
4
|
+
import { __name } from './chunk-7QVYU63E.js';
|
|
5
5
|
import { transformAsync } from '@babel/core';
|
|
6
6
|
import { formatLogMessage } from '@storm-software/config-tools/logger/console';
|
|
7
7
|
import { LogLevelLabel } from '@storm-software/config-tools/types';
|
|
8
8
|
import { toArray } from '@stryke/convert/to-array';
|
|
9
9
|
import { copyFiles } from '@stryke/fs/copy-file';
|
|
10
|
+
import { createDirectory } from '@stryke/fs/helpers';
|
|
10
11
|
import { install } from '@stryke/fs/install';
|
|
11
|
-
import {
|
|
12
|
+
import { listFilesSync, listFiles } from '@stryke/fs/list-files';
|
|
12
13
|
import { isPackageExists, isPackageListed, doesPackageMatch, getPackageListing } from '@stryke/fs/package-fns';
|
|
13
|
-
import { getResolutionCombinations, resolve, resolveSync, resolvePackage } from '@stryke/fs/resolve';
|
|
14
|
+
import { getResolutionCombinations, resolve as resolve$1, resolveSync, resolvePackage } from '@stryke/fs/resolve';
|
|
14
15
|
import { appendPath } from '@stryke/path/append';
|
|
15
16
|
import { joinPaths as joinPaths$1 } from '@stryke/path/join-paths';
|
|
16
17
|
import { replacePath, replaceExtension } from '@stryke/path/replace';
|
|
@@ -26,15 +27,17 @@ import Handlebars from 'handlebars';
|
|
|
26
27
|
import { declare } from '@babel/helper-plugin-utils';
|
|
27
28
|
import * as t from '@babel/types';
|
|
28
29
|
import ts, { flattenDiagnosticMessageText } from 'typescript';
|
|
29
|
-
import
|
|
30
|
+
import { joinPaths } from '@stryke/path/join';
|
|
31
|
+
import defu7, { defu } from 'defu';
|
|
32
|
+
import { InMemoryFileSystemHost, Project } from 'ts-morph';
|
|
30
33
|
import { getPackageName, hasPackageVersion, getPackageVersion } from '@stryke/string-format/package';
|
|
31
34
|
import { getObjectDiff } from '@donedeal0/superdiff';
|
|
32
35
|
import { readJsonFile, readJsonFileSync } from '@stryke/fs/json';
|
|
33
36
|
import { StormJSON } from '@stryke/json/storm-json';
|
|
34
|
-
import { findFilePath,
|
|
37
|
+
import { hasFileExtension, findFilePath, findFileName, relativePath, findFileDotExtensionSafe } from '@stryke/path/file-path-fns';
|
|
35
38
|
import { titleCase } from '@stryke/string-format/title-case';
|
|
36
|
-
import { existsSync } from '@stryke/fs/exists';
|
|
37
|
-
import { writeFile as writeFile$1 } from '@stryke/fs/write-file';
|
|
39
|
+
import { existsSync, exists } from '@stryke/fs/exists';
|
|
40
|
+
import { writeFileSync, writeFile as writeFile$1 } from '@stryke/fs/write-file';
|
|
38
41
|
import { resolveConfig, format } from 'prettier';
|
|
39
42
|
import { getWorkspaceConfig } from '@storm-software/config-tools/get-config';
|
|
40
43
|
import { loadConfig } from 'c12';
|
|
@@ -45,7 +48,6 @@ import { murmurhash } from '@stryke/hash/murmurhash';
|
|
|
45
48
|
import { getUnique, getUniqueBy } from '@stryke/helpers/get-unique';
|
|
46
49
|
import { omit } from '@stryke/helpers/omit';
|
|
47
50
|
import { isAbsolutePath, isAbsolute } from '@stryke/path/is-type';
|
|
48
|
-
import { joinPaths } from '@stryke/path/join';
|
|
49
51
|
import { isNull } from '@stryke/type-checks/is-null';
|
|
50
52
|
import { isString } from '@stryke/type-checks/is-string';
|
|
51
53
|
import { uuid } from '@stryke/unique-id/uuid';
|
|
@@ -55,22 +57,20 @@ import { isUndefined } from '@stryke/type-checks/is-undefined';
|
|
|
55
57
|
import { parseTypeDefinition } from '@stryke/convert/parse-type-definition';
|
|
56
58
|
import { isFile } from '@stryke/fs/is-file';
|
|
57
59
|
import * as $ from '@stryke/capnp';
|
|
58
|
-
import { bufferToString } from '@stryke/convert/buffer-to-string';
|
|
59
60
|
import { readFileBuffer, readFileBufferSync, writeFileBuffer } from '@stryke/fs/buffer';
|
|
60
|
-
import {
|
|
61
|
+
import { correctPath, toAbsolutePath } from '@stryke/path/correct-path';
|
|
62
|
+
import { isParentPath } from '@stryke/path/is-parent-path';
|
|
61
63
|
import { prettyBytes } from '@stryke/string-format/pretty-bytes';
|
|
62
|
-
import { isBuffer } from '@stryke/type-checks/is-buffer';
|
|
63
64
|
import { create } from 'flat-cache';
|
|
64
65
|
import { Blob } from 'node:buffer';
|
|
65
|
-
import _fs from 'node:fs';
|
|
66
66
|
import { getLogFn, getLogLevel } from '@storm-software/config-tools/logger';
|
|
67
67
|
import { getColor } from '@storm-software/config-tools/utilities/colors';
|
|
68
68
|
import { noop } from '@stryke/helpers/noop';
|
|
69
69
|
import { slash } from '@stryke/path/slash';
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
70
|
+
import { readFileSync, readFile } from '@stryke/fs/read-file';
|
|
71
|
+
import { unlinkSync } from 'node:fs';
|
|
72
|
+
import { unlink } from 'node:fs/promises';
|
|
73
|
+
import { resolve } from 'node:path';
|
|
74
74
|
import '@stryke/fs/remove-file';
|
|
75
75
|
import { kebabCase } from '@stryke/string-format/kebab-case';
|
|
76
76
|
import { isObject } from '@stryke/type-checks/is-object';
|
|
@@ -176,6 +176,108 @@ var moduleResolverBabelPlugin = /* @__PURE__ */ __name((context) => {
|
|
|
176
176
|
};
|
|
177
177
|
}, "builder"));
|
|
178
178
|
}, "moduleResolverBabelPlugin");
|
|
179
|
+
var VirtualFileSystemHost = class extends InMemoryFileSystemHost {
|
|
180
|
+
static {
|
|
181
|
+
__name(this, "VirtualFileSystemHost");
|
|
182
|
+
}
|
|
183
|
+
#context;
|
|
184
|
+
constructor(context) {
|
|
185
|
+
super();
|
|
186
|
+
this.#context = context;
|
|
187
|
+
}
|
|
188
|
+
deleteSync(path) {
|
|
189
|
+
this.#context.fs.removeSync(path);
|
|
190
|
+
}
|
|
191
|
+
readDirSync(dirPath) {
|
|
192
|
+
return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {
|
|
193
|
+
const fullPath = this.#context.fs.resolveSync(joinPaths(dirPath, entry));
|
|
194
|
+
if (fullPath) {
|
|
195
|
+
ret.push({
|
|
196
|
+
name: entry,
|
|
197
|
+
isDirectory: this.#context.fs.existsSync(fullPath),
|
|
198
|
+
isFile: this.#context.fs.existsSync(fullPath),
|
|
199
|
+
isSymlink: false
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return ret;
|
|
203
|
+
}, []);
|
|
204
|
+
}
|
|
205
|
+
async readFile(filePath) {
|
|
206
|
+
if (!this.#context.fs.existsSync(filePath)) {
|
|
207
|
+
throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
|
|
208
|
+
}
|
|
209
|
+
return await this.#context.fs.read(filePath);
|
|
210
|
+
}
|
|
211
|
+
readFileSync(filePath) {
|
|
212
|
+
if (!this.#context.fs.existsSync(filePath)) {
|
|
213
|
+
throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
|
|
214
|
+
}
|
|
215
|
+
return this.#context.fs.readSync(filePath);
|
|
216
|
+
}
|
|
217
|
+
async writeFile(filePath, fileText) {
|
|
218
|
+
return this.#context.fs.write(filePath, fileText);
|
|
219
|
+
}
|
|
220
|
+
writeFileSync(filePath, fileText) {
|
|
221
|
+
this.#context.fs.writeSync(filePath, fileText);
|
|
222
|
+
}
|
|
223
|
+
async mkdir(_dirPath) {
|
|
224
|
+
}
|
|
225
|
+
mkdirSync(_dirPath) {
|
|
226
|
+
}
|
|
227
|
+
async move(srcPath, destPath) {
|
|
228
|
+
await this.#context.fs.move(srcPath, destPath);
|
|
229
|
+
}
|
|
230
|
+
moveSync(srcPath, destPath) {
|
|
231
|
+
this.#context.fs.moveSync(srcPath, destPath);
|
|
232
|
+
}
|
|
233
|
+
async copy(srcPath, destPath) {
|
|
234
|
+
await this.#context.fs.copy(srcPath, destPath);
|
|
235
|
+
}
|
|
236
|
+
copySync(srcPath, destPath) {
|
|
237
|
+
this.#context.fs.copySync(srcPath, destPath);
|
|
238
|
+
}
|
|
239
|
+
async fileExists(filePath) {
|
|
240
|
+
return this.#context.fs.exists(filePath);
|
|
241
|
+
}
|
|
242
|
+
fileExistsSync(filePath) {
|
|
243
|
+
return this.#context.fs.existsSync(filePath);
|
|
244
|
+
}
|
|
245
|
+
async directoryExists(dirPath) {
|
|
246
|
+
return this.#context.fs.exists(dirPath);
|
|
247
|
+
}
|
|
248
|
+
directoryExistsSync(dirPath) {
|
|
249
|
+
return this.#context.fs.existsSync(dirPath);
|
|
250
|
+
}
|
|
251
|
+
realpathSync(path) {
|
|
252
|
+
return this.#context.fs.resolveSync(path) || path;
|
|
253
|
+
}
|
|
254
|
+
getCurrentDirectory() {
|
|
255
|
+
return this.#context.workspaceConfig.workspaceRoot;
|
|
256
|
+
}
|
|
257
|
+
async glob(patterns) {
|
|
258
|
+
return this.#context.fs.glob(patterns);
|
|
259
|
+
}
|
|
260
|
+
globSync(patterns) {
|
|
261
|
+
return this.#context.fs.globSync(patterns);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
function createProgram(context, override) {
|
|
265
|
+
context.log(LogLevelLabel.TRACE, `Creating ts-morph Project instance with configuration from: ${context.tsconfig.tsconfigFilePath}.`);
|
|
266
|
+
const project = new Project(defu7(override ?? {}, {
|
|
267
|
+
skipAddingFilesFromTsConfig: false,
|
|
268
|
+
tsConfigFilePath: context.tsconfig.tsconfigFilePath,
|
|
269
|
+
fileSystem: new VirtualFileSystemHost(context),
|
|
270
|
+
compilerOptions: defu7(context.tsconfig.options ?? {}, {
|
|
271
|
+
lib: [
|
|
272
|
+
"lib.esnext.full.d.ts"
|
|
273
|
+
]
|
|
274
|
+
})
|
|
275
|
+
}));
|
|
276
|
+
return project;
|
|
277
|
+
}
|
|
278
|
+
__name(createProgram, "createProgram");
|
|
279
|
+
|
|
280
|
+
// src/internal/helpers/generate-types.ts
|
|
179
281
|
function formatTypes(code) {
|
|
180
282
|
return code.replace(
|
|
181
283
|
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
@@ -186,8 +288,11 @@ function formatTypes(code) {
|
|
|
186
288
|
__name(formatTypes, "formatTypes");
|
|
187
289
|
async function emitTypes(context, files) {
|
|
188
290
|
context.log(LogLevelLabel.TRACE, `Running the TypeScript compiler for ${files.length} generated runtime files.`);
|
|
189
|
-
|
|
190
|
-
|
|
291
|
+
const program = createProgram(context, {
|
|
292
|
+
skipAddingFilesFromTsConfig: true
|
|
293
|
+
});
|
|
294
|
+
program.addSourceFilesAtPaths(files);
|
|
295
|
+
const result = program.emitToMemory({
|
|
191
296
|
emitOnlyDtsFiles: true
|
|
192
297
|
});
|
|
193
298
|
let builtinModules = "";
|
|
@@ -390,7 +495,7 @@ function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfi
|
|
|
390
495
|
if (!tsconfigJson) {
|
|
391
496
|
throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${joinPaths$1(projectRoot, tsconfig ?? "tsconfig.json")}`);
|
|
392
497
|
}
|
|
393
|
-
const parsedCommandLine = ts.parseJsonConfigFileContent(
|
|
498
|
+
const parsedCommandLine = ts.parseJsonConfigFileContent(defu7(tsconfigRaw ?? {}, tsconfigJson), host, appendPath(projectRoot, workspaceRoot));
|
|
394
499
|
if (parsedCommandLine.errors.length > 0) {
|
|
395
500
|
const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:
|
|
396
501
|
${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && error.code ? `[${error.category}-${error.code}]: ` : "") + error.messageText.toString()}`).join("\n")}
|
|
@@ -431,9 +536,6 @@ async function resolveTsconfigChanges(context) {
|
|
|
431
536
|
const tsconfigJson = await readJsonFile(tsconfigFilePath);
|
|
432
537
|
tsconfigJson.compilerOptions ??= {};
|
|
433
538
|
if (context.config.output.dts !== false) {
|
|
434
|
-
if (findFileExtension(context.dtsPath) !== "d.ts" && findFileExtension(context.dtsPath) !== "d.cts" && findFileExtension(context.dtsPath) !== "d.mts") {
|
|
435
|
-
context.config.output.dts = joinPaths$1(context.dtsPath, "powerlines.d.ts");
|
|
436
|
-
}
|
|
437
539
|
const dtsRelativePath = joinPaths$1(relativePath(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot), findFilePath(context.dtsPath)), findFileName(context.dtsPath));
|
|
438
540
|
if (!tsconfigJson.include?.some((filePattern) => isIncludeMatchFound(filePattern, [
|
|
439
541
|
context.dtsPath,
|
|
@@ -476,9 +578,7 @@ async function initializeTsconfig(context) {
|
|
|
476
578
|
context.tsconfig.originalTsconfigJson = await readJsonFile(tsconfigFilePath);
|
|
477
579
|
context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
|
|
478
580
|
context.log(LogLevelLabel.TRACE, "Writing updated TypeScript configuration (tsconfig.json) file to disk.");
|
|
479
|
-
await context.
|
|
480
|
-
mode: "fs"
|
|
481
|
-
});
|
|
581
|
+
await writeFile(context.log, tsconfigFilePath, StormJSON.stringify(context.tsconfig.tsconfigJson));
|
|
482
582
|
context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
|
|
483
583
|
}
|
|
484
584
|
__name(initializeTsconfig, "initializeTsconfig");
|
|
@@ -538,7 +638,7 @@ async function resolveTsconfig(context) {
|
|
|
538
638
|
__name(resolveTsconfig, "resolveTsconfig");
|
|
539
639
|
var DEFAULT_ENVIRONMENT = "default";
|
|
540
640
|
function createEnvironment(name, userConfig) {
|
|
541
|
-
return
|
|
641
|
+
return defu7(userConfig.environments?.[name] ?? {}, {
|
|
542
642
|
name,
|
|
543
643
|
title: userConfig.title || titleCase(userConfig.name),
|
|
544
644
|
ssr: false,
|
|
@@ -582,7 +682,7 @@ function createDefaultEnvironment(userConfig) {
|
|
|
582
682
|
}
|
|
583
683
|
__name(createDefaultEnvironment, "createDefaultEnvironment");
|
|
584
684
|
async function loadWorkspaceConfig(workspaceRoot, cwd) {
|
|
585
|
-
return
|
|
685
|
+
return defu7({
|
|
586
686
|
workspaceRoot
|
|
587
687
|
}, await getWorkspaceConfig(true, {
|
|
588
688
|
cwd,
|
|
@@ -630,15 +730,14 @@ async function loadUserConfigFile(projectRoot, workspaceRoot, jiti, command, mod
|
|
|
630
730
|
dotenv: true,
|
|
631
731
|
jiti
|
|
632
732
|
});
|
|
633
|
-
return
|
|
733
|
+
return defu7(resolvedUserConfig, isSetObject(result?.config) ? {
|
|
634
734
|
...result.config,
|
|
635
735
|
...result
|
|
636
736
|
} : {});
|
|
637
737
|
}
|
|
638
738
|
__name(loadUserConfigFile, "loadUserConfigFile");
|
|
639
739
|
function resolveOptions(options) {
|
|
640
|
-
return
|
|
641
|
-
debug: options.logLevel === "trace",
|
|
740
|
+
return defu7(options, {
|
|
642
741
|
interopDefault: true,
|
|
643
742
|
fsCache: options.mode !== "development" ? joinPaths$1(options.cacheDir, "jiti") : false,
|
|
644
743
|
moduleCache: options.mode !== "development"
|
|
@@ -714,7 +813,7 @@ function replacePathTokens(context, path) {
|
|
|
714
813
|
if (!path) {
|
|
715
814
|
return path;
|
|
716
815
|
}
|
|
717
|
-
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{
|
|
816
|
+
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
718
817
|
}
|
|
719
818
|
__name(replacePathTokens, "replacePathTokens");
|
|
720
819
|
function resolveEntryInputFile(context, typeDefinition) {
|
|
@@ -765,19 +864,6 @@ function getUniqueEntries(entries = []) {
|
|
|
765
864
|
}
|
|
766
865
|
__name(getUniqueEntries, "getUniqueEntries");
|
|
767
866
|
var _capnpFileId = BigInt("0xa56c61324b9d6e49");
|
|
768
|
-
var FileType = {
|
|
769
|
-
NORMAL: 0,
|
|
770
|
-
BUILTIN: 1,
|
|
771
|
-
ENTRY: 2,
|
|
772
|
-
CHUNK: 3,
|
|
773
|
-
PREBUILT: 4,
|
|
774
|
-
ASSET: 5
|
|
775
|
-
};
|
|
776
|
-
var PreserveSignatureType = {
|
|
777
|
-
STRICT: 0,
|
|
778
|
-
ALLOW_EXTENSION: 1,
|
|
779
|
-
EXPORTS_ONLY: 2
|
|
780
|
-
};
|
|
781
867
|
var FileMetadata_KeyValuePair = class extends $.Struct {
|
|
782
868
|
static {
|
|
783
869
|
__name(this, "FileMetadata_KeyValuePair");
|
|
@@ -811,7 +897,7 @@ var FileMetadata = class _FileMetadata extends $.Struct {
|
|
|
811
897
|
static _capnp = {
|
|
812
898
|
displayName: "FileMetadata",
|
|
813
899
|
id: "8e2cab5d7e28c7b3",
|
|
814
|
-
size: new $.ObjectSize(8,
|
|
900
|
+
size: new $.ObjectSize(8, 3),
|
|
815
901
|
defaultType: "normal"
|
|
816
902
|
};
|
|
817
903
|
static _Properties;
|
|
@@ -826,7 +912,7 @@ var FileMetadata = class _FileMetadata extends $.Struct {
|
|
|
826
912
|
$.utils.setText(0, value, this);
|
|
827
913
|
}
|
|
828
914
|
/**
|
|
829
|
-
* The
|
|
915
|
+
* The timestamp representing the file's creation date.
|
|
830
916
|
*
|
|
831
917
|
*/
|
|
832
918
|
get type() {
|
|
@@ -836,16 +922,6 @@ var FileMetadata = class _FileMetadata extends $.Struct {
|
|
|
836
922
|
$.utils.setText(1, value, this);
|
|
837
923
|
}
|
|
838
924
|
/**
|
|
839
|
-
* The timestamp representing the file's creation date.
|
|
840
|
-
*
|
|
841
|
-
*/
|
|
842
|
-
get mode() {
|
|
843
|
-
return $.utils.getText(2, this);
|
|
844
|
-
}
|
|
845
|
-
set mode(value) {
|
|
846
|
-
$.utils.setText(2, value, this);
|
|
847
|
-
}
|
|
848
|
-
/**
|
|
849
925
|
* Additional metadata associated with the file.
|
|
850
926
|
*
|
|
851
927
|
*/
|
|
@@ -856,22 +932,22 @@ var FileMetadata = class _FileMetadata extends $.Struct {
|
|
|
856
932
|
$.utils.setUint32(0, value, this);
|
|
857
933
|
}
|
|
858
934
|
_adoptProperties(value) {
|
|
859
|
-
$.utils.adopt(value, $.utils.getPointer(
|
|
935
|
+
$.utils.adopt(value, $.utils.getPointer(2, this));
|
|
860
936
|
}
|
|
861
937
|
_disownProperties() {
|
|
862
938
|
return $.utils.disown(this.properties);
|
|
863
939
|
}
|
|
864
940
|
get properties() {
|
|
865
|
-
return $.utils.getList(
|
|
941
|
+
return $.utils.getList(2, _FileMetadata._Properties, this);
|
|
866
942
|
}
|
|
867
943
|
_hasProperties() {
|
|
868
|
-
return !$.utils.isNull($.utils.getPointer(
|
|
944
|
+
return !$.utils.isNull($.utils.getPointer(2, this));
|
|
869
945
|
}
|
|
870
946
|
_initProperties(length) {
|
|
871
|
-
return $.utils.initList(
|
|
947
|
+
return $.utils.initList(2, _FileMetadata._Properties, length, this);
|
|
872
948
|
}
|
|
873
949
|
set properties(value) {
|
|
874
|
-
$.utils.copyFrom(value, $.utils.getPointer(
|
|
950
|
+
$.utils.copyFrom(value, $.utils.getPointer(2, this));
|
|
875
951
|
}
|
|
876
952
|
toString() {
|
|
877
953
|
return "FileMetadata_" + super.toString();
|
|
@@ -906,13 +982,13 @@ var FileId = class extends $.Struct {
|
|
|
906
982
|
return "FileId_" + super.toString();
|
|
907
983
|
}
|
|
908
984
|
};
|
|
909
|
-
var
|
|
985
|
+
var FileStorage = class extends $.Struct {
|
|
910
986
|
static {
|
|
911
|
-
__name(this, "
|
|
987
|
+
__name(this, "FileStorage");
|
|
912
988
|
}
|
|
913
989
|
static _capnp = {
|
|
914
|
-
displayName: "
|
|
915
|
-
id: "
|
|
990
|
+
displayName: "FileStorage",
|
|
991
|
+
id: "9dca66ac858c9ebe",
|
|
916
992
|
size: new $.ObjectSize(0, 2)
|
|
917
993
|
};
|
|
918
994
|
/**
|
|
@@ -932,7 +1008,7 @@ var FileData = class extends $.Struct {
|
|
|
932
1008
|
$.utils.setText(1, value, this);
|
|
933
1009
|
}
|
|
934
1010
|
toString() {
|
|
935
|
-
return "
|
|
1011
|
+
return "FileStorage_" + super.toString();
|
|
936
1012
|
}
|
|
937
1013
|
};
|
|
938
1014
|
var FileSystem = class _FileSystem extends $.Struct {
|
|
@@ -945,7 +1021,7 @@ var FileSystem = class _FileSystem extends $.Struct {
|
|
|
945
1021
|
size: new $.ObjectSize(0, 3)
|
|
946
1022
|
};
|
|
947
1023
|
static _Ids;
|
|
948
|
-
static
|
|
1024
|
+
static _Storage;
|
|
949
1025
|
static _Metadata;
|
|
950
1026
|
_adoptIds(value) {
|
|
951
1027
|
$.utils.adopt(value, $.utils.getPointer(0, this));
|
|
@@ -965,22 +1041,22 @@ var FileSystem = class _FileSystem extends $.Struct {
|
|
|
965
1041
|
set ids(value) {
|
|
966
1042
|
$.utils.copyFrom(value, $.utils.getPointer(0, this));
|
|
967
1043
|
}
|
|
968
|
-
|
|
1044
|
+
_adoptStorage(value) {
|
|
969
1045
|
$.utils.adopt(value, $.utils.getPointer(1, this));
|
|
970
1046
|
}
|
|
971
|
-
|
|
972
|
-
return $.utils.disown(this.
|
|
1047
|
+
_disownStorage() {
|
|
1048
|
+
return $.utils.disown(this.storage);
|
|
973
1049
|
}
|
|
974
|
-
get
|
|
975
|
-
return $.utils.getList(1, _FileSystem.
|
|
1050
|
+
get storage() {
|
|
1051
|
+
return $.utils.getList(1, _FileSystem._Storage, this);
|
|
976
1052
|
}
|
|
977
|
-
|
|
1053
|
+
_hasStorage() {
|
|
978
1054
|
return !$.utils.isNull($.utils.getPointer(1, this));
|
|
979
1055
|
}
|
|
980
|
-
|
|
981
|
-
return $.utils.initList(1, _FileSystem.
|
|
1056
|
+
_initStorage(length) {
|
|
1057
|
+
return $.utils.initList(1, _FileSystem._Storage, length, this);
|
|
982
1058
|
}
|
|
983
|
-
set
|
|
1059
|
+
set storage(value) {
|
|
984
1060
|
$.utils.copyFrom(value, $.utils.getPointer(1, this));
|
|
985
1061
|
}
|
|
986
1062
|
_adoptMetadata(value) {
|
|
@@ -1007,7 +1083,7 @@ var FileSystem = class _FileSystem extends $.Struct {
|
|
|
1007
1083
|
};
|
|
1008
1084
|
FileMetadata._Properties = $.CompositeList(FileMetadata_KeyValuePair);
|
|
1009
1085
|
FileSystem._Ids = $.CompositeList(FileId);
|
|
1010
|
-
FileSystem.
|
|
1086
|
+
FileSystem._Storage = $.CompositeList(FileStorage);
|
|
1011
1087
|
FileSystem._Metadata = $.CompositeList(FileMetadata);
|
|
1012
1088
|
var createLog = /* @__PURE__ */ __name((name, options = {}) => {
|
|
1013
1089
|
const logLevel = options.logLevel === null ? LogLevelLabel.SILENT : options.logLevel || LogLevelLabel.INFO;
|
|
@@ -1047,142 +1123,18 @@ var BADGE_COLORS = [
|
|
|
1047
1123
|
var extendLog = /* @__PURE__ */ __name((logFn, name) => {
|
|
1048
1124
|
return (type, ...args) => logFn(type, ` ${chalk5.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
|
|
1049
1125
|
}, "extendLog");
|
|
1050
|
-
function
|
|
1051
|
-
return
|
|
1052
|
-
}
|
|
1053
|
-
__name(isBufferEncoding, "isBufferEncoding");
|
|
1054
|
-
function isPowerlinesWriteFileOptions(options) {
|
|
1055
|
-
return !isBufferEncoding(options) && isSetObject(options) && "mode" in options && (options.mode === "fs" || options.mode === "virtual");
|
|
1126
|
+
function isFileError(err) {
|
|
1127
|
+
return isError(err) && "code" in err && err.code;
|
|
1056
1128
|
}
|
|
1057
|
-
__name(
|
|
1058
|
-
function
|
|
1059
|
-
return
|
|
1129
|
+
__name(isFileError, "isFileError");
|
|
1130
|
+
function ignoreNotfound(err) {
|
|
1131
|
+
return isFileError(err) && (err.code === "ENOENT" || err.code === "EISDIR" ? null : err);
|
|
1060
1132
|
}
|
|
1061
|
-
__name(
|
|
1133
|
+
__name(ignoreNotfound, "ignoreNotfound");
|
|
1062
1134
|
function toFilePath(path) {
|
|
1063
1135
|
return correctPath(slash(path?.toString() || ".").replace(/^file:\/\//, ""));
|
|
1064
1136
|
}
|
|
1065
1137
|
__name(toFilePath, "toFilePath");
|
|
1066
|
-
var FS_METHODS = [
|
|
1067
|
-
"mkdir",
|
|
1068
|
-
"mkdirSync",
|
|
1069
|
-
"rmdir",
|
|
1070
|
-
"rmdirSync",
|
|
1071
|
-
"unlink",
|
|
1072
|
-
"unlinkSync",
|
|
1073
|
-
"existsSync",
|
|
1074
|
-
"realpathSync",
|
|
1075
|
-
"writeFileSync",
|
|
1076
|
-
"readFileSync",
|
|
1077
|
-
"readdirSync",
|
|
1078
|
-
"createWriteStream",
|
|
1079
|
-
"WriteStream",
|
|
1080
|
-
"createReadStream",
|
|
1081
|
-
"ReadStream"
|
|
1082
|
-
];
|
|
1083
|
-
var FS_PROMISE_METHODS = [
|
|
1084
|
-
"mkdir",
|
|
1085
|
-
"rm",
|
|
1086
|
-
"rmdir",
|
|
1087
|
-
"unlink",
|
|
1088
|
-
"writeFile",
|
|
1089
|
-
"readFile",
|
|
1090
|
-
"readdir",
|
|
1091
|
-
"stat",
|
|
1092
|
-
"lstat"
|
|
1093
|
-
];
|
|
1094
|
-
function cloneFS(originalFS) {
|
|
1095
|
-
const clonedFS = {
|
|
1096
|
-
...originalFS,
|
|
1097
|
-
promises: {
|
|
1098
|
-
...originalFS.promises ?? {}
|
|
1099
|
-
}
|
|
1100
|
-
};
|
|
1101
|
-
for (const method of FS_METHODS) {
|
|
1102
|
-
if (originalFS[method]) {
|
|
1103
|
-
clonedFS[method] = originalFS[method];
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
originalFS.promises ??= {};
|
|
1107
|
-
for (const method of FS_PROMISE_METHODS) {
|
|
1108
|
-
if (originalFS.promises[method]) {
|
|
1109
|
-
clonedFS.promises ??= {};
|
|
1110
|
-
clonedFS.promises[method] = originalFS.promises[method];
|
|
1111
|
-
clonedFS[method] = originalFS.promises[method];
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
for (const prop in clonedFS) {
|
|
1115
|
-
if (isFunction(clonedFS[prop])) {
|
|
1116
|
-
clonedFS[prop] = clonedFS[prop].bind(originalFS);
|
|
1117
|
-
if (isFunction(clonedFS.promises[prop])) {
|
|
1118
|
-
clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
for (const prop in clonedFS.promises) {
|
|
1123
|
-
if (isFunction(clonedFS.promises[prop])) {
|
|
1124
|
-
clonedFS.promises[prop] = clonedFS.promises[prop].bind(originalFS);
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
return clonedFS;
|
|
1128
|
-
}
|
|
1129
|
-
__name(cloneFS, "cloneFS");
|
|
1130
|
-
function patchFS(originalFS, vfs) {
|
|
1131
|
-
const clonedFS = cloneFS(originalFS);
|
|
1132
|
-
originalFS.mkdirSync = (file, options) => vfs.mkdirSync(toFilePath(file), options);
|
|
1133
|
-
originalFS.mkdir = (file, options, callback) => vfs.mkdir(toFilePath(file), options, callback);
|
|
1134
|
-
originalFS.promises.mkdir = async (file, options) => vfs.mkdir(toFilePath(file), options);
|
|
1135
|
-
originalFS.unlinkSync = (file) => vfs.unlinkSync(toFilePath(file));
|
|
1136
|
-
originalFS.promises.rm = async (file, options) => vfs.rm(toFilePath(file), options);
|
|
1137
|
-
originalFS.promises.unlink = async (file) => vfs.unlink(toFilePath(file));
|
|
1138
|
-
originalFS.existsSync = (file) => vfs.existsSync(toFilePath(file));
|
|
1139
|
-
Object.defineProperty(originalFS, "realpathSync", {
|
|
1140
|
-
value: /* @__PURE__ */ __name((file, options) => vfs.realpathSync(toFilePath(file), options), "value")
|
|
1141
|
-
});
|
|
1142
|
-
originalFS.writeFileSync = (file, data, options) => vfs.writeFileSync(toFilePath(file), data, options);
|
|
1143
|
-
originalFS.promises.writeFile = async (file, data, options) => vfs.writeFile(toFilePath(file), data, options);
|
|
1144
|
-
originalFS.readFileSync = (file, options) => vfs.readFileSync(toFilePath(file), options);
|
|
1145
|
-
originalFS.promises.readFile = (file, options) => vfs.readFile(toFilePath(file), options);
|
|
1146
|
-
originalFS.readdirSync = (file, options) => vfs.readdirSync(toFilePath(file), options);
|
|
1147
|
-
originalFS.promises.readdir = (file, options) => vfs.readdir(toFilePath(file), options);
|
|
1148
|
-
Object.defineProperty(originalFS, "statSync", {
|
|
1149
|
-
value: /* @__PURE__ */ __name((file, options) => vfs.statSync(toFilePath(file), options), "value")
|
|
1150
|
-
});
|
|
1151
|
-
originalFS.stat = (file, options) => vfs.statSync(toFilePath(file), options);
|
|
1152
|
-
originalFS.promises.stat = (file, options) => vfs.stat(toFilePath(file), options);
|
|
1153
|
-
Object.defineProperty(originalFS, "lstatSync", {
|
|
1154
|
-
value: /* @__PURE__ */ __name((file, options) => vfs.lstatSync(toFilePath(file), options), "value")
|
|
1155
|
-
});
|
|
1156
|
-
originalFS.lstat = (file, options) => vfs.lstatSync(toFilePath(file), options);
|
|
1157
|
-
originalFS.promises.lstat = (file, options) => vfs.lstat(toFilePath(file), options);
|
|
1158
|
-
return () => {
|
|
1159
|
-
originalFS.mkdirSync = clonedFS.mkdirSync;
|
|
1160
|
-
originalFS.mkdir = clonedFS.mkdir;
|
|
1161
|
-
originalFS.promises.mkdir = clonedFS.promises.mkdir;
|
|
1162
|
-
originalFS.unlinkSync = clonedFS.unlinkSync;
|
|
1163
|
-
originalFS.promises.rm = clonedFS.promises.rm;
|
|
1164
|
-
originalFS.promises.unlink = clonedFS.promises.unlink;
|
|
1165
|
-
originalFS.existsSync = clonedFS.existsSync;
|
|
1166
|
-
originalFS.realpathSync = clonedFS.realpathSync;
|
|
1167
|
-
originalFS.writeFileSync = clonedFS.writeFileSync;
|
|
1168
|
-
originalFS.promises.writeFile = clonedFS.promises.writeFile;
|
|
1169
|
-
originalFS.readFileSync = clonedFS.readFileSync;
|
|
1170
|
-
originalFS.promises.readFile = clonedFS.promises.readFile;
|
|
1171
|
-
originalFS.readdirSync = clonedFS.readdirSync;
|
|
1172
|
-
originalFS.promises.readdir = clonedFS.promises.readdir;
|
|
1173
|
-
Object.defineProperty(originalFS, "statSync", {
|
|
1174
|
-
value: clonedFS.statSync
|
|
1175
|
-
});
|
|
1176
|
-
originalFS.stat = clonedFS.stat;
|
|
1177
|
-
originalFS.promises.stat = clonedFS.promises.stat;
|
|
1178
|
-
Object.defineProperty(originalFS, "lstatSync", {
|
|
1179
|
-
value: clonedFS.lstatSync
|
|
1180
|
-
});
|
|
1181
|
-
originalFS.lstat = clonedFS.lstat;
|
|
1182
|
-
originalFS.promises.lstat = clonedFS.promises.lstat;
|
|
1183
|
-
};
|
|
1184
|
-
}
|
|
1185
|
-
__name(patchFS, "patchFS");
|
|
1186
1138
|
function isValidId(id, prefix = "powerlines") {
|
|
1187
1139
|
return id.replace(/^\\0/, "").startsWith(`${prefix.replace(/:$/, "")}`);
|
|
1188
1140
|
}
|
|
@@ -1192,164 +1144,368 @@ function normalizeId(id, prefix = "powerlines") {
|
|
|
1192
1144
|
}
|
|
1193
1145
|
__name(normalizeId, "normalizeId");
|
|
1194
1146
|
function normalizePath(path, builtinsPath, prefix = "powerlines") {
|
|
1195
|
-
return isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
|
|
1147
|
+
return isAbsolutePath(path) ? path : isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
|
|
1196
1148
|
}
|
|
1197
1149
|
__name(normalizePath, "normalizePath");
|
|
1198
|
-
|
|
1150
|
+
function normalizeKey(key, sep = ":") {
|
|
1151
|
+
if (!key) {
|
|
1152
|
+
return "";
|
|
1153
|
+
}
|
|
1154
|
+
return key.replace(/[:/\\]/g, sep).replace(/^[:/\\]|[:/\\]$/g, "");
|
|
1155
|
+
}
|
|
1156
|
+
__name(normalizeKey, "normalizeKey");
|
|
1157
|
+
function filterKeyByBase(key, base) {
|
|
1158
|
+
if (base) {
|
|
1159
|
+
return key.startsWith(base) && key[key.length - 1] !== "$";
|
|
1160
|
+
}
|
|
1161
|
+
return key[key.length - 1] !== "$";
|
|
1162
|
+
}
|
|
1163
|
+
__name(filterKeyByBase, "filterKeyByBase");
|
|
1164
|
+
var BaseStorageAdapter = class {
|
|
1199
1165
|
static {
|
|
1200
|
-
__name(this, "
|
|
1166
|
+
__name(this, "BaseStorageAdapter");
|
|
1201
1167
|
}
|
|
1202
1168
|
/**
|
|
1203
|
-
*
|
|
1169
|
+
* Indicates whether the storage adapter has been disposed.
|
|
1204
1170
|
*/
|
|
1205
|
-
#
|
|
1171
|
+
#isDisposed = false;
|
|
1206
1172
|
/**
|
|
1207
|
-
*
|
|
1173
|
+
* Configuration options for the storage adapter.
|
|
1208
1174
|
*/
|
|
1209
|
-
|
|
1175
|
+
options;
|
|
1210
1176
|
/**
|
|
1211
|
-
*
|
|
1177
|
+
* Constructor for the BaseStorageAdapter.
|
|
1178
|
+
*
|
|
1179
|
+
* @param options - Configuration options for the storage adapter.
|
|
1212
1180
|
*/
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
}
|
|
1220
|
-
return result;
|
|
1181
|
+
constructor(options = {
|
|
1182
|
+
base: "/"
|
|
1183
|
+
}) {
|
|
1184
|
+
this.options = options;
|
|
1185
|
+
this.options.base = resolve(options.base);
|
|
1186
|
+
this.options.isReadOnly = !!options.isReadOnly;
|
|
1221
1187
|
}
|
|
1222
1188
|
/**
|
|
1223
|
-
*
|
|
1189
|
+
* Asynchronously checks if a key exists in the storage.
|
|
1190
|
+
*
|
|
1191
|
+
* @param key - The key to check for existence.
|
|
1192
|
+
* @returns A promise that resolves to `true` if the key exists, otherwise `false`.
|
|
1224
1193
|
*/
|
|
1225
|
-
|
|
1226
|
-
return this
|
|
1194
|
+
async exists(key) {
|
|
1195
|
+
return this.existsSync(key);
|
|
1227
1196
|
}
|
|
1228
1197
|
/**
|
|
1229
|
-
*
|
|
1198
|
+
* Asynchronously retrieves the value associated with a given key.
|
|
1199
|
+
*
|
|
1200
|
+
* @param key - The key whose value is to be retrieved.
|
|
1201
|
+
* @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.
|
|
1230
1202
|
*/
|
|
1231
|
-
get
|
|
1232
|
-
return this
|
|
1203
|
+
async get(key) {
|
|
1204
|
+
return this.getSync(key);
|
|
1233
1205
|
}
|
|
1234
1206
|
/**
|
|
1235
|
-
*
|
|
1207
|
+
* Asynchronously sets the value for a given key.
|
|
1236
1208
|
*
|
|
1237
|
-
* @param
|
|
1238
|
-
* @param
|
|
1209
|
+
* @param key - The key to set the value for.
|
|
1210
|
+
* @param value - The value to set.
|
|
1239
1211
|
*/
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
if (!this.#physicalFS.existsSync(this.#context.dataPath)) {
|
|
1244
|
-
this.#physicalFS.mkdirSync(this.#context.dataPath, {
|
|
1245
|
-
recursive: true
|
|
1246
|
-
});
|
|
1212
|
+
async set(key, value) {
|
|
1213
|
+
if (!this.options.isReadOnly) {
|
|
1214
|
+
this.setSync(key, value);
|
|
1247
1215
|
}
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Asynchronously removes a key from the storage.
|
|
1219
|
+
*
|
|
1220
|
+
* @param key - The key to remove.
|
|
1221
|
+
*/
|
|
1222
|
+
async remove(key) {
|
|
1223
|
+
if (!this.options.isReadOnly) {
|
|
1224
|
+
this.removeSync(key);
|
|
1257
1225
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
this.#virtualFS.mkdirSync(this.#context.builtinsPath, {
|
|
1270
|
-
recursive: true
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
|
-
if (!this.#virtualFS.existsSync(this.#context.entryPath)) {
|
|
1274
|
-
this.#virtualFS.mkdirSync(this.#context.entryPath, {
|
|
1275
|
-
recursive: true
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
|
-
if (!this.#virtualFS.existsSync(this.#context.dtsPath)) {
|
|
1279
|
-
this.#virtualFS.mkdirSync(this.#context.dtsPath, {
|
|
1280
|
-
recursive: true
|
|
1281
|
-
});
|
|
1282
|
-
}
|
|
1283
|
-
} else if (this.#context.config.projectType === "application") {
|
|
1284
|
-
if (!this.#physicalFS.existsSync(this.#context.artifactsPath)) {
|
|
1285
|
-
this.#physicalFS.mkdirSync(this.#context.artifactsPath, {
|
|
1286
|
-
recursive: true
|
|
1287
|
-
});
|
|
1288
|
-
}
|
|
1289
|
-
if (!this.#physicalFS.existsSync(this.#context.builtinsPath)) {
|
|
1290
|
-
this.#physicalFS.mkdirSync(this.#context.builtinsPath, {
|
|
1291
|
-
recursive: true
|
|
1292
|
-
});
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Synchronously removes all entries from the storage that match the provided base path.
|
|
1229
|
+
*
|
|
1230
|
+
* @param base - The base path to clear keys from.
|
|
1231
|
+
*/
|
|
1232
|
+
clearSync(base) {
|
|
1233
|
+
if (!this.options.isReadOnly) {
|
|
1234
|
+
const keys = this.listSync(base || this.options.base);
|
|
1235
|
+
if (!keys.length) {
|
|
1236
|
+
return;
|
|
1293
1237
|
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1238
|
+
keys.map((key) => this.removeSync(base && !key.startsWith(base) ? joinPaths(base, key) : key));
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Asynchronously removes all entries from the storage that match the provided base path.
|
|
1243
|
+
*
|
|
1244
|
+
* @param base - The base path to clear keys from.
|
|
1245
|
+
* @returns A promise that resolves when the operation is complete.
|
|
1246
|
+
*/
|
|
1247
|
+
async clear(base) {
|
|
1248
|
+
if (!this.options.isReadOnly) {
|
|
1249
|
+
const keys = await this.list(base || this.options.base);
|
|
1250
|
+
if (!keys.length) {
|
|
1251
|
+
return;
|
|
1298
1252
|
}
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1253
|
+
await Promise.all(keys.map(async (key) => this.remove(base && !key.startsWith(base) ? joinPaths(base, key) : key)));
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
/**
|
|
1257
|
+
* Asynchronously lists all keys under a given base path.
|
|
1258
|
+
*
|
|
1259
|
+
* @param base - The base path to list keys from.
|
|
1260
|
+
* @returns A promise that resolves to an array of keys under the specified base path.
|
|
1261
|
+
*/
|
|
1262
|
+
async list(base) {
|
|
1263
|
+
return this.listSync(base);
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Disposes of the storage adapter, releasing any held resources.
|
|
1267
|
+
*
|
|
1268
|
+
* @returns A promise that resolves when the disposal is complete.
|
|
1269
|
+
*/
|
|
1270
|
+
dispose() {
|
|
1271
|
+
return Promise.resolve();
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Async dispose method to clean up resources.
|
|
1275
|
+
*
|
|
1276
|
+
* @returns A promise that resolves when disposal is complete.
|
|
1277
|
+
*/
|
|
1278
|
+
async [Symbol.asyncDispose]() {
|
|
1279
|
+
return this._dispose();
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Resolves a given key to its full path within the storage adapter.
|
|
1283
|
+
*
|
|
1284
|
+
* @param key - The key to resolve.
|
|
1285
|
+
* @returns The resolved full path for the key.
|
|
1286
|
+
*/
|
|
1287
|
+
resolve(key = this.options.base) {
|
|
1288
|
+
if (/\.\.:|\.\.$/.test(key)) {
|
|
1289
|
+
throw new Error(`[${this.name}]: Invalid key: ${JSON.stringify(key)} provided to storage adapter.`);
|
|
1290
|
+
}
|
|
1291
|
+
return appendPath(correctPath(key).replace(/:/g, "/"), this.options.base);
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Disposes of the storage adapter, releasing any held resources.
|
|
1295
|
+
*
|
|
1296
|
+
* @returns A promise that resolves when the disposal is complete.
|
|
1297
|
+
*/
|
|
1298
|
+
async _dispose() {
|
|
1299
|
+
if (!this.#isDisposed) {
|
|
1300
|
+
await Promise.resolve(this.dispose());
|
|
1301
|
+
this.#isDisposed = true;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1306
|
+
// src/lib/fs/storage/file-system.ts
|
|
1307
|
+
var FileSystemStorageAdapter = class extends BaseStorageAdapter {
|
|
1308
|
+
static {
|
|
1309
|
+
__name(this, "FileSystemStorageAdapter");
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* A name identifying the storage adapter type.
|
|
1313
|
+
*/
|
|
1314
|
+
name = "file-system";
|
|
1315
|
+
/**
|
|
1316
|
+
* Constructor for the FileSystemStorageAdapter.
|
|
1317
|
+
*
|
|
1318
|
+
* @param options - Configuration options for the storage adapter.
|
|
1319
|
+
*/
|
|
1320
|
+
constructor(options) {
|
|
1321
|
+
super(options);
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Synchronously checks if a key exists in the storage.
|
|
1325
|
+
*
|
|
1326
|
+
* @param key - The key to check for existence.
|
|
1327
|
+
* @returns Returns `true` if the key exists, otherwise `false`.
|
|
1328
|
+
*/
|
|
1329
|
+
existsSync(key) {
|
|
1330
|
+
return existsSync(this.resolve(key));
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Asynchronously checks if a key exists in the storage.
|
|
1334
|
+
*
|
|
1335
|
+
* @param key - The key to check for existence.
|
|
1336
|
+
* @returns A promise that resolves to `true` if the key exists, otherwise `false`.
|
|
1337
|
+
*/
|
|
1338
|
+
async exists(key) {
|
|
1339
|
+
return exists(this.resolve(key));
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Synchronously retrieves the value associated with a given key.
|
|
1343
|
+
*
|
|
1344
|
+
* @param key - The key whose value is to be retrieved.
|
|
1345
|
+
* @returns The value associated with the key, or `null` if the key does not exist.
|
|
1346
|
+
*/
|
|
1347
|
+
getSync(key) {
|
|
1348
|
+
return readFileSync(this.resolve(key));
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Asynchronously retrieves the value associated with a given key.
|
|
1352
|
+
*
|
|
1353
|
+
* @param key - The key whose value is to be retrieved.
|
|
1354
|
+
* @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.
|
|
1355
|
+
*/
|
|
1356
|
+
async get(key) {
|
|
1357
|
+
return readFile(this.resolve(key));
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Synchronously sets the value for a given key.
|
|
1361
|
+
*
|
|
1362
|
+
* @param key - The key to set the value for.
|
|
1363
|
+
* @param value - The value to set.
|
|
1364
|
+
*/
|
|
1365
|
+
setSync(key, value) {
|
|
1366
|
+
if (!this.options.isReadOnly) {
|
|
1367
|
+
return writeFileSync(this.resolve(key), value);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Asynchronously sets the value for a given key.
|
|
1372
|
+
*
|
|
1373
|
+
* @param key - The key to set the value for.
|
|
1374
|
+
* @param value - The value to set.
|
|
1375
|
+
*/
|
|
1376
|
+
async set(key, value) {
|
|
1377
|
+
if (!this.options.isReadOnly) {
|
|
1378
|
+
return writeFile$1(this.resolve(key), value);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Synchronously removes a key from the storage.
|
|
1383
|
+
*
|
|
1384
|
+
* @param key - The key to remove.
|
|
1385
|
+
*/
|
|
1386
|
+
removeSync(key) {
|
|
1387
|
+
if (!this.options.isReadOnly) {
|
|
1388
|
+
try {
|
|
1389
|
+
return unlinkSync(this.resolve(key));
|
|
1390
|
+
} catch (err) {
|
|
1391
|
+
return ignoreNotfound(err);
|
|
1303
1392
|
}
|
|
1304
1393
|
}
|
|
1305
1394
|
}
|
|
1306
1395
|
/**
|
|
1307
|
-
*
|
|
1396
|
+
* Asynchronously removes a key from the storage.
|
|
1308
1397
|
*
|
|
1309
|
-
* @param
|
|
1310
|
-
* @param options - Options for the operation, such as output mode.
|
|
1311
|
-
* @returns The file system module used for the operation.
|
|
1398
|
+
* @param key - The key to remove.
|
|
1312
1399
|
*/
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
return {
|
|
1317
|
-
...this.#virtualFS,
|
|
1318
|
-
mode: "virtual"
|
|
1319
|
-
};
|
|
1320
|
-
} else if (mode === "fs") {
|
|
1321
|
-
return {
|
|
1322
|
-
...this.#physicalFS,
|
|
1323
|
-
mode: "fs"
|
|
1324
|
-
};
|
|
1400
|
+
async remove(key) {
|
|
1401
|
+
if (!this.options.isReadOnly) {
|
|
1402
|
+
return unlink(this.resolve(key)).catch(ignoreNotfound);
|
|
1325
1403
|
}
|
|
1326
|
-
return {
|
|
1327
|
-
...this,
|
|
1328
|
-
mode: this.#context.config.output.mode
|
|
1329
|
-
};
|
|
1330
1404
|
}
|
|
1331
1405
|
/**
|
|
1332
|
-
*
|
|
1406
|
+
* Lists all keys under a given base path synchronously.
|
|
1333
1407
|
*
|
|
1334
|
-
* @param
|
|
1335
|
-
* @
|
|
1336
|
-
* @returns The file system module used for the operation.
|
|
1408
|
+
* @param base - The base path to list keys from.
|
|
1409
|
+
* @returns An array of keys under the specified base path.
|
|
1337
1410
|
*/
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
return
|
|
1341
|
-
|
|
1342
|
-
|
|
1411
|
+
listSync(base) {
|
|
1412
|
+
try {
|
|
1413
|
+
return listFilesSync(this.resolve(base), {
|
|
1414
|
+
ignore: this.options.ignore
|
|
1415
|
+
});
|
|
1416
|
+
} catch (err) {
|
|
1417
|
+
return ignoreNotfound(err) ?? [];
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Asynchronously lists all keys under a given base path.
|
|
1422
|
+
*
|
|
1423
|
+
* @param base - The base path to list keys from.
|
|
1424
|
+
* @returns A promise that resolves to an array of keys under the specified base path.
|
|
1425
|
+
*/
|
|
1426
|
+
async list(base) {
|
|
1427
|
+
return listFiles(this.resolve(base), {
|
|
1428
|
+
ignore: this.options.ignore
|
|
1429
|
+
}).catch(ignoreNotfound).then((r) => r || []);
|
|
1430
|
+
}
|
|
1431
|
+
};
|
|
1432
|
+
var VirtualStorageAdapter = class extends BaseStorageAdapter {
|
|
1433
|
+
static {
|
|
1434
|
+
__name(this, "VirtualStorageAdapter");
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* A name identifying the storage adapter type.
|
|
1438
|
+
*/
|
|
1439
|
+
name = "virtual";
|
|
1440
|
+
/**
|
|
1441
|
+
* In-memory data storage.
|
|
1442
|
+
*/
|
|
1443
|
+
data = /* @__PURE__ */ new Map();
|
|
1444
|
+
/**
|
|
1445
|
+
* Constructor for the VirtualStorageAdapter.
|
|
1446
|
+
*
|
|
1447
|
+
* @param options - Configuration options for the storage adapter.
|
|
1448
|
+
*/
|
|
1449
|
+
constructor(options) {
|
|
1450
|
+
super(options);
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Synchronously checks if a key exists in the storage.
|
|
1454
|
+
*
|
|
1455
|
+
* @param key - The key to check for existence.
|
|
1456
|
+
* @returns Returns `true` if the key exists, otherwise `false`.
|
|
1457
|
+
*/
|
|
1458
|
+
existsSync(key) {
|
|
1459
|
+
return this.data.has(this.resolve(key));
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Synchronously retrieves the value associated with a given key.
|
|
1463
|
+
*
|
|
1464
|
+
* @param key - The key whose value is to be retrieved.
|
|
1465
|
+
* @returns The value associated with the key, or `null` if the key does not exist.
|
|
1466
|
+
*/
|
|
1467
|
+
getSync(key) {
|
|
1468
|
+
return this.data.get(this.resolve(key)) ?? null;
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Synchronously sets the value for a given key.
|
|
1472
|
+
*
|
|
1473
|
+
* @param key - The key to set the value for.
|
|
1474
|
+
* @param value - The value to set.
|
|
1475
|
+
*/
|
|
1476
|
+
setSync(key, value) {
|
|
1477
|
+
if (!this.options.isReadOnly) {
|
|
1478
|
+
this.data.set(this.resolve(key), value);
|
|
1343
1479
|
}
|
|
1344
|
-
return void 0;
|
|
1345
1480
|
}
|
|
1346
1481
|
/**
|
|
1347
|
-
*
|
|
1482
|
+
* Synchronously removes a key from the storage.
|
|
1348
1483
|
*
|
|
1349
|
-
* @
|
|
1484
|
+
* @param key - The key to remove.
|
|
1350
1485
|
*/
|
|
1351
|
-
|
|
1352
|
-
|
|
1486
|
+
removeSync(key) {
|
|
1487
|
+
if (!this.options.isReadOnly) {
|
|
1488
|
+
this.data.delete(this.resolve(key));
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Lists all keys under a given base path synchronously.
|
|
1493
|
+
*
|
|
1494
|
+
* @param base - The base path to list keys from.
|
|
1495
|
+
* @returns An array of keys under the specified base path.
|
|
1496
|
+
*/
|
|
1497
|
+
listSync(base) {
|
|
1498
|
+
return [
|
|
1499
|
+
...this.data.keys().filter((key) => !base ? true : isParentPath(key, this.resolve(base)))
|
|
1500
|
+
];
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Disposes of the storage adapter, releasing any held resources.
|
|
1504
|
+
*
|
|
1505
|
+
* @returns A promise that resolves when the disposal is complete.
|
|
1506
|
+
*/
|
|
1507
|
+
async dispose() {
|
|
1508
|
+
return this.clear();
|
|
1353
1509
|
}
|
|
1354
1510
|
};
|
|
1355
1511
|
|
|
@@ -1371,29 +1527,23 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1371
1527
|
*/
|
|
1372
1528
|
#paths;
|
|
1373
1529
|
/**
|
|
1374
|
-
* A cache for module resolution results.
|
|
1375
|
-
*/
|
|
1376
|
-
#resolverCache;
|
|
1377
|
-
/**
|
|
1378
1530
|
* The unified volume that combines the virtual file system with the real file system.
|
|
1379
1531
|
*
|
|
1380
1532
|
* @remarks
|
|
1381
1533
|
* This volume allows for seamless access to both virtual and real files.
|
|
1382
1534
|
*/
|
|
1383
|
-
#
|
|
1535
|
+
#storage = {
|
|
1536
|
+
"": new FileSystemStorageAdapter()
|
|
1537
|
+
};
|
|
1384
1538
|
/**
|
|
1385
|
-
*
|
|
1539
|
+
* A cache for module resolution results.
|
|
1386
1540
|
*/
|
|
1387
|
-
#
|
|
1541
|
+
#resolverCache;
|
|
1388
1542
|
/**
|
|
1389
1543
|
* Indicator specifying if the virtual file system (VFS) is disposed
|
|
1390
1544
|
*/
|
|
1391
1545
|
#isDisposed = false;
|
|
1392
1546
|
/**
|
|
1393
|
-
* Function to revert require patch
|
|
1394
|
-
*/
|
|
1395
|
-
#revert;
|
|
1396
|
-
/**
|
|
1397
1547
|
* The context of the virtual file system.
|
|
1398
1548
|
*/
|
|
1399
1549
|
#context;
|
|
@@ -1402,15 +1552,6 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1402
1552
|
*/
|
|
1403
1553
|
#log;
|
|
1404
1554
|
/**
|
|
1405
|
-
* Checks if a path exists in the virtual file system (VFS).
|
|
1406
|
-
*
|
|
1407
|
-
* @param path - The path to check.
|
|
1408
|
-
* @returns `true` if the path exists, otherwise `false`.
|
|
1409
|
-
*/
|
|
1410
|
-
#existsSync(path) {
|
|
1411
|
-
return this.#unifiedFS.virtual.existsSync(this.#normalizePath(path)) || this.#unifiedFS.physical.existsSync(this.#normalizePath(path)) || this.#unifiedFS.resolveFS(path).existsSync(this.#normalizePath(path));
|
|
1412
|
-
}
|
|
1413
|
-
/**
|
|
1414
1555
|
* Normalizes a given module id by resolving it against the built-ins path.
|
|
1415
1556
|
*
|
|
1416
1557
|
* @param id - The module id to normalize.
|
|
@@ -1439,6 +1580,43 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1439
1580
|
return new RegExp(`^${this.#normalizePath(path).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
|
|
1440
1581
|
}
|
|
1441
1582
|
/**
|
|
1583
|
+
* Gets the storage adapter and relative key for a given key.
|
|
1584
|
+
*
|
|
1585
|
+
* @param key - The key to get the storage adapter for.
|
|
1586
|
+
* @returns The storage adapter and relative key for the given key.
|
|
1587
|
+
*/
|
|
1588
|
+
#getStorage(key) {
|
|
1589
|
+
const path = this.resolveSync(this.#normalizePath(key)) || key;
|
|
1590
|
+
for (const base of Object.keys(this.#storage).filter(Boolean).sort().reverse()) {
|
|
1591
|
+
if (isParentPath(path, base)) {
|
|
1592
|
+
return {
|
|
1593
|
+
base,
|
|
1594
|
+
relativeKey: replacePath(path, base),
|
|
1595
|
+
adapter: this.#storage[base]
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
return {
|
|
1600
|
+
base: "",
|
|
1601
|
+
relativeKey: path,
|
|
1602
|
+
adapter: this.#storage[""]
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* Gets all storage adapters that match a given base key.
|
|
1607
|
+
*
|
|
1608
|
+
* @param base - The base key to match storage adapters against.
|
|
1609
|
+
* @param includeParent - Whether to include parent storage adapters.
|
|
1610
|
+
* @returns An array of storage adapters that match the given base key.
|
|
1611
|
+
*/
|
|
1612
|
+
#getStorages(base = "", includeParent = false) {
|
|
1613
|
+
return Object.keys(this.#storage).sort().reverse().filter((key) => isParentPath(key, base) || includeParent && isParentPath(base, key)).map((key) => ({
|
|
1614
|
+
relativeBase: base.length > key.length ? base.slice(key.length) : void 0,
|
|
1615
|
+
base: key,
|
|
1616
|
+
adapter: this.#storage[key]
|
|
1617
|
+
}));
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1442
1620
|
* Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
|
|
1443
1621
|
*
|
|
1444
1622
|
* @param context - The context of the virtual file system, typically containing options and logging functions.
|
|
@@ -1448,7 +1626,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1448
1626
|
if (!context.config.skipCache && existsSync(joinPaths$1(context.dataPath, "fs.bin"))) {
|
|
1449
1627
|
const buffer = await readFileBuffer(joinPaths$1(context.dataPath, "fs.bin"));
|
|
1450
1628
|
const message2 = new $.Message(buffer, false);
|
|
1451
|
-
|
|
1629
|
+
const fs = message2.getRoot(FileSystem);
|
|
1630
|
+
const result = new _VirtualFileSystem(context, fs);
|
|
1631
|
+
if (fs._hasStorage() && fs.storage.length > 0) {
|
|
1632
|
+
await Promise.all(fs.storage.values().map(async (file) => {
|
|
1633
|
+
await result.write(file.path, file.code);
|
|
1634
|
+
}));
|
|
1635
|
+
}
|
|
1452
1636
|
}
|
|
1453
1637
|
const message = new $.Message();
|
|
1454
1638
|
return new _VirtualFileSystem(context, message.initRoot(FileSystem));
|
|
@@ -1463,7 +1647,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1463
1647
|
if (!context.config.skipCache && existsSync(joinPaths$1(context.dataPath, "fs.bin"))) {
|
|
1464
1648
|
const buffer = readFileBufferSync(joinPaths$1(context.dataPath, "fs.bin"));
|
|
1465
1649
|
const message2 = new $.Message(buffer, false);
|
|
1466
|
-
|
|
1650
|
+
const fs = message2.getRoot(FileSystem);
|
|
1651
|
+
const result = new _VirtualFileSystem(context, fs);
|
|
1652
|
+
if (fs._hasStorage() && fs.storage.length > 0) {
|
|
1653
|
+
fs.storage.values().map((file) => {
|
|
1654
|
+
result.writeSync(file.path, file.code);
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1467
1657
|
}
|
|
1468
1658
|
const message = new $.Message();
|
|
1469
1659
|
return new _VirtualFileSystem(context, message.initRoot(FileSystem));
|
|
@@ -1498,6 +1688,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1498
1688
|
}, "get")
|
|
1499
1689
|
});
|
|
1500
1690
|
}
|
|
1691
|
+
/**
|
|
1692
|
+
* Gets the resolver cache.
|
|
1693
|
+
*/
|
|
1501
1694
|
get resolverCache() {
|
|
1502
1695
|
if (!this.#resolverCache) {
|
|
1503
1696
|
this.#resolverCache = create({
|
|
@@ -1516,16 +1709,34 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1516
1709
|
* @param context - The context of the virtual file system, typically containing options and logging functions.
|
|
1517
1710
|
* @param fs - A buffer containing the serialized virtual file system data.
|
|
1518
1711
|
*/
|
|
1519
|
-
constructor(context,
|
|
1712
|
+
constructor(context, fs) {
|
|
1520
1713
|
this.#context = context;
|
|
1521
|
-
this.#
|
|
1714
|
+
if (isSetObject(this.#context.config.output.storage)) {
|
|
1715
|
+
this.#storage = {
|
|
1716
|
+
...this.#storage,
|
|
1717
|
+
...this.#context.config.output.storage
|
|
1718
|
+
};
|
|
1719
|
+
}
|
|
1720
|
+
this.#storage.virtual ??= new VirtualStorageAdapter({
|
|
1721
|
+
base: "/_virtual"
|
|
1722
|
+
});
|
|
1723
|
+
if (this.#context.config.output.storage !== StoragePreset.FS) {
|
|
1724
|
+
this.#storage[this.#context.artifactsPath] ??= new VirtualStorageAdapter({
|
|
1725
|
+
base: this.#context.artifactsPath
|
|
1726
|
+
});
|
|
1727
|
+
this.#storage[this.#context.builtinsPath] ??= new VirtualStorageAdapter({
|
|
1728
|
+
base: this.#context.builtinsPath
|
|
1729
|
+
});
|
|
1730
|
+
this.#storage[this.#context.entryPath] ??= new VirtualStorageAdapter({
|
|
1731
|
+
base: this.#context.entryPath
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1522
1734
|
this.#metadata = {};
|
|
1523
|
-
if (
|
|
1524
|
-
this.#metadata =
|
|
1735
|
+
if (fs._hasMetadata()) {
|
|
1736
|
+
this.#metadata = fs.metadata.values().reduce((ret, metadata) => {
|
|
1525
1737
|
ret[metadata.id] = {
|
|
1526
1738
|
id: metadata.id,
|
|
1527
1739
|
type: metadata.type,
|
|
1528
|
-
mode: metadata.mode,
|
|
1529
1740
|
timestamp: metadata.timestamp || Date.now(),
|
|
1530
1741
|
properties: metadata._hasProperties() ? metadata.properties.values().reduce((ret2, item) => {
|
|
1531
1742
|
ret2[item.key] = item.value;
|
|
@@ -1537,12 +1748,12 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1537
1748
|
}
|
|
1538
1749
|
this.#ids = {};
|
|
1539
1750
|
this.#paths = {};
|
|
1540
|
-
if (
|
|
1541
|
-
this.#ids =
|
|
1751
|
+
if (fs._hasIds()) {
|
|
1752
|
+
this.#ids = fs.ids.values().reduce((ret, identifier) => {
|
|
1542
1753
|
ret[identifier.path] ??= identifier.id;
|
|
1543
1754
|
return ret;
|
|
1544
1755
|
}, {});
|
|
1545
|
-
this.#paths =
|
|
1756
|
+
this.#paths = fs.ids.values().reduce((ret, identifier) => {
|
|
1546
1757
|
ret[identifier.id] ??= identifier.path;
|
|
1547
1758
|
return ret;
|
|
1548
1759
|
}, {});
|
|
@@ -1550,187 +1761,123 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1550
1761
|
this.#log = extendLog(this.#context.log, "file-system");
|
|
1551
1762
|
}
|
|
1552
1763
|
/**
|
|
1553
|
-
*
|
|
1764
|
+
* Asynchronously checks if a file exists in the virtual file system (VFS).
|
|
1554
1765
|
*
|
|
1555
|
-
* @param
|
|
1556
|
-
* @returns
|
|
1557
|
-
*/
|
|
1558
|
-
isVirtual(pathOrId, importer, options = {}) {
|
|
1559
|
-
if (!pathOrId) {
|
|
1560
|
-
return false;
|
|
1561
|
-
}
|
|
1562
|
-
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
1563
|
-
if (!resolvedPath) {
|
|
1564
|
-
return false;
|
|
1565
|
-
}
|
|
1566
|
-
return this.metadata[resolvedPath]?.mode === "virtual";
|
|
1567
|
-
}
|
|
1568
|
-
/**
|
|
1569
|
-
* Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
1570
|
-
*
|
|
1571
|
-
* @param pathOrId - The path or id to check.
|
|
1572
|
-
* @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
1573
|
-
*/
|
|
1574
|
-
isPhysical(pathOrId, importer, options = {}) {
|
|
1575
|
-
if (!pathOrId) {
|
|
1576
|
-
return false;
|
|
1577
|
-
}
|
|
1578
|
-
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
1579
|
-
if (!resolvedPath) {
|
|
1580
|
-
return false;
|
|
1581
|
-
}
|
|
1582
|
-
return this.metadata[resolvedPath]?.mode === "fs";
|
|
1583
|
-
}
|
|
1584
|
-
/**
|
|
1585
|
-
* Lists files in a given path.
|
|
1586
|
-
*
|
|
1587
|
-
* @param path - The path to list files from.
|
|
1588
|
-
* @param options - Options for listing files, such as encoding and recursion.
|
|
1589
|
-
* @returns An array of file names in the specified path.
|
|
1590
|
-
*/
|
|
1591
|
-
readdirSync(path, options = "utf8") {
|
|
1592
|
-
return this.#unifiedFS.resolveFS(path).readdirSync(toFilePath(path), options);
|
|
1593
|
-
}
|
|
1594
|
-
/**
|
|
1595
|
-
* Removes a file in the virtual file system (VFS).
|
|
1596
|
-
*
|
|
1597
|
-
* @param path - The path to create the directory at.
|
|
1598
|
-
*/
|
|
1599
|
-
unlinkSync(path, options) {
|
|
1600
|
-
if (!this.isFile(this.#normalizePath(path))) {
|
|
1601
|
-
return;
|
|
1602
|
-
}
|
|
1603
|
-
this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${this.#normalizePath(path)}`);
|
|
1604
|
-
this.#unifiedFS.resolveFS(path, options).unlinkSync(this.#normalizePath(path));
|
|
1605
|
-
if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
|
|
1606
|
-
delete this.#metadata[this.#ids[this.#normalizePath(path)]];
|
|
1607
|
-
delete this.#ids[this.#normalizePath(path)];
|
|
1608
|
-
delete this.#paths[this.#normalizeId(path)];
|
|
1609
|
-
this.#resolverCache.delete(this.#normalizePath(path));
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
/**
|
|
1613
|
-
* Removes a file in the virtual file system (VFS).
|
|
1614
|
-
*
|
|
1615
|
-
* @param path - The path to create the directory at.
|
|
1766
|
+
* @param path - The path to the file.
|
|
1767
|
+
* @returns A promise that resolves to `true` if the file exists, otherwise `false`.
|
|
1616
1768
|
*/
|
|
1617
|
-
async
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
}
|
|
1621
|
-
this.#log(LogLevelLabel.TRACE, `Removing file: ${this.#normalizePath(path)}`);
|
|
1622
|
-
if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
|
|
1623
|
-
await this.#unifiedFS.resolveFS(path, options).promises.unlink(this.#normalizePath(path));
|
|
1624
|
-
if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
|
|
1625
|
-
delete this.#metadata[this.#ids[this.#normalizePath(path)]];
|
|
1626
|
-
}
|
|
1627
|
-
} else {
|
|
1628
|
-
this.unlinkSync(this.#normalizePath(path), options);
|
|
1629
|
-
}
|
|
1769
|
+
async exists(path) {
|
|
1770
|
+
const { relativeKey, adapter } = this.#getStorage(path);
|
|
1771
|
+
return adapter.exists(relativeKey);
|
|
1630
1772
|
}
|
|
1631
1773
|
/**
|
|
1632
|
-
*
|
|
1774
|
+
* Synchronously checks if a file exists in the virtual file system (VFS).
|
|
1633
1775
|
*
|
|
1634
|
-
* @param path - The path to
|
|
1635
|
-
* @
|
|
1776
|
+
* @param path - The path to the file.
|
|
1777
|
+
* @returns `true` if the file exists, otherwise `false`.
|
|
1636
1778
|
*/
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
}
|
|
1641
|
-
this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${this.#normalizePath(path)}`);
|
|
1642
|
-
this.#unifiedFS.resolveFS(path, options).rmdirSync(this.#normalizePath(path), defu6(options, {
|
|
1643
|
-
recursive: true
|
|
1644
|
-
}));
|
|
1779
|
+
existsSync(path) {
|
|
1780
|
+
const { relativeKey, adapter } = this.#getStorage(path);
|
|
1781
|
+
return adapter.existsSync(relativeKey);
|
|
1645
1782
|
}
|
|
1646
1783
|
/**
|
|
1647
|
-
*
|
|
1784
|
+
* Checks if a file is virtual in the virtual file system (VFS).
|
|
1648
1785
|
*
|
|
1649
|
-
* @param path - The path to
|
|
1650
|
-
* @
|
|
1651
|
-
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
1786
|
+
* @param path - The path to the file.
|
|
1787
|
+
* @returns `true` if the file is virtual, otherwise `false`.
|
|
1652
1788
|
*/
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
this.#log(LogLevelLabel.TRACE, `Removing directory: ${this.#normalizePath(path)}`);
|
|
1658
|
-
if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
|
|
1659
|
-
await this.#unifiedFS.resolveFS(path, options).promises.rm(this.#normalizePath(path), defu6(options, {
|
|
1660
|
-
force: true,
|
|
1661
|
-
recursive: true
|
|
1662
|
-
}));
|
|
1663
|
-
} else {
|
|
1664
|
-
this.rmdirSync(this.#normalizePath(path), defu6(options ?? {}, {
|
|
1665
|
-
force: true,
|
|
1666
|
-
recursive: true
|
|
1667
|
-
}));
|
|
1789
|
+
isVirtual(path) {
|
|
1790
|
+
const resolved = this.resolveSync(path);
|
|
1791
|
+
if (!resolved) {
|
|
1792
|
+
return false;
|
|
1668
1793
|
}
|
|
1794
|
+
return this.#getStorage(resolved)?.adapter?.name === "virtual";
|
|
1669
1795
|
}
|
|
1670
1796
|
/**
|
|
1671
|
-
*
|
|
1797
|
+
* Lists files in a given path.
|
|
1672
1798
|
*
|
|
1673
|
-
* @param path - The path to
|
|
1674
|
-
* @
|
|
1675
|
-
* @returns A promise that resolves when the file is removed.
|
|
1799
|
+
* @param path - The path to list files from.
|
|
1800
|
+
* @returns An array of file names in the specified path.
|
|
1676
1801
|
*/
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1802
|
+
listSync(path) {
|
|
1803
|
+
let maskedMounts = [];
|
|
1804
|
+
const allKeys = [];
|
|
1805
|
+
for (const storage of this.#getStorages(path, true)) {
|
|
1806
|
+
for (const key of storage.adapter.listSync(storage.relativeBase)) {
|
|
1807
|
+
if (!maskedMounts.some((p) => `${storage.base}${normalizeKey(key)}`.startsWith(p))) {
|
|
1808
|
+
allKeys.push(`${storage.base}${normalizeKey(key)}`);
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
maskedMounts = [
|
|
1812
|
+
storage.base,
|
|
1813
|
+
...maskedMounts.filter((p) => !p.startsWith(storage.base))
|
|
1814
|
+
];
|
|
1681
1815
|
}
|
|
1682
|
-
return
|
|
1816
|
+
return allKeys.filter((key) => filterKeyByBase(key, path));
|
|
1683
1817
|
}
|
|
1684
1818
|
/**
|
|
1685
|
-
*
|
|
1819
|
+
* Lists files in a given path.
|
|
1686
1820
|
*
|
|
1687
|
-
* @param path - The path to
|
|
1688
|
-
* @
|
|
1821
|
+
* @param path - The path to list files from.
|
|
1822
|
+
* @returns An array of file names in the specified path.
|
|
1689
1823
|
*/
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1824
|
+
async list(path) {
|
|
1825
|
+
let maskedMounts = [];
|
|
1826
|
+
const allKeys = [];
|
|
1827
|
+
for (const storage of this.#getStorages(path, true)) {
|
|
1828
|
+
for (const key of await storage.adapter.list(storage.relativeBase)) {
|
|
1829
|
+
if (!maskedMounts.some((p) => `${storage.base}${normalizeKey(key)}`.startsWith(p))) {
|
|
1830
|
+
allKeys.push(`${storage.base}${normalizeKey(key)}`);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
maskedMounts = [
|
|
1834
|
+
storage.base,
|
|
1835
|
+
...maskedMounts.filter((p) => !p.startsWith(storage.base))
|
|
1836
|
+
];
|
|
1694
1837
|
}
|
|
1695
|
-
return
|
|
1838
|
+
return allKeys.filter((key) => filterKeyByBase(key, path));
|
|
1696
1839
|
}
|
|
1697
1840
|
/**
|
|
1698
|
-
*
|
|
1841
|
+
* Removes a file in the virtual file system (VFS).
|
|
1699
1842
|
*
|
|
1700
1843
|
* @param path - The path to create the directory at.
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1844
|
+
*/
|
|
1845
|
+
async remove(path) {
|
|
1846
|
+
const normalizedPath = this.#normalizePath(path);
|
|
1847
|
+
this.#log(LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
|
|
1848
|
+
const { relativeKey, adapter } = this.#getStorage(normalizedPath);
|
|
1849
|
+
if (hasFileExtension(normalizedPath)) {
|
|
1850
|
+
await adapter.remove(relativeKey);
|
|
1851
|
+
} else {
|
|
1852
|
+
await adapter.clear(relativeKey);
|
|
1853
|
+
}
|
|
1854
|
+
const id = this.#ids[normalizedPath];
|
|
1855
|
+
if (id && this.#metadata[id]) {
|
|
1856
|
+
delete this.#metadata[id];
|
|
1857
|
+
delete this.#ids[normalizedPath];
|
|
1858
|
+
delete this.#paths[id];
|
|
1859
|
+
}
|
|
1710
1860
|
}
|
|
1711
1861
|
/**
|
|
1712
|
-
*
|
|
1862
|
+
* Removes a file in the virtual file system (VFS).
|
|
1713
1863
|
*
|
|
1714
1864
|
* @param path - The path to create the directory at.
|
|
1715
|
-
* @param options - Options for creating the directory.
|
|
1716
|
-
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
1717
1865
|
*/
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
recursive: true
|
|
1725
|
-
}));
|
|
1866
|
+
removeSync(path) {
|
|
1867
|
+
const normalizedPath = this.#normalizePath(path);
|
|
1868
|
+
this.#log(LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
|
|
1869
|
+
const { relativeKey, adapter } = this.#getStorage(normalizedPath);
|
|
1870
|
+
if (hasFileExtension(normalizedPath)) {
|
|
1871
|
+
adapter.removeSync(relativeKey);
|
|
1726
1872
|
} else {
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1873
|
+
adapter.clearSync(relativeKey);
|
|
1874
|
+
}
|
|
1875
|
+
const id = this.#ids[normalizedPath];
|
|
1876
|
+
if (id && this.#metadata[id]) {
|
|
1877
|
+
delete this.#metadata[id];
|
|
1878
|
+
delete this.#ids[normalizedPath];
|
|
1879
|
+
delete this.#paths[id];
|
|
1732
1880
|
}
|
|
1733
|
-
return result;
|
|
1734
1881
|
}
|
|
1735
1882
|
/**
|
|
1736
1883
|
* Glob files in the virtual file system (VFS) based on the provided pattern(s).
|
|
@@ -1752,38 +1899,14 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1752
1899
|
const absPattern = isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
1753
1900
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
1754
1901
|
const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
let entries = [];
|
|
1761
|
-
try {
|
|
1762
|
-
entries = await this.readdir(dir);
|
|
1763
|
-
} catch {
|
|
1764
|
-
continue;
|
|
1765
|
-
}
|
|
1766
|
-
for (const entry of entries) {
|
|
1767
|
-
const full = this.#normalizePath(joinPaths$1(dir, entry));
|
|
1768
|
-
let stats;
|
|
1769
|
-
try {
|
|
1770
|
-
stats = this.#unifiedFS.lstatSync(full);
|
|
1771
|
-
} catch {
|
|
1772
|
-
stats = void 0;
|
|
1773
|
-
}
|
|
1774
|
-
if (!stats) continue;
|
|
1775
|
-
if (stats.isDirectory()) {
|
|
1776
|
-
stack.push(full);
|
|
1777
|
-
} else if (stats.isFile()) {
|
|
1778
|
-
if (this.#buildRegex(absPattern).test(full)) {
|
|
1779
|
-
const resolved = this.resolveSync(full);
|
|
1780
|
-
if (resolved && !results.includes(resolved)) {
|
|
1781
|
-
results.push(resolved);
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1902
|
+
await Promise.all((await this.list(baseDir && isAbsolutePath(baseDir) ? baseDir : this.#context.workspaceConfig.workspaceRoot)).map(async (file) => {
|
|
1903
|
+
if (this.#buildRegex(absPattern).test(file)) {
|
|
1904
|
+
const resolved = this.resolveSync(file);
|
|
1905
|
+
if (resolved && !results.includes(resolved)) {
|
|
1906
|
+
results.push(resolved);
|
|
1784
1907
|
}
|
|
1785
1908
|
}
|
|
1786
|
-
}
|
|
1909
|
+
}));
|
|
1787
1910
|
}
|
|
1788
1911
|
return results;
|
|
1789
1912
|
}
|
|
@@ -1807,35 +1930,12 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1807
1930
|
const absPattern = isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
1808
1931
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
1809
1932
|
const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
1810
|
-
const
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
try {
|
|
1817
|
-
entries = this.readdirSync(dir);
|
|
1818
|
-
} catch {
|
|
1819
|
-
continue;
|
|
1820
|
-
}
|
|
1821
|
-
for (const entry of entries) {
|
|
1822
|
-
const full = this.#normalizePath(joinPaths$1(dir, entry));
|
|
1823
|
-
let stats;
|
|
1824
|
-
try {
|
|
1825
|
-
stats = this.#unifiedFS.lstatSync(full);
|
|
1826
|
-
} catch {
|
|
1827
|
-
stats = void 0;
|
|
1828
|
-
}
|
|
1829
|
-
if (!stats) continue;
|
|
1830
|
-
if (stats.isDirectory()) {
|
|
1831
|
-
stack.push(full);
|
|
1832
|
-
} else if (stats.isFile()) {
|
|
1833
|
-
if (this.#buildRegex(absPattern).test(full)) {
|
|
1834
|
-
const resolved = this.resolveSync(full);
|
|
1835
|
-
if (resolved && !results.includes(resolved)) {
|
|
1836
|
-
results.push(resolved);
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1933
|
+
const files = this.listSync(baseDir && isAbsolutePath(baseDir) ? baseDir : this.#context.workspaceConfig.workspaceRoot);
|
|
1934
|
+
for (const file of files) {
|
|
1935
|
+
if (this.#buildRegex(absPattern).test(file)) {
|
|
1936
|
+
const resolved = this.resolveSync(file);
|
|
1937
|
+
if (resolved && !results.includes(resolved)) {
|
|
1938
|
+
results.push(resolved);
|
|
1839
1939
|
}
|
|
1840
1940
|
}
|
|
1841
1941
|
}
|
|
@@ -1843,36 +1943,27 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1843
1943
|
return results;
|
|
1844
1944
|
}
|
|
1845
1945
|
/**
|
|
1846
|
-
* Moves a file from one path to another in the virtual file system (VFS).
|
|
1847
|
-
*
|
|
1848
|
-
* @param srcPath - The source path to move
|
|
1849
|
-
* @param destPath - The destination path to move to
|
|
1850
|
-
*/
|
|
1851
|
-
async move(srcPath, destPath) {
|
|
1852
|
-
const content = await this.readFile(srcPath);
|
|
1853
|
-
await this.writeFile(destPath, content);
|
|
1854
|
-
await this.rm(srcPath);
|
|
1855
|
-
}
|
|
1856
|
-
/**
|
|
1857
|
-
* Synchronously moves a file from one path to another in the virtual file system (VFS).
|
|
1858
|
-
*
|
|
1859
|
-
* @param srcPath - The source path to move
|
|
1860
|
-
* @param destPath - The destination path to move to
|
|
1861
|
-
*/
|
|
1862
|
-
moveSync(srcPath, destPath) {
|
|
1863
|
-
const content = this.readFileSync(srcPath);
|
|
1864
|
-
this.writeFileSync(destPath, content);
|
|
1865
|
-
this.rmSync(srcPath);
|
|
1866
|
-
}
|
|
1867
|
-
/**
|
|
1868
1946
|
* Copies a file from one path to another in the virtual file system (VFS).
|
|
1869
1947
|
*
|
|
1870
1948
|
* @param srcPath - The source path to copy
|
|
1871
1949
|
* @param destPath - The destination path to copy to
|
|
1872
1950
|
*/
|
|
1873
1951
|
async copy(srcPath, destPath) {
|
|
1874
|
-
|
|
1875
|
-
|
|
1952
|
+
if (hasFileExtension(srcPath)) {
|
|
1953
|
+
const content = await this.read(srcPath);
|
|
1954
|
+
if (content !== void 0) {
|
|
1955
|
+
await this.write(hasFileExtension(destPath) ? destPath : joinPaths$1(destPath, findFileName(srcPath)), content);
|
|
1956
|
+
}
|
|
1957
|
+
} else {
|
|
1958
|
+
await Promise.all((await this.list(srcPath)).map(async (file) => {
|
|
1959
|
+
const relativePath2 = file.replace(this.#normalizePath(srcPath), "");
|
|
1960
|
+
const destinationPath = this.#normalizePath(appendPath(destPath, relativePath2));
|
|
1961
|
+
const content = await this.read(file);
|
|
1962
|
+
if (content !== void 0) {
|
|
1963
|
+
await this.write(destinationPath, content);
|
|
1964
|
+
}
|
|
1965
|
+
}));
|
|
1966
|
+
}
|
|
1876
1967
|
}
|
|
1877
1968
|
/**
|
|
1878
1969
|
* Synchronously copies a file from one path to another in the virtual file system (VFS).
|
|
@@ -1881,51 +1972,85 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1881
1972
|
* @param destPath - The destination path to copy to
|
|
1882
1973
|
*/
|
|
1883
1974
|
copySync(srcPath, destPath) {
|
|
1884
|
-
|
|
1885
|
-
|
|
1975
|
+
if (hasFileExtension(srcPath)) {
|
|
1976
|
+
const content = this.readSync(srcPath);
|
|
1977
|
+
if (content !== void 0) {
|
|
1978
|
+
this.writeSync(hasFileExtension(destPath) ? destPath : joinPaths$1(destPath, findFileName(srcPath)), content);
|
|
1979
|
+
}
|
|
1980
|
+
} else {
|
|
1981
|
+
this.listSync(srcPath).forEach((file) => {
|
|
1982
|
+
const relativePath2 = file.replace(this.#normalizePath(srcPath), "");
|
|
1983
|
+
const destinationPath = this.#normalizePath(appendPath(destPath, relativePath2));
|
|
1984
|
+
const content = this.readSync(file);
|
|
1985
|
+
if (content !== void 0) {
|
|
1986
|
+
this.writeSync(destinationPath, content);
|
|
1987
|
+
}
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1886
1990
|
}
|
|
1887
1991
|
/**
|
|
1888
|
-
*
|
|
1992
|
+
* Moves a file (or files) from one path to another in the virtual file system (VFS).
|
|
1889
1993
|
*
|
|
1890
|
-
* @param
|
|
1891
|
-
* @param
|
|
1892
|
-
|
|
1994
|
+
* @param srcPath - The source path to move
|
|
1995
|
+
* @param destPath - The destination path to move to
|
|
1996
|
+
*/
|
|
1997
|
+
async move(srcPath, destPath) {
|
|
1998
|
+
if (hasFileExtension(srcPath)) {
|
|
1999
|
+
await this.copy(srcPath, destPath);
|
|
2000
|
+
await this.remove(srcPath);
|
|
2001
|
+
} else {
|
|
2002
|
+
await Promise.all((await this.list(srcPath)).map(async (file) => {
|
|
2003
|
+
await this.copy(file, destPath);
|
|
2004
|
+
await this.remove(file);
|
|
2005
|
+
}));
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
/**
|
|
2009
|
+
* Synchronously moves a file (or files) from one path to another in the virtual file system (VFS).
|
|
2010
|
+
*
|
|
2011
|
+
* @param srcPath - The source path to move
|
|
2012
|
+
* @param destPath - The destination path to move to
|
|
1893
2013
|
*/
|
|
1894
|
-
|
|
1895
|
-
|
|
2014
|
+
moveSync(srcPath, destPath) {
|
|
2015
|
+
if (hasFileExtension(srcPath)) {
|
|
2016
|
+
this.copySync(srcPath, destPath);
|
|
2017
|
+
this.removeSync(srcPath);
|
|
2018
|
+
} else {
|
|
2019
|
+
this.listSync(srcPath).forEach((file) => {
|
|
2020
|
+
this.copySync(file, destPath);
|
|
2021
|
+
this.removeSync(file);
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
1896
2024
|
}
|
|
1897
2025
|
/**
|
|
1898
2026
|
* Asynchronously reads a file from the virtual file system (VFS).
|
|
1899
2027
|
*
|
|
1900
|
-
* @param
|
|
2028
|
+
* @param path - The path or ID of the file to read.
|
|
1901
2029
|
* @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
|
|
1902
2030
|
*/
|
|
1903
|
-
async
|
|
1904
|
-
const filePath = await this.resolve(
|
|
1905
|
-
if (filePath
|
|
1906
|
-
|
|
1907
|
-
if (isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
|
|
1908
|
-
result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
|
|
1909
|
-
} else {
|
|
1910
|
-
result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
1911
|
-
}
|
|
1912
|
-
return isBuffer(result) ? bufferToString(result) : result;
|
|
2031
|
+
async read(path) {
|
|
2032
|
+
const filePath = await this.resolve(path);
|
|
2033
|
+
if (!filePath) {
|
|
2034
|
+
return void 0;
|
|
1913
2035
|
}
|
|
1914
|
-
|
|
2036
|
+
const { relativeKey, adapter } = this.#getStorage(filePath);
|
|
2037
|
+
this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
|
|
2038
|
+
return await adapter.get(relativeKey) ?? void 0;
|
|
1915
2039
|
}
|
|
1916
2040
|
/**
|
|
1917
2041
|
* Synchronously reads a file from the virtual file system (VFS).
|
|
1918
2042
|
*
|
|
1919
|
-
* @param
|
|
2043
|
+
* @param path - The path or ID of the file to read.
|
|
1920
2044
|
* @returns The contents of the file as a string, or undefined if the file does not exist.
|
|
1921
2045
|
*/
|
|
1922
|
-
|
|
1923
|
-
const filePath = this.resolveSync(
|
|
1924
|
-
if (filePath
|
|
1925
|
-
|
|
1926
|
-
return isBuffer(result) ? bufferToString(result) : result;
|
|
2046
|
+
readSync(path) {
|
|
2047
|
+
const filePath = this.resolveSync(path);
|
|
2048
|
+
if (!filePath) {
|
|
2049
|
+
return void 0;
|
|
1927
2050
|
}
|
|
1928
|
-
|
|
2051
|
+
const { relativeKey, adapter } = this.#getStorage(filePath);
|
|
2052
|
+
this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
|
|
2053
|
+
return adapter.getSync(relativeKey) ?? void 0;
|
|
1929
2054
|
}
|
|
1930
2055
|
/**
|
|
1931
2056
|
* Writes a file to the virtual file system (VFS).
|
|
@@ -1935,41 +2060,28 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1935
2060
|
* @param options - Optional parameters for writing the file.
|
|
1936
2061
|
* @returns A promise that resolves when the file is written.
|
|
1937
2062
|
*/
|
|
1938
|
-
async
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
}
|
|
1942
|
-
const metadata = isVirtualFileData(data) ? data : {};
|
|
1943
|
-
metadata.id = this.#normalizeId(path);
|
|
1944
|
-
let code = isVirtualFileData(data) ? metadata.code : data;
|
|
1945
|
-
if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString(code)) {
|
|
2063
|
+
async write(path, data = "", options = {}) {
|
|
2064
|
+
let code = data;
|
|
2065
|
+
if (!options.skipFormat) {
|
|
1946
2066
|
const resolvedConfig = await resolveConfig(this.#normalizePath(path));
|
|
1947
2067
|
if (resolvedConfig) {
|
|
1948
|
-
code = await format(
|
|
2068
|
+
code = await format(data, {
|
|
1949
2069
|
absolutePath: this.#normalizePath(path),
|
|
1950
2070
|
...resolvedConfig
|
|
1951
2071
|
});
|
|
1952
2072
|
}
|
|
1953
2073
|
}
|
|
1954
|
-
const
|
|
1955
|
-
this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)}
|
|
1956
|
-
|
|
1957
|
-
|
|
2074
|
+
const { relativeKey, adapter } = this.#getStorage(path);
|
|
2075
|
+
this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
|
|
2076
|
+
const id = options?.meta?.id || this.#normalizeId(path);
|
|
2077
|
+
this.#metadata[id] = {
|
|
1958
2078
|
variant: "normal",
|
|
1959
2079
|
timestamp: Date.now(),
|
|
1960
|
-
...
|
|
2080
|
+
...options.meta ?? {}
|
|
1961
2081
|
};
|
|
1962
|
-
this.#paths[
|
|
1963
|
-
this.#ids[this.#normalizePath(path)] =
|
|
1964
|
-
|
|
1965
|
-
if (isFunction(ifs.promises.writeFile)) {
|
|
1966
|
-
return ifs.promises.writeFile(this.#normalizePath(path), code, isSetObject(options) ? omit(options, [
|
|
1967
|
-
"mode"
|
|
1968
|
-
]) : "utf8");
|
|
1969
|
-
}
|
|
1970
|
-
return ifs.writeFileSync(this.#normalizePath(path), code, isSetObject(options) ? omit(options, [
|
|
1971
|
-
"mode"
|
|
1972
|
-
]) : "utf8");
|
|
2082
|
+
this.#paths[id] = this.#normalizePath(path);
|
|
2083
|
+
this.#ids[this.#normalizePath(path)] = id;
|
|
2084
|
+
return adapter.set(relativeKey, code);
|
|
1973
2085
|
}
|
|
1974
2086
|
/**
|
|
1975
2087
|
* Synchronously writes a file to the virtual file system (VFS).
|
|
@@ -1978,38 +2090,18 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1978
2090
|
* @param data - The contents of the file.
|
|
1979
2091
|
* @param options - Optional parameters for writing the file.
|
|
1980
2092
|
*/
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
metadata.id = this.#normalizeId(path);
|
|
1987
|
-
const code = isVirtualFileData(data) ? metadata.code : data;
|
|
1988
|
-
const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1989
|
-
this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
|
|
1990
|
-
this.#metadata[metadata.id] = {
|
|
1991
|
-
mode: outputMode,
|
|
2093
|
+
writeSync(path, data = "", options = {}) {
|
|
2094
|
+
const { relativeKey, adapter } = this.#getStorage(path);
|
|
2095
|
+
this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
|
|
2096
|
+
const id = options?.meta?.id || this.#normalizeId(path);
|
|
2097
|
+
this.#metadata[id] = {
|
|
1992
2098
|
variant: "normal",
|
|
1993
2099
|
timestamp: Date.now(),
|
|
1994
|
-
...
|
|
2100
|
+
...options.meta ?? {}
|
|
1995
2101
|
};
|
|
1996
|
-
this.#paths[
|
|
1997
|
-
this.#ids[this.#normalizePath(path)] =
|
|
1998
|
-
|
|
1999
|
-
try {
|
|
2000
|
-
writeStream.write(code);
|
|
2001
|
-
} finally {
|
|
2002
|
-
writeStream.close();
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
/**
|
|
2006
|
-
* Synchronously checks if a file exists in the virtual file system (VFS).
|
|
2007
|
-
*
|
|
2008
|
-
* @param pathOrId - The path or ID of the file to check.
|
|
2009
|
-
* @returns `true` if the file exists, otherwise `false`.
|
|
2010
|
-
*/
|
|
2011
|
-
existsSync(pathOrId) {
|
|
2012
|
-
return !!this.resolveSync(pathOrId);
|
|
2102
|
+
this.#paths[id] = this.#normalizePath(path);
|
|
2103
|
+
this.#ids[this.#normalizePath(path)] = id;
|
|
2104
|
+
return adapter.setSync(relativeKey, data);
|
|
2013
2105
|
}
|
|
2014
2106
|
/**
|
|
2015
2107
|
* Retrieves the metadata of a file in the virtual file system (VFS).
|
|
@@ -2025,78 +2117,6 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2025
2117
|
return void 0;
|
|
2026
2118
|
}
|
|
2027
2119
|
/**
|
|
2028
|
-
* Checks if a file exists in the virtual file system (VFS).
|
|
2029
|
-
*
|
|
2030
|
-
* @remarks
|
|
2031
|
-
* 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.
|
|
2032
|
-
*
|
|
2033
|
-
* @param pathOrId - The path of the file to check.
|
|
2034
|
-
* @returns `true` if the file exists, otherwise `false`.
|
|
2035
|
-
*/
|
|
2036
|
-
isFile(pathOrId) {
|
|
2037
|
-
const resolved = this.resolveSync(pathOrId);
|
|
2038
|
-
return !!(resolved && (this.#unifiedFS.virtual.existsSync(resolved) && this.#unifiedFS.virtual.lstatSync(resolved).isFile() || this.#unifiedFS.physical.existsSync(resolved) && this.#unifiedFS.physical.lstatSync(resolved).isFile() || this.#unifiedFS.resolveFS(resolved).existsSync(resolved) && this.#unifiedFS.resolveFS(resolved).lstatSync(resolved).isFile()));
|
|
2039
|
-
}
|
|
2040
|
-
/**
|
|
2041
|
-
* Checks if a directory exists in the virtual file system (VFS).
|
|
2042
|
-
*
|
|
2043
|
-
* @param pathOrId - The path of the directory to check.
|
|
2044
|
-
* @returns `true` if the directory exists, otherwise `false`.
|
|
2045
|
-
*/
|
|
2046
|
-
isDirectory(pathOrId) {
|
|
2047
|
-
const resolved = this.resolveSync(pathOrId);
|
|
2048
|
-
return !!(resolved && (this.#unifiedFS.virtual.existsSync(resolved) && this.#unifiedFS.virtual.lstatSync(resolved).isDirectory() || this.#unifiedFS.physical.existsSync(resolved) && this.#unifiedFS.physical.lstatSync(resolved).isDirectory() || this.#unifiedFS.resolveFS(resolved).existsSync(resolved) && this.#unifiedFS.resolveFS(resolved).lstatSync(resolved).isDirectory()));
|
|
2049
|
-
}
|
|
2050
|
-
/**
|
|
2051
|
-
* Retrieves the status of a file in the virtual file system (VFS).
|
|
2052
|
-
*
|
|
2053
|
-
* @param pathOrId - The path or ID of the file to retrieve status for.
|
|
2054
|
-
* @returns A promise that resolves to the file's status information, or false if the file does not exist.
|
|
2055
|
-
*/
|
|
2056
|
-
async stat(pathOrId, options) {
|
|
2057
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.stat(await this.resolve(pathOrId) || pathOrId, options);
|
|
2058
|
-
}
|
|
2059
|
-
/**
|
|
2060
|
-
* Synchronously retrieves the status of a file in the virtual file system (VFS).
|
|
2061
|
-
*
|
|
2062
|
-
* @param pathOrId - The path or ID of the file to retrieve status for.
|
|
2063
|
-
* @returns The file's status information, or false if the file does not exist.
|
|
2064
|
-
*/
|
|
2065
|
-
statSync(pathOrId) {
|
|
2066
|
-
return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolveSync(pathOrId) || pathOrId);
|
|
2067
|
-
}
|
|
2068
|
-
/**
|
|
2069
|
-
* Retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
2070
|
-
*
|
|
2071
|
-
* @param pathOrId - The path or ID of the symbolic link to retrieve status for.
|
|
2072
|
-
* @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
|
|
2073
|
-
*/
|
|
2074
|
-
async lstat(pathOrId, options) {
|
|
2075
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(await this.resolve(pathOrId) || pathOrId, options);
|
|
2076
|
-
}
|
|
2077
|
-
/**
|
|
2078
|
-
* Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
2079
|
-
*
|
|
2080
|
-
* @param pathOrId - The path or ID of the symbolic link to retrieve status for.
|
|
2081
|
-
* @returns The symbolic link's status information, or false if the link does not exist.
|
|
2082
|
-
*/
|
|
2083
|
-
lstatSync(pathOrId, options) {
|
|
2084
|
-
return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolveSync(pathOrId) || pathOrId, options);
|
|
2085
|
-
}
|
|
2086
|
-
/**
|
|
2087
|
-
* Resolves a path or ID to its real path in the virtual file system (VFS).
|
|
2088
|
-
*
|
|
2089
|
-
* @param pathOrId - The path or ID to resolve.
|
|
2090
|
-
* @returns The resolved real path if it exists, otherwise undefined.
|
|
2091
|
-
*/
|
|
2092
|
-
realpathSync(pathOrId) {
|
|
2093
|
-
const filePath = this.resolveSync(pathOrId);
|
|
2094
|
-
if (!filePath) {
|
|
2095
|
-
throw new Error(`File not found: ${pathOrId}`);
|
|
2096
|
-
}
|
|
2097
|
-
return filePath;
|
|
2098
|
-
}
|
|
2099
|
-
/**
|
|
2100
2120
|
* A helper function to resolve modules in the virtual file system (VFS).
|
|
2101
2121
|
*
|
|
2102
2122
|
* @remarks
|
|
@@ -2113,9 +2133,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2113
2133
|
* @returns A promise that resolves to the resolved module path.
|
|
2114
2134
|
*/
|
|
2115
2135
|
async resolve(id, importer, options = {}) {
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2136
|
+
if (isAbsolutePath(id)) {
|
|
2137
|
+
return id;
|
|
2138
|
+
}
|
|
2139
|
+
let result;
|
|
2140
|
+
if (!this.#context.config.skipCache) {
|
|
2141
|
+
result = this.resolverCache.get(this.#normalizeId(id));
|
|
2142
|
+
if (result) {
|
|
2143
|
+
return result;
|
|
2144
|
+
}
|
|
2119
2145
|
}
|
|
2120
2146
|
result = this.paths[this.#normalizeId(id)];
|
|
2121
2147
|
if (!result) {
|
|
@@ -2130,12 +2156,14 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2130
2156
|
for (const combination of getResolutionCombinations(id, {
|
|
2131
2157
|
paths
|
|
2132
2158
|
})) {
|
|
2133
|
-
|
|
2159
|
+
const { relativeKey, adapter } = this.#getStorage(combination);
|
|
2160
|
+
if (await adapter.exists(relativeKey)) {
|
|
2134
2161
|
result = combination;
|
|
2162
|
+
break;
|
|
2135
2163
|
}
|
|
2136
2164
|
}
|
|
2137
2165
|
try {
|
|
2138
|
-
result = await resolve(id, {
|
|
2166
|
+
result = await resolve$1(id, {
|
|
2139
2167
|
paths
|
|
2140
2168
|
});
|
|
2141
2169
|
} catch {
|
|
@@ -2143,7 +2171,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2143
2171
|
}
|
|
2144
2172
|
if (result) {
|
|
2145
2173
|
result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
|
|
2146
|
-
this.
|
|
2174
|
+
if (!this.#context.config.skipCache) {
|
|
2175
|
+
this.resolverCache.set(this.#normalizeId(id), result);
|
|
2176
|
+
}
|
|
2147
2177
|
}
|
|
2148
2178
|
return result;
|
|
2149
2179
|
}
|
|
@@ -2164,9 +2194,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2164
2194
|
* @returns The resolved module path.
|
|
2165
2195
|
*/
|
|
2166
2196
|
resolveSync(id, importer, options = {}) {
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2197
|
+
if (isAbsolutePath(id)) {
|
|
2198
|
+
return id;
|
|
2199
|
+
}
|
|
2200
|
+
let result;
|
|
2201
|
+
if (!this.#context.config.skipCache) {
|
|
2202
|
+
result = this.resolverCache.get(this.#normalizeId(id));
|
|
2203
|
+
if (result) {
|
|
2204
|
+
return result;
|
|
2205
|
+
}
|
|
2170
2206
|
}
|
|
2171
2207
|
result = this.paths[this.#normalizeId(id)];
|
|
2172
2208
|
if (!result) {
|
|
@@ -2175,14 +2211,16 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2175
2211
|
paths.push(importer);
|
|
2176
2212
|
}
|
|
2177
2213
|
paths.push(this.#context.workspaceConfig.workspaceRoot);
|
|
2178
|
-
paths.push(
|
|
2179
|
-
paths.push(
|
|
2180
|
-
paths.push(...Object.keys(this.#context.tsconfig
|
|
2214
|
+
paths.push(appendPath(this.#context.config.projectRoot, this.#context.workspaceConfig.workspaceRoot));
|
|
2215
|
+
paths.push(appendPath(this.#context.config.sourceRoot, this.#context.workspaceConfig.workspaceRoot));
|
|
2216
|
+
paths.push(...Object.keys(this.#context.tsconfig.options.paths ?? {}).filter((tsconfigPath) => id.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
|
|
2181
2217
|
for (const combination of getResolutionCombinations(id, {
|
|
2182
2218
|
paths
|
|
2183
2219
|
})) {
|
|
2184
|
-
|
|
2220
|
+
const { relativeKey, adapter } = this.#getStorage(combination);
|
|
2221
|
+
if (adapter.existsSync(relativeKey)) {
|
|
2185
2222
|
result = combination;
|
|
2223
|
+
break;
|
|
2186
2224
|
}
|
|
2187
2225
|
}
|
|
2188
2226
|
try {
|
|
@@ -2194,7 +2232,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2194
2232
|
}
|
|
2195
2233
|
if (result) {
|
|
2196
2234
|
result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
|
|
2197
|
-
this.
|
|
2235
|
+
if (!this.#context.config.skipCache) {
|
|
2236
|
+
this.resolverCache.set(this.#normalizeId(id), result);
|
|
2237
|
+
}
|
|
2198
2238
|
}
|
|
2199
2239
|
return result;
|
|
2200
2240
|
}
|
|
@@ -2205,27 +2245,27 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2205
2245
|
if (!this.#isDisposed) {
|
|
2206
2246
|
this.#isDisposed = true;
|
|
2207
2247
|
this.#log(LogLevelLabel.DEBUG, "Disposing virtual file system...");
|
|
2208
|
-
await this.
|
|
2248
|
+
await this.remove(joinPaths$1(this.#context.dataPath, "fs.bin"));
|
|
2209
2249
|
const message = new $.Message();
|
|
2210
|
-
const
|
|
2211
|
-
const
|
|
2212
|
-
const
|
|
2213
|
-
|
|
2214
|
-
const
|
|
2250
|
+
const fs = message.initRoot(FileSystem);
|
|
2251
|
+
const paths = await this.list();
|
|
2252
|
+
const storage = fs._initStorage(paths.length);
|
|
2253
|
+
await Promise.all(paths.map(async (path, index) => {
|
|
2254
|
+
const code = await this.read(path);
|
|
2255
|
+
const fd = storage.get(index);
|
|
2215
2256
|
fd.path = path;
|
|
2216
2257
|
fd.code = code || "";
|
|
2217
|
-
});
|
|
2218
|
-
const ids =
|
|
2258
|
+
}));
|
|
2259
|
+
const ids = fs._initIds(Object.keys(this.ids).length);
|
|
2219
2260
|
Object.entries(this.ids).filter(([, path]) => path).forEach(([id, path], index) => {
|
|
2220
2261
|
const fileId = ids.get(index);
|
|
2221
2262
|
fileId.id = id;
|
|
2222
2263
|
fileId.path = path;
|
|
2223
2264
|
});
|
|
2224
|
-
const metadata =
|
|
2265
|
+
const metadata = fs._initMetadata(Object.keys(this.metadata).length);
|
|
2225
2266
|
Object.entries(this.metadata).filter(([, value]) => value).forEach(([id, value], index) => {
|
|
2226
2267
|
const fileMetadata = metadata.get(index);
|
|
2227
2268
|
fileMetadata.id = id;
|
|
2228
|
-
fileMetadata.mode = value.mode;
|
|
2229
2269
|
fileMetadata.type = value.type;
|
|
2230
2270
|
fileMetadata.timestamp = value.timestamp ?? BigInt(Date.now());
|
|
2231
2271
|
if (value.properties) {
|
|
@@ -2238,134 +2278,40 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2238
2278
|
}
|
|
2239
2279
|
});
|
|
2240
2280
|
await writeFileBuffer(joinPaths$1(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
|
|
2241
|
-
this.#
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2281
|
+
if (!this.#context.config.skipCache) {
|
|
2282
|
+
this.#resolverCache.save(true);
|
|
2283
|
+
}
|
|
2284
|
+
await Promise.all(this.#getStorages().map(async (storage2) => storage2.adapter.dispose()));
|
|
2285
|
+
this.#log(LogLevelLabel.TRACE, "Virtual file system has been disposed.");
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
// /**
|
|
2289
|
+
// * Initializes the virtual file system (VFS) by patching the file system module if necessary.
|
|
2290
|
+
// */
|
|
2291
|
+
// public [__VFS_PATCH__]() {
|
|
2292
|
+
// if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
|
|
2293
|
+
// this.#revert = patchFS(fs, this);
|
|
2294
|
+
// this.#isPatched = true;
|
|
2295
|
+
// }
|
|
2296
|
+
// }
|
|
2297
|
+
// /**
|
|
2298
|
+
// * Reverts the file system module to its original state if it was previously patched.
|
|
2299
|
+
// */
|
|
2300
|
+
// public [__VFS_REVERT__]() {
|
|
2301
|
+
// if (this.#isPatched && this.#context.config.output.mode !== "fs") {
|
|
2302
|
+
// if (!this.#revert) {
|
|
2303
|
+
// throw new Error(
|
|
2304
|
+
// "Attempting to revert File System patch prior to calling `__init__` function"
|
|
2305
|
+
// );
|
|
2306
|
+
// }
|
|
2307
|
+
// this.#revert?.();
|
|
2308
|
+
// this.#isPatched = false;
|
|
2309
|
+
// }
|
|
2310
|
+
// }
|
|
2266
2311
|
async [Symbol.asyncDispose]() {
|
|
2267
2312
|
return this.dispose();
|
|
2268
2313
|
}
|
|
2269
2314
|
};
|
|
2270
|
-
var VirtualFileSystemHost = class VirtualFileSystemHost2 extends InMemoryFileSystemHost {
|
|
2271
|
-
static {
|
|
2272
|
-
__name(this, "VirtualFileSystemHost");
|
|
2273
|
-
}
|
|
2274
|
-
#fs;
|
|
2275
|
-
constructor(fs2) {
|
|
2276
|
-
super();
|
|
2277
|
-
this.#fs = fs2;
|
|
2278
|
-
}
|
|
2279
|
-
deleteSync(path) {
|
|
2280
|
-
this.#fs.rmSync(path);
|
|
2281
|
-
}
|
|
2282
|
-
readDirSync(dirPath) {
|
|
2283
|
-
return this.#fs.readdirSync(dirPath).reduce((ret, entry) => {
|
|
2284
|
-
const fullPath = this.#fs.resolveSync(joinPaths(dirPath, entry));
|
|
2285
|
-
if (fullPath) {
|
|
2286
|
-
ret.push({
|
|
2287
|
-
name: entry,
|
|
2288
|
-
isDirectory: this.#fs.isDirectory(fullPath),
|
|
2289
|
-
isFile: this.#fs.isFile(fullPath),
|
|
2290
|
-
isSymlink: false
|
|
2291
|
-
});
|
|
2292
|
-
}
|
|
2293
|
-
return ret;
|
|
2294
|
-
}, []);
|
|
2295
|
-
}
|
|
2296
|
-
async readFile(filePath) {
|
|
2297
|
-
if (!this.#fs.existsSync(filePath)) {
|
|
2298
|
-
throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
|
|
2299
|
-
}
|
|
2300
|
-
return await this.#fs.readFile(filePath);
|
|
2301
|
-
}
|
|
2302
|
-
readFileSync(filePath) {
|
|
2303
|
-
if (!this.#fs.existsSync(filePath)) {
|
|
2304
|
-
throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
|
|
2305
|
-
}
|
|
2306
|
-
return this.#fs.readFileSync(filePath);
|
|
2307
|
-
}
|
|
2308
|
-
async writeFile(filePath, fileText) {
|
|
2309
|
-
return this.#fs.writeFile(filePath, fileText);
|
|
2310
|
-
}
|
|
2311
|
-
writeFileSync(filePath, fileText) {
|
|
2312
|
-
this.#fs.writeFileSync(filePath, fileText);
|
|
2313
|
-
}
|
|
2314
|
-
async mkdir(dirPath) {
|
|
2315
|
-
await this.#fs.mkdir(dirPath);
|
|
2316
|
-
}
|
|
2317
|
-
mkdirSync(dirPath) {
|
|
2318
|
-
this.#fs.mkdirSync(dirPath);
|
|
2319
|
-
}
|
|
2320
|
-
async move(srcPath, destPath) {
|
|
2321
|
-
await this.#fs.move(srcPath, destPath);
|
|
2322
|
-
}
|
|
2323
|
-
moveSync(srcPath, destPath) {
|
|
2324
|
-
this.#fs.moveSync(srcPath, destPath);
|
|
2325
|
-
}
|
|
2326
|
-
async copy(srcPath, destPath) {
|
|
2327
|
-
await this.#fs.copy(srcPath, destPath);
|
|
2328
|
-
}
|
|
2329
|
-
copySync(srcPath, destPath) {
|
|
2330
|
-
this.#fs.copySync(srcPath, destPath);
|
|
2331
|
-
}
|
|
2332
|
-
async fileExists(filePath) {
|
|
2333
|
-
return this.#fs.isFile(filePath);
|
|
2334
|
-
}
|
|
2335
|
-
fileExistsSync(filePath) {
|
|
2336
|
-
return this.#fs.isFile(filePath);
|
|
2337
|
-
}
|
|
2338
|
-
async directoryExists(dirPath) {
|
|
2339
|
-
return this.#fs.isDirectory(dirPath);
|
|
2340
|
-
}
|
|
2341
|
-
directoryExistsSync(dirPath) {
|
|
2342
|
-
return this.#fs.isDirectory(dirPath);
|
|
2343
|
-
}
|
|
2344
|
-
realpathSync(path) {
|
|
2345
|
-
return this.#fs.resolveSync(path) || path;
|
|
2346
|
-
}
|
|
2347
|
-
getCurrentDirectory() {
|
|
2348
|
-
return "/";
|
|
2349
|
-
}
|
|
2350
|
-
async glob(patterns) {
|
|
2351
|
-
return this.#fs.glob(patterns);
|
|
2352
|
-
}
|
|
2353
|
-
globSync(patterns) {
|
|
2354
|
-
return this.#fs.globSync(patterns);
|
|
2355
|
-
}
|
|
2356
|
-
};
|
|
2357
|
-
function createProgram(context, override) {
|
|
2358
|
-
const project = new Project({
|
|
2359
|
-
compilerOptions: {
|
|
2360
|
-
...context.tsconfig.options
|
|
2361
|
-
},
|
|
2362
|
-
tsConfigFilePath: context.tsconfig.tsconfigFilePath,
|
|
2363
|
-
fileSystem: new VirtualFileSystemHost(context.fs),
|
|
2364
|
-
...override
|
|
2365
|
-
});
|
|
2366
|
-
return project;
|
|
2367
|
-
}
|
|
2368
|
-
__name(createProgram, "createProgram");
|
|
2369
2315
|
var PROJECT_ROOT_HASH_LENGTH = 45;
|
|
2370
2316
|
var CACHE_HASH_LENGTH = 62;
|
|
2371
2317
|
function getPrefixedProjectRootHash(name, projectRootHash) {
|
|
@@ -2376,9 +2322,7 @@ __name(getPrefixedProjectRootHash, "getPrefixedProjectRootHash");
|
|
|
2376
2322
|
async function writeMetaFile(context) {
|
|
2377
2323
|
const metaFilePath = joinPaths$1(context.dataPath, "meta.json");
|
|
2378
2324
|
context.log(LogLevelLabel.DEBUG, `Writing runtime metadata to ${metaFilePath}`);
|
|
2379
|
-
await context.fs.
|
|
2380
|
-
mode: "fs"
|
|
2381
|
-
});
|
|
2325
|
+
await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
|
|
2382
2326
|
}
|
|
2383
2327
|
__name(writeMetaFile, "writeMetaFile");
|
|
2384
2328
|
|
|
@@ -2581,7 +2525,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2581
2525
|
* Get the path to the artifacts directory for the project
|
|
2582
2526
|
*/
|
|
2583
2527
|
get artifactsPath() {
|
|
2584
|
-
return joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.
|
|
2528
|
+
return joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.artifactsPath);
|
|
2585
2529
|
}
|
|
2586
2530
|
/**
|
|
2587
2531
|
* Get the path to the builtin modules used by the project
|
|
@@ -2721,7 +2665,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2721
2665
|
if (!resolvedId) {
|
|
2722
2666
|
return void 0;
|
|
2723
2667
|
}
|
|
2724
|
-
const code = await this.fs.
|
|
2668
|
+
const code = await this.fs.read(resolvedId);
|
|
2725
2669
|
if (!code) {
|
|
2726
2670
|
return void 0;
|
|
2727
2671
|
}
|
|
@@ -2735,7 +2679,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2735
2679
|
*/
|
|
2736
2680
|
async getBuiltins() {
|
|
2737
2681
|
return Promise.all(Object.entries(this.fs.metadata).filter(([, meta]) => meta && meta.type === "builtin").map(async ([path, meta]) => {
|
|
2738
|
-
const code = await this.fs.
|
|
2682
|
+
const code = await this.fs.read(path);
|
|
2739
2683
|
return {
|
|
2740
2684
|
...meta,
|
|
2741
2685
|
path,
|
|
@@ -2751,11 +2695,8 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2751
2695
|
* @param options - Optional write file options
|
|
2752
2696
|
*/
|
|
2753
2697
|
async emitEntry(code, path, options = {}) {
|
|
2754
|
-
return this.fs.
|
|
2755
|
-
code,
|
|
2698
|
+
return this.fs.write(isAbsolute(path) ? path : appendPath(path, this.entryPath), code, defu7(options, {
|
|
2756
2699
|
type: "entry"
|
|
2757
|
-
}, defu6(options, {
|
|
2758
|
-
mode: this.config.output.mode
|
|
2759
2700
|
}));
|
|
2760
2701
|
}
|
|
2761
2702
|
/**
|
|
@@ -2767,12 +2708,8 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2767
2708
|
* @param options - Optional write file options
|
|
2768
2709
|
*/
|
|
2769
2710
|
async emitBuiltin(code, id, path, options = {}) {
|
|
2770
|
-
return this.fs.
|
|
2771
|
-
id,
|
|
2772
|
-
code,
|
|
2711
|
+
return this.fs.write(path ? isAbsolute(path) ? path : joinPaths(this.builtinsPath, path) : appendPath(id, this.builtinsPath), code, defu7(options, {
|
|
2773
2712
|
type: "builtin"
|
|
2774
|
-
}, defu6(options, {
|
|
2775
|
-
mode: this.config.output.mode
|
|
2776
2713
|
}));
|
|
2777
2714
|
}
|
|
2778
2715
|
/**
|
|
@@ -2966,9 +2903,9 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2966
2903
|
userConfig
|
|
2967
2904
|
});
|
|
2968
2905
|
}
|
|
2969
|
-
|
|
2906
|
+
config.tsconfig ??= getTsconfigFilePath(this.workspaceConfig.workspaceRoot, cacheKey.projectRoot, config.tsconfig);
|
|
2970
2907
|
if (isSetObject(config)) {
|
|
2971
|
-
this.resolvedConfig =
|
|
2908
|
+
this.resolvedConfig = defu7({
|
|
2972
2909
|
inlineConfig: this.config.inlineConfig,
|
|
2973
2910
|
userConfig: this.config.userConfig
|
|
2974
2911
|
}, options.isHighPriority ? this.#getConfigProps(config) : {}, {
|
|
@@ -2983,12 +2920,11 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2983
2920
|
version: this.packageJson?.version,
|
|
2984
2921
|
description: this.packageJson?.description,
|
|
2985
2922
|
sourceRoot: this.projectJson?.sourceRoot || appendPath("src", cacheKey.projectRoot),
|
|
2986
|
-
output: {
|
|
2923
|
+
output: defu7(config.output ?? {}, {
|
|
2987
2924
|
outputPath: cacheKey.projectRoot ? joinPaths(this.workspaceConfig?.directories?.build || "dist", cacheKey.projectRoot) : this.workspaceConfig?.directories?.build || "dist",
|
|
2988
|
-
|
|
2925
|
+
artifactsPath: joinPaths(cacheKey.projectRoot, `.${config.framework ?? "powerlines"}`),
|
|
2989
2926
|
dts: joinPaths(cacheKey.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
|
|
2990
2927
|
builtinPrefix: config.framework ?? "powerlines",
|
|
2991
|
-
artifactsFolder: joinPaths(cacheKey.projectRoot, `.${config.framework ?? "powerlines"}`),
|
|
2992
2928
|
assets: [
|
|
2993
2929
|
{
|
|
2994
2930
|
glob: "LICENSE"
|
|
@@ -3002,7 +2938,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
3002
2938
|
glob: "package.json"
|
|
3003
2939
|
}
|
|
3004
2940
|
]
|
|
3005
|
-
}
|
|
2941
|
+
})
|
|
3006
2942
|
}, options.isHighPriority ? {} : this.#getConfigProps(config), {
|
|
3007
2943
|
inlineConfig: {},
|
|
3008
2944
|
userConfig: {},
|
|
@@ -3047,10 +2983,10 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
3047
2983
|
])));
|
|
3048
2984
|
if (this.config.projectRoot && this.config.projectRoot !== "." && this.config.projectRoot !== "./" && this.config.projectRoot !== this.workspaceConfig.workspaceRoot) {
|
|
3049
2985
|
this.config.output.outputPath ??= joinPaths("dist", this.config.projectRoot);
|
|
3050
|
-
this.config.output.
|
|
2986
|
+
this.config.output.buildPath ??= joinPaths(this.config.projectRoot, "dist");
|
|
3051
2987
|
} else {
|
|
3052
2988
|
this.config.output.outputPath ??= "dist";
|
|
3053
|
-
this.config.output.
|
|
2989
|
+
this.config.output.buildPath ??= "dist";
|
|
3054
2990
|
}
|
|
3055
2991
|
this.config.output.assets = getUnique(this.config.output.assets.map((asset) => {
|
|
3056
2992
|
return {
|
|
@@ -3088,7 +3024,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
3088
3024
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
3089
3025
|
}
|
|
3090
3026
|
mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
|
|
3091
|
-
this.config.userConfig =
|
|
3027
|
+
this.config.userConfig = defu7({
|
|
3092
3028
|
entry: Array.isArray(from.entry) && from.entry.length > 0 ? from.entry : Array.isArray(into?.entry) && into.entry.length > 0 ? into.entry : []
|
|
3093
3029
|
}, omit(from ?? {}, [
|
|
3094
3030
|
"entry"
|
|
@@ -3384,12 +3320,49 @@ var PowerlinesAPIContext = class _PowerlinesAPIContext extends PowerlinesContext
|
|
|
3384
3320
|
}
|
|
3385
3321
|
return context;
|
|
3386
3322
|
}
|
|
3323
|
+
/**
|
|
3324
|
+
* Update the context using a new user configuration options
|
|
3325
|
+
*
|
|
3326
|
+
* @param userConfig - The new user configuration options.
|
|
3327
|
+
*/
|
|
3328
|
+
async withUserConfig(userConfig, options = {
|
|
3329
|
+
isHighPriority: true
|
|
3330
|
+
}) {
|
|
3331
|
+
await super.withUserConfig(userConfig, options);
|
|
3332
|
+
await Promise.all(Object.keys(this.#environments).map(async (name) => {
|
|
3333
|
+
await this.#environments[name].withUserConfig(userConfig, options);
|
|
3334
|
+
}));
|
|
3335
|
+
}
|
|
3336
|
+
/**
|
|
3337
|
+
* Update the context using a new inline configuration options
|
|
3338
|
+
*
|
|
3339
|
+
* @param inlineConfig - The new inline configuration options.
|
|
3340
|
+
*/
|
|
3341
|
+
async withInlineConfig(inlineConfig, options = {
|
|
3342
|
+
isHighPriority: true
|
|
3343
|
+
}) {
|
|
3344
|
+
await super.withInlineConfig(inlineConfig, options);
|
|
3345
|
+
await Promise.all(Object.keys(this.#environments).map(async (name) => {
|
|
3346
|
+
await this.#environments[name].withInlineConfig(inlineConfig, options);
|
|
3347
|
+
}));
|
|
3348
|
+
}
|
|
3349
|
+
/**
|
|
3350
|
+
* Add a plugin to the API context and all environments
|
|
3351
|
+
*
|
|
3352
|
+
* @param plugin - The plugin to add.
|
|
3353
|
+
*/
|
|
3387
3354
|
async addPlugin(plugin) {
|
|
3388
3355
|
this.plugins.push(plugin);
|
|
3389
3356
|
await Promise.all(Object.keys(this.environments).map(async (name) => {
|
|
3390
3357
|
await this.environments[name].addPlugin(plugin);
|
|
3391
3358
|
}));
|
|
3392
3359
|
}
|
|
3360
|
+
/**
|
|
3361
|
+
* Get an environment by name, or the default environment if no name is provided
|
|
3362
|
+
*
|
|
3363
|
+
* @param name - The name of the environment to retrieve.
|
|
3364
|
+
* @returns The requested environment context.
|
|
3365
|
+
*/
|
|
3393
3366
|
async getEnvironment(name) {
|
|
3394
3367
|
let environment;
|
|
3395
3368
|
if (name) {
|
|
@@ -3511,21 +3484,17 @@ ${formatLogMessage(context.config)}`);
|
|
|
3511
3484
|
await writeMetaFile(context);
|
|
3512
3485
|
context.persistedMeta = context.meta;
|
|
3513
3486
|
if (!context.fs.existsSync(context.cachePath)) {
|
|
3514
|
-
await
|
|
3515
|
-
mode: "fs"
|
|
3516
|
-
});
|
|
3487
|
+
await createDirectory(context.cachePath);
|
|
3517
3488
|
}
|
|
3518
3489
|
if (!context.fs.existsSync(context.dataPath)) {
|
|
3519
|
-
await
|
|
3520
|
-
mode: "fs"
|
|
3521
|
-
});
|
|
3490
|
+
await createDirectory(context.dataPath);
|
|
3522
3491
|
}
|
|
3523
3492
|
await this.callPreHook(context, "prepare");
|
|
3524
3493
|
await this.callNormalHook(context, "prepare");
|
|
3525
3494
|
if (context.config.output.dts !== false) {
|
|
3526
3495
|
context.log(LogLevelLabel.TRACE, `Preparing the TypeScript definitions for the Powerlines project.`);
|
|
3527
3496
|
if (context.fs.existsSync(context.dtsPath)) {
|
|
3528
|
-
await context.fs.
|
|
3497
|
+
await context.fs.remove(context.dtsPath);
|
|
3529
3498
|
}
|
|
3530
3499
|
context.log(LogLevelLabel.TRACE, "Transforming built-ins runtime modules files.");
|
|
3531
3500
|
const builtinFilePaths = await Promise.all((await context.getBuiltins()).map(async (file) => {
|
|
@@ -3612,7 +3581,7 @@ ${formatLogMessage(context.config)}`);
|
|
|
3612
3581
|
generatedTypes = result;
|
|
3613
3582
|
}
|
|
3614
3583
|
}
|
|
3615
|
-
await context.fs.
|
|
3584
|
+
await context.fs.write(context.dtsPath, `${directives ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
|
|
3616
3585
|
|
|
3617
3586
|
` : ""}${getFileHeader(context, {
|
|
3618
3587
|
directive: null,
|
|
@@ -3620,9 +3589,7 @@ ${formatLogMessage(context.config)}`);
|
|
|
3620
3589
|
})}
|
|
3621
3590
|
|
|
3622
3591
|
${formatTypes(generatedTypes)}
|
|
3623
|
-
|
|
3624
|
-
mode: "fs"
|
|
3625
|
-
});
|
|
3592
|
+
`);
|
|
3626
3593
|
}
|
|
3627
3594
|
context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
3628
3595
|
if (!context.tsconfig) {
|
|
@@ -3690,8 +3657,8 @@ ${formatTypes(generatedTypes)}
|
|
|
3690
3657
|
await this.prepare(inlineConfig);
|
|
3691
3658
|
await this.#executeEnvironments(async (context) => {
|
|
3692
3659
|
this.context.log(LogLevelLabel.TRACE, "Cleaning the project's dist and artifacts directories.");
|
|
3693
|
-
await context.fs.
|
|
3694
|
-
await context.fs.
|
|
3660
|
+
await context.fs.remove(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.output.buildPath));
|
|
3661
|
+
await context.fs.remove(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.output.artifactsPath));
|
|
3695
3662
|
await callHook(context, "clean", {
|
|
3696
3663
|
sequential: true
|
|
3697
3664
|
});
|
|
@@ -3733,11 +3700,11 @@ ${formatTypes(generatedTypes)}
|
|
|
3733
3700
|
await this.#executeEnvironments(async (context) => {
|
|
3734
3701
|
await this.callPreHook(context, "build");
|
|
3735
3702
|
await this.callNormalHook(context, "build");
|
|
3736
|
-
if (context.config.output.
|
|
3737
|
-
const sourcePath = appendPath(context.config.output.
|
|
3703
|
+
if (context.config.output.buildPath !== context.config.output.outputPath) {
|
|
3704
|
+
const sourcePath = appendPath(context.config.output.buildPath, context.workspaceConfig.workspaceRoot);
|
|
3738
3705
|
const destinationPath = joinPaths$1(appendPath(context.config.output.outputPath, context.workspaceConfig.workspaceRoot), "dist");
|
|
3739
3706
|
if (sourcePath !== destinationPath) {
|
|
3740
|
-
context.log(LogLevelLabel.INFO, `Copying build output files from project's build directory (${context.config.output.
|
|
3707
|
+
context.log(LogLevelLabel.INFO, `Copying build output files from project's build directory (${context.config.output.buildPath}) to the workspace's output directory (${context.config.output.outputPath}).`);
|
|
3741
3708
|
await copyFiles({
|
|
3742
3709
|
input: sourcePath,
|
|
3743
3710
|
glob: "**/*"
|
|
@@ -4067,4 +4034,6 @@ Note: Please ensure the plugin package's default export is a class that extends
|
|
|
4067
4034
|
}
|
|
4068
4035
|
};
|
|
4069
4036
|
|
|
4070
|
-
export {
|
|
4037
|
+
export { FileId, FileMetadata, FileMetadata_KeyValuePair, FileStorage, FileSystem, PowerlinesAPI, _capnpFileId, createLog, extendLog };
|
|
4038
|
+
//# sourceMappingURL=chunk-LZFTQGQG.js.map
|
|
4039
|
+
//# sourceMappingURL=chunk-LZFTQGQG.js.map
|