@powerlines/engine 0.45.3 → 0.46.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 (52) hide show
  1. package/dist/_internal/worker.cjs +844 -789
  2. package/dist/_internal/worker.mjs +847 -792
  3. package/dist/_internal/worker.mjs.map +1 -1
  4. package/dist/api.cjs +292 -323
  5. package/dist/api.d.cts +44 -11
  6. package/dist/api.d.cts.map +1 -1
  7. package/dist/api.d.mts +44 -11
  8. package/dist/api.d.mts.map +1 -1
  9. package/dist/api.mjs +292 -323
  10. package/dist/api.mjs.map +1 -1
  11. package/dist/{base-context-Byizvf4F.cjs → base-context-BCG0xN2e.cjs} +70 -64
  12. package/dist/{base-context-BSAC5sO9.mjs → base-context-Cmo6TTh7.mjs} +73 -67
  13. package/dist/base-context-Cmo6TTh7.mjs.map +1 -0
  14. package/dist/context/index.cjs +3 -3
  15. package/dist/context/index.d.cts +44 -617
  16. package/dist/context/index.d.cts.map +1 -1
  17. package/dist/context/index.d.mts +44 -617
  18. package/dist/context/index.d.mts.map +1 -1
  19. package/dist/context/index.mjs +3 -3
  20. package/dist/engine-context-BjFMVQEE.mjs +86 -0
  21. package/dist/engine-context-BjFMVQEE.mjs.map +1 -0
  22. package/dist/engine-context-DOsGtgD9.cjs +91 -0
  23. package/dist/execution-context-BdZt7wWa.d.mts +631 -0
  24. package/dist/execution-context-BdZt7wWa.d.mts.map +1 -0
  25. package/dist/execution-context-CU6iNchD.d.cts +631 -0
  26. package/dist/execution-context-CU6iNchD.d.cts.map +1 -0
  27. package/dist/{execution-context-Bkxp1fML.mjs → execution-context-Cp32TarF.mjs} +421 -364
  28. package/dist/execution-context-Cp32TarF.mjs.map +1 -0
  29. package/dist/{execution-context-BYGFYty0.cjs → execution-context-DgqxcDDx.cjs} +419 -362
  30. package/dist/index.cjs +15 -16
  31. package/dist/index.d.cts +3 -3
  32. package/dist/index.d.cts.map +1 -1
  33. package/dist/index.d.mts +3 -3
  34. package/dist/index.d.mts.map +1 -1
  35. package/dist/index.mjs +15 -16
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/{tsconfig-QMSxSwBD.cjs → tsconfig-BUDqmOaT.cjs} +13 -13
  38. package/dist/{tsconfig-CI6bla4E.mjs → tsconfig-MeFEs21S.mjs} +14 -14
  39. package/dist/tsconfig-MeFEs21S.mjs.map +1 -0
  40. package/dist/typescript/index.cjs +1 -1
  41. package/dist/typescript/index.d.cts +6 -6
  42. package/dist/typescript/index.d.cts.map +1 -1
  43. package/dist/typescript/index.d.mts +6 -6
  44. package/dist/typescript/index.d.mts.map +1 -1
  45. package/dist/typescript/index.mjs +1 -1
  46. package/package.json +17 -17
  47. package/dist/base-context-BSAC5sO9.mjs.map +0 -1
  48. package/dist/engine-context-CI_0NWIk.cjs +0 -73
  49. package/dist/engine-context-_RMFwG4J.mjs +0 -68
  50. package/dist/engine-context-_RMFwG4J.mjs.map +0 -1
  51. package/dist/execution-context-Bkxp1fML.mjs.map +0 -1
  52. package/dist/tsconfig-CI6bla4E.mjs.map +0 -1
@@ -1,517 +1,49 @@
1
- import { BaseContext, Context, EmitEntryOptions, EmitOptions, EngineContext, EngineOptions, EnvironmentContext, EnvironmentContextPlugin, EnvironmentResolvedConfig, ExecutionContext, ExecutionOptions, ExecutionState, FetchOptions, HooksList, InitialConfig, InlineConfig, LogFn, LogLevelResolvedConfig, LogMessage, Logger, LoggerOptions, MetaInfo, Mode, ParseOptions, ParsedTypeScriptConfig, ParsedUserConfig, Plugin, PluginContext, ResolveOptions, ResolveResult, ResolvedConfig, ResolvedEntryTypeDefinition, Resolver, SelectHookResult, SelectHooksOptions, TransformResult, VirtualFile, VirtualFileSystemInterface, WorkspaceConfig } from "@powerlines/core";
2
- import { EnvPaths } from "@stryke/env/get-env-paths";
1
+ import { n as PowerlinesContext, r as PowerlinesBaseContext, t as PowerlinesExecutionContext } from "../execution-context-CU6iNchD.cjs";
2
+ import { EngineContext, EngineOptions, EnvironmentContextPlugin, EnvironmentResolvedConfig, ExecutionOptions, ExecutionState, HooksList, InferOverridableConfig, LogFn, LogLevelResolvedConfig, Logger, LoggerOptions, Plugin, PluginContext, ResolvedConfig, SelectHookResult, SelectHooksOptions, UserConfig } from "@powerlines/core";
3
+ import { DeepPartial, RequiredKeys } from "@stryke/types/base";
3
4
  import { Unstable_ContextInternal, Unstable_EnvironmentContext, Unstable_PluginContext } from "@powerlines/core/types/_internal";
4
- import { PackageJson } from "@stryke/types/package-json";
5
- import { FlatCache } from "flat-cache";
6
- import { ParseResult } from "oxc-parser";
7
- import { Range } from "semver";
8
- import { RequestInfo, Response } from "undici";
9
5
 
10
- //#region src/context/base-context.d.ts
11
- declare class PowerlinesBaseContext implements BaseContext {
6
+ //#region src/context/engine-context.d.ts
7
+ declare class PowerlinesEngineContext extends PowerlinesBaseContext implements EngineContext {
12
8
  #private;
13
9
  /**
14
- * The path to the Powerlines package
15
- */
16
- powerlinesPath: string;
17
- /**
18
- * The module resolver for the project
19
- */
20
- resolver: Resolver;
21
- /**
22
- * The options provided to the Powerlines process
23
- */
24
- options: EngineOptions;
25
- /**
26
- * The input options used to initialize the context, which may be used when cloning the context to ensure the same configuration is applied to the new context
27
- */
28
- initialOptions: Partial<EngineOptions>;
29
- /**
30
- * The initial configuration provided when initializing the context, which may be used during the setup process to ensure that the configuration is properly merged and applied to the context. This is typically the user configuration provided in the Powerlines configuration file, but may also include additional configuration options provided by plugins or other sources.
31
- */
32
- initialConfig: InitialConfig<any>;
33
- /**
34
- * The parsed configuration file for the project
35
- */
36
- configFile: ParsedUserConfig;
37
- /**
38
- * The logger instance for the context, which can be used to create log messages with consistent formatting and metadata. This logger is extended by plugin contexts to include additional metadata such as the plugin name and category, which can be used to filter and format log messages in a more granular way.
39
- */
40
- get logger(): Logger;
41
- /**
42
- * A timestamp representing when the context was initialized
43
- */
44
- get timestamp(): number;
45
- get logLevel(): LogLevelResolvedConfig;
46
- /**
47
- * The environment paths for the project
48
- */
49
- get envPaths(): EnvPaths;
50
- /**
51
- * Creates a clone of the current context with the same configuration and workspace settings. This can be useful for running multiple builds in parallel or for creating isolated contexts for different parts of the build process.
52
- *
53
- * @remarks
54
- * The cloned context will have the same configuration and workspace settings as the original context, but will have a different build ID, release ID, and timestamp. The virtual file system and caches will also be separate between the original and cloned contexts.
55
- *
56
- * @returns A promise that resolves to the cloned context.
57
- */
58
- clone(): Promise<BaseContext>;
59
- /**
60
- * A logging function for fatal messages
61
- *
62
- * @param message - The message to log.
63
- */
64
- fatal(message: string | LogMessage): void;
65
- /**
66
- * A logging function for error messages
67
- *
68
- * @param message - The message to log.
69
- */
70
- error(message: string | LogMessage): void;
71
- /**
72
- * A logging function for warning messages
73
- *
74
- * @param message - The message to log.
75
- */
76
- warn(message: string | LogMessage): void;
77
- /**
78
- * A logging function for informational messages
79
- *
80
- * @param message - The message to log.
81
- */
82
- info(message: string | LogMessage): void;
83
- /**
84
- * A logging function for debug messages
85
- *
86
- * @param message - The message to log.
87
- */
88
- debug(message: string | LogMessage): void;
89
- /**
90
- * A logging function for trace messages
91
- *
92
- * @param message - The message to log.
93
- */
94
- trace(message: string | LogMessage): void;
95
- /**
96
- * A function to create a timer for measuring the duration of asynchronous operations
97
- *
98
- * @example
99
- * ```ts
100
- * const stopTimer = context.timer("Your Async Operation");
101
- * await performAsyncOperation();
102
- * stopTimer(); // "Your Async Operation completed in 123.45 milliseconds"
103
- * ```
104
- *
105
- * @param name - The name of the timer.
106
- * @returns A function that, when called, stops the timer and logs the duration.
107
- */
108
- timer(name: string): () => void;
109
- /**
110
- * Create a new logger instance
111
- *
112
- * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
113
- * @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.
114
- * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
115
- */
116
- createLogger(options: LoggerOptions, logFn?: LogFn): Logger;
117
- /**
118
- * Extend the base logger with additional configuration options
119
- *
120
- * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
121
- * @returns A new logger client instance that extends the base logger with the provided configuration options.
122
- */
123
- extendLogger(options: LoggerOptions): Logger;
124
- /**
125
- * Retrieve the workspace configuration for the current project, if it exists. This function will look for a configuration file in the project root and return its contents as a JavaScript object. If no configuration file is found, it will return undefined.
126
- *
127
- * @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.
128
- */
129
- protected getWorkspaceConfig(): Promise<WorkspaceConfig | undefined>;
130
- /**
131
- * Determine the default mode for the current execution based on the environment and workspace configuration. This function will check the `NODE_ENV` environment variable to determine if the current environment is development, production, or test. If `NODE_ENV` is not set, it will look for a `mode` property in the workspace configuration file. If no mode is specified in the workspace configuration, it will default to "production".
132
- *
133
- * @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
134
- */
135
- protected getDefaultMode(): Promise<Mode>;
136
- /**
137
- * Determine the default log level for the current execution based on the environment and workspace configuration. This function will check the `logLevel` property in the workspace configuration file and resolve it to a `LogLevelResolvedConfig` value. If no log level is specified in the workspace configuration, it will default to "info" for development mode and "warn" for production mode.
10
+ * Creates a new instance of the PowerlinesEngineContext class.
138
11
  *
139
- * @returns A promise that resolves to the default log level for the current execution, which can be "fatal", "error", "warn", "info", "debug", or "trace".
12
+ * @param options - The options to initialize the context with.
13
+ * @returns A promise that resolves to an instance of the PowerlinesEngineContext class.
140
14
  */
141
- protected getDefaultLogLevel(): Promise<LogLevelResolvedConfig>;
15
+ static fromInitialConfig(options: EngineOptions, initialConfig?: DeepPartial<UserConfig>): Promise<PowerlinesEngineContext>;
142
16
  /**
143
- * Initialize the context with the provided configuration options
144
- *
145
- * @remarks
146
- * This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.
147
- *
148
- * @param options - The configuration options to initialize the context with
149
- * @param initialConfig - The initial configuration to initialize the context with
17
+ * The initial options provided to the Powerlines process before any resolution or merging. This is typically the user configuration provided in the Powerlines configuration file, but may also include additional configuration options provided by plugins or other sources.
150
18
  */
151
- protected init(options: EngineOptions, initialConfig: InitialConfig): Promise<void>;
152
- }
153
- //#endregion
154
- //#region src/context/context.d.ts
155
- declare class PowerlinesContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends PowerlinesBaseContext implements Context<TResolvedConfig> {
156
- #private;
19
+ readonly initialOptions: EngineOptions;
157
20
  /**
158
- * Create a new Storm context from the workspace root and user config.
159
- *
160
- * @param options - The options for resolving the context.
161
- * @returns A promise that resolves to the new context.
21
+ * The initial user configuration provided to the Powerlines process before any resolution or merging. This is typically the user configuration provided in the Powerlines configuration file, but may also include additional configuration options provided by plugins or other sources.
162
22
  */
163
- static init<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(options: ExecutionOptions, initialConfig: InitialConfig<TResolvedConfig["userConfig"]>): Promise<Context<TResolvedConfig>>;
23
+ readonly initialConfig: DeepPartial<UserConfig>;
164
24
  /**
165
25
  * The options provided to the Powerlines process
166
26
  */
167
- options: ExecutionOptions;
168
- /**
169
- * An object containing the dependencies that should be installed for the project
170
- */
171
- dependencies: Record<string, string | Range>;
172
- /**
173
- * An object containing the development dependencies that should be installed for the project
174
- */
175
- devDependencies: Record<string, string | Range>;
176
- /**
177
- * The persisted meta information about the current build
178
- */
179
- persistedMeta: MetaInfo | undefined;
180
- /**
181
- * The parsed `package.json` file for the project
182
- */
183
- packageJson: PackageJson;
184
- /**
185
- * The parsed `project.json` file for the project
186
- */
187
- projectJson: Record<string, any> | undefined;
188
- /**
189
- * The resolved tsconfig file paths for the project
190
- */
191
- resolvePatterns: RegExp[];
192
- /**
193
- * Internal context fields and methods
194
- *
195
- * @danger
196
- * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
197
- *
198
- * @internal
199
- */
200
- get $$internal(): Unstable_ContextInternal<TResolvedConfig>;
201
- /**
202
- * Internal context fields and methods
203
- *
204
- * @danger
205
- * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
206
- *
207
- * @internal
208
- */
209
- set $$internal(value: Unstable_ContextInternal<TResolvedConfig>);
210
- /**
211
- * The resolved entry type definitions for the project
212
- */
213
- get entry(): ResolvedEntryTypeDefinition[];
214
- /**
215
- * The TypeScript configuration parsed from the tsconfig file
216
- */
217
- get tsconfig(): ParsedTypeScriptConfig;
218
- /**
219
- * Sets the TypeScript configuration parsed from the tsconfig file
220
- */
221
- set tsconfig(value: ParsedTypeScriptConfig);
222
- /**
223
- * The virtual file system interface for the project
224
- */
225
- get fs(): VirtualFileSystemInterface;
226
- /**
227
- * Get the checksum of the project's current state
228
- */
229
- get checksum(): string | null;
230
- /**
231
- * The meta information about the current build
232
- */
233
- get meta(): MetaInfo;
234
- /**
235
- * The resolved configuration options
236
- */
237
- get config(): TResolvedConfig;
238
- /**
239
- * Get the path to the artifacts directory for the project
240
- */
241
- get artifactsPath(): string;
242
- /**
243
- * Get the path to the builtin modules used by the project
244
- */
245
- get builtinsPath(): string;
246
- /**
247
- * Get the path to the entry directory for the project
248
- */
249
- get entryPath(): string;
250
- /**
251
- * Get the path to the infrastructure modules used by the project
252
- */
253
- get infrastructurePath(): string;
254
- /**
255
- * Get the path to the data directory for the project
256
- */
257
- get dataPath(): string;
258
- /**
259
- * Get the path to the cache directory for the project
260
- */
261
- get cachePath(): string;
262
- /**
263
- * Get the path to the generated declaration file for the project
264
- */
265
- get typesPath(): string;
266
- /**
267
- * Get the project root relative to the workspace root
268
- */
269
- get relativeToWorkspaceRoot(): string;
270
- /**
271
- * The builtin module id that exist in the Powerlines virtual file system
272
- */
273
- get builtins(): string[];
274
- /**
275
- * Additional arguments provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed.
276
- */
277
- get additionalArgs(): Record<string, string | string[]>;
278
- /**
279
- * The alias mappings for the project used during module resolution
280
- *
281
- * @remarks
282
- * This includes both the built-in module aliases as well as any custom aliases defined in the build configuration.
283
- */
284
- get alias(): Record<string, string>;
285
- /**
286
- * Create a new logger instance
287
- *
288
- * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
289
- * @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.
290
- * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
291
- */
292
- createLogger(options: LoggerOptions, logFn?: LogFn): Logger;
293
- /**
294
- * The log level for the context, which determines the minimum level of log messages that will be emitted by the logger. This is resolved based on the configuration options provided by the user, and can be set to different levels for development, production, and test environments. The log level can also be overridden by plugins or other parts of the build process to provide more granular control over logging output.
295
- */
296
- get logLevel(): LogLevelResolvedConfig;
297
- /**
298
- * The environment paths for the project, which provide the locations of various directories and files used by the Powerlines framework. These paths are resolved based on the organization ID, application ID, and workspace root directory, and can be used to access configuration files, cache directories, and other resources in a consistent manner.
299
- */
300
- get envPaths(): EnvPaths;
301
- /**
302
- * Gets the parser cache.
303
- */
304
- protected get parserCache(): FlatCache;
27
+ options: RequiredKeys<Omit<EngineOptions, "logLevel">, "name" | "root" | "cwd" | "mode" | "framework"> & {
28
+ /**
29
+ * The log level to use for logging messages during the build process. This can be a string indicating the log level or a more detailed configuration object that allows for specifying different log levels for different categories of logs.
30
+ */
31
+ logLevel: LogLevelResolvedConfig;
32
+ };
305
33
  /**
306
- * Gets the request cache.
307
- */
308
- protected get requestCache(): FlatCache;
309
- /**
310
- * The entry points that exist in the Powerlines virtual file system
311
- */
312
- protected get resolvedEntry(): ResolvedEntryTypeDefinition[];
313
- /**
314
- * Creates a new StormContext instance.
34
+ * Creates a new Context instance.
315
35
  *
316
36
  * @param options - The options to use for creating the context, including the resolved configuration and workspace settings.
37
+ * @param initialConfig - The initial configuration provided by the user, which can be used to resolve the final configuration for the context. This typically includes the user configuration options defined in the `powerlines.config.ts` file, as well as any inline configuration options provided during execution.
317
38
  */
318
- protected constructor(options: ExecutionOptions);
319
- /**
320
- * Creates a clone of the current context with the same configuration and workspace settings. This can be useful for running multiple builds in parallel or for creating isolated contexts for different parts of the build process.
321
- *
322
- * @remarks
323
- * The cloned context will have the same configuration and workspace settings as the original context, but will have a different build ID, release ID, and timestamp. The virtual file system and caches will also be separate between the original and cloned contexts.
324
- *
325
- * @returns A promise that resolves to the cloned context.
326
- */
327
- clone(): Promise<Context<TResolvedConfig>>;
328
- /**
329
- * A function to perform HTTP fetch requests
330
- *
331
- * @remarks
332
- * This function uses a caching layer to avoid duplicate requests during the Powerlines process.
333
- *
334
- * @example
335
- * ```ts
336
- * const response = await context.fetch("https://api.example.com/data");
337
- * const data = await response.json();
338
- * ```
339
- *
340
- * @see https://github.com/nodejs/undici
341
- *
342
- * @param input - The URL to fetch.
343
- * @param options - The fetch request options.
344
- * @returns A promise that resolves to a response returned by the fetch.
345
- */
346
- fetch(input: RequestInfo, options?: FetchOptions): Promise<Response>;
347
- /**
348
- * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
349
- *
350
- * @remarks
351
- * This function can be used to parse TypeScript code into an AST for further analysis or transformation.
352
- *
353
- * @example
354
- * ```ts
355
- * const ast = context.parse("const x: number = 42;");
356
- * ```
357
- *
358
- * @see https://rollupjs.org/plugin-development/#this-parse
359
- * @see https://github.com/oxc/oxc
360
- *
361
- * @param code - The source code to parse.
362
- * @param options - The options to pass to the parser.
363
- * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
364
- */
365
- parse(code: string, options?: ParseOptions): Promise<ParseResult>;
366
- /**
367
- * A helper function to resolve modules in the Virtual File System
368
- *
369
- * @remarks
370
- * This function can be used to resolve modules relative to the project root directory.
371
- *
372
- * @example
373
- * ```ts
374
- * const resolved = await context.resolve("some-module", "/path/to/importer");
375
- * ```
376
- *
377
- * @param id - The module to resolve.
378
- * @param importer - An optional path to the importer module.
379
- * @param options - Additional resolution options.
380
- * @returns A promise that resolves to the resolved module path.
381
- */
382
- resolve(id: string, importer?: string, options?: ResolveOptions): Promise<ResolveResult | undefined>;
383
- /**
384
- * A helper function to load modules from the Virtual File System
385
- *
386
- * @remarks
387
- * This function can be used to load modules relative to the project root directory.
388
- *
389
- * @example
390
- * ```ts
391
- * const module = await context.load("some-module", "/path/to/importer");
392
- * ```
393
- *
394
- * @param id - The module to load.
395
- * @returns A promise that resolves to the loaded module.
396
- */
397
- load(id: string): Promise<TransformResult | undefined>;
398
- /**
399
- * Get the builtin virtual files that exist in the Powerlines virtual file system
400
- */
401
- getBuiltins(): Promise<VirtualFile[]>;
402
- /**
403
- * Resolves a file and writes it to the VFS if it does not already exist
404
- *
405
- * @param code - The source code of the file
406
- * @param path - The path to write the file to
407
- * @param options - Additional options for writing the file
408
- */
409
- emit(code: string, path: string, options?: EmitOptions): Promise<void>;
410
- /**
411
- * Synchronously resolves a file and writes it to the VFS if it does not already exist
412
- *
413
- * @param code - The source code of the file
414
- * @param path - The path to write the file to
415
- * @param options - Additional options for writing the file
416
- */
417
- emitSync(code: string, path: string, options?: EmitOptions): void;
418
- /**
419
- * Resolves a entry virtual file and writes it to the VFS if it does not already exist
420
- *
421
- * @param code - The source code of the entry file
422
- * @param path - A path to write the entry file to
423
- * @param options - Optional write file options
424
- */
425
- emitEntry(code: string, path: string, options?: EmitEntryOptions): Promise<void>;
426
- /**
427
- * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
428
- *
429
- * @param code - The source code of the entry file
430
- * @param path - A path to write the entry file to
431
- * @param options - Optional write file options
432
- */
433
- emitEntrySync(code: string, path: string, options?: EmitEntryOptions): void;
434
- /**
435
- * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
436
- *
437
- * @param code - The source code of the builtin file
438
- * @param id - The unique identifier of the builtin file
439
- * @param options - Optional write file options
440
- */
441
- emitBuiltin(code: string, id: string, options?: EmitOptions): Promise<void>;
442
- /**
443
- * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
444
- *
445
- * @param code - The source code of the builtin file
446
- * @param id - The unique identifier of the builtin file
447
- * @param options - Optional write file options
448
- */
449
- emitBuiltinSync(code: string, id: string, options?: EmitOptions): void;
450
- /**
451
- * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
452
- *
453
- * @param code - The source code of the builtin file
454
- * @param id - The unique identifier of the builtin file
455
- * @param options - Optional write file options
456
- */
457
- emitInfrastructure(code: string, id: string, options?: EmitOptions): Promise<void>;
458
- /**
459
- * Synchronously resolves an infrastructure virtual file and writes it to the VFS if it does not already exist
460
- *
461
- * @param code - The source code of the infrastructure file
462
- * @param id - The unique identifier of the infrastructure file
463
- * @param options - Optional write file options
464
- */
465
- emitInfrastructureSync(code: string, id: string, options?: EmitOptions): void;
466
- /**
467
- * Generates a checksum representing the current context state
468
- *
469
- * @param root - The root directory of the project to generate the checksum for
470
- * @returns A promise that resolves to a string representing the checksum
471
- */
472
- generateChecksum(root?: string): Promise<string>;
39
+ protected constructor(options: EngineOptions, initialConfig?: DeepPartial<UserConfig>);
473
40
  /**
474
41
  * Initialize the context with the provided configuration options
475
- */
476
- setup(): Promise<void>;
477
- /**
478
- * The resolved configuration for this context
479
- */
480
- protected resolvedConfig: TResolvedConfig;
481
- /**
482
- * Creates a clone of the current context with the same configuration and workspace settings. This can be useful for running multiple builds in parallel or for creating isolated contexts for different parts of the build process.
483
42
  *
484
43
  * @remarks
485
- * The cloned context will have the same configuration and workspace settings as the original context, but will have a different build ID, release ID, and timestamp. The virtual file system and caches will also be separate between the original and cloned contexts.
486
- *
487
- * @returns The cloned context.
488
- */
489
- protected copyTo(context: Context<TResolvedConfig>): Context<TResolvedConfig>;
490
- /**
491
- * Initialize the context with the provided configuration options
492
- *
493
- * @remarks
494
44
  * This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.
495
- *
496
- * @param options - The configuration options to initialize the context with
497
- */
498
- protected init(options: ExecutionOptions, initialConfig?: InitialConfig<any>): Promise<void>;
499
- /**
500
- * Initialize the context with the provided configuration options
501
45
  */
502
- protected innerSetup(): Promise<void>;
503
- }
504
- //#endregion
505
- //#region src/context/engine-context.d.ts
506
- declare class PowerlinesEngineContext extends PowerlinesBaseContext implements EngineContext {
507
- #private;
508
- /**
509
- * Creates a new instance of the PowerlinesEngineContext class.
510
- *
511
- * @param options - The options to initialize the context with.
512
- * @returns A promise that resolves to an instance of the PowerlinesEngineContext class.
513
- */
514
- static init(options: EngineOptions, initialConfig?: InitialConfig<any>): Promise<PowerlinesEngineContext>;
46
+ protected init(): Promise<void>;
515
47
  /**
516
48
  * A list of all command executions that will be run during the lifecycle of the engine
517
49
  *
@@ -521,94 +53,26 @@ declare class PowerlinesEngineContext extends PowerlinesBaseContext implements E
521
53
  }
522
54
  //#endregion
523
55
  //#region src/context/environment-context.d.ts
524
- declare class PowerlinesEnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends PowerlinesContext<TResolvedConfig> implements EnvironmentContext<TResolvedConfig> {
56
+ declare class PowerlinesEnvironmentContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends PowerlinesContext<EnvironmentResolvedConfig<TResolvedConfig>> implements Unstable_EnvironmentContext<TResolvedConfig> {
525
57
  #private;
526
58
  /**
527
59
  * Create a new context from the config.
528
60
  *
529
61
  * @param options - The resolved execution options.
530
62
  * @param config - The user configuration options.
531
- * @returns A promise that resolves to the new context.
63
+ * @param overriddenConfig - The configuration options that should override all other configuration sources, such as CLI flags or environment variables. This is used to ensure that certain configuration values take precedence over any other settings defined in the user configuration or environment configuration, allowing for dynamic overrides based on the execution context.
64
+ * @param environment - The resolved environment configuration, which may include additional properties or modifications made during the configuration loading process. This is used to provide context about the environment in which the command is being executed, allowing for environment-specific behavior and configuration resolution.
65
+ * @returns A promise that resolves to an instance of the PowerlinesEnvironmentContext class, initialized with the provided configuration and environment data.
532
66
  */
533
- static fromConfig<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(options: ExecutionOptions, config: TResolvedConfig, environment: EnvironmentResolvedConfig): Promise<PowerlinesEnvironmentContext<TResolvedConfig>>;
67
+ static createEnvironment<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(options: ExecutionOptions, config: TResolvedConfig, overriddenConfig: InferOverridableConfig<EnvironmentResolvedConfig<TResolvedConfig>>, environment: EnvironmentResolvedConfig<TResolvedConfig>["environment"]): Promise<PowerlinesEnvironmentContext<TResolvedConfig>>;
534
68
  /**
535
- * The resolved environment configuration
69
+ * The configuration options provided by plugins added by the user (and other plugins)
536
70
  */
537
- environment: EnvironmentResolvedConfig;
71
+ protected environmentConfig: EnvironmentResolvedConfig<TResolvedConfig>["environment"];
538
72
  /**
539
73
  * The list of plugins applied to this environment
540
74
  */
541
75
  plugins: EnvironmentContextPlugin<TResolvedConfig>[];
542
- /**
543
- * The unique identifier of the environment associated with this context, which can be used for logging and other purposes to distinguish between different environments in the same process.
544
- */
545
- get id(): string;
546
- /**
547
- * The hooks registered by plugins in this environment
548
- */
549
- get hooks(): Record<string, HooksList<PluginContext<TResolvedConfig>>>;
550
- /**
551
- * Create a new logger instance
552
- *
553
- * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
554
- * @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.
555
- * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
556
- */
557
- createLogger(options: LoggerOptions, logFn?: LogFn): Logger;
558
- /**
559
- * Extend the base logger with additional configuration options
560
- *
561
- * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
562
- * @returns A new logger client instance that extends the base logger with the provided configuration options.
563
- */
564
- extendLogger(options: LoggerOptions): Logger;
565
- /**
566
- * Creates a clone of the current context with the same configuration and workspace settings. This can be useful for running multiple builds in parallel or for creating isolated contexts for different parts of the build process.
567
- *
568
- * @remarks
569
- * The cloned context will have the same configuration and workspace settings as the original context, but will have a different build ID, release ID, and timestamp. The virtual file system and caches will also be separate between the original and cloned contexts.
570
- *
571
- * @returns A promise that resolves to the cloned context.
572
- */
573
- clone(): Promise<EnvironmentContext<TResolvedConfig>>;
574
- /**
575
- * Initialize the context with the provided configuration options
576
- */
577
- setup(): Promise<void>;
578
- addPlugin(plugin: Plugin<PluginContext<TResolvedConfig>>): Promise<void>;
579
- /**
580
- * Retrieves the hook handlers for a specific hook name
581
- */
582
- selectHooks<TKey extends string>(key: TKey, options?: SelectHooksOptions): SelectHookResult<PluginContext<TResolvedConfig>, TKey>;
583
- protected constructor(options: ExecutionOptions, config: TResolvedConfig, environment: EnvironmentResolvedConfig);
584
- /**
585
- * Creates a clone of the current context with the same configuration and workspace settings. This can be useful for running multiple builds in parallel or for creating isolated contexts for different parts of the build process.
586
- *
587
- * @remarks
588
- * The cloned context will have the same configuration and workspace settings as the original context, but will have a different build ID, release ID, and timestamp. The virtual file system and caches will also be separate between the original and cloned contexts.
589
- *
590
- * @returns The cloned context.
591
- */
592
- protected copyTo(context: EnvironmentContext<TResolvedConfig>): EnvironmentContext<TResolvedConfig>;
593
- }
594
- //#endregion
595
- //#region src/context/execution-context.d.ts
596
- declare class PowerlinesExecutionContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends PowerlinesContext<TResolvedConfig> implements ExecutionContext<TResolvedConfig> {
597
- #private;
598
- /**
599
- * Create a new Storm context from the workspace root and user config.
600
- *
601
- * @param options - The options for resolving the context.
602
- * @returns A promise that resolves to the new context.
603
- */
604
- static init<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(options: ExecutionOptions, initialConfig: InitialConfig<TResolvedConfig["userConfig"]>): Promise<ExecutionContext<TResolvedConfig>>;
605
- /**
606
- * Create a new Storm context from the workspace root and user config.
607
- *
608
- * @param options - The options for resolving the context.
609
- * @returns A promise that resolves to the new context.
610
- */
611
- static inline<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(options: ExecutionOptions, initialConfig: InitialConfig<TResolvedConfig["userConfig"]>, inlineConfig: InlineConfig<TResolvedConfig["userConfig"]>): Promise<ExecutionContext<TResolvedConfig>>;
612
76
  /**
613
77
  * Internal context fields and methods
614
78
  *
@@ -628,20 +92,20 @@ declare class PowerlinesExecutionContext<TResolvedConfig extends ResolvedConfig
628
92
  */
629
93
  set $$internal(value: Unstable_ContextInternal<TResolvedConfig>);
630
94
  /**
631
- * The unique identifier of the execution context, which can be used for logging and other purposes to distinguish between different executions in the same process.
95
+ * The unique identifier of the environment associated with this context, which can be used for logging and other purposes to distinguish between different environments in the same process.
632
96
  */
633
97
  get id(): string;
634
98
  /**
635
- * A record of all environments by name
99
+ * The hooks registered by plugins in this environment
636
100
  */
637
- get environments(): Record<string, Unstable_EnvironmentContext<TResolvedConfig>>;
638
- get plugins(): Array<Plugin<PluginContext<TResolvedConfig>>>;
101
+ get hooks(): Record<string, HooksList<PluginContext<TResolvedConfig>>>;
639
102
  /**
640
- * Creates a new instance.
103
+ * A setter function to populate the environment config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the environment configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any environment configuration provided during execution.
641
104
  *
642
- * @param options - The options to use for creating the context, including the resolved configuration and workspace settings.
105
+ * @param config - The environment configuration values to set.
106
+ * @returns A promise that resolves when the environment configuration values have been set.
643
107
  */
644
- protected constructor(options: ExecutionOptions);
108
+ protected setEnvironmentConfig(config: EnvironmentResolvedConfig<TResolvedConfig>["environment"]): Promise<void>;
645
109
  /**
646
110
  * Create a new logger instance
647
111
  *
@@ -657,55 +121,18 @@ declare class PowerlinesExecutionContext<TResolvedConfig extends ResolvedConfig
657
121
  * @returns A new logger client instance that extends the base logger with the provided configuration options.
658
122
  */
659
123
  extendLogger(options: LoggerOptions): Logger;
660
- /**
661
- * Creates a clone of the current context with the same configuration and workspace settings. This can be useful for running multiple builds in parallel or for creating isolated contexts for different parts of the build process.
662
- *
663
- * @remarks
664
- * The cloned context will have the same configuration and workspace settings as the original context, but will have a different build ID, release ID, and timestamp. The virtual file system and caches will also be separate between the original and cloned contexts.
665
- *
666
- * @returns A promise that resolves to the cloned context.
667
- */
668
- clone(): Promise<ExecutionContext<TResolvedConfig>>;
669
- /**
670
- * A function to copy the context and update the fields for a specific environment
671
- *
672
- * @param environment - The environment configuration to use.
673
- * @returns A new context instance with the updated environment.
674
- */
675
- in(environment: EnvironmentResolvedConfig): Promise<Unstable_EnvironmentContext<TResolvedConfig>>;
676
- /**
677
- * Update the context using a new inline configuration options
678
- */
679
- setup(): Promise<void>;
680
- /**
681
- * Add a plugin to the API context and all environments
682
- *
683
- * @param plugin - The plugin to add.
684
- */
685
124
  addPlugin(plugin: Plugin<PluginContext<TResolvedConfig>>): Promise<void>;
686
125
  /**
687
- * Get an environment by name, or the default environment if no name is provided
688
- *
689
- * @param name - The name of the environment to retrieve.
690
- * @returns The requested environment context.
691
- */
692
- getEnvironment(name?: string): Promise<EnvironmentContext<TResolvedConfig>>;
693
- /**
694
- * A safe version of `getEnvironment` that returns `undefined` if the environment is not found
695
- *
696
- * @param name - The name of the environment to retrieve.
697
- * @returns The requested environment context or `undefined` if not found.
126
+ * Retrieves the hook handlers for a specific hook name
698
127
  */
699
- getEnvironmentSafe(name?: string): Promise<EnvironmentContext<TResolvedConfig> | undefined>;
128
+ selectHooks<TKey extends string>(key: TKey, options?: SelectHooksOptions): SelectHookResult<PluginContext<TResolvedConfig>, TKey>;
129
+ protected constructor(options: ExecutionOptions, config: TResolvedConfig, overriddenConfig: InferOverridableConfig<EnvironmentResolvedConfig<TResolvedConfig>>);
700
130
  /**
701
- * A function to merge all configured environments into a single context.
702
- *
703
- * @remarks
704
- * If only one environment is configured, that environment will be returned directly.
131
+ * A function to merge the various configuration objects (initial, user, inline, and plugin) into a single resolved configuration object that can be used throughout the Powerlines process. This function takes into account the different sources of configuration and their respective priorities, ensuring that the final configuration reflects the intended settings for the project. The merged configuration is then returned as a new object that can be accessed through the `config` property of the context.
705
132
  *
706
- * @returns A promise that resolves to a merged/global environment context.
133
+ * @returns The merged configuration object that combines the initial, user, inline, and plugin configurations.
707
134
  */
708
- toEnvironment(): Promise<EnvironmentContext<TResolvedConfig>>;
135
+ protected mergeConfig(): EnvironmentResolvedConfig<TResolvedConfig>;
709
136
  }
710
137
  //#endregion
711
138
  //#region src/context/plugin-context.d.ts
@@ -717,7 +144,7 @@ declare class PowerlinesExecutionContext<TResolvedConfig extends ResolvedConfig
717
144
  * @param environment - The environment context
718
145
  * @returns The proxied plugin context
719
146
  */
720
- declare function createPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(pluginId: string, plugin: Plugin<PluginContext<TResolvedConfig>>, environment: Unstable_EnvironmentContext<TResolvedConfig>): Unstable_PluginContext<TResolvedConfig>;
147
+ declare function createPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(pluginId: string, plugin: Plugin<PluginContext<TResolvedConfig>>, environment: PowerlinesEnvironmentContext<TResolvedConfig>): Unstable_PluginContext<TResolvedConfig>;
721
148
  //#endregion
722
149
  export { PowerlinesBaseContext, PowerlinesContext, PowerlinesEngineContext, PowerlinesEnvironmentContext, PowerlinesExecutionContext, createPluginContext };
723
150
  //# sourceMappingURL=index.d.cts.map