powerlines 0.23.2 → 0.23.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api--9pVSIbm.d.cts +168 -0
- package/dist/api-DxPACGY4.d.ts +168 -0
- package/dist/api.cjs +3 -3
- package/dist/api.d.cts +16 -7
- package/dist/api.d.ts +16 -7
- package/dist/api.js +2 -2
- package/dist/astro.cjs +8 -8
- package/dist/astro.d.cts +3 -5
- package/dist/astro.d.ts +3 -5
- package/dist/astro.js +5 -5
- package/dist/{chunk-ZFO3FUM4.cjs → chunk-2FLICTDF.cjs} +2 -2
- package/dist/{chunk-JAJ4CI2F.cjs → chunk-3OQXZ5MM.cjs} +2 -2
- package/dist/{chunk-KFRKOIP3.js → chunk-5B6P2VUG.js} +1 -1
- package/dist/{chunk-GNNF5SG6.cjs → chunk-6ACGI52O.cjs} +2 -2
- package/dist/{chunk-JZAQW55G.cjs → chunk-AF5VNWZD.cjs} +2 -2
- package/dist/{chunk-J7MZRPLN.cjs → chunk-AIC2EHPW.cjs} +5 -4
- package/dist/{chunk-3WDMXRK6.cjs → chunk-AYKZK666.cjs} +1 -1
- package/dist/chunk-CHNKTBUA.cjs +32 -0
- package/dist/{chunk-M4QJ2474.cjs → chunk-CTSSNO5L.cjs} +4 -4
- package/dist/{chunk-5A7FM72H.cjs → chunk-GP6XGAJ4.cjs} +2 -2
- package/dist/{chunk-DUYZ3TCT.js → chunk-HLQGKQZY.js} +1 -1
- package/dist/{chunk-LKN52AAX.js → chunk-HNJC47JM.js} +1 -1
- package/dist/{chunk-IGWSCIES.js → chunk-ISLX4Z3L.js} +3 -2
- package/dist/{chunk-J5LKLH5Z.js → chunk-KFSVTJMR.js} +1 -1
- package/dist/{chunk-RWVNX2CP.js → chunk-MI3U2GAT.js} +1 -1
- package/dist/{chunk-4ODWTALP.js → chunk-N3F54RFW.js} +2 -2
- package/dist/{chunk-Q7HBETZW.js → chunk-O2WB6QZ6.js} +1 -1
- package/dist/{chunk-DWV5QAGZ.cjs → chunk-OEKSQ22R.cjs} +2997 -2710
- package/dist/{chunk-WSLPUUGZ.js → chunk-PTZB4LWS.js} +1 -1
- package/dist/{chunk-CPRXGMH2.js → chunk-QSNFMINQ.js} +1 -1
- package/dist/{chunk-YQ76DZYD.cjs → chunk-QUZ4T5AX.cjs} +2 -2
- package/dist/chunk-UTAJPBVT.js +29 -0
- package/dist/{chunk-WG55ZHJL.cjs → chunk-UW3MXOWV.cjs} +2 -2
- package/dist/{chunk-F6BDL4HD.js → chunk-VDBKZJV6.js} +1 -1
- package/dist/{chunk-J3LN5HOC.cjs → chunk-VFLCP3SA.cjs} +2 -2
- package/dist/{chunk-FM4ABZQ2.js → chunk-VT7NVLLU.js} +1 -1
- package/dist/{chunk-WDBPA4RQ.cjs → chunk-VXAKPZ3A.cjs} +2 -2
- package/dist/{chunk-WXU3KLBP.cjs → chunk-XOI5CY62.cjs} +2 -2
- package/dist/{chunk-NH7U3PTV.js → chunk-ZQ7PDXYO.js} +1 -1
- package/dist/{chunk-TNYZH6EG.js → chunk-ZYCPZLIG.js} +2982 -2700
- package/dist/config.d.cts +3 -5
- package/dist/config.d.ts +3 -5
- package/dist/esbuild.cjs +7 -7
- package/dist/esbuild.d.cts +3 -5
- package/dist/esbuild.d.ts +3 -5
- package/dist/esbuild.js +4 -4
- package/dist/farm.cjs +4 -4
- package/dist/farm.d.cts +3 -5
- package/dist/farm.d.ts +3 -5
- package/dist/farm.js +3 -3
- package/dist/index.cjs +54 -33
- package/dist/index.d.cts +191 -39
- package/dist/index.d.ts +191 -39
- package/dist/index.js +18 -17
- package/dist/lib/api-B6hfFxVS.d.ts +167 -0
- package/dist/lib/api-CD2QlMig.d.cts +167 -0
- package/dist/lib/build/esbuild.d.cts +2 -4
- package/dist/lib/build/esbuild.d.ts +2 -4
- package/dist/lib/build/index.d.cts +4 -5
- package/dist/lib/build/index.d.ts +4 -5
- package/dist/lib/build/rolldown.d.cts +2 -4
- package/dist/lib/build/rolldown.d.ts +2 -4
- package/dist/lib/build/rollup.d.cts +2 -4
- package/dist/lib/build/rollup.d.ts +2 -4
- package/dist/lib/build/rspack.d.cts +2 -4
- package/dist/lib/build/rspack.d.ts +2 -4
- package/dist/lib/build/tsup.d.cts +2 -4
- package/dist/lib/build/tsup.d.ts +2 -4
- package/dist/lib/build/unbuild.d.cts +4 -23
- package/dist/lib/build/unbuild.d.ts +4 -23
- package/dist/lib/build/vite.d.cts +2 -4
- package/dist/lib/build/vite.d.ts +2 -4
- package/dist/lib/build/webpack.d.cts +2 -4
- package/dist/lib/build/webpack.d.ts +2 -4
- package/dist/lib/chunk-32Q2PG5D.js +9 -0
- package/dist/lib/chunk-35FGUJFD.cjs +2 -0
- package/dist/lib/{chunk-LIN4KAV3.js → chunk-52VDUP5J.js} +5 -7
- package/dist/lib/chunk-B3EE3VHZ.cjs +127 -0
- package/dist/lib/{chunk-UWHGJ4JS.js → chunk-BLNW3ZQA.js} +483 -1776
- package/dist/lib/chunk-DX2VAXZB.cjs +11 -0
- package/dist/lib/{chunk-VGSV2BEL.cjs → chunk-EFYMNU53.cjs} +6 -12
- package/dist/lib/chunk-FBQIPNRV.cjs +146 -0
- package/dist/lib/chunk-FFT4PWRM.js +1 -0
- package/dist/lib/{chunk-L4NEN725.js → chunk-G7S5PIAC.js} +1 -1
- package/dist/lib/chunk-KFJCWNVG.js +120 -0
- package/dist/lib/chunk-M2U6XIQ2.js +144 -0
- package/dist/lib/chunk-MVIKYHBX.cjs +2 -0
- package/dist/lib/chunk-NYNHNTHT.js +1 -0
- package/dist/lib/{chunk-A5SB72VO.cjs → chunk-PYQADZVV.cjs} +493 -1779
- package/dist/lib/chunk-QP6WX3Q3.js +1190 -0
- package/dist/lib/chunk-S7LLEDQM.cjs +1218 -0
- package/dist/lib/chunk-UHGGYHSK.cjs +175 -0
- package/dist/lib/chunk-YNKFRPUY.js +168 -0
- package/dist/lib/{chunk-ULJVBW4L.cjs → chunk-ZBDVQVUK.cjs} +1 -1
- package/dist/lib/{config-BoGlIhnH.d.cts → config-DTSdCZsw.d.cts} +650 -633
- package/dist/lib/{config-CTej7RMP.d.ts → config-DeUaQYc_.d.ts} +650 -633
- package/dist/lib/config-file.d.cts +4 -5
- package/dist/lib/config-file.d.ts +4 -5
- package/dist/lib/contexts/api-context.cjs +18 -0
- package/dist/lib/contexts/api-context.d.cts +69 -0
- package/dist/lib/contexts/api-context.d.ts +69 -0
- package/dist/lib/contexts/api-context.js +9 -0
- package/dist/lib/contexts/context.cjs +15 -0
- package/dist/lib/contexts/context.d.cts +255 -0
- package/dist/lib/contexts/context.d.ts +255 -0
- package/dist/lib/contexts/context.js +6 -0
- package/dist/lib/contexts/environment-context.cjs +17 -0
- package/dist/lib/contexts/environment-context.d.cts +65 -0
- package/dist/lib/contexts/environment-context.d.ts +65 -0
- package/dist/lib/contexts/environment-context.js +8 -0
- package/dist/lib/contexts/index.cjs +31 -0
- package/dist/lib/contexts/index.d.cts +35 -0
- package/dist/lib/contexts/index.d.ts +35 -0
- package/dist/lib/contexts/index.js +10 -0
- package/dist/lib/contexts/plugin-context.cjs +11 -0
- package/dist/lib/contexts/plugin-context.d.cts +42 -0
- package/dist/lib/contexts/plugin-context.d.ts +42 -0
- package/dist/lib/contexts/plugin-context.js +2 -0
- package/dist/lib/entry.d.cts +2 -4
- package/dist/lib/entry.d.ts +2 -4
- package/dist/lib/index.cjs +96 -74
- package/dist/lib/index.d.cts +26 -23
- package/dist/lib/index.d.ts +26 -23
- package/dist/lib/index.js +18 -12
- package/dist/lib/internal-CpVMJCaU.d.ts +39 -0
- package/dist/lib/internal-ypnrUNZy.d.cts +39 -0
- package/dist/lib/logger.d.cts +4 -5
- package/dist/lib/logger.d.ts +4 -5
- package/dist/lib/typescript/compiler-host.cjs +1 -1
- package/dist/lib/typescript/compiler-host.d.cts +5 -5
- package/dist/lib/typescript/compiler-host.d.ts +5 -5
- package/dist/lib/typescript/compiler-host.js +1 -1
- package/dist/lib/typescript/import-transformer.d.cts +2 -4
- package/dist/lib/typescript/import-transformer.d.ts +2 -4
- package/dist/lib/typescript/index.cjs +29 -24
- package/dist/lib/typescript/index.d.cts +6 -6
- package/dist/lib/typescript/index.d.ts +6 -6
- package/dist/lib/typescript/index.js +3 -2
- package/dist/lib/typescript/isolated-decl.d.cts +2 -1
- package/dist/lib/typescript/isolated-decl.d.ts +2 -1
- package/dist/lib/typescript/program.d.cts +5 -5
- package/dist/lib/typescript/program.d.ts +5 -5
- package/dist/lib/typescript/ts-morph.cjs +11 -0
- package/dist/lib/{create-program.d.ts → typescript/ts-morph.d.cts} +3 -5
- package/dist/lib/{create-program.d.cts → typescript/ts-morph.d.ts} +3 -5
- package/dist/lib/typescript/ts-morph.js +2 -0
- package/dist/lib/unplugin/factory.cjs +8 -4
- package/dist/lib/unplugin/factory.d.cts +27 -10
- package/dist/lib/unplugin/factory.d.ts +27 -10
- package/dist/lib/unplugin/factory.js +7 -3
- package/dist/lib/unplugin/helpers.cjs +11 -0
- package/dist/lib/unplugin/helpers.d.cts +128 -0
- package/dist/lib/unplugin/helpers.d.ts +128 -0
- package/dist/lib/unplugin/helpers.js +2 -0
- package/dist/lib/unplugin/index.cjs +12 -7
- package/dist/lib/unplugin/index.d.cts +6 -8
- package/dist/lib/unplugin/index.d.ts +6 -8
- package/dist/lib/unplugin/index.js +9 -4
- package/dist/lib/unplugin/plugin.cjs +4 -3
- package/dist/lib/unplugin/plugin.d.cts +4 -5
- package/dist/lib/unplugin/plugin.d.ts +4 -5
- package/dist/lib/unplugin/plugin.js +3 -2
- package/dist/lib/unplugin/resolve-id.cjs +2 -2
- package/dist/lib/unplugin/resolve-id.d.cts +5 -5
- package/dist/lib/unplugin/resolve-id.d.ts +5 -5
- package/dist/lib/unplugin/resolve-id.js +1 -1
- package/dist/lib/utilities/bundle.d.cts +2 -4
- package/dist/lib/utilities/bundle.d.ts +2 -4
- package/dist/lib/utilities/cache.d.cts +2 -4
- package/dist/lib/utilities/cache.d.ts +2 -4
- package/dist/lib/utilities/file-header.d.cts +4 -5
- package/dist/lib/utilities/file-header.d.ts +4 -5
- package/dist/lib/utilities/index.cjs +18 -18
- package/dist/lib/utilities/index.d.cts +5 -7
- package/dist/lib/utilities/index.d.ts +5 -7
- package/dist/lib/utilities/index.js +4 -4
- package/dist/lib/utilities/meta.d.cts +4 -5
- package/dist/lib/utilities/meta.d.ts +4 -5
- package/dist/lib/utilities/resolve-path.d.cts +2 -4
- package/dist/lib/utilities/resolve-path.d.ts +2 -4
- package/dist/lib/utilities/resolve.d.cts +2 -4
- package/dist/lib/utilities/resolve.d.ts +2 -4
- package/dist/lib/utilities/source-file.d.cts +2 -4
- package/dist/lib/utilities/source-file.d.ts +2 -4
- package/dist/lib/utilities/source-map.d.cts +2 -4
- package/dist/lib/utilities/source-map.d.ts +2 -4
- package/dist/lib/utilities/worker.d.cts +4 -5
- package/dist/lib/utilities/worker.d.ts +4 -5
- package/dist/lib/utilities/write-file.d.cts +2 -4
- package/dist/lib/utilities/write-file.d.ts +2 -4
- package/dist/next.cjs +8 -8
- package/dist/next.js +5 -5
- package/dist/nuxt.cjs +9 -9
- package/dist/nuxt.js +6 -6
- package/dist/plugin-utils/{context-D1I2JQgs.d.cts → context-DRFZE3XI.d.cts} +535 -518
- package/dist/plugin-utils/{context-D1I2JQgs.d.ts → context-DRFZE3XI.d.ts} +535 -518
- package/dist/plugin-utils/context-helpers.d.cts +2 -4
- package/dist/plugin-utils/context-helpers.d.ts +2 -4
- package/dist/plugin-utils/enforce.d.cts +2 -4
- package/dist/plugin-utils/enforce.d.ts +2 -4
- package/dist/plugin-utils/extend.d.cts +2 -4
- package/dist/plugin-utils/extend.d.ts +2 -4
- package/dist/plugin-utils/get-config-path.d.cts +2 -4
- package/dist/plugin-utils/get-config-path.d.ts +2 -4
- package/dist/plugin-utils/helpers.d.cts +2 -4
- package/dist/plugin-utils/helpers.d.ts +2 -4
- package/dist/plugin-utils/index.d.cts +3 -5
- package/dist/plugin-utils/index.d.ts +3 -5
- package/dist/plugin-utils/merge.d.cts +4 -5
- package/dist/plugin-utils/merge.d.ts +4 -5
- package/dist/plugin-utils/paths.d.cts +2 -4
- package/dist/plugin-utils/paths.d.ts +2 -4
- package/dist/{resolved-DYLxPDut.d.cts → resolved-C00CJgsk.d.cts} +128 -9
- package/dist/{resolved-D1ySEdUv.d.ts → resolved-DKFZ11S7.d.ts} +128 -9
- package/dist/rolldown.cjs +7 -7
- package/dist/rolldown.d.cts +3 -5
- package/dist/rolldown.d.ts +3 -5
- package/dist/rolldown.js +4 -4
- package/dist/rollup.cjs +7 -7
- package/dist/rollup.d.cts +3 -5
- package/dist/rollup.d.ts +3 -5
- package/dist/rollup.js +4 -4
- package/dist/rspack.cjs +7 -7
- package/dist/rspack.d.cts +3 -5
- package/dist/rspack.d.ts +3 -5
- package/dist/rspack.js +4 -4
- package/dist/tsup.cjs +8 -8
- package/dist/tsup.js +5 -5
- package/dist/types/api.cjs +4 -0
- package/dist/types/api.d.cts +36 -0
- package/dist/types/api.d.ts +36 -0
- package/dist/types/api.js +1 -0
- package/dist/types/babel.d.cts +3 -5
- package/dist/types/babel.d.ts +3 -5
- package/dist/types/build.d.cts +26 -1
- package/dist/types/build.d.ts +26 -1
- package/dist/types/commands.d.cts +3 -5
- package/dist/types/commands.d.ts +3 -5
- package/dist/types/config.d.cts +3 -5
- package/dist/types/config.d.ts +3 -5
- package/dist/types/context.d.cts +3 -5
- package/dist/types/context.d.ts +3 -5
- package/dist/types/{vfs.cjs → fs.cjs} +3 -3
- package/dist/types/{vfs.d.cts → fs.d.cts} +54 -35
- package/dist/types/{vfs.d.ts → fs.d.ts} +54 -35
- package/dist/types/fs.js +2 -0
- package/dist/types/hooks.d.cts +3 -5
- package/dist/types/hooks.d.ts +3 -5
- package/dist/types/index.cjs +9 -8
- package/dist/types/index.d.cts +8 -9
- package/dist/types/index.d.ts +8 -9
- package/dist/types/index.js +3 -2
- package/dist/types/internal.d.cts +46 -9
- package/dist/types/internal.d.ts +46 -9
- package/dist/types/plugin.d.cts +3 -5
- package/dist/types/plugin.d.ts +3 -5
- package/dist/types/resolved.d.cts +3 -5
- package/dist/types/resolved.d.ts +3 -5
- package/dist/types/tsconfig.d.cts +8 -1
- package/dist/types/tsconfig.d.ts +8 -1
- package/dist/types/typedoc.d.cts +3 -1
- package/dist/types/typedoc.d.ts +3 -1
- package/dist/types/unplugin.d.cts +22 -11
- package/dist/types/unplugin.d.ts +22 -11
- package/dist/unloader.cjs +7 -7
- package/dist/unloader.d.cts +12 -14
- package/dist/unloader.d.ts +12 -14
- package/dist/unloader.js +4 -4
- package/dist/unplugin.cjs +18 -18
- package/dist/unplugin.d.cts +6 -9
- package/dist/unplugin.d.ts +6 -9
- package/dist/unplugin.js +15 -15
- package/dist/vite.cjs +7 -7
- package/dist/vite.d.cts +3 -5
- package/dist/vite.d.ts +3 -5
- package/dist/vite.js +4 -4
- package/dist/webpack.cjs +7 -7
- package/dist/webpack.d.cts +3 -5
- package/dist/webpack.d.ts +3 -5
- package/dist/webpack.js +4 -4
- package/package.json +39 -11
- package/schemas/fs.capnp +73 -15
- package/dist/chunk-RODEAGIJ.cjs +0 -32
- package/dist/chunk-SKLSRHBU.js +0 -29
- package/dist/hooks-D2UGCryi.d.ts +0 -28
- package/dist/hooks-DJG3B-Hw.d.cts +0 -28
- package/dist/lib/create-program.cjs +0 -11
- package/dist/lib/create-program.js +0 -2
- package/dist/lib/hooks-CDLPWf7j.d.cts +0 -28
- package/dist/lib/hooks-Cn-IqwYp.d.ts +0 -28
- package/dist/types/vfs.js +0 -2
- /package/dist/{chunk-KIKTWMI3.cjs → chunk-2NCILNCH.cjs} +0 -0
- /package/dist/{chunk-XVLT2RQ2.js → chunk-BLNT5INX.js} +0 -0
- /package/dist/{lib/chunk-RJ4277VZ.cjs → chunk-GRU7B3QM.cjs} +0 -0
- /package/dist/{lib/chunk-ZBLDAREE.js → chunk-T2P533I5.js} +0 -0
- /package/dist/lib/{chunk-CGYAL3S2.cjs → chunk-4EIXDLFP.cjs} +0 -0
- /package/dist/lib/{chunk-CXRSMYEX.js → chunk-RD5AUWXN.js} +0 -0
|
@@ -1,75 +1,48 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chunk2NZADVP5_cjs = require('./chunk-2NZADVP5.cjs');
|
|
4
|
-
var chunk4NHFXDTQ_cjs = require('./chunk-4NHFXDTQ.cjs');
|
|
5
3
|
var chunk7XHBIYIN_cjs = require('./chunk-7XHBIYIN.cjs');
|
|
6
|
-
var chunkULJVBW4L_cjs = require('./chunk-ULJVBW4L.cjs');
|
|
7
|
-
var chunkBQU53ZNB_cjs = require('./chunk-BQU53ZNB.cjs');
|
|
8
4
|
var chunkXW5TELHB_cjs = require('./chunk-XW5TELHB.cjs');
|
|
9
5
|
var chunkJA4HSQRN_cjs = require('./chunk-JA4HSQRN.cjs');
|
|
10
|
-
var chunk3OCI4TH7_cjs = require('./chunk-3OCI4TH7.cjs');
|
|
11
6
|
var chunkISBHXSDH_cjs = require('./chunk-ISBHXSDH.cjs');
|
|
12
7
|
var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.cjs');
|
|
13
8
|
var types = require('@storm-software/config-tools/types');
|
|
14
|
-
var getWorkspaceRoot = require('@stryke/fs/get-workspace-root');
|
|
15
|
-
var bundleRequire = require('bundle-require');
|
|
16
|
-
var core = require('@babel/core');
|
|
17
|
-
var console = require('@storm-software/config-tools/logger/console');
|
|
18
9
|
var toArray = require('@stryke/convert/to-array');
|
|
19
|
-
var copyFile = require('@stryke/fs/copy-file');
|
|
20
|
-
var exists = require('@stryke/fs/exists');
|
|
21
|
-
var helpers = require('@stryke/fs/helpers');
|
|
22
|
-
var install = require('@stryke/fs/install');
|
|
23
|
-
var listFiles = require('@stryke/fs/list-files');
|
|
24
|
-
var packageFns = require('@stryke/fs/package-fns');
|
|
25
|
-
var resolve = require('@stryke/fs/resolve');
|
|
26
|
-
var append = require('@stryke/path/append');
|
|
27
|
-
var joinPaths = require('@stryke/path/join-paths');
|
|
28
|
-
var replace = require('@stryke/path/replace');
|
|
29
|
-
var isError = require('@stryke/type-checks/is-error');
|
|
30
|
-
var isFunction = require('@stryke/type-checks/is-function');
|
|
31
|
-
var isNumber = require('@stryke/type-checks/is-number');
|
|
32
|
-
var isPromise = require('@stryke/type-checks/is-promise');
|
|
33
|
-
var isSet = require('@stryke/type-checks/is-set');
|
|
34
|
-
var isSetObject = require('@stryke/type-checks/is-set-object');
|
|
35
|
-
var isSetString = require('@stryke/type-checks/is-set-string');
|
|
36
|
-
var chalk4 = require('chalk');
|
|
37
|
-
var defu2 = require('defu');
|
|
38
|
-
var Handlebars = require('handlebars');
|
|
39
|
-
var helperPluginUtils = require('@babel/helper-plugin-utils');
|
|
40
|
-
var t = require('@babel/types');
|
|
41
|
-
var titleCase = require('@stryke/string-format/title-case');
|
|
42
10
|
var getEnvPaths = require('@stryke/env/get-env-paths');
|
|
11
|
+
var exists = require('@stryke/fs/exists');
|
|
12
|
+
var getWorkspaceRoot = require('@stryke/fs/get-workspace-root');
|
|
43
13
|
var json = require('@stryke/fs/json');
|
|
14
|
+
var resolve = require('@stryke/fs/resolve');
|
|
44
15
|
var murmurhash = require('@stryke/hash/murmurhash');
|
|
45
16
|
var getUnique = require('@stryke/helpers/get-unique');
|
|
46
17
|
var omit = require('@stryke/helpers/omit');
|
|
47
18
|
var stormJson = require('@stryke/json/storm-json');
|
|
48
|
-
var
|
|
19
|
+
var append = require('@stryke/path/append');
|
|
49
20
|
var isType = require('@stryke/path/is-type');
|
|
50
21
|
var join = require('@stryke/path/join');
|
|
22
|
+
var replace = require('@stryke/path/replace');
|
|
23
|
+
var titleCase = require('@stryke/string-format/title-case');
|
|
51
24
|
var isNull = require('@stryke/type-checks/is-null');
|
|
25
|
+
var isSetObject = require('@stryke/type-checks/is-set-object');
|
|
26
|
+
var isSetString = require('@stryke/type-checks/is-set-string');
|
|
52
27
|
var isString = require('@stryke/type-checks/is-string');
|
|
53
28
|
var uuid = require('@stryke/unique-id/uuid');
|
|
54
|
-
var
|
|
29
|
+
var defu2 = require('defu');
|
|
30
|
+
var joinPaths = require('@stryke/path/join-paths');
|
|
31
|
+
var jiti = require('jiti');
|
|
32
|
+
var isFunction = require('@stryke/type-checks/is-function');
|
|
33
|
+
var isUndefined = require('@stryke/type-checks/is-undefined');
|
|
55
34
|
var $ = require('@stryke/capnp');
|
|
56
35
|
var bufferToString = require('@stryke/convert/buffer-to-string');
|
|
57
36
|
var buffer = require('@stryke/fs/buffer');
|
|
37
|
+
var filePathFns = require('@stryke/path/file-path-fns');
|
|
58
38
|
var prettyBytes = require('@stryke/string-format/pretty-bytes');
|
|
59
39
|
var isBuffer = require('@stryke/type-checks/is-buffer');
|
|
60
40
|
var buffer$1 = require('buffer');
|
|
61
|
-
var
|
|
41
|
+
var _fs = require('fs');
|
|
62
42
|
var prettier = require('prettier');
|
|
63
|
-
var isUndefined = require('@stryke/type-checks/is-undefined');
|
|
64
43
|
var isParentPath = require('@stryke/path/is-parent-path');
|
|
65
44
|
var volume = require('memfs/lib/node/volume');
|
|
66
45
|
var unionfs = require('unionfs');
|
|
67
|
-
var jiti = require('jiti');
|
|
68
|
-
var isObject = require('@stryke/type-checks/is-object');
|
|
69
|
-
var ts = require('typescript');
|
|
70
|
-
var _package = require('@stryke/string-format/package');
|
|
71
|
-
var superdiff = require('@donedeal0/superdiff');
|
|
72
|
-
var tsconfig = require('@stryke/fs/tsconfig');
|
|
73
46
|
|
|
74
47
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
75
48
|
|
|
@@ -91,160 +64,98 @@ function _interopNamespace(e) {
|
|
|
91
64
|
return Object.freeze(n);
|
|
92
65
|
}
|
|
93
66
|
|
|
94
|
-
var chalk4__default = /*#__PURE__*/_interopDefault(chalk4);
|
|
95
67
|
var defu2__default = /*#__PURE__*/_interopDefault(defu2);
|
|
96
|
-
var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
|
|
97
|
-
var t__namespace = /*#__PURE__*/_interopNamespace(t);
|
|
98
68
|
var $__namespace = /*#__PURE__*/_interopNamespace($);
|
|
99
|
-
var
|
|
100
|
-
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
69
|
+
var _fs__default = /*#__PURE__*/_interopDefault(_fs);
|
|
101
70
|
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
71
|
+
function resolveOptions(options) {
|
|
72
|
+
return defu2__default.default(options, {
|
|
73
|
+
interopDefault: true,
|
|
74
|
+
fsCache: options.mode !== "development" ? joinPaths.joinPaths(options.cacheDir, "jiti") : false,
|
|
75
|
+
moduleCache: options.mode !== "development"
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
chunkUSNT2KNT_cjs.__name(resolveOptions, "resolveOptions");
|
|
79
|
+
function createPluginResolver(options) {
|
|
80
|
+
return jiti.createJiti(joinPaths.joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions({
|
|
81
|
+
...options
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
chunkUSNT2KNT_cjs.__name(createPluginResolver, "createPluginResolver");
|
|
85
|
+
function createResolver(options) {
|
|
86
|
+
const baseResolver = jiti.createJiti(joinPaths.joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions(options));
|
|
87
|
+
baseResolver.plugin = createPluginResolver(options);
|
|
88
|
+
return baseResolver;
|
|
114
89
|
}
|
|
115
|
-
chunkUSNT2KNT_cjs.__name(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
|
|
126
|
-
"
|
|
127
|
-
"
|
|
128
|
-
"jest.requireActual",
|
|
129
|
-
"jest.requireMock",
|
|
130
|
-
// Older Jest methods
|
|
131
|
-
"require.requireActual",
|
|
132
|
-
"require.requireMock"
|
|
90
|
+
chunkUSNT2KNT_cjs.__name(createResolver, "createResolver");
|
|
91
|
+
|
|
92
|
+
// src/types/commands.ts
|
|
93
|
+
var SUPPORTED_COMMANDS = [
|
|
94
|
+
"new",
|
|
95
|
+
"clean",
|
|
96
|
+
"prepare",
|
|
97
|
+
"lint",
|
|
98
|
+
"test",
|
|
99
|
+
"build",
|
|
100
|
+
"docs",
|
|
101
|
+
"deploy",
|
|
102
|
+
"finalize"
|
|
133
103
|
];
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
if (!t__namespace.isIdentifier(node) || pattern.includes(".")) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
const name = pattern.split(".")[0];
|
|
143
|
-
return node.name === name;
|
|
104
|
+
|
|
105
|
+
// src/plugin-utils/helpers.ts
|
|
106
|
+
function isPlugin(value) {
|
|
107
|
+
return isSetObject.isSetObject(value) && "name" in value && isSetString.isSetString(value.name) && (isUndefined.isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction.isFunction(value.applyToEnvironment)) && (isUndefined.isUndefined(value.dedupe) || "dedupe" in value && isFunction.isFunction(value.dedupe)) && (isUndefined.isUndefined(value.dependsOn) || "dependsOn" in value && Array.isArray(value.dependsOn) && value.dependsOn.every(isPluginConfig)) && SUPPORTED_COMMANDS.every((command) => isUndefined.isUndefined(value[command]) || command in value && (isFunction.isFunction(value[command]) || isSetObject.isSetObject(value[command]) && "handler" in value[command] && isFunction.isFunction(value[command].handler)));
|
|
144
108
|
}
|
|
145
|
-
chunkUSNT2KNT_cjs.__name(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
programPath.traverse(importVisitors, {
|
|
181
|
-
...state,
|
|
182
|
-
context,
|
|
183
|
-
moduleResolverVisited,
|
|
184
|
-
api
|
|
185
|
-
});
|
|
186
|
-
},
|
|
187
|
-
exit(programPath, state) {
|
|
188
|
-
programPath.traverse(importVisitors, {
|
|
189
|
-
...state,
|
|
190
|
-
context,
|
|
191
|
-
moduleResolverVisited,
|
|
192
|
-
api
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
post() {
|
|
198
|
-
moduleResolverVisited.clear();
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
}, "builder"));
|
|
202
|
-
}, "moduleResolverBabelPlugin");
|
|
203
|
-
var DEFAULT_ENVIRONMENT = "default";
|
|
204
|
-
function createEnvironment(name, userConfig) {
|
|
205
|
-
return defu2__default.default(userConfig.environments?.[name] ?? {}, {
|
|
206
|
-
name,
|
|
207
|
-
title: userConfig.title || titleCase.titleCase(userConfig.name),
|
|
208
|
-
ssr: false,
|
|
209
|
-
mainFields: userConfig.build?.platform === "browser" ? [
|
|
210
|
-
"browser",
|
|
211
|
-
"module",
|
|
212
|
-
"jsnext:main",
|
|
213
|
-
"jsnext"
|
|
214
|
-
] : [
|
|
215
|
-
"module",
|
|
216
|
-
"jsnext:main",
|
|
217
|
-
"jsnext"
|
|
218
|
-
],
|
|
219
|
-
extensions: [
|
|
220
|
-
".mjs",
|
|
221
|
-
".js",
|
|
222
|
-
".mts",
|
|
223
|
-
".ts",
|
|
224
|
-
".jsx",
|
|
225
|
-
".tsx",
|
|
226
|
-
".json"
|
|
227
|
-
],
|
|
228
|
-
consumer: userConfig.build?.platform === "browser" ? "client" : "server",
|
|
229
|
-
preview: userConfig.build?.platform === "browser" ? {
|
|
230
|
-
port: 5173,
|
|
231
|
-
open: true,
|
|
232
|
-
strictPort: false,
|
|
233
|
-
// https: false,
|
|
234
|
-
host: "localhost",
|
|
235
|
-
allowedHosts: [
|
|
236
|
-
"."
|
|
237
|
-
],
|
|
238
|
-
cors: true,
|
|
239
|
-
headers: {}
|
|
240
|
-
} : void 0
|
|
241
|
-
}, userConfig);
|
|
109
|
+
chunkUSNT2KNT_cjs.__name(isPlugin, "isPlugin");
|
|
110
|
+
function isPluginConfigObject(value) {
|
|
111
|
+
return isSetObject.isSetObject(value) && "plugin" in value && ((isSetString.isSetString(value.plugin) || isFunction.isFunction(value.plugin)) && "options" in value && isSetObject.isSetObject(value.options) || isPlugin(value.plugin));
|
|
112
|
+
}
|
|
113
|
+
chunkUSNT2KNT_cjs.__name(isPluginConfigObject, "isPluginConfigObject");
|
|
114
|
+
function isPluginConfigTuple(value) {
|
|
115
|
+
return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString.isSetString(value[0]) || isFunction.isFunction(value[0])) && value.length > 1 && isSetObject.isSetObject(value[1]) || isPlugin(value[0]));
|
|
116
|
+
}
|
|
117
|
+
chunkUSNT2KNT_cjs.__name(isPluginConfigTuple, "isPluginConfigTuple");
|
|
118
|
+
function isPluginConfig(value) {
|
|
119
|
+
return isSetString.isSetString(value) || isFunction.isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
|
|
120
|
+
}
|
|
121
|
+
chunkUSNT2KNT_cjs.__name(isPluginConfig, "isPluginConfig");
|
|
122
|
+
function isPluginHookFunction(value) {
|
|
123
|
+
return isFunction.isFunction(value) || isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
|
|
124
|
+
}
|
|
125
|
+
chunkUSNT2KNT_cjs.__name(isPluginHookFunction, "isPluginHookFunction");
|
|
126
|
+
function isPluginHookObject(value) {
|
|
127
|
+
return isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
|
|
128
|
+
}
|
|
129
|
+
chunkUSNT2KNT_cjs.__name(isPluginHookObject, "isPluginHookObject");
|
|
130
|
+
function isPluginHook(value) {
|
|
131
|
+
return isPluginHookFunction(value) || isPluginHookObject(value);
|
|
132
|
+
}
|
|
133
|
+
chunkUSNT2KNT_cjs.__name(isPluginHook, "isPluginHook");
|
|
134
|
+
function getHookHandler(pluginHook) {
|
|
135
|
+
return isFunction.isFunction(pluginHook) ? pluginHook : pluginHook.handler;
|
|
136
|
+
}
|
|
137
|
+
chunkUSNT2KNT_cjs.__name(getHookHandler, "getHookHandler");
|
|
138
|
+
function isHookExternal(hook) {
|
|
139
|
+
return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
|
|
140
|
+
}
|
|
141
|
+
chunkUSNT2KNT_cjs.__name(isHookExternal, "isHookExternal");
|
|
142
|
+
function checkDedupe(plugin, plugins) {
|
|
143
|
+
return plugin.dedupe === false || plugins.some((p) => p.dedupe !== false && (isFunction.isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
|
|
242
144
|
}
|
|
243
|
-
chunkUSNT2KNT_cjs.__name(
|
|
244
|
-
function
|
|
245
|
-
|
|
145
|
+
chunkUSNT2KNT_cjs.__name(checkDedupe, "checkDedupe");
|
|
146
|
+
function addPluginHook(context, plugin, pluginHook, hooksList) {
|
|
147
|
+
if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
|
|
148
|
+
hooksList.push(isFunction.isFunction(pluginHook) ? {
|
|
149
|
+
plugin,
|
|
150
|
+
handler: getHookHandler(pluginHook).bind(context)
|
|
151
|
+
} : {
|
|
152
|
+
plugin,
|
|
153
|
+
...pluginHook,
|
|
154
|
+
handler: getHookHandler(pluginHook).bind(context)
|
|
155
|
+
});
|
|
156
|
+
}
|
|
246
157
|
}
|
|
247
|
-
chunkUSNT2KNT_cjs.__name(
|
|
158
|
+
chunkUSNT2KNT_cjs.__name(addPluginHook, "addPluginHook");
|
|
248
159
|
BigInt("0xa56c61324b9d6e49");
|
|
249
160
|
var FileMetadata_KeyValuePair = class extends $__namespace.Struct {
|
|
250
161
|
static {
|
|
@@ -279,12 +190,12 @@ var FileMetadata = class _FileMetadata extends $__namespace.Struct {
|
|
|
279
190
|
static _capnp = {
|
|
280
191
|
displayName: "FileMetadata",
|
|
281
192
|
id: "8e2cab5d7e28c7b3",
|
|
282
|
-
size: new $__namespace.ObjectSize(
|
|
283
|
-
|
|
193
|
+
size: new $__namespace.ObjectSize(8, 4),
|
|
194
|
+
defaultType: "normal"
|
|
284
195
|
};
|
|
285
196
|
static _Properties;
|
|
286
197
|
/**
|
|
287
|
-
* The
|
|
198
|
+
* The type of the file.
|
|
288
199
|
*
|
|
289
200
|
*/
|
|
290
201
|
get id() {
|
|
@@ -297,14 +208,14 @@ var FileMetadata = class _FileMetadata extends $__namespace.Struct {
|
|
|
297
208
|
* The output mode of the file.
|
|
298
209
|
*
|
|
299
210
|
*/
|
|
300
|
-
get
|
|
301
|
-
return $__namespace.utils.getText(1, this, _FileMetadata._capnp.
|
|
211
|
+
get type() {
|
|
212
|
+
return $__namespace.utils.getText(1, this, _FileMetadata._capnp.defaultType);
|
|
302
213
|
}
|
|
303
|
-
set
|
|
214
|
+
set type(value) {
|
|
304
215
|
$__namespace.utils.setText(1, value, this);
|
|
305
216
|
}
|
|
306
217
|
/**
|
|
307
|
-
*
|
|
218
|
+
* The timestamp representing the file's creation date.
|
|
308
219
|
*
|
|
309
220
|
*/
|
|
310
221
|
get mode() {
|
|
@@ -313,6 +224,16 @@ var FileMetadata = class _FileMetadata extends $__namespace.Struct {
|
|
|
313
224
|
set mode(value) {
|
|
314
225
|
$__namespace.utils.setText(2, value, this);
|
|
315
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Additional metadata associated with the file.
|
|
229
|
+
*
|
|
230
|
+
*/
|
|
231
|
+
get timestamp() {
|
|
232
|
+
return $__namespace.utils.getUint32(0, this);
|
|
233
|
+
}
|
|
234
|
+
set timestamp(value) {
|
|
235
|
+
$__namespace.utils.setUint32(0, value, this);
|
|
236
|
+
}
|
|
316
237
|
_adoptProperties(value) {
|
|
317
238
|
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(3, this));
|
|
318
239
|
}
|
|
@@ -335,33 +256,214 @@ var FileMetadata = class _FileMetadata extends $__namespace.Struct {
|
|
|
335
256
|
return "FileMetadata_" + super.toString();
|
|
336
257
|
}
|
|
337
258
|
};
|
|
338
|
-
var
|
|
259
|
+
var ChunkData = class extends $__namespace.Struct {
|
|
339
260
|
static {
|
|
340
|
-
chunkUSNT2KNT_cjs.__name(this, "
|
|
261
|
+
chunkUSNT2KNT_cjs.__name(this, "ChunkData");
|
|
341
262
|
}
|
|
342
263
|
static _capnp = {
|
|
343
|
-
displayName: "
|
|
344
|
-
id: "
|
|
345
|
-
size: new $__namespace.ObjectSize(
|
|
264
|
+
displayName: "ChunkData",
|
|
265
|
+
id: "84076f13b057f83a",
|
|
266
|
+
size: new $__namespace.ObjectSize(8, 4)
|
|
346
267
|
};
|
|
347
268
|
/**
|
|
348
|
-
* An additional
|
|
269
|
+
* An additional name for the file.
|
|
349
270
|
*
|
|
350
271
|
*/
|
|
351
|
-
get
|
|
272
|
+
get id() {
|
|
352
273
|
return $__namespace.utils.getText(0, this);
|
|
353
274
|
}
|
|
354
|
-
set
|
|
275
|
+
set id(value) {
|
|
276
|
+
$__namespace.utils.setText(0, value, this);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Files that are implicitly loaded after one of the specified files.
|
|
280
|
+
*
|
|
281
|
+
*/
|
|
282
|
+
get name() {
|
|
283
|
+
return $__namespace.utils.getText(1, this);
|
|
284
|
+
}
|
|
285
|
+
set name(value) {
|
|
286
|
+
$__namespace.utils.setText(1, value, this);
|
|
287
|
+
}
|
|
288
|
+
_adoptImplicitlyLoadedAfterOneOf(value) {
|
|
289
|
+
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
|
|
290
|
+
}
|
|
291
|
+
_disownImplicitlyLoadedAfterOneOf() {
|
|
292
|
+
return $__namespace.utils.disown(this.implicitlyLoadedAfterOneOf);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* The importer of the file.
|
|
296
|
+
*
|
|
297
|
+
*/
|
|
298
|
+
get implicitlyLoadedAfterOneOf() {
|
|
299
|
+
return $__namespace.utils.getList(2, $__namespace.TextList, this);
|
|
300
|
+
}
|
|
301
|
+
_hasImplicitlyLoadedAfterOneOf() {
|
|
302
|
+
return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
|
|
303
|
+
}
|
|
304
|
+
_initImplicitlyLoadedAfterOneOf(length) {
|
|
305
|
+
return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
|
|
306
|
+
}
|
|
307
|
+
set implicitlyLoadedAfterOneOf(value) {
|
|
308
|
+
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* The signature preservation mode for the file.
|
|
312
|
+
*
|
|
313
|
+
*/
|
|
314
|
+
get importer() {
|
|
315
|
+
return $__namespace.utils.getText(3, this);
|
|
316
|
+
}
|
|
317
|
+
set importer(value) {
|
|
318
|
+
$__namespace.utils.setText(3, value, this);
|
|
319
|
+
}
|
|
320
|
+
get preserveSignature() {
|
|
321
|
+
return $__namespace.utils.getUint16(0, this);
|
|
322
|
+
}
|
|
323
|
+
set preserveSignature(value) {
|
|
324
|
+
$__namespace.utils.setUint16(0, value, this);
|
|
325
|
+
}
|
|
326
|
+
toString() {
|
|
327
|
+
return "ChunkData_" + super.toString();
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
var PrebuiltData = class extends $__namespace.Struct {
|
|
331
|
+
static {
|
|
332
|
+
chunkUSNT2KNT_cjs.__name(this, "PrebuiltData");
|
|
333
|
+
}
|
|
334
|
+
static _capnp = {
|
|
335
|
+
displayName: "PrebuiltData",
|
|
336
|
+
id: "c5b1a6ca696328ee",
|
|
337
|
+
size: new $__namespace.ObjectSize(0, 4)
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* An additional name for the file.
|
|
341
|
+
*
|
|
342
|
+
*/
|
|
343
|
+
get id() {
|
|
344
|
+
return $__namespace.utils.getText(0, this);
|
|
345
|
+
}
|
|
346
|
+
set id(value) {
|
|
355
347
|
$__namespace.utils.setText(0, value, this);
|
|
356
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* The file exports.
|
|
351
|
+
*
|
|
352
|
+
*/
|
|
353
|
+
get name() {
|
|
354
|
+
return $__namespace.utils.getText(1, this);
|
|
355
|
+
}
|
|
356
|
+
set name(value) {
|
|
357
|
+
$__namespace.utils.setText(1, value, this);
|
|
358
|
+
}
|
|
359
|
+
_adoptExports(value) {
|
|
360
|
+
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
|
|
361
|
+
}
|
|
362
|
+
_disownExports() {
|
|
363
|
+
return $__namespace.utils.disown(this.exports);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* The source map for the file.
|
|
367
|
+
*
|
|
368
|
+
*/
|
|
369
|
+
get exports() {
|
|
370
|
+
return $__namespace.utils.getList(2, $__namespace.TextList, this);
|
|
371
|
+
}
|
|
372
|
+
_hasExports() {
|
|
373
|
+
return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
|
|
374
|
+
}
|
|
375
|
+
_initExports(length) {
|
|
376
|
+
return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
|
|
377
|
+
}
|
|
378
|
+
set exports(value) {
|
|
379
|
+
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
380
|
+
}
|
|
381
|
+
get map() {
|
|
382
|
+
return $__namespace.utils.getText(3, this);
|
|
383
|
+
}
|
|
384
|
+
set map(value) {
|
|
385
|
+
$__namespace.utils.setText(3, value, this);
|
|
386
|
+
}
|
|
387
|
+
toString() {
|
|
388
|
+
return "PrebuiltData_" + super.toString();
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
var AssetData = class extends $__namespace.Struct {
|
|
392
|
+
static {
|
|
393
|
+
chunkUSNT2KNT_cjs.__name(this, "AssetData");
|
|
394
|
+
}
|
|
395
|
+
static _capnp = {
|
|
396
|
+
displayName: "AssetData",
|
|
397
|
+
id: "da660c6c1fa4c830",
|
|
398
|
+
size: new $__namespace.ObjectSize(8, 3)
|
|
399
|
+
};
|
|
400
|
+
/**
|
|
401
|
+
* An additional name for the file.
|
|
402
|
+
*
|
|
403
|
+
*/
|
|
357
404
|
get id() {
|
|
405
|
+
return $__namespace.utils.getText(0, this);
|
|
406
|
+
}
|
|
407
|
+
set id(value) {
|
|
408
|
+
$__namespace.utils.setText(0, value, this);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Indicates whether the file needs a code reference.
|
|
412
|
+
*
|
|
413
|
+
*/
|
|
414
|
+
get name() {
|
|
358
415
|
return $__namespace.utils.getText(1, this);
|
|
359
416
|
}
|
|
417
|
+
set name(value) {
|
|
418
|
+
$__namespace.utils.setText(1, value, this);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* The original file name before any transformations.
|
|
422
|
+
*
|
|
423
|
+
*/
|
|
424
|
+
get needsCodeReference() {
|
|
425
|
+
return $__namespace.utils.getBit(0, this);
|
|
426
|
+
}
|
|
427
|
+
set needsCodeReference(value) {
|
|
428
|
+
$__namespace.utils.setBit(0, value, this);
|
|
429
|
+
}
|
|
430
|
+
get originalFileName() {
|
|
431
|
+
return $__namespace.utils.getText(2, this);
|
|
432
|
+
}
|
|
433
|
+
set originalFileName(value) {
|
|
434
|
+
$__namespace.utils.setText(2, value, this);
|
|
435
|
+
}
|
|
436
|
+
toString() {
|
|
437
|
+
return "AssetData_" + super.toString();
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
var FileId = class extends $__namespace.Struct {
|
|
441
|
+
static {
|
|
442
|
+
chunkUSNT2KNT_cjs.__name(this, "FileId");
|
|
443
|
+
}
|
|
444
|
+
static _capnp = {
|
|
445
|
+
displayName: "FileId",
|
|
446
|
+
id: "990d6a471072f997",
|
|
447
|
+
size: new $__namespace.ObjectSize(0, 2)
|
|
448
|
+
};
|
|
449
|
+
/**
|
|
450
|
+
* A virtual (or actual) path to the file in the file system.
|
|
451
|
+
*
|
|
452
|
+
*/
|
|
453
|
+
get id() {
|
|
454
|
+
return $__namespace.utils.getText(0, this);
|
|
455
|
+
}
|
|
360
456
|
set id(value) {
|
|
457
|
+
$__namespace.utils.setText(0, value, this);
|
|
458
|
+
}
|
|
459
|
+
get path() {
|
|
460
|
+
return $__namespace.utils.getText(1, this);
|
|
461
|
+
}
|
|
462
|
+
set path(value) {
|
|
361
463
|
$__namespace.utils.setText(1, value, this);
|
|
362
464
|
}
|
|
363
465
|
toString() {
|
|
364
|
-
return "
|
|
466
|
+
return "FileId_" + super.toString();
|
|
365
467
|
}
|
|
366
468
|
};
|
|
367
469
|
var FileData = class extends $__namespace.Struct {
|
|
@@ -374,7 +476,7 @@ var FileData = class extends $__namespace.Struct {
|
|
|
374
476
|
size: new $__namespace.ObjectSize(0, 2)
|
|
375
477
|
};
|
|
376
478
|
/**
|
|
377
|
-
*
|
|
479
|
+
* A virtual (or actual) path to the file in the file system.
|
|
378
480
|
*
|
|
379
481
|
*/
|
|
380
482
|
get path() {
|
|
@@ -383,28 +485,31 @@ var FileData = class extends $__namespace.Struct {
|
|
|
383
485
|
set path(value) {
|
|
384
486
|
$__namespace.utils.setText(0, value, this);
|
|
385
487
|
}
|
|
386
|
-
get
|
|
488
|
+
get code() {
|
|
387
489
|
return $__namespace.utils.getText(1, this);
|
|
388
490
|
}
|
|
389
|
-
set
|
|
491
|
+
set code(value) {
|
|
390
492
|
$__namespace.utils.setText(1, value, this);
|
|
391
493
|
}
|
|
392
494
|
toString() {
|
|
393
495
|
return "FileData_" + super.toString();
|
|
394
496
|
}
|
|
395
497
|
};
|
|
396
|
-
var
|
|
498
|
+
var FileSystem = class _FileSystem extends $__namespace.Struct {
|
|
397
499
|
static {
|
|
398
|
-
chunkUSNT2KNT_cjs.__name(this, "
|
|
500
|
+
chunkUSNT2KNT_cjs.__name(this, "FileSystem");
|
|
399
501
|
}
|
|
400
502
|
static _capnp = {
|
|
401
|
-
displayName: "
|
|
402
|
-
id: "
|
|
403
|
-
size: new $__namespace.ObjectSize(0,
|
|
503
|
+
displayName: "FileSystem",
|
|
504
|
+
id: "ae0c23d43e56abcf",
|
|
505
|
+
size: new $__namespace.ObjectSize(0, 6)
|
|
404
506
|
};
|
|
405
507
|
static _Ids;
|
|
406
|
-
static _Metadata;
|
|
407
508
|
static _Files;
|
|
509
|
+
static _Metadata;
|
|
510
|
+
static _Assets;
|
|
511
|
+
static _Chunks;
|
|
512
|
+
static _Prebuilt;
|
|
408
513
|
_adoptIds(value) {
|
|
409
514
|
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(0, this));
|
|
410
515
|
}
|
|
@@ -412,63 +517,120 @@ var FileSystemData = class _FileSystemData extends $__namespace.Struct {
|
|
|
412
517
|
return $__namespace.utils.disown(this.ids);
|
|
413
518
|
}
|
|
414
519
|
get ids() {
|
|
415
|
-
return $__namespace.utils.getList(0,
|
|
520
|
+
return $__namespace.utils.getList(0, _FileSystem._Ids, this);
|
|
416
521
|
}
|
|
417
522
|
_hasIds() {
|
|
418
523
|
return !$__namespace.utils.isNull($__namespace.utils.getPointer(0, this));
|
|
419
524
|
}
|
|
420
525
|
_initIds(length) {
|
|
421
|
-
return $__namespace.utils.initList(0,
|
|
526
|
+
return $__namespace.utils.initList(0, _FileSystem._Ids, length, this);
|
|
422
527
|
}
|
|
423
528
|
set ids(value) {
|
|
424
529
|
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(0, this));
|
|
425
530
|
}
|
|
426
|
-
|
|
531
|
+
_adoptFiles(value) {
|
|
427
532
|
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(1, this));
|
|
428
533
|
}
|
|
429
|
-
|
|
430
|
-
return $__namespace.utils.disown(this.
|
|
534
|
+
_disownFiles() {
|
|
535
|
+
return $__namespace.utils.disown(this.files);
|
|
431
536
|
}
|
|
432
|
-
get
|
|
433
|
-
return $__namespace.utils.getList(1,
|
|
537
|
+
get files() {
|
|
538
|
+
return $__namespace.utils.getList(1, _FileSystem._Files, this);
|
|
434
539
|
}
|
|
435
|
-
|
|
540
|
+
_hasFiles() {
|
|
436
541
|
return !$__namespace.utils.isNull($__namespace.utils.getPointer(1, this));
|
|
437
542
|
}
|
|
438
|
-
|
|
439
|
-
return $__namespace.utils.initList(1,
|
|
543
|
+
_initFiles(length) {
|
|
544
|
+
return $__namespace.utils.initList(1, _FileSystem._Files, length, this);
|
|
440
545
|
}
|
|
441
|
-
set
|
|
546
|
+
set files(value) {
|
|
442
547
|
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(1, this));
|
|
443
548
|
}
|
|
444
|
-
|
|
549
|
+
_adoptMetadata(value) {
|
|
445
550
|
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
|
|
446
551
|
}
|
|
447
|
-
|
|
448
|
-
return $__namespace.utils.disown(this.
|
|
552
|
+
_disownMetadata() {
|
|
553
|
+
return $__namespace.utils.disown(this.metadata);
|
|
449
554
|
}
|
|
450
|
-
get
|
|
451
|
-
return $__namespace.utils.getList(2,
|
|
555
|
+
get metadata() {
|
|
556
|
+
return $__namespace.utils.getList(2, _FileSystem._Metadata, this);
|
|
452
557
|
}
|
|
453
|
-
|
|
558
|
+
_hasMetadata() {
|
|
454
559
|
return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
|
|
455
560
|
}
|
|
456
|
-
|
|
457
|
-
return $__namespace.utils.initList(2,
|
|
561
|
+
_initMetadata(length) {
|
|
562
|
+
return $__namespace.utils.initList(2, _FileSystem._Metadata, length, this);
|
|
458
563
|
}
|
|
459
|
-
set
|
|
564
|
+
set metadata(value) {
|
|
460
565
|
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
461
566
|
}
|
|
567
|
+
_adoptAssets(value) {
|
|
568
|
+
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(3, this));
|
|
569
|
+
}
|
|
570
|
+
_disownAssets() {
|
|
571
|
+
return $__namespace.utils.disown(this.assets);
|
|
572
|
+
}
|
|
573
|
+
get assets() {
|
|
574
|
+
return $__namespace.utils.getList(3, _FileSystem._Assets, this);
|
|
575
|
+
}
|
|
576
|
+
_hasAssets() {
|
|
577
|
+
return !$__namespace.utils.isNull($__namespace.utils.getPointer(3, this));
|
|
578
|
+
}
|
|
579
|
+
_initAssets(length) {
|
|
580
|
+
return $__namespace.utils.initList(3, _FileSystem._Assets, length, this);
|
|
581
|
+
}
|
|
582
|
+
set assets(value) {
|
|
583
|
+
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(3, this));
|
|
584
|
+
}
|
|
585
|
+
_adoptChunks(value) {
|
|
586
|
+
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(4, this));
|
|
587
|
+
}
|
|
588
|
+
_disownChunks() {
|
|
589
|
+
return $__namespace.utils.disown(this.chunks);
|
|
590
|
+
}
|
|
591
|
+
get chunks() {
|
|
592
|
+
return $__namespace.utils.getList(4, _FileSystem._Chunks, this);
|
|
593
|
+
}
|
|
594
|
+
_hasChunks() {
|
|
595
|
+
return !$__namespace.utils.isNull($__namespace.utils.getPointer(4, this));
|
|
596
|
+
}
|
|
597
|
+
_initChunks(length) {
|
|
598
|
+
return $__namespace.utils.initList(4, _FileSystem._Chunks, length, this);
|
|
599
|
+
}
|
|
600
|
+
set chunks(value) {
|
|
601
|
+
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(4, this));
|
|
602
|
+
}
|
|
603
|
+
_adoptPrebuilt(value) {
|
|
604
|
+
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(5, this));
|
|
605
|
+
}
|
|
606
|
+
_disownPrebuilt() {
|
|
607
|
+
return $__namespace.utils.disown(this.prebuilt);
|
|
608
|
+
}
|
|
609
|
+
get prebuilt() {
|
|
610
|
+
return $__namespace.utils.getList(5, _FileSystem._Prebuilt, this);
|
|
611
|
+
}
|
|
612
|
+
_hasPrebuilt() {
|
|
613
|
+
return !$__namespace.utils.isNull($__namespace.utils.getPointer(5, this));
|
|
614
|
+
}
|
|
615
|
+
_initPrebuilt(length) {
|
|
616
|
+
return $__namespace.utils.initList(5, _FileSystem._Prebuilt, length, this);
|
|
617
|
+
}
|
|
618
|
+
set prebuilt(value) {
|
|
619
|
+
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(5, this));
|
|
620
|
+
}
|
|
462
621
|
toString() {
|
|
463
|
-
return "
|
|
622
|
+
return "FileSystem_" + super.toString();
|
|
464
623
|
}
|
|
465
624
|
};
|
|
466
625
|
FileMetadata._Properties = $__namespace.CompositeList(FileMetadata_KeyValuePair);
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
626
|
+
FileSystem._Ids = $__namespace.CompositeList(FileId);
|
|
627
|
+
FileSystem._Files = $__namespace.CompositeList(FileData);
|
|
628
|
+
FileSystem._Metadata = $__namespace.CompositeList(FileMetadata);
|
|
629
|
+
FileSystem._Assets = $__namespace.CompositeList(AssetData);
|
|
630
|
+
FileSystem._Chunks = $__namespace.CompositeList(ChunkData);
|
|
631
|
+
FileSystem._Prebuilt = $__namespace.CompositeList(PrebuiltData);
|
|
470
632
|
|
|
471
|
-
// src/types/
|
|
633
|
+
// src/types/fs.ts
|
|
472
634
|
var __VFS_PATCH__ = "__VFS_PATCH__";
|
|
473
635
|
var __VFS_REVERT__ = "__VFS_REVERT__";
|
|
474
636
|
function isBufferEncoding(options) {
|
|
@@ -483,10 +645,10 @@ function isNodeWriteFileOptions(options) {
|
|
|
483
645
|
return !isUndefined.isUndefined(options) && (isBufferEncoding(options) || !isPowerlinesWriteFileOptions(options));
|
|
484
646
|
}
|
|
485
647
|
chunkUSNT2KNT_cjs.__name(isNodeWriteFileOptions, "isNodeWriteFileOptions");
|
|
486
|
-
function
|
|
487
|
-
return !!(isSetObject.isSetObject(
|
|
648
|
+
function isVirtualFileData(obj) {
|
|
649
|
+
return !!(isSetObject.isSetObject(obj) && "code" in obj && obj.code);
|
|
488
650
|
}
|
|
489
|
-
chunkUSNT2KNT_cjs.__name(
|
|
651
|
+
chunkUSNT2KNT_cjs.__name(isVirtualFileData, "isVirtualFileData");
|
|
490
652
|
var FILE_PREFIX = "file://";
|
|
491
653
|
function toFilePath(pathOrUrl) {
|
|
492
654
|
if (!pathOrUrl) {
|
|
@@ -630,13 +792,13 @@ var UnifiedFS = class _UnifiedFS extends unionfs.Union {
|
|
|
630
792
|
/**
|
|
631
793
|
* The physical file system.
|
|
632
794
|
*/
|
|
633
|
-
#physicalFS = cloneFS(
|
|
795
|
+
#physicalFS = cloneFS(_fs__default.default);
|
|
634
796
|
/**
|
|
635
797
|
* The context of the unified file system.
|
|
636
798
|
*/
|
|
637
799
|
#context;
|
|
638
|
-
static create(context,
|
|
639
|
-
let result = new _UnifiedFS(context,
|
|
800
|
+
static create(context, fs2) {
|
|
801
|
+
let result = new _UnifiedFS(context, fs2);
|
|
640
802
|
result = result.use(result.#physicalFS);
|
|
641
803
|
if (result.#context.config.output.mode !== "fs") {
|
|
642
804
|
result = result.use(result.#virtualFS);
|
|
@@ -659,9 +821,9 @@ var UnifiedFS = class _UnifiedFS extends unionfs.Union {
|
|
|
659
821
|
* Creates a new instance of the VirtualFileSystem.
|
|
660
822
|
*
|
|
661
823
|
* @param context - The context of the virtual file system, typically containing options and logging functions.
|
|
662
|
-
* @param
|
|
824
|
+
* @param fs - A buffer containing the serialized virtual file system data.
|
|
663
825
|
*/
|
|
664
|
-
constructor(context,
|
|
826
|
+
constructor(context, fs2) {
|
|
665
827
|
super();
|
|
666
828
|
this.#context = context;
|
|
667
829
|
if (!this.#physicalFS.existsSync(this.#context.dataPath)) {
|
|
@@ -680,8 +842,8 @@ var UnifiedFS = class _UnifiedFS extends unionfs.Union {
|
|
|
680
842
|
});
|
|
681
843
|
}
|
|
682
844
|
if (this.#context.config.output.mode !== "fs") {
|
|
683
|
-
this.#virtualFS = volume.Volume.fromJSON(
|
|
684
|
-
ret[file.path] = file.
|
|
845
|
+
this.#virtualFS = volume.Volume.fromJSON(fs2._hasFiles() && fs2.files.length > 0 ? fs2.files.values().reduce((ret, file) => {
|
|
846
|
+
ret[file.path] = file.code;
|
|
685
847
|
return ret;
|
|
686
848
|
}, {}) : {});
|
|
687
849
|
if (!this.#virtualFS.existsSync(this.#context.artifactsPath)) {
|
|
@@ -1026,10 +1188,10 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1026
1188
|
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.cachePath, "fs.bin"))) {
|
|
1027
1189
|
const buffer$1 = await buffer.readFileBuffer(joinPaths.joinPaths(context.cachePath, "fs.bin"));
|
|
1028
1190
|
const message2 = new $__namespace.Message(buffer$1, false);
|
|
1029
|
-
return new _VirtualFileSystem(context, message2.getRoot(
|
|
1191
|
+
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1030
1192
|
}
|
|
1031
1193
|
const message = new $__namespace.Message();
|
|
1032
|
-
return new _VirtualFileSystem(context, message.initRoot(
|
|
1194
|
+
return new _VirtualFileSystem(context, message.initRoot(FileSystem));
|
|
1033
1195
|
}
|
|
1034
1196
|
/**
|
|
1035
1197
|
* Synchronously creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
|
|
@@ -1041,10 +1203,10 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1041
1203
|
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.cachePath, "fs.bin"))) {
|
|
1042
1204
|
const buffer$1 = buffer.readFileBufferSync(joinPaths.joinPaths(context.cachePath, "fs.bin"));
|
|
1043
1205
|
const message2 = new $__namespace.Message(buffer$1, false);
|
|
1044
|
-
return new _VirtualFileSystem(context, message2.getRoot(
|
|
1206
|
+
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1045
1207
|
}
|
|
1046
1208
|
const message = new $__namespace.Message();
|
|
1047
|
-
return new _VirtualFileSystem(context, message.initRoot(
|
|
1209
|
+
return new _VirtualFileSystem(context, message.initRoot(FileSystem));
|
|
1048
1210
|
}
|
|
1049
1211
|
/**
|
|
1050
1212
|
* A map of file ids to their metadata.
|
|
@@ -1068,19 +1230,20 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1068
1230
|
* Creates a new instance of the {@link VirtualFileSystem}.
|
|
1069
1231
|
*
|
|
1070
1232
|
* @param context - The context of the virtual file system, typically containing options and logging functions.
|
|
1071
|
-
* @param
|
|
1233
|
+
* @param fs - A buffer containing the serialized virtual file system data.
|
|
1072
1234
|
*/
|
|
1073
|
-
constructor(context,
|
|
1235
|
+
constructor(context, fs2) {
|
|
1074
1236
|
this.#context = context;
|
|
1075
|
-
this.#unifiedFS = UnifiedFS.create(context,
|
|
1237
|
+
this.#unifiedFS = UnifiedFS.create(context, fs2);
|
|
1076
1238
|
this.#metadata = {};
|
|
1077
|
-
if (
|
|
1078
|
-
this.#metadata =
|
|
1079
|
-
ret[
|
|
1080
|
-
id:
|
|
1081
|
-
|
|
1082
|
-
mode:
|
|
1083
|
-
|
|
1239
|
+
if (fs2._hasMetadata()) {
|
|
1240
|
+
this.#metadata = fs2.metadata.values().reduce((ret, metadata) => {
|
|
1241
|
+
ret[metadata.id] = {
|
|
1242
|
+
id: metadata.id,
|
|
1243
|
+
type: metadata.type,
|
|
1244
|
+
mode: metadata.mode,
|
|
1245
|
+
timestamp: metadata.timestamp || Date.now(),
|
|
1246
|
+
properties: metadata._hasProperties() ? metadata.properties.values().reduce((ret2, item) => {
|
|
1084
1247
|
ret2[item.key] = item.value;
|
|
1085
1248
|
return ret2;
|
|
1086
1249
|
}, {}) : {}
|
|
@@ -1090,14 +1253,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1090
1253
|
}
|
|
1091
1254
|
this.#ids = {};
|
|
1092
1255
|
this.#paths = {};
|
|
1093
|
-
if (
|
|
1094
|
-
this.#ids =
|
|
1095
|
-
ret[
|
|
1096
|
-
ret[data2.path] ??= data2.path;
|
|
1256
|
+
if (fs2._hasIds()) {
|
|
1257
|
+
this.#ids = fs2.ids.values().reduce((ret, identifier) => {
|
|
1258
|
+
ret[identifier.path] ??= identifier.id;
|
|
1097
1259
|
return ret;
|
|
1098
1260
|
}, {});
|
|
1099
|
-
this.#paths =
|
|
1100
|
-
ret[
|
|
1261
|
+
this.#paths = fs2.ids.values().reduce((ret, identifier) => {
|
|
1262
|
+
ret[identifier.id] ??= identifier.path;
|
|
1101
1263
|
return ret;
|
|
1102
1264
|
}, {});
|
|
1103
1265
|
}
|
|
@@ -1116,7 +1278,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1116
1278
|
}
|
|
1117
1279
|
const resolvedPath = this.resolve(pathOrId, {
|
|
1118
1280
|
...options,
|
|
1119
|
-
|
|
1281
|
+
pathType: "file"
|
|
1120
1282
|
});
|
|
1121
1283
|
if (!resolvedPath) {
|
|
1122
1284
|
return false;
|
|
@@ -1136,7 +1298,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1136
1298
|
}
|
|
1137
1299
|
const resolvedPath = this.resolve(pathOrId, {
|
|
1138
1300
|
...options,
|
|
1139
|
-
|
|
1301
|
+
pathType: "file"
|
|
1140
1302
|
});
|
|
1141
1303
|
if (!resolvedPath) {
|
|
1142
1304
|
return false;
|
|
@@ -1309,7 +1471,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1309
1471
|
const normalized = this.formatPath(pattern);
|
|
1310
1472
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
1311
1473
|
const resolved = this.resolve(normalized, {
|
|
1312
|
-
|
|
1474
|
+
pathType: "file"
|
|
1313
1475
|
});
|
|
1314
1476
|
if (resolved && !results.includes(resolved)) {
|
|
1315
1477
|
results.push(resolved);
|
|
@@ -1344,7 +1506,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1344
1506
|
} else if (stats.isFile()) {
|
|
1345
1507
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
1346
1508
|
const resolved = this.resolve(full, {
|
|
1347
|
-
|
|
1509
|
+
pathType: "file"
|
|
1348
1510
|
});
|
|
1349
1511
|
if (resolved && !results.includes(resolved)) {
|
|
1350
1512
|
results.push(resolved);
|
|
@@ -1368,7 +1530,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1368
1530
|
const normalized = this.formatPath(pattern);
|
|
1369
1531
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
1370
1532
|
const resolved = this.resolve(normalized, {
|
|
1371
|
-
|
|
1533
|
+
pathType: "file"
|
|
1372
1534
|
});
|
|
1373
1535
|
if (resolved && !results.includes(resolved)) {
|
|
1374
1536
|
results.push(resolved);
|
|
@@ -1403,7 +1565,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1403
1565
|
} else if (stats.isFile()) {
|
|
1404
1566
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
1405
1567
|
const resolved = this.resolve(full, {
|
|
1406
|
-
|
|
1568
|
+
pathType: "file"
|
|
1407
1569
|
});
|
|
1408
1570
|
if (resolved && !results.includes(resolved)) {
|
|
1409
1571
|
results.push(resolved);
|
|
@@ -1478,7 +1640,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1478
1640
|
return void 0;
|
|
1479
1641
|
}
|
|
1480
1642
|
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
1481
|
-
|
|
1643
|
+
pathType: "file"
|
|
1482
1644
|
});
|
|
1483
1645
|
if (filePath) {
|
|
1484
1646
|
let result;
|
|
@@ -1503,7 +1665,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1503
1665
|
return void 0;
|
|
1504
1666
|
}
|
|
1505
1667
|
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
1506
|
-
|
|
1668
|
+
pathType: "file"
|
|
1507
1669
|
});
|
|
1508
1670
|
if (filePath) {
|
|
1509
1671
|
const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
@@ -1525,7 +1687,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1525
1687
|
if (!this.isDirectory(filePathFns.findFilePath(formattedPath))) {
|
|
1526
1688
|
await this.mkdir(filePathFns.findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1527
1689
|
}
|
|
1528
|
-
let code =
|
|
1690
|
+
let code = isVirtualFileData(data) ? data.code : data;
|
|
1529
1691
|
if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString.isSetString(code)) {
|
|
1530
1692
|
const resolvedConfig = await prettier.resolveConfig(formattedPath);
|
|
1531
1693
|
if (resolvedConfig) {
|
|
@@ -1540,7 +1702,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1540
1702
|
this.metadata[formattedPath] = {
|
|
1541
1703
|
mode: outputMode,
|
|
1542
1704
|
variant: "normal",
|
|
1543
|
-
|
|
1705
|
+
timestamp: Date.now(),
|
|
1706
|
+
...isVirtualFileData(data) ? data : {}
|
|
1544
1707
|
};
|
|
1545
1708
|
this.#clearResolverCache(formattedPath);
|
|
1546
1709
|
const ifs = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
@@ -1561,13 +1724,14 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1561
1724
|
if (!this.isDirectory(filePathFns.findFilePath(formattedPath))) {
|
|
1562
1725
|
this.mkdirSync(filePathFns.findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1563
1726
|
}
|
|
1564
|
-
const code =
|
|
1727
|
+
const code = isVirtualFileData(data) ? data.code : data;
|
|
1565
1728
|
const outputMode = this.#unifiedFS.resolveMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1566
1729
|
this.#log(types.LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(code)).size)})`);
|
|
1567
1730
|
this.metadata[formattedPath] = {
|
|
1568
1731
|
mode: outputMode,
|
|
1569
1732
|
variant: "normal",
|
|
1570
|
-
|
|
1733
|
+
timestamp: Date.now(),
|
|
1734
|
+
...isVirtualFileData(data) ? data : {}
|
|
1571
1735
|
};
|
|
1572
1736
|
this.#clearResolverCache(formattedPath);
|
|
1573
1737
|
const writeStream = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
|
|
@@ -1680,7 +1844,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1680
1844
|
*/
|
|
1681
1845
|
resolve(pathOrId, options = {}) {
|
|
1682
1846
|
const formattedPathOrId = toFilePath(pathOrId);
|
|
1683
|
-
const resolverKey = `${formattedPathOrId}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash.murmurhash(options.paths)}` : ""}${options.
|
|
1847
|
+
const resolverKey = `${formattedPathOrId}${options.withExtension ? "-ext" : ""}${options.paths ? `-${murmurhash.murmurhash(options.paths)}` : ""}${options.pathType ? `-${options.pathType}` : ""}`;
|
|
1684
1848
|
if (this.#cachedResolver.has(resolverKey)) {
|
|
1685
1849
|
return this.#cachedResolver.get(resolverKey);
|
|
1686
1850
|
}
|
|
@@ -1721,26 +1885,28 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1721
1885
|
this.#log(types.LogLevelLabel.DEBUG, "Disposing virtual file system...");
|
|
1722
1886
|
await this.unlink(joinPaths.joinPaths(this.#context.cachePath, "fs.bin"));
|
|
1723
1887
|
const message = new $__namespace.Message();
|
|
1724
|
-
const
|
|
1888
|
+
const fs2 = message.initRoot(FileSystem);
|
|
1725
1889
|
const virtualFS = this.#unifiedFS.toJSON();
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1890
|
+
const virtualFiles = Object.entries(virtualFS).filter(([_, code]) => code);
|
|
1891
|
+
const files = fs2._initFiles(virtualFiles.length);
|
|
1892
|
+
virtualFiles.forEach(([path, code], index) => {
|
|
1893
|
+
const fd = files.get(index);
|
|
1894
|
+
fd.path = path;
|
|
1895
|
+
fd.code = code;
|
|
1731
1896
|
});
|
|
1732
|
-
const ids =
|
|
1897
|
+
const ids = fs2._initIds(Object.keys(this.ids).length);
|
|
1733
1898
|
Object.entries(this.ids).forEach(([id, path], index) => {
|
|
1734
1899
|
const fileId = ids.get(index);
|
|
1735
1900
|
fileId.id = id;
|
|
1736
1901
|
fileId.path = path;
|
|
1737
1902
|
});
|
|
1738
|
-
const metadata =
|
|
1903
|
+
const metadata = fs2._initMetadata(Object.keys(this.metadata).length);
|
|
1739
1904
|
Object.entries(this.metadata).forEach(([id, value], index) => {
|
|
1740
1905
|
const fileMetadata = metadata.get(index);
|
|
1741
1906
|
fileMetadata.id = id;
|
|
1742
1907
|
fileMetadata.mode = value.mode;
|
|
1743
|
-
fileMetadata.
|
|
1908
|
+
fileMetadata.type = value.type;
|
|
1909
|
+
fileMetadata.timestamp = value.timestamp ?? BigInt(Date.now());
|
|
1744
1910
|
if (value.properties) {
|
|
1745
1911
|
const props = fileMetadata._initProperties(Object.keys(value.properties).length);
|
|
1746
1912
|
Object.entries(value.properties).forEach(([key, val], propIndex) => {
|
|
@@ -1758,7 +1924,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1758
1924
|
*/
|
|
1759
1925
|
[__VFS_PATCH__]() {
|
|
1760
1926
|
if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
|
|
1761
|
-
this.#revert = patchFS(
|
|
1927
|
+
this.#revert = patchFS(_fs__default.default, this);
|
|
1762
1928
|
this.#isPatched = true;
|
|
1763
1929
|
}
|
|
1764
1930
|
}
|
|
@@ -1779,101 +1945,18 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1779
1945
|
}
|
|
1780
1946
|
};
|
|
1781
1947
|
|
|
1782
|
-
// src/
|
|
1783
|
-
var SUPPORTED_COMMANDS = [
|
|
1784
|
-
"new",
|
|
1785
|
-
"clean",
|
|
1786
|
-
"prepare",
|
|
1787
|
-
"lint",
|
|
1788
|
-
"test",
|
|
1789
|
-
"build",
|
|
1790
|
-
"docs",
|
|
1791
|
-
"deploy",
|
|
1792
|
-
"finalize"
|
|
1793
|
-
];
|
|
1794
|
-
|
|
1795
|
-
// src/plugin-utils/helpers.ts
|
|
1796
|
-
function isPlugin(value) {
|
|
1797
|
-
return isSetObject.isSetObject(value) && "name" in value && isSetString.isSetString(value.name) && (isUndefined.isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction.isFunction(value.applyToEnvironment)) && (isUndefined.isUndefined(value.dedupe) || "dedupe" in value && isFunction.isFunction(value.dedupe)) && (isUndefined.isUndefined(value.dependsOn) || "dependsOn" in value && Array.isArray(value.dependsOn) && value.dependsOn.every(isPluginConfig)) && SUPPORTED_COMMANDS.every((command) => isUndefined.isUndefined(value[command]) || command in value && (isFunction.isFunction(value[command]) || isSetObject.isSetObject(value[command]) && "handler" in value[command] && isFunction.isFunction(value[command].handler)));
|
|
1798
|
-
}
|
|
1799
|
-
chunkUSNT2KNT_cjs.__name(isPlugin, "isPlugin");
|
|
1800
|
-
function isPluginConfigObject(value) {
|
|
1801
|
-
return isSetObject.isSetObject(value) && "plugin" in value && ((isSetString.isSetString(value.plugin) || isFunction.isFunction(value.plugin)) && "options" in value && isSetObject.isSetObject(value.options) || isPlugin(value.plugin));
|
|
1802
|
-
}
|
|
1803
|
-
chunkUSNT2KNT_cjs.__name(isPluginConfigObject, "isPluginConfigObject");
|
|
1804
|
-
function isPluginConfigTuple(value) {
|
|
1805
|
-
return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString.isSetString(value[0]) || isFunction.isFunction(value[0])) && value.length > 1 && isSetObject.isSetObject(value[1]) || isPlugin(value[0]));
|
|
1806
|
-
}
|
|
1807
|
-
chunkUSNT2KNT_cjs.__name(isPluginConfigTuple, "isPluginConfigTuple");
|
|
1808
|
-
function isPluginConfig(value) {
|
|
1809
|
-
return isSetString.isSetString(value) || isFunction.isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
|
|
1810
|
-
}
|
|
1811
|
-
chunkUSNT2KNT_cjs.__name(isPluginConfig, "isPluginConfig");
|
|
1812
|
-
function isPluginHookFunction(value) {
|
|
1813
|
-
return isFunction.isFunction(value) || isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
|
|
1814
|
-
}
|
|
1815
|
-
chunkUSNT2KNT_cjs.__name(isPluginHookFunction, "isPluginHookFunction");
|
|
1816
|
-
function isPluginHookObject(value) {
|
|
1817
|
-
return isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
|
|
1818
|
-
}
|
|
1819
|
-
chunkUSNT2KNT_cjs.__name(isPluginHookObject, "isPluginHookObject");
|
|
1820
|
-
function isPluginHook(value) {
|
|
1821
|
-
return isPluginHookFunction(value) || isPluginHookObject(value);
|
|
1822
|
-
}
|
|
1823
|
-
chunkUSNT2KNT_cjs.__name(isPluginHook, "isPluginHook");
|
|
1824
|
-
function getHookHandler(pluginHook) {
|
|
1825
|
-
return isFunction.isFunction(pluginHook) ? pluginHook : pluginHook.handler;
|
|
1826
|
-
}
|
|
1827
|
-
chunkUSNT2KNT_cjs.__name(getHookHandler, "getHookHandler");
|
|
1828
|
-
function isHookExternal(hook) {
|
|
1829
|
-
return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
|
|
1830
|
-
}
|
|
1831
|
-
chunkUSNT2KNT_cjs.__name(isHookExternal, "isHookExternal");
|
|
1832
|
-
function checkDedupe(plugin, plugins) {
|
|
1833
|
-
return plugin.dedupe === false || plugins.some((p) => p.dedupe !== false && (isFunction.isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
|
|
1834
|
-
}
|
|
1835
|
-
chunkUSNT2KNT_cjs.__name(checkDedupe, "checkDedupe");
|
|
1836
|
-
function addPluginHook(context, plugin, pluginHook, hooksList) {
|
|
1837
|
-
if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
|
|
1838
|
-
hooksList.push(isFunction.isFunction(pluginHook) ? {
|
|
1839
|
-
plugin,
|
|
1840
|
-
handler: getHookHandler(pluginHook).bind(context)
|
|
1841
|
-
} : {
|
|
1842
|
-
plugin,
|
|
1843
|
-
...pluginHook,
|
|
1844
|
-
handler: getHookHandler(pluginHook).bind(context)
|
|
1845
|
-
});
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
chunkUSNT2KNT_cjs.__name(addPluginHook, "addPluginHook");
|
|
1849
|
-
function resolveOptions(options) {
|
|
1850
|
-
return defu2__default.default(options, {
|
|
1851
|
-
interopDefault: true,
|
|
1852
|
-
fsCache: options.mode !== "development" ? joinPaths.joinPaths(options.cacheDir, "jiti") : false,
|
|
1853
|
-
moduleCache: options.mode !== "development"
|
|
1854
|
-
});
|
|
1855
|
-
}
|
|
1856
|
-
chunkUSNT2KNT_cjs.__name(resolveOptions, "resolveOptions");
|
|
1857
|
-
function createPluginResolver(options) {
|
|
1858
|
-
return jiti.createJiti(joinPaths.joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions({
|
|
1859
|
-
...options
|
|
1860
|
-
}));
|
|
1861
|
-
}
|
|
1862
|
-
chunkUSNT2KNT_cjs.__name(createPluginResolver, "createPluginResolver");
|
|
1863
|
-
function createResolver(options) {
|
|
1864
|
-
const baseResolver = jiti.createJiti(joinPaths.joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions(options));
|
|
1865
|
-
baseResolver.plugin = createPluginResolver(options);
|
|
1866
|
-
return baseResolver;
|
|
1867
|
-
}
|
|
1868
|
-
chunkUSNT2KNT_cjs.__name(createResolver, "createResolver");
|
|
1869
|
-
|
|
1870
|
-
// src/internal/contexts/context.ts
|
|
1948
|
+
// src/lib/contexts/context.ts
|
|
1871
1949
|
var configCache = /* @__PURE__ */ new WeakMap();
|
|
1872
|
-
var parseCache = /* @__PURE__ */ new WeakMap();
|
|
1873
1950
|
var PowerlinesContext = class _PowerlinesContext {
|
|
1874
1951
|
static {
|
|
1875
1952
|
chunkUSNT2KNT_cjs.__name(this, "PowerlinesContext");
|
|
1876
1953
|
}
|
|
1954
|
+
/**
|
|
1955
|
+
* Internal reference to the API instance
|
|
1956
|
+
*
|
|
1957
|
+
* @internal
|
|
1958
|
+
*/
|
|
1959
|
+
#api;
|
|
1877
1960
|
#workspaceConfig;
|
|
1878
1961
|
#checksum = null;
|
|
1879
1962
|
#buildId = uuid.uuid();
|
|
@@ -1953,6 +2036,16 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1953
2036
|
*/
|
|
1954
2037
|
resolver;
|
|
1955
2038
|
/**
|
|
2039
|
+
* Internal context fields and methods
|
|
2040
|
+
*
|
|
2041
|
+
* @internal
|
|
2042
|
+
*/
|
|
2043
|
+
get $$internal() {
|
|
2044
|
+
return {
|
|
2045
|
+
api: this.#api
|
|
2046
|
+
};
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
1956
2049
|
* The resolved entry type definitions for the project
|
|
1957
2050
|
*/
|
|
1958
2051
|
get entry() {
|
|
@@ -2095,13 +2188,13 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2095
2188
|
* The builtin module id that exist in the Powerlines virtual file system
|
|
2096
2189
|
*/
|
|
2097
2190
|
get builtins() {
|
|
2098
|
-
return Object.values(this.fs.metadata).filter((meta) => meta && meta.
|
|
2191
|
+
return Object.values(this.fs.metadata).filter((meta) => meta && meta.type === "builtin").map((meta) => meta?.id).filter(Boolean);
|
|
2099
2192
|
}
|
|
2100
2193
|
/**
|
|
2101
2194
|
* Get the builtin virtual files that exist in the Powerlines virtual file system
|
|
2102
2195
|
*/
|
|
2103
2196
|
async getBuiltins() {
|
|
2104
|
-
return Promise.all(Object.entries(this.fs.metadata).filter(([, meta]) => meta && meta.
|
|
2197
|
+
return Promise.all(Object.entries(this.fs.metadata).filter(([, meta]) => meta && meta.type === "builtin").map(async ([path, meta]) => {
|
|
2105
2198
|
const code = await this.fs.readFile(path);
|
|
2106
2199
|
return {
|
|
2107
2200
|
...meta,
|
|
@@ -2117,10 +2210,10 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2117
2210
|
* @param path - A path to write the entry file to
|
|
2118
2211
|
* @param options - Optional write file options
|
|
2119
2212
|
*/
|
|
2120
|
-
async
|
|
2213
|
+
async emitEntry(code, path, options = {}) {
|
|
2121
2214
|
return this.fs.writeFile(isType.isAbsolute(path) ? path : append.appendPath(path, this.entryPath), {
|
|
2122
2215
|
code,
|
|
2123
|
-
|
|
2216
|
+
type: "entry"
|
|
2124
2217
|
}, defu2__default.default(options, {
|
|
2125
2218
|
mode: this.config.output.mode
|
|
2126
2219
|
}));
|
|
@@ -2133,51 +2226,16 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2133
2226
|
* @param path - An optional path to write the builtin file to
|
|
2134
2227
|
* @param options - Optional write file options
|
|
2135
2228
|
*/
|
|
2136
|
-
async
|
|
2229
|
+
async emitBuiltin(code, id, path, options = {}) {
|
|
2137
2230
|
return this.fs.writeFile(path ? isType.isAbsolute(path) ? path : join.joinPaths(this.builtinsPath, path) : append.appendPath(id, this.builtinsPath), {
|
|
2138
2231
|
id,
|
|
2139
2232
|
code,
|
|
2140
|
-
|
|
2233
|
+
type: "builtin"
|
|
2141
2234
|
}, defu2__default.default(options, {
|
|
2142
2235
|
mode: this.config.output.mode
|
|
2143
2236
|
}));
|
|
2144
2237
|
}
|
|
2145
2238
|
/**
|
|
2146
|
-
* Parses the source code and returns a {@link ParseResult} object.
|
|
2147
|
-
*
|
|
2148
|
-
* @param code - The source code to parse.
|
|
2149
|
-
* @param id - The unique identifier for the source file.
|
|
2150
|
-
* @param options - Optional parser options.
|
|
2151
|
-
* @returns The parsed {@link ParseResult} object.
|
|
2152
|
-
*/
|
|
2153
|
-
async parse(code, id, options = {}) {
|
|
2154
|
-
if (parseCache.has({
|
|
2155
|
-
code,
|
|
2156
|
-
options
|
|
2157
|
-
})) {
|
|
2158
|
-
return parseCache.get({
|
|
2159
|
-
code,
|
|
2160
|
-
options
|
|
2161
|
-
});
|
|
2162
|
-
}
|
|
2163
|
-
const result = await oxcParser.parseAsync(id, code, defu2__default.default(options ?? {}, {
|
|
2164
|
-
lang: filePathFns.hasFileExtension(id) ? void 0 : "ts",
|
|
2165
|
-
astType: filePathFns.hasFileExtension(id) ? void 0 : "ts",
|
|
2166
|
-
sourceType: "module",
|
|
2167
|
-
showSemanticErrors: false
|
|
2168
|
-
}));
|
|
2169
|
-
if (result.errors && result.errors.length > 0) {
|
|
2170
|
-
throw new Error(`Powerlines parsing errors in file: ${id}
|
|
2171
|
-
${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.codeframe ? ` (${error.codeframe})` : ""}${error.helpMessage ? `
|
|
2172
|
-
Help: ${error.helpMessage}` : ""}`).join("\n")}`);
|
|
2173
|
-
}
|
|
2174
|
-
parseCache.set({
|
|
2175
|
-
code,
|
|
2176
|
-
options
|
|
2177
|
-
}, result);
|
|
2178
|
-
return result;
|
|
2179
|
-
}
|
|
2180
|
-
/**
|
|
2181
2239
|
* Update the context using a new user configuration options
|
|
2182
2240
|
*
|
|
2183
2241
|
* @param userConfig - The new user configuration options.
|
|
@@ -2365,7 +2423,7 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
|
|
|
2365
2423
|
tsconfig: append.appendPath("tsconfig.json", cacheKey.projectRoot),
|
|
2366
2424
|
sourceRoot: this.projectJson?.sourceRoot || append.appendPath("src", cacheKey.projectRoot),
|
|
2367
2425
|
output: {
|
|
2368
|
-
outputPath: join.joinPaths("dist", cacheKey.projectRoot),
|
|
2426
|
+
outputPath: cacheKey.projectRoot ? join.joinPaths(this.workspaceConfig?.directories?.build || "dist", cacheKey.projectRoot) : this.workspaceConfig?.directories?.build || "dist",
|
|
2369
2427
|
mode: "virtual",
|
|
2370
2428
|
dts: join.joinPaths(cacheKey.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
|
|
2371
2429
|
builtinPrefix: config.framework ?? "powerlines",
|
|
@@ -2471,1360 +2529,16 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
|
|
|
2471
2529
|
}
|
|
2472
2530
|
};
|
|
2473
2531
|
|
|
2474
|
-
|
|
2475
|
-
var PLUGIN_NON_HOOK_FIELDS = [
|
|
2476
|
-
"name",
|
|
2477
|
-
"enforce",
|
|
2478
|
-
"dedupe",
|
|
2479
|
-
"dependsOn",
|
|
2480
|
-
"applyToEnvironment"
|
|
2481
|
-
];
|
|
2482
|
-
async function callHook(context, hook, options, ...args) {
|
|
2483
|
-
const handlers = context.selectHooks(hook, options);
|
|
2484
|
-
if (handlers.length > 0) {
|
|
2485
|
-
context.log(types.LogLevelLabel.DEBUG, ` \u{1F9E9} Calling plugin hook: ${chalk4__default.default.bold.cyanBright(`${hook}${options?.order ? ` (${options.order})` : ""}`)}`);
|
|
2486
|
-
let results = [];
|
|
2487
|
-
if (options?.sequential === false) {
|
|
2488
|
-
results = await Promise.all(handlers.map(async (handler) => {
|
|
2489
|
-
if (!isFunction.isFunction(handler)) {
|
|
2490
|
-
throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
|
|
2491
|
-
}
|
|
2492
|
-
return Promise.resolve(handler.apply(null, ...args));
|
|
2493
|
-
}));
|
|
2494
|
-
} else {
|
|
2495
|
-
for (const handler of handlers) {
|
|
2496
|
-
if (!isFunction.isFunction(handler)) {
|
|
2497
|
-
throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
|
|
2498
|
-
}
|
|
2499
|
-
results.push(await Promise.resolve(handler.apply(null, ...args)));
|
|
2500
|
-
if (options?.result === "first" && isSet.isSet(results[results.length - 1])) {
|
|
2501
|
-
break;
|
|
2502
|
-
}
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
2505
|
-
const definedResults = results.filter((result) => isSet.isSet(result));
|
|
2506
|
-
if (definedResults.length > 0) {
|
|
2507
|
-
let mergedResult = void 0;
|
|
2508
|
-
for (const result of definedResults) {
|
|
2509
|
-
mergedResult = defu2.defu(result, mergedResult ?? {});
|
|
2510
|
-
}
|
|
2511
|
-
return mergedResult;
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
return void 0;
|
|
2515
|
-
}
|
|
2516
|
-
chunkUSNT2KNT_cjs.__name(callHook, "callHook");
|
|
2517
|
-
|
|
2518
|
-
// src/internal/contexts/plugin-context.ts
|
|
2519
|
-
function createPluginContext(plugin, environment) {
|
|
2520
|
-
const normalizeMessage = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((message) => {
|
|
2521
|
-
return isString.isString(message) ? message : message.message;
|
|
2522
|
-
}, "normalizeMessage");
|
|
2523
|
-
const log = environment.extendLog(plugin.name);
|
|
2524
|
-
const callHookFn = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name(async (hook, options, ...args) => {
|
|
2525
|
-
return callHook(environment, hook, {
|
|
2526
|
-
sequential: true,
|
|
2527
|
-
...options
|
|
2528
|
-
}, ...args);
|
|
2529
|
-
}, "callHookFn");
|
|
2530
|
-
return new Proxy({}, {
|
|
2531
|
-
get(_, prop) {
|
|
2532
|
-
if (prop === "$$internal") {
|
|
2533
|
-
return {
|
|
2534
|
-
environment,
|
|
2535
|
-
callHook: callHookFn
|
|
2536
|
-
};
|
|
2537
|
-
}
|
|
2538
|
-
if (prop === "log" || prop === "logger") {
|
|
2539
|
-
return log;
|
|
2540
|
-
}
|
|
2541
|
-
if (prop === "error") {
|
|
2542
|
-
return (message) => {
|
|
2543
|
-
log(types.LogLevelLabel.ERROR, normalizeMessage(message));
|
|
2544
|
-
};
|
|
2545
|
-
}
|
|
2546
|
-
if (prop === "warn") {
|
|
2547
|
-
return (message) => {
|
|
2548
|
-
log(types.LogLevelLabel.WARN, normalizeMessage(message));
|
|
2549
|
-
};
|
|
2550
|
-
}
|
|
2551
|
-
return environment[prop];
|
|
2552
|
-
},
|
|
2553
|
-
set(_, prop, value) {
|
|
2554
|
-
if ([
|
|
2555
|
-
"$$internal",
|
|
2556
|
-
"environment",
|
|
2557
|
-
"config",
|
|
2558
|
-
"log",
|
|
2559
|
-
"logger",
|
|
2560
|
-
"error",
|
|
2561
|
-
"warn",
|
|
2562
|
-
"plugins",
|
|
2563
|
-
"hooks",
|
|
2564
|
-
"addPlugin",
|
|
2565
|
-
"selectHooks"
|
|
2566
|
-
].includes(prop)) {
|
|
2567
|
-
log(types.LogLevelLabel.WARN, `Cannot set read-only property "${String(prop)}"`);
|
|
2568
|
-
return false;
|
|
2569
|
-
}
|
|
2570
|
-
environment[prop] = value;
|
|
2571
|
-
return true;
|
|
2572
|
-
}
|
|
2573
|
-
});
|
|
2574
|
-
}
|
|
2575
|
-
chunkUSNT2KNT_cjs.__name(createPluginContext, "createPluginContext");
|
|
2576
|
-
|
|
2577
|
-
// src/internal/contexts/environment-context.ts
|
|
2578
|
-
var PowerlinesEnvironmentContext = class _PowerlinesEnvironmentContext extends PowerlinesContext {
|
|
2579
|
-
static {
|
|
2580
|
-
chunkUSNT2KNT_cjs.__name(this, "PowerlinesEnvironmentContext");
|
|
2581
|
-
}
|
|
2582
|
-
#hooks = {};
|
|
2583
|
-
/**
|
|
2584
|
-
* Create a new Storm context from the workspace root and user config.
|
|
2585
|
-
*
|
|
2586
|
-
* @param workspaceConfig - The root directory of the workspace.
|
|
2587
|
-
* @param config - The user configuration options.
|
|
2588
|
-
* @returns A promise that resolves to the new context.
|
|
2589
|
-
*/
|
|
2590
|
-
static async fromConfig(workspaceConfig, config) {
|
|
2591
|
-
const context = new _PowerlinesEnvironmentContext(config, workspaceConfig);
|
|
2592
|
-
await context.init();
|
|
2593
|
-
context.powerlinesPath = await resolve.resolvePackage("powerlines");
|
|
2594
|
-
if (!context.powerlinesPath) {
|
|
2595
|
-
throw new Error("Could not resolve `powerlines` package location.");
|
|
2596
|
-
}
|
|
2597
|
-
return context;
|
|
2598
|
-
}
|
|
2599
|
-
environment;
|
|
2600
|
-
plugins = [];
|
|
2601
|
-
/**
|
|
2602
|
-
* The resolved configuration options
|
|
2603
|
-
*/
|
|
2604
|
-
get config() {
|
|
2605
|
-
return super.config;
|
|
2606
|
-
}
|
|
2607
|
-
get hooks() {
|
|
2608
|
-
return this.#hooks;
|
|
2609
|
-
}
|
|
2610
|
-
async addPlugin(plugin) {
|
|
2611
|
-
let resolvedPlugin = plugin;
|
|
2612
|
-
if (plugin.applyToEnvironment) {
|
|
2613
|
-
const result = await Promise.resolve(plugin.applyToEnvironment(this.environment));
|
|
2614
|
-
if (!result || isObject.isObject(result) && Object.keys(result).length === 0) {
|
|
2615
|
-
return;
|
|
2616
|
-
}
|
|
2617
|
-
resolvedPlugin = isPlugin(result) ? result : plugin;
|
|
2618
|
-
}
|
|
2619
|
-
const context = createPluginContext(resolvedPlugin, this);
|
|
2620
|
-
this.plugins.push({
|
|
2621
|
-
plugin: resolvedPlugin,
|
|
2622
|
-
context
|
|
2623
|
-
});
|
|
2624
|
-
this.#hooks = Object.keys(resolvedPlugin).filter((key) => !PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => {
|
|
2625
|
-
const hook = key;
|
|
2626
|
-
const pluginHook = resolvedPlugin[hook];
|
|
2627
|
-
if (!isPluginHook(pluginHook)) {
|
|
2628
|
-
return ret;
|
|
2629
|
-
}
|
|
2630
|
-
if (!isHookExternal(hook)) {
|
|
2631
|
-
ret[hook] ??= {};
|
|
2632
|
-
if (resolvedPlugin.enforce) {
|
|
2633
|
-
ret[hook][`${resolvedPlugin.enforce}Enforced`] ??= [];
|
|
2634
|
-
addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][`${resolvedPlugin.enforce}Enforced`]);
|
|
2635
|
-
return ret;
|
|
2636
|
-
}
|
|
2637
|
-
if (isFunction.isFunction(pluginHook) || !pluginHook.order) {
|
|
2638
|
-
ret[hook].normal ??= [];
|
|
2639
|
-
addPluginHook(context, resolvedPlugin, pluginHook, ret[hook].normal);
|
|
2640
|
-
return ret;
|
|
2641
|
-
}
|
|
2642
|
-
ret[hook][`${pluginHook.order}Ordered`] ??= [];
|
|
2643
|
-
addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][`${pluginHook.order}Ordered`]);
|
|
2644
|
-
} else {
|
|
2645
|
-
ret[hook] ??= [];
|
|
2646
|
-
ret[hook].push({
|
|
2647
|
-
plugin: resolvedPlugin,
|
|
2648
|
-
hook: getHookHandler(pluginHook).bind(context)
|
|
2649
|
-
});
|
|
2650
|
-
}
|
|
2651
|
-
return ret;
|
|
2652
|
-
}, this.hooks);
|
|
2653
|
-
}
|
|
2654
|
-
/**
|
|
2655
|
-
* Retrieves the hook handlers for a specific hook name
|
|
2656
|
-
*/
|
|
2657
|
-
selectHooks(hook, options) {
|
|
2658
|
-
const handlers = [];
|
|
2659
|
-
if (this.hooks[hook]) {
|
|
2660
|
-
if (!isHookExternal(hook)) {
|
|
2661
|
-
const hooks = this.hooks[hook];
|
|
2662
|
-
if (options?.order) {
|
|
2663
|
-
if (options?.order === "pre") {
|
|
2664
|
-
handlers.push(...(hooks.preOrdered ?? []).map((h) => h.handler));
|
|
2665
|
-
handlers.push(...(hooks.preEnforced ?? []).map((h) => h.handler));
|
|
2666
|
-
} else if (options?.order === "post") {
|
|
2667
|
-
handlers.push(...(hooks.postOrdered ?? []).map((h) => h.handler));
|
|
2668
|
-
handlers.push(...(hooks.postEnforced ?? []).map((h) => h.handler));
|
|
2669
|
-
} else {
|
|
2670
|
-
handlers.push(...(hooks.normal ?? []).map((h) => h.handler));
|
|
2671
|
-
}
|
|
2672
|
-
} else {
|
|
2673
|
-
handlers.push(...this.selectHooks(hook, {
|
|
2674
|
-
order: "pre"
|
|
2675
|
-
}));
|
|
2676
|
-
handlers.push(...this.selectHooks(hook, {
|
|
2677
|
-
order: "normal"
|
|
2678
|
-
}));
|
|
2679
|
-
handlers.push(...this.selectHooks(hook, {
|
|
2680
|
-
order: "post"
|
|
2681
|
-
}));
|
|
2682
|
-
}
|
|
2683
|
-
} else {
|
|
2684
|
-
handlers.push(...this.hooks[hook].map((h) => h.handler));
|
|
2685
|
-
}
|
|
2686
|
-
}
|
|
2687
|
-
return handlers;
|
|
2688
|
-
}
|
|
2689
|
-
constructor(config, workspaceConfig) {
|
|
2690
|
-
super(workspaceConfig);
|
|
2691
|
-
this.resolvedConfig = config;
|
|
2692
|
-
}
|
|
2693
|
-
};
|
|
2694
|
-
|
|
2695
|
-
// src/internal/contexts/api-context.ts
|
|
2696
|
-
var PowerlinesAPIContext = class _PowerlinesAPIContext extends PowerlinesContext {
|
|
2697
|
-
static {
|
|
2698
|
-
chunkUSNT2KNT_cjs.__name(this, "PowerlinesAPIContext");
|
|
2699
|
-
}
|
|
2700
|
-
#environments = {};
|
|
2701
|
-
#plugins = [];
|
|
2702
|
-
#log;
|
|
2703
|
-
/**
|
|
2704
|
-
* Create a new Storm context from the workspace root and user config.
|
|
2705
|
-
*
|
|
2706
|
-
* @param workspaceRoot - The root directory of the workspace.
|
|
2707
|
-
* @param config - The user configuration options.
|
|
2708
|
-
* @returns A promise that resolves to the new context.
|
|
2709
|
-
*/
|
|
2710
|
-
static async from(workspaceRoot, config) {
|
|
2711
|
-
const context = new _PowerlinesAPIContext(await chunkXW5TELHB_cjs.loadWorkspaceConfig(workspaceRoot, config.root));
|
|
2712
|
-
await context.withUserConfig(config);
|
|
2713
|
-
context.powerlinesPath = await resolve.resolvePackage("powerlines");
|
|
2714
|
-
if (!context.powerlinesPath) {
|
|
2715
|
-
throw new Error("Could not resolve `powerlines` package location.");
|
|
2716
|
-
}
|
|
2717
|
-
return context;
|
|
2718
|
-
}
|
|
2719
|
-
/**
|
|
2720
|
-
* A record of all environments by name
|
|
2721
|
-
*/
|
|
2722
|
-
get environments() {
|
|
2723
|
-
return this.#environments;
|
|
2724
|
-
}
|
|
2725
|
-
get log() {
|
|
2726
|
-
if (!this.#log) {
|
|
2727
|
-
this.#log = this.createLog("engine");
|
|
2728
|
-
}
|
|
2729
|
-
return this.#log;
|
|
2730
|
-
}
|
|
2731
|
-
get plugins() {
|
|
2732
|
-
return this.#plugins;
|
|
2733
|
-
}
|
|
2734
|
-
constructor(workspaceConfig) {
|
|
2735
|
-
super(workspaceConfig);
|
|
2736
|
-
}
|
|
2737
|
-
/**
|
|
2738
|
-
* Initialize the context with the provided configuration options
|
|
2739
|
-
*
|
|
2740
|
-
* @param config - The partial user configuration to use for initialization.
|
|
2741
|
-
*/
|
|
2742
|
-
async init(config = {}) {
|
|
2743
|
-
await super.init(config);
|
|
2744
|
-
await Promise.all(toArray.toArray(this.config.userConfig.environments && Object.keys(this.config.userConfig.environments).length > 0 ? Object.keys(this.config.userConfig.environments).map((name) => createEnvironment(name, this.config.userConfig)) : createDefaultEnvironment(this.config.userConfig)).map(async (env) => {
|
|
2745
|
-
this.#environments[env.name] = await this.in(env);
|
|
2746
|
-
}));
|
|
2747
|
-
}
|
|
2748
|
-
/**
|
|
2749
|
-
* A function to copy the context and update the fields for a specific environment
|
|
2750
|
-
*
|
|
2751
|
-
* @param environment - The environment configuration to use.
|
|
2752
|
-
* @returns A new context instance with the updated environment.
|
|
2753
|
-
*/
|
|
2754
|
-
async in(environment) {
|
|
2755
|
-
let context;
|
|
2756
|
-
if (this.environments[environment.name]) {
|
|
2757
|
-
context = this.environments[environment.name];
|
|
2758
|
-
} else {
|
|
2759
|
-
context = await PowerlinesEnvironmentContext.fromConfig(this.workspaceConfig, this.config);
|
|
2760
|
-
}
|
|
2761
|
-
if (isSetObject.isSetObject(this.config.inlineConfig)) {
|
|
2762
|
-
await context.withInlineConfig(this.config.inlineConfig);
|
|
2763
|
-
}
|
|
2764
|
-
context.environment = environment;
|
|
2765
|
-
context.plugins = [];
|
|
2766
|
-
for (const plugin of this.plugins) {
|
|
2767
|
-
await context.addPlugin(plugin);
|
|
2768
|
-
}
|
|
2769
|
-
return context;
|
|
2770
|
-
}
|
|
2771
|
-
async addPlugin(plugin) {
|
|
2772
|
-
this.plugins.push(plugin);
|
|
2773
|
-
await Promise.all(Object.keys(this.environments).map(async (name) => {
|
|
2774
|
-
await this.environments[name].addPlugin(plugin);
|
|
2775
|
-
}));
|
|
2776
|
-
}
|
|
2777
|
-
async getEnvironment(name) {
|
|
2778
|
-
let environment;
|
|
2779
|
-
if (name) {
|
|
2780
|
-
environment = this.environments[name];
|
|
2781
|
-
}
|
|
2782
|
-
if (Object.keys(this.environments).length === 1) {
|
|
2783
|
-
environment = this.environments[Object.keys(this.environments)[0]];
|
|
2784
|
-
this.log(types.LogLevelLabel.DEBUG, `Applying the only configured environment: ${chalk4__default.default.bold.cyanBright(environment?.environment.name)}`);
|
|
2785
|
-
}
|
|
2786
|
-
if (!environment) {
|
|
2787
|
-
if (name) {
|
|
2788
|
-
throw new Error(`Environment "${name}" not found.`);
|
|
2789
|
-
}
|
|
2790
|
-
environment = await this.in(createDefaultEnvironment(this.config.userConfig));
|
|
2791
|
-
this.log(types.LogLevelLabel.WARN, `No environment specified, and no default environment found. Using a temporary default environment: ${chalk4__default.default.bold.cyanBright(environment?.environment.name)}`);
|
|
2792
|
-
}
|
|
2793
|
-
return environment;
|
|
2794
|
-
}
|
|
2795
|
-
async getEnvironmentSafe(name) {
|
|
2796
|
-
try {
|
|
2797
|
-
return await this.getEnvironment(name);
|
|
2798
|
-
} catch {
|
|
2799
|
-
return void 0;
|
|
2800
|
-
}
|
|
2801
|
-
}
|
|
2802
|
-
};
|
|
2803
|
-
function formatTypes(code) {
|
|
2804
|
-
return code.replace(
|
|
2805
|
-
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
2806
|
-
/import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g,
|
|
2807
|
-
""
|
|
2808
|
-
).replaceAll("#private;", "").replace(/__Ω/g, "");
|
|
2809
|
-
}
|
|
2810
|
-
chunkUSNT2KNT_cjs.__name(formatTypes, "formatTypes");
|
|
2811
|
-
async function emitTypes(context, tsconfig, files) {
|
|
2812
|
-
context.log(types.LogLevelLabel.TRACE, "Creating the TypeScript compiler host");
|
|
2813
|
-
const program = ts.createProgram(files, tsconfig.options, ts.createCompilerHost(tsconfig.options));
|
|
2814
|
-
context.log(types.LogLevelLabel.TRACE, `Running the TypeScript compiler for ${context.builtins.length} built-in runtime files.`);
|
|
2815
|
-
let builtinModules = "";
|
|
2816
|
-
const emitResult = program.emit(void 0, (fileName, text, _, __, sourceFiles, _data) => {
|
|
2817
|
-
const sourceFile = sourceFiles?.[0];
|
|
2818
|
-
if (sourceFile?.fileName && !fileName.endsWith(".map")) {
|
|
2819
|
-
if (context.builtins.some((file) => file === sourceFile.fileName || context.fs.metadata[file]?.id && context.fs.metadata[file]?.id === sourceFile.fileName)) {
|
|
2820
|
-
builtinModules += `
|
|
2821
|
-
declare module "${context.fs.resolve(sourceFile.fileName)}" {
|
|
2822
|
-
${text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
|
|
2823
|
-
}
|
|
2824
|
-
`;
|
|
2825
|
-
}
|
|
2826
|
-
}
|
|
2827
|
-
}, void 0, true);
|
|
2828
|
-
const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
2829
|
-
const diagnosticMessages = [];
|
|
2830
|
-
diagnostics.forEach((diagnostic) => {
|
|
2831
|
-
if (diagnostic.file) {
|
|
2832
|
-
const { line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
|
2833
|
-
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
2834
|
-
diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
|
2835
|
-
} else {
|
|
2836
|
-
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
2837
|
-
diagnosticMessages.push(message);
|
|
2838
|
-
}
|
|
2839
|
-
});
|
|
2840
|
-
const diagnosticMessage = diagnosticMessages.join("\n");
|
|
2841
|
-
if (diagnosticMessage) {
|
|
2842
|
-
throw new Error(`TypeScript compilation failed:
|
|
2843
|
-
|
|
2844
|
-
${diagnosticMessage.length > 5e3 ? `${diagnosticMessage.slice(0, 5e3)}...` : diagnosticMessage}`);
|
|
2845
|
-
}
|
|
2846
|
-
return formatTypes(builtinModules);
|
|
2847
|
-
}
|
|
2848
|
-
chunkUSNT2KNT_cjs.__name(emitTypes, "emitTypes");
|
|
2849
|
-
async function installPackage(context, packageName, dev = false) {
|
|
2850
|
-
if (!await packageFns.isPackageListed(_package.getPackageName(packageName), {
|
|
2851
|
-
cwd: context.config.projectRoot
|
|
2852
|
-
})) {
|
|
2853
|
-
if (context.config.skipInstalls !== true && !process.env.POWERLINES_LOCAL) {
|
|
2854
|
-
context.log(types.LogLevelLabel.WARN, `The package "${packageName}" is not installed. It will be installed automatically.`);
|
|
2855
|
-
const result = await install.install(packageName, {
|
|
2856
|
-
cwd: context.config.projectRoot,
|
|
2857
|
-
dev
|
|
2858
|
-
});
|
|
2859
|
-
if (isNumber.isNumber(result.exitCode) && result.exitCode > 0) {
|
|
2860
|
-
context.log(types.LogLevelLabel.ERROR, result.stderr);
|
|
2861
|
-
throw new Error(`An error occurred while installing the package "${packageName}"`);
|
|
2862
|
-
}
|
|
2863
|
-
} else {
|
|
2864
|
-
context.log(types.LogLevelLabel.WARN, `The package "${packageName}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`);
|
|
2865
|
-
}
|
|
2866
|
-
} else if (_package.hasPackageVersion(packageName) && !process.env.POWERLINES_SKIP_VERSION_CHECK) {
|
|
2867
|
-
const isMatching = await packageFns.doesPackageMatch(_package.getPackageName(packageName), _package.getPackageVersion(packageName), context.config.projectRoot);
|
|
2868
|
-
if (!isMatching) {
|
|
2869
|
-
const packageListing = await packageFns.getPackageListing(_package.getPackageName(packageName), {
|
|
2870
|
-
cwd: context.config.projectRoot
|
|
2871
|
-
});
|
|
2872
|
-
if (!packageListing?.version.startsWith("catalog:") && !packageListing?.version.startsWith("workspace:")) {
|
|
2873
|
-
context.log(types.LogLevelLabel.WARN, `The package "${_package.getPackageName(packageName)}" is installed but does not match the expected version ${_package.getPackageVersion(packageName)} (installed version: ${packageListing?.version || "<Unknown>"}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`);
|
|
2874
|
-
}
|
|
2875
|
-
}
|
|
2876
|
-
}
|
|
2877
|
-
}
|
|
2878
|
-
chunkUSNT2KNT_cjs.__name(installPackage, "installPackage");
|
|
2879
|
-
|
|
2880
|
-
// src/internal/helpers/install-dependencies.ts
|
|
2881
|
-
async function installDependencies(context) {
|
|
2882
|
-
context.log(types.LogLevelLabel.TRACE, `Checking and installing missing project dependencies.`);
|
|
2883
|
-
context.dependencies ??= {};
|
|
2884
|
-
context.devDependencies ??= {};
|
|
2885
|
-
if (Object.keys(context.dependencies).length === 0 && Object.keys(context.devDependencies).length === 0) {
|
|
2886
|
-
context.log(types.LogLevelLabel.TRACE, `No dependencies or devDependencies to install. Skipping installation step.`);
|
|
2887
|
-
return;
|
|
2888
|
-
}
|
|
2889
|
-
context.log(types.LogLevelLabel.DEBUG, `The following packages are required:
|
|
2890
|
-
Dependencies:
|
|
2891
|
-
${Object.entries(context.dependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}
|
|
2892
|
-
|
|
2893
|
-
DevDependencies:
|
|
2894
|
-
${Object.entries(context.devDependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}`);
|
|
2895
|
-
await Promise.all([
|
|
2896
|
-
Promise.all(Object.entries(context.dependencies).map(async ([name, version]) => installPackage(context, `${_package.getPackageName(name)}@${String(version)}`, false))),
|
|
2897
|
-
Promise.all(Object.entries(context.devDependencies).map(async ([name, version]) => installPackage(context, `${_package.getPackageName(name)}@${String(version)}`, true)))
|
|
2898
|
-
]);
|
|
2899
|
-
}
|
|
2900
|
-
chunkUSNT2KNT_cjs.__name(installDependencies, "installDependencies");
|
|
2901
|
-
async function resolveTsconfigChanges(context) {
|
|
2902
|
-
const tsconfig$1 = chunkBQU53ZNB_cjs.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw);
|
|
2903
|
-
const tsconfigFilePath = chunkBQU53ZNB_cjs.getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
2904
|
-
const tsconfigJson = await json.readJsonFile(tsconfigFilePath);
|
|
2905
|
-
tsconfigJson.compilerOptions ??= {};
|
|
2906
|
-
const extendedTsconfig = await tsconfig.loadTsConfig(tsconfigFilePath);
|
|
2907
|
-
extendedTsconfig.compilerOptions ??= {};
|
|
2908
|
-
if (tsconfigJson.reflection !== true) {
|
|
2909
|
-
tsconfigJson.reflection = true;
|
|
2910
|
-
}
|
|
2911
|
-
if (tsconfig$1.options.experimentalDecorators !== true) {
|
|
2912
|
-
tsconfigJson.compilerOptions.experimentalDecorators = true;
|
|
2913
|
-
}
|
|
2914
|
-
if (tsconfig$1.options.emitDecoratorMetadata !== true) {
|
|
2915
|
-
tsconfigJson.compilerOptions.emitDecoratorMetadata = true;
|
|
2916
|
-
}
|
|
2917
|
-
if (context.config.output.dts) {
|
|
2918
|
-
const dtsFilePath = context.config.output.dts ? context.config.output.dts.startsWith(context.workspaceConfig.workspaceRoot) ? context.config.output.dts : joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.output.dts) : joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, "storm.d.ts");
|
|
2919
|
-
const dtsRelativePath = joinPaths.joinPaths(filePathFns.relativePath(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot), filePathFns.findFilePath(dtsFilePath)), filePathFns.findFileName(dtsFilePath));
|
|
2920
|
-
if (!tsconfigJson.include?.some((filePattern) => chunkBQU53ZNB_cjs.isIncludeMatchFound(filePattern, [
|
|
2921
|
-
dtsFilePath,
|
|
2922
|
-
dtsRelativePath,
|
|
2923
|
-
"storm.d.ts"
|
|
2924
|
-
]))) {
|
|
2925
|
-
tsconfigJson.include ??= [];
|
|
2926
|
-
tsconfigJson.include.push(dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath);
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
|
-
if (!tsconfig$1.options.lib?.some((lib) => [
|
|
2930
|
-
"lib.esnext.d.ts",
|
|
2931
|
-
"lib.es2021.d.ts",
|
|
2932
|
-
"lib.es2022.d.ts",
|
|
2933
|
-
"lib.es2023.d.ts"
|
|
2934
|
-
].includes(lib.toLowerCase()))) {
|
|
2935
|
-
tsconfigJson.compilerOptions.lib ??= [];
|
|
2936
|
-
tsconfigJson.compilerOptions.lib.push("esnext");
|
|
2937
|
-
}
|
|
2938
|
-
if (tsconfig$1.options.module !== ts__default.default.ModuleKind.ESNext) {
|
|
2939
|
-
tsconfigJson.compilerOptions.module = "ESNext";
|
|
2940
|
-
}
|
|
2941
|
-
if (!tsconfig$1.options.target || ![
|
|
2942
|
-
ts__default.default.ScriptTarget.ESNext,
|
|
2943
|
-
ts__default.default.ScriptTarget.ES2024,
|
|
2944
|
-
ts__default.default.ScriptTarget.ES2023,
|
|
2945
|
-
ts__default.default.ScriptTarget.ES2022,
|
|
2946
|
-
ts__default.default.ScriptTarget.ES2021
|
|
2947
|
-
].includes(tsconfig$1.options.target)) {
|
|
2948
|
-
tsconfigJson.compilerOptions.target = "ESNext";
|
|
2949
|
-
}
|
|
2950
|
-
if (tsconfig$1.options.moduleResolution !== ts__default.default.ModuleResolutionKind.Bundler) {
|
|
2951
|
-
tsconfigJson.compilerOptions.moduleResolution = "Bundler";
|
|
2952
|
-
}
|
|
2953
|
-
if (tsconfig$1.options.moduleDetection !== ts__default.default.ModuleDetectionKind.Force) {
|
|
2954
|
-
tsconfigJson.compilerOptions.moduleDetection = "force";
|
|
2955
|
-
}
|
|
2956
|
-
if (tsconfig$1.options.allowSyntheticDefaultImports !== true) {
|
|
2957
|
-
tsconfigJson.compilerOptions.allowSyntheticDefaultImports = true;
|
|
2958
|
-
}
|
|
2959
|
-
if (tsconfig$1.options.noImplicitOverride !== true) {
|
|
2960
|
-
tsconfigJson.compilerOptions.noImplicitOverride = true;
|
|
2961
|
-
}
|
|
2962
|
-
if (tsconfig$1.options.noUncheckedIndexedAccess !== true) {
|
|
2963
|
-
tsconfigJson.compilerOptions.noUncheckedIndexedAccess = true;
|
|
2964
|
-
}
|
|
2965
|
-
if (tsconfig$1.options.skipLibCheck !== true) {
|
|
2966
|
-
tsconfigJson.compilerOptions.skipLibCheck = true;
|
|
2967
|
-
}
|
|
2968
|
-
if (tsconfig$1.options.resolveJsonModule !== true) {
|
|
2969
|
-
tsconfigJson.compilerOptions.resolveJsonModule = true;
|
|
2970
|
-
}
|
|
2971
|
-
if (tsconfig$1.options.isolatedModules !== true) {
|
|
2972
|
-
tsconfigJson.compilerOptions.isolatedModules = true;
|
|
2973
|
-
}
|
|
2974
|
-
if (tsconfig$1.options.verbatimModuleSyntax !== false) {
|
|
2975
|
-
tsconfigJson.compilerOptions.verbatimModuleSyntax = false;
|
|
2976
|
-
}
|
|
2977
|
-
if (tsconfig$1.options.allowJs !== true) {
|
|
2978
|
-
tsconfigJson.compilerOptions.allowJs = true;
|
|
2979
|
-
}
|
|
2980
|
-
if (tsconfig$1.options.esModuleInterop !== true) {
|
|
2981
|
-
tsconfigJson.compilerOptions.esModuleInterop = true;
|
|
2982
|
-
}
|
|
2983
|
-
if (tsconfig$1.options.declaration !== true) {
|
|
2984
|
-
tsconfigJson.compilerOptions.declaration = true;
|
|
2985
|
-
}
|
|
2986
|
-
if (context.environment.consumer === "client") {
|
|
2987
|
-
if (tsconfig$1.options.jsx !== ts__default.default.JsxEmit.ReactJSX) {
|
|
2988
|
-
tsconfigJson.compilerOptions.jsx = "react-jsx";
|
|
2989
|
-
}
|
|
2990
|
-
if (!tsconfig$1.options.lib?.some((lib) => lib.toLowerCase() !== "dom")) {
|
|
2991
|
-
tsconfigJson.compilerOptions.lib ??= [];
|
|
2992
|
-
tsconfigJson.compilerOptions.lib.push("dom");
|
|
2993
|
-
}
|
|
2994
|
-
if (!tsconfig$1.options.lib?.some((lib) => lib.toLowerCase() !== "dom.iterable")) {
|
|
2995
|
-
tsconfigJson.compilerOptions.lib ??= [];
|
|
2996
|
-
tsconfigJson.compilerOptions.lib.push("dom.iterable");
|
|
2997
|
-
}
|
|
2998
|
-
} else if (context.config.build.platform === "node") {
|
|
2999
|
-
if (!tsconfig$1.options.types?.some((type) => type.toLowerCase() === "node" || type.toLowerCase() === "@types/node")) {
|
|
3000
|
-
tsconfigJson.compilerOptions.types ??= [];
|
|
3001
|
-
tsconfigJson.compilerOptions.types.push("node");
|
|
3002
|
-
}
|
|
3003
|
-
}
|
|
3004
|
-
return tsconfigJson;
|
|
3005
|
-
}
|
|
3006
|
-
chunkUSNT2KNT_cjs.__name(resolveTsconfigChanges, "resolveTsconfigChanges");
|
|
3007
|
-
async function initializeTsconfig(context) {
|
|
3008
|
-
context.log(types.LogLevelLabel.TRACE, "Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.");
|
|
3009
|
-
if (!packageFns.isPackageExists("typescript")) {
|
|
3010
|
-
throw new Error('The TypeScript package is not installed. Please install the package using the command: "npm install typescript --save-dev"');
|
|
3011
|
-
}
|
|
3012
|
-
const tsconfigFilePath = chunkBQU53ZNB_cjs.getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
3013
|
-
context.tsconfig.originalTsconfigJson = await json.readJsonFile(tsconfigFilePath);
|
|
3014
|
-
context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
|
|
3015
|
-
await context.fs.writeFile(tsconfigFilePath, stormJson.StormJSON.stringify(context.tsconfig.tsconfigJson), {
|
|
3016
|
-
mode: "fs"
|
|
3017
|
-
});
|
|
3018
|
-
context.tsconfig = chunkBQU53ZNB_cjs.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
|
|
3019
|
-
}
|
|
3020
|
-
chunkUSNT2KNT_cjs.__name(initializeTsconfig, "initializeTsconfig");
|
|
3021
|
-
async function resolveTsconfig(context) {
|
|
3022
|
-
const updateTsconfigJson = await json.readJsonFile(context.tsconfig.tsconfigFilePath);
|
|
3023
|
-
if (updateTsconfigJson?.compilerOptions?.types && Array.isArray(updateTsconfigJson.compilerOptions.types) && !updateTsconfigJson.compilerOptions.types.length) {
|
|
3024
|
-
delete updateTsconfigJson.compilerOptions.types;
|
|
3025
|
-
}
|
|
3026
|
-
const result = superdiff.getObjectDiff(context.tsconfig.originalTsconfigJson, updateTsconfigJson, {
|
|
3027
|
-
ignoreArrayOrder: true,
|
|
3028
|
-
showOnly: {
|
|
3029
|
-
statuses: [
|
|
3030
|
-
"added",
|
|
3031
|
-
"deleted",
|
|
3032
|
-
"updated"
|
|
3033
|
-
],
|
|
3034
|
-
granularity: "deep"
|
|
3035
|
-
}
|
|
3036
|
-
});
|
|
3037
|
-
const changes = [];
|
|
3038
|
-
const getChanges = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((difference, property) => {
|
|
3039
|
-
if (difference.status === "added" || difference.status === "deleted" || difference.status === "updated") {
|
|
3040
|
-
if (difference.diff) {
|
|
3041
|
-
for (const diff of difference.diff) {
|
|
3042
|
-
getChanges(diff, property ? `${property}.${difference.property}` : difference.property);
|
|
3043
|
-
}
|
|
3044
|
-
} else {
|
|
3045
|
-
changes.push({
|
|
3046
|
-
field: property ? `${property}.${difference.property}` : difference.property,
|
|
3047
|
-
status: difference.status,
|
|
3048
|
-
previous: difference.status === "added" ? "---" : stormJson.StormJSON.stringify(difference.previousValue),
|
|
3049
|
-
current: difference.status === "deleted" ? "---" : stormJson.StormJSON.stringify(difference.currentValue)
|
|
3050
|
-
});
|
|
3051
|
-
}
|
|
3052
|
-
}
|
|
3053
|
-
}, "getChanges");
|
|
3054
|
-
for (const diff of result.diff) {
|
|
3055
|
-
getChanges(diff);
|
|
3056
|
-
}
|
|
3057
|
-
if (changes.length > 0) {
|
|
3058
|
-
context.log(types.LogLevelLabel.WARN, `Updating the following configuration values in "${context.tsconfig.tsconfigFilePath}" file:
|
|
3059
|
-
|
|
3060
|
-
${changes.map((change, i) => `${chalk4__default.default.bold.whiteBright(`${i + 1}. ${titleCase.titleCase(change.status)} the ${change.field} field: `)}
|
|
3061
|
-
${chalk4__default.default.red(` - Previous: ${change.previous} `)}
|
|
3062
|
-
${chalk4__default.default.green(` - Updated: ${change.current} `)}
|
|
3063
|
-
`).join("\n")}
|
|
3064
|
-
`);
|
|
3065
|
-
}
|
|
3066
|
-
await chunk2NZADVP5_cjs.writeFile(context.log, context.tsconfig.tsconfigFilePath, stormJson.StormJSON.stringify(updateTsconfigJson));
|
|
3067
|
-
context.tsconfig = chunkBQU53ZNB_cjs.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
3068
|
-
if (!context.tsconfig) {
|
|
3069
|
-
throw new Error("Failed to parse the TypeScript configuration file.");
|
|
3070
|
-
}
|
|
3071
|
-
context.tsconfig.tsconfigJson.compilerOptions ??= {};
|
|
3072
|
-
context.tsconfig.tsconfigJson.compilerOptions.strict = false;
|
|
3073
|
-
}
|
|
3074
|
-
chunkUSNT2KNT_cjs.__name(resolveTsconfig, "resolveTsconfig");
|
|
3075
|
-
|
|
3076
|
-
// src/api.ts
|
|
3077
|
-
var PowerlinesAPI = class _PowerlinesAPI {
|
|
3078
|
-
static {
|
|
3079
|
-
chunkUSNT2KNT_cjs.__name(this, "PowerlinesAPI");
|
|
3080
|
-
}
|
|
3081
|
-
/**
|
|
3082
|
-
* The Powerlines context
|
|
3083
|
-
*/
|
|
3084
|
-
#context;
|
|
3085
|
-
/**
|
|
3086
|
-
* The Powerlines context
|
|
3087
|
-
*/
|
|
3088
|
-
get context() {
|
|
3089
|
-
return this.#context;
|
|
3090
|
-
}
|
|
3091
|
-
/**
|
|
3092
|
-
* Create a new Powerlines API instance
|
|
3093
|
-
*
|
|
3094
|
-
* @param context - The Powerlines context
|
|
3095
|
-
*/
|
|
3096
|
-
constructor(context) {
|
|
3097
|
-
this.#context = context;
|
|
3098
|
-
}
|
|
3099
|
-
/**
|
|
3100
|
-
* Initialize the Powerlines API
|
|
3101
|
-
*/
|
|
3102
|
-
static async from(workspaceRoot, config) {
|
|
3103
|
-
const api = new _PowerlinesAPI(await PowerlinesAPIContext.from(workspaceRoot, config));
|
|
3104
|
-
for (const plugin of api.context.config.plugins ?? []) {
|
|
3105
|
-
await api.#addPlugin(plugin);
|
|
3106
|
-
}
|
|
3107
|
-
if (api.context.plugins.length === 0) {
|
|
3108
|
-
api.context.log(types.LogLevelLabel.WARN, "No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.");
|
|
3109
|
-
}
|
|
3110
|
-
const pluginConfig = await callHook(await api.context.getEnvironment(), "config", {
|
|
3111
|
-
sequential: true,
|
|
3112
|
-
result: "merge"
|
|
3113
|
-
});
|
|
3114
|
-
await api.context.withUserConfig(pluginConfig, {
|
|
3115
|
-
isHighPriority: false
|
|
3116
|
-
});
|
|
3117
|
-
return api;
|
|
3118
|
-
}
|
|
3119
|
-
/**
|
|
3120
|
-
* Prepare the Powerlines API
|
|
3121
|
-
*/
|
|
3122
|
-
async prepare(inlineConfig = {
|
|
3123
|
-
command: "prepare"
|
|
3124
|
-
}) {
|
|
3125
|
-
this.context.log(types.LogLevelLabel.TRACE, " \u{1F3D7}\uFE0F Preparing the Powerlines project");
|
|
3126
|
-
this.context.log(types.LogLevelLabel.TRACE, " \u2699\uFE0F Aggregating configuration options for the Powerlines project");
|
|
3127
|
-
await this.context.withInlineConfig(inlineConfig);
|
|
3128
|
-
await this.#executeEnvironments(async (context) => {
|
|
3129
|
-
context.log(types.LogLevelLabel.TRACE, `Initializing the processing options for the Powerlines project.`);
|
|
3130
|
-
await this.callPreHook(context, "configResolved");
|
|
3131
|
-
await initializeTsconfig(context);
|
|
3132
|
-
await this.callNormalHook(context, "configResolved");
|
|
3133
|
-
context.log(types.LogLevelLabel.DEBUG, `The configuration provided ${toArray.toArray(context.config.entry).length} entry point(s), Powerlines has found ${context.entry.length} entry files(s) for the ${context.config.title} project${context.entry.length > 0 && context.entry.length < 10 ? `:
|
|
3134
|
-
${context.entry.map((entry) => `- ${entry.input.file || entry.file}${entry.output ? ` -> ${entry.output}` : ""}`).join(" \n")}` : ""}.`);
|
|
3135
|
-
await resolveTsconfig(context);
|
|
3136
|
-
await installDependencies(context);
|
|
3137
|
-
await this.callPostHook(context, "configResolved");
|
|
3138
|
-
if (context.config.build.polyfill) {
|
|
3139
|
-
context.config.build.polyfill = context.config.build.polyfill.map((polyfill) => chunkISBHXSDH_cjs.replacePathTokens(context, polyfill));
|
|
3140
|
-
}
|
|
3141
|
-
context.log(types.LogLevelLabel.TRACE, `Powerlines configuration has been resolved:
|
|
3142
|
-
|
|
3143
|
-
${console.formatLogMessage(context.config)}`);
|
|
3144
|
-
context.fs[__VFS_PATCH__]();
|
|
3145
|
-
await chunk7XHBIYIN_cjs.writeMetaFile(context);
|
|
3146
|
-
context.persistedMeta = context.meta;
|
|
3147
|
-
if (!exists.existsSync(context.cachePath)) {
|
|
3148
|
-
await helpers.createDirectory(context.cachePath);
|
|
3149
|
-
}
|
|
3150
|
-
if (!exists.existsSync(context.dataPath)) {
|
|
3151
|
-
await helpers.createDirectory(context.dataPath);
|
|
3152
|
-
}
|
|
3153
|
-
await this.callPreHook(context, "prepare");
|
|
3154
|
-
await this.callNormalHook(context, "prepare");
|
|
3155
|
-
if (context.config.output.dts !== false) {
|
|
3156
|
-
context.log(types.LogLevelLabel.TRACE, `Preparing the TypeScript definitions for the Powerlines project.`);
|
|
3157
|
-
context.log(types.LogLevelLabel.TRACE, "Transforming built-ins runtime modules files.");
|
|
3158
|
-
const builtinFilePaths = await Promise.all((await context.getBuiltins()).map(async (file) => {
|
|
3159
|
-
const result2 = await core.transformAsync(file.code.toString(), {
|
|
3160
|
-
highlightCode: true,
|
|
3161
|
-
code: true,
|
|
3162
|
-
ast: false,
|
|
3163
|
-
cloneInputAst: false,
|
|
3164
|
-
comments: true,
|
|
3165
|
-
sourceType: "module",
|
|
3166
|
-
configFile: false,
|
|
3167
|
-
babelrc: false,
|
|
3168
|
-
envName: context.config.mode,
|
|
3169
|
-
caller: {
|
|
3170
|
-
name: "powerlines"
|
|
3171
|
-
},
|
|
3172
|
-
...context.config.transform.babel,
|
|
3173
|
-
filename: file.path,
|
|
3174
|
-
plugins: [
|
|
3175
|
-
[
|
|
3176
|
-
"@babel/plugin-syntax-typescript"
|
|
3177
|
-
],
|
|
3178
|
-
[
|
|
3179
|
-
moduleResolverBabelPlugin(context)
|
|
3180
|
-
]
|
|
3181
|
-
]
|
|
3182
|
-
});
|
|
3183
|
-
if (!result2?.code) {
|
|
3184
|
-
throw new Error(`Powerlines - Generate Types failed to compile ${file.id}`);
|
|
3185
|
-
}
|
|
3186
|
-
context.log(types.LogLevelLabel.TRACE, `Writing transformed built-in runtime file ${file.id}.`);
|
|
3187
|
-
await context.writeBuiltin(result2.code, file.id, file.path);
|
|
3188
|
-
return file.path;
|
|
3189
|
-
}));
|
|
3190
|
-
const typescriptPath = await resolve.resolvePackage("typescript");
|
|
3191
|
-
if (!typescriptPath) {
|
|
3192
|
-
throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
|
|
3193
|
-
}
|
|
3194
|
-
const files = builtinFilePaths.reduce((ret, fileName) => {
|
|
3195
|
-
const formatted = replace.replacePath(fileName, context.workspaceConfig.workspaceRoot);
|
|
3196
|
-
if (!ret.includes(formatted)) {
|
|
3197
|
-
ret.push(formatted);
|
|
3198
|
-
}
|
|
3199
|
-
return ret;
|
|
3200
|
-
}, [
|
|
3201
|
-
joinPaths.joinPaths(typescriptPath, "lib", "lib.esnext.full.d.ts")
|
|
3202
|
-
]);
|
|
3203
|
-
context.log(types.LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
|
|
3204
|
-
const resolvedTsconfig = chunkBQU53ZNB_cjs.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu2__default.default({
|
|
3205
|
-
compilerOptions: {
|
|
3206
|
-
strict: false,
|
|
3207
|
-
noEmit: false,
|
|
3208
|
-
declaration: true,
|
|
3209
|
-
declarationMap: false,
|
|
3210
|
-
emitDeclarationOnly: true,
|
|
3211
|
-
skipLibCheck: true
|
|
3212
|
-
},
|
|
3213
|
-
exclude: [
|
|
3214
|
-
"node_modules",
|
|
3215
|
-
"dist"
|
|
3216
|
-
],
|
|
3217
|
-
include: files
|
|
3218
|
-
}, context.config.tsconfigRaw ?? {}));
|
|
3219
|
-
resolvedTsconfig.options.configFilePath = joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.tsconfig.tsconfigFilePath);
|
|
3220
|
-
resolvedTsconfig.options.pathsBasePath = context.workspaceConfig.workspaceRoot;
|
|
3221
|
-
resolvedTsconfig.options.suppressOutputPathCheck = true;
|
|
3222
|
-
let generatedTypes = await emitTypes(context, resolvedTsconfig, files);
|
|
3223
|
-
context.log(types.LogLevelLabel.TRACE, `Generating TypeScript declaration file in ${context.config.output.dts}.`);
|
|
3224
|
-
const directives = [];
|
|
3225
|
-
let result = await this.callPreHook(context, "generateTypes", generatedTypes);
|
|
3226
|
-
if (result) {
|
|
3227
|
-
if (isSetObject.isSetObject(result)) {
|
|
3228
|
-
generatedTypes = result.code;
|
|
3229
|
-
if (Array.isArray(result.directives) && result.directives.length > 0) {
|
|
3230
|
-
directives.push(...result.directives);
|
|
3231
|
-
}
|
|
3232
|
-
} else if (isSetString.isSetString(result)) {
|
|
3233
|
-
generatedTypes = result;
|
|
3234
|
-
}
|
|
3235
|
-
}
|
|
3236
|
-
result = await this.callNormalHook(context, "generateTypes", generatedTypes);
|
|
3237
|
-
if (result) {
|
|
3238
|
-
if (isSetObject.isSetObject(result)) {
|
|
3239
|
-
generatedTypes = result.code;
|
|
3240
|
-
if (Array.isArray(result.directives) && result.directives.length > 0) {
|
|
3241
|
-
directives.push(...result.directives);
|
|
3242
|
-
}
|
|
3243
|
-
} else if (isSetString.isSetString(result)) {
|
|
3244
|
-
generatedTypes = result;
|
|
3245
|
-
}
|
|
3246
|
-
}
|
|
3247
|
-
result = await this.callPostHook(context, "generateTypes", generatedTypes);
|
|
3248
|
-
if (result) {
|
|
3249
|
-
if (isSetObject.isSetObject(result)) {
|
|
3250
|
-
generatedTypes = result.code;
|
|
3251
|
-
if (Array.isArray(result.directives) && result.directives.length > 0) {
|
|
3252
|
-
directives.push(...result.directives);
|
|
3253
|
-
}
|
|
3254
|
-
} else if (isSetString.isSetString(result)) {
|
|
3255
|
-
generatedTypes = result;
|
|
3256
|
-
}
|
|
3257
|
-
}
|
|
3258
|
-
await context.fs.writeFile(context.config.output.dts, `${directives ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
|
|
3259
|
-
|
|
3260
|
-
` : ""}${chunk4NHFXDTQ_cjs.getFileHeader(context, {
|
|
3261
|
-
directive: null,
|
|
3262
|
-
prettierIgnore: false
|
|
3263
|
-
})}
|
|
3264
|
-
|
|
3265
|
-
${formatTypes(generatedTypes)}
|
|
3266
|
-
`, {
|
|
3267
|
-
mode: "fs"
|
|
3268
|
-
});
|
|
3269
|
-
}
|
|
3270
|
-
context.tsconfig = chunkBQU53ZNB_cjs.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
3271
|
-
if (!context.tsconfig) {
|
|
3272
|
-
throw new Error("Failed to parse the TypeScript configuration file.");
|
|
3273
|
-
}
|
|
3274
|
-
await this.callPostHook(context, "prepare");
|
|
3275
|
-
await chunk7XHBIYIN_cjs.writeMetaFile(context);
|
|
3276
|
-
context.fs[__VFS_REVERT__]();
|
|
3277
|
-
});
|
|
3278
|
-
this.context.log(types.LogLevelLabel.INFO, "Powerlines API has been prepared successfully");
|
|
3279
|
-
}
|
|
3280
|
-
/**
|
|
3281
|
-
* Create a new Powerlines project
|
|
3282
|
-
*
|
|
3283
|
-
* @remarks
|
|
3284
|
-
* This method will create a new Powerlines project in the current directory.
|
|
3285
|
-
*
|
|
3286
|
-
* @param inlineConfig - The inline configuration for the new command
|
|
3287
|
-
* @returns A promise that resolves when the project has been created
|
|
3288
|
-
*/
|
|
3289
|
-
async new(inlineConfig) {
|
|
3290
|
-
this.context.log(types.LogLevelLabel.INFO, "\u{1F195} Creating a new Powerlines project");
|
|
3291
|
-
await this.prepare(inlineConfig);
|
|
3292
|
-
await this.#executeEnvironments(async (context) => {
|
|
3293
|
-
context.log(types.LogLevelLabel.TRACE, `Initializing the processing options for the Powerlines project.`);
|
|
3294
|
-
await this.callPreHook(context, "new");
|
|
3295
|
-
const files = await listFiles.listFiles(joinPaths.joinPaths(context.powerlinesPath, "files/common/**/*.hbs"));
|
|
3296
|
-
for (const file of files) {
|
|
3297
|
-
context.log(types.LogLevelLabel.TRACE, `Adding template file: ${file}`);
|
|
3298
|
-
const template = Handlebars__default.default.compile(file);
|
|
3299
|
-
await chunk2NZADVP5_cjs.writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
|
|
3300
|
-
}
|
|
3301
|
-
await this.callNormalHook(context, "new");
|
|
3302
|
-
if (context.config.projectType === "application") {
|
|
3303
|
-
const files2 = await listFiles.listFiles(joinPaths.joinPaths(context.powerlinesPath, "files/application/**/*.hbs"));
|
|
3304
|
-
for (const file of files2) {
|
|
3305
|
-
context.log(types.LogLevelLabel.TRACE, `Adding application template file: ${file}`);
|
|
3306
|
-
const template = Handlebars__default.default.compile(file);
|
|
3307
|
-
await chunk2NZADVP5_cjs.writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
|
|
3308
|
-
}
|
|
3309
|
-
} else {
|
|
3310
|
-
const files2 = await listFiles.listFiles(joinPaths.joinPaths(context.powerlinesPath, "files/library/**/*.hbs"));
|
|
3311
|
-
for (const file of files2) {
|
|
3312
|
-
context.log(types.LogLevelLabel.TRACE, `Adding library template file: ${file}`);
|
|
3313
|
-
const template = Handlebars__default.default.compile(file);
|
|
3314
|
-
await chunk2NZADVP5_cjs.writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
|
|
3315
|
-
}
|
|
3316
|
-
}
|
|
3317
|
-
await this.callPostHook(context, "new");
|
|
3318
|
-
});
|
|
3319
|
-
this.context.log(types.LogLevelLabel.TRACE, "Powerlines - New command completed");
|
|
3320
|
-
}
|
|
3321
|
-
/**
|
|
3322
|
-
* Clean any previously prepared artifacts
|
|
3323
|
-
*
|
|
3324
|
-
* @remarks
|
|
3325
|
-
* This method will remove the previous Powerlines artifacts from the project.
|
|
3326
|
-
*
|
|
3327
|
-
* @param inlineConfig - The inline configuration for the clean command
|
|
3328
|
-
* @returns A promise that resolves when the clean command has completed
|
|
3329
|
-
*/
|
|
3330
|
-
async clean(inlineConfig = {
|
|
3331
|
-
command: "clean"
|
|
3332
|
-
}) {
|
|
3333
|
-
this.context.log(types.LogLevelLabel.INFO, "\u{1F9F9} Cleaning the previous Powerlines artifacts");
|
|
3334
|
-
await this.prepare(inlineConfig);
|
|
3335
|
-
await this.#executeEnvironments(async (context) => {
|
|
3336
|
-
this.context.log(types.LogLevelLabel.TRACE, "Cleaning the project's dist and artifacts directories.");
|
|
3337
|
-
await context.fs.rmdir(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.output.distPath));
|
|
3338
|
-
await context.fs.rmdir(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.output.artifactsFolder));
|
|
3339
|
-
await callHook(context, "clean", {
|
|
3340
|
-
sequential: true
|
|
3341
|
-
});
|
|
3342
|
-
});
|
|
3343
|
-
this.context.log(types.LogLevelLabel.TRACE, "Powerlines - Clean command completed");
|
|
3344
|
-
}
|
|
3345
|
-
/**
|
|
3346
|
-
* Lint the project
|
|
3347
|
-
*
|
|
3348
|
-
* @param inlineConfig - The inline configuration for the lint command
|
|
3349
|
-
* @returns A promise that resolves when the lint command has completed
|
|
3350
|
-
*/
|
|
3351
|
-
async lint(inlineConfig = {
|
|
3352
|
-
command: "lint"
|
|
3353
|
-
}) {
|
|
3354
|
-
this.context.log(types.LogLevelLabel.INFO, "\u{1F4CB} Linting the Powerlines project");
|
|
3355
|
-
await this.prepare(inlineConfig);
|
|
3356
|
-
await this.#executeEnvironments(async (context) => {
|
|
3357
|
-
if (context.config.lint !== false) {
|
|
3358
|
-
await this.callHook(context, "lint");
|
|
3359
|
-
}
|
|
3360
|
-
});
|
|
3361
|
-
this.context.log(types.LogLevelLabel.TRACE, "Powerlines linting completed");
|
|
3362
|
-
}
|
|
3363
|
-
/**
|
|
3364
|
-
* Build the project
|
|
3365
|
-
*
|
|
3366
|
-
* @remarks
|
|
3367
|
-
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
3368
|
-
*
|
|
3369
|
-
* @param inlineConfig - The inline configuration for the build command
|
|
3370
|
-
* @returns A promise that resolves when the build command has completed
|
|
3371
|
-
*/
|
|
3372
|
-
async build(inlineConfig = {
|
|
3373
|
-
command: "build"
|
|
3374
|
-
}) {
|
|
3375
|
-
this.context.log(types.LogLevelLabel.INFO, "\u{1F4E6} Building the Powerlines project");
|
|
3376
|
-
await this.prepare(inlineConfig);
|
|
3377
|
-
await this.#executeEnvironments(async (context) => {
|
|
3378
|
-
await this.callPreHook(context, "build");
|
|
3379
|
-
await this.callNormalHook(context, "build");
|
|
3380
|
-
if (context.config.output.distPath !== context.config.output.outputPath) {
|
|
3381
|
-
const sourcePath = append.appendPath(context.config.output.distPath, context.workspaceConfig.workspaceRoot);
|
|
3382
|
-
const destinationPath = joinPaths.joinPaths(append.appendPath(context.config.output.outputPath, context.workspaceConfig.workspaceRoot), "dist");
|
|
3383
|
-
if (sourcePath !== destinationPath) {
|
|
3384
|
-
context.log(types.LogLevelLabel.INFO, `Copying build output files from project's build directory (${context.config.output.distPath}) to the workspace's output directory (${context.config.output.outputPath}).`);
|
|
3385
|
-
await copyFile.copyFiles({
|
|
3386
|
-
input: sourcePath,
|
|
3387
|
-
glob: "**/*"
|
|
3388
|
-
}, destinationPath);
|
|
3389
|
-
}
|
|
3390
|
-
}
|
|
3391
|
-
await Promise.all(context.config.output.assets.map(async (asset) => {
|
|
3392
|
-
context.log(types.LogLevelLabel.DEBUG, `Copying asset(s): ${chalk4__default.default.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : joinPaths.joinPaths(replace.replacePath(asset.input, context.workspaceConfig.workspaceRoot), asset.glob))} -> ${chalk4__default.default.greenBright(joinPaths.joinPaths(replace.replacePath(asset.output, context.workspaceConfig.workspaceRoot), asset.glob))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk4__default.default.yellowBright(i)).join(", ")})` : ""}`);
|
|
3393
|
-
await copyFile.copyFiles(asset, asset.output);
|
|
3394
|
-
}));
|
|
3395
|
-
await this.callPostHook(context, "build");
|
|
3396
|
-
});
|
|
3397
|
-
this.context.log(types.LogLevelLabel.TRACE, "Powerlines build completed");
|
|
3398
|
-
}
|
|
3399
|
-
/**
|
|
3400
|
-
* Prepare the documentation for the project
|
|
3401
|
-
*
|
|
3402
|
-
* @param inlineConfig - The inline configuration for the docs command
|
|
3403
|
-
* @returns A promise that resolves when the documentation generation has completed
|
|
3404
|
-
*/
|
|
3405
|
-
async docs(inlineConfig = {
|
|
3406
|
-
command: "docs"
|
|
3407
|
-
}) {
|
|
3408
|
-
this.context.log(types.LogLevelLabel.INFO, "\u{1F4D3} Generating documentation for the Powerlines project");
|
|
3409
|
-
await this.prepare(inlineConfig);
|
|
3410
|
-
await this.#executeEnvironments(async (context) => {
|
|
3411
|
-
context.log(types.LogLevelLabel.TRACE, "Writing documentation for the Powerlines project artifacts.");
|
|
3412
|
-
await this.prepare(inlineConfig);
|
|
3413
|
-
await this.#executeEnvironments(async (context2) => {
|
|
3414
|
-
await this.callHook(context2, "docs");
|
|
3415
|
-
});
|
|
3416
|
-
});
|
|
3417
|
-
this.#context.log(types.LogLevelLabel.TRACE, "Powerlines documentation generation completed");
|
|
3418
|
-
}
|
|
3419
|
-
/**
|
|
3420
|
-
* Deploy the project source code
|
|
3421
|
-
*
|
|
3422
|
-
* @remarks
|
|
3423
|
-
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
3424
|
-
*
|
|
3425
|
-
* @param inlineConfig - The inline configuration for the deploy command
|
|
3426
|
-
*/
|
|
3427
|
-
async deploy(inlineConfig = {
|
|
3428
|
-
command: "deploy"
|
|
3429
|
-
}) {
|
|
3430
|
-
this.context.log(types.LogLevelLabel.INFO, "\u{1F4E6} Deploying the Powerlines project");
|
|
3431
|
-
await this.prepare(inlineConfig);
|
|
3432
|
-
await this.#executeEnvironments(async (context) => {
|
|
3433
|
-
await this.callHook(context, "deploy");
|
|
3434
|
-
});
|
|
3435
|
-
this.context.log(types.LogLevelLabel.TRACE, "Powerlines deploy completed");
|
|
3436
|
-
}
|
|
3437
|
-
/**
|
|
3438
|
-
* Finalization process
|
|
3439
|
-
*
|
|
3440
|
-
* @remarks
|
|
3441
|
-
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
3442
|
-
*
|
|
3443
|
-
* @returns A promise that resolves when the finalization process has completed
|
|
3444
|
-
*/
|
|
3445
|
-
async finalize() {
|
|
3446
|
-
this.context.log(types.LogLevelLabel.TRACE, "Powerlines finalize execution started");
|
|
3447
|
-
await this.#executeEnvironments(async (context) => {
|
|
3448
|
-
await this.callHook(context, "finalize");
|
|
3449
|
-
context.fs[__VFS_REVERT__]();
|
|
3450
|
-
await context.fs.dispose();
|
|
3451
|
-
});
|
|
3452
|
-
this.context.log(types.LogLevelLabel.TRACE, "Powerlines finalize execution completed");
|
|
3453
|
-
}
|
|
3454
|
-
/**
|
|
3455
|
-
* Calls a hook in parallel
|
|
3456
|
-
*
|
|
3457
|
-
* @param hook - The hook to call
|
|
3458
|
-
* @param options - Options for calling the hook
|
|
3459
|
-
* @param args - The arguments to pass to the hook
|
|
3460
|
-
* @returns The result of the hook call
|
|
3461
|
-
*/
|
|
3462
|
-
async callHookParallel(hook, options, ...args) {
|
|
3463
|
-
return callHook(isSetObject.isSetObject(options?.environment) ? options.environment : await this.#context.getEnvironment(options?.environment), hook, {
|
|
3464
|
-
...options,
|
|
3465
|
-
sequential: false
|
|
3466
|
-
}, ...args);
|
|
3467
|
-
}
|
|
3468
|
-
/**
|
|
3469
|
-
* Calls a hook in sequence
|
|
3470
|
-
*
|
|
3471
|
-
* @param hook - The hook to call
|
|
3472
|
-
* @param options - Options for calling the hook
|
|
3473
|
-
* @param args - The arguments to pass to the hook
|
|
3474
|
-
* @returns The result of the hook call
|
|
3475
|
-
*/
|
|
3476
|
-
async callHookSequential(hook, options, ...args) {
|
|
3477
|
-
return callHook(isSetObject.isSetObject(options?.environment) ? options.environment : await this.#context.getEnvironment(options?.environment), hook, {
|
|
3478
|
-
...options,
|
|
3479
|
-
sequential: true
|
|
3480
|
-
}, ...args);
|
|
3481
|
-
}
|
|
3482
|
-
/**
|
|
3483
|
-
* Calls the `"pre"` ordered hooks in sequence
|
|
3484
|
-
*
|
|
3485
|
-
* @param environment - The environment to use for the hook call
|
|
3486
|
-
* @param hook - The hook to call
|
|
3487
|
-
* @param args - The arguments to pass to the hook
|
|
3488
|
-
* @returns The result of the hook call
|
|
3489
|
-
*/
|
|
3490
|
-
async callPreHook(environment, hook, ...args) {
|
|
3491
|
-
return this.callHookSequential(hook, {
|
|
3492
|
-
order: "pre",
|
|
3493
|
-
environment
|
|
3494
|
-
}, ...args);
|
|
3495
|
-
}
|
|
3496
|
-
/**
|
|
3497
|
-
* Calls the `"post"` ordered hooks in sequence
|
|
3498
|
-
*
|
|
3499
|
-
* @param environment - The environment to use for the hook call
|
|
3500
|
-
* @param hook - The hook to call
|
|
3501
|
-
* @param args - The arguments to pass to the hook
|
|
3502
|
-
* @returns The result of the hook call
|
|
3503
|
-
*/
|
|
3504
|
-
async callPostHook(environment, hook, ...args) {
|
|
3505
|
-
return this.callHookSequential(hook, {
|
|
3506
|
-
order: "post",
|
|
3507
|
-
environment
|
|
3508
|
-
}, ...args);
|
|
3509
|
-
}
|
|
3510
|
-
/**
|
|
3511
|
-
* Calls a hook in sequence
|
|
3512
|
-
*
|
|
3513
|
-
* @param environment - The environment to use for the hook call
|
|
3514
|
-
* @param hook - The hook to call
|
|
3515
|
-
* @param args - The arguments to pass to the hook
|
|
3516
|
-
* @returns The result of the hook call
|
|
3517
|
-
*/
|
|
3518
|
-
async callNormalHook(environment, hook, ...args) {
|
|
3519
|
-
return this.callHookSequential(hook, {
|
|
3520
|
-
order: "normal",
|
|
3521
|
-
environment
|
|
3522
|
-
}, ...args);
|
|
3523
|
-
}
|
|
3524
|
-
/**
|
|
3525
|
-
* Calls the `"pre"` and `"post"` ordered hooks, as well as the normal hooks in sequence
|
|
3526
|
-
*
|
|
3527
|
-
* @param environment - The environment to use for the hook call
|
|
3528
|
-
* @param hook - The hook to call
|
|
3529
|
-
* @param args - The arguments to pass to the hook
|
|
3530
|
-
* @returns The result of the hook call
|
|
3531
|
-
*/
|
|
3532
|
-
async callHook(environment, hook, ...args) {
|
|
3533
|
-
return this.callHookSequential(hook, {
|
|
3534
|
-
environment
|
|
3535
|
-
}, ...args);
|
|
3536
|
-
}
|
|
3537
|
-
async [Symbol.asyncDispose]() {
|
|
3538
|
-
await this.finalize();
|
|
3539
|
-
}
|
|
3540
|
-
/**
|
|
3541
|
-
* Get the configured environments
|
|
3542
|
-
*
|
|
3543
|
-
* @returns The configured environments
|
|
3544
|
-
*/
|
|
3545
|
-
async #getEnvironments() {
|
|
3546
|
-
if (!this.context.config.environments || Object.keys(this.context.config.environments).length <= 1) {
|
|
3547
|
-
this.context.log(types.LogLevelLabel.DEBUG, "No environments are configured for this Powerlines project. Using the default environment.");
|
|
3548
|
-
return [
|
|
3549
|
-
await this.context.getEnvironment()
|
|
3550
|
-
];
|
|
3551
|
-
}
|
|
3552
|
-
this.context.log(types.LogLevelLabel.DEBUG, `Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`);
|
|
3553
|
-
return (await Promise.all(Object.entries(this.context.config.environments).map(async ([name, config]) => {
|
|
3554
|
-
const environment = await this.context.getEnvironmentSafe(name);
|
|
3555
|
-
if (!environment) {
|
|
3556
|
-
const resolvedEnvironment = await this.callHookParallel("configEnvironment", {
|
|
3557
|
-
environment: name
|
|
3558
|
-
}, name, config);
|
|
3559
|
-
if (resolvedEnvironment) {
|
|
3560
|
-
this.context.environments[name] = await this.context.in(resolvedEnvironment);
|
|
3561
|
-
}
|
|
3562
|
-
}
|
|
3563
|
-
return this.context.environments[name];
|
|
3564
|
-
}))).filter((context) => isSet.isSet(context));
|
|
3565
|
-
}
|
|
3566
|
-
/**
|
|
3567
|
-
* Execute a handler function for each environment
|
|
3568
|
-
*
|
|
3569
|
-
* @param handle - The handler function to execute for each environment
|
|
3570
|
-
*/
|
|
3571
|
-
async #executeEnvironments(handle) {
|
|
3572
|
-
await Promise.all((await this.#getEnvironments()).map(async (context) => {
|
|
3573
|
-
return Promise.resolve(handle(context));
|
|
3574
|
-
}));
|
|
3575
|
-
}
|
|
3576
|
-
/**
|
|
3577
|
-
* Add a Powerlines plugin used in the build process
|
|
3578
|
-
*
|
|
3579
|
-
* @param config - The import path of the plugin to add
|
|
3580
|
-
*/
|
|
3581
|
-
async #addPlugin(config) {
|
|
3582
|
-
if (config) {
|
|
3583
|
-
const plugin = await this.#initPlugin(config);
|
|
3584
|
-
if (!plugin) {
|
|
3585
|
-
return;
|
|
3586
|
-
}
|
|
3587
|
-
if (plugin.dependsOn) {
|
|
3588
|
-
for (const required of plugin.dependsOn) {
|
|
3589
|
-
await this.#addPlugin(required);
|
|
3590
|
-
}
|
|
3591
|
-
}
|
|
3592
|
-
this.context.log(types.LogLevelLabel.DEBUG, `Successfully initialized the ${chalk4__default.default.bold.cyanBright(plugin.name)} plugin`);
|
|
3593
|
-
await this.context.addPlugin(plugin);
|
|
3594
|
-
}
|
|
3595
|
-
}
|
|
3596
|
-
/**
|
|
3597
|
-
* Initialize a Powerlines plugin
|
|
3598
|
-
*
|
|
3599
|
-
* @param config - The configuration for the plugin
|
|
3600
|
-
* @returns The initialized plugin instance, or null if the plugin was a duplicate
|
|
3601
|
-
* @throws Will throw an error if the plugin cannot be found or is invalid
|
|
3602
|
-
*/
|
|
3603
|
-
async #initPlugin(config) {
|
|
3604
|
-
let awaited = config;
|
|
3605
|
-
if (isPromise.isPromiseLike(config)) {
|
|
3606
|
-
awaited = await Promise.resolve(config);
|
|
3607
|
-
}
|
|
3608
|
-
if (!isPluginConfig(awaited)) {
|
|
3609
|
-
throw new Error(`Invalid plugin specified in the configuration - ${JSON.stringify(awaited)}. Please ensure the value is a plugin name, an object with the \`plugin\` and \`props\` properties, or an instance of \`Plugin\`.`);
|
|
3610
|
-
}
|
|
3611
|
-
let plugin;
|
|
3612
|
-
if (isPlugin(awaited)) {
|
|
3613
|
-
plugin = awaited;
|
|
3614
|
-
} else if (isFunction.isFunction(awaited)) {
|
|
3615
|
-
plugin = await Promise.resolve(awaited());
|
|
3616
|
-
} else if (isSetString.isSetString(awaited)) {
|
|
3617
|
-
const resolved = await this.#resolvePlugin(awaited);
|
|
3618
|
-
if (isFunction.isFunction(resolved)) {
|
|
3619
|
-
plugin = await Promise.resolve(resolved());
|
|
3620
|
-
} else {
|
|
3621
|
-
plugin = resolved;
|
|
3622
|
-
}
|
|
3623
|
-
} else if (isPluginConfigTuple(awaited) || isPluginConfigObject(awaited)) {
|
|
3624
|
-
let pluginConfig;
|
|
3625
|
-
let pluginOptions;
|
|
3626
|
-
if (isPluginConfigTuple(awaited)) {
|
|
3627
|
-
pluginConfig = awaited[0];
|
|
3628
|
-
pluginOptions = awaited?.length === 2 ? awaited[1] : void 0;
|
|
3629
|
-
} else {
|
|
3630
|
-
pluginConfig = awaited.plugin;
|
|
3631
|
-
pluginOptions = awaited.options;
|
|
3632
|
-
}
|
|
3633
|
-
if (isSetString.isSetString(pluginConfig)) {
|
|
3634
|
-
const resolved = await this.#resolvePlugin(pluginConfig);
|
|
3635
|
-
if (isFunction.isFunction(resolved)) {
|
|
3636
|
-
plugin = await Promise.resolve(pluginOptions ? resolved(pluginOptions) : resolved());
|
|
3637
|
-
} else {
|
|
3638
|
-
plugin = resolved;
|
|
3639
|
-
}
|
|
3640
|
-
} else if (isFunction.isFunction(pluginConfig)) {
|
|
3641
|
-
plugin = await Promise.resolve(pluginConfig(pluginOptions));
|
|
3642
|
-
} else if (isPlugin(pluginConfig)) {
|
|
3643
|
-
plugin = pluginConfig;
|
|
3644
|
-
}
|
|
3645
|
-
}
|
|
3646
|
-
if (!plugin) {
|
|
3647
|
-
throw new Error(`The plugin configuration ${JSON.stringify(awaited)} is invalid. This configuration must point to a valid Powerlines plugin module.`);
|
|
3648
|
-
}
|
|
3649
|
-
if (!isPlugin(plugin)) {
|
|
3650
|
-
throw new Error(`The plugin option ${JSON.stringify(plugin)} does not export a valid module. This configuration must point to a valid Powerlines plugin module.`);
|
|
3651
|
-
}
|
|
3652
|
-
if (checkDedupe(plugin, this.context.plugins)) {
|
|
3653
|
-
this.context.log(types.LogLevelLabel.TRACE, `Duplicate ${chalk4__default.default.bold.cyanBright(plugin.name)} plugin dependency detected - Skipping initialization.`);
|
|
3654
|
-
return null;
|
|
3655
|
-
}
|
|
3656
|
-
this.context.log(types.LogLevelLabel.TRACE, `Initializing the ${chalk4__default.default.bold.cyanBright(plugin.name)} plugin...`);
|
|
3657
|
-
return plugin;
|
|
3658
|
-
}
|
|
3659
|
-
async #resolvePlugin(pluginPath) {
|
|
3660
|
-
if (pluginPath.startsWith("@") && pluginPath.split("/").filter(Boolean).length > 2) {
|
|
3661
|
-
const splits = pluginPath.split("/").filter(Boolean);
|
|
3662
|
-
pluginPath = `${splits[0]}/${splits[1]}`;
|
|
3663
|
-
}
|
|
3664
|
-
const isInstalled = packageFns.isPackageExists(pluginPath, {
|
|
3665
|
-
paths: [
|
|
3666
|
-
this.context.workspaceConfig.workspaceRoot,
|
|
3667
|
-
this.context.config.projectRoot
|
|
3668
|
-
]
|
|
3669
|
-
});
|
|
3670
|
-
if (!isInstalled && this.context.config.skipInstalls !== true) {
|
|
3671
|
-
this.#context.log(types.LogLevelLabel.WARN, `The plugin package "${pluginPath}" is not installed. It will be installed automatically.`);
|
|
3672
|
-
const result = await install.install(pluginPath, {
|
|
3673
|
-
cwd: this.context.config.projectRoot
|
|
3674
|
-
});
|
|
3675
|
-
if (isNumber.isNumber(result.exitCode) && result.exitCode > 0) {
|
|
3676
|
-
this.#context.log(types.LogLevelLabel.ERROR, result.stderr);
|
|
3677
|
-
throw new Error(`An error occurred while installing the build plugin package "${pluginPath}" `);
|
|
3678
|
-
}
|
|
3679
|
-
}
|
|
3680
|
-
try {
|
|
3681
|
-
const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(joinPaths.joinPaths(pluginPath, "plugin")));
|
|
3682
|
-
const result = module.plugin ?? module.default;
|
|
3683
|
-
if (!result) {
|
|
3684
|
-
throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
|
|
3685
|
-
}
|
|
3686
|
-
return result;
|
|
3687
|
-
} catch (error) {
|
|
3688
|
-
try {
|
|
3689
|
-
const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(pluginPath));
|
|
3690
|
-
const result = module.plugin ?? module.default;
|
|
3691
|
-
if (!result) {
|
|
3692
|
-
throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
|
|
3693
|
-
}
|
|
3694
|
-
return result;
|
|
3695
|
-
} catch {
|
|
3696
|
-
if (!isInstalled) {
|
|
3697
|
-
throw new Error(`The plugin package "${pluginPath}" is not installed. Please install the package using the command: "npm install ${pluginPath} --save-dev"`);
|
|
3698
|
-
} else {
|
|
3699
|
-
throw new Error(`An error occurred while importing the build plugin package "${pluginPath}":
|
|
3700
|
-
${isError.isError(error) ? error.message : String(error)}
|
|
3701
|
-
|
|
3702
|
-
Note: Please ensure the plugin package's default export is a class that extends \`Plugin\` with a constructor that excepts a single arguments of type \`PluginOptions\`.`);
|
|
3703
|
-
}
|
|
3704
|
-
}
|
|
3705
|
-
}
|
|
3706
|
-
}
|
|
3707
|
-
};
|
|
3708
|
-
|
|
3709
|
-
// src/lib/unplugin/factory.ts
|
|
3710
|
-
function createUnpluginFactory(variant, decorate) {
|
|
3711
|
-
return (config, meta) => {
|
|
3712
|
-
const log = chunkJA4HSQRN_cjs.createLog("unplugin", config);
|
|
3713
|
-
log(types.LogLevelLabel.DEBUG, "Initializing Unplugin");
|
|
3714
|
-
try {
|
|
3715
|
-
const userConfig = {
|
|
3716
|
-
...config,
|
|
3717
|
-
variant,
|
|
3718
|
-
unplugin: meta
|
|
3719
|
-
};
|
|
3720
|
-
let api;
|
|
3721
|
-
let resolvePatterns = [];
|
|
3722
|
-
async function buildStart() {
|
|
3723
|
-
log(types.LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
|
|
3724
|
-
const workspaceRoot = getWorkspaceRoot.getWorkspaceRoot(process.cwd());
|
|
3725
|
-
api = await PowerlinesAPI.from(workspaceRoot, userConfig);
|
|
3726
|
-
if (api.context.config.build.skipNodeModulesBundle) {
|
|
3727
|
-
resolvePatterns = bundleRequire.tsconfigPathsToRegExp(api.context.tsconfig.options.paths ?? []);
|
|
3728
|
-
}
|
|
3729
|
-
log(types.LogLevelLabel.DEBUG, "Preparing build artifacts for the Powerlines project...");
|
|
3730
|
-
await api.prepare({
|
|
3731
|
-
command: "build"
|
|
3732
|
-
});
|
|
3733
|
-
}
|
|
3734
|
-
chunkUSNT2KNT_cjs.__name(buildStart, "buildStart");
|
|
3735
|
-
async function resolveId(id, importer, options = {
|
|
3736
|
-
isEntry: false
|
|
3737
|
-
}) {
|
|
3738
|
-
return chunkULJVBW4L_cjs.handleResolveId(api.context, {
|
|
3739
|
-
id,
|
|
3740
|
-
importer,
|
|
3741
|
-
options
|
|
3742
|
-
}, {
|
|
3743
|
-
skipNodeModulesBundle: api.context.config.build.skipNodeModulesBundle,
|
|
3744
|
-
external: api.context.config.build.external,
|
|
3745
|
-
noExternal: api.context.config.build.noExternal,
|
|
3746
|
-
resolvePatterns
|
|
3747
|
-
});
|
|
3748
|
-
}
|
|
3749
|
-
chunkUSNT2KNT_cjs.__name(resolveId, "resolveId");
|
|
3750
|
-
async function load(id) {
|
|
3751
|
-
const environment = await api.context.getEnvironment();
|
|
3752
|
-
if (id) {
|
|
3753
|
-
const resolvedPath = environment.fs.resolve(id);
|
|
3754
|
-
if (resolvedPath) {
|
|
3755
|
-
return environment.fs.readFile(resolvedPath);
|
|
3756
|
-
}
|
|
3757
|
-
}
|
|
3758
|
-
let result2 = await api.callPreHook(environment, "load", id);
|
|
3759
|
-
if (result2) {
|
|
3760
|
-
return result2;
|
|
3761
|
-
}
|
|
3762
|
-
result2 = await api.callNormalHook(environment, "load", id);
|
|
3763
|
-
if (result2) {
|
|
3764
|
-
return result2;
|
|
3765
|
-
}
|
|
3766
|
-
return api.callPostHook(environment, "load", id);
|
|
3767
|
-
}
|
|
3768
|
-
chunkUSNT2KNT_cjs.__name(load, "load");
|
|
3769
|
-
async function transform(code, id) {
|
|
3770
|
-
const environment = await api.context.getEnvironment();
|
|
3771
|
-
let transformed = code;
|
|
3772
|
-
let result2 = await api.callPreHook(environment, "transform", chunk3OCI4TH7_cjs.getString(transformed), id);
|
|
3773
|
-
if (result2) {
|
|
3774
|
-
transformed = result2;
|
|
3775
|
-
}
|
|
3776
|
-
result2 = await api.callNormalHook(environment, "transform", chunk3OCI4TH7_cjs.getString(transformed), id);
|
|
3777
|
-
if (result2) {
|
|
3778
|
-
transformed = result2;
|
|
3779
|
-
}
|
|
3780
|
-
result2 = await api.callPostHook(environment, "transform", chunk3OCI4TH7_cjs.getString(transformed), id);
|
|
3781
|
-
if (result2) {
|
|
3782
|
-
transformed = result2;
|
|
3783
|
-
}
|
|
3784
|
-
return transformed;
|
|
3785
|
-
}
|
|
3786
|
-
chunkUSNT2KNT_cjs.__name(transform, "transform");
|
|
3787
|
-
async function writeBundle() {
|
|
3788
|
-
log(types.LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
|
|
3789
|
-
const environment = await api.context.getEnvironment();
|
|
3790
|
-
await api.callHook(environment, "writeBundle");
|
|
3791
|
-
}
|
|
3792
|
-
chunkUSNT2KNT_cjs.__name(writeBundle, "writeBundle");
|
|
3793
|
-
const result = {
|
|
3794
|
-
name: "powerlines",
|
|
3795
|
-
resolveId: {
|
|
3796
|
-
filter: {
|
|
3797
|
-
id: {
|
|
3798
|
-
include: [
|
|
3799
|
-
/.*/
|
|
3800
|
-
]
|
|
3801
|
-
}
|
|
3802
|
-
},
|
|
3803
|
-
handler: resolveId
|
|
3804
|
-
},
|
|
3805
|
-
load: {
|
|
3806
|
-
filter: {
|
|
3807
|
-
id: {
|
|
3808
|
-
include: [
|
|
3809
|
-
/.*/,
|
|
3810
|
-
/^storm:/
|
|
3811
|
-
]
|
|
3812
|
-
}
|
|
3813
|
-
},
|
|
3814
|
-
handler: load
|
|
3815
|
-
},
|
|
3816
|
-
transform,
|
|
3817
|
-
buildStart,
|
|
3818
|
-
writeBundle
|
|
3819
|
-
};
|
|
3820
|
-
return decorate ? decorate(api, result) : result;
|
|
3821
|
-
} catch (error) {
|
|
3822
|
-
log(types.LogLevelLabel.FATAL, error?.message);
|
|
3823
|
-
throw error;
|
|
3824
|
-
}
|
|
3825
|
-
};
|
|
3826
|
-
}
|
|
3827
|
-
chunkUSNT2KNT_cjs.__name(createUnpluginFactory, "createUnpluginFactory");
|
|
3828
|
-
|
|
2532
|
+
exports.PowerlinesContext = PowerlinesContext;
|
|
3829
2533
|
exports.VirtualFileSystem = VirtualFileSystem;
|
|
3830
|
-
exports.
|
|
2534
|
+
exports.__VFS_PATCH__ = __VFS_PATCH__;
|
|
2535
|
+
exports.__VFS_REVERT__ = __VFS_REVERT__;
|
|
2536
|
+
exports.addPluginHook = addPluginHook;
|
|
2537
|
+
exports.checkDedupe = checkDedupe;
|
|
2538
|
+
exports.getHookHandler = getHookHandler;
|
|
2539
|
+
exports.isHookExternal = isHookExternal;
|
|
2540
|
+
exports.isPlugin = isPlugin;
|
|
2541
|
+
exports.isPluginConfig = isPluginConfig;
|
|
2542
|
+
exports.isPluginConfigObject = isPluginConfigObject;
|
|
2543
|
+
exports.isPluginConfigTuple = isPluginConfigTuple;
|
|
2544
|
+
exports.isPluginHook = isPluginHook;
|