@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
@@ -2203,7 +2203,7 @@ function createResolver(options) {
2203
2203
 
2204
2204
  //#endregion
2205
2205
  //#region src/context/base-context.ts
2206
- var PowerlinesBaseContext = class PowerlinesBaseContext {
2206
+ var PowerlinesBaseContext = class {
2207
2207
  #timestamp = Date.now();
2208
2208
  /**
2209
2209
  * The path to the Powerlines package
@@ -2255,19 +2255,6 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2255
2255
  });
2256
2256
  }
2257
2257
  /**
2258
- * 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.
2259
- *
2260
- * @remarks
2261
- * 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.
2262
- *
2263
- * @returns A promise that resolves to the cloned context.
2264
- */
2265
- async clone() {
2266
- const clone = new PowerlinesBaseContext(this.options, this.initialConfig);
2267
- await clone.init();
2268
- return clone;
2269
- }
2270
- /**
2271
2258
  * A logging function for fatal messages
2272
2259
  *
2273
2260
  * @param message - The message to log.
@@ -2422,13 +2409,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2422
2409
  cacheDir: this.envPaths.cache,
2423
2410
  mode: this.options.mode
2424
2411
  });
2425
- const projectJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(this.options.root, this.options.cwd), "project.json");
2426
- if ((0, node_fs.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs.readJsonFile)(projectJsonPath);
2427
- const packageJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(this.options.root, this.options.cwd), "package.json");
2428
- if ((0, node_fs.existsSync)(packageJsonPath)) {
2429
- this.packageJson = await (0, _stryke_fs.readJsonFile)(packageJsonPath);
2430
- 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);
2431
- }
2412
+ await this.resolvePackageConfigs();
2432
2413
  this.configFile = await (0, _powerlines_core_lib_config.loadUserConfigFile)(this.options, this.resolver);
2433
2414
  if (this.configFile.config) {
2434
2415
  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);
@@ -2445,6 +2426,25 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2445
2426
  }
2446
2427
  }
2447
2428
  /**
2429
+ * 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.
2430
+ *
2431
+ * @remarks
2432
+ * 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.
2433
+ *
2434
+ * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
2435
+ * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
2436
+ * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
2437
+ */
2438
+ async resolvePackageConfigs(cwd = this.options.cwd, root = this.options.root) {
2439
+ const projectJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root, cwd), "project.json");
2440
+ if ((0, node_fs.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs.readJsonFile)(projectJsonPath);
2441
+ const packageJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root, cwd), "package.json");
2442
+ if ((0, node_fs.existsSync)(packageJsonPath)) {
2443
+ this.packageJson = await (0, _stryke_fs.readJsonFile)(packageJsonPath);
2444
+ 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);
2445
+ }
2446
+ }
2447
+ /**
2448
2448
  * 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".
2449
2449
  *
2450
2450
  * @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
@@ -3196,6 +3196,19 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3196
3196
  else await this.setUserConfig((0, _stryke_type_checks_is_function.isFunction)(result) ? await Promise.resolve(result(this.options)) : result);
3197
3197
  }
3198
3198
  /**
3199
+ * 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.
3200
+ *
3201
+ * @remarks
3202
+ * 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.
3203
+ *
3204
+ * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
3205
+ * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
3206
+ * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
3207
+ */
3208
+ async resolvePackageConfigs(cwd = this.config.cwd, root = this.config.root) {
3209
+ return super.resolvePackageConfigs(cwd, root);
3210
+ }
3211
+ /**
3199
3212
  * Initialize the context with the provided configuration options
3200
3213
  */
3201
3214
  async resolveConfig() {
@@ -3225,6 +3238,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3225
3238
  mergedConfig.compatibilityDate = (0, compatx.resolveCompatibilityDates)(mergedConfig.compatibilityDate, "latest");
3226
3239
  this.resolvedConfig = mergedConfig;
3227
3240
  this.#configProxy = this.createConfigProxy();
3241
+ if (!this.packageJson) await this.resolvePackageConfigs();
3228
3242
  mergedConfig.input = (0, _powerlines_core_lib_entry.getUniqueInputs)(mergedConfig.input);
3229
3243
  if (mergedConfig.name?.startsWith("@") && mergedConfig.name.split("/").filter(Boolean).length > 1) mergedConfig.name = mergedConfig.name.split("/").filter(Boolean)[1];
3230
3244
  mergedConfig.title ??= (0, _stryke_string_format_title_case.titleCase)(mergedConfig.name);
@@ -3676,10 +3690,10 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
3676
3690
  if ((0, _powerlines_core_plugin_utils.isPluginConfig)(result)) return this.$$internal.addPlugin(result);
3677
3691
  resolvedPlugin = (0, _powerlines_core_plugin_utils.isPlugin)(result) ? result : plugin;
3678
3692
  }
3679
- const pluginId = (0, _stryke_unique_id_uuid.uuid)();
3680
- const context = createPluginContext(pluginId, resolvedPlugin, this);
3693
+ const id = (0, _stryke_unique_id_uuid.uuid)();
3694
+ const context = createPluginContext(id, resolvedPlugin, this);
3681
3695
  this.plugins.push({
3682
- pluginId,
3696
+ id,
3683
3697
  plugin: resolvedPlugin,
3684
3698
  context
3685
3699
  });
@@ -3889,15 +3903,29 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
3889
3903
  */
3890
3904
  async createEnvironment(environment) {
3891
3905
  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));
3906
+ context.$$internal = this.$$internal;
3892
3907
  context.dependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.dependencies);
3893
3908
  context.devDependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.devDependencies);
3894
3909
  context.persistedMeta = (0, _stryke_helpers_deep_clone.deepClone)(this.persistedMeta);
3895
3910
  context.resolvePatterns = (0, _stryke_helpers_deep_clone.deepClone)(this.resolvePatterns);
3896
3911
  context.powerlinesPath ??= this.powerlinesPath;
3897
3912
  context.resolver ??= this.resolver;
3898
- context.$$internal = this.$$internal;
3899
3913
  context.plugins = [];
3900
3914
  for (const plugin of this.plugins) await context.addPlugin(plugin);
3915
+ for (const [key, value] of Object.entries(this)) if (![
3916
+ "fs",
3917
+ "$$internal",
3918
+ "dependencies",
3919
+ "devDependencies",
3920
+ "persistedMeta",
3921
+ "packageJson",
3922
+ "projectJson",
3923
+ "tsconfig",
3924
+ "resolver",
3925
+ "plugins",
3926
+ "environments"
3927
+ ].includes(key)) if ((0, _stryke_type_checks_is_object.isObject)(value) || Array.isArray(value)) context[key] = (0, _stryke_helpers_deep_clone.deepClone)(value);
3928
+ else context[key] = value;
3901
3929
  return context;
3902
3930
  }
3903
3931
  /**
@@ -2170,7 +2170,7 @@ function createResolver(options) {
2170
2170
 
2171
2171
  //#endregion
2172
2172
  //#region src/context/base-context.ts
2173
- var PowerlinesBaseContext = class PowerlinesBaseContext {
2173
+ var PowerlinesBaseContext = class {
2174
2174
  #timestamp = Date.now();
2175
2175
  /**
2176
2176
  * The path to the Powerlines package
@@ -2222,19 +2222,6 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2222
2222
  });
2223
2223
  }
2224
2224
  /**
2225
- * 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.
2226
- *
2227
- * @remarks
2228
- * 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.
2229
- *
2230
- * @returns A promise that resolves to the cloned context.
2231
- */
2232
- async clone() {
2233
- const clone = new PowerlinesBaseContext(this.options, this.initialConfig);
2234
- await clone.init();
2235
- return clone;
2236
- }
2237
- /**
2238
2225
  * A logging function for fatal messages
2239
2226
  *
2240
2227
  * @param message - The message to log.
@@ -2389,13 +2376,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2389
2376
  cacheDir: this.envPaths.cache,
2390
2377
  mode: this.options.mode
2391
2378
  });
2392
- const projectJsonPath = joinPaths$2(appendPath(this.options.root, this.options.cwd), "project.json");
2393
- if (existsSync$1(projectJsonPath)) this.projectJson = await readJsonFile$1(projectJsonPath);
2394
- const packageJsonPath = joinPaths$2(appendPath(this.options.root, this.options.cwd), "package.json");
2395
- if (existsSync$1(packageJsonPath)) {
2396
- this.packageJson = await readJsonFile$1(packageJsonPath);
2397
- this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
2398
- }
2379
+ await this.resolvePackageConfigs();
2399
2380
  this.configFile = await loadUserConfigFile(this.options, this.resolver);
2400
2381
  if (this.configFile.config) {
2401
2382
  if (isSetString(this.configFile.configFile)) this.options.configFile ??= replacePath(this.configFile.configFile, this.options.cwd);
@@ -2412,6 +2393,25 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2412
2393
  }
2413
2394
  }
2414
2395
  /**
2396
+ * 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.
2397
+ *
2398
+ * @remarks
2399
+ * 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.
2400
+ *
2401
+ * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
2402
+ * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
2403
+ * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
2404
+ */
2405
+ async resolvePackageConfigs(cwd = this.options.cwd, root = this.options.root) {
2406
+ const projectJsonPath = joinPaths$2(appendPath(root, cwd), "project.json");
2407
+ if (existsSync$1(projectJsonPath)) this.projectJson = await readJsonFile$1(projectJsonPath);
2408
+ const packageJsonPath = joinPaths$2(appendPath(root, cwd), "package.json");
2409
+ if (existsSync$1(packageJsonPath)) {
2410
+ this.packageJson = await readJsonFile$1(packageJsonPath);
2411
+ this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
2412
+ }
2413
+ }
2414
+ /**
2415
2415
  * 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".
2416
2416
  *
2417
2417
  * @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
@@ -3163,6 +3163,19 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3163
3163
  else await this.setUserConfig(isFunction(result) ? await Promise.resolve(result(this.options)) : result);
3164
3164
  }
3165
3165
  /**
3166
+ * 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.
3167
+ *
3168
+ * @remarks
3169
+ * 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.
3170
+ *
3171
+ * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
3172
+ * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
3173
+ * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
3174
+ */
3175
+ async resolvePackageConfigs(cwd = this.config.cwd, root = this.config.root) {
3176
+ return super.resolvePackageConfigs(cwd, root);
3177
+ }
3178
+ /**
3166
3179
  * Initialize the context with the provided configuration options
3167
3180
  */
3168
3181
  async resolveConfig() {
@@ -3192,6 +3205,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3192
3205
  mergedConfig.compatibilityDate = resolveCompatibilityDates(mergedConfig.compatibilityDate, "latest");
3193
3206
  this.resolvedConfig = mergedConfig;
3194
3207
  this.#configProxy = this.createConfigProxy();
3208
+ if (!this.packageJson) await this.resolvePackageConfigs();
3195
3209
  mergedConfig.input = getUniqueInputs(mergedConfig.input);
3196
3210
  if (mergedConfig.name?.startsWith("@") && mergedConfig.name.split("/").filter(Boolean).length > 1) mergedConfig.name = mergedConfig.name.split("/").filter(Boolean)[1];
3197
3211
  mergedConfig.title ??= titleCase(mergedConfig.name);
@@ -3643,10 +3657,10 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
3643
3657
  if (isPluginConfig(result)) return this.$$internal.addPlugin(result);
3644
3658
  resolvedPlugin = isPlugin(result) ? result : plugin;
3645
3659
  }
3646
- const pluginId = uuid();
3647
- const context = createPluginContext(pluginId, resolvedPlugin, this);
3660
+ const id = uuid();
3661
+ const context = createPluginContext(id, resolvedPlugin, this);
3648
3662
  this.plugins.push({
3649
- pluginId,
3663
+ id,
3650
3664
  plugin: resolvedPlugin,
3651
3665
  context
3652
3666
  });
@@ -3856,15 +3870,29 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
3856
3870
  */
3857
3871
  async createEnvironment(environment) {
3858
3872
  const context = await PowerlinesEnvironmentContext.createEnvironment(deepClone(this.options), deepClone(this.config), deepClone(this.overriddenConfig), deepClone(environment));
3873
+ context.$$internal = this.$$internal;
3859
3874
  context.dependencies = deepClone(this.dependencies);
3860
3875
  context.devDependencies = deepClone(this.devDependencies);
3861
3876
  context.persistedMeta = deepClone(this.persistedMeta);
3862
3877
  context.resolvePatterns = deepClone(this.resolvePatterns);
3863
3878
  context.powerlinesPath ??= this.powerlinesPath;
3864
3879
  context.resolver ??= this.resolver;
3865
- context.$$internal = this.$$internal;
3866
3880
  context.plugins = [];
3867
3881
  for (const plugin of this.plugins) await context.addPlugin(plugin);
3882
+ for (const [key, value] of Object.entries(this)) if (![
3883
+ "fs",
3884
+ "$$internal",
3885
+ "dependencies",
3886
+ "devDependencies",
3887
+ "persistedMeta",
3888
+ "packageJson",
3889
+ "projectJson",
3890
+ "tsconfig",
3891
+ "resolver",
3892
+ "plugins",
3893
+ "environments"
3894
+ ].includes(key)) if (isObject(value) || Array.isArray(value)) context[key] = deepClone(value);
3895
+ else context[key] = value;
3868
3896
  return context;
3869
3897
  }
3870
3898
  /**