powerlines 0.10.2 → 0.12.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-BGYnc61f.d.ts → hooks-BmvalJZ4.d.ts} +1 -1
  50. package/dist/{hooks-gk8S8LFP.d.cts → hooks-BzFKq34L.d.cts} +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-BI46yeFZ.d.cts} +617 -557
  114. package/dist/lib/{config-B_WTwd49.d.ts → context-tEqvC3yI.d.ts} +617 -557
  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-C9_XPS6c.d.cts} +1 -1
  124. package/dist/lib/{hooks-4KkL9GD2.d.cts → hooks-DESiFNA6.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/{resolved-Dhscmo3z.d.ts → resolved-BS8bJ6b1.d.ts} +21 -17
  182. package/dist/{resolved-CcuVqMqc.d.cts → resolved-CjkYiKA1.d.cts} +21 -17
  183. package/dist/rolldown.cjs +7 -7
  184. package/dist/rolldown.d.cts +1 -1
  185. package/dist/rolldown.d.ts +1 -1
  186. package/dist/rolldown.js +4 -4
  187. package/dist/rollup.cjs +7 -7
  188. package/dist/rollup.d.cts +1 -1
  189. package/dist/rollup.d.ts +1 -1
  190. package/dist/rollup.js +4 -4
  191. package/dist/rspack.cjs +7 -7
  192. package/dist/rspack.d.cts +1 -1
  193. package/dist/rspack.d.ts +1 -1
  194. package/dist/rspack.js +4 -4
  195. package/dist/tsup.cjs +8 -8
  196. package/dist/tsup.js +5 -5
  197. package/dist/types/babel.d.cts +1 -1
  198. package/dist/types/babel.d.ts +1 -1
  199. package/dist/types/commands.d.cts +1 -1
  200. package/dist/types/commands.d.ts +1 -1
  201. package/dist/types/compiler.d.cts +1 -1
  202. package/dist/types/compiler.d.ts +1 -1
  203. package/dist/types/config.d.cts +1 -1
  204. package/dist/types/config.d.ts +1 -1
  205. package/dist/types/context.cjs +2 -2
  206. package/dist/types/context.d.cts +1 -1
  207. package/dist/types/context.d.ts +1 -1
  208. package/dist/types/context.js +1 -1
  209. package/dist/types/hooks.d.cts +1 -1
  210. package/dist/types/hooks.d.ts +1 -1
  211. package/dist/types/index.cjs +9 -9
  212. package/dist/types/index.d.cts +1 -1
  213. package/dist/types/index.d.ts +1 -1
  214. package/dist/types/index.js +2 -2
  215. package/dist/types/internal.d.cts +2 -2
  216. package/dist/types/internal.d.ts +2 -2
  217. package/dist/types/plugin.d.cts +1 -1
  218. package/dist/types/plugin.d.ts +1 -1
  219. package/dist/types/resolved.d.cts +1 -1
  220. package/dist/types/resolved.d.ts +1 -1
  221. package/dist/types/unplugin.d.cts +1 -1
  222. package/dist/types/unplugin.d.ts +1 -1
  223. package/dist/types/vfs.cjs +7 -7
  224. package/dist/types/vfs.d.cts +61 -5
  225. package/dist/types/vfs.d.ts +61 -5
  226. package/dist/types/vfs.js +1 -1
  227. package/dist/unloader.cjs +7 -7
  228. package/dist/unloader.d.cts +1 -1
  229. package/dist/unloader.d.ts +1 -1
  230. package/dist/unloader.js +4 -4
  231. package/dist/unplugin.cjs +18 -18
  232. package/dist/unplugin.d.cts +2 -2
  233. package/dist/unplugin.d.ts +2 -2
  234. package/dist/unplugin.js +15 -15
  235. package/dist/vite.cjs +7 -7
  236. package/dist/vite.d.cts +1 -1
  237. package/dist/vite.d.ts +1 -1
  238. package/dist/vite.js +4 -4
  239. package/dist/webpack.cjs +7 -7
  240. package/dist/webpack.d.cts +1 -1
  241. package/dist/webpack.d.ts +1 -1
  242. package/dist/webpack.js +4 -4
  243. package/package.json +11 -9
  244. package/dist/chunk-IJBH5OUN.cjs +0 -12
  245. package/dist/chunk-JBTSAOIQ.js +0 -31
  246. package/dist/chunk-LXMNDUPG.cjs +0 -12
  247. package/dist/chunk-RQ4CHMPO.cjs +0 -12
  248. package/dist/chunk-S5QFX2GM.cjs +0 -12
  249. package/dist/chunk-SL3CXJWD.cjs +0 -34
  250. package/dist/chunk-YG7U2GIR.cjs +0 -24
  251. package/dist/chunk-ZFATNDSY.cjs +0 -12
  252. package/dist/lib/chunk-6U2UX2PX.cjs.map +0 -1
  253. package/dist/lib/chunk-KFE2IR3Y.js.map +0 -1
  254. package/dist/lib/chunk-M7U5RMK7.js.map +0 -1
  255. package/dist/lib/chunk-M7WHFUKR.cjs.map +0 -1
  256. package/dist/lib/chunk-PIFE7MUZ.js.map +0 -1
  257. package/dist/lib/chunk-Q2RUDKWY.cjs.map +0 -1
@@ -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.js';
24
25
  import { ArrayValues } from '@stryke/types/array';
25
- import { P as ParsedTypeScriptConfig, T as TSConfig } from './tsconfig-Bz-CiFqD.js';
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,773 @@ 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
797
+ * @remarks
798
+ * This option is used in documentation generation and other places where a human-readable title is needed.
805
799
  */
806
- isHighPriority: boolean;
807
- }
808
- interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
800
+ title?: string;
809
801
  /**
810
- * The Storm workspace configuration
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.
811
806
  */
812
- workspaceConfig: WorkspaceConfig;
807
+ description?: string;
813
808
  /**
814
- * An object containing the options provided to Powerlines
809
+ * The log level to use for the Powerlines processes.
810
+ *
811
+ * @defaultValue "info"
815
812
  */
816
- config: TResolvedConfig;
813
+ logLevel?: LogLevelLabel | null;
817
814
  /**
818
- * A logging function for the Powerlines engine
815
+ * A custom logger function to use for logging messages
819
816
  */
820
- log: LogFn;
817
+ customLogger?: LogFn;
821
818
  /**
822
- * The metadata information
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"
823
822
  */
824
- meta: MetaInfo;
823
+ mode?: "development" | "test" | "production";
825
824
  /**
826
- * The metadata information currently written to disk
825
+ * The entry point(s) for the application
827
826
  */
828
- persistedMeta?: MetaInfo;
827
+ entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
829
828
  /**
830
- * The parsed TypeScript configuration from the `tsconfig.json` file
829
+ * Configuration for linting the source code
831
830
  */
832
- tsconfig: ParsedTypeScriptConfig;
831
+ lint?: Record<string, any> | false;
833
832
  /**
834
- * The entry points of the source code
833
+ * Configuration for testing the source code
835
834
  */
836
- entry: ResolvedEntryTypeDefinition[];
835
+ test?: Record<string, any> | false;
837
836
  /**
838
- * The relative path to the Powerlines workspace root directory
837
+ * Configuration for the output of the build process
839
838
  */
840
- relativeToWorkspaceRoot: string;
839
+ output?: OutputConfig;
841
840
  /**
842
- * The Powerlines artifacts directory
841
+ * Configuration for the transformation of the source code
843
842
  */
844
- artifactsPath: string;
843
+ transform?: Record<string, any>;
845
844
  /**
846
- * The path to the Powerlines builtin runtime modules directory
845
+ * Options to to provide to the build process
847
846
  */
848
- builtinsPath: string;
847
+ build?: BuildConfig;
849
848
  /**
850
- * The path to the Powerlines entry modules directory
849
+ * Configuration for documentation generation
850
+ *
851
+ * @remarks
852
+ * This configuration will be used by the documentation generation plugins during the `docs` command.
851
853
  */
852
- entryPath: string;
854
+ docs?: Record<string, any>;
853
855
  /**
854
- * The path to the Powerlines TypeScript declaration files directory
856
+ * The path to the tsconfig file to be used by the compiler
857
+ *
858
+ * @remarks
859
+ * 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).
860
+ *
861
+ * @defaultValue "\{projectRoot\}/tsconfig.json"
855
862
  */
856
- dtsPath: string;
863
+ tsconfig?: string;
857
864
  /**
858
- * The path to a directory where the reflection data buffers (used by the build processes) are stored
865
+ * The raw {@link TSConfig} object to be used by the compiler. This object will be merged with the `tsconfig.json` file.
866
+ *
867
+ * @see https://www.typescriptlang.org/tsconfig
868
+ *
869
+ * @remarks
870
+ * If populated, this option takes higher priority than `tsconfig`
859
871
  */
860
- dataPath: string;
872
+ tsconfigRaw?: TSConfig;
873
+ }
874
+ interface EnvironmentConfig extends BaseConfig {
861
875
  /**
862
- * The path to a directory where the project cache (used by the build processes) is stored
876
+ * 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.
877
+ *
878
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
863
879
  */
864
- cachePath: string;
880
+ mainFields?: string[];
865
881
  /**
866
- * The Powerlines environment paths
882
+ * Array of strings indicating what conditions should be used for module resolution.
867
883
  */
868
- envPaths: EnvPaths;
884
+ conditions?: string[];
869
885
  /**
870
- * The file system path to the Powerlines package installation
886
+ * Array of strings indicating what conditions should be used for external modules.
871
887
  */
872
- powerlinesPath: string;
888
+ externalConditions?: string[];
873
889
  /**
874
- * The dependency installations required by the project
890
+ * Array of strings indicating what file extensions should be used for module resolution.
891
+ *
892
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
875
893
  */
876
- dependencies: Record<string, string | Range>;
894
+ extensions?: string[];
877
895
  /**
878
- * The development dependency installations required by the project
896
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
897
+ *
898
+ * @remarks
899
+ * 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
900
  */
880
- devDependencies: Record<string, string | Range>;
901
+ dedupe?: string[];
881
902
  /**
882
- * The project's `package.json` file content
903
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
883
904
  */
884
- packageJson: PackageJson & Record<string, any>;
905
+ builtins?: (string | RegExp)[];
885
906
  /**
886
- * The project's `project.json` file content
907
+ * Configuration options for the preview server
887
908
  */
888
- projectJson?: Record<string, any>;
909
+ preview?: PreviewOptions;
889
910
  /**
890
- * The virtual file system manager used during the build process to reference generated runtime files
911
+ * A flag indicating whether the build is for a Server-Side Rendering environment.
891
912
  */
892
- fs: VirtualFileSystemInterface;
913
+ ssr?: boolean;
893
914
  /**
894
- * The Jiti module resolver
915
+ * Define if this environment is used for Server-Side Rendering
916
+ *
917
+ * @defaultValue "server" (if it isn't the client environment)
895
918
  */
896
- resolver: Resolver;
919
+ consumer?: "client" | "server";
920
+ }
921
+ interface CommonUserConfig extends BaseConfig {
897
922
  /**
898
- * The builtin module id that exist in the Powerlines virtual file system
923
+ * The type of project being built
924
+ *
925
+ * @defaultValue "application"
899
926
  */
900
- builtins: string[];
927
+ type?: ProjectType;
901
928
  /**
902
- * The Powerlines builtin virtual files
929
+ * The root directory of the project
903
930
  */
904
- getBuiltins: () => Promise<VirtualFile[]>;
931
+ root: string;
905
932
  /**
906
- * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
933
+ * The root directory of the project's source code
907
934
  *
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
935
+ * @defaultValue "\{root\}/src"
912
936
  */
913
- writeBuiltin: (code: string, id: string, path?: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
937
+ sourceRoot?: string;
914
938
  /**
915
- * Resolves a entry virtual file and writes it to the VFS if it does not already exist
939
+ * 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
940
  *
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
941
+ * @remarks
942
+ * This option is useful for running Powerlines commands with different configuration files, such as in CI/CD environments or when testing different configurations.
920
943
  */
921
- writeEntry: (code: string, path: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
944
+ configFile?: string;
922
945
  /**
923
- * Parses the source code and returns a {@link ParseResult} object.
946
+ * Should the Powerlines CLI processes skip installing missing packages?
947
+ *
948
+ * @remarks
949
+ * This option is useful for CI/CD environments where the installation of packages is handled by a different process.
950
+ *
951
+ * @defaultValue false
924
952
  */
925
- parse: (code: string, id: string, options?: ParserOptions | null) => Promise<ParseResult>;
953
+ skipInstalls?: boolean;
926
954
  /**
927
- * A function to update the context fields using a new user configuration options
955
+ * Should the compiler processes skip any improvements that make use of cache?
956
+ *
957
+ * @defaultValue false
928
958
  */
929
- withUserConfig: (userConfig: UserConfig, options?: InitContextOptions) => Promise<void>;
959
+ skipCache?: boolean;
930
960
  /**
931
- * A function to update the context fields using inline configuration options
961
+ * A list of resolvable paths to plugins used during the build process
932
962
  */
933
- withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
963
+ plugins?: PluginConfig<PluginContext<any>>[];
934
964
  /**
935
- * Create a new logger instance
936
- *
937
- * @param name - The name to use for the logger instance
938
- * @returns A logger function
965
+ * Environment-specific configurations
939
966
  */
940
- createLog: (name: string | null) => LogFn;
967
+ environments?: Record<string, EnvironmentConfig>;
941
968
  /**
942
- * Extend the current logger instance with a new name
969
+ * A string identifier that allows a child framework or tool to identify itself when using Powerlines.
943
970
  *
944
- * @param name - The name to use for the extended logger instance
945
- * @returns A logger function
971
+ * @defaultValue "powerlines"
946
972
  */
947
- extendLog: (name: string) => LogFn;
973
+ framework?: string;
948
974
  }
949
- interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
975
+ type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = CommonUserConfig & {
976
+ build?: TBuildConfig & {
977
+ /**
978
+ * The build variant being used by the Powerlines engine.
979
+ */
980
+ variant?: TBuildVariant;
981
+ };
982
+ override?: Partial<TBuildResolvedConfig>;
983
+ };
984
+ type WebpackUserConfig = UserConfig<WebpackBuildConfig, WebpackResolvedBuildConfig, "webpack">;
985
+ type RspackUserConfig = UserConfig<RspackBuildConfig, RspackResolvedBuildConfig, "rspack">;
986
+ type RollupUserConfig = UserConfig<RollupBuildConfig, RollupResolvedBuildConfig, "rollup">;
987
+ type RolldownUserConfig = UserConfig<RolldownBuildConfig, RolldownResolvedBuildConfig, "rolldown">;
988
+ type ViteUserConfig = UserConfig<ViteBuildConfig, ViteResolvedBuildConfig, "vite">;
989
+ type ESBuildUserConfig = UserConfig<ESBuildBuildConfig, ESBuildResolvedBuildConfig, "esbuild">;
990
+ type UnbuildUserConfig = UserConfig<UnbuildBuildConfig, UnbuildResolvedBuildConfig, "unbuild">;
991
+ type TsupUserConfig = UserConfig<TsupBuildConfig, TsupResolvedBuildConfig, "tsup">;
992
+ type FarmUserConfig = UserConfig<FarmBuildConfig, FarmResolvedBuildConfig, "farm">;
993
+ 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;
994
+ type InitialUserConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserConfig> & {
995
+ root: string;
996
+ };
997
+ type ParsedUserConfig<TUserConfig extends UserConfig = UserConfig> = TUserConfig & ResolvedConfig$1<TUserConfig> & {
950
998
  /**
951
- * The expected plugins options for the Powerlines project.
999
+ * The path to the user configuration file, if it exists.
952
1000
  *
953
1001
  * @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.
1002
+ * This is typically the `powerlines.json`, `powerlines.config.js`, or `powerlines.config.ts` file in the project root.
955
1003
  */
956
- plugins: Plugin<PluginContext<TResolvedConfig>>[];
1004
+ configFile?: ConfigLayer<TUserConfig>["configFile"];
1005
+ };
1006
+ type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "release" | "clean";
1007
+ /**
1008
+ * The configuration provided while executing Powerlines commands.
1009
+ */
1010
+ type InlineConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserConfig> & {
957
1011
  /**
958
- * A function to add a plugin to the context and update the configuration options
1012
+ * A string identifier for the Powerlines command being executed
959
1013
  */
960
- addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1014
+ command: PowerlinesCommand;
1015
+ };
1016
+ type NewInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
961
1017
  /**
962
- * A table for storing the current context for each configured environment
1018
+ * A string identifier for the Powerlines command being executed
963
1019
  */
964
- environments: Record<string, EnvironmentContext<TResolvedConfig>>;
1020
+ command: "new";
965
1021
  /**
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
- * ```
1022
+ * 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
1023
  */
979
- getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
1024
+ packageName?: string;
1025
+ };
1026
+ type CleanInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
980
1027
  /**
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.
1028
+ * A string identifier for the Powerlines command being executed
1006
1029
  */
1007
- getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
1030
+ command: "clean";
1031
+ };
1032
+ type PrepareInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1008
1033
  /**
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.
1034
+ * A string identifier for the Powerlines command being executed
1013
1035
  */
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> {
1036
+ command: "prepare";
1037
+ };
1038
+ type BuildInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1021
1039
  /**
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.
1040
+ * A string identifier for the Powerlines command being executed
1026
1041
  */
1027
- plugins: EnvironmentContextPlugin<TResolvedConfig>[];
1042
+ command: "build";
1043
+ };
1044
+ type LintInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1028
1045
  /**
1029
- * A function to add a plugin to the context and update the configuration options
1046
+ * A string identifier for the Powerlines command being executed
1030
1047
  */
1031
- addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1048
+ command: "lint";
1049
+ };
1050
+ type DocsInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1032
1051
  /**
1033
- * The environment specific resolved configuration
1052
+ * A string identifier for the Powerlines command being executed
1034
1053
  */
1035
- environment: EnvironmentResolvedConfig;
1054
+ command: "docs";
1055
+ };
1056
+ type ReleaseInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1036
1057
  /**
1037
- * A table holding references to hook functions registered by plugins
1058
+ * A string identifier for the Powerlines command being executed
1038
1059
  */
1039
- hooks: HooksList<PluginContext<TResolvedConfig>>;
1060
+ command: "release";
1061
+ };
1062
+
1063
+ interface ResolvedEntryTypeDefinition extends TypeDefinition {
1040
1064
  /**
1041
- * Retrieves the hook handlers for a specific hook name
1065
+ * The user provided entry point in the source code
1042
1066
  */
1043
- selectHooks: <TKey extends HookKeys<PluginContext<TResolvedConfig>>>(hook: TKey, options?: SelectHooksOptions) => Hooks[TKey][];
1067
+ input: TypeDefinition;
1068
+ /**
1069
+ * An optional name to use in the package export during the build process
1070
+ */
1071
+ output?: string;
1044
1072
  }
1045
- interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
1073
+ type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview" | "mainFields" | "extensions"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr" | "mainFields" | "extensions">> & {
1046
1074
  /**
1047
- * The environment specific resolved configuration
1075
+ * The name of the environment
1048
1076
  */
1049
- environment: EnvironmentResolvedConfig;
1077
+ name: string;
1050
1078
  /**
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.
1079
+ * Configuration options for the preview server
1055
1080
  */
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;
1081
+ preview?: ResolvedPreviewOptions;
1079
1082
  };
1083
+ type ResolvedAssetGlob = AssetGlob & Required<Pick<AssetGlob, "input">>;
1084
+ type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
1085
+ assets: ResolvedAssetGlob[];
1086
+ }>;
1080
1087
  /**
1081
- * A configuration tuple for a Powerlines plugin.
1088
+ * The resolved options for the Powerlines project configuration.
1082
1089
  */
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 {
1090
+ type ResolvedConfig<TUserConfig extends UserConfig = UserConfig> = Omit<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "platform" | "tsconfig" | "lint" | "test" | "build" | "transform" | "override" | "root" | "variant" | "type" | "output" | "logLevel" | "framework"> & Required<Pick<TUserConfig, "name" | "title" | "plugins" | "mode" | "environments" | "tsconfig" | "lint" | "test" | "build" | "transform" | "override" | "framework">> & {
1086
1091
  /**
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\}"
1092
+ * The configuration options that were provided inline to the Powerlines CLI.
1095
1093
  */
1096
- outputPath?: string;
1094
+ inlineConfig: InlineConfig<TUserConfig>;
1097
1095
  /**
1098
- * The format of the output files
1099
- *
1100
- * @defaultValue "virtual"
1096
+ * The original configuration options that were provided by the user to the Powerlines process.
1101
1097
  */
1102
- mode?: OutputModeType;
1098
+ userConfig: TUserConfig;
1103
1099
  /**
1104
- * The path of the generated runtime declaration file relative to the workspace root.
1105
- *
1106
- * @defaultValue "\{projectRoot\}/powerlines.d.ts"
1100
+ * A string identifier for the Powerlines command being executed.
1107
1101
  */
1108
- dts?: string | false;
1102
+ command: NonUndefined<InlineConfig<TUserConfig>["command"]>;
1109
1103
  /**
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"`.
1104
+ * The root directory of the project's source code
1114
1105
  *
1115
- * @defaultValue "powerlines"
1106
+ * @defaultValue "\{projectRoot\}/src"
1116
1107
  */
1117
- builtinPrefix?: string;
1108
+ sourceRoot: NonUndefined<TUserConfig["sourceRoot"]>;
1118
1109
  /**
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"
1110
+ * The root directory of the project.
1125
1111
  */
1126
- artifactsFolder?: string;
1112
+ projectRoot: NonUndefined<TUserConfig["root"]>;
1127
1113
  /**
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"
1114
+ * The type of project being built.
1134
1115
  */
1135
- format?: Format | Format[];
1116
+ projectType: NonUndefined<TUserConfig["type"]>;
1136
1117
  /**
1137
- * A list of assets to copy to the output directory
1118
+ * The output configuration options to use for the build process
1119
+ */
1120
+ output: OutputResolvedConfig;
1121
+ /**
1122
+ * The log level to use for the Powerlines processes.
1138
1123
  *
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.
1124
+ * @defaultValue "info"
1141
1125
  */
1142
- assets?: Array<string | AssetGlob>;
1126
+ logLevel: LogLevelLabel | null;
1127
+ };
1128
+ type ViteResolvedConfig = ResolvedConfig<ViteUserConfig>;
1129
+ type WebpackResolvedConfig = ResolvedConfig<WebpackUserConfig>;
1130
+ type RspackResolvedConfig = ResolvedConfig<RspackUserConfig>;
1131
+ type ESBuildResolvedConfig = ResolvedConfig<ESBuildUserConfig>;
1132
+ type RollupResolvedConfig = ResolvedConfig<RollupUserConfig>;
1133
+ type RolldownResolvedConfig = ResolvedConfig<RolldownUserConfig>;
1134
+ type TsupResolvedConfig = ResolvedConfig<TsupUserConfig>;
1135
+ type UnbuildResolvedConfig = ResolvedConfig<UnbuildUserConfig>;
1136
+ type FarmResolvedConfig = ResolvedConfig<FarmUserConfig>;
1137
+ 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;
1138
+
1139
+ type BaseHooks<TContext extends PluginContext = PluginContext> = BasePluginHookFunctions<TContext>;
1140
+ type BaseHookKeys<TContext extends PluginContext = PluginContext> = keyof BaseHooks<TContext>;
1141
+ type ExternalHooks<TContext extends PluginContext = PluginContext> = ExternalPluginHookFunctions<TContext>;
1142
+ type ExternalHookKeys<TContext extends PluginContext = PluginContext> = keyof ExternalHooks<TContext>;
1143
+ type Hooks<TContext extends PluginContext = PluginContext> = PluginHookFunctions<TContext>;
1144
+ type HookKeys<TContext extends PluginContext = PluginContext> = keyof Hooks<TContext>;
1145
+ interface BaseHooksListItem<TContext extends PluginContext = PluginContext, TKey extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> extends PluginHookObject<BaseHooks<TContext>[TKey]> {
1146
+ plugin: Plugin<TContext>;
1143
1147
  }
1144
- interface BaseConfig {
1148
+ interface BaseHooksList<TContext extends PluginContext = PluginContext, TKey extends BaseHookKeys<TContext> = BaseHookKeys<TContext>> {
1149
+ preOrdered?: BaseHooksListItem<TContext, TKey>[];
1150
+ preEnforced?: BaseHooksListItem<TContext, TKey>[];
1151
+ normal?: BaseHooksListItem<TContext, TKey>[];
1152
+ postEnforced?: BaseHooksListItem<TContext, TKey>[];
1153
+ postOrdered?: BaseHooksListItem<TContext, TKey>[];
1154
+ }
1155
+ interface ExternalHooksListItem<TContext extends PluginContext = PluginContext, TKey extends ExternalHookKeys<TContext> = ExternalHookKeys<TContext>> {
1156
+ plugin: Plugin<TContext>;
1157
+ handler: ExternalHooks<TContext>[TKey];
1158
+ }
1159
+ type HooksList<TContext extends PluginContext = PluginContext> = {
1160
+ [TKey in BaseHookKeys<TContext>]?: BaseHooksList<TContext, TKey>;
1161
+ } & {
1162
+ [TKey in ExternalHookKeys<TContext>]?: ExternalHooksListItem<TContext, TKey>[];
1163
+ };
1164
+ type InferHookHandler<TContext extends PluginContext, TKey extends HookKeys<TContext>> = Hooks<TContext>[TKey];
1165
+ 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>>;
1166
+ type InferHookParameters<TContext extends PluginContext, TKey extends HookKeys<TContext>> = Parameters<InferHookHandler<TContext, TKey>>;
1167
+
1168
+ type WorkerProcess<TExposedMethods extends ReadonlyArray<string>> = {
1169
+ [K in TExposedMethods[number]]: (data: any) => Promise<any>;
1170
+ } & {
1171
+ close: () => void;
1172
+ end: () => ReturnType<Worker["end"]>;
1173
+ };
1174
+ interface MetaInfo {
1145
1175
  /**
1146
- * The name of the project
1176
+ * The checksum generated from the resolved options
1147
1177
  */
1148
- name?: string;
1178
+ checksum: string;
1149
1179
  /**
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.
1180
+ * The build id
1154
1181
  */
1155
- title?: string;
1182
+ buildId: string;
1156
1183
  /**
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.
1184
+ * The release id
1161
1185
  */
1162
- description?: string;
1186
+ releaseId: string;
1163
1187
  /**
1164
- * The log level to use for the Powerlines processes.
1165
- *
1166
- * @defaultValue "info"
1188
+ * The build timestamp
1167
1189
  */
1168
- logLevel?: LogLevelLabel | null;
1190
+ timestamp: number;
1169
1191
  /**
1170
- * A custom logger function to use for logging messages
1192
+ * A hash that represents the path to the project root directory
1171
1193
  */
1172
- customLogger?: LogFn;
1194
+ projectRootHash: string;
1173
1195
  /**
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.
1196
+ * A hash that represents the path to the project root directory
1197
+ */
1198
+ configHash: string;
1199
+ /**
1200
+ * A mapping of runtime ids to their corresponding file paths
1201
+ */
1202
+ builtinIdMap: Record<string, string>;
1203
+ /**
1204
+ * A mapping of virtual file paths to their corresponding file contents
1205
+ */
1206
+ virtualFiles: Record<string, string | null>;
1207
+ }
1208
+ interface Resolver extends Jiti {
1209
+ plugin: Jiti;
1210
+ }
1211
+ interface SelectHooksOptions {
1212
+ order?: "pre" | "post" | "normal";
1213
+ }
1214
+ interface InitContextOptions {
1215
+ /**
1216
+ * If false, the plugin will be loaded after all other plugins.
1175
1217
  *
1176
- * @defaultValue "production"
1218
+ * @defaultValue true
1177
1219
  */
1178
- mode?: "development" | "test" | "production";
1220
+ isHighPriority: boolean;
1221
+ }
1222
+ interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1179
1223
  /**
1180
- * The entry point(s) for the application
1224
+ * The Storm workspace configuration
1181
1225
  */
1182
- entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
1226
+ workspaceConfig: WorkspaceConfig;
1183
1227
  /**
1184
- * Configuration for linting the source code
1228
+ * An object containing the options provided to Powerlines
1185
1229
  */
1186
- lint?: Record<string, any> | false;
1230
+ config: TResolvedConfig;
1187
1231
  /**
1188
- * Configuration for the output of the build process
1232
+ * A logging function for the Powerlines engine
1189
1233
  */
1190
- output?: OutputConfig;
1234
+ log: LogFn;
1191
1235
  /**
1192
- * Configuration for the transformation of the source code
1236
+ * The metadata information
1193
1237
  */
1194
- transform?: Record<string, any>;
1238
+ meta: MetaInfo;
1195
1239
  /**
1196
- * Options to to provide to the build process
1240
+ * The metadata information currently written to disk
1197
1241
  */
1198
- build?: BuildConfig;
1242
+ persistedMeta?: MetaInfo;
1199
1243
  /**
1200
- * Configuration for documentation generation
1201
- *
1202
- * @remarks
1203
- * This configuration will be used by the documentation generation plugins during the `docs` command.
1244
+ * The Powerlines artifacts directory
1204
1245
  */
1205
- docs?: Record<string, any>;
1246
+ artifactsPath: string;
1206
1247
  /**
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"
1248
+ * The path to the Powerlines builtin runtime modules directory
1213
1249
  */
1214
- tsconfig?: string;
1250
+ builtinsPath: string;
1215
1251
  /**
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`
1252
+ * The path to the Powerlines entry modules directory
1253
+ */
1254
+ entryPath: string;
1255
+ /**
1256
+ * The path to the Powerlines TypeScript declaration files directory
1257
+ */
1258
+ dtsPath: string;
1259
+ /**
1260
+ * The path to a directory where the reflection data buffers (used by the build processes) are stored
1261
+ */
1262
+ dataPath: string;
1263
+ /**
1264
+ * The path to a directory where the project cache (used by the build processes) is stored
1265
+ */
1266
+ cachePath: string;
1267
+ /**
1268
+ * The Powerlines environment paths
1269
+ */
1270
+ envPaths: EnvPaths;
1271
+ /**
1272
+ * The file system path to the Powerlines package installation
1273
+ */
1274
+ powerlinesPath: string;
1275
+ /**
1276
+ * The relative path to the Powerlines workspace root directory
1277
+ */
1278
+ relativeToWorkspaceRoot: string;
1279
+ /**
1280
+ * The project's `package.json` file content
1281
+ */
1282
+ packageJson: PackageJson & Record<string, any>;
1283
+ /**
1284
+ * The project's `project.json` file content
1222
1285
  */
1223
- tsconfigRaw?: TSConfig;
1224
- }
1225
- interface EnvironmentConfig extends BaseConfig {
1286
+ projectJson?: Record<string, any>;
1226
1287
  /**
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']`
1288
+ * The dependency installations required by the project
1230
1289
  */
1231
- mainFields?: string[];
1290
+ dependencies: Record<string, string | Range>;
1232
1291
  /**
1233
- * Array of strings indicating what conditions should be used for module resolution.
1292
+ * The development dependency installations required by the project
1234
1293
  */
1235
- conditions?: string[];
1294
+ devDependencies: Record<string, string | Range>;
1236
1295
  /**
1237
- * Array of strings indicating what conditions should be used for external modules.
1296
+ * The parsed TypeScript configuration from the `tsconfig.json` file
1238
1297
  */
1239
- externalConditions?: string[];
1298
+ tsconfig: ParsedTypeScriptConfig;
1240
1299
  /**
1241
- * Array of strings indicating what file extensions should be used for module resolution.
1242
- *
1243
- * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
1300
+ * The entry points of the source code
1244
1301
  */
1245
- extensions?: string[];
1302
+ entry: ResolvedEntryTypeDefinition[];
1246
1303
  /**
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.
1304
+ * The virtual file system manager used during the build process to reference generated runtime files
1251
1305
  */
1252
- dedupe?: string[];
1306
+ fs: VirtualFileSystemInterface;
1253
1307
  /**
1254
- * Array of strings or regular expressions that indicate what modules are builtin for the environment.
1308
+ * The Jiti module resolver
1255
1309
  */
1256
- builtins?: (string | RegExp)[];
1310
+ resolver: Resolver;
1257
1311
  /**
1258
- * Configuration options for the preview server
1312
+ * The builtin module id that exist in the Powerlines virtual file system
1259
1313
  */
1260
- preview?: PreviewOptions;
1314
+ builtins: string[];
1261
1315
  /**
1262
- * A flag indicating whether the build is for a Server-Side Rendering environment.
1316
+ * The Powerlines builtin virtual files
1263
1317
  */
1264
- ssr?: boolean;
1318
+ getBuiltins: () => Promise<VirtualFile[]>;
1265
1319
  /**
1266
- * Define if this environment is used for Server-Side Rendering
1320
+ * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
1267
1321
  *
1268
- * @defaultValue "server" (if it isn't the client environment)
1322
+ * @param code - The source code of the builtin file
1323
+ * @param id - The unique identifier of the builtin file
1324
+ * @param path - An optional path to write the builtin file to
1325
+ * @param options - Options for writing the file
1269
1326
  */
1270
- consumer?: "client" | "server";
1271
- }
1272
- interface CommonUserConfig extends BaseConfig {
1327
+ writeBuiltin: (code: string, id: string, path?: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1273
1328
  /**
1274
- * The type of project being built
1329
+ * Resolves a entry virtual file and writes it to the VFS if it does not already exist
1275
1330
  *
1276
- * @defaultValue "application"
1331
+ * @param code - The source code of the entry file
1332
+ * @param path - An optional path to write the entry file to
1333
+ * @param options - Options for writing the file
1277
1334
  */
1278
- type?: ProjectType;
1335
+ writeEntry: (code: string, path: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1279
1336
  /**
1280
- * The root directory of the project
1337
+ * Parses the source code and returns a {@link ParseResult} object.
1281
1338
  */
1282
- root: string;
1339
+ parse: (code: string, id: string, options?: ParserOptions | null) => Promise<ParseResult>;
1283
1340
  /**
1284
- * The root directory of the project's source code
1285
- *
1286
- * @defaultValue "\{root\}/src"
1341
+ * A function to update the context fields using a new user configuration options
1287
1342
  */
1288
- sourceRoot?: string;
1343
+ withUserConfig: (userConfig: UserConfig, options?: InitContextOptions) => Promise<void>;
1289
1344
  /**
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.
1345
+ * A function to update the context fields using inline configuration options
1294
1346
  */
1295
- configFile?: string;
1347
+ withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
1296
1348
  /**
1297
- * Should the Powerlines CLI processes skip installing missing packages?
1349
+ * Create a new logger instance
1298
1350
  *
1299
- * @remarks
1300
- * This option is useful for CI/CD environments where the installation of packages is handled by a different process.
1351
+ * @param name - The name to use for the logger instance
1352
+ * @returns A logger function
1353
+ */
1354
+ createLog: (name: string | null) => LogFn;
1355
+ /**
1356
+ * Extend the current logger instance with a new name
1301
1357
  *
1302
- * @defaultValue false
1358
+ * @param name - The name to use for the extended logger instance
1359
+ * @returns A logger function
1303
1360
  */
1304
- skipInstalls?: boolean;
1361
+ extendLog: (name: string) => LogFn;
1362
+ }
1363
+ interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
1305
1364
  /**
1306
- * Should the compiler processes skip any improvements that make use of cache?
1365
+ * The expected plugins options for the Powerlines project.
1307
1366
  *
1308
- * @defaultValue false
1367
+ * @remarks
1368
+ * 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
1369
  */
1310
- skipCache?: boolean;
1370
+ plugins: Plugin<PluginContext<TResolvedConfig>>[];
1311
1371
  /**
1312
- * A list of resolvable paths to plugins used during the build process
1372
+ * A function to add a plugin to the context and update the configuration options
1313
1373
  */
1314
- plugins?: PluginConfig<PluginContext<any>>[];
1374
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1315
1375
  /**
1316
- * Environment-specific configurations
1376
+ * A table for storing the current context for each configured environment
1317
1377
  */
1318
- environments?: Record<string, EnvironmentConfig>;
1378
+ environments: Record<string, EnvironmentContext<TResolvedConfig>>;
1319
1379
  /**
1320
- * A string identifier that allows a child framework or tool to identify itself when using Powerlines.
1380
+ * Retrieves the context for a specific environment by name
1321
1381
  *
1322
- * @defaultValue "powerlines"
1382
+ * @throws Will throw an error if the environment does not exist
1383
+ *
1384
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
1385
+ * @returns A promise that resolves to the environment context.
1386
+ *
1387
+ * @example
1388
+ * ```ts
1389
+ * const devEnv = await apiContext.getEnvironment("development");
1390
+ * const defaultEnv = await apiContext.getEnvironment();
1391
+ * ```
1323
1392
  */
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> & {
1393
+ getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
1349
1394
  /**
1350
- * The path to the user configuration file, if it exists.
1395
+ * Safely retrieves the context for a specific environment by name
1396
+ *
1397
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
1398
+ * @returns A promise that resolves to the environment context, or undefined if the environment does not exist.
1399
+ *
1400
+ * @example
1401
+ * ```ts
1402
+ * const devEnv = await apiContext.getEnvironmentSafe("development");
1403
+ * const defaultEnv = await apiContext.getEnvironmentSafe();
1404
+ * ```
1351
1405
  *
1352
1406
  * @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
1407
+ * This method is similar to `getEnvironment`, but it returns `undefined` instead of throwing an error if the specified environment does not exist.
1408
+ * This can be useful in scenarios where the existence of an environment is optional or uncertain.
1409
+ *
1410
+ * ```ts
1411
+ * const testEnv = await apiContext.getEnvironmentSafe("test");
1412
+ * if (testEnv) {
1413
+ * // Environment exists, safe to use it
1414
+ * } else {
1415
+ * // Environment does not exist, handle accordingly
1416
+ * }
1417
+ * ```
1418
+ *
1419
+ * Using this method helps avoid unhandled exceptions in cases where an environment might not be defined.
1364
1420
  */
1365
- command: PowerlinesCommand;
1366
- };
1367
- type NewInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
1421
+ getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
1368
1422
  /**
1369
- * A string identifier for the Powerlines command being executed
1423
+ * A function to copy the context and update the fields for a specific environment
1424
+ *
1425
+ * @param environment - The environment configuration to use.
1426
+ * @returns A new context instance with the updated environment.
1370
1427
  */
1371
- command: "new";
1428
+ in: (environment: EnvironmentResolvedConfig) => Promise<EnvironmentContext<TResolvedConfig>>;
1429
+ }
1430
+ interface EnvironmentContextPlugin<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1431
+ plugin: Plugin<PluginContext<TResolvedConfig>>;
1432
+ context: PluginContext<TResolvedConfig>;
1433
+ }
1434
+ interface EnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
1372
1435
  /**
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
1436
+ * The expected plugins options for the Powerlines project.
1437
+ *
1438
+ * @remarks
1439
+ * 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
1440
  */
1375
- packageName?: string;
1376
- };
1377
- type CleanInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1441
+ plugins: EnvironmentContextPlugin<TResolvedConfig>[];
1378
1442
  /**
1379
- * A string identifier for the Powerlines command being executed
1443
+ * A function to add a plugin to the context and update the configuration options
1380
1444
  */
1381
- command: "clean";
1382
- };
1383
- type PrepareInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1445
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1384
1446
  /**
1385
- * A string identifier for the Powerlines command being executed
1447
+ * The environment specific resolved configuration
1386
1448
  */
1387
- command: "prepare";
1388
- };
1389
- type BuildInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1449
+ environment: EnvironmentResolvedConfig;
1390
1450
  /**
1391
- * A string identifier for the Powerlines command being executed
1451
+ * A table holding references to hook functions registered by plugins
1392
1452
  */
1393
- command: "build";
1394
- };
1395
- type LintInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1453
+ hooks: HooksList<PluginContext<TResolvedConfig>>;
1396
1454
  /**
1397
- * A string identifier for the Powerlines command being executed
1455
+ * Retrieves the hook handlers for a specific hook name
1398
1456
  */
1399
- command: "lint";
1400
- };
1401
- type DocsInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1457
+ selectHooks: <TKey extends HookKeys<PluginContext<TResolvedConfig>>>(hook: TKey, options?: SelectHooksOptions) => Hooks[TKey][];
1458
+ }
1459
+ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
1402
1460
  /**
1403
- * A string identifier for the Powerlines command being executed
1461
+ * The environment specific resolved configuration
1404
1462
  */
1405
- command: "docs";
1406
- };
1407
- type ReleaseInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1463
+ environment: EnvironmentResolvedConfig;
1408
1464
  /**
1409
- * A string identifier for the Powerlines command being executed
1465
+ * An alternative property name for the {@link log} property
1466
+ *
1467
+ * @remarks
1468
+ * This is provided for compatibility with other logging libraries that expect a `logger` property.
1410
1469
  */
1411
- command: "release";
1412
- };
1470
+ logger: LogFn;
1471
+ }
1472
+ type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = PluginContext<TResolvedConfig> & Omit<UnpluginBuildContext, "parse">;
1413
1473
 
1414
1474
  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 };