@powerlines/engine 0.46.0 → 0.46.1

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 (33) hide show
  1. package/dist/_internal/worker.cjs +53 -25
  2. package/dist/_internal/worker.mjs +53 -25
  3. package/dist/_internal/worker.mjs.map +1 -1
  4. package/dist/api.cjs +1 -1
  5. package/dist/api.d.cts +1 -1
  6. package/dist/api.d.cts.map +1 -1
  7. package/dist/api.d.mts +1 -1
  8. package/dist/api.d.mts.map +1 -1
  9. package/dist/api.mjs +1 -1
  10. package/dist/api.mjs.map +1 -1
  11. package/dist/{base-context-BCG0xN2e.cjs → base-context-D7G_24-i.cjs} +21 -21
  12. package/dist/{base-context-Cmo6TTh7.mjs → base-context-DU0NRHDt.mjs} +22 -22
  13. package/dist/base-context-DU0NRHDt.mjs.map +1 -0
  14. package/dist/context/index.cjs +3 -3
  15. package/dist/context/index.d.cts +1 -1
  16. package/dist/context/index.d.mts +1 -1
  17. package/dist/context/index.mjs +3 -3
  18. package/dist/{engine-context-DOsGtgD9.cjs → engine-context-BuJQY312.cjs} +1 -1
  19. package/dist/{engine-context-BjFMVQEE.mjs → engine-context-BvDfqfY7.mjs} +2 -2
  20. package/dist/{engine-context-BjFMVQEE.mjs.map → engine-context-BvDfqfY7.mjs.map} +1 -1
  21. package/dist/{execution-context-BdZt7wWa.d.mts → execution-context-BpRfsnkE.d.mts} +23 -10
  22. package/dist/execution-context-BpRfsnkE.d.mts.map +1 -0
  23. package/dist/{execution-context-DgqxcDDx.cjs → execution-context-BrX9i_L8.cjs} +33 -5
  24. package/dist/{execution-context-Cp32TarF.mjs → execution-context-CgDuoi8o.mjs} +34 -6
  25. package/dist/{execution-context-Cp32TarF.mjs.map → execution-context-CgDuoi8o.mjs.map} +1 -1
  26. package/dist/{execution-context-CU6iNchD.d.cts → execution-context-CodQucFX.d.cts} +23 -10
  27. package/dist/execution-context-CodQucFX.d.cts.map +1 -0
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.mjs +1 -1
  30. package/package.json +3 -3
  31. package/dist/base-context-Cmo6TTh7.mjs.map +0 -1
  32. package/dist/execution-context-BdZt7wWa.d.mts.map +0 -1
  33. package/dist/execution-context-CU6iNchD.d.cts.map +0 -1
@@ -50,7 +50,7 @@ function createResolver(options) {
50
50
 
51
51
  //#endregion
52
52
  //#region src/context/base-context.ts
53
- var PowerlinesBaseContext = class PowerlinesBaseContext {
53
+ var PowerlinesBaseContext = class {
54
54
  #timestamp = Date.now();
55
55
  /**
56
56
  * The path to the Powerlines package
@@ -102,19 +102,6 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
102
102
  });
103
103
  }
104
104
  /**
105
- * 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.
106
- *
107
- * @remarks
108
- * 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.
109
- *
110
- * @returns A promise that resolves to the cloned context.
111
- */
112
- async clone() {
113
- const clone = new PowerlinesBaseContext(this.options, this.initialConfig);
114
- await clone.init();
115
- return clone;
116
- }
117
- /**
118
105
  * A logging function for fatal messages
119
106
  *
120
107
  * @param message - The message to log.
@@ -269,13 +256,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
269
256
  cacheDir: this.envPaths.cache,
270
257
  mode: this.options.mode
271
258
  });
272
- const projectJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(this.options.root, this.options.cwd), "project.json");
273
- if ((0, node_fs.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs.readJsonFile)(projectJsonPath);
274
- const packageJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(this.options.root, this.options.cwd), "package.json");
275
- if ((0, node_fs.existsSync)(packageJsonPath)) {
276
- this.packageJson = await (0, _stryke_fs.readJsonFile)(packageJsonPath);
277
- this.options.organization ??= (0, _stryke_type_checks_is_set_object.isSetObject)(this.packageJson?.author) ? (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author?.name) : (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author);
278
- }
259
+ await this.resolvePackageConfigs();
279
260
  this.configFile = await (0, _powerlines_core_lib_config.loadUserConfigFile)(this.options, this.resolver);
280
261
  if (this.configFile.config) {
281
262
  if ((0, _stryke_type_checks_is_set_string.isSetString)(this.configFile.configFile)) this.options.configFile ??= (0, _stryke_path_replace.replacePath)(this.configFile.configFile, this.options.cwd);
@@ -292,6 +273,25 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
292
273
  }
293
274
  }
294
275
  /**
276
+ * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.
277
+ *
278
+ * @remarks
279
+ * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
280
+ *
281
+ * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
282
+ * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
283
+ * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
284
+ */
285
+ async resolvePackageConfigs(cwd = this.options.cwd, root = this.options.root) {
286
+ const projectJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root, cwd), "project.json");
287
+ if ((0, node_fs.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs.readJsonFile)(projectJsonPath);
288
+ const packageJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root, cwd), "package.json");
289
+ if ((0, node_fs.existsSync)(packageJsonPath)) {
290
+ this.packageJson = await (0, _stryke_fs.readJsonFile)(packageJsonPath);
291
+ this.options.organization ??= (0, _stryke_type_checks_is_set_object.isSetObject)(this.packageJson?.author) ? (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author?.name) : (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author);
292
+ }
293
+ }
294
+ /**
295
295
  * 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".
296
296
  *
297
297
  * @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
@@ -47,7 +47,7 @@ function createResolver(options) {
47
47
 
48
48
  //#endregion
49
49
  //#region src/context/base-context.ts
50
- var PowerlinesBaseContext = class PowerlinesBaseContext {
50
+ var PowerlinesBaseContext = class {
51
51
  #timestamp = Date.now();
52
52
  /**
53
53
  * The path to the Powerlines package
@@ -99,19 +99,6 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
99
99
  });
100
100
  }
101
101
  /**
102
- * 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.
103
- *
104
- * @remarks
105
- * 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.
106
- *
107
- * @returns A promise that resolves to the cloned context.
108
- */
109
- async clone() {
110
- const clone = new PowerlinesBaseContext(this.options, this.initialConfig);
111
- await clone.init();
112
- return clone;
113
- }
114
- /**
115
102
  * A logging function for fatal messages
116
103
  *
117
104
  * @param message - The message to log.
@@ -266,13 +253,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
266
253
  cacheDir: this.envPaths.cache,
267
254
  mode: this.options.mode
268
255
  });
269
- const projectJsonPath = joinPaths(appendPath(this.options.root, this.options.cwd), "project.json");
270
- if (existsSync(projectJsonPath)) this.projectJson = await readJsonFile(projectJsonPath);
271
- const packageJsonPath = joinPaths(appendPath(this.options.root, this.options.cwd), "package.json");
272
- if (existsSync(packageJsonPath)) {
273
- this.packageJson = await readJsonFile(packageJsonPath);
274
- this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
275
- }
256
+ await this.resolvePackageConfigs();
276
257
  this.configFile = await loadUserConfigFile(this.options, this.resolver);
277
258
  if (this.configFile.config) {
278
259
  if (isSetString(this.configFile.configFile)) this.options.configFile ??= replacePath(this.configFile.configFile, this.options.cwd);
@@ -289,6 +270,25 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
289
270
  }
290
271
  }
291
272
  /**
273
+ * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.
274
+ *
275
+ * @remarks
276
+ * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
277
+ *
278
+ * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
279
+ * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
280
+ * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
281
+ */
282
+ async resolvePackageConfigs(cwd = this.options.cwd, root = this.options.root) {
283
+ const projectJsonPath = joinPaths(appendPath(root, cwd), "project.json");
284
+ if (existsSync(projectJsonPath)) this.projectJson = await readJsonFile(projectJsonPath);
285
+ const packageJsonPath = joinPaths(appendPath(root, cwd), "package.json");
286
+ if (existsSync(packageJsonPath)) {
287
+ this.packageJson = await readJsonFile(packageJsonPath);
288
+ this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
289
+ }
290
+ }
291
+ /**
292
292
  * 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".
293
293
  *
294
294
  * @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
@@ -310,4 +310,4 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
310
310
 
311
311
  //#endregion
312
312
  export { PowerlinesBaseContext as t };
313
- //# sourceMappingURL=base-context-Cmo6TTh7.mjs.map
313
+ //# sourceMappingURL=base-context-DU0NRHDt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-context-DU0NRHDt.mjs","names":["joinPaths","#timestamp","createLogger"],"sources":["../src/_internal/helpers/resolver.ts","../src/context/base-context.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ResolvedConfig, Resolver } from \"@powerlines/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport { JitiOptions, createJiti } from \"jiti\";\n\nexport type CreateResolverOptions = Omit<\n JitiOptions,\n \"fsCache\" | \"moduleCache\" | \"interopDefault\"\n> &\n Partial<Pick<ResolvedConfig, \"mode\" | \"skipCache\">> & {\n workspaceRoot: string;\n root: string;\n cacheDir: string;\n };\n\n/**\n * Create a Jiti resolver for the given workspace and project root.\n *\n * @param options - The options for creating the resolver.\n * @returns A Jiti instance configured for the specified workspace and project root.\n */\nfunction resolveOptions(options: CreateResolverOptions): JitiOptions {\n return defu(options, {\n interopDefault: true,\n fsCache:\n options.mode !== \"development\"\n ? joinPaths(options.cacheDir, \"jiti\")\n : false,\n moduleCache: options.mode !== \"development\"\n });\n}\n\n/**\n * Create a Jiti resolver for the given workspace and project root.\n *\n * @param options - The options for creating the resolver.\n * @returns A Jiti instance configured for the specified workspace and project root.\n */\nexport function createResolver(options: CreateResolverOptions): Resolver {\n const baseResolver = createJiti(\n joinPaths(options.workspaceRoot, options.root),\n resolveOptions(options)\n ) as Resolver;\n baseResolver.plugin = createJiti(\n joinPaths(options.workspaceRoot, options.root),\n resolveOptions(options)\n );\n\n return baseResolver;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n BaseContext,\n EngineOptions,\n LogFn,\n Logger,\n LoggerOptions,\n LogLevelResolvedConfig,\n LogMessage,\n Mode,\n ParsedUserConfig,\n Resolver,\n UserConfig,\n WorkspaceConfig\n} from \"@powerlines/core\";\nimport { loadUserConfigFile } from \"@powerlines/core/lib/config\";\nimport { resolveLogLevel } from \"@powerlines/core/plugin-utils\";\nimport {\n createLogger,\n extendLogger\n} from \"@powerlines/core/plugin-utils/logging\";\nimport { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport {\n isDevelopment,\n isProduction,\n isTest\n} from \"@stryke/env/environment-checks\";\nimport { EnvPaths, getEnvPaths } from \"@stryke/env/get-env-paths\";\nimport { isFile, readJsonFile } from \"@stryke/fs\";\nimport { resolvePackage } from \"@stryke/fs/resolve\";\nimport { findFilePath, joinPaths, relativePath } from \"@stryke/path\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { DeepPartial, RequiredKeys } from \"@stryke/types/base\";\nimport { PackageJson } from \"@stryke/types/package-json\";\nimport chalk from \"chalk\";\nimport { formatDistanceToNowStrict } from \"date-fns/formatDistanceToNowStrict\";\nimport defu from \"defu\";\nimport { existsSync } from \"node:fs\";\nimport { createResolver } from \"../_internal/helpers/resolver\";\n\nexport class PowerlinesBaseContext implements BaseContext {\n #timestamp: number = Date.now();\n\n /**\n * The path to the Powerlines package\n */\n public powerlinesPath!: string;\n\n /**\n * The module resolver for the project\n */\n public resolver!: Resolver;\n\n /**\n * 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.\n */\n public options!: RequiredKeys<\n EngineOptions,\n \"mode\" | \"cwd\" | \"root\" | \"framework\"\n >;\n\n /**\n * The parsed `package.json` file for the project\n */\n public packageJson!: PackageJson;\n\n /**\n * The parsed `project.json` file for the project\n */\n public projectJson: Record<string, any> | undefined = undefined;\n\n /**\n * The parsed configuration file for the project\n */\n public configFile!: ParsedUserConfig;\n\n /**\n * 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.\n */\n public get logger(): Logger {\n return this.createLogger({});\n }\n\n /**\n * A timestamp representing when the context was initialized\n */\n public get timestamp(): number {\n return this.#timestamp;\n }\n\n public get logLevel(): LogLevelResolvedConfig {\n return resolveLogLevel(this.options.logLevel, this.options.mode);\n }\n\n /**\n * The environment paths for the project\n */\n public get envPaths(): EnvPaths {\n return getEnvPaths({\n orgId: this.options.organization,\n appId: this.options.framework || \"powerlines\",\n workspaceRoot: this.options.cwd\n });\n }\n\n /**\n * A logging function for fatal messages\n *\n * @param message - The message to log.\n */\n public fatal(message: string | LogMessage) {\n this.logger.error(message);\n }\n\n /**\n * A logging function for error messages\n *\n * @param message - The message to log.\n */\n public error(message: string | LogMessage) {\n this.logger.error(message);\n }\n\n /**\n * A logging function for warning messages\n *\n * @param message - The message to log.\n */\n public warn(message: string | LogMessage) {\n this.logger.warn(message);\n }\n\n /**\n * A logging function for informational messages\n *\n * @param message - The message to log.\n */\n public info(message: string | LogMessage) {\n this.logger.info(message);\n }\n\n /**\n * A logging function for debug messages\n *\n * @param message - The message to log.\n */\n public debug(message: string | LogMessage) {\n this.logger.debug(message);\n }\n\n /**\n * A logging function for trace messages\n *\n * @param message - The message to log.\n */\n public trace(message: string | LogMessage) {\n this.logger.trace(message);\n }\n\n /**\n * A function to create a timer for measuring the duration of asynchronous operations\n *\n * @example\n * ```ts\n * const stopTimer = context.timer(\"Your Async Operation\");\n * await performAsyncOperation();\n * stopTimer(); // \"Your Async Operation completed in 123.45 milliseconds\"\n * ```\n *\n * @param name - The name of the timer.\n * @returns A function that, when called, stops the timer and logs the duration.\n */\n public timer(name: string): () => void {\n const startDate = Date.now();\n const startDuration = performance.now();\n\n return () => {\n const duration = performance.now() - startDuration;\n this.logger.info({\n meta: {\n category: \"performance\"\n },\n message: `${chalk.bold.cyanBright(name)} completed in ${chalk.bold.cyanBright(\n duration < 1000\n ? `${duration.toFixed(2)} milliseconds`\n : formatDistanceToNowStrict(startDate)\n )}`\n });\n };\n }\n\n /**\n * Create a new logger instance\n *\n * @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.\n * @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.\n * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.\n */\n public createLogger(options: LoggerOptions, logFn?: LogFn): Logger {\n return createLogger(\n this.options.name || this.options.root || \"powerlines\",\n { ...this.configFile.config, ...this.options, ...options },\n logFn\n );\n }\n\n /**\n * Extend the base logger with additional configuration options\n *\n * @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.\n * @returns A new logger client instance that extends the base logger with the provided configuration options.\n */\n public extendLogger(options: LoggerOptions): Logger {\n return extendLogger(this.logger, options);\n }\n\n /**\n * 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\n */\n protected initialOptions: EngineOptions = {};\n\n /**\n * 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.\n */\n protected initialConfig: DeepPartial<UserConfig> = {};\n\n /**\n * 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.\n *\n * @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.\n * @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\n */\n protected constructor(\n options: EngineOptions,\n initialConfig: DeepPartial<UserConfig> = {}\n ) {\n this.initialOptions = options;\n this.initialConfig = initialConfig;\n }\n\n /**\n * 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.\n *\n * @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.\n */\n protected async getWorkspaceConfig(): Promise<WorkspaceConfig | undefined> {\n return tryGetWorkspaceConfig(\n false,\n this.options || this.initialOptions\n ? {\n cwd:\n this.options?.root || this.initialOptions?.root\n ? appendPath(\n this.options?.root || this.initialOptions?.root || \".\",\n this.options?.cwd || this.initialOptions?.cwd\n )\n : undefined,\n workspaceRoot: this.options?.cwd || this.initialOptions?.cwd\n }\n : undefined\n );\n }\n\n /**\n * Initialize the context with the provided configuration options\n *\n * @remarks\n * 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.\n */\n protected async init() {\n if (!this.powerlinesPath) {\n const powerlinesPath = await resolvePackage(\"powerlines\");\n if (!powerlinesPath) {\n throw new Error(\"Could not resolve `powerlines` package location.\");\n }\n this.powerlinesPath = powerlinesPath;\n }\n\n this.options = defu(this.initialOptions, this.initialConfig, {\n cwd: process.cwd(),\n mode: await this.getDefaultMode(),\n logLevel: await this.getDefaultLogLevel(),\n framework: \"powerlines\"\n }) as RequiredKeys<EngineOptions, \"mode\" | \"cwd\" | \"root\" | \"framework\">;\n\n if (!this.options.root) {\n if (this.options.configFile) {\n const configFile = appendPath(\n this.options.configFile,\n this.options.cwd\n );\n if (!existsSync(configFile)) {\n throw new Error(\n `The user-provided configuration file at \"${\n this.options.configFile\n }\" does not exist. Please ensure this path is correct and try again.`\n );\n }\n if (!isFile(configFile)) {\n throw new Error(\n `The user-provided configuration file at \"${\n this.options.configFile\n }\" is not a file. Please ensure this path is correct and try again.`\n );\n }\n\n this.options.root = relativePath(\n this.options.cwd,\n findFilePath(configFile)\n );\n } else {\n this.options.root = \".\";\n }\n } else {\n this.options.root = replacePath(this.options.root, this.options.cwd);\n }\n\n this.resolver = createResolver({\n workspaceRoot: this.options.cwd,\n root: this.options.root,\n cacheDir: this.envPaths.cache,\n mode: this.options.mode\n });\n\n await this.resolvePackageConfigs();\n\n this.configFile = await loadUserConfigFile(this.options, this.resolver);\n if (this.configFile.config) {\n if (isSetString(this.configFile.configFile)) {\n this.options.configFile ??= replacePath(\n this.configFile.configFile,\n this.options.cwd\n );\n }\n\n if (!this.options.name) {\n if (\n isSetObject(this.configFile.config) &&\n isSetString((this.configFile.config as UserConfig).name)\n ) {\n this.options.name = (this.configFile.config as UserConfig).name;\n } else if (Array.isArray(this.configFile.config)) {\n for (const config of this.configFile.config) {\n if (\n isSetObject(config) &&\n isSetString((config as UserConfig).name)\n ) {\n this.options.name = (config as UserConfig).name;\n break;\n }\n }\n }\n }\n\n if (!this.options.name) {\n this.options.name = this.projectJson?.name || this.packageJson?.name;\n }\n }\n }\n\n /**\n * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.\n *\n * @remarks\n * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.\n *\n * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.\n * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.\n * @returns A promise that resolves when the package configurations have been loaded and stored in the context.\n */\n protected async resolvePackageConfigs(\n cwd: string = this.options.cwd,\n root: string = this.options.root\n ) {\n const projectJsonPath = joinPaths(appendPath(root, cwd), \"project.json\");\n if (existsSync(projectJsonPath)) {\n this.projectJson = await readJsonFile(projectJsonPath);\n }\n\n const packageJsonPath = joinPaths(appendPath(root, cwd), \"package.json\");\n if (existsSync(packageJsonPath)) {\n this.packageJson = await readJsonFile<PackageJson>(packageJsonPath);\n this.options.organization ??= isSetObject(this.packageJson?.author)\n ? kebabCase(this.packageJson?.author?.name)\n : kebabCase(this.packageJson?.author);\n }\n }\n\n /**\n * 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\".\n *\n * @returns A promise that resolves to the default mode for the current execution, which can be \"development\", \"production\", or \"test\".\n */\n protected async getDefaultMode(): Promise<Mode> {\n const workspaceConfig = await this.getWorkspaceConfig();\n\n return isProduction\n ? \"production\"\n : isDevelopment\n ? \"development\"\n : isTest\n ? \"test\"\n : workspaceConfig?.mode || \"production\";\n }\n\n /**\n * 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.\n *\n * @returns A promise that resolves to the default log level for the current execution, which can be \"fatal\", \"error\", \"warn\", \"info\", \"debug\", or \"trace\".\n */\n protected async getDefaultLogLevel(): Promise<LogLevelResolvedConfig> {\n const workspaceConfig = await this.getWorkspaceConfig();\n\n return resolveLogLevel(\n workspaceConfig?.logLevel\n ? workspaceConfig.logLevel === \"success\" ||\n workspaceConfig.logLevel === \"performance\"\n ? \"info\"\n : workspaceConfig.logLevel === \"all\"\n ? \"debug\"\n : workspaceConfig.logLevel === \"fatal\"\n ? \"error\"\n : workspaceConfig.logLevel\n : undefined,\n this.options?.mode ||\n this.initialOptions?.mode ||\n workspaceConfig?.mode ||\n (await this.getDefaultMode())\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAS,eAAe,SAA6C;AACnE,QAAO,KAAK,SAAS;EACnB,gBAAgB;EAChB,SACE,QAAQ,SAAS,gBACbA,YAAU,QAAQ,UAAU,OAAO,GACnC;EACN,aAAa,QAAQ,SAAS;EAC/B,CAAC;;;;;;;;AASJ,SAAgB,eAAe,SAA0C;CACvE,MAAM,eAAe,WACnBA,YAAU,QAAQ,eAAe,QAAQ,KAAK,EAC9C,eAAe,QAAQ,CACxB;AACD,cAAa,SAAS,WACpBA,YAAU,QAAQ,eAAe,QAAQ,KAAK,EAC9C,eAAe,QAAQ,CACxB;AAED,QAAO;;;;;ACLT,IAAa,wBAAb,MAA0D;CACxD,aAAqB,KAAK,KAAK;;;;CAK/B,AAAO;;;;CAKP,AAAO;;;;CAKP,AAAO;;;;CAQP,AAAO;;;;CAKP,AAAO,cAA+C;;;;CAKtD,AAAO;;;;CAKP,IAAW,SAAiB;AAC1B,SAAO,KAAK,aAAa,EAAE,CAAC;;;;;CAM9B,IAAW,YAAoB;AAC7B,SAAO,MAAKC;;CAGd,IAAW,WAAmC;AAC5C,SAAO,gBAAgB,KAAK,QAAQ,UAAU,KAAK,QAAQ,KAA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ACH,eACA,gBACE,gBACA,SACE,SACA,iBAAiB,QAAQ;;;;;;;CAQnC,MAAgB,qBAAsD;EACpE,MAAM,kBAAkB,MAAM,KAAK,oBAAoB;AAEvD,SAAO,gBACL,iBAAiB,WACb,gBAAgB,aAAa,aAC7B,gBAAgB,aAAa,gBAC3B,SACA,gBAAgB,aAAa,QAC3B,UACA,gBAAgB,aAAa,UAC3B,UACA,gBAAgB,WACtB,QACJ,KAAK,SAAS,QACZ,KAAK,gBAAgB,QACrB,iBAAiB,QAChB,MAAM,KAAK,gBAAgB,CAC/B"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_base_context = require('../base-context-BCG0xN2e.cjs');
3
- const require_engine_context = require('../engine-context-DOsGtgD9.cjs');
4
- const require_execution_context = require('../execution-context-DgqxcDDx.cjs');
2
+ const require_base_context = require('../base-context-D7G_24-i.cjs');
3
+ const require_engine_context = require('../engine-context-BuJQY312.cjs');
4
+ const require_execution_context = require('../execution-context-BrX9i_L8.cjs');
5
5
 
6
6
  exports.PowerlinesBaseContext = require_base_context.PowerlinesBaseContext;
7
7
  exports.PowerlinesContext = require_execution_context.PowerlinesContext;
@@ -1,4 +1,4 @@
1
- import { n as PowerlinesContext, r as PowerlinesBaseContext, t as PowerlinesExecutionContext } from "../execution-context-CU6iNchD.cjs";
1
+ import { n as PowerlinesContext, r as PowerlinesBaseContext, t as PowerlinesExecutionContext } from "../execution-context-CodQucFX.cjs";
2
2
  import { EngineContext, EngineOptions, EnvironmentContextPlugin, EnvironmentResolvedConfig, ExecutionOptions, ExecutionState, HooksList, InferOverridableConfig, LogFn, LogLevelResolvedConfig, Logger, LoggerOptions, Plugin, PluginContext, ResolvedConfig, SelectHookResult, SelectHooksOptions, UserConfig } from "@powerlines/core";
3
3
  import { DeepPartial, RequiredKeys } from "@stryke/types/base";
4
4
  import { Unstable_ContextInternal, Unstable_EnvironmentContext, Unstable_PluginContext } from "@powerlines/core/types/_internal";
@@ -1,4 +1,4 @@
1
- import { n as PowerlinesContext, r as PowerlinesBaseContext, t as PowerlinesExecutionContext } from "../execution-context-BdZt7wWa.mjs";
1
+ import { n as PowerlinesContext, r as PowerlinesBaseContext, t as PowerlinesExecutionContext } from "../execution-context-BpRfsnkE.mjs";
2
2
  import { EngineContext, EngineOptions, EnvironmentContextPlugin, EnvironmentResolvedConfig, ExecutionOptions, ExecutionState, HooksList, InferOverridableConfig, LogFn, LogLevelResolvedConfig, Logger, LoggerOptions, Plugin, PluginContext, ResolvedConfig, SelectHookResult, SelectHooksOptions, UserConfig } from "@powerlines/core";
3
3
  import { DeepPartial, RequiredKeys } from "@stryke/types/base";
4
4
  import { Unstable_ContextInternal, Unstable_EnvironmentContext, Unstable_PluginContext } from "@powerlines/core/types/_internal";
@@ -1,5 +1,5 @@
1
- import { t as PowerlinesBaseContext } from "../base-context-Cmo6TTh7.mjs";
2
- import { t as PowerlinesEngineContext } from "../engine-context-BjFMVQEE.mjs";
3
- import { n as PowerlinesEnvironmentContext, o as PowerlinesContext, r as createPluginContext, t as PowerlinesExecutionContext } from "../execution-context-Cp32TarF.mjs";
1
+ import { t as PowerlinesBaseContext } from "../base-context-DU0NRHDt.mjs";
2
+ import { t as PowerlinesEngineContext } from "../engine-context-BvDfqfY7.mjs";
3
+ import { n as PowerlinesEnvironmentContext, o as PowerlinesContext, r as createPluginContext, t as PowerlinesExecutionContext } from "../execution-context-CgDuoi8o.mjs";
4
4
 
5
5
  export { PowerlinesBaseContext, PowerlinesContext, PowerlinesEngineContext, PowerlinesEnvironmentContext, PowerlinesExecutionContext, createPluginContext };
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-C0xms8kb.cjs');
2
- const require_base_context = require('./base-context-BCG0xN2e.cjs');
2
+ const require_base_context = require('./base-context-D7G_24-i.cjs');
3
3
  let _stryke_convert_to_array = require("@stryke/convert/to-array");
4
4
  let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
5
5
 
@@ -1,4 +1,4 @@
1
- import { t as PowerlinesBaseContext } from "./base-context-Cmo6TTh7.mjs";
1
+ import { t as PowerlinesBaseContext } from "./base-context-DU0NRHDt.mjs";
2
2
  import { toArray } from "@stryke/convert/to-array";
3
3
  import { uuid } from "@stryke/unique-id/uuid";
4
4
 
@@ -83,4 +83,4 @@ var PowerlinesEngineContext = class PowerlinesEngineContext extends PowerlinesBa
83
83
 
84
84
  //#endregion
85
85
  export { PowerlinesEngineContext as t };
86
- //# sourceMappingURL=engine-context-BjFMVQEE.mjs.map
86
+ //# sourceMappingURL=engine-context-BvDfqfY7.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-context-BjFMVQEE.mjs","names":["#executions"],"sources":["../src/context/engine-context.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n EngineContext,\n EngineOptions,\n ExecutionState,\n LogLevelResolvedConfig,\n UserConfig\n} from \"@powerlines/core\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { DeepPartial, RequiredKeys } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { PowerlinesBaseContext } from \"./base-context\";\n\nexport class PowerlinesEngineContext\n extends PowerlinesBaseContext\n implements EngineContext\n{\n #executions: ExecutionState[] = [];\n\n /**\n * Creates a new instance of the PowerlinesEngineContext class.\n *\n * @param options - The options to initialize the context with.\n * @returns A promise that resolves to an instance of the PowerlinesEngineContext class.\n */\n public static async fromInitialConfig(\n options: EngineOptions,\n initialConfig: DeepPartial<UserConfig> = {}\n ): Promise<PowerlinesEngineContext> {\n const context = new PowerlinesEngineContext(options, initialConfig);\n await context.init();\n\n return context;\n }\n\n /**\n * 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.\n */\n public override readonly initialOptions: EngineOptions;\n\n /**\n * 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.\n */\n public override readonly initialConfig: DeepPartial<UserConfig>;\n\n /**\n * The options provided to the Powerlines process\n */\n public override options: RequiredKeys<\n Omit<EngineOptions, \"logLevel\">,\n \"name\" | \"root\" | \"cwd\" | \"mode\" | \"framework\"\n > & {\n /**\n * 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.\n */\n logLevel: LogLevelResolvedConfig;\n } = {} as RequiredKeys<\n Omit<EngineOptions, \"logLevel\">,\n \"name\" | \"root\" | \"cwd\" | \"mode\" | \"framework\"\n > & {\n /**\n * 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.\n */\n logLevel: LogLevelResolvedConfig;\n };\n\n /**\n * Creates a new Context instance.\n *\n * @param options - The options to use for creating the context, including the resolved configuration and workspace settings.\n * @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.\n */\n protected constructor(\n options: EngineOptions,\n initialConfig: DeepPartial<UserConfig> = {}\n ) {\n super(options, initialConfig);\n this.initialOptions = options;\n this.initialConfig = initialConfig;\n }\n\n /**\n * Initialize the context with the provided configuration options\n *\n * @remarks\n * 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.\n */\n protected override async init() {\n await super.init();\n\n if (!this.configFile?.config) {\n this.fatal(\n \"No configuration file found. Please ensure you have a valid configuration file in your project.\"\n );\n throw new Error(\"No configuration file found\");\n }\n\n this.#executions = await Promise.all(\n toArray(this.configFile.config).map(async (_, executionIndex) => {\n const executionId = uuid();\n\n return {\n executionId,\n options: {\n cwd: this.options.cwd,\n root: this.options.root,\n configFile: this.options.configFile,\n ...this.initialOptions,\n executionId,\n executionIndex\n },\n active: {\n command: null,\n hook: null,\n plugin: null\n }\n };\n })\n );\n }\n\n /**\n * A list of all command executions that will be run during the lifecycle of the engine\n *\n * @returns An array of {@link ExecutionState} representing each execution context for the engine.\n */\n public get executions(): ExecutionState[] {\n return this.#executions;\n }\n}\n"],"mappings":";;;;;AA8BA,IAAa,0BAAb,MAAa,gCACH,sBAEV;CACE,cAAgC,EAAE;;;;;;;CAQlC,aAAoB,kBAClB,SACA,gBAAyC,EAAE,EACT;EAClC,MAAM,UAAU,IAAI,wBAAwB,SAAS,cAAc;AACnE,QAAM,QAAQ,MAAM;AAEpB,SAAO;;;;;CAMT,AAAyB;;;;CAKzB,AAAyB;;;;CAKzB,AAAgB,UAQZ,EAAE;;;;;;;CAgBN,AAAU,YACR,SACA,gBAAyC,EAAE,EAC3C;AACA,QAAM,SAAS,cAAc;AAC7B,OAAK,iBAAiB;AACtB,OAAK,gBAAgB;;;;;;;;CASvB,MAAyB,OAAO;AAC9B,QAAM,MAAM,MAAM;AAElB,MAAI,CAAC,KAAK,YAAY,QAAQ;AAC5B,QAAK,MACH,kGACD;AACD,SAAM,IAAI,MAAM,8BAA8B;;AAGhD,QAAKA,aAAc,MAAM,QAAQ,IAC/B,QAAQ,KAAK,WAAW,OAAO,CAAC,IAAI,OAAO,GAAG,mBAAmB;GAC/D,MAAM,cAAc,MAAM;AAE1B,UAAO;IACL;IACA,SAAS;KACP,KAAK,KAAK,QAAQ;KAClB,MAAM,KAAK,QAAQ;KACnB,YAAY,KAAK,QAAQ;KACzB,GAAG,KAAK;KACR;KACA;KACD;IACD,QAAQ;KACN,SAAS;KACT,MAAM;KACN,QAAQ;KACT;IACF;IACD,CACH;;;;;;;CAQH,IAAW,aAA+B;AACxC,SAAO,MAAKA"}
1
+ {"version":3,"file":"engine-context-BvDfqfY7.mjs","names":["#executions"],"sources":["../src/context/engine-context.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n EngineContext,\n EngineOptions,\n ExecutionState,\n LogLevelResolvedConfig,\n UserConfig\n} from \"@powerlines/core\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { DeepPartial, RequiredKeys } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { PowerlinesBaseContext } from \"./base-context\";\n\nexport class PowerlinesEngineContext\n extends PowerlinesBaseContext\n implements EngineContext\n{\n #executions: ExecutionState[] = [];\n\n /**\n * Creates a new instance of the PowerlinesEngineContext class.\n *\n * @param options - The options to initialize the context with.\n * @returns A promise that resolves to an instance of the PowerlinesEngineContext class.\n */\n public static async fromInitialConfig(\n options: EngineOptions,\n initialConfig: DeepPartial<UserConfig> = {}\n ): Promise<PowerlinesEngineContext> {\n const context = new PowerlinesEngineContext(options, initialConfig);\n await context.init();\n\n return context;\n }\n\n /**\n * 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.\n */\n public override readonly initialOptions: EngineOptions;\n\n /**\n * 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.\n */\n public override readonly initialConfig: DeepPartial<UserConfig>;\n\n /**\n * The options provided to the Powerlines process\n */\n public override options: RequiredKeys<\n Omit<EngineOptions, \"logLevel\">,\n \"name\" | \"root\" | \"cwd\" | \"mode\" | \"framework\"\n > & {\n /**\n * 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.\n */\n logLevel: LogLevelResolvedConfig;\n } = {} as RequiredKeys<\n Omit<EngineOptions, \"logLevel\">,\n \"name\" | \"root\" | \"cwd\" | \"mode\" | \"framework\"\n > & {\n /**\n * 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.\n */\n logLevel: LogLevelResolvedConfig;\n };\n\n /**\n * Creates a new Context instance.\n *\n * @param options - The options to use for creating the context, including the resolved configuration and workspace settings.\n * @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.\n */\n protected constructor(\n options: EngineOptions,\n initialConfig: DeepPartial<UserConfig> = {}\n ) {\n super(options, initialConfig);\n this.initialOptions = options;\n this.initialConfig = initialConfig;\n }\n\n /**\n * Initialize the context with the provided configuration options\n *\n * @remarks\n * 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.\n */\n protected override async init() {\n await super.init();\n\n if (!this.configFile?.config) {\n this.fatal(\n \"No configuration file found. Please ensure you have a valid configuration file in your project.\"\n );\n throw new Error(\"No configuration file found\");\n }\n\n this.#executions = await Promise.all(\n toArray(this.configFile.config).map(async (_, executionIndex) => {\n const executionId = uuid();\n\n return {\n executionId,\n options: {\n cwd: this.options.cwd,\n root: this.options.root,\n configFile: this.options.configFile,\n ...this.initialOptions,\n executionId,\n executionIndex\n },\n active: {\n command: null,\n hook: null,\n plugin: null\n }\n };\n })\n );\n }\n\n /**\n * A list of all command executions that will be run during the lifecycle of the engine\n *\n * @returns An array of {@link ExecutionState} representing each execution context for the engine.\n */\n public get executions(): ExecutionState[] {\n return this.#executions;\n }\n}\n"],"mappings":";;;;;AA8BA,IAAa,0BAAb,MAAa,gCACH,sBAEV;CACE,cAAgC,EAAE;;;;;;;CAQlC,aAAoB,kBAClB,SACA,gBAAyC,EAAE,EACT;EAClC,MAAM,UAAU,IAAI,wBAAwB,SAAS,cAAc;AACnE,QAAM,QAAQ,MAAM;AAEpB,SAAO;;;;;CAMT,AAAyB;;;;CAKzB,AAAyB;;;;CAKzB,AAAgB,UAQZ,EAAE;;;;;;;CAgBN,AAAU,YACR,SACA,gBAAyC,EAAE,EAC3C;AACA,QAAM,SAAS,cAAc;AAC7B,OAAK,iBAAiB;AACtB,OAAK,gBAAgB;;;;;;;;CASvB,MAAyB,OAAO;AAC9B,QAAM,MAAM,MAAM;AAElB,MAAI,CAAC,KAAK,YAAY,QAAQ;AAC5B,QAAK,MACH,kGACD;AACD,SAAM,IAAI,MAAM,8BAA8B;;AAGhD,QAAKA,aAAc,MAAM,QAAQ,IAC/B,QAAQ,KAAK,WAAW,OAAO,CAAC,IAAI,OAAO,GAAG,mBAAmB;GAC/D,MAAM,cAAc,MAAM;AAE1B,UAAO;IACL;IACA,SAAS;KACP,KAAK,KAAK,QAAQ;KAClB,MAAM,KAAK,QAAQ;KACnB,YAAY,KAAK,QAAQ;KACzB,GAAG,KAAK;KACR;KACA;KACD;IACD,QAAQ;KACN,SAAS;KACT,MAAM;KACN,QAAQ;KACT;IACF;IACD,CACH;;;;;;;CAQH,IAAW,aAA+B;AACxC,SAAO,MAAKA"}
@@ -48,15 +48,6 @@ declare class PowerlinesBaseContext implements BaseContext {
48
48
  * The environment paths for the project
49
49
  */
50
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
51
  /**
61
52
  * A logging function for fatal messages
62
53
  *
@@ -150,6 +141,17 @@ declare class PowerlinesBaseContext implements BaseContext {
150
141
  * 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
142
  */
152
143
  protected init(): Promise<void>;
144
+ /**
145
+ * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.
146
+ *
147
+ * @remarks
148
+ * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
149
+ *
150
+ * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
151
+ * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
152
+ * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
153
+ */
154
+ protected resolvePackageConfigs(cwd?: string, root?: string): Promise<void>;
153
155
  /**
154
156
  * 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
157
  *
@@ -504,6 +506,17 @@ declare class PowerlinesContext<TResolvedConfig extends ResolvedConfig = Resolve
504
506
  * Initialize the context with the provided configuration options
505
507
  */
506
508
  protected init(): Promise<void>;
509
+ /**
510
+ * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.
511
+ *
512
+ * @remarks
513
+ * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
514
+ *
515
+ * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
516
+ * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
517
+ * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
518
+ */
519
+ protected resolvePackageConfigs(cwd?: string, root?: string): Promise<void>;
507
520
  /**
508
521
  * Initialize the context with the provided configuration options
509
522
  */
@@ -628,4 +641,4 @@ declare class PowerlinesExecutionContext<TResolvedConfig extends ResolvedConfig
628
641
  }
629
642
  //#endregion
630
643
  export { PowerlinesContext as n, PowerlinesBaseContext as r, PowerlinesExecutionContext as t };
631
- //# sourceMappingURL=execution-context-BdZt7wWa.d.mts.map
644
+ //# sourceMappingURL=execution-context-BpRfsnkE.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-context-BpRfsnkE.d.mts","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;EAoEU;;;EA/DvB,UAAA,EAAa,gBAAA;EA4HgC;;;EAAA,IAvHzC,MAAA,CAAA,GAAU,MAAA;EA4IK;;;EAAA,IArIf,SAAA,CAAA;EAAA,IAIA,QAAA,CAAA,GAAY,sBAAA;EAgJN;;;EAAA,IAzIN,QAAA,CAAA,GAAY,QAAA;EAmRW;;;;;EAtQ3B,KAAA,CAAM,OAAA,WAAkB,UAAA;EAtEwB;;;;;EA+EhD,KAAA,CAAM,OAAA,WAAkB,UAAA;EApEb;;;;;EA6EX,IAAA,CAAK,OAAA,WAAkB,UAAA;EA3DvB;;;;;EAoEA,IAAA,CAAK,OAAA,WAA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AA;EFyFrB;;;;;;;;EAAA,IE7ElB,UAAA,CAAW,KAAA,EAAO,wBAAA,CAAyB,eAAA;EFiHzB;;;EAAA,IEtGlB,EAAA,CAAA;EFyIS;;;EAAA,IElIT,YAAA,CAAA,GAAgB,MAAA,SAEzB,2BAAA,CAA4B,eAAA;EAAA,IAKnB,OAAA,CAAA,GAAW,KAAA,CAAM,MAAA,CAAO,aAAA,CAAc,eAAA;EFwQX;;;;;;EAAA,UE9P7B,WAAA,CACP,OAAA,EAAS,gBAAA,EACT,aAAA,GAAe,eAAA;EF3GV;;;;;;EEwHe,eAAA,CACpB,MAAA,EAAQ,eAAA,mBACP,OAAA;EFxGI;;;;;;;EEkIS,YAAA,CAAa,OAAA,EAAS,aAAA,EAAe,KAAA,GAAQ,KAAA,GAAQ,MAAA;EF7G9C;;;;;;EE8HP,YAAA,CAAa,OAAA,EAAS,aAAA,GAAgB,MAAA;EFjGvB;;;;;;EE+GlB,iBAAA,CACX,WAAA,EAAa,yBAAA,CAA0B,eAAA,mBACtC,OAAA,CAAQ,2BAAA,CAA4B,eAAA;EF/F3B;;;EEiKU,aAAA,CAAA,GAAa,OAAA;EF/I5B;;;;;EEqKM,SAAA,CAAU,MAAA,EAAQ,MAAA,CAAO,aAAA,CAAc,eAAA,KAAiB,OAAA;EF1HxC;;;;;;EE0IhB,cAAA,CAAe,IAAA,YAAa,OAAA,CAAA,kBAAA,CAAA,eAAA;EF5HrB;;;;;;EEoLP,kBAAA,CACX,IAAA,YACC,OAAA,CAAQ,kBAAA,CAAmB,eAAA;EFlKrB;;;;;;;;EEkLI,aAAA,CAAA,GAAiB,OAAA,CAAQ,kBAAA,CAAmB,eAAA;AAAA"}
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-C0xms8kb.cjs');
2
- const require_base_context = require('./base-context-BCG0xN2e.cjs');
2
+ const require_base_context = require('./base-context-D7G_24-i.cjs');
3
3
  const require_fs = require('./fs-XogSgMqT.cjs');
4
4
  const require_virtual = require('./virtual-Ct3ZqPeN.cjs');
5
5
  const require_tsconfig = require('./tsconfig-BUDqmOaT.cjs');
@@ -2011,6 +2011,19 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
2011
2011
  else await this.setUserConfig((0, _stryke_type_checks_is_function.isFunction)(result) ? await Promise.resolve(result(this.options)) : result);
2012
2012
  }
2013
2013
  /**
2014
+ * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.
2015
+ *
2016
+ * @remarks
2017
+ * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
2018
+ *
2019
+ * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
2020
+ * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
2021
+ * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
2022
+ */
2023
+ async resolvePackageConfigs(cwd = this.config.cwd, root = this.config.root) {
2024
+ return super.resolvePackageConfigs(cwd, root);
2025
+ }
2026
+ /**
2014
2027
  * Initialize the context with the provided configuration options
2015
2028
  */
2016
2029
  async resolveConfig() {
@@ -2040,6 +2053,7 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
2040
2053
  mergedConfig.compatibilityDate = (0, compatx.resolveCompatibilityDates)(mergedConfig.compatibilityDate, "latest");
2041
2054
  this.resolvedConfig = mergedConfig;
2042
2055
  this.#configProxy = this.createConfigProxy();
2056
+ if (!this.packageJson) await this.resolvePackageConfigs();
2043
2057
  mergedConfig.input = (0, _powerlines_core_lib_entry.getUniqueInputs)(mergedConfig.input);
2044
2058
  if (mergedConfig.name?.startsWith("@") && mergedConfig.name.split("/").filter(Boolean).length > 1) mergedConfig.name = mergedConfig.name.split("/").filter(Boolean)[1];
2045
2059
  mergedConfig.title ??= (0, _stryke_string_format_title_case.titleCase)(mergedConfig.name);
@@ -2491,10 +2505,10 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
2491
2505
  if ((0, _powerlines_core_plugin_utils.isPluginConfig)(result)) return this.$$internal.addPlugin(result);
2492
2506
  resolvedPlugin = (0, _powerlines_core_plugin_utils.isPlugin)(result) ? result : plugin;
2493
2507
  }
2494
- const pluginId = (0, _stryke_unique_id_uuid.uuid)();
2495
- const context = createPluginContext(pluginId, resolvedPlugin, this);
2508
+ const id = (0, _stryke_unique_id_uuid.uuid)();
2509
+ const context = createPluginContext(id, resolvedPlugin, this);
2496
2510
  this.plugins.push({
2497
- pluginId,
2511
+ id,
2498
2512
  plugin: resolvedPlugin,
2499
2513
  context
2500
2514
  });
@@ -2704,15 +2718,29 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
2704
2718
  */
2705
2719
  async createEnvironment(environment) {
2706
2720
  const context = await PowerlinesEnvironmentContext.createEnvironment((0, _stryke_helpers_deep_clone.deepClone)(this.options), (0, _stryke_helpers_deep_clone.deepClone)(this.config), (0, _stryke_helpers_deep_clone.deepClone)(this.overriddenConfig), (0, _stryke_helpers_deep_clone.deepClone)(environment));
2721
+ context.$$internal = this.$$internal;
2707
2722
  context.dependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.dependencies);
2708
2723
  context.devDependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.devDependencies);
2709
2724
  context.persistedMeta = (0, _stryke_helpers_deep_clone.deepClone)(this.persistedMeta);
2710
2725
  context.resolvePatterns = (0, _stryke_helpers_deep_clone.deepClone)(this.resolvePatterns);
2711
2726
  context.powerlinesPath ??= this.powerlinesPath;
2712
2727
  context.resolver ??= this.resolver;
2713
- context.$$internal = this.$$internal;
2714
2728
  context.plugins = [];
2715
2729
  for (const plugin of this.plugins) await context.addPlugin(plugin);
2730
+ for (const [key, value] of Object.entries(this)) if (![
2731
+ "fs",
2732
+ "$$internal",
2733
+ "dependencies",
2734
+ "devDependencies",
2735
+ "persistedMeta",
2736
+ "packageJson",
2737
+ "projectJson",
2738
+ "tsconfig",
2739
+ "resolver",
2740
+ "plugins",
2741
+ "environments"
2742
+ ].includes(key)) if ((0, _stryke_type_checks_is_object.isObject)(value) || Array.isArray(value)) context[key] = (0, _stryke_helpers_deep_clone.deepClone)(value);
2743
+ else context[key] = value;
2716
2744
  return context;
2717
2745
  }
2718
2746
  /**
@@ -1,4 +1,4 @@
1
- import { t as PowerlinesBaseContext } from "./base-context-Cmo6TTh7.mjs";
1
+ import { t as PowerlinesBaseContext } from "./base-context-DU0NRHDt.mjs";
2
2
  import { a as FileSystem } from "./fs-D1nIP45P.mjs";
3
3
  import { n as FileSystemStorageAdapter, t as VirtualStorageAdapter } from "./virtual-CYGZHTDd.mjs";
4
4
  import { i as getTsconfigFilePath } from "./tsconfig-MeFEs21S.mjs";
@@ -2007,6 +2007,19 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2007
2007
  else await this.setUserConfig(isFunction(result) ? await Promise.resolve(result(this.options)) : result);
2008
2008
  }
2009
2009
  /**
2010
+ * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.
2011
+ *
2012
+ * @remarks
2013
+ * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
2014
+ *
2015
+ * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
2016
+ * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
2017
+ * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
2018
+ */
2019
+ async resolvePackageConfigs(cwd = this.config.cwd, root = this.config.root) {
2020
+ return super.resolvePackageConfigs(cwd, root);
2021
+ }
2022
+ /**
2010
2023
  * Initialize the context with the provided configuration options
2011
2024
  */
2012
2025
  async resolveConfig() {
@@ -2036,6 +2049,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2036
2049
  mergedConfig.compatibilityDate = resolveCompatibilityDates(mergedConfig.compatibilityDate, "latest");
2037
2050
  this.resolvedConfig = mergedConfig;
2038
2051
  this.#configProxy = this.createConfigProxy();
2052
+ if (!this.packageJson) await this.resolvePackageConfigs();
2039
2053
  mergedConfig.input = getUniqueInputs(mergedConfig.input);
2040
2054
  if (mergedConfig.name?.startsWith("@") && mergedConfig.name.split("/").filter(Boolean).length > 1) mergedConfig.name = mergedConfig.name.split("/").filter(Boolean)[1];
2041
2055
  mergedConfig.title ??= titleCase(mergedConfig.name);
@@ -2487,10 +2501,10 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
2487
2501
  if (isPluginConfig(result)) return this.$$internal.addPlugin(result);
2488
2502
  resolvedPlugin = isPlugin(result) ? result : plugin;
2489
2503
  }
2490
- const pluginId = uuid();
2491
- const context = createPluginContext(pluginId, resolvedPlugin, this);
2504
+ const id = uuid();
2505
+ const context = createPluginContext(id, resolvedPlugin, this);
2492
2506
  this.plugins.push({
2493
- pluginId,
2507
+ id,
2494
2508
  plugin: resolvedPlugin,
2495
2509
  context
2496
2510
  });
@@ -2700,15 +2714,29 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
2700
2714
  */
2701
2715
  async createEnvironment(environment) {
2702
2716
  const context = await PowerlinesEnvironmentContext.createEnvironment(deepClone(this.options), deepClone(this.config), deepClone(this.overriddenConfig), deepClone(environment));
2717
+ context.$$internal = this.$$internal;
2703
2718
  context.dependencies = deepClone(this.dependencies);
2704
2719
  context.devDependencies = deepClone(this.devDependencies);
2705
2720
  context.persistedMeta = deepClone(this.persistedMeta);
2706
2721
  context.resolvePatterns = deepClone(this.resolvePatterns);
2707
2722
  context.powerlinesPath ??= this.powerlinesPath;
2708
2723
  context.resolver ??= this.resolver;
2709
- context.$$internal = this.$$internal;
2710
2724
  context.plugins = [];
2711
2725
  for (const plugin of this.plugins) await context.addPlugin(plugin);
2726
+ for (const [key, value] of Object.entries(this)) if (![
2727
+ "fs",
2728
+ "$$internal",
2729
+ "dependencies",
2730
+ "devDependencies",
2731
+ "persistedMeta",
2732
+ "packageJson",
2733
+ "projectJson",
2734
+ "tsconfig",
2735
+ "resolver",
2736
+ "plugins",
2737
+ "environments"
2738
+ ].includes(key)) if (isObject(value) || Array.isArray(value)) context[key] = deepClone(value);
2739
+ else context[key] = value;
2712
2740
  return context;
2713
2741
  }
2714
2742
  /**
@@ -2795,4 +2823,4 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
2795
2823
 
2796
2824
  //#endregion
2797
2825
  export { mergeConfigs as a, callHook as i, PowerlinesEnvironmentContext as n, PowerlinesContext as o, createPluginContext as r, writeMetaFile as s, PowerlinesExecutionContext as t };
2798
- //# sourceMappingURL=execution-context-Cp32TarF.mjs.map
2826
+ //# sourceMappingURL=execution-context-CgDuoi8o.mjs.map