powerlines 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/dist/astro.cjs +8 -8
  2. package/dist/astro.d.cts +1 -1
  3. package/dist/astro.d.ts +1 -1
  4. package/dist/astro.js +5 -5
  5. package/dist/{chunk-5XYGZ3DC.cjs → chunk-22K72CJ5.cjs} +2 -2
  6. package/dist/{chunk-GPPJ2CRE.js → chunk-4HGQJ4KR.js} +2 -2
  7. package/dist/chunk-7MTW3KR2.cjs +12 -0
  8. package/dist/{chunk-VIRKTIPK.js → chunk-7UIYU6SC.js} +3 -3
  9. package/dist/chunk-7WMWRX2S.cjs +12 -0
  10. package/dist/{chunk-HVT7PBFF.js → chunk-A3BBPLTY.js} +3 -3
  11. package/dist/{chunk-S746E63M.js → chunk-BHP6KBGK.js} +3 -3
  12. package/dist/{chunk-ZU4IRZSQ.js → chunk-BOIEJ5I6.js} +3 -3
  13. package/dist/chunk-DELRP3WY.js +31 -0
  14. package/dist/{chunk-ZBDP43LG.cjs → chunk-ELHJY5WG.cjs} +4 -4
  15. package/dist/{chunk-UHCRNFFC.cjs → chunk-FANQC345.cjs} +4 -4
  16. package/dist/chunk-GV3S7ZR3.cjs +34 -0
  17. package/dist/{chunk-WCPY7HPU.js → chunk-L3DAMAEC.js} +4 -4
  18. package/dist/chunk-LC6FLEJS.cjs +12 -0
  19. package/dist/{chunk-N7NE3VOU.js → chunk-MAEKW52U.js} +3 -3
  20. package/dist/chunk-MXJWCZDP.cjs +12 -0
  21. package/dist/{chunk-EGSEJQCE.js → chunk-NGKWITCO.js} +3 -3
  22. package/dist/{chunk-L2SAK2JC.cjs → chunk-OC7CCD5M.cjs} +4 -4
  23. package/dist/{chunk-OYIM2M74.js → chunk-P4BOYWXT.js} +195 -6
  24. package/dist/{chunk-UTVZVGM3.cjs → chunk-PJRHRDLS.cjs} +204 -15
  25. package/dist/{chunk-5Y4JYQ66.js → chunk-RBRFT2R6.js} +3 -3
  26. package/dist/{chunk-66GXB2UY.cjs → chunk-RU6BHTIP.cjs} +4 -4
  27. package/dist/{chunk-WPVIF35O.js → chunk-SIZKRND7.js} +2 -2
  28. package/dist/chunk-SNARILEC.cjs +24 -0
  29. package/dist/{chunk-6UDHGAAI.js → chunk-SY7N6FC3.js} +3 -3
  30. package/dist/{chunk-QHGPZK2H.cjs → chunk-V5D5NVV7.cjs} +4 -4
  31. package/dist/{chunk-SDEBJQDT.js → chunk-V7LXFIGK.js} +3 -3
  32. package/dist/{chunk-2RHPFVYT.cjs → chunk-WCTOTE3T.cjs} +8 -8
  33. package/dist/chunk-WD4363UW.cjs +12 -0
  34. package/dist/{chunk-7IWH37DY.cjs → chunk-YIWHO6SW.cjs} +2 -2
  35. package/dist/{chunk-3Y5CCIJR.js → chunk-ZP5QLZQ2.js} +3 -3
  36. package/dist/{chunk-KYGEWAEG.js → chunk-ZQ7U35QZ.js} +3 -3
  37. package/dist/define-config.d.cts +1 -1
  38. package/dist/define-config.d.ts +1 -1
  39. package/dist/esbuild.cjs +7 -7
  40. package/dist/esbuild.d.cts +1 -1
  41. package/dist/esbuild.d.ts +1 -1
  42. package/dist/esbuild.js +4 -4
  43. package/dist/extend-plugin.d.cts +1 -1
  44. package/dist/extend-plugin.d.ts +1 -1
  45. package/dist/farm.cjs +4 -4
  46. package/dist/farm.d.cts +1 -1
  47. package/dist/farm.d.ts +1 -1
  48. package/dist/farm.js +3 -3
  49. package/dist/{hooks-gk8S8LFP.d.cts → hooks-H3i0YxVa.d.cts} +1 -1
  50. package/dist/{hooks-BGYnc61f.d.ts → hooks-QG1Q6zBM.d.ts} +1 -1
  51. package/dist/index.cjs +26 -26
  52. package/dist/index.d.cts +2 -2
  53. package/dist/index.d.ts +2 -2
  54. package/dist/index.js +17 -17
  55. package/dist/internal/api.cjs +3 -3
  56. package/dist/internal/api.d.cts +2 -2
  57. package/dist/internal/api.d.ts +2 -2
  58. package/dist/internal/api.js +2 -2
  59. package/dist/lib/build/esbuild.d.cts +12 -12
  60. package/dist/lib/build/esbuild.d.ts +12 -12
  61. package/dist/lib/build/index.cjs +18 -18
  62. package/dist/lib/build/index.d.cts +13 -13
  63. package/dist/lib/build/index.d.ts +13 -13
  64. package/dist/lib/build/index.js +3 -3
  65. package/dist/lib/build/rolldown.d.cts +12 -12
  66. package/dist/lib/build/rolldown.d.ts +12 -12
  67. package/dist/lib/build/rollup.d.cts +12 -12
  68. package/dist/lib/build/rollup.d.ts +12 -12
  69. package/dist/lib/build/rspack.d.cts +12 -12
  70. package/dist/lib/build/rspack.d.ts +12 -12
  71. package/dist/lib/build/tsup.d.cts +11 -11
  72. package/dist/lib/build/tsup.d.ts +11 -11
  73. package/dist/lib/build/unbuild.cjs +5 -5
  74. package/dist/lib/build/unbuild.d.cts +13 -13
  75. package/dist/lib/build/unbuild.d.ts +13 -13
  76. package/dist/lib/build/unbuild.js +2 -2
  77. package/dist/lib/build/vite.d.cts +12 -12
  78. package/dist/lib/build/vite.d.ts +12 -12
  79. package/dist/lib/build/webpack.d.cts +12 -12
  80. package/dist/lib/build/webpack.d.ts +12 -12
  81. package/dist/lib/bundle.cjs +16 -0
  82. package/dist/lib/bundle.cjs.map +1 -0
  83. package/dist/lib/bundle.d.cts +44 -0
  84. package/dist/lib/bundle.d.ts +44 -0
  85. package/dist/lib/bundle.js +7 -0
  86. package/dist/lib/bundle.js.map +1 -0
  87. package/dist/lib/chunk-2625RJNJ.cjs +41 -0
  88. package/dist/lib/chunk-2625RJNJ.cjs.map +1 -0
  89. package/dist/lib/{chunk-PIFE7MUZ.js → chunk-6BRTJXZ2.js} +195 -6
  90. package/dist/lib/chunk-6BRTJXZ2.js.map +1 -0
  91. package/dist/lib/chunk-6IJTWIVJ.cjs +107 -0
  92. package/dist/lib/chunk-6IJTWIVJ.cjs.map +1 -0
  93. package/dist/lib/{chunk-YVDJCVE5.cjs → chunk-BAC4AJEP.cjs} +3 -3
  94. package/dist/lib/{chunk-YVDJCVE5.cjs.map → chunk-BAC4AJEP.cjs.map} +1 -1
  95. package/dist/lib/{chunk-Q2RUDKWY.cjs → chunk-BW3VFCTS.cjs} +2 -2
  96. package/dist/lib/chunk-BW3VFCTS.cjs.map +1 -0
  97. package/dist/lib/chunk-ESYYL5UH.js +105 -0
  98. package/dist/lib/chunk-ESYYL5UH.js.map +1 -0
  99. package/dist/lib/chunk-GTQZYDA7.js +39 -0
  100. package/dist/lib/chunk-GTQZYDA7.js.map +1 -0
  101. package/dist/lib/{chunk-M7U5RMK7.js → chunk-KOCDKJDJ.js} +2 -2
  102. package/dist/lib/chunk-KOCDKJDJ.js.map +1 -0
  103. package/dist/lib/{chunk-M7WHFUKR.cjs → chunk-LYD5OTBI.cjs} +210 -21
  104. package/dist/lib/chunk-LYD5OTBI.cjs.map +1 -0
  105. package/dist/lib/{chunk-6U2UX2PX.cjs → chunk-RLMEYZ5I.cjs} +11 -15
  106. package/dist/lib/chunk-RLMEYZ5I.cjs.map +1 -0
  107. package/dist/lib/{chunk-CAPN4FSS.js → chunk-S4TGQD45.js} +3 -3
  108. package/dist/lib/{chunk-CAPN4FSS.js.map → chunk-S4TGQD45.js.map} +1 -1
  109. package/dist/lib/{chunk-KFE2IR3Y.js → chunk-V2T4H24I.js} +11 -15
  110. package/dist/lib/chunk-V2T4H24I.js.map +1 -0
  111. package/dist/lib/config-file.d.cts +11 -11
  112. package/dist/lib/config-file.d.ts +11 -11
  113. package/dist/lib/{config-AuIGsUck.d.cts → context-B481RQbf.d.cts} +615 -559
  114. package/dist/lib/{config-B_WTwd49.d.ts → context-efHKG-wc.d.ts} +615 -559
  115. package/dist/lib/create-program.cjs +13 -0
  116. package/dist/lib/create-program.cjs.map +1 -0
  117. package/dist/lib/create-program.d.cts +42 -0
  118. package/dist/lib/create-program.d.ts +42 -0
  119. package/dist/lib/create-program.js +4 -0
  120. package/dist/lib/create-program.js.map +1 -0
  121. package/dist/lib/entry.d.cts +12 -12
  122. package/dist/lib/entry.d.ts +12 -12
  123. package/dist/lib/{hooks-DErK4Fv4.d.ts → hooks-CdvPHbFZ.d.cts} +1 -1
  124. package/dist/lib/{hooks-4KkL9GD2.d.cts → hooks-JhMVguVh.d.ts} +1 -1
  125. package/dist/lib/index.cjs +47 -36
  126. package/dist/lib/index.d.cts +16 -13
  127. package/dist/lib/index.d.ts +16 -13
  128. package/dist/lib/index.js +10 -7
  129. package/dist/lib/logger.d.cts +12 -12
  130. package/dist/lib/logger.d.ts +12 -12
  131. package/dist/lib/typescript/compiler-host.cjs +46 -2
  132. package/dist/lib/typescript/compiler-host.cjs.map +1 -1
  133. package/dist/lib/typescript/compiler-host.d.cts +18 -13
  134. package/dist/lib/typescript/compiler-host.d.ts +18 -13
  135. package/dist/lib/typescript/compiler-host.js +45 -2
  136. package/dist/lib/typescript/compiler-host.js.map +1 -1
  137. package/dist/lib/typescript/import-transformer.d.cts +12 -12
  138. package/dist/lib/typescript/import-transformer.d.ts +12 -12
  139. package/dist/lib/typescript/index.cjs +6 -6
  140. package/dist/lib/typescript/index.d.cts +12 -12
  141. package/dist/lib/typescript/index.d.ts +12 -12
  142. package/dist/lib/typescript/index.js +1 -1
  143. package/dist/lib/typescript/program.cjs +6 -6
  144. package/dist/lib/typescript/program.d.cts +13 -13
  145. package/dist/lib/typescript/program.d.ts +13 -13
  146. package/dist/lib/typescript/program.js +1 -1
  147. package/dist/lib/unplugin/factory.cjs +3 -3
  148. package/dist/lib/unplugin/factory.d.cts +12 -12
  149. package/dist/lib/unplugin/factory.d.ts +12 -12
  150. package/dist/lib/unplugin/factory.js +2 -2
  151. package/dist/lib/unplugin/index.cjs +3 -3
  152. package/dist/lib/unplugin/index.d.cts +12 -12
  153. package/dist/lib/unplugin/index.d.ts +12 -12
  154. package/dist/lib/unplugin/index.js +2 -2
  155. package/dist/lib/unplugin/plugin.d.cts +11 -11
  156. package/dist/lib/unplugin/plugin.d.ts +11 -11
  157. package/dist/lib/unplugin/resolve-id.d.cts +11 -11
  158. package/dist/lib/unplugin/resolve-id.d.ts +11 -11
  159. package/dist/lib/utilities/file-header.d.cts +12 -12
  160. package/dist/lib/utilities/file-header.d.ts +12 -12
  161. package/dist/lib/utilities/index.cjs +20 -20
  162. package/dist/lib/utilities/index.d.cts +12 -12
  163. package/dist/lib/utilities/index.d.ts +12 -12
  164. package/dist/lib/utilities/index.js +3 -3
  165. package/dist/lib/utilities/meta.cjs +8 -8
  166. package/dist/lib/utilities/meta.d.cts +12 -12
  167. package/dist/lib/utilities/meta.d.ts +12 -12
  168. package/dist/lib/utilities/meta.js +1 -1
  169. package/dist/lib/utilities/plugin-helpers.d.cts +11 -11
  170. package/dist/lib/utilities/plugin-helpers.d.ts +11 -11
  171. package/dist/lib/utilities/resolve-path.d.cts +12 -12
  172. package/dist/lib/utilities/resolve-path.d.ts +12 -12
  173. package/dist/lib/utilities/worker.d.cts +11 -11
  174. package/dist/lib/utilities/worker.d.ts +11 -11
  175. package/dist/lib/utilities/write-file.d.cts +12 -12
  176. package/dist/lib/utilities/write-file.d.ts +12 -12
  177. package/dist/next.cjs +8 -8
  178. package/dist/next.js +5 -5
  179. package/dist/nuxt.cjs +9 -9
  180. package/dist/nuxt.js +6 -6
  181. package/dist/rolldown.cjs +7 -7
  182. package/dist/rolldown.d.cts +1 -1
  183. package/dist/rolldown.d.ts +1 -1
  184. package/dist/rolldown.js +4 -4
  185. package/dist/rollup.cjs +7 -7
  186. package/dist/rollup.d.cts +1 -1
  187. package/dist/rollup.d.ts +1 -1
  188. package/dist/rollup.js +4 -4
  189. package/dist/rspack.cjs +7 -7
  190. package/dist/rspack.d.cts +1 -1
  191. package/dist/rspack.d.ts +1 -1
  192. package/dist/rspack.js +4 -4
  193. package/dist/tsup.cjs +8 -8
  194. package/dist/tsup.js +5 -5
  195. package/dist/types/babel.d.cts +1 -1
  196. package/dist/types/babel.d.ts +1 -1
  197. package/dist/types/commands.d.cts +1 -1
  198. package/dist/types/commands.d.ts +1 -1
  199. package/dist/types/compiler.d.cts +1 -1
  200. package/dist/types/compiler.d.ts +1 -1
  201. package/dist/types/config.d.cts +1 -1
  202. package/dist/types/config.d.ts +1 -1
  203. package/dist/types/context.cjs +2 -2
  204. package/dist/types/context.d.cts +1 -1
  205. package/dist/types/context.d.ts +1 -1
  206. package/dist/types/context.js +1 -1
  207. package/dist/types/hooks.d.cts +1 -1
  208. package/dist/types/hooks.d.ts +1 -1
  209. package/dist/types/index.cjs +9 -9
  210. package/dist/types/index.d.cts +1 -1
  211. package/dist/types/index.d.ts +1 -1
  212. package/dist/types/index.js +2 -2
  213. package/dist/types/internal.d.cts +2 -2
  214. package/dist/types/internal.d.ts +2 -2
  215. package/dist/types/plugin.d.cts +1 -1
  216. package/dist/types/plugin.d.ts +1 -1
  217. package/dist/types/resolved.d.cts +1 -1
  218. package/dist/types/resolved.d.ts +1 -1
  219. package/dist/types/unplugin.d.cts +1 -1
  220. package/dist/types/unplugin.d.ts +1 -1
  221. package/dist/types/vfs.cjs +7 -7
  222. package/dist/types/vfs.d.cts +61 -5
  223. package/dist/types/vfs.d.ts +61 -5
  224. package/dist/types/vfs.js +1 -1
  225. package/dist/unloader.cjs +7 -7
  226. package/dist/unloader.d.cts +1 -1
  227. package/dist/unloader.d.ts +1 -1
  228. package/dist/unloader.js +4 -4
  229. package/dist/unplugin.cjs +18 -18
  230. package/dist/unplugin.d.cts +2 -2
  231. package/dist/unplugin.d.ts +2 -2
  232. package/dist/unplugin.js +15 -15
  233. package/dist/vite.cjs +7 -7
  234. package/dist/vite.d.cts +1 -1
  235. package/dist/vite.d.ts +1 -1
  236. package/dist/vite.js +4 -4
  237. package/dist/webpack.cjs +7 -7
  238. package/dist/webpack.d.cts +1 -1
  239. package/dist/webpack.d.ts +1 -1
  240. package/dist/webpack.js +4 -4
  241. package/package.json +9 -7
  242. package/dist/chunk-IJBH5OUN.cjs +0 -12
  243. package/dist/chunk-JBTSAOIQ.js +0 -31
  244. package/dist/chunk-LXMNDUPG.cjs +0 -12
  245. package/dist/chunk-RQ4CHMPO.cjs +0 -12
  246. package/dist/chunk-S5QFX2GM.cjs +0 -12
  247. package/dist/chunk-SL3CXJWD.cjs +0 -34
  248. package/dist/chunk-YG7U2GIR.cjs +0 -24
  249. package/dist/chunk-ZFATNDSY.cjs +0 -12
  250. package/dist/lib/chunk-6U2UX2PX.cjs.map +0 -1
  251. package/dist/lib/chunk-KFE2IR3Y.js.map +0 -1
  252. package/dist/lib/chunk-M7U5RMK7.js.map +0 -1
  253. package/dist/lib/chunk-M7WHFUKR.cjs.map +0 -1
  254. package/dist/lib/chunk-PIFE7MUZ.js.map +0 -1
  255. package/dist/lib/chunk-Q2RUDKWY.cjs.map +0 -1
  256. package/dist/{resolved-CcuVqMqc.d.cts → resolved-3RFshyDy.d.cts} +16 -16
  257. package/dist/{resolved-Dhscmo3z.d.ts → resolved-BzyBMgQG.d.ts} +16 -16
@@ -1,11 +1,15 @@
1
- import { Format } from '@storm-software/build-tools/types';
1
+ import { EnvPaths } from '@stryke/env/get-env-paths';
2
+ import { PackageJson } from '@stryke/types/package-json';
3
+ import { Worker } from 'jest-worker';
4
+ import { Jiti } from 'jiti';
5
+ import { ParserOptions, ParseResult } from 'oxc-parser';
6
+ import { Range } from 'semver';
7
+ import { TransformResult, ExternalIdResult, HookFilter, UnpluginOptions, UnpluginContext, UnpluginBuildContext } from 'unplugin';
2
8
  import { LogLevelLabel } from '@storm-software/config-tools/types';
3
- import { StormWorkspaceConfig } from '@storm-software/config/types';
4
- import { NonUndefined, MaybePromise, FunctionLike } from '@stryke/types/base';
5
- import { TypeDefinition, TypeDefinitionParameter } from '@stryke/types/configuration';
9
+ import { MaybePromise, FunctionLike, NonUndefined } from '@stryke/types/base';
10
+ import { TypeDefinitionParameter, TypeDefinition } from '@stryke/types/configuration';
6
11
  import { AssetGlob } from '@stryke/types/file';
7
- import { ResolvedConfig as ResolvedConfig$1, ConfigLayer } from 'c12';
8
- import { UserConfig as UserConfig$1, ResolvedPreviewOptions, PreviewOptions } from 'vite';
12
+ import { UserConfig as UserConfig$1, PreviewOptions, ResolvedPreviewOptions } from 'vite';
9
13
  import { UserConfig as UserConfig$2 } from '@farmfe/core';
10
14
  import { Configuration as Configuration$1 } from '@rspack/core';
11
15
  import { ESBuildOptions } from '@storm-software/esbuild/types';
@@ -14,18 +18,14 @@ import { BuildOptions } from 'esbuild';
14
18
  import { RolldownOptions, RolldownOutput } from 'rolldown';
15
19
  import { RollupOptions, OutputOptions } from 'rollup';
16
20
  import { Configuration } from 'webpack';
17
- import { EnvPaths } from '@stryke/env/get-env-paths';
18
- import { PackageJson } from '@stryke/types/package-json';
19
- import { Worker } from 'jest-worker';
20
- import { Jiti } from 'jiti';
21
- import { ParserOptions, ParseResult } from 'oxc-parser';
22
- import { Range } from 'semver';
23
- import { TransformResult, ExternalIdResult, HookFilter, UnpluginOptions, UnpluginContext, UnpluginBuildContext } from 'unplugin';
21
+ import { Format } from '@storm-software/build-tools/types';
22
+ import { StormWorkspaceConfig } from '@storm-software/config/types';
23
+ import { ResolvedConfig as ResolvedConfig$1, ConfigLayer } from 'c12';
24
+ import { T as TSConfig, P as ParsedTypeScriptConfig } from './tsconfig-Bz-CiFqD.cjs';
24
25
  import { ArrayValues } from '@stryke/types/array';
25
- import { P as ParsedTypeScriptConfig, T as TSConfig } from './tsconfig-Bz-CiFqD.cjs';
26
26
  import { PrimitiveJsonValue } from '@stryke/json/types';
27
27
  import { Volume } from 'memfs';
28
- import { StatSyncOptions, Stats, PathLike, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, PathOrFileDescriptor, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
28
+ import { PathLike, StatSyncOptions, Stats, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, PathOrFileDescriptor, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
29
29
  import { IUnionFs } from 'unionfs';
30
30
 
31
31
  type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
@@ -103,82 +103,6 @@ type UnbuildResolvedBuildConfig = UnbuildOptions & BuildResolvedConfig;
103
103
  type FarmBuildConfig = Partial<Omit<UserConfig$2, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">> & BuildConfig;
104
104
  type FarmResolvedBuildConfig = UserConfig$2 & BuildResolvedConfig;
105
105
 
106
- interface ResolvedEntryTypeDefinition extends TypeDefinition {
107
- /**
108
- * The user provided entry point in the source code
109
- */
110
- input: TypeDefinition;
111
- /**
112
- * An optional name to use in the package export during the build process
113
- */
114
- output?: string;
115
- }
116
- type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview" | "mainFields" | "extensions"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr" | "mainFields" | "extensions">> & {
117
- /**
118
- * The name of the environment
119
- */
120
- name: string;
121
- /**
122
- * Configuration options for the preview server
123
- */
124
- preview?: ResolvedPreviewOptions;
125
- };
126
- type ResolvedAssetGlob = AssetGlob & Required<Pick<AssetGlob, "input">>;
127
- type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
128
- assets: ResolvedAssetGlob[];
129
- }>;
130
- /**
131
- * The resolved options for the Powerlines project configuration.
132
- */
133
- type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "build" | "transform" | "override" | "root" | "variant" | "type" | "output" | "logLevel" | "framework"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "build" | "transform" | "override" | "framework">> & {
134
- /**
135
- * The configuration options that were provided inline to the Powerlines CLI.
136
- */
137
- inlineConfig: InlineConfig<TUserConfig>;
138
- /**
139
- * The original configuration options that were provided by the user to the Powerlines process.
140
- */
141
- userConfig: TUserConfig;
142
- /**
143
- * A string identifier for the Powerlines command being executed.
144
- */
145
- command: NonUndefined<InlineConfig<TUserConfig>["command"]>;
146
- /**
147
- * The root directory of the project's source code
148
- *
149
- * @defaultValue "\{projectRoot\}/src"
150
- */
151
- sourceRoot: NonUndefined<TUserConfig["sourceRoot"]>;
152
- /**
153
- * The root directory of the project.
154
- */
155
- projectRoot: NonUndefined<TUserConfig["root"]>;
156
- /**
157
- * The type of project being built.
158
- */
159
- projectType: NonUndefined<TUserConfig["type"]>;
160
- /**
161
- * The output configuration options to use for the build process
162
- */
163
- output: OutputResolvedConfig;
164
- /**
165
- * The log level to use for the Powerlines processes.
166
- *
167
- * @defaultValue "info"
168
- */
169
- logLevel: LogLevelLabel | null;
170
- };
171
- type ViteResolvedConfig = ResolvedConfig<ViteUserConfig>;
172
- type WebpackResolvedConfig = ResolvedConfig<WebpackUserConfig>;
173
- type RspackResolvedConfig = ResolvedConfig<RspackUserConfig>;
174
- type ESBuildResolvedConfig = ResolvedConfig<ESBuildUserConfig>;
175
- type RollupResolvedConfig = ResolvedConfig<RollupUserConfig>;
176
- type RolldownResolvedConfig = ResolvedConfig<RolldownUserConfig>;
177
- type TsupResolvedConfig = ResolvedConfig<TsupUserConfig>;
178
- type UnbuildResolvedConfig = ResolvedConfig<UnbuildUserConfig>;
179
- type FarmResolvedConfig = ResolvedConfig<FarmUserConfig>;
180
- type InferResolvedConfig<TBuildVariant extends BuildVariant | undefined> = TBuildVariant extends undefined ? ResolvedConfig : TBuildVariant extends "webpack" ? WebpackResolvedConfig : TBuildVariant extends "rspack" ? RspackResolvedConfig : TBuildVariant extends "vite" ? ViteResolvedConfig : TBuildVariant extends "esbuild" ? ESBuildResolvedConfig : TBuildVariant extends "unbuild" ? UnbuildResolvedConfig : TBuildVariant extends "tsup" ? TsupResolvedConfig : TBuildVariant extends "rolldown" ? RolldownResolvedConfig : TBuildVariant extends "rollup" ? RollupResolvedConfig : TBuildVariant extends "farm" ? FarmResolvedConfig : ResolvedConfig;
181
-
182
106
  declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "release", "finalize"];
183
107
  type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
184
108
 
@@ -391,35 +315,6 @@ interface Plugin<in out TContext extends PluginContext<ResolvedConfig> = PluginC
391
315
  applyToEnvironment?: (environment: EnvironmentResolvedConfig) => MaybePromise<boolean | Plugin<any>>;
392
316
  }
393
317
 
394
- type BaseHooks<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext>;
395
- type BaseHookKeys<TContext extends PluginContext = PluginContext> = keyof BaseHooks<TContext>;
396
- type ExternalHooks<TContext extends PluginContext = PluginContext> = ExternalPluginHookFunctions<TContext>;
397
- type ExternalHookKeys<TContext extends PluginContext = PluginContext> = keyof ExternalHooks<TContext>;
398
- type Hooks<TContext extends PluginContext = PluginContext> = PluginHookFunctions<TContext>;
399
- type HookKeys<TContext extends PluginContext = PluginContext> = keyof Hooks<TContext>;
400
- interface BaseHooksListItem<TContext extends PluginContext = PluginContext, TKey extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> extends PluginHookObject<BaseHooks<TContext>[TKey]> {
401
- plugin: Plugin<TContext>;
402
- }
403
- interface BaseHooksList<TContext extends PluginContext = PluginContext, TKey extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> {
404
- preOrdered?: BaseHooksListItem<TContext, TKey>[];
405
- preEnforced?: BaseHooksListItem<TContext, TKey>[];
406
- normal?: BaseHooksListItem<TContext, TKey>[];
407
- postEnforced?: BaseHooksListItem<TContext, TKey>[];
408
- postOrdered?: BaseHooksListItem<TContext, TKey>[];
409
- }
410
- interface ExternalHooksListItem<TContext extends PluginContext = PluginContext, TKey extends ExternalHookKeys<TContext> = ExternalHookKeys<TContext>> {
411
- plugin: Plugin<TContext>;
412
- handler: ExternalHooks<TContext>[TKey];
413
- }
414
- type HooksList<TContext extends PluginContext = PluginContext> = {
415
- [TKey in BaseHookKeys<TContext>]?: BaseHooksList<TContext, TKey>;
416
- } & {
417
- [TKey in ExternalHookKeys<TContext>]?: ExternalHooksListItem<TContext, TKey>[];
418
- };
419
- type InferHookHandler<TContext extends PluginContext, TKey extends HookKeys<TContext>> = Hooks<TContext>[TKey];
420
- type InferHookReturnType<TContext extends PluginContext, TKey extends HookKeys<TContext>> = ReturnType<InferHookHandler<TContext, TKey>> extends Promise<infer U> ? U extends Promise<infer V> ? V : U : ReturnType<InferHookHandler<TContext, TKey>>;
421
- type InferHookParameters<TContext extends PluginContext, TKey extends HookKeys<TContext>> = Parameters<InferHookHandler<TContext, TKey>>;
422
-
423
318
  declare const __VFS_INIT__ = "__VFS_INIT__";
424
319
  declare const __VFS_REVERT__ = "__VFS_REVERT__";
425
320
  declare const __VFS_CACHE__ = "__VFS_CACHE__";
@@ -549,6 +444,13 @@ interface VirtualFileSystemInterface {
549
444
  * @returns `true` if the file exists, otherwise `false`.
550
445
  */
551
446
  existsSync: (pathOrId: string) => boolean;
447
+ /**
448
+ * Gets the metadata of a file in the virtual file system (VFS).
449
+ *
450
+ * @param pathOrId - The path or id of the file.
451
+ * @returns The metadata of the file if it exists, otherwise undefined.
452
+ */
453
+ getMetadata: (pathOrId: PathLike) => VirtualFileSystemMetadata | undefined;
552
454
  /**
553
455
  * Gets the stats of a file in the virtual file system (VFS).
554
456
  *
@@ -645,13 +547,20 @@ interface VirtualFileSystemInterface {
645
547
  */
646
548
  rmdir: (path: PathLike, options?: RmDirOptions & ResolveFSOptions) => Promise<void>;
647
549
  /**
648
- * Removes a file in the virtual file system (VFS).
550
+ * Removes a file or directory in the virtual file system (VFS).
649
551
  *
650
- * @param path - The path to the file to remove.
651
- * @param options - Options for removing the file.
652
- * @returns A promise that resolves when the file is removed.
552
+ * @param path - The path to the file or directory to remove.
553
+ * @param options - Options for removing the file or directory.
554
+ * @returns A promise that resolves when the file or directory is removed.
653
555
  */
654
556
  rm: (path: PathLike, options?: RmOptions & ResolveFSOptions) => Promise<void>;
557
+ /**
558
+ * Synchronously removes a file or directory in the virtual file system (VFS).
559
+ *
560
+ * @param path - The path to the file or directory to remove.
561
+ * @param options - Options for removing the file or directory.
562
+ */
563
+ rmSync: (path: PathLike, options?: RmOptions & ResolveFSOptions) => void;
655
564
  /**
656
565
  * Creates a directory in the virtual file system (VFS).
657
566
  *
@@ -698,6 +607,48 @@ interface VirtualFileSystemInterface {
698
607
  * @param options - Optional parameters for writing the file.
699
608
  */
700
609
  writeFileSync: (path: PathOrFileDescriptor, data?: WriteFileData, options?: WriteFileOptions) => void;
610
+ /**
611
+ * Moves a file from one path to another in the virtual file system (VFS).
612
+ *
613
+ * @param srcPath - The source path to move
614
+ * @param destPath - The destination path to move to
615
+ */
616
+ move: (srcPath: string, destPath: string) => Promise<void>;
617
+ /**
618
+ * Synchronously moves a file from one path to another in the virtual file system (VFS).
619
+ *
620
+ * @param srcPath - The source path to move
621
+ * @param destPath - The destination path to move to
622
+ */
623
+ moveSync: (srcPath: string, destPath: string) => void;
624
+ /**
625
+ * Copies a file from one path to another in the virtual file system (VFS).
626
+ *
627
+ * @param srcPath - The source path to copy
628
+ * @param destPath - The destination path to copy to
629
+ */
630
+ copy: (srcPath: string, destPath: string) => Promise<void>;
631
+ /**
632
+ * Synchronously copies a file from one path to another in the virtual file system (VFS).
633
+ *
634
+ * @param srcPath - The source path to copy
635
+ * @param destPath - The destination path to copy to
636
+ */
637
+ copySync: (srcPath: string, destPath: string) => void;
638
+ /**
639
+ * Glob files in the virtual file system (VFS) based on the provided pattern(s).
640
+ *
641
+ * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
642
+ * @returns An array of file paths matching the provided pattern(s)
643
+ */
644
+ glob: (pattern: string | string[]) => Promise<string[]>;
645
+ /**
646
+ * Synchronously glob files in the virtual file system (VFS) based on the provided pattern(s).
647
+ *
648
+ * @param pattern - A pattern (or multiple patterns) to use to determine the file paths to return
649
+ * @returns An array of file paths matching the provided pattern(s)
650
+ */
651
+ globSync: (pattern: string | string[]) => string[];
701
652
  /**
702
653
  * Resolves a path or id to a file path in the virtual file system.
703
654
  *
@@ -751,664 +702,769 @@ interface VirtualFileSystemInterface {
751
702
  [__VFS_UNIFIED__]: IUnionFs;
752
703
  }
753
704
 
754
- type WorkerProcess<TExposedMethods extends ReadonlyArray<string>> = {
755
- [K in TExposedMethods[number]]: (data: any) => Promise<any>;
756
- } & {
757
- close: () => void;
758
- end: () => ReturnType<Worker["end"]>;
705
+ type LogFn = (type: LogLevelLabel, ...args: string[]) => void;
706
+ /**
707
+ * The {@link StormWorkspaceConfig | configuration} object for an entire Powerlines workspace
708
+ */
709
+ type WorkspaceConfig = Partial<StormWorkspaceConfig> & Required<Pick<StormWorkspaceConfig, "workspaceRoot">>;
710
+ type PluginFactory<in out TContext extends PluginContext = PluginContext, TOptions = any> = (options: TOptions) => MaybePromise<Plugin<TContext>>;
711
+ /**
712
+ * A configuration tuple for a Powerlines plugin.
713
+ */
714
+ type PluginConfigTuple<TContext extends PluginContext = PluginContext, TOptions = any> = [string | PluginFactory<TContext, TOptions>, TOptions] | [Plugin<TContext>];
715
+ /**
716
+ * A configuration object for a Powerlines plugin.
717
+ */
718
+ type PluginConfigObject<TContext extends PluginContext = PluginContext, TOptions = any> = {
719
+ plugin: string | PluginFactory<TContext, TOptions>;
720
+ options: TOptions;
721
+ } | {
722
+ plugin: Plugin<TContext>;
723
+ options?: never;
759
724
  };
760
- interface MetaInfo {
725
+ /**
726
+ * A configuration tuple for a Powerlines plugin.
727
+ */
728
+ type PluginConfig<TContext extends PluginContext = PluginContext> = string | PluginFactory<TContext, void> | Plugin<TContext> | Promise<Plugin<TContext>> | PluginConfigTuple<TContext> | PluginConfigObject<TContext>;
729
+ type ProjectType = "application" | "library";
730
+ interface OutputConfig {
761
731
  /**
762
- * The checksum generated from the resolved options
732
+ * The path to output the final compiled files to
733
+ *
734
+ * @remarks
735
+ * If a value is not provided, Powerlines will attempt to:
736
+ * 1. Use the `outDir` value in the `tsconfig.json` file.
737
+ * 2. Use the `dist` directory in the project root directory.
738
+ *
739
+ * @defaultValue "dist/\{projectRoot\}"
763
740
  */
764
- checksum: string;
741
+ outputPath?: string;
765
742
  /**
766
- * The build id
743
+ * The format of the output files
744
+ *
745
+ * @defaultValue "virtual"
767
746
  */
768
- buildId: string;
747
+ mode?: OutputModeType;
769
748
  /**
770
- * The release id
749
+ * The path of the generated runtime declaration file relative to the workspace root.
750
+ *
751
+ * @defaultValue "\{projectRoot\}/powerlines.d.ts"
771
752
  */
772
- releaseId: string;
753
+ dts?: string | false;
773
754
  /**
774
- * The build timestamp
755
+ * A prefix to use for identifying builtin modules
756
+ *
757
+ * @remarks
758
+ * This prefix will be used to identify all builtin modules generated during the "prepare" phase. An example builtin ID for a module called `"utils"` would be `"{builtinPrefix}:utils"`.
759
+ *
760
+ * @defaultValue "powerlines"
775
761
  */
776
- timestamp: number;
762
+ builtinPrefix?: string;
777
763
  /**
778
- * A hash that represents the path to the project root directory
764
+ * The folder where the generated runtime artifacts will be located
765
+ *
766
+ * @remarks
767
+ * This folder will contain all runtime artifacts and builtins generated during the "prepare" phase.
768
+ *
769
+ * @defaultValue "\{projectRoot\}/.powerlines"
779
770
  */
780
- projectRootHash: string;
771
+ artifactsFolder?: string;
781
772
  /**
782
- * A hash that represents the path to the project root directory
773
+ * The module format of the output files
774
+ *
775
+ * @remarks
776
+ * This option can be a single format or an array of formats. If an array is provided, multiple builds will be generated for each format.
777
+ *
778
+ * @defaultValue "esm"
783
779
  */
784
- configHash: string;
780
+ format?: Format | Format[];
785
781
  /**
786
- * A mapping of runtime ids to their corresponding file paths
782
+ * A list of assets to copy to the output directory
783
+ *
784
+ * @remarks
785
+ * The assets can be specified as a string (path to the asset) or as an object with a `glob` property (to match multiple files). The paths are relative to the project root directory.
787
786
  */
788
- builtinIdMap: Record<string, string>;
787
+ assets?: Array<string | AssetGlob>;
788
+ }
789
+ interface BaseConfig {
789
790
  /**
790
- * A mapping of virtual file paths to their corresponding file contents
791
+ * The name of the project
791
792
  */
792
- virtualFiles: Record<string, string | null>;
793
- }
794
- interface Resolver extends Jiti {
795
- plugin: Jiti;
796
- }
797
- interface SelectHooksOptions {
798
- order?: "pre" | "post" | "normal";
799
- }
800
- interface InitContextOptions {
793
+ name?: string;
801
794
  /**
802
- * If false, the plugin will be loaded after all other plugins.
795
+ * The project display title
803
796
  *
804
- * @defaultValue true
805
- */
806
- isHighPriority: boolean;
807
- }
808
- interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
809
- /**
810
- * The Storm workspace configuration
797
+ * @remarks
798
+ * This option is used in documentation generation and other places where a human-readable title is needed.
811
799
  */
812
- workspaceConfig: WorkspaceConfig;
800
+ title?: string;
813
801
  /**
814
- * An object containing the options provided to Powerlines
802
+ * A description of the project
803
+ *
804
+ * @remarks
805
+ * If this option is not provided, the build process will try to use the \`description\` value from the `\package.json\` file.
815
806
  */
816
- config: TResolvedConfig;
807
+ description?: string;
817
808
  /**
818
- * A logging function for the Powerlines engine
809
+ * The log level to use for the Powerlines processes.
810
+ *
811
+ * @defaultValue "info"
819
812
  */
820
- log: LogFn;
813
+ logLevel?: LogLevelLabel | null;
821
814
  /**
822
- * The metadata information
815
+ * A custom logger function to use for logging messages
823
816
  */
824
- meta: MetaInfo;
817
+ customLogger?: LogFn;
825
818
  /**
826
- * The metadata information currently written to disk
819
+ * Explicitly set a mode to run in. This mode will be used at various points throughout the Powerlines processes, such as when compiling the source code.
820
+ *
821
+ * @defaultValue "production"
827
822
  */
828
- persistedMeta?: MetaInfo;
823
+ mode?: "development" | "test" | "production";
829
824
  /**
830
- * The parsed TypeScript configuration from the `tsconfig.json` file
825
+ * The entry point(s) for the application
831
826
  */
832
- tsconfig: ParsedTypeScriptConfig;
827
+ entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
833
828
  /**
834
- * The entry points of the source code
829
+ * Configuration for linting the source code
835
830
  */
836
- entry: ResolvedEntryTypeDefinition[];
831
+ lint?: Record<string, any> | false;
837
832
  /**
838
- * The relative path to the Powerlines workspace root directory
833
+ * Configuration for the output of the build process
839
834
  */
840
- relativeToWorkspaceRoot: string;
835
+ output?: OutputConfig;
841
836
  /**
842
- * The Powerlines artifacts directory
837
+ * Configuration for the transformation of the source code
843
838
  */
844
- artifactsPath: string;
839
+ transform?: Record<string, any>;
845
840
  /**
846
- * The path to the Powerlines builtin runtime modules directory
841
+ * Options to to provide to the build process
847
842
  */
848
- builtinsPath: string;
843
+ build?: BuildConfig;
849
844
  /**
850
- * The path to the Powerlines entry modules directory
845
+ * Configuration for documentation generation
846
+ *
847
+ * @remarks
848
+ * This configuration will be used by the documentation generation plugins during the `docs` command.
851
849
  */
852
- entryPath: string;
850
+ docs?: Record<string, any>;
853
851
  /**
854
- * The path to the Powerlines TypeScript declaration files directory
852
+ * The path to the tsconfig file to be used by the compiler
853
+ *
854
+ * @remarks
855
+ * If a value is not provided, the plugin will attempt to find the `tsconfig.json` file in the project root directory. The parsed tsconfig compiler options will be merged with the {@link Options.tsconfigRaw} value (if provided).
856
+ *
857
+ * @defaultValue "\{projectRoot\}/tsconfig.json"
855
858
  */
856
- dtsPath: string;
859
+ tsconfig?: string;
857
860
  /**
858
- * The path to a directory where the reflection data buffers (used by the build processes) are stored
861
+ * The raw {@link TSConfig} object to be used by the compiler. This object will be merged with the `tsconfig.json` file.
862
+ *
863
+ * @see https://www.typescriptlang.org/tsconfig
864
+ *
865
+ * @remarks
866
+ * If populated, this option takes higher priority than `tsconfig`
859
867
  */
860
- dataPath: string;
868
+ tsconfigRaw?: TSConfig;
869
+ }
870
+ interface EnvironmentConfig extends BaseConfig {
861
871
  /**
862
- * The path to a directory where the project cache (used by the build processes) is stored
872
+ * Array of strings indicating the order in which fields in a package.json file should be resolved to determine the entry point for a module.
873
+ *
874
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
863
875
  */
864
- cachePath: string;
876
+ mainFields?: string[];
865
877
  /**
866
- * The Powerlines environment paths
878
+ * Array of strings indicating what conditions should be used for module resolution.
867
879
  */
868
- envPaths: EnvPaths;
880
+ conditions?: string[];
869
881
  /**
870
- * The file system path to the Powerlines package installation
882
+ * Array of strings indicating what conditions should be used for external modules.
871
883
  */
872
- powerlinesPath: string;
884
+ externalConditions?: string[];
873
885
  /**
874
- * The dependency installations required by the project
886
+ * Array of strings indicating what file extensions should be used for module resolution.
887
+ *
888
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
875
889
  */
876
- dependencies: Record<string, string | Range>;
890
+ extensions?: string[];
877
891
  /**
878
- * The development dependency installations required by the project
892
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
893
+ *
894
+ * @remarks
895
+ * This option is useful for ensuring that only one version of a module is included in the bundle, which can help reduce bundle size and avoid conflicts.
879
896
  */
880
- devDependencies: Record<string, string | Range>;
897
+ dedupe?: string[];
881
898
  /**
882
- * The project's `package.json` file content
899
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
883
900
  */
884
- packageJson: PackageJson & Record<string, any>;
901
+ builtins?: (string | RegExp)[];
885
902
  /**
886
- * The project's `project.json` file content
903
+ * Configuration options for the preview server
887
904
  */
888
- projectJson?: Record<string, any>;
905
+ preview?: PreviewOptions;
889
906
  /**
890
- * The virtual file system manager used during the build process to reference generated runtime files
907
+ * A flag indicating whether the build is for a Server-Side Rendering environment.
891
908
  */
892
- fs: VirtualFileSystemInterface;
909
+ ssr?: boolean;
893
910
  /**
894
- * The Jiti module resolver
911
+ * Define if this environment is used for Server-Side Rendering
912
+ *
913
+ * @defaultValue "server" (if it isn't the client environment)
895
914
  */
896
- resolver: Resolver;
915
+ consumer?: "client" | "server";
916
+ }
917
+ interface CommonUserConfig extends BaseConfig {
897
918
  /**
898
- * The builtin module id that exist in the Powerlines virtual file system
919
+ * The type of project being built
920
+ *
921
+ * @defaultValue "application"
899
922
  */
900
- builtins: string[];
923
+ type?: ProjectType;
901
924
  /**
902
- * The Powerlines builtin virtual files
925
+ * The root directory of the project
903
926
  */
904
- getBuiltins: () => Promise<VirtualFile[]>;
927
+ root: string;
905
928
  /**
906
- * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
929
+ * The root directory of the project's source code
907
930
  *
908
- * @param code - The source code of the builtin file
909
- * @param id - The unique identifier of the builtin file
910
- * @param path - An optional path to write the builtin file to
911
- * @param options - Options for writing the file
931
+ * @defaultValue "\{root\}/src"
912
932
  */
913
- writeBuiltin: (code: string, id: string, path?: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
933
+ sourceRoot?: string;
914
934
  /**
915
- * Resolves a entry virtual file and writes it to the VFS if it does not already exist
935
+ * A path to a custom configuration file to be used instead of the default `storm.json`, `powerlines.config.js`, or `powerlines.config.ts` files.
916
936
  *
917
- * @param code - The source code of the entry file
918
- * @param path - An optional path to write the entry file to
919
- * @param options - Options for writing the file
937
+ * @remarks
938
+ * This option is useful for running Powerlines commands with different configuration files, such as in CI/CD environments or when testing different configurations.
920
939
  */
921
- writeEntry: (code: string, path: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
940
+ configFile?: string;
922
941
  /**
923
- * Parses the source code and returns a {@link ParseResult} object.
942
+ * Should the Powerlines CLI processes skip installing missing packages?
943
+ *
944
+ * @remarks
945
+ * This option is useful for CI/CD environments where the installation of packages is handled by a different process.
946
+ *
947
+ * @defaultValue false
924
948
  */
925
- parse: (code: string, id: string, options?: ParserOptions | null) => Promise<ParseResult>;
949
+ skipInstalls?: boolean;
926
950
  /**
927
- * A function to update the context fields using a new user configuration options
951
+ * Should the compiler processes skip any improvements that make use of cache?
952
+ *
953
+ * @defaultValue false
928
954
  */
929
- withUserConfig: (userConfig: UserConfig, options?: InitContextOptions) => Promise<void>;
955
+ skipCache?: boolean;
930
956
  /**
931
- * A function to update the context fields using inline configuration options
957
+ * A list of resolvable paths to plugins used during the build process
932
958
  */
933
- withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
959
+ plugins?: PluginConfig<PluginContext<any>>[];
934
960
  /**
935
- * Create a new logger instance
936
- *
937
- * @param name - The name to use for the logger instance
938
- * @returns A logger function
961
+ * Environment-specific configurations
939
962
  */
940
- createLog: (name: string | null) => LogFn;
963
+ environments?: Record<string, EnvironmentConfig>;
941
964
  /**
942
- * Extend the current logger instance with a new name
965
+ * A string identifier that allows a child framework or tool to identify itself when using Powerlines.
943
966
  *
944
- * @param name - The name to use for the extended logger instance
945
- * @returns A logger function
967
+ * @defaultValue "powerlines"
946
968
  */
947
- extendLog: (name: string) => LogFn;
969
+ framework?: string;
948
970
  }
949
- interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
971
+ type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = CommonUserConfig & {
972
+ build?: TBuildConfig & {
973
+ /**
974
+ * The build variant being used by the Powerlines engine.
975
+ */
976
+ variant?: TBuildVariant;
977
+ };
978
+ override?: Partial<TBuildResolvedConfig>;
979
+ };
980
+ type WebpackUserConfig = UserConfig<WebpackBuildConfig, WebpackResolvedBuildConfig, "webpack">;
981
+ type RspackUserConfig = UserConfig<RspackBuildConfig, RspackResolvedBuildConfig, "rspack">;
982
+ type RollupUserConfig = UserConfig<RollupBuildConfig, RollupResolvedBuildConfig, "rollup">;
983
+ type RolldownUserConfig = UserConfig<RolldownBuildConfig, RolldownResolvedBuildConfig, "rolldown">;
984
+ type ViteUserConfig = UserConfig<ViteBuildConfig, ViteResolvedBuildConfig, "vite">;
985
+ type ESBuildUserConfig = UserConfig<ESBuildBuildConfig, ESBuildResolvedBuildConfig, "esbuild">;
986
+ type UnbuildUserConfig = UserConfig<UnbuildBuildConfig, UnbuildResolvedBuildConfig, "unbuild">;
987
+ type TsupUserConfig = UserConfig<TsupBuildConfig, TsupResolvedBuildConfig, "tsup">;
988
+ type FarmUserConfig = UserConfig<FarmBuildConfig, FarmResolvedBuildConfig, "farm">;
989
+ type InferUserConfig<TBuildVariant extends BuildVariant | undefined> = TBuildVariant extends "webpack" ? WebpackUserConfig : TBuildVariant extends "rspack" ? RspackUserConfig : TBuildVariant extends "vite" ? ViteUserConfig : TBuildVariant extends "esbuild" ? ESBuildUserConfig : TBuildVariant extends "unbuild" ? UnbuildUserConfig : TBuildVariant extends "tsup" ? TsupUserConfig : TBuildVariant extends "rolldown" ? RolldownUserConfig : TBuildVariant extends "rollup" ? RollupUserConfig : TBuildVariant extends "farm" ? FarmUserConfig : UserConfig;
990
+ type InitialUserConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserConfig> & {
991
+ root: string;
992
+ };
993
+ type ParsedUserConfig<TUserConfig extends UserConfig = UserConfig> = TUserConfig & ResolvedConfig$1<TUserConfig> & {
950
994
  /**
951
- * The expected plugins options for the Powerlines project.
995
+ * The path to the user configuration file, if it exists.
952
996
  *
953
997
  * @remarks
954
- * This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
998
+ * This is typically the `powerlines.json`, `powerlines.config.js`, or `powerlines.config.ts` file in the project root.
955
999
  */
956
- plugins: Plugin<PluginContext<TResolvedConfig>>[];
1000
+ configFile?: ConfigLayer<TUserConfig>["configFile"];
1001
+ };
1002
+ type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "release" | "clean";
1003
+ /**
1004
+ * The configuration provided while executing Powerlines commands.
1005
+ */
1006
+ type InlineConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserConfig> & {
957
1007
  /**
958
- * A function to add a plugin to the context and update the configuration options
1008
+ * A string identifier for the Powerlines command being executed
959
1009
  */
960
- addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1010
+ command: PowerlinesCommand;
1011
+ };
1012
+ type NewInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
961
1013
  /**
962
- * A table for storing the current context for each configured environment
1014
+ * A string identifier for the Powerlines command being executed
963
1015
  */
964
- environments: Record<string, EnvironmentContext<TResolvedConfig>>;
1016
+ command: "new";
965
1017
  /**
966
- * Retrieves the context for a specific environment by name
967
- *
968
- * @throws Will throw an error if the environment does not exist
969
- *
970
- * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
971
- * @returns A promise that resolves to the environment context.
972
- *
973
- * @example
974
- * ```ts
975
- * const devEnv = await apiContext.getEnvironment("development");
976
- * const defaultEnv = await apiContext.getEnvironment();
977
- * ```
1018
+ * The package name (from the \`package.json\`) for the project that will be used in the \`new\` command to create a new project based on this configuration
978
1019
  */
979
- getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
1020
+ packageName?: string;
1021
+ };
1022
+ type CleanInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
980
1023
  /**
981
- * Safely retrieves the context for a specific environment by name
982
- *
983
- * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
984
- * @returns A promise that resolves to the environment context, or undefined if the environment does not exist.
985
- *
986
- * @example
987
- * ```ts
988
- * const devEnv = await apiContext.getEnvironmentSafe("development");
989
- * const defaultEnv = await apiContext.getEnvironmentSafe();
990
- * ```
991
- *
992
- * @remarks
993
- * This method is similar to `getEnvironment`, but it returns `undefined` instead of throwing an error if the specified environment does not exist.
994
- * This can be useful in scenarios where the existence of an environment is optional or uncertain.
995
- *
996
- * ```ts
997
- * const testEnv = await apiContext.getEnvironmentSafe("test");
998
- * if (testEnv) {
999
- * // Environment exists, safe to use it
1000
- * } else {
1001
- * // Environment does not exist, handle accordingly
1002
- * }
1003
- * ```
1004
- *
1005
- * Using this method helps avoid unhandled exceptions in cases where an environment might not be defined.
1024
+ * A string identifier for the Powerlines command being executed
1006
1025
  */
1007
- getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
1026
+ command: "clean";
1027
+ };
1028
+ type PrepareInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1008
1029
  /**
1009
- * A function to copy the context and update the fields for a specific environment
1010
- *
1011
- * @param environment - The environment configuration to use.
1012
- * @returns A new context instance with the updated environment.
1030
+ * A string identifier for the Powerlines command being executed
1013
1031
  */
1014
- in: (environment: EnvironmentResolvedConfig) => Promise<EnvironmentContext<TResolvedConfig>>;
1015
- }
1016
- interface EnvironmentContextPlugin<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1017
- plugin: Plugin<PluginContext<TResolvedConfig>>;
1018
- context: PluginContext<TResolvedConfig>;
1019
- }
1020
- interface EnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
1032
+ command: "prepare";
1033
+ };
1034
+ type BuildInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1021
1035
  /**
1022
- * The expected plugins options for the Powerlines project.
1023
- *
1024
- * @remarks
1025
- * This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
1036
+ * A string identifier for the Powerlines command being executed
1026
1037
  */
1027
- plugins: EnvironmentContextPlugin<TResolvedConfig>[];
1038
+ command: "build";
1039
+ };
1040
+ type LintInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1028
1041
  /**
1029
- * A function to add a plugin to the context and update the configuration options
1042
+ * A string identifier for the Powerlines command being executed
1030
1043
  */
1031
- addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1044
+ command: "lint";
1045
+ };
1046
+ type DocsInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1032
1047
  /**
1033
- * The environment specific resolved configuration
1048
+ * A string identifier for the Powerlines command being executed
1034
1049
  */
1035
- environment: EnvironmentResolvedConfig;
1050
+ command: "docs";
1051
+ };
1052
+ type ReleaseInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1036
1053
  /**
1037
- * A table holding references to hook functions registered by plugins
1054
+ * A string identifier for the Powerlines command being executed
1038
1055
  */
1039
- hooks: HooksList<PluginContext<TResolvedConfig>>;
1056
+ command: "release";
1057
+ };
1058
+
1059
+ interface ResolvedEntryTypeDefinition extends TypeDefinition {
1040
1060
  /**
1041
- * Retrieves the hook handlers for a specific hook name
1061
+ * The user provided entry point in the source code
1042
1062
  */
1043
- selectHooks: <TKey extends HookKeys<PluginContext<TResolvedConfig>>>(hook: TKey, options?: SelectHooksOptions) => Hooks[TKey][];
1063
+ input: TypeDefinition;
1064
+ /**
1065
+ * An optional name to use in the package export during the build process
1066
+ */
1067
+ output?: string;
1044
1068
  }
1045
- interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
1069
+ type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview" | "mainFields" | "extensions"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr" | "mainFields" | "extensions">> & {
1046
1070
  /**
1047
- * The environment specific resolved configuration
1071
+ * The name of the environment
1048
1072
  */
1049
- environment: EnvironmentResolvedConfig;
1073
+ name: string;
1050
1074
  /**
1051
- * An alternative property name for the {@link log} property
1052
- *
1053
- * @remarks
1054
- * This is provided for compatibility with other logging libraries that expect a `logger` property.
1075
+ * Configuration options for the preview server
1055
1076
  */
1056
- logger: LogFn;
1057
- }
1058
- type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = PluginContext<TResolvedConfig> & Omit<UnpluginBuildContext, "parse">;
1059
-
1060
- type LogFn = (type: LogLevelLabel, ...args: string[]) => void;
1061
- /**
1062
- * The {@link StormWorkspaceConfig | configuration} object for an entire Powerlines workspace
1063
- */
1064
- type WorkspaceConfig = Partial<StormWorkspaceConfig> & Required<Pick<StormWorkspaceConfig, "workspaceRoot">>;
1065
- type PluginFactory<in out TContext extends PluginContext = PluginContext, TOptions = any> = (options: TOptions) => MaybePromise<Plugin<TContext>>;
1066
- /**
1067
- * A configuration tuple for a Powerlines plugin.
1068
- */
1069
- type PluginConfigTuple<TContext extends PluginContext = PluginContext, TOptions = any> = [string | PluginFactory<TContext, TOptions>, TOptions] | [Plugin<TContext>];
1070
- /**
1071
- * A configuration object for a Powerlines plugin.
1072
- */
1073
- type PluginConfigObject<TContext extends PluginContext = PluginContext, TOptions = any> = {
1074
- plugin: string | PluginFactory<TContext, TOptions>;
1075
- options: TOptions;
1076
- } | {
1077
- plugin: Plugin<TContext>;
1078
- options?: never;
1077
+ preview?: ResolvedPreviewOptions;
1079
1078
  };
1079
+ type ResolvedAssetGlob = AssetGlob & Required<Pick<AssetGlob, "input">>;
1080
+ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
1081
+ assets: ResolvedAssetGlob[];
1082
+ }>;
1080
1083
  /**
1081
- * A configuration tuple for a Powerlines plugin.
1084
+ * The resolved options for the Powerlines project configuration.
1082
1085
  */
1083
- type PluginConfig<TContext extends PluginContext = PluginContext> = string | PluginFactory<TContext, void> | Plugin<TContext> | Promise<Plugin<TContext>> | PluginConfigTuple<TContext> | PluginConfigObject<TContext>;
1084
- type ProjectType = "application" | "library";
1085
- interface OutputConfig {
1086
+ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "build" | "transform" | "override" | "root" | "variant" | "type" | "output" | "logLevel" | "framework"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "build" | "transform" | "override" | "framework">> & {
1086
1087
  /**
1087
- * The path to output the final compiled files to
1088
- *
1089
- * @remarks
1090
- * If a value is not provided, Powerlines will attempt to:
1091
- * 1. Use the `outDir` value in the `tsconfig.json` file.
1092
- * 2. Use the `dist` directory in the project root directory.
1093
- *
1094
- * @defaultValue "dist/\{projectRoot\}"
1088
+ * The configuration options that were provided inline to the Powerlines CLI.
1095
1089
  */
1096
- outputPath?: string;
1090
+ inlineConfig: InlineConfig<TUserConfig>;
1097
1091
  /**
1098
- * The format of the output files
1099
- *
1100
- * @defaultValue "virtual"
1092
+ * The original configuration options that were provided by the user to the Powerlines process.
1101
1093
  */
1102
- mode?: OutputModeType;
1094
+ userConfig: TUserConfig;
1103
1095
  /**
1104
- * The path of the generated runtime declaration file relative to the workspace root.
1105
- *
1106
- * @defaultValue "\{projectRoot\}/powerlines.d.ts"
1096
+ * A string identifier for the Powerlines command being executed.
1107
1097
  */
1108
- dts?: string | false;
1098
+ command: NonUndefined<InlineConfig<TUserConfig>["command"]>;
1109
1099
  /**
1110
- * A prefix to use for identifying builtin modules
1111
- *
1112
- * @remarks
1113
- * This prefix will be used to identify all builtin modules generated during the "prepare" phase. An example builtin ID for a module called `"utils"` would be `"{builtinPrefix}:utils"`.
1100
+ * The root directory of the project's source code
1114
1101
  *
1115
- * @defaultValue "powerlines"
1102
+ * @defaultValue "\{projectRoot\}/src"
1116
1103
  */
1117
- builtinPrefix?: string;
1104
+ sourceRoot: NonUndefined<TUserConfig["sourceRoot"]>;
1118
1105
  /**
1119
- * The folder where the generated runtime artifacts will be located
1120
- *
1121
- * @remarks
1122
- * This folder will contain all runtime artifacts and builtins generated during the "prepare" phase.
1123
- *
1124
- * @defaultValue "\{projectRoot\}/.powerlines"
1106
+ * The root directory of the project.
1125
1107
  */
1126
- artifactsFolder?: string;
1108
+ projectRoot: NonUndefined<TUserConfig["root"]>;
1127
1109
  /**
1128
- * The module format of the output files
1129
- *
1130
- * @remarks
1131
- * This option can be a single format or an array of formats. If an array is provided, multiple builds will be generated for each format.
1132
- *
1133
- * @defaultValue "esm"
1110
+ * The type of project being built.
1134
1111
  */
1135
- format?: Format | Format[];
1112
+ projectType: NonUndefined<TUserConfig["type"]>;
1136
1113
  /**
1137
- * A list of assets to copy to the output directory
1114
+ * The output configuration options to use for the build process
1115
+ */
1116
+ output: OutputResolvedConfig;
1117
+ /**
1118
+ * The log level to use for the Powerlines processes.
1138
1119
  *
1139
- * @remarks
1140
- * The assets can be specified as a string (path to the asset) or as an object with a `glob` property (to match multiple files). The paths are relative to the project root directory.
1120
+ * @defaultValue "info"
1141
1121
  */
1142
- assets?: Array<string | AssetGlob>;
1122
+ logLevel: LogLevelLabel | null;
1123
+ };
1124
+ type ViteResolvedConfig = ResolvedConfig<ViteUserConfig>;
1125
+ type WebpackResolvedConfig = ResolvedConfig<WebpackUserConfig>;
1126
+ type RspackResolvedConfig = ResolvedConfig<RspackUserConfig>;
1127
+ type ESBuildResolvedConfig = ResolvedConfig<ESBuildUserConfig>;
1128
+ type RollupResolvedConfig = ResolvedConfig<RollupUserConfig>;
1129
+ type RolldownResolvedConfig = ResolvedConfig<RolldownUserConfig>;
1130
+ type TsupResolvedConfig = ResolvedConfig<TsupUserConfig>;
1131
+ type UnbuildResolvedConfig = ResolvedConfig<UnbuildUserConfig>;
1132
+ type FarmResolvedConfig = ResolvedConfig<FarmUserConfig>;
1133
+ type InferResolvedConfig<TBuildVariant extends BuildVariant | undefined> = TBuildVariant extends undefined ? ResolvedConfig : TBuildVariant extends "webpack" ? WebpackResolvedConfig : TBuildVariant extends "rspack" ? RspackResolvedConfig : TBuildVariant extends "vite" ? ViteResolvedConfig : TBuildVariant extends "esbuild" ? ESBuildResolvedConfig : TBuildVariant extends "unbuild" ? UnbuildResolvedConfig : TBuildVariant extends "tsup" ? TsupResolvedConfig : TBuildVariant extends "rolldown" ? RolldownResolvedConfig : TBuildVariant extends "rollup" ? RollupResolvedConfig : TBuildVariant extends "farm" ? FarmResolvedConfig : ResolvedConfig;
1134
+
1135
+ type BaseHooks<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext>;
1136
+ type BaseHookKeys<TContext extends PluginContext = PluginContext> = keyof BaseHooks<TContext>;
1137
+ type ExternalHooks<TContext extends PluginContext = PluginContext> = ExternalPluginHookFunctions<TContext>;
1138
+ type ExternalHookKeys<TContext extends PluginContext = PluginContext> = keyof ExternalHooks<TContext>;
1139
+ type Hooks<TContext extends PluginContext = PluginContext> = PluginHookFunctions<TContext>;
1140
+ type HookKeys<TContext extends PluginContext = PluginContext> = keyof Hooks<TContext>;
1141
+ interface BaseHooksListItem<TContext extends PluginContext = PluginContext, TKey extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> extends PluginHookObject<BaseHooks<TContext>[TKey]> {
1142
+ plugin: Plugin<TContext>;
1143
1143
  }
1144
- interface BaseConfig {
1144
+ interface BaseHooksList<TContext extends PluginContext = PluginContext, TKey extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> {
1145
+ preOrdered?: BaseHooksListItem<TContext, TKey>[];
1146
+ preEnforced?: BaseHooksListItem<TContext, TKey>[];
1147
+ normal?: BaseHooksListItem<TContext, TKey>[];
1148
+ postEnforced?: BaseHooksListItem<TContext, TKey>[];
1149
+ postOrdered?: BaseHooksListItem<TContext, TKey>[];
1150
+ }
1151
+ interface ExternalHooksListItem<TContext extends PluginContext = PluginContext, TKey extends ExternalHookKeys<TContext> = ExternalHookKeys<TContext>> {
1152
+ plugin: Plugin<TContext>;
1153
+ handler: ExternalHooks<TContext>[TKey];
1154
+ }
1155
+ type HooksList<TContext extends PluginContext = PluginContext> = {
1156
+ [TKey in BaseHookKeys<TContext>]?: BaseHooksList<TContext, TKey>;
1157
+ } & {
1158
+ [TKey in ExternalHookKeys<TContext>]?: ExternalHooksListItem<TContext, TKey>[];
1159
+ };
1160
+ type InferHookHandler<TContext extends PluginContext, TKey extends HookKeys<TContext>> = Hooks<TContext>[TKey];
1161
+ type InferHookReturnType<TContext extends PluginContext, TKey extends HookKeys<TContext>> = ReturnType<InferHookHandler<TContext, TKey>> extends Promise<infer U> ? U extends Promise<infer V> ? V : U : ReturnType<InferHookHandler<TContext, TKey>>;
1162
+ type InferHookParameters<TContext extends PluginContext, TKey extends HookKeys<TContext>> = Parameters<InferHookHandler<TContext, TKey>>;
1163
+
1164
+ type WorkerProcess<TExposedMethods extends ReadonlyArray<string>> = {
1165
+ [K in TExposedMethods[number]]: (data: any) => Promise<any>;
1166
+ } & {
1167
+ close: () => void;
1168
+ end: () => ReturnType<Worker["end"]>;
1169
+ };
1170
+ interface MetaInfo {
1145
1171
  /**
1146
- * The name of the project
1172
+ * The checksum generated from the resolved options
1147
1173
  */
1148
- name?: string;
1174
+ checksum: string;
1149
1175
  /**
1150
- * The project display title
1151
- *
1152
- * @remarks
1153
- * This option is used in documentation generation and other places where a human-readable title is needed.
1176
+ * The build id
1154
1177
  */
1155
- title?: string;
1178
+ buildId: string;
1156
1179
  /**
1157
- * A description of the project
1158
- *
1159
- * @remarks
1160
- * If this option is not provided, the build process will try to use the \`description\` value from the `\package.json\` file.
1180
+ * The release id
1161
1181
  */
1162
- description?: string;
1182
+ releaseId: string;
1163
1183
  /**
1164
- * The log level to use for the Powerlines processes.
1165
- *
1166
- * @defaultValue "info"
1184
+ * The build timestamp
1167
1185
  */
1168
- logLevel?: LogLevelLabel | null;
1186
+ timestamp: number;
1169
1187
  /**
1170
- * A custom logger function to use for logging messages
1188
+ * A hash that represents the path to the project root directory
1171
1189
  */
1172
- customLogger?: LogFn;
1190
+ projectRootHash: string;
1173
1191
  /**
1174
- * Explicitly set a mode to run in. This mode will be used at various points throughout the Powerlines processes, such as when compiling the source code.
1192
+ * A hash that represents the path to the project root directory
1193
+ */
1194
+ configHash: string;
1195
+ /**
1196
+ * A mapping of runtime ids to their corresponding file paths
1197
+ */
1198
+ builtinIdMap: Record<string, string>;
1199
+ /**
1200
+ * A mapping of virtual file paths to their corresponding file contents
1201
+ */
1202
+ virtualFiles: Record<string, string | null>;
1203
+ }
1204
+ interface Resolver extends Jiti {
1205
+ plugin: Jiti;
1206
+ }
1207
+ interface SelectHooksOptions {
1208
+ order?: "pre" | "post" | "normal";
1209
+ }
1210
+ interface InitContextOptions {
1211
+ /**
1212
+ * If false, the plugin will be loaded after all other plugins.
1175
1213
  *
1176
- * @defaultValue "production"
1214
+ * @defaultValue true
1177
1215
  */
1178
- mode?: "development" | "test" | "production";
1216
+ isHighPriority: boolean;
1217
+ }
1218
+ interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1179
1219
  /**
1180
- * The entry point(s) for the application
1220
+ * The Storm workspace configuration
1181
1221
  */
1182
- entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
1222
+ workspaceConfig: WorkspaceConfig;
1183
1223
  /**
1184
- * Configuration for linting the source code
1224
+ * An object containing the options provided to Powerlines
1185
1225
  */
1186
- lint?: Record<string, any> | false;
1226
+ config: TResolvedConfig;
1187
1227
  /**
1188
- * Configuration for the output of the build process
1228
+ * A logging function for the Powerlines engine
1189
1229
  */
1190
- output?: OutputConfig;
1230
+ log: LogFn;
1191
1231
  /**
1192
- * Configuration for the transformation of the source code
1232
+ * The metadata information
1193
1233
  */
1194
- transform?: Record<string, any>;
1234
+ meta: MetaInfo;
1195
1235
  /**
1196
- * Options to to provide to the build process
1236
+ * The metadata information currently written to disk
1197
1237
  */
1198
- build?: BuildConfig;
1238
+ persistedMeta?: MetaInfo;
1199
1239
  /**
1200
- * Configuration for documentation generation
1201
- *
1202
- * @remarks
1203
- * This configuration will be used by the documentation generation plugins during the `docs` command.
1240
+ * The Powerlines artifacts directory
1204
1241
  */
1205
- docs?: Record<string, any>;
1242
+ artifactsPath: string;
1206
1243
  /**
1207
- * The path to the tsconfig file to be used by the compiler
1208
- *
1209
- * @remarks
1210
- * If a value is not provided, the plugin will attempt to find the `tsconfig.json` file in the project root directory. The parsed tsconfig compiler options will be merged with the {@link Options.tsconfigRaw} value (if provided).
1211
- *
1212
- * @defaultValue "\{projectRoot\}/tsconfig.json"
1244
+ * The path to the Powerlines builtin runtime modules directory
1213
1245
  */
1214
- tsconfig?: string;
1246
+ builtinsPath: string;
1215
1247
  /**
1216
- * The raw {@link TSConfig} object to be used by the compiler. This object will be merged with the `tsconfig.json` file.
1217
- *
1218
- * @see https://www.typescriptlang.org/tsconfig
1219
- *
1220
- * @remarks
1221
- * If populated, this option takes higher priority than `tsconfig`
1248
+ * The path to the Powerlines entry modules directory
1249
+ */
1250
+ entryPath: string;
1251
+ /**
1252
+ * The path to the Powerlines TypeScript declaration files directory
1253
+ */
1254
+ dtsPath: string;
1255
+ /**
1256
+ * The path to a directory where the reflection data buffers (used by the build processes) are stored
1257
+ */
1258
+ dataPath: string;
1259
+ /**
1260
+ * The path to a directory where the project cache (used by the build processes) is stored
1261
+ */
1262
+ cachePath: string;
1263
+ /**
1264
+ * The Powerlines environment paths
1265
+ */
1266
+ envPaths: EnvPaths;
1267
+ /**
1268
+ * The file system path to the Powerlines package installation
1269
+ */
1270
+ powerlinesPath: string;
1271
+ /**
1272
+ * The relative path to the Powerlines workspace root directory
1273
+ */
1274
+ relativeToWorkspaceRoot: string;
1275
+ /**
1276
+ * The project's `package.json` file content
1277
+ */
1278
+ packageJson: PackageJson & Record<string, any>;
1279
+ /**
1280
+ * The project's `project.json` file content
1222
1281
  */
1223
- tsconfigRaw?: TSConfig;
1224
- }
1225
- interface EnvironmentConfig extends BaseConfig {
1282
+ projectJson?: Record<string, any>;
1226
1283
  /**
1227
- * Array of strings indicating the order in which fields in a package.json file should be resolved to determine the entry point for a module.
1228
- *
1229
- * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
1284
+ * The dependency installations required by the project
1230
1285
  */
1231
- mainFields?: string[];
1286
+ dependencies: Record<string, string | Range>;
1232
1287
  /**
1233
- * Array of strings indicating what conditions should be used for module resolution.
1288
+ * The development dependency installations required by the project
1234
1289
  */
1235
- conditions?: string[];
1290
+ devDependencies: Record<string, string | Range>;
1236
1291
  /**
1237
- * Array of strings indicating what conditions should be used for external modules.
1292
+ * The parsed TypeScript configuration from the `tsconfig.json` file
1238
1293
  */
1239
- externalConditions?: string[];
1294
+ tsconfig: ParsedTypeScriptConfig;
1240
1295
  /**
1241
- * Array of strings indicating what file extensions should be used for module resolution.
1242
- *
1243
- * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
1296
+ * The entry points of the source code
1244
1297
  */
1245
- extensions?: string[];
1298
+ entry: ResolvedEntryTypeDefinition[];
1246
1299
  /**
1247
- * Array of strings indicating what modules should be deduplicated to a single version in the build.
1248
- *
1249
- * @remarks
1250
- * This option is useful for ensuring that only one version of a module is included in the bundle, which can help reduce bundle size and avoid conflicts.
1300
+ * The virtual file system manager used during the build process to reference generated runtime files
1251
1301
  */
1252
- dedupe?: string[];
1302
+ fs: VirtualFileSystemInterface;
1253
1303
  /**
1254
- * Array of strings or regular expressions that indicate what modules are builtin for the environment.
1304
+ * The Jiti module resolver
1255
1305
  */
1256
- builtins?: (string | RegExp)[];
1306
+ resolver: Resolver;
1257
1307
  /**
1258
- * Configuration options for the preview server
1308
+ * The builtin module id that exist in the Powerlines virtual file system
1259
1309
  */
1260
- preview?: PreviewOptions;
1310
+ builtins: string[];
1261
1311
  /**
1262
- * A flag indicating whether the build is for a Server-Side Rendering environment.
1312
+ * The Powerlines builtin virtual files
1263
1313
  */
1264
- ssr?: boolean;
1314
+ getBuiltins: () => Promise<VirtualFile[]>;
1265
1315
  /**
1266
- * Define if this environment is used for Server-Side Rendering
1316
+ * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
1267
1317
  *
1268
- * @defaultValue "server" (if it isn't the client environment)
1318
+ * @param code - The source code of the builtin file
1319
+ * @param id - The unique identifier of the builtin file
1320
+ * @param path - An optional path to write the builtin file to
1321
+ * @param options - Options for writing the file
1269
1322
  */
1270
- consumer?: "client" | "server";
1271
- }
1272
- interface CommonUserConfig extends BaseConfig {
1323
+ writeBuiltin: (code: string, id: string, path?: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1273
1324
  /**
1274
- * The type of project being built
1325
+ * Resolves a entry virtual file and writes it to the VFS if it does not already exist
1275
1326
  *
1276
- * @defaultValue "application"
1327
+ * @param code - The source code of the entry file
1328
+ * @param path - An optional path to write the entry file to
1329
+ * @param options - Options for writing the file
1277
1330
  */
1278
- type?: ProjectType;
1331
+ writeEntry: (code: string, path: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1279
1332
  /**
1280
- * The root directory of the project
1333
+ * Parses the source code and returns a {@link ParseResult} object.
1281
1334
  */
1282
- root: string;
1335
+ parse: (code: string, id: string, options?: ParserOptions | null) => Promise<ParseResult>;
1283
1336
  /**
1284
- * The root directory of the project's source code
1285
- *
1286
- * @defaultValue "\{root\}/src"
1337
+ * A function to update the context fields using a new user configuration options
1287
1338
  */
1288
- sourceRoot?: string;
1339
+ withUserConfig: (userConfig: UserConfig, options?: InitContextOptions) => Promise<void>;
1289
1340
  /**
1290
- * A path to a custom configuration file to be used instead of the default `storm.json`, `powerlines.config.js`, or `powerlines.config.ts` files.
1291
- *
1292
- * @remarks
1293
- * This option is useful for running Powerlines commands with different configuration files, such as in CI/CD environments or when testing different configurations.
1341
+ * A function to update the context fields using inline configuration options
1294
1342
  */
1295
- configFile?: string;
1343
+ withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
1296
1344
  /**
1297
- * Should the Powerlines CLI processes skip installing missing packages?
1345
+ * Create a new logger instance
1298
1346
  *
1299
- * @remarks
1300
- * This option is useful for CI/CD environments where the installation of packages is handled by a different process.
1347
+ * @param name - The name to use for the logger instance
1348
+ * @returns A logger function
1349
+ */
1350
+ createLog: (name: string | null) => LogFn;
1351
+ /**
1352
+ * Extend the current logger instance with a new name
1301
1353
  *
1302
- * @defaultValue false
1354
+ * @param name - The name to use for the extended logger instance
1355
+ * @returns A logger function
1303
1356
  */
1304
- skipInstalls?: boolean;
1357
+ extendLog: (name: string) => LogFn;
1358
+ }
1359
+ interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
1305
1360
  /**
1306
- * Should the compiler processes skip any improvements that make use of cache?
1361
+ * The expected plugins options for the Powerlines project.
1307
1362
  *
1308
- * @defaultValue false
1363
+ * @remarks
1364
+ * This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
1309
1365
  */
1310
- skipCache?: boolean;
1366
+ plugins: Plugin<PluginContext<TResolvedConfig>>[];
1311
1367
  /**
1312
- * A list of resolvable paths to plugins used during the build process
1368
+ * A function to add a plugin to the context and update the configuration options
1313
1369
  */
1314
- plugins?: PluginConfig<PluginContext<any>>[];
1370
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1315
1371
  /**
1316
- * Environment-specific configurations
1372
+ * A table for storing the current context for each configured environment
1317
1373
  */
1318
- environments?: Record<string, EnvironmentConfig>;
1374
+ environments: Record<string, EnvironmentContext<TResolvedConfig>>;
1319
1375
  /**
1320
- * A string identifier that allows a child framework or tool to identify itself when using Powerlines.
1376
+ * Retrieves the context for a specific environment by name
1321
1377
  *
1322
- * @defaultValue "powerlines"
1378
+ * @throws Will throw an error if the environment does not exist
1379
+ *
1380
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
1381
+ * @returns A promise that resolves to the environment context.
1382
+ *
1383
+ * @example
1384
+ * ```ts
1385
+ * const devEnv = await apiContext.getEnvironment("development");
1386
+ * const defaultEnv = await apiContext.getEnvironment();
1387
+ * ```
1323
1388
  */
1324
- framework?: string;
1325
- }
1326
- type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = CommonUserConfig & {
1327
- build?: TBuildConfig & {
1328
- /**
1329
- * The build variant being used by the Powerlines engine.
1330
- */
1331
- variant?: TBuildVariant;
1332
- };
1333
- override?: Partial<TBuildResolvedConfig>;
1334
- };
1335
- type WebpackUserConfig = UserConfig<WebpackBuildConfig, WebpackResolvedBuildConfig, "webpack">;
1336
- type RspackUserConfig = UserConfig<RspackBuildConfig, RspackResolvedBuildConfig, "rspack">;
1337
- type RollupUserConfig = UserConfig<RollupBuildConfig, RollupResolvedBuildConfig, "rollup">;
1338
- type RolldownUserConfig = UserConfig<RolldownBuildConfig, RolldownResolvedBuildConfig, "rolldown">;
1339
- type ViteUserConfig = UserConfig<ViteBuildConfig, ViteResolvedBuildConfig, "vite">;
1340
- type ESBuildUserConfig = UserConfig<ESBuildBuildConfig, ESBuildResolvedBuildConfig, "esbuild">;
1341
- type UnbuildUserConfig = UserConfig<UnbuildBuildConfig, UnbuildResolvedBuildConfig, "unbuild">;
1342
- type TsupUserConfig = UserConfig<TsupBuildConfig, TsupResolvedBuildConfig, "tsup">;
1343
- type FarmUserConfig = UserConfig<FarmBuildConfig, FarmResolvedBuildConfig, "farm">;
1344
- type InferUserConfig<TBuildVariant extends BuildVariant | undefined> = TBuildVariant extends "webpack" ? WebpackUserConfig : TBuildVariant extends "rspack" ? RspackUserConfig : TBuildVariant extends "vite" ? ViteUserConfig : TBuildVariant extends "esbuild" ? ESBuildUserConfig : TBuildVariant extends "unbuild" ? UnbuildUserConfig : TBuildVariant extends "tsup" ? TsupUserConfig : TBuildVariant extends "rolldown" ? RolldownUserConfig : TBuildVariant extends "rollup" ? RollupUserConfig : TBuildVariant extends "farm" ? FarmUserConfig : UserConfig;
1345
- type InitialUserConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserConfig> & {
1346
- root: string;
1347
- };
1348
- type ParsedUserConfig<TUserConfig extends UserConfig = UserConfig> = TUserConfig & ResolvedConfig$1<TUserConfig> & {
1389
+ getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
1349
1390
  /**
1350
- * The path to the user configuration file, if it exists.
1391
+ * Safely retrieves the context for a specific environment by name
1392
+ *
1393
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
1394
+ * @returns A promise that resolves to the environment context, or undefined if the environment does not exist.
1395
+ *
1396
+ * @example
1397
+ * ```ts
1398
+ * const devEnv = await apiContext.getEnvironmentSafe("development");
1399
+ * const defaultEnv = await apiContext.getEnvironmentSafe();
1400
+ * ```
1351
1401
  *
1352
1402
  * @remarks
1353
- * This is typically the `powerlines.json`, `powerlines.config.js`, or `powerlines.config.ts` file in the project root.
1354
- */
1355
- configFile?: ConfigLayer<TUserConfig>["configFile"];
1356
- };
1357
- type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "release" | "clean";
1358
- /**
1359
- * The configuration provided while executing Powerlines commands.
1360
- */
1361
- type InlineConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserConfig> & {
1362
- /**
1363
- * A string identifier for the Powerlines command being executed
1403
+ * This method is similar to `getEnvironment`, but it returns `undefined` instead of throwing an error if the specified environment does not exist.
1404
+ * This can be useful in scenarios where the existence of an environment is optional or uncertain.
1405
+ *
1406
+ * ```ts
1407
+ * const testEnv = await apiContext.getEnvironmentSafe("test");
1408
+ * if (testEnv) {
1409
+ * // Environment exists, safe to use it
1410
+ * } else {
1411
+ * // Environment does not exist, handle accordingly
1412
+ * }
1413
+ * ```
1414
+ *
1415
+ * Using this method helps avoid unhandled exceptions in cases where an environment might not be defined.
1364
1416
  */
1365
- command: PowerlinesCommand;
1366
- };
1367
- type NewInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
1417
+ getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
1368
1418
  /**
1369
- * A string identifier for the Powerlines command being executed
1419
+ * A function to copy the context and update the fields for a specific environment
1420
+ *
1421
+ * @param environment - The environment configuration to use.
1422
+ * @returns A new context instance with the updated environment.
1370
1423
  */
1371
- command: "new";
1424
+ in: (environment: EnvironmentResolvedConfig) => Promise<EnvironmentContext<TResolvedConfig>>;
1425
+ }
1426
+ interface EnvironmentContextPlugin<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1427
+ plugin: Plugin<PluginContext<TResolvedConfig>>;
1428
+ context: PluginContext<TResolvedConfig>;
1429
+ }
1430
+ interface EnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
1372
1431
  /**
1373
- * The package name (from the \`package.json\`) for the project that will be used in the \`new\` command to create a new project based on this configuration
1432
+ * The expected plugins options for the Powerlines project.
1433
+ *
1434
+ * @remarks
1435
+ * This is a record of plugin identifiers to their respective options. This field is populated by the Powerlines engine during both plugin initialization and the `init` command.
1374
1436
  */
1375
- packageName?: string;
1376
- };
1377
- type CleanInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1437
+ plugins: EnvironmentContextPlugin<TResolvedConfig>[];
1378
1438
  /**
1379
- * A string identifier for the Powerlines command being executed
1439
+ * A function to add a plugin to the context and update the configuration options
1380
1440
  */
1381
- command: "clean";
1382
- };
1383
- type PrepareInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1441
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1384
1442
  /**
1385
- * A string identifier for the Powerlines command being executed
1443
+ * The environment specific resolved configuration
1386
1444
  */
1387
- command: "prepare";
1388
- };
1389
- type BuildInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1445
+ environment: EnvironmentResolvedConfig;
1390
1446
  /**
1391
- * A string identifier for the Powerlines command being executed
1447
+ * A table holding references to hook functions registered by plugins
1392
1448
  */
1393
- command: "build";
1394
- };
1395
- type LintInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1449
+ hooks: HooksList<PluginContext<TResolvedConfig>>;
1396
1450
  /**
1397
- * A string identifier for the Powerlines command being executed
1451
+ * Retrieves the hook handlers for a specific hook name
1398
1452
  */
1399
- command: "lint";
1400
- };
1401
- type DocsInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1453
+ selectHooks: <TKey extends HookKeys<PluginContext<TResolvedConfig>>>(hook: TKey, options?: SelectHooksOptions) => Hooks[TKey][];
1454
+ }
1455
+ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
1402
1456
  /**
1403
- * A string identifier for the Powerlines command being executed
1457
+ * The environment specific resolved configuration
1404
1458
  */
1405
- command: "docs";
1406
- };
1407
- type ReleaseInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1459
+ environment: EnvironmentResolvedConfig;
1408
1460
  /**
1409
- * A string identifier for the Powerlines command being executed
1461
+ * An alternative property name for the {@link log} property
1462
+ *
1463
+ * @remarks
1464
+ * This is provided for compatibility with other logging libraries that expect a `logger` property.
1410
1465
  */
1411
- command: "release";
1412
- };
1466
+ logger: LogFn;
1467
+ }
1468
+ type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = PluginContext<TResolvedConfig> & Omit<UnpluginBuildContext, "parse">;
1413
1469
 
1414
1470
  export type { APIContext as A, BaseHookKeys as B, Context as C, InitialUserConfig as D, ESBuildResolvedBuildConfig as E, PrepareInlineConfig as F, CleanInlineConfig as G, HookKeys as H, InferHookParameters as I, BuildInlineConfig as J, LintInlineConfig as K, LogFn as L, MetaInfo as M, NewInlineConfig as N, DocsInlineConfig as O, PowerlinesCommand as P, ReleaseInlineConfig as Q, ResolvedEntryTypeDefinition as R, SelectHooksOptions as S, TsupBuildConfig as T, UnbuildBuildConfig as U, ViteResolvedBuildConfig as V, WorkspaceConfig as W, ParsedUserConfig as a, RolldownResolvedBuildConfig as b, RollupResolvedBuildConfig as c, TsupResolvedBuildConfig as d, PluginContext as e, ResolvedConfig as f, Plugin as g, PluginConfigObject as h, PluginConfigTuple as i, PluginConfig as j, PluginHookObject as k, PluginHook as l, EnvironmentConfig as m, EnvironmentResolvedConfig as n, ExternalHookKeys as o, BaseHooksListItem as p, WorkerProcess as q, EnvironmentContext as r, InferHookReturnType as s, UnbuildResolvedBuildConfig as t, BuildVariant as u, InferUnpluginVariant as v, BuildPlugin as w, InferResolvedConfig as x, UnpluginBuildVariant as y, InferUserConfig as z };