@powerlines/engine 0.45.2 → 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 -788
  2. package/dist/_internal/worker.mjs +847 -791
  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-BRzNYU9u.mjs → execution-context-Cp32TarF.mjs} +421 -363
  28. package/dist/execution-context-Cp32TarF.mjs.map +1 -0
  29. package/dist/{execution-context-BlWK2rTX.cjs → execution-context-DgqxcDDx.cjs} +419 -361
  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-BRzNYU9u.mjs.map +0 -1
  52. package/dist/tsconfig-CI6bla4E.mjs.map +0 -1
@@ -0,0 +1,631 @@
1
+ import { BaseContext, Context, EmitEntryOptions, EmitOptions, EngineOptions, EnvironmentContext, EnvironmentResolvedConfig, ExecutionContext, ExecutionOptions, FetchOptions, InferOverridableConfig, LogFn, LogLevelResolvedConfig, LogMessage, Logger, LoggerOptions, MetaInfo, Mode, ParseOptions, ParsedTypeScriptConfig, ParsedUserConfig, Plugin, PluginContext, ResolveOptions, ResolveResult, ResolvedConfig, ResolvedEntryTypeDefinition, Resolver, TransformResult, UserConfig, VirtualFile, VirtualFileSystemInterface, WorkspaceConfig } from "@powerlines/core";
2
+ import { DeepPartial, RequiredKeys } from "@stryke/types/base";
3
+ import { Unstable_ContextInternal, Unstable_EnvironmentContext } from "@powerlines/core/types/_internal";
4
+ import { EnvPaths } from "@stryke/env/get-env-paths";
5
+ import { FlatCache } from "flat-cache";
6
+ import { ParseResult } from "oxc-parser";
7
+ import { Range } from "semver";
8
+ import { RequestInfo, Response } from "undici";
9
+ import { PackageJson } from "@stryke/types/package-json";
10
+
11
+ //#region src/context/base-context.d.ts
12
+ declare class PowerlinesBaseContext implements BaseContext {
13
+ #private;
14
+ /**
15
+ * The path to the Powerlines package
16
+ */
17
+ powerlinesPath: string;
18
+ /**
19
+ * The module resolver for the project
20
+ */
21
+ resolver: Resolver;
22
+ /**
23
+ * The options provided to the Powerlines process, resolved with default values and merged with any configuration provided by plugins or other sources. This is typically the final configuration used during the build process, but may also include additional options that are relevant to the context and its interactions with the Powerlines engine.
24
+ */
25
+ options: RequiredKeys<EngineOptions, "mode" | "cwd" | "root" | "framework">;
26
+ /**
27
+ * The parsed `package.json` file for the project
28
+ */
29
+ packageJson: PackageJson;
30
+ /**
31
+ * The parsed `project.json` file for the project
32
+ */
33
+ projectJson: Record<string, any> | undefined;
34
+ /**
35
+ * The parsed configuration file for the project
36
+ */
37
+ configFile: ParsedUserConfig;
38
+ /**
39
+ * 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.
40
+ */
41
+ get logger(): Logger;
42
+ /**
43
+ * A timestamp representing when the context was initialized
44
+ */
45
+ get timestamp(): number;
46
+ get logLevel(): LogLevelResolvedConfig;
47
+ /**
48
+ * The environment paths for the project
49
+ */
50
+ get envPaths(): EnvPaths;
51
+ /**
52
+ * 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.
53
+ *
54
+ * @remarks
55
+ * 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.
56
+ *
57
+ * @returns A promise that resolves to the cloned context.
58
+ */
59
+ clone(): Promise<BaseContext>;
60
+ /**
61
+ * A logging function for fatal messages
62
+ *
63
+ * @param message - The message to log.
64
+ */
65
+ fatal(message: string | LogMessage): void;
66
+ /**
67
+ * A logging function for error messages
68
+ *
69
+ * @param message - The message to log.
70
+ */
71
+ error(message: string | LogMessage): void;
72
+ /**
73
+ * A logging function for warning messages
74
+ *
75
+ * @param message - The message to log.
76
+ */
77
+ warn(message: string | LogMessage): void;
78
+ /**
79
+ * A logging function for informational messages
80
+ *
81
+ * @param message - The message to log.
82
+ */
83
+ info(message: string | LogMessage): void;
84
+ /**
85
+ * A logging function for debug messages
86
+ *
87
+ * @param message - The message to log.
88
+ */
89
+ debug(message: string | LogMessage): void;
90
+ /**
91
+ * A logging function for trace messages
92
+ *
93
+ * @param message - The message to log.
94
+ */
95
+ trace(message: string | LogMessage): void;
96
+ /**
97
+ * A function to create a timer for measuring the duration of asynchronous operations
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const stopTimer = context.timer("Your Async Operation");
102
+ * await performAsyncOperation();
103
+ * stopTimer(); // "Your Async Operation completed in 123.45 milliseconds"
104
+ * ```
105
+ *
106
+ * @param name - The name of the timer.
107
+ * @returns A function that, when called, stops the timer and logs the duration.
108
+ */
109
+ timer(name: string): () => void;
110
+ /**
111
+ * Create a new logger instance
112
+ *
113
+ * @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.
114
+ * @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.
115
+ * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
116
+ */
117
+ createLogger(options: LoggerOptions, logFn?: LogFn): Logger;
118
+ /**
119
+ * Extend the base logger with additional configuration options
120
+ *
121
+ * @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.
122
+ * @returns A new logger client instance that extends the base logger with the provided configuration options.
123
+ */
124
+ extendLogger(options: LoggerOptions): Logger;
125
+ /**
126
+ * 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
127
+ */
128
+ protected initialOptions: EngineOptions;
129
+ /**
130
+ * 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.
131
+ */
132
+ protected initialConfig: DeepPartial<UserConfig>;
133
+ /**
134
+ * Initialize the context with the provided configuration options and set up the resolver and user configuration file. This method 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 as the original context.
135
+ *
136
+ * @param options - The configuration options to initialize the context with, which can include properties such as the project root, mode, log level, and other settings that affect the behavior of the context and its plugins.
137
+ * @param initialConfig - The initial configuration to initialize the context with, which is typically the user configuration provided in the Powerlines configuration file. This can also include additional configuration options provided by plugins or other sources that should be merged with the user configuration during initialization
138
+ */
139
+ protected constructor(options: EngineOptions, initialConfig?: DeepPartial<UserConfig>);
140
+ /**
141
+ * 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.
142
+ *
143
+ * @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.
144
+ */
145
+ protected getWorkspaceConfig(): Promise<WorkspaceConfig | undefined>;
146
+ /**
147
+ * Initialize the context with the provided configuration options
148
+ *
149
+ * @remarks
150
+ * 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.
151
+ */
152
+ protected init(): Promise<void>;
153
+ /**
154
+ * 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".
155
+ *
156
+ * @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
157
+ */
158
+ protected getDefaultMode(): Promise<Mode>;
159
+ /**
160
+ * 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.
161
+ *
162
+ * @returns A promise that resolves to the default log level for the current execution, which can be "fatal", "error", "warn", "info", "debug", or "trace".
163
+ */
164
+ protected getDefaultLogLevel(): Promise<LogLevelResolvedConfig>;
165
+ }
166
+ //#endregion
167
+ //#region src/context/context.d.ts
168
+ declare class PowerlinesContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends PowerlinesBaseContext implements Context<TResolvedConfig> {
169
+ #private;
170
+ /**
171
+ * Create a new context from the workspace root and user config.
172
+ *
173
+ * @param options - The options for resolving the context.
174
+ * @returns A promise that resolves to the new context.
175
+ */
176
+ static fromInitialConfig<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(options: ExecutionOptions, initialConfig: TResolvedConfig["initialConfig"]): Promise<PowerlinesContext<TResolvedConfig>>;
177
+ /**
178
+ * The options provided to the Powerlines process, resolved with default values and merged with any configuration provided by plugins or other sources. This is typically the final configuration used during the build process, but may also include additional options that are relevant to the context and its interactions with the Powerlines engine.
179
+ */
180
+ options: RequiredKeys<ExecutionOptions, "mode" | "cwd" | "root" | "framework" | "logLevel">;
181
+ /**
182
+ * An object containing the dependencies that should be installed for the project
183
+ */
184
+ dependencies: Record<string, string | Range>;
185
+ /**
186
+ * An object containing the development dependencies that should be installed for the project
187
+ */
188
+ devDependencies: Record<string, string | Range>;
189
+ /**
190
+ * The persisted meta information about the current build
191
+ */
192
+ persistedMeta: MetaInfo | undefined;
193
+ /**
194
+ * The resolved tsconfig file paths for the project
195
+ */
196
+ resolvePatterns: RegExp[];
197
+ /**
198
+ * 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
199
+ */
200
+ protected initialOptions: ExecutionOptions;
201
+ /**
202
+ * The resolved configuration for this context
203
+ */
204
+ protected resolvedConfig: TResolvedConfig;
205
+ /**
206
+ * The configuration options that were overridden by plugins during the build process, which may include additional properties or modifications made during the configuration loading process.
207
+ */
208
+ protected overriddenConfig: InferOverridableConfig<TResolvedConfig>;
209
+ /**
210
+ * The configuration options provided inline during execution, such as CLI flags or other parameters that may be relevant to the command being executed. These options can be used to override or supplement the configuration options defined in a configuration file on disk, and are typically provided as part of the execution context when running a Powerlines command.
211
+ */
212
+ protected inlineConfig: TResolvedConfig["inlineConfig"];
213
+ /**
214
+ * The configuration options read from a configuration file on disk, which may 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.
215
+ */
216
+ protected userConfig: TResolvedConfig["userConfig"];
217
+ /**
218
+ * The configuration options provided by plugins added by the user (and other plugins)
219
+ */
220
+ protected pluginConfig: TResolvedConfig["pluginConfig"];
221
+ /**
222
+ * The resolved entry type definitions for the project
223
+ */
224
+ get entry(): ResolvedEntryTypeDefinition[];
225
+ /**
226
+ * The TypeScript configuration parsed from the tsconfig file
227
+ */
228
+ get tsconfig(): ParsedTypeScriptConfig;
229
+ /**
230
+ * Sets the TypeScript configuration parsed from the tsconfig file
231
+ */
232
+ set tsconfig(value: ParsedTypeScriptConfig);
233
+ /**
234
+ * The virtual file system interface for the project
235
+ */
236
+ get fs(): VirtualFileSystemInterface;
237
+ /**
238
+ * Get the checksum of the project's current state
239
+ */
240
+ get checksum(): string | null;
241
+ /**
242
+ * The meta information about the current build
243
+ */
244
+ get meta(): MetaInfo;
245
+ /**
246
+ * The resolved configuration options
247
+ */
248
+ get config(): TResolvedConfig;
249
+ /**
250
+ * Get the path to the artifacts directory for the project
251
+ */
252
+ get artifactsPath(): string;
253
+ /**
254
+ * Get the path to the builtin modules used by the project
255
+ */
256
+ get builtinsPath(): string;
257
+ /**
258
+ * Get the path to the entry directory for the project
259
+ */
260
+ get entryPath(): string;
261
+ /**
262
+ * Get the path to the infrastructure modules used by the project
263
+ */
264
+ get infrastructurePath(): string;
265
+ /**
266
+ * Get the path to the data directory for the project
267
+ */
268
+ get dataPath(): string;
269
+ /**
270
+ * Get the path to the cache directory for the project
271
+ */
272
+ get cachePath(): string;
273
+ /**
274
+ * Get the path to the generated declaration file for the project
275
+ */
276
+ get typesPath(): string;
277
+ /**
278
+ * Get the project root relative to the workspace root
279
+ */
280
+ get relativeToWorkspaceRoot(): string;
281
+ /**
282
+ * The builtin module id that exist in the Powerlines virtual file system
283
+ */
284
+ get builtins(): string[];
285
+ /**
286
+ * Additional arguments provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed.
287
+ */
288
+ get additionalArgs(): Record<string, string | string[]>;
289
+ /**
290
+ * The alias mappings for the project used during module resolution
291
+ *
292
+ * @remarks
293
+ * This includes both the built-in module aliases as well as any custom aliases defined in the build configuration.
294
+ */
295
+ get alias(): Record<string, string>;
296
+ /**
297
+ * 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.
298
+ */
299
+ get logLevel(): LogLevelResolvedConfig;
300
+ /**
301
+ * 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.
302
+ */
303
+ get envPaths(): EnvPaths;
304
+ /**
305
+ * Gets the parser cache.
306
+ */
307
+ protected get parserCache(): FlatCache;
308
+ /**
309
+ * Gets the request cache.
310
+ */
311
+ protected get requestCache(): FlatCache;
312
+ /**
313
+ * The entry points that exist in the Powerlines virtual file system
314
+ */
315
+ protected get resolvedEntry(): ResolvedEntryTypeDefinition[];
316
+ /**
317
+ * Creates a new Context instance.
318
+ *
319
+ * @param options - The options to use for creating the context, including the resolved configuration and workspace settings.
320
+ * @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.
321
+ */
322
+ protected constructor(options: ExecutionOptions, initialConfig: TResolvedConfig["initialConfig"]);
323
+ /**
324
+ * Create a new logger instance
325
+ *
326
+ * @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.
327
+ * @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.
328
+ * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
329
+ */
330
+ createLogger(options: LoggerOptions, logFn?: LogFn): Logger;
331
+ /**
332
+ * A function to perform HTTP fetch requests
333
+ *
334
+ * @remarks
335
+ * This function uses a caching layer to avoid duplicate requests during the Powerlines process.
336
+ *
337
+ * @example
338
+ * ```ts
339
+ * const response = await context.fetch("https://api.example.com/data");
340
+ * const data = await response.json();
341
+ * ```
342
+ *
343
+ * @see https://github.com/nodejs/undici
344
+ *
345
+ * @param input - The URL to fetch.
346
+ * @param options - The fetch request options.
347
+ * @returns A promise that resolves to a response returned by the fetch.
348
+ */
349
+ fetch(input: RequestInfo, options?: FetchOptions): Promise<Response>;
350
+ /**
351
+ * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
352
+ *
353
+ * @remarks
354
+ * This function can be used to parse TypeScript code into an AST for further analysis or transformation.
355
+ *
356
+ * @example
357
+ * ```ts
358
+ * const ast = context.parse("const x: number = 42;");
359
+ * ```
360
+ *
361
+ * @see https://rollupjs.org/plugin-development/#this-parse
362
+ * @see https://github.com/oxc/oxc
363
+ *
364
+ * @param code - The source code to parse.
365
+ * @param options - The options to pass to the parser.
366
+ * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
367
+ */
368
+ parse(code: string, options?: ParseOptions): Promise<ParseResult>;
369
+ /**
370
+ * A helper function to resolve modules in the Virtual File System
371
+ *
372
+ * @remarks
373
+ * This function can be used to resolve modules relative to the project root directory.
374
+ *
375
+ * @example
376
+ * ```ts
377
+ * const resolved = await context.resolve("some-module", "/path/to/importer");
378
+ * ```
379
+ *
380
+ * @param id - The module to resolve.
381
+ * @param importer - An optional path to the importer module.
382
+ * @param options - Additional resolution options.
383
+ * @returns A promise that resolves to the resolved module path.
384
+ */
385
+ resolve(id: string, importer?: string, options?: ResolveOptions): Promise<ResolveResult | undefined>;
386
+ /**
387
+ * A helper function to load modules from the Virtual File System
388
+ *
389
+ * @remarks
390
+ * This function can be used to load modules relative to the project root directory.
391
+ *
392
+ * @example
393
+ * ```ts
394
+ * const module = await context.load("some-module", "/path/to/importer");
395
+ * ```
396
+ *
397
+ * @param id - The module to load.
398
+ * @returns A promise that resolves to the loaded module.
399
+ */
400
+ load(id: string): Promise<TransformResult | undefined>;
401
+ /**
402
+ * Get the builtin virtual files that exist in the Powerlines virtual file system
403
+ */
404
+ getBuiltins(): Promise<VirtualFile[]>;
405
+ /**
406
+ * Resolves a file and writes it to the VFS if it does not already exist
407
+ *
408
+ * @param code - The source code of the file
409
+ * @param path - The path to write the file to
410
+ * @param options - Additional options for writing the file
411
+ */
412
+ emit(code: string, path: string, options?: EmitOptions): Promise<void>;
413
+ /**
414
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
415
+ *
416
+ * @param code - The source code of the file
417
+ * @param path - The path to write the file to
418
+ * @param options - Additional options for writing the file
419
+ */
420
+ emitSync(code: string, path: string, options?: EmitOptions): void;
421
+ /**
422
+ * Resolves a entry virtual file and writes it to the VFS if it does not already exist
423
+ *
424
+ * @param code - The source code of the entry file
425
+ * @param path - A path to write the entry file to
426
+ * @param options - Optional write file options
427
+ */
428
+ emitEntry(code: string, path: string, options?: EmitEntryOptions): Promise<void>;
429
+ /**
430
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
431
+ *
432
+ * @param code - The source code of the entry file
433
+ * @param path - A path to write the entry file to
434
+ * @param options - Optional write file options
435
+ */
436
+ emitEntrySync(code: string, path: string, options?: EmitEntryOptions): void;
437
+ /**
438
+ * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
439
+ *
440
+ * @param code - The source code of the builtin file
441
+ * @param id - The unique identifier of the builtin file
442
+ * @param options - Optional write file options
443
+ */
444
+ emitBuiltin(code: string, id: string, options?: EmitOptions): Promise<void>;
445
+ /**
446
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
447
+ *
448
+ * @param code - The source code of the builtin file
449
+ * @param id - The unique identifier of the builtin file
450
+ * @param options - Optional write file options
451
+ */
452
+ emitBuiltinSync(code: string, id: string, options?: EmitOptions): void;
453
+ /**
454
+ * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
455
+ *
456
+ * @param code - The source code of the builtin file
457
+ * @param id - The unique identifier of the builtin file
458
+ * @param options - Optional write file options
459
+ */
460
+ emitInfrastructure(code: string, id: string, options?: EmitOptions): Promise<void>;
461
+ /**
462
+ * Synchronously resolves an infrastructure virtual file and writes it to the VFS if it does not already exist
463
+ *
464
+ * @param code - The source code of the infrastructure file
465
+ * @param id - The unique identifier of the infrastructure file
466
+ * @param options - Optional write file options
467
+ */
468
+ emitInfrastructureSync(code: string, id: string, options?: EmitOptions): void;
469
+ /**
470
+ * Generates a checksum representing the current context state
471
+ *
472
+ * @param path - The root directory of the project to generate the checksum for
473
+ * @returns A promise that resolves to a string representing the checksum
474
+ */
475
+ generateChecksum(path?: string): Promise<string>;
476
+ /**
477
+ * A setter function to populate the inline 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 inline configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any inline configuration provided during execution.
478
+ *
479
+ * @param config - The inline configuration values to set.
480
+ * @returns A promise that resolves when the inline configuration values have been set.
481
+ */
482
+ setInlineConfig(config: TResolvedConfig["inlineConfig"]): Promise<void>;
483
+ /**
484
+ * A setter function to populate the plugin 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 plugin configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any plugin configuration provided during execution.
485
+ *
486
+ * @param config - The plugin configuration values to set.
487
+ * @returns A promise that resolves when the plugin configuration values have been set.
488
+ */
489
+ setPluginConfig(config: TResolvedConfig["pluginConfig"]): Promise<void>;
490
+ /**
491
+ * 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.
492
+ *
493
+ * @returns The merged configuration object that combines the initial, user, inline, and plugin configurations.
494
+ */
495
+ protected mergeConfig(): TResolvedConfig;
496
+ /**
497
+ * A setter function to populate the user 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 user configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any inline configuration provided during execution.
498
+ *
499
+ * @param config - The user configuration values to set.
500
+ * @returns A promise that resolves when the user configuration values have been set.
501
+ */
502
+ protected setUserConfig(config: TResolvedConfig["userConfig"]): Promise<void>;
503
+ /**
504
+ * Initialize the context with the provided configuration options
505
+ */
506
+ protected init(): Promise<void>;
507
+ /**
508
+ * Initialize the context with the provided configuration options
509
+ */
510
+ protected resolveConfig(): Promise<void>;
511
+ protected logConfig(config: TResolvedConfig | TResolvedConfig["initialConfig"] | TResolvedConfig["userConfig"] | TResolvedConfig["inlineConfig"] | TResolvedConfig["pluginConfig"]): string;
512
+ private createConfigProxy;
513
+ }
514
+ //#endregion
515
+ //#region src/context/execution-context.d.ts
516
+ declare class PowerlinesExecutionContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> extends PowerlinesContext<TResolvedConfig> implements ExecutionContext<TResolvedConfig> {
517
+ #private;
518
+ /**
519
+ * Create a new Storm context from the workspace root and user config.
520
+ *
521
+ * @param options - The options for resolving the context.
522
+ * @returns A promise that resolves to the new context.
523
+ */
524
+ static fromInitialConfig<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(options: ExecutionOptions, initialConfig: TResolvedConfig["initialConfig"]): Promise<PowerlinesExecutionContext<TResolvedConfig>>;
525
+ /**
526
+ * Create a new Storm context from the workspace root and user config.
527
+ *
528
+ * @param options - The options for resolving the context.
529
+ * @returns A promise that resolves to the new context.
530
+ */
531
+ static fromInlineConfig<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(options: ExecutionOptions, initialConfig: TResolvedConfig["initialConfig"], inlineConfig: TResolvedConfig["inlineConfig"]): Promise<PowerlinesExecutionContext<TResolvedConfig>>;
532
+ /**
533
+ * Internal context fields and methods
534
+ *
535
+ * @danger
536
+ * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
537
+ *
538
+ * @internal
539
+ */
540
+ get $$internal(): Unstable_ContextInternal<TResolvedConfig>;
541
+ /**
542
+ * Internal context fields and methods
543
+ *
544
+ * @danger
545
+ * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
546
+ *
547
+ * @internal
548
+ */
549
+ set $$internal(value: Unstable_ContextInternal<TResolvedConfig>);
550
+ /**
551
+ * 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.
552
+ */
553
+ get id(): string;
554
+ /**
555
+ * A record of all environments by name
556
+ */
557
+ get environments(): Record<string, Unstable_EnvironmentContext<TResolvedConfig>>;
558
+ get plugins(): Array<Plugin<PluginContext<TResolvedConfig>>>;
559
+ /**
560
+ * Creates a new instance.
561
+ *
562
+ * @param options - The options to use for creating the context, including the resolved configuration and workspace settings.
563
+ * @param initialConfig - The initial configuration options to use for the context, which can be used to provide default values for configuration options that may be overridden by user configuration or inline configuration. This is typically the configuration options provided by the user in a configuration file on disk, and can include any relevant settings such as environment definitions, plugin configurations, and other parameters that may be relevant to the execution of a Powerlines command.
564
+ */
565
+ protected constructor(options: ExecutionOptions, initialConfig?: TResolvedConfig["initialConfig"]);
566
+ /**
567
+ * A setter function to populate the inline 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 inline configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any inline configuration provided during execution.
568
+ *
569
+ * @param config - The inline configuration values to set.
570
+ * @returns A promise that resolves when the inline configuration values have been set.
571
+ */
572
+ setInlineConfig(config: TResolvedConfig["inlineConfig"]): Promise<void>;
573
+ /**
574
+ * Create a new logger instance
575
+ *
576
+ * @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.
577
+ * @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.
578
+ * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
579
+ */
580
+ createLogger(options: LoggerOptions, logFn?: LogFn): Logger;
581
+ /**
582
+ * Extend the base logger with additional configuration options
583
+ *
584
+ * @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.
585
+ * @returns A new logger client instance that extends the base logger with the provided configuration options.
586
+ */
587
+ extendLogger(options: LoggerOptions): Logger;
588
+ /**
589
+ * A function to copy the context and update the fields for a specific environment
590
+ *
591
+ * @param environment - The environment configuration to use.
592
+ * @returns A new context instance with the updated environment.
593
+ */
594
+ createEnvironment(environment: EnvironmentResolvedConfig<TResolvedConfig>["environment"]): Promise<Unstable_EnvironmentContext<TResolvedConfig>>;
595
+ /**
596
+ * Update the context using a new inline configuration options
597
+ */
598
+ resolveConfig(): Promise<void>;
599
+ /**
600
+ * Add a plugin to the API context and all environments
601
+ *
602
+ * @param plugin - The plugin to add.
603
+ */
604
+ addPlugin(plugin: Plugin<PluginContext<TResolvedConfig>>): Promise<void>;
605
+ /**
606
+ * Get an environment by name, or the default environment if no name is provided
607
+ *
608
+ * @param name - The name of the environment to retrieve.
609
+ * @returns The requested environment context.
610
+ */
611
+ getEnvironment(name?: string): Promise<EnvironmentContext<TResolvedConfig>>;
612
+ /**
613
+ * A safe version of `getEnvironment` that returns `undefined` if the environment is not found
614
+ *
615
+ * @param name - The name of the environment to retrieve.
616
+ * @returns The requested environment context or `undefined` if not found.
617
+ */
618
+ getEnvironmentSafe(name?: string): Promise<EnvironmentContext<TResolvedConfig> | undefined>;
619
+ /**
620
+ * A function to merge all configured environments into a single context.
621
+ *
622
+ * @remarks
623
+ * If only one environment is configured, that environment will be returned directly.
624
+ *
625
+ * @returns A promise that resolves to a merged/global environment context.
626
+ */
627
+ toEnvironment(): Promise<EnvironmentContext<TResolvedConfig>>;
628
+ }
629
+ //#endregion
630
+ export { PowerlinesContext as n, PowerlinesBaseContext as r, PowerlinesExecutionContext as t };
631
+ //# sourceMappingURL=execution-context-CU6iNchD.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-context-CU6iNchD.d.cts","names":[],"sources":["../src/context/base-context.ts","../src/context/context.ts","../src/context/execution-context.ts"],"mappings":";;;;;;;;;;;cA6Da,qBAAA,YAAiC,WAAA;EAAA;;;;EAMrC,cAAA;;AANT;;EAWS,QAAA,EAAW,QAAA;EAAA;;;EAKX,OAAA,EAAU,YAAA,CACf,aAAA;EAYkB;;;EALb,WAAA,EAAc,WAAA;EAiCE;;;EA5BhB,WAAA,EAAa,MAAA;EAiEW;;;EA5DxB,UAAA,EAAa,gBAAA;EAgGW;;;EAAA,IA3FpB,MAAA,CAAA,GAAU,MAAA;EAoJQ;;;EAAA,IA7IlB,SAAA,CAAA;EAAA,IAIA,QAAA,CAAA,GAAY,sBAAA;EA8JZ;;;EAAA,IAvJA,QAAA,CAAA,GAAY,QAAA;EAmKe;;;;;;;;EAnJzB,KAAA,CAAA,GAAS,OAAA,CAAQ,WAAA;EAzEc;;;;;EAqFrC,KAAA,CAAM,OAAA,WAAkB,UAAA;EArEd;;;;;EA8EV,KAAA,CAAM,OAAA,WAAkB,UAAA;EA5DxB;;;;;EAqEA,IAAA,CAAK,OAAA,WAAkB,UAAA;EArDP;;;;;EA8DhB,IAAA,CAAK,OAAA,WAAkB,UAAA;EA3BvB;;;;;EAoCA,KAAA,CAAM,OAAA,WAAkB,UAAA;EAlBxB;;;;;EA2BA,KAAA,CAAM,OAAA,WAAkB,UAAA;EATxB;;;;;;;;;;;;;EA0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