powerlines 0.13.0 → 0.14.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 (105) hide show
  1. package/dist/lib/build/esbuild.d.cts +13 -13
  2. package/dist/lib/build/esbuild.d.ts +13 -13
  3. package/dist/lib/build/index.cjs +18 -18
  4. package/dist/lib/build/index.d.cts +14 -14
  5. package/dist/lib/build/index.d.ts +14 -14
  6. package/dist/lib/build/index.js +3 -3
  7. package/dist/lib/build/rolldown.d.cts +13 -13
  8. package/dist/lib/build/rolldown.d.ts +13 -13
  9. package/dist/lib/build/rollup.d.cts +13 -13
  10. package/dist/lib/build/rollup.d.ts +13 -13
  11. package/dist/lib/build/rspack.d.cts +13 -13
  12. package/dist/lib/build/rspack.d.ts +13 -13
  13. package/dist/lib/build/tsup.d.cts +12 -12
  14. package/dist/lib/build/tsup.d.ts +12 -12
  15. package/dist/lib/build/unbuild.cjs +5 -5
  16. package/dist/lib/build/unbuild.d.cts +14 -14
  17. package/dist/lib/build/unbuild.d.ts +14 -14
  18. package/dist/lib/build/unbuild.js +2 -2
  19. package/dist/lib/build/vite.d.cts +13 -13
  20. package/dist/lib/build/vite.d.ts +13 -13
  21. package/dist/lib/build/webpack.d.cts +13 -13
  22. package/dist/lib/build/webpack.d.ts +13 -13
  23. package/dist/lib/chunk-5PNLONNN.cjs +30 -0
  24. package/dist/lib/chunk-5PNLONNN.cjs.map +1 -0
  25. package/dist/lib/{chunk-2625RJNJ.cjs → chunk-7LLECRBP.cjs} +2 -2
  26. package/dist/lib/chunk-7LLECRBP.cjs.map +1 -0
  27. package/dist/lib/{chunk-S4TGQD45.js → chunk-CAPN4FSS.js} +3 -3
  28. package/dist/lib/{chunk-S4TGQD45.js.map → chunk-CAPN4FSS.js.map} +1 -1
  29. package/dist/lib/chunk-HJWJNSSZ.js +3 -0
  30. package/dist/lib/{chunk-CLOW34EQ.js.map → chunk-HJWJNSSZ.js.map} +1 -1
  31. package/dist/lib/chunk-LEIOWD2W.js +28 -0
  32. package/dist/lib/chunk-LEIOWD2W.js.map +1 -0
  33. package/dist/lib/{chunk-GTQZYDA7.js → chunk-ODJBZ6PS.js} +2 -2
  34. package/dist/lib/chunk-ODJBZ6PS.js.map +1 -0
  35. package/dist/lib/chunk-XQMVE2NH.cjs +4 -0
  36. package/dist/lib/{chunk-UYDY7RRQ.cjs.map → chunk-XQMVE2NH.cjs.map} +1 -1
  37. package/dist/lib/{chunk-BAC4AJEP.cjs → chunk-YVDJCVE5.cjs} +3 -3
  38. package/dist/lib/{chunk-BAC4AJEP.cjs.map → chunk-YVDJCVE5.cjs.map} +1 -1
  39. package/dist/lib/{context-CyvlnBhJ.d.ts → config-DnifzkPt.d.ts} +555 -555
  40. package/dist/lib/{context-C2kRqM7P.d.cts → config-Ro14HmyO.d.cts} +555 -555
  41. package/dist/lib/config-file.d.cts +12 -12
  42. package/dist/lib/config-file.d.ts +12 -12
  43. package/dist/lib/create-program.d.cts +13 -13
  44. package/dist/lib/create-program.d.ts +13 -13
  45. package/dist/lib/entry.d.cts +13 -13
  46. package/dist/lib/entry.d.ts +13 -13
  47. package/dist/lib/{hooks-CzUm_Tex.d.cts → hooks-B6Ow5MtE.d.ts} +1 -1
  48. package/dist/lib/{hooks-DC-ktHnL.d.ts → hooks-CM-BbMzz.d.cts} +1 -1
  49. package/dist/lib/index.cjs +16 -11
  50. package/dist/lib/index.d.cts +16 -15
  51. package/dist/lib/index.d.ts +16 -15
  52. package/dist/lib/index.js +4 -3
  53. package/dist/lib/logger.d.cts +12 -12
  54. package/dist/lib/logger.d.ts +12 -12
  55. package/dist/lib/typescript/compiler-host.d.cts +13 -13
  56. package/dist/lib/typescript/compiler-host.d.ts +13 -13
  57. package/dist/lib/typescript/import-transformer.d.cts +13 -13
  58. package/dist/lib/typescript/import-transformer.d.ts +13 -13
  59. package/dist/lib/typescript/index.d.cts +13 -13
  60. package/dist/lib/typescript/index.d.ts +13 -13
  61. package/dist/lib/typescript/program.d.cts +13 -13
  62. package/dist/lib/typescript/program.d.ts +13 -13
  63. package/dist/lib/unplugin/factory.d.cts +13 -13
  64. package/dist/lib/unplugin/factory.d.ts +13 -13
  65. package/dist/lib/unplugin/index.d.cts +13 -13
  66. package/dist/lib/unplugin/index.d.ts +13 -13
  67. package/dist/lib/unplugin/plugin.d.cts +12 -12
  68. package/dist/lib/unplugin/plugin.d.ts +12 -12
  69. package/dist/lib/unplugin/resolve-id.d.cts +12 -12
  70. package/dist/lib/unplugin/resolve-id.d.ts +12 -12
  71. package/dist/lib/utilities/bundle.cjs +16 -0
  72. package/dist/lib/{bundle.d.cts → utilities/bundle.d.cts} +14 -14
  73. package/dist/lib/{bundle.d.ts → utilities/bundle.d.ts} +14 -14
  74. package/dist/lib/utilities/bundle.js +7 -0
  75. package/dist/lib/utilities/file-header.d.cts +13 -13
  76. package/dist/lib/utilities/file-header.d.ts +13 -13
  77. package/dist/lib/utilities/index.cjs +18 -6
  78. package/dist/lib/utilities/index.d.cts +18 -16
  79. package/dist/lib/utilities/index.d.ts +18 -16
  80. package/dist/lib/utilities/index.js +6 -2
  81. package/dist/lib/utilities/meta.d.cts +13 -13
  82. package/dist/lib/utilities/meta.d.ts +13 -13
  83. package/dist/lib/utilities/plugin-helpers.d.cts +12 -12
  84. package/dist/lib/utilities/plugin-helpers.d.ts +12 -12
  85. package/dist/lib/utilities/resolve-path.d.cts +13 -13
  86. package/dist/lib/utilities/resolve-path.d.ts +13 -13
  87. package/dist/lib/utilities/resolve.cjs +17 -0
  88. package/dist/lib/utilities/resolve.cjs.map +1 -0
  89. package/dist/lib/utilities/resolve.d.cts +44 -0
  90. package/dist/lib/utilities/resolve.d.ts +44 -0
  91. package/dist/lib/utilities/resolve.js +8 -0
  92. package/dist/lib/utilities/resolve.js.map +1 -0
  93. package/dist/lib/utilities/worker.d.cts +12 -12
  94. package/dist/lib/utilities/worker.d.ts +12 -12
  95. package/dist/lib/utilities/write-file.d.cts +13 -13
  96. package/dist/lib/utilities/write-file.d.ts +13 -13
  97. package/package.json +2 -2
  98. package/dist/lib/bundle.cjs +0 -16
  99. package/dist/lib/bundle.js +0 -7
  100. package/dist/lib/chunk-2625RJNJ.cjs.map +0 -1
  101. package/dist/lib/chunk-CLOW34EQ.js +0 -3
  102. package/dist/lib/chunk-GTQZYDA7.js.map +0 -1
  103. package/dist/lib/chunk-UYDY7RRQ.cjs +0 -4
  104. /package/dist/lib/{bundle.cjs.map → utilities/bundle.cjs.map} +0 -0
  105. /package/dist/lib/{bundle.js.map → utilities/bundle.js.map} +0 -0
@@ -1,14 +1,11 @@
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';
8
- import { MaybePromise, FunctionLike, NonUndefined } from '@stryke/types/base';
9
- import { TypeDefinitionParameter, TypeDefinition } from '@stryke/types/configuration';
1
+ import { Format } from '@storm-software/build-tools/types';
2
+ 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';
10
6
  import { AssetGlob } from '@stryke/types/file';
11
- import { UserConfig as UserConfig$1, PreviewOptions, ResolvedPreviewOptions } from 'vite';
7
+ import { ResolvedConfig as ResolvedConfig$1, ConfigLayer } from 'c12';
8
+ import { UserConfig as UserConfig$1, ResolvedPreviewOptions, PreviewOptions } from 'vite';
12
9
  import { UserConfig as UserConfig$2 } from '@farmfe/core';
13
10
  import { Configuration as Configuration$1 } from '@rspack/core';
14
11
  import { ESBuildOptions } from '@storm-software/esbuild/types';
@@ -17,12 +14,15 @@ import { BuildOptions } from 'esbuild';
17
14
  import { RolldownOptions, RolldownOutput } from 'rolldown';
18
15
  import { RollupOptions, OutputOptions } from 'rollup';
19
16
  import { Configuration } from 'webpack';
20
- import { Format } from '@storm-software/build-tools/types';
21
- import { LogLevelLabel } from '@storm-software/config-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';
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';
25
24
  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
28
  import { PathLike, StatSyncOptions, Stats, RmDirOptions, RmOptions, Mode, MakeDirectoryOptions as MakeDirectoryOptions$1, PathOrFileDescriptor, WriteFileOptions as WriteFileOptions$1 } from 'node:fs';
@@ -103,6 +103,82 @@ 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" | "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">> & {
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: "error" | "warn" | "info" | "debug" | "trace" | 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
+
106
182
  declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "release", "finalize"];
107
183
  type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
108
184
 
@@ -315,6 +391,35 @@ interface Plugin<in out TContext extends PluginContext<ResolvedConfig> = PluginC
315
391
  applyToEnvironment?: (environment: EnvironmentResolvedConfig) => MaybePromise<boolean | Plugin<any>>;
316
392
  }
317
393
 
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
+
318
423
  declare const __VFS_INIT__ = "__VFS_INIT__";
319
424
  declare const __VFS_REVERT__ = "__VFS_REVERT__";
320
425
  declare const __VFS_CACHE__ = "__VFS_CACHE__";
@@ -702,773 +807,668 @@ interface VirtualFileSystemInterface {
702
807
  [__VFS_UNIFIED__]: IUnionFs;
703
808
  }
704
809
 
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;
810
+ type WorkerProcess<TExposedMethods extends ReadonlyArray<string>> = {
811
+ [K in TExposedMethods[number]]: (data: any) => Promise<any>;
812
+ } & {
813
+ close: () => void;
814
+ end: () => ReturnType<Worker["end"]>;
724
815
  };
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 {
816
+ interface MetaInfo {
731
817
  /**
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\}"
818
+ * The checksum generated from the resolved options
740
819
  */
741
- outputPath?: string;
820
+ checksum: string;
742
821
  /**
743
- * The format of the output files
744
- *
745
- * @defaultValue "virtual"
822
+ * The build id
746
823
  */
747
- mode?: OutputModeType;
824
+ buildId: string;
748
825
  /**
749
- * The path of the generated runtime declaration file relative to the workspace root.
750
- *
751
- * @defaultValue "\{projectRoot\}/powerlines.d.ts"
826
+ * The release id
752
827
  */
753
- dts?: string | false;
828
+ releaseId: string;
754
829
  /**
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"
830
+ * The build timestamp
761
831
  */
762
- builtinPrefix?: string;
832
+ timestamp: number;
763
833
  /**
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"
834
+ * A hash that represents the path to the project root directory
770
835
  */
771
- artifactsFolder?: string;
836
+ projectRootHash: string;
772
837
  /**
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"
838
+ * A hash that represents the path to the project root directory
779
839
  */
780
- format?: Format | Format[];
840
+ configHash: string;
781
841
  /**
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.
842
+ * A mapping of runtime ids to their corresponding file paths
786
843
  */
787
- assets?: Array<string | AssetGlob>;
788
- }
789
- interface BaseConfig {
844
+ builtinIdMap: Record<string, string>;
790
845
  /**
791
- * The name of the project
846
+ * A mapping of virtual file paths to their corresponding file contents
792
847
  */
793
- name?: string;
848
+ virtualFiles: Record<string, string | null>;
849
+ }
850
+ interface Resolver extends Jiti {
851
+ plugin: Jiti;
852
+ }
853
+ interface SelectHooksOptions {
854
+ order?: "pre" | "post" | "normal";
855
+ }
856
+ interface InitContextOptions {
794
857
  /**
795
- * The project display title
858
+ * If false, the plugin will be loaded after all other plugins.
796
859
  *
797
- * @remarks
798
- * This option is used in documentation generation and other places where a human-readable title is needed.
860
+ * @defaultValue true
799
861
  */
800
- title?: string;
862
+ isHighPriority: boolean;
863
+ }
864
+ interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
801
865
  /**
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.
866
+ * The Storm workspace configuration
806
867
  */
807
- description?: string;
868
+ workspaceConfig: WorkspaceConfig;
808
869
  /**
809
- * The log level to use for the Powerlines processes.
810
- *
811
- * @defaultValue "info"
870
+ * An object containing the options provided to Powerlines
812
871
  */
813
- logLevel?: LogLevelLabel | null;
872
+ config: TResolvedConfig;
814
873
  /**
815
- * A custom logger function to use for logging messages
874
+ * A logging function for the Powerlines engine
816
875
  */
817
- customLogger?: LogFn;
876
+ log: LogFn;
818
877
  /**
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"
878
+ * The metadata information
822
879
  */
823
- mode?: "development" | "test" | "production";
880
+ meta: MetaInfo;
824
881
  /**
825
- * The entry point(s) for the application
882
+ * The metadata information currently written to disk
826
883
  */
827
- entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
884
+ persistedMeta?: MetaInfo;
828
885
  /**
829
- * Configuration for linting the source code
886
+ * The Powerlines artifacts directory
830
887
  */
831
- lint?: Record<string, any> | false;
888
+ artifactsPath: string;
832
889
  /**
833
- * Configuration for testing the source code
890
+ * The path to the Powerlines builtin runtime modules directory
834
891
  */
835
- test?: Record<string, any> | false;
892
+ builtinsPath: string;
836
893
  /**
837
- * Configuration for the output of the build process
894
+ * The path to the Powerlines entry modules directory
838
895
  */
839
- output?: OutputConfig;
896
+ entryPath: string;
840
897
  /**
841
- * Configuration for the transformation of the source code
898
+ * The path to the Powerlines TypeScript declaration files directory
842
899
  */
843
- transform?: Record<string, any>;
900
+ dtsPath: string;
844
901
  /**
845
- * Options to to provide to the build process
902
+ * The path to a directory where the reflection data buffers (used by the build processes) are stored
846
903
  */
847
- build?: BuildConfig;
904
+ dataPath: string;
848
905
  /**
849
- * Configuration for documentation generation
850
- *
851
- * @remarks
852
- * This configuration will be used by the documentation generation plugins during the `docs` command.
906
+ * The path to a directory where the project cache (used by the build processes) is stored
853
907
  */
854
- docs?: Record<string, any>;
908
+ cachePath: string;
855
909
  /**
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"
910
+ * The Powerlines environment paths
862
911
  */
863
- tsconfig?: string;
912
+ envPaths: EnvPaths;
864
913
  /**
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`
914
+ * The file system path to the Powerlines package installation
871
915
  */
872
- tsconfigRaw?: TSConfig;
873
- }
874
- interface EnvironmentConfig extends BaseConfig {
916
+ powerlinesPath: string;
875
917
  /**
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']`
918
+ * The relative path to the Powerlines workspace root directory
879
919
  */
880
- mainFields?: string[];
920
+ relativeToWorkspaceRoot: string;
881
921
  /**
882
- * Array of strings indicating what conditions should be used for module resolution.
922
+ * The project's `package.json` file content
883
923
  */
884
- conditions?: string[];
924
+ packageJson: PackageJson & Record<string, any>;
885
925
  /**
886
- * Array of strings indicating what conditions should be used for external modules.
926
+ * The project's `project.json` file content
887
927
  */
888
- externalConditions?: string[];
928
+ projectJson?: Record<string, any>;
889
929
  /**
890
- * Array of strings indicating what file extensions should be used for module resolution.
891
- *
892
- * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
930
+ * The dependency installations required by the project
893
931
  */
894
- extensions?: string[];
932
+ dependencies: Record<string, string | Range>;
895
933
  /**
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.
934
+ * The development dependency installations required by the project
900
935
  */
901
- dedupe?: string[];
936
+ devDependencies: Record<string, string | Range>;
902
937
  /**
903
- * Array of strings or regular expressions that indicate what modules are builtin for the environment.
938
+ * The parsed TypeScript configuration from the `tsconfig.json` file
904
939
  */
905
- builtins?: (string | RegExp)[];
940
+ tsconfig: ParsedTypeScriptConfig;
906
941
  /**
907
- * Configuration options for the preview server
942
+ * The entry points of the source code
908
943
  */
909
- preview?: PreviewOptions;
944
+ entry: ResolvedEntryTypeDefinition[];
910
945
  /**
911
- * A flag indicating whether the build is for a Server-Side Rendering environment.
946
+ * The virtual file system manager used during the build process to reference generated runtime files
912
947
  */
913
- ssr?: boolean;
948
+ fs: VirtualFileSystemInterface;
914
949
  /**
915
- * Define if this environment is used for Server-Side Rendering
916
- *
917
- * @defaultValue "server" (if it isn't the client environment)
950
+ * The Jiti module resolver
918
951
  */
919
- consumer?: "client" | "server";
920
- }
921
- interface CommonUserConfig extends BaseConfig {
952
+ resolver: Resolver;
922
953
  /**
923
- * The type of project being built
924
- *
925
- * @defaultValue "application"
954
+ * The builtin module id that exist in the Powerlines virtual file system
926
955
  */
927
- type?: ProjectType;
956
+ builtins: string[];
928
957
  /**
929
- * The root directory of the project
958
+ * The Powerlines builtin virtual files
930
959
  */
931
- root: string;
960
+ getBuiltins: () => Promise<VirtualFile[]>;
932
961
  /**
933
- * The root directory of the project's source code
962
+ * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
934
963
  *
935
- * @defaultValue "\{root\}/src"
964
+ * @param code - The source code of the builtin file
965
+ * @param id - The unique identifier of the builtin file
966
+ * @param path - An optional path to write the builtin file to
967
+ * @param options - Options for writing the file
936
968
  */
937
- sourceRoot?: string;
969
+ writeBuiltin: (code: string, id: string, path?: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
938
970
  /**
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.
971
+ * Resolves a entry virtual file and writes it to the VFS if it does not already exist
940
972
  *
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.
973
+ * @param code - The source code of the entry file
974
+ * @param path - An optional path to write the entry file to
975
+ * @param options - Options for writing the file
943
976
  */
944
- configFile?: string;
977
+ writeEntry: (code: string, path: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
945
978
  /**
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
979
+ * Parses the source code and returns a {@link ParseResult} object.
952
980
  */
953
- skipInstalls?: boolean;
981
+ parse: (code: string, id: string, options?: ParserOptions | null) => Promise<ParseResult>;
954
982
  /**
955
- * Should the compiler processes skip any improvements that make use of cache?
956
- *
957
- * @defaultValue false
983
+ * A function to update the context fields using a new user configuration options
958
984
  */
959
- skipCache?: boolean;
985
+ withUserConfig: (userConfig: UserConfig, options?: InitContextOptions) => Promise<void>;
960
986
  /**
961
- * A list of resolvable paths to plugins used during the build process
987
+ * A function to update the context fields using inline configuration options
962
988
  */
963
- plugins?: PluginConfig<PluginContext<any>>[];
989
+ withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
964
990
  /**
965
- * Environment-specific configurations
991
+ * Create a new logger instance
992
+ *
993
+ * @param name - The name to use for the logger instance
994
+ * @returns A logger function
966
995
  */
967
- environments?: Record<string, EnvironmentConfig>;
996
+ createLog: (name: string | null) => LogFn;
968
997
  /**
969
- * A string identifier that allows a child framework or tool to identify itself when using Powerlines.
998
+ * Extend the current logger instance with a new name
970
999
  *
971
- * @defaultValue "powerlines"
1000
+ * @param name - The name to use for the extended logger instance
1001
+ * @returns A logger function
972
1002
  */
973
- framework?: string;
1003
+ extendLog: (name: string) => LogFn;
974
1004
  }
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> & {
1005
+ interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
998
1006
  /**
999
- * The path to the user configuration file, if it exists.
1007
+ * The expected plugins options for the Powerlines project.
1000
1008
  *
1001
1009
  * @remarks
1002
- * This is typically the `powerlines.json`, `powerlines.config.js`, or `powerlines.config.ts` file in the project root.
1010
+ * 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.
1003
1011
  */
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> & {
1012
+ plugins: Plugin<PluginContext<TResolvedConfig>>[];
1011
1013
  /**
1012
- * A string identifier for the Powerlines command being executed
1014
+ * A function to add a plugin to the context and update the configuration options
1013
1015
  */
1014
- command: PowerlinesCommand;
1015
- };
1016
- type NewInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
1016
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1017
1017
  /**
1018
- * A string identifier for the Powerlines command being executed
1018
+ * A table for storing the current context for each configured environment
1019
1019
  */
1020
- command: "new";
1020
+ environments: Record<string, EnvironmentContext<TResolvedConfig>>;
1021
1021
  /**
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
1022
+ * Retrieves the context for a specific environment by name
1023
+ *
1024
+ * @throws Will throw an error if the environment does not exist
1025
+ *
1026
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
1027
+ * @returns A promise that resolves to the environment context.
1028
+ *
1029
+ * @example
1030
+ * ```ts
1031
+ * const devEnv = await apiContext.getEnvironment("development");
1032
+ * const defaultEnv = await apiContext.getEnvironment();
1033
+ * ```
1023
1034
  */
1024
- packageName?: string;
1025
- };
1026
- type CleanInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1035
+ getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
1027
1036
  /**
1028
- * A string identifier for the Powerlines command being executed
1037
+ * Safely retrieves the context for a specific environment by name
1038
+ *
1039
+ * @param name - The name of the environment to retrieve. If not provided, the default environment is returned.
1040
+ * @returns A promise that resolves to the environment context, or undefined if the environment does not exist.
1041
+ *
1042
+ * @example
1043
+ * ```ts
1044
+ * const devEnv = await apiContext.getEnvironmentSafe("development");
1045
+ * const defaultEnv = await apiContext.getEnvironmentSafe();
1046
+ * ```
1047
+ *
1048
+ * @remarks
1049
+ * This method is similar to `getEnvironment`, but it returns `undefined` instead of throwing an error if the specified environment does not exist.
1050
+ * This can be useful in scenarios where the existence of an environment is optional or uncertain.
1051
+ *
1052
+ * ```ts
1053
+ * const testEnv = await apiContext.getEnvironmentSafe("test");
1054
+ * if (testEnv) {
1055
+ * // Environment exists, safe to use it
1056
+ * } else {
1057
+ * // Environment does not exist, handle accordingly
1058
+ * }
1059
+ * ```
1060
+ *
1061
+ * Using this method helps avoid unhandled exceptions in cases where an environment might not be defined.
1029
1062
  */
1030
- command: "clean";
1031
- };
1032
- type PrepareInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1033
- /**
1034
- * A string identifier for the Powerlines command being executed
1035
- */
1036
- command: "prepare";
1037
- };
1038
- type BuildInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1063
+ getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
1039
1064
  /**
1040
- * A string identifier for the Powerlines command being executed
1065
+ * A function to copy the context and update the fields for a specific environment
1066
+ *
1067
+ * @param environment - The environment configuration to use.
1068
+ * @returns A new context instance with the updated environment.
1041
1069
  */
1042
- command: "build";
1043
- };
1044
- type LintInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1070
+ in: (environment: EnvironmentResolvedConfig) => Promise<EnvironmentContext<TResolvedConfig>>;
1071
+ }
1072
+ interface EnvironmentContextPlugin<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1073
+ plugin: Plugin<PluginContext<TResolvedConfig>>;
1074
+ context: PluginContext<TResolvedConfig>;
1075
+ }
1076
+ interface EnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
1045
1077
  /**
1046
- * A string identifier for the Powerlines command being executed
1078
+ * The expected plugins options for the Powerlines project.
1079
+ *
1080
+ * @remarks
1081
+ * 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.
1047
1082
  */
1048
- command: "lint";
1049
- };
1050
- type DocsInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1083
+ plugins: EnvironmentContextPlugin<TResolvedConfig>[];
1051
1084
  /**
1052
- * A string identifier for the Powerlines command being executed
1085
+ * A function to add a plugin to the context and update the configuration options
1053
1086
  */
1054
- command: "docs";
1055
- };
1056
- type ReleaseInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1087
+ addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1057
1088
  /**
1058
- * A string identifier for the Powerlines command being executed
1089
+ * The environment specific resolved configuration
1059
1090
  */
1060
- command: "release";
1061
- };
1062
-
1063
- interface ResolvedEntryTypeDefinition extends TypeDefinition {
1091
+ environment: EnvironmentResolvedConfig;
1064
1092
  /**
1065
- * The user provided entry point in the source code
1093
+ * A table holding references to hook functions registered by plugins
1066
1094
  */
1067
- input: TypeDefinition;
1095
+ hooks: HooksList<PluginContext<TResolvedConfig>>;
1068
1096
  /**
1069
- * An optional name to use in the package export during the build process
1097
+ * Retrieves the hook handlers for a specific hook name
1070
1098
  */
1071
- output?: string;
1099
+ selectHooks: <TKey extends HookKeys<PluginContext<TResolvedConfig>>>(hook: TKey, options?: SelectHooksOptions) => Hooks[TKey][];
1072
1100
  }
1073
- type EnvironmentResolvedConfig = Omit<EnvironmentConfig, "consumer" | "mode" | "ssr" | "preview" | "mainFields" | "extensions"> & Required<Pick<EnvironmentConfig, "consumer" | "mode" | "ssr" | "mainFields" | "extensions">> & {
1101
+ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig>, UnpluginContext {
1074
1102
  /**
1075
- * The name of the environment
1103
+ * The environment specific resolved configuration
1076
1104
  */
1077
- name: string;
1105
+ environment: EnvironmentResolvedConfig;
1078
1106
  /**
1079
- * Configuration options for the preview server
1107
+ * An alternative property name for the {@link log} property
1108
+ *
1109
+ * @remarks
1110
+ * This is provided for compatibility with other logging libraries that expect a `logger` property.
1080
1111
  */
1081
- preview?: ResolvedPreviewOptions;
1112
+ logger: LogFn;
1113
+ }
1114
+ type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = PluginContext<TResolvedConfig> & Omit<UnpluginBuildContext, "parse">;
1115
+
1116
+ type LogFn = (type: LogLevelLabel, ...args: string[]) => void;
1117
+ /**
1118
+ * The {@link StormWorkspaceConfig | configuration} object for an entire Powerlines workspace
1119
+ */
1120
+ type WorkspaceConfig = Partial<StormWorkspaceConfig> & Required<Pick<StormWorkspaceConfig, "workspaceRoot">>;
1121
+ type PluginFactory<in out TContext extends PluginContext = PluginContext, TOptions = any> = (options: TOptions) => MaybePromise<Plugin<TContext>>;
1122
+ /**
1123
+ * A configuration tuple for a Powerlines plugin.
1124
+ */
1125
+ type PluginConfigTuple<TContext extends PluginContext = PluginContext, TOptions = any> = [string | PluginFactory<TContext, TOptions>, TOptions] | [Plugin<TContext>];
1126
+ /**
1127
+ * A configuration object for a Powerlines plugin.
1128
+ */
1129
+ type PluginConfigObject<TContext extends PluginContext = PluginContext, TOptions = any> = {
1130
+ plugin: string | PluginFactory<TContext, TOptions>;
1131
+ options: TOptions;
1132
+ } | {
1133
+ plugin: Plugin<TContext>;
1134
+ options?: never;
1082
1135
  };
1083
- type ResolvedAssetGlob = AssetGlob & Required<Pick<AssetGlob, "input">>;
1084
- type OutputResolvedConfig = Required<Omit<OutputConfig, "assets"> & {
1085
- assets: ResolvedAssetGlob[];
1086
- }>;
1087
1136
  /**
1088
- * The resolved options for the Powerlines project configuration.
1137
+ * A configuration tuple for a Powerlines plugin.
1089
1138
  */
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">> & {
1091
- /**
1092
- * The configuration options that were provided inline to the Powerlines CLI.
1093
- */
1094
- inlineConfig: InlineConfig<TUserConfig>;
1095
- /**
1096
- * The original configuration options that were provided by the user to the Powerlines process.
1097
- */
1098
- userConfig: TUserConfig;
1099
- /**
1100
- * A string identifier for the Powerlines command being executed.
1101
- */
1102
- command: NonUndefined<InlineConfig<TUserConfig>["command"]>;
1139
+ type PluginConfig<TContext extends PluginContext = PluginContext> = string | PluginFactory<TContext, void> | Plugin<TContext> | Promise<Plugin<TContext>> | PluginConfigTuple<TContext> | PluginConfigObject<TContext>;
1140
+ type ProjectType = "application" | "library";
1141
+ interface OutputConfig {
1103
1142
  /**
1104
- * The root directory of the project's source code
1143
+ * The path to output the final compiled files to
1105
1144
  *
1106
- * @defaultValue "\{projectRoot\}/src"
1107
- */
1108
- sourceRoot: NonUndefined<TUserConfig["sourceRoot"]>;
1109
- /**
1110
- * The root directory of the project.
1111
- */
1112
- projectRoot: NonUndefined<TUserConfig["root"]>;
1113
- /**
1114
- * The type of project being built.
1115
- */
1116
- projectType: NonUndefined<TUserConfig["type"]>;
1117
- /**
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.
1145
+ * @remarks
1146
+ * If a value is not provided, Powerlines will attempt to:
1147
+ * 1. Use the `outDir` value in the `tsconfig.json` file.
1148
+ * 2. Use the `dist` directory in the project root directory.
1123
1149
  *
1124
- * @defaultValue "info"
1125
- */
1126
- logLevel: "error" | "warn" | "info" | "debug" | "trace" | 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>;
1147
- }
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 {
1175
- /**
1176
- * The checksum generated from the resolved options
1177
- */
1178
- checksum: string;
1179
- /**
1180
- * The build id
1181
- */
1182
- buildId: string;
1183
- /**
1184
- * The release id
1150
+ * @defaultValue "dist/\{projectRoot\}"
1185
1151
  */
1186
- releaseId: string;
1152
+ outputPath?: string;
1187
1153
  /**
1188
- * The build timestamp
1154
+ * The format of the output files
1155
+ *
1156
+ * @defaultValue "virtual"
1189
1157
  */
1190
- timestamp: number;
1158
+ mode?: OutputModeType;
1191
1159
  /**
1192
- * A hash that represents the path to the project root directory
1160
+ * The path of the generated runtime declaration file relative to the workspace root.
1161
+ *
1162
+ * @defaultValue "\{projectRoot\}/powerlines.d.ts"
1193
1163
  */
1194
- projectRootHash: string;
1164
+ dts?: string | false;
1195
1165
  /**
1196
- * A hash that represents the path to the project root directory
1166
+ * A prefix to use for identifying builtin modules
1167
+ *
1168
+ * @remarks
1169
+ * 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"`.
1170
+ *
1171
+ * @defaultValue "powerlines"
1197
1172
  */
1198
- configHash: string;
1173
+ builtinPrefix?: string;
1199
1174
  /**
1200
- * A mapping of runtime ids to their corresponding file paths
1175
+ * The folder where the generated runtime artifacts will be located
1176
+ *
1177
+ * @remarks
1178
+ * This folder will contain all runtime artifacts and builtins generated during the "prepare" phase.
1179
+ *
1180
+ * @defaultValue "\{projectRoot\}/.powerlines"
1201
1181
  */
1202
- builtinIdMap: Record<string, string>;
1182
+ artifactsFolder?: string;
1203
1183
  /**
1204
- * A mapping of virtual file paths to their corresponding file contents
1184
+ * The module format of the output files
1185
+ *
1186
+ * @remarks
1187
+ * 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.
1188
+ *
1189
+ * @defaultValue "esm"
1205
1190
  */
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 {
1191
+ format?: Format | Format[];
1215
1192
  /**
1216
- * If false, the plugin will be loaded after all other plugins.
1193
+ * A list of assets to copy to the output directory
1217
1194
  *
1218
- * @defaultValue true
1195
+ * @remarks
1196
+ * 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.
1219
1197
  */
1220
- isHighPriority: boolean;
1198
+ assets?: Array<string | AssetGlob>;
1221
1199
  }
1222
- interface Context<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
1223
- /**
1224
- * The Storm workspace configuration
1225
- */
1226
- workspaceConfig: WorkspaceConfig;
1200
+ interface BaseConfig {
1227
1201
  /**
1228
- * An object containing the options provided to Powerlines
1202
+ * The name of the project
1229
1203
  */
1230
- config: TResolvedConfig;
1204
+ name?: string;
1231
1205
  /**
1232
- * A logging function for the Powerlines engine
1206
+ * The project display title
1207
+ *
1208
+ * @remarks
1209
+ * This option is used in documentation generation and other places where a human-readable title is needed.
1233
1210
  */
1234
- log: LogFn;
1211
+ title?: string;
1235
1212
  /**
1236
- * The metadata information
1213
+ * A description of the project
1214
+ *
1215
+ * @remarks
1216
+ * If this option is not provided, the build process will try to use the \`description\` value from the `\package.json\` file.
1237
1217
  */
1238
- meta: MetaInfo;
1218
+ description?: string;
1239
1219
  /**
1240
- * The metadata information currently written to disk
1220
+ * The log level to use for the Powerlines processes.
1221
+ *
1222
+ * @defaultValue "info"
1241
1223
  */
1242
- persistedMeta?: MetaInfo;
1224
+ logLevel?: LogLevelLabel | null;
1243
1225
  /**
1244
- * The Powerlines artifacts directory
1226
+ * A custom logger function to use for logging messages
1245
1227
  */
1246
- artifactsPath: string;
1228
+ customLogger?: LogFn;
1247
1229
  /**
1248
- * The path to the Powerlines builtin runtime modules directory
1230
+ * 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.
1231
+ *
1232
+ * @defaultValue "production"
1249
1233
  */
1250
- builtinsPath: string;
1234
+ mode?: "development" | "test" | "production";
1251
1235
  /**
1252
- * The path to the Powerlines entry modules directory
1236
+ * The entry point(s) for the application
1253
1237
  */
1254
- entryPath: string;
1238
+ entry?: TypeDefinitionParameter | TypeDefinitionParameter[];
1255
1239
  /**
1256
- * The path to the Powerlines TypeScript declaration files directory
1240
+ * Configuration for linting the source code
1257
1241
  */
1258
- dtsPath: string;
1242
+ lint?: Record<string, any> | false;
1259
1243
  /**
1260
- * The path to a directory where the reflection data buffers (used by the build processes) are stored
1244
+ * Configuration for testing the source code
1261
1245
  */
1262
- dataPath: string;
1246
+ test?: Record<string, any> | false;
1263
1247
  /**
1264
- * The path to a directory where the project cache (used by the build processes) is stored
1248
+ * Configuration for the output of the build process
1265
1249
  */
1266
- cachePath: string;
1250
+ output?: OutputConfig;
1267
1251
  /**
1268
- * The Powerlines environment paths
1252
+ * Configuration for the transformation of the source code
1269
1253
  */
1270
- envPaths: EnvPaths;
1254
+ transform?: Record<string, any>;
1271
1255
  /**
1272
- * The file system path to the Powerlines package installation
1256
+ * Options to to provide to the build process
1273
1257
  */
1274
- powerlinesPath: string;
1258
+ build?: BuildConfig;
1275
1259
  /**
1276
- * The relative path to the Powerlines workspace root directory
1260
+ * Configuration for documentation generation
1261
+ *
1262
+ * @remarks
1263
+ * This configuration will be used by the documentation generation plugins during the `docs` command.
1277
1264
  */
1278
- relativeToWorkspaceRoot: string;
1265
+ docs?: Record<string, any>;
1279
1266
  /**
1280
- * The project's `package.json` file content
1267
+ * The path to the tsconfig file to be used by the compiler
1268
+ *
1269
+ * @remarks
1270
+ * 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).
1271
+ *
1272
+ * @defaultValue "\{projectRoot\}/tsconfig.json"
1281
1273
  */
1282
- packageJson: PackageJson & Record<string, any>;
1274
+ tsconfig?: string;
1283
1275
  /**
1284
- * The project's `project.json` file content
1276
+ * The raw {@link TSConfig} object to be used by the compiler. This object will be merged with the `tsconfig.json` file.
1277
+ *
1278
+ * @see https://www.typescriptlang.org/tsconfig
1279
+ *
1280
+ * @remarks
1281
+ * If populated, this option takes higher priority than `tsconfig`
1285
1282
  */
1286
- projectJson?: Record<string, any>;
1283
+ tsconfigRaw?: TSConfig;
1284
+ }
1285
+ interface EnvironmentConfig extends BaseConfig {
1287
1286
  /**
1288
- * The dependency installations required by the project
1287
+ * 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.
1288
+ *
1289
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
1289
1290
  */
1290
- dependencies: Record<string, string | Range>;
1291
+ mainFields?: string[];
1291
1292
  /**
1292
- * The development dependency installations required by the project
1293
+ * Array of strings indicating what conditions should be used for module resolution.
1293
1294
  */
1294
- devDependencies: Record<string, string | Range>;
1295
+ conditions?: string[];
1295
1296
  /**
1296
- * The parsed TypeScript configuration from the `tsconfig.json` file
1297
+ * Array of strings indicating what conditions should be used for external modules.
1297
1298
  */
1298
- tsconfig: ParsedTypeScriptConfig;
1299
+ externalConditions?: string[];
1299
1300
  /**
1300
- * The entry points of the source code
1301
+ * Array of strings indicating what file extensions should be used for module resolution.
1302
+ *
1303
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
1301
1304
  */
1302
- entry: ResolvedEntryTypeDefinition[];
1305
+ extensions?: string[];
1303
1306
  /**
1304
- * The virtual file system manager used during the build process to reference generated runtime files
1307
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
1308
+ *
1309
+ * @remarks
1310
+ * 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.
1305
1311
  */
1306
- fs: VirtualFileSystemInterface;
1312
+ dedupe?: string[];
1307
1313
  /**
1308
- * The Jiti module resolver
1314
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
1309
1315
  */
1310
- resolver: Resolver;
1316
+ builtins?: (string | RegExp)[];
1311
1317
  /**
1312
- * The builtin module id that exist in the Powerlines virtual file system
1318
+ * Configuration options for the preview server
1313
1319
  */
1314
- builtins: string[];
1320
+ preview?: PreviewOptions;
1315
1321
  /**
1316
- * The Powerlines builtin virtual files
1322
+ * A flag indicating whether the build is for a Server-Side Rendering environment.
1317
1323
  */
1318
- getBuiltins: () => Promise<VirtualFile[]>;
1324
+ ssr?: boolean;
1319
1325
  /**
1320
- * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
1326
+ * Define if this environment is used for Server-Side Rendering
1321
1327
  *
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
1328
+ * @defaultValue "server" (if it isn't the client environment)
1326
1329
  */
1327
- writeBuiltin: (code: string, id: string, path?: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1330
+ consumer?: "client" | "server";
1331
+ }
1332
+ interface CommonUserConfig extends BaseConfig {
1328
1333
  /**
1329
- * Resolves a entry virtual file and writes it to the VFS if it does not already exist
1334
+ * The type of project being built
1330
1335
  *
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
1334
- */
1335
- writeEntry: (code: string, path: string, options?: PowerlinesWriteFileOptions) => Promise<void>;
1336
- /**
1337
- * Parses the source code and returns a {@link ParseResult} object.
1336
+ * @defaultValue "application"
1338
1337
  */
1339
- parse: (code: string, id: string, options?: ParserOptions | null) => Promise<ParseResult>;
1338
+ type?: ProjectType;
1340
1339
  /**
1341
- * A function to update the context fields using a new user configuration options
1340
+ * The root directory of the project
1342
1341
  */
1343
- withUserConfig: (userConfig: UserConfig, options?: InitContextOptions) => Promise<void>;
1342
+ root: string;
1344
1343
  /**
1345
- * A function to update the context fields using inline configuration options
1344
+ * The root directory of the project's source code
1345
+ *
1346
+ * @defaultValue "\{root\}/src"
1346
1347
  */
1347
- withInlineConfig: (inlineConfig: InlineConfig, options?: InitContextOptions) => Promise<void>;
1348
+ sourceRoot?: string;
1348
1349
  /**
1349
- * Create a new logger instance
1350
+ * A path to a custom configuration file to be used instead of the default `storm.json`, `powerlines.config.js`, or `powerlines.config.ts` files.
1350
1351
  *
1351
- * @param name - The name to use for the logger instance
1352
- * @returns A logger function
1352
+ * @remarks
1353
+ * This option is useful for running Powerlines commands with different configuration files, such as in CI/CD environments or when testing different configurations.
1353
1354
  */
1354
- createLog: (name: string | null) => LogFn;
1355
+ configFile?: string;
1355
1356
  /**
1356
- * Extend the current logger instance with a new name
1357
+ * Should the Powerlines CLI processes skip installing missing packages?
1357
1358
  *
1358
- * @param name - The name to use for the extended logger instance
1359
- * @returns A logger function
1359
+ * @remarks
1360
+ * This option is useful for CI/CD environments where the installation of packages is handled by a different process.
1361
+ *
1362
+ * @defaultValue false
1360
1363
  */
1361
- extendLog: (name: string) => LogFn;
1362
- }
1363
- interface APIContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends Context<TResolvedConfig> {
1364
+ skipInstalls?: boolean;
1364
1365
  /**
1365
- * The expected plugins options for the Powerlines project.
1366
+ * Should the compiler processes skip any improvements that make use of cache?
1366
1367
  *
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.
1368
+ * @defaultValue false
1369
1369
  */
1370
- plugins: Plugin<PluginContext<TResolvedConfig>>[];
1370
+ skipCache?: boolean;
1371
1371
  /**
1372
- * A function to add a plugin to the context and update the configuration options
1372
+ * A list of resolvable paths to plugins used during the build process
1373
1373
  */
1374
- addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1374
+ plugins?: PluginConfig<PluginContext<any>>[];
1375
1375
  /**
1376
- * A table for storing the current context for each configured environment
1376
+ * Environment-specific configurations
1377
1377
  */
1378
- environments: Record<string, EnvironmentContext<TResolvedConfig>>;
1378
+ environments?: Record<string, EnvironmentConfig>;
1379
1379
  /**
1380
- * Retrieves the context for a specific environment by name
1381
- *
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.
1380
+ * A string identifier that allows a child framework or tool to identify itself when using Powerlines.
1386
1381
  *
1387
- * @example
1388
- * ```ts
1389
- * const devEnv = await apiContext.getEnvironment("development");
1390
- * const defaultEnv = await apiContext.getEnvironment();
1391
- * ```
1382
+ * @defaultValue "powerlines"
1392
1383
  */
1393
- getEnvironment: (name?: string) => Promise<EnvironmentContext<TResolvedConfig>>;
1384
+ framework?: string;
1385
+ }
1386
+ type UserConfig<TBuildConfig extends BuildConfig = BuildConfig, TBuildResolvedConfig extends BuildResolvedConfig = BuildResolvedConfig, TBuildVariant extends string = any> = CommonUserConfig & {
1387
+ build?: TBuildConfig & {
1388
+ /**
1389
+ * The build variant being used by the Powerlines engine.
1390
+ */
1391
+ variant?: TBuildVariant;
1392
+ };
1393
+ override?: Partial<TBuildResolvedConfig>;
1394
+ };
1395
+ type WebpackUserConfig = UserConfig<WebpackBuildConfig, WebpackResolvedBuildConfig, "webpack">;
1396
+ type RspackUserConfig = UserConfig<RspackBuildConfig, RspackResolvedBuildConfig, "rspack">;
1397
+ type RollupUserConfig = UserConfig<RollupBuildConfig, RollupResolvedBuildConfig, "rollup">;
1398
+ type RolldownUserConfig = UserConfig<RolldownBuildConfig, RolldownResolvedBuildConfig, "rolldown">;
1399
+ type ViteUserConfig = UserConfig<ViteBuildConfig, ViteResolvedBuildConfig, "vite">;
1400
+ type ESBuildUserConfig = UserConfig<ESBuildBuildConfig, ESBuildResolvedBuildConfig, "esbuild">;
1401
+ type UnbuildUserConfig = UserConfig<UnbuildBuildConfig, UnbuildResolvedBuildConfig, "unbuild">;
1402
+ type TsupUserConfig = UserConfig<TsupBuildConfig, TsupResolvedBuildConfig, "tsup">;
1403
+ type FarmUserConfig = UserConfig<FarmBuildConfig, FarmResolvedBuildConfig, "farm">;
1404
+ 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;
1405
+ type InitialUserConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserConfig> & {
1406
+ root: string;
1407
+ };
1408
+ type ParsedUserConfig<TUserConfig extends UserConfig = UserConfig> = TUserConfig & ResolvedConfig$1<TUserConfig> & {
1394
1409
  /**
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
- * ```
1410
+ * The path to the user configuration file, if it exists.
1405
1411
  *
1406
1412
  * @remarks
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.
1413
+ * This is typically the `powerlines.json`, `powerlines.config.js`, or `powerlines.config.ts` file in the project root.
1420
1414
  */
1421
- getEnvironmentSafe: (name?: string) => Promise<EnvironmentContext<TResolvedConfig> | undefined>;
1415
+ configFile?: ConfigLayer<TUserConfig>["configFile"];
1416
+ };
1417
+ type PowerlinesCommand = "new" | "prepare" | "build" | "lint" | "test" | "docs" | "release" | "clean";
1418
+ /**
1419
+ * The configuration provided while executing Powerlines commands.
1420
+ */
1421
+ type InlineConfig<TUserConfig extends UserConfig = UserConfig> = Partial<TUserConfig> & {
1422
1422
  /**
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.
1423
+ * A string identifier for the Powerlines command being executed
1427
1424
  */
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> {
1425
+ command: PowerlinesCommand;
1426
+ };
1427
+ type NewInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & Required<Pick<InlineConfig<TUserConfig>, "root">> & {
1435
1428
  /**
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.
1429
+ * A string identifier for the Powerlines command being executed
1440
1430
  */
1441
- plugins: EnvironmentContextPlugin<TResolvedConfig>[];
1431
+ command: "new";
1442
1432
  /**
1443
- * A function to add a plugin to the context and update the configuration options
1433
+ * 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
1444
1434
  */
1445
- addPlugin: (plugin: Plugin<PluginContext<TResolvedConfig>>) => Promise<void>;
1435
+ packageName?: string;
1436
+ };
1437
+ type CleanInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1446
1438
  /**
1447
- * The environment specific resolved configuration
1439
+ * A string identifier for the Powerlines command being executed
1448
1440
  */
1449
- environment: EnvironmentResolvedConfig;
1441
+ command: "clean";
1442
+ };
1443
+ type PrepareInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1450
1444
  /**
1451
- * A table holding references to hook functions registered by plugins
1445
+ * A string identifier for the Powerlines command being executed
1452
1446
  */
1453
- hooks: HooksList<PluginContext<TResolvedConfig>>;
1447
+ command: "prepare";
1448
+ };
1449
+ type BuildInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1454
1450
  /**
1455
- * Retrieves the hook handlers for a specific hook name
1451
+ * A string identifier for the Powerlines command being executed
1456
1452
  */
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 {
1453
+ command: "build";
1454
+ };
1455
+ type LintInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1460
1456
  /**
1461
- * The environment specific resolved configuration
1457
+ * A string identifier for the Powerlines command being executed
1462
1458
  */
1463
- environment: EnvironmentResolvedConfig;
1459
+ command: "lint";
1460
+ };
1461
+ type DocsInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1464
1462
  /**
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.
1463
+ * A string identifier for the Powerlines command being executed
1469
1464
  */
1470
- logger: LogFn;
1471
- }
1472
- type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = PluginContext<TResolvedConfig> & Omit<UnpluginBuildContext, "parse">;
1465
+ command: "docs";
1466
+ };
1467
+ type ReleaseInlineConfig<TUserConfig extends UserConfig = UserConfig> = InlineConfig<TUserConfig> & {
1468
+ /**
1469
+ * A string identifier for the Powerlines command being executed
1470
+ */
1471
+ command: "release";
1472
+ };
1473
1473
 
1474
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 };