@powerlines/engine 0.44.12 → 0.45.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 (40) hide show
  1. package/dist/_internal/worker.cjs +143 -106
  2. package/dist/_internal/worker.d.cts +16 -8
  3. package/dist/_internal/worker.d.cts.map +1 -1
  4. package/dist/_internal/worker.d.mts +16 -8
  5. package/dist/_internal/worker.d.mts.map +1 -1
  6. package/dist/_internal/worker.mjs +144 -107
  7. package/dist/_internal/worker.mjs.map +1 -1
  8. package/dist/api.cjs +60 -46
  9. package/dist/api.d.cts +18 -13
  10. package/dist/api.d.cts.map +1 -1
  11. package/dist/api.d.mts +18 -13
  12. package/dist/api.d.mts.map +1 -1
  13. package/dist/api.mjs +60 -46
  14. package/dist/api.mjs.map +1 -1
  15. package/dist/{base-context-C6yzgs6K.mjs → base-context-BSAC5sO9.mjs} +21 -15
  16. package/dist/base-context-BSAC5sO9.mjs.map +1 -0
  17. package/dist/{base-context-trNQZNsX.cjs → base-context-Byizvf4F.cjs} +20 -14
  18. package/dist/context/index.cjs +3 -3
  19. package/dist/context/index.d.cts +13 -8
  20. package/dist/context/index.d.cts.map +1 -1
  21. package/dist/context/index.d.mts +13 -8
  22. package/dist/context/index.d.mts.map +1 -1
  23. package/dist/context/index.mjs +3 -3
  24. package/dist/{engine-context-D1_U6xVC.cjs → engine-context-CI_0NWIk.cjs} +5 -3
  25. package/dist/{engine-context-C-11i43N.mjs → engine-context-_RMFwG4J.mjs} +6 -4
  26. package/dist/engine-context-_RMFwG4J.mjs.map +1 -0
  27. package/dist/{execution-context-D9Enw3J5.mjs → execution-context-O6eXdsCn.mjs} +65 -50
  28. package/dist/execution-context-O6eXdsCn.mjs.map +1 -0
  29. package/dist/{execution-context-C-M-Mxse.cjs → execution-context-SXtPe9Ae.cjs} +63 -48
  30. package/dist/index.cjs +30 -20
  31. package/dist/index.d.cts +9 -8
  32. package/dist/index.d.cts.map +1 -1
  33. package/dist/index.d.mts +9 -8
  34. package/dist/index.d.mts.map +1 -1
  35. package/dist/index.mjs +30 -20
  36. package/dist/index.mjs.map +1 -1
  37. package/package.json +3 -3
  38. package/dist/base-context-C6yzgs6K.mjs.map +0 -1
  39. package/dist/engine-context-C-11i43N.mjs.map +0 -1
  40. package/dist/execution-context-D9Enw3J5.mjs.map +0 -1
@@ -30,7 +30,7 @@ import { isSetObject } from "@stryke/type-checks/is-set-object";
30
30
  import { isSetString } from "@stryke/type-checks/is-set-string";
31
31
  import { isString } from "@stryke/type-checks/is-string";
32
32
  import chalk from "chalk";
33
- import defu, { createDefu, defu as defu$1 } from "defu";
33
+ import defu, { defu as defu$1 } from "defu";
34
34
  import Handlebars from "handlebars";
35
35
  import { CACHE_HASH_LENGTH, DEFAULT_DEVELOPMENT_LOG_LEVEL, DEFAULT_ENVIRONMENT, DEFAULT_PRODUCTION_LOG_LEVEL, DEFAULT_TEST_LOG_LEVEL, GLOBAL_ENVIRONMENT, PLUGIN_NON_HOOK_FIELDS, ROOT_HASH_LENGTH } from "@powerlines/core/constants";
36
36
  import { readJsonFile, readJsonFileSync } from "@stryke/fs/json";
@@ -2173,7 +2173,11 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2173
2173
  /**
2174
2174
  * 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
2175
2175
  */
2176
- inputOptions = {};
2176
+ initialOptions = {};
2177
+ /**
2178
+ * 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.
2179
+ */
2180
+ initialConfig = {};
2177
2181
  /**
2178
2182
  * The parsed configuration file for the project
2179
2183
  */
@@ -2213,7 +2217,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2213
2217
  */
2214
2218
  async clone() {
2215
2219
  const clone = new PowerlinesBaseContext();
2216
- await clone.init(this.options);
2220
+ await clone.init(this.options, this.initialConfig);
2217
2221
  return clone;
2218
2222
  }
2219
2223
  /**
@@ -2317,9 +2321,9 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2317
2321
  * @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.
2318
2322
  */
2319
2323
  async getWorkspaceConfig() {
2320
- return tryGetWorkspaceConfig(false, this.options || this.inputOptions ? {
2321
- cwd: this.options?.root || this.inputOptions?.root ? appendPath(this.options?.root || this.inputOptions?.root || ".", this.options?.cwd || this.inputOptions?.cwd) : void 0,
2322
- workspaceRoot: this.options?.cwd || this.inputOptions?.cwd
2324
+ return tryGetWorkspaceConfig(false, this.options || this.initialOptions ? {
2325
+ cwd: this.options?.root || this.initialOptions?.root ? appendPath(this.options?.root || this.initialOptions?.root || ".", this.options?.cwd || this.initialOptions?.cwd) : void 0,
2326
+ workspaceRoot: this.options?.cwd || this.initialOptions?.cwd
2323
2327
  } : void 0);
2324
2328
  }
2325
2329
  /**
@@ -2338,7 +2342,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2338
2342
  */
2339
2343
  async getDefaultLogLevel() {
2340
2344
  const workspaceConfig = await this.getWorkspaceConfig();
2341
- return resolveLogLevel(workspaceConfig?.logLevel ? workspaceConfig.logLevel === "success" || workspaceConfig.logLevel === "performance" ? "info" : workspaceConfig.logLevel === "all" ? "debug" : workspaceConfig.logLevel === "fatal" ? "error" : workspaceConfig.logLevel : void 0, this.options?.mode || this.inputOptions?.mode || workspaceConfig?.mode || await this.getDefaultMode());
2345
+ return resolveLogLevel(workspaceConfig?.logLevel ? workspaceConfig.logLevel === "success" || workspaceConfig.logLevel === "performance" ? "info" : workspaceConfig.logLevel === "all" ? "debug" : workspaceConfig.logLevel === "fatal" ? "error" : workspaceConfig.logLevel : void 0, this.options?.mode || this.initialOptions?.mode || workspaceConfig?.mode || await this.getDefaultMode());
2342
2346
  }
2343
2347
  /**
2344
2348
  * Initialize the context with the provided configuration options
@@ -2347,9 +2351,11 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2347
2351
  * 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.
2348
2352
  *
2349
2353
  * @param options - The configuration options to initialize the context with
2354
+ * @param initialConfig - The initial configuration to initialize the context with
2350
2355
  */
2351
- async init(options) {
2352
- this.inputOptions = { ...options };
2356
+ async init(options, initialConfig) {
2357
+ this.initialOptions = { ...options };
2358
+ this.initialConfig = { ...initialConfig };
2353
2359
  if (!this.powerlinesPath) {
2354
2360
  const powerlinesPath = await resolvePackage("powerlines");
2355
2361
  if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
@@ -2358,14 +2364,14 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2358
2364
  const cwd = options.cwd || this.options?.cwd || process.cwd();
2359
2365
  const root = replacePath((options.root || this.options?.root) && (options.root || this.options.root).replace(/^\.\/?/, "") && !isEqual(options.root || this.options.root, cwd) ? options.root || this.options.root : ".", cwd);
2360
2366
  this.options = defu({
2361
- name: options.name,
2367
+ name: options.name || this.initialConfig.name,
2362
2368
  root,
2363
2369
  cwd,
2364
- mode: options.mode,
2365
- logLevel: options.logLevel,
2366
- framework: options.framework,
2367
- organization: options.organization,
2368
- configFile: options.configFile
2370
+ mode: options.mode || this.initialConfig.mode,
2371
+ logLevel: options.logLevel || this.initialConfig.logLevel,
2372
+ framework: options.framework || this.initialConfig.framework,
2373
+ organization: options.organization || this.initialConfig.organization,
2374
+ configFile: options.configFile || this.initialConfig.configFile
2369
2375
  }, this.options ?? {}, {
2370
2376
  mode: await this.getDefaultMode(),
2371
2377
  logLevel: await this.getDefaultLogLevel()
@@ -2448,9 +2454,9 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2448
2454
  * @param options - The options for resolving the context.
2449
2455
  * @returns A promise that resolves to the new context.
2450
2456
  */
2451
- static async fromOptions(options) {
2457
+ static async init(options, initialConfig) {
2452
2458
  const context = new PowerlinesContext(options);
2453
- await context.init(options);
2459
+ await context.init(options, initialConfig);
2454
2460
  const powerlinesPath = await resolvePackage("powerlines");
2455
2461
  if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
2456
2462
  context.powerlinesPath = powerlinesPath;
@@ -2753,7 +2759,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2753
2759
  * @returns A promise that resolves to the cloned context.
2754
2760
  */
2755
2761
  async clone() {
2756
- const clone = await PowerlinesContext.fromOptions(this.options);
2762
+ const clone = await PowerlinesContext.init(this.options, this.initialConfig);
2757
2763
  return this.copyTo(clone);
2758
2764
  }
2759
2765
  /**
@@ -3107,8 +3113,9 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3107
3113
  cwd: this.options.cwd,
3108
3114
  inlineConfig: this.config.inlineConfig ?? {},
3109
3115
  userConfig: this.config.userConfig ?? {},
3116
+ initialConfig: this.config.initialConfig ?? {},
3110
3117
  pluginConfig: this.config.pluginConfig ?? {}
3111
- }, getConfigProps(this.config.inlineConfig), getConfigProps(this.config.userConfig), getConfigProps(this.config.pluginConfig), this.options, {
3118
+ }, getConfigProps(this.config.inlineConfig), getConfigProps(this.config.userConfig), getConfigProps(this.config.initialConfig), getConfigProps(this.config.pluginConfig), this.options, {
3112
3119
  name: this.projectJson?.name || this.packageJson?.name,
3113
3120
  version: this.packageJson?.version,
3114
3121
  description: this.packageJson?.description
@@ -3133,7 +3140,8 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3133
3140
  copyTo(context) {
3134
3141
  for (const [key, value] of Object.entries(this)) if (!SKIP_CLONING_PROPS.includes(key)) if (isObject(value) || Array.isArray(value)) context[key] = deepClone(value);
3135
3142
  else context[key] = value;
3136
- context.inputOptions = deepClone(this.inputOptions);
3143
+ context.initialConfig = deepClone(this.initialConfig);
3144
+ context.initialOptions = deepClone(this.initialOptions);
3137
3145
  context.options = deepClone(this.options);
3138
3146
  context.dependencies = deepClone(this.dependencies);
3139
3147
  context.devDependencies = deepClone(this.devDependencies);
@@ -3154,8 +3162,8 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3154
3162
  *
3155
3163
  * @param options - The configuration options to initialize the context with
3156
3164
  */
3157
- async init(options) {
3158
- await super.init(options);
3165
+ async init(options, initialConfig) {
3166
+ await super.init(options, initialConfig ?? {});
3159
3167
  this.options.executionId = options.executionId ?? this.options.executionId;
3160
3168
  this.options.executionIndex = options.executionIndex ?? this.options.executionIndex ?? 0;
3161
3169
  const projectJsonPath = joinPaths$1(this.options.cwd, this.options.root, "project.json");
@@ -3168,8 +3176,14 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3168
3176
  this.#checksum = await this.generateChecksum(joinPaths$1(this.options.cwd, this.options.root));
3169
3177
  const userConfig = this.configFile.config ? Array.isArray(this.configFile.config) && this.configFile.config.length > this.options.executionIndex ? this.configFile.config[this.options.executionIndex] : this.configFile.config : {};
3170
3178
  this.resolvedConfig = {
3171
- ...this.options,
3179
+ cwd: this.options.cwd,
3180
+ root: this.options.root,
3181
+ ...this.initialOptions,
3182
+ ...initialConfig,
3172
3183
  ...userConfig,
3184
+ inlineConfig: {},
3185
+ pluginConfig: {},
3186
+ initialConfig,
3173
3187
  userConfig
3174
3188
  };
3175
3189
  }
@@ -3192,28 +3206,33 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3192
3206
  ] },
3193
3207
  dts: true
3194
3208
  });
3195
- logger.trace(`Pre-setup Powerlines configuration object: \n${JSON.stringify({
3196
- ...omit(this.config, ["plugins"]),
3197
- userConfig: this.config.userConfig ? omit(this.config.userConfig, ["plugins"]) : {},
3198
- inlineConfig: this.config.inlineConfig ? omit(this.config.inlineConfig, ["plugins"]) : {},
3199
- pluginConfig: this.config.pluginConfig ? omit(this.config.pluginConfig, ["plugins"]) : {}
3200
- }, null, 2)}`);
3201
- if (!this.inputOptions.mode && !this.config.userConfig?.mode && !this.config.inlineConfig?.mode && !this.config.pluginConfig?.mode) {
3209
+ logger.trace(`Pre-setup Powerlines configuration object: \n${formatLogMessage({
3210
+ ...omit(this.config, [
3211
+ "inlineConfig",
3212
+ "userConfig",
3213
+ "initialConfig",
3214
+ "pluginConfig",
3215
+ "plugins"
3216
+ ]),
3217
+ inlineConfig: isSetObject(this.config.inlineConfig) ? omit(this.config.inlineConfig, ["plugins"]) : void 0,
3218
+ userConfig: isSetObject(this.config.userConfig) ? omit(this.config.userConfig, ["plugins"]) : void 0,
3219
+ initialConfig: isSetObject(this.config.initialConfig) ? omit(this.config.initialConfig, ["plugins"]) : void 0,
3220
+ pluginConfig: isSetObject(this.config.pluginConfig) ? omit(this.config.pluginConfig, ["plugins"]) : void 0
3221
+ })}`);
3222
+ if (!this.initialOptions.mode && !this.config.userConfig?.mode && !this.config.inlineConfig?.mode && !this.config.initialConfig?.mode && !this.config.pluginConfig?.mode) {
3202
3223
  this.options.mode = "production";
3203
3224
  this.config.mode = "production";
3204
3225
  }
3205
- if (!this.inputOptions.framework && !this.config.userConfig?.framework && !this.config.inlineConfig?.framework && !this.config.pluginConfig?.framework) {
3226
+ if (!this.initialOptions.framework && !this.config.userConfig?.framework && !this.config.inlineConfig?.framework && !this.config.initialConfig?.framework && !this.config.pluginConfig?.framework) {
3206
3227
  this.options.framework = "powerlines";
3207
3228
  this.config.framework = "powerlines";
3208
3229
  }
3209
- if (!this.config.userConfig?.projectType && !this.config.inlineConfig?.projectType && !this.config.pluginConfig?.projectType) this.config.projectType = "application";
3210
- if (!this.config.userConfig?.platform && !this.config.inlineConfig?.platform && !this.config.pluginConfig?.platform) this.config.platform = "neutral";
3211
- this.resolvedConfig.compatibilityDate = resolveCompatibilityDates(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
3230
+ if (!this.config.userConfig?.projectType && !this.config.inlineConfig?.projectType && !this.config.initialConfig?.projectType && !this.config.pluginConfig?.projectType) this.config.projectType = "application";
3231
+ if (!this.config.userConfig?.platform && !this.config.inlineConfig?.platform && !this.config.initialConfig?.platform && !this.config.pluginConfig?.platform) this.config.platform = "neutral";
3232
+ this.config.compatibilityDate = resolveCompatibilityDates(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.initialConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
3212
3233
  this.config.input = getUniqueInputs(this.config.input);
3213
3234
  if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
3214
3235
  this.config.title ??= titleCase(this.config.name);
3215
- if (this.config.userConfig.resolve?.external) this.config.userConfig.resolve.external = getUnique(this.config.userConfig.resolve.external);
3216
- if (this.config.userConfig.resolve?.noExternal) this.config.userConfig.resolve.noExternal = getUnique(this.config.userConfig.resolve.noExternal);
3217
3236
  if (this.config.resolve.external) this.config.resolve.external = getUnique(this.config.resolve.external);
3218
3237
  if (this.config.resolve.noExternal) this.config.resolve.noExternal = getUnique(this.config.resolve.noExternal);
3219
3238
  this.config.plugins = (this.config.plugins ?? []).flatMap((plugin) => toArray(plugin)).filter(Boolean).reduce((ret, plugin) => {
@@ -3221,10 +3240,10 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3221
3240
  ret.push(plugin);
3222
3241
  return ret;
3223
3242
  }, []);
3224
- if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;
3243
+ if (!this.config.userConfig?.logLevel && !this.config.initialConfig?.logLevel && !this.config.pluginConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;
3225
3244
  else if (this.config.mode === "test") this.config.logLevel = DEFAULT_TEST_LOG_LEVEL;
3226
3245
  else this.config.logLevel = DEFAULT_PRODUCTION_LOG_LEVEL;
3227
- if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = getTsconfigFilePath(this.config.cwd, this.config.root);
3246
+ if (!this.config.userConfig?.tsconfig && !this.config.initialConfig?.tsconfig && !this.config.pluginConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = getTsconfigFilePath(this.config.cwd, this.config.root);
3228
3247
  else if (this.config.tsconfig) this.config.tsconfig = replacePath(replacePathTokens(this, this.config.tsconfig), this.config.cwd);
3229
3248
  this.config.output.format = getUnique(toArray(this.config.output?.format ?? (this.config.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
3230
3249
  if (this.config.output.path) this.config.output.path = appendPath(replacePathTokens(this, this.config.output.path), this.config.cwd);
@@ -3234,7 +3253,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3234
3253
  if (!this.config.root.replace(/^\.\/?/, "")) this.config.output.copy.path = this.config.output.copy.path ? appendPath(replacePathTokens(this, this.config.output.copy.path), this.config.cwd) : this.config.output.path;
3235
3254
  else this.config.output.copy.path = appendPath(replacePathTokens(this, this.config.output.copy.path || joinPaths$1("dist", this.config.root)), this.config.cwd);
3236
3255
  }
3237
- if (this.config.output.types !== false) this.config.output.types = appendPath(replacePathTokens(this, this.config.userConfig?.output?.types || this.config.inlineConfig?.output?.types || this.config.pluginConfig?.output?.types || joinPaths$1(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`)), this.config.cwd);
3256
+ if (this.config.output.types !== false) this.config.output.types = appendPath(replacePathTokens(this, this.config.userConfig?.output?.types || this.config.inlineConfig?.output?.types || this.config.initialConfig?.output?.types || this.config.pluginConfig?.output?.types || joinPaths$1(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`)), this.config.cwd);
3238
3257
  if (this.config.output.copy && this.config.output.copy.path && this.config.output.copy.assets && Array.isArray(this.config.output.copy.assets)) this.config.output.copy.assets = getUniqueBy(this.config.output.copy.assets.map((asset) => {
3239
3258
  return {
3240
3259
  glob: isSetObject(asset) ? asset.glob : asset,
@@ -3243,11 +3262,11 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3243
3262
  ignore: isSetObject(asset) && asset.ignore ? toArray(asset.ignore) : void 0
3244
3263
  };
3245
3264
  }), (a) => `${a.input}-${a.glob}-${a.output}`);
3246
- if (!this.config.userConfig?.output?.sourceMap && !this.config.inlineConfig?.output?.sourceMap) if (this.config.mode === "development") this.config.output.sourceMap = true;
3265
+ if (!this.config.userConfig?.output?.sourceMap && !this.config.initialConfig?.output?.sourceMap && !this.config.inlineConfig?.output?.sourceMap && !this.config.pluginConfig?.output?.sourceMap) if (this.config.mode === "development") this.config.output.sourceMap = true;
3247
3266
  else this.config.output.sourceMap = false;
3248
- if (!this.config.userConfig?.output?.minify && !this.config.inlineConfig?.output?.minify) if (this.config.mode === "production") this.config.output.minify = true;
3267
+ if (!this.config.userConfig?.output?.minify && !this.config.initialConfig?.output?.minify && !this.config.inlineConfig?.output?.minify && !this.config.pluginConfig?.output?.minify) if (this.config.mode === "production") this.config.output.minify = true;
3249
3268
  else this.config.output.minify = false;
3250
- if (!this.config.userConfig?.output?.artifactsPath && !this.config.inlineConfig?.output?.artifactsPath && !this.config.pluginConfig?.output?.artifactsPath) this.config.output.artifactsPath = `.${this.config.framework || "powerlines"}`;
3269
+ if (!this.config.userConfig?.output?.artifactsPath && !this.config.initialConfig?.output?.artifactsPath && !this.config.inlineConfig?.output?.artifactsPath && !this.config.pluginConfig?.output?.artifactsPath) this.config.output.artifactsPath = `.${this.config.framework || "powerlines"}`;
3251
3270
  if (this.config.output.copy && this.config.output.copy.assets) this.config.output.copy.assets = this.config.output.copy.assets.map((asset) => ({
3252
3271
  ...asset,
3253
3272
  glob: replacePathTokens(this, asset.glob),
@@ -3257,24 +3276,24 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3257
3276
  }));
3258
3277
  if (isSetString(this.config.output?.storage) && this.config.output.storage === "virtual" || isSetObject(this.config.output?.storage) && Object.values(this.config.output.storage).every((adapter) => adapter.preset === "virtual")) this.config.output.overwrite = true;
3259
3278
  this.#fs ??= await VirtualFileSystem.create(this);
3260
- if (isSetObject(this.config.userConfig) && isSetObject(this.config.inlineConfig) && isSetObject(this.config.pluginConfig)) logger.debug(`Resolved Powerlines configuration object: \n${JSON.stringify({
3261
- ...omit(this.config, ["plugins"]),
3262
- userConfig: this.config.userConfig ? omit(this.config.userConfig, ["plugins"]) : {},
3263
- inlineConfig: this.config.inlineConfig ? omit(this.config.inlineConfig, ["plugins"]) : {},
3264
- pluginConfig: this.config.pluginConfig ? omit(this.config.pluginConfig, ["plugins"]) : {}
3265
- }, null, 2)}`);
3279
+ if (isSetObject(this.config.inlineConfig) && isSetObject(this.config.userConfig) && isSetObject(this.config.initialConfig) && isSetObject(this.config.pluginConfig)) logger.debug(`Resolved Powerlines configuration object: \n${formatLogMessage({
3280
+ ...omit(this.config, [
3281
+ "inlineConfig",
3282
+ "userConfig",
3283
+ "initialConfig",
3284
+ "pluginConfig",
3285
+ "plugins"
3286
+ ]),
3287
+ inlineConfig: isSetObject(this.config.inlineConfig) ? omit(this.config.inlineConfig, ["plugins"]) : void 0,
3288
+ userConfig: isSetObject(this.config.userConfig) ? omit(this.config.userConfig, ["plugins"]) : void 0,
3289
+ initialConfig: isSetObject(this.config.initialConfig) ? omit(this.config.initialConfig, ["plugins"]) : void 0,
3290
+ pluginConfig: isSetObject(this.config.pluginConfig) ? omit(this.config.pluginConfig, ["plugins"]) : void 0
3291
+ })}`);
3266
3292
  }
3267
3293
  };
3268
3294
 
3269
3295
  //#endregion
3270
3296
  //#region src/_internal/helpers/hooks.ts
3271
- const mergeResultObjects = createDefu((obj, key, value) => {
3272
- if (isString(obj[key]) && isString(value)) {
3273
- obj[key] = `${obj[key] || ""}\n${value || ""}`.trim();
3274
- return true;
3275
- }
3276
- return false;
3277
- });
3278
3297
  /**
3279
3298
  * Merges the current hook result with the previous results based on their types.
3280
3299
  *
@@ -3285,7 +3304,7 @@ const mergeResultObjects = createDefu((obj, key, value) => {
3285
3304
  function mergeResults(currentResult, previousResults) {
3286
3305
  if (!previousResults || previousResults.length === 0) return [currentResult];
3287
3306
  if (isSetString(currentResult)) previousResults = [`${isSetString(previousResults[0]) ? previousResults[0] || "" : ""}\n${isSetString(previousResults[0]) ? currentResult.replace(previousResults[0], "") : currentResult}`.trim()];
3288
- else if (isObject(currentResult)) previousResults = [mergeResultObjects(currentResult, previousResults[0] ?? {})];
3307
+ else if (isObject(currentResult)) previousResults = previousResults.length > 0 ? [defu$1(currentResult, previousResults[0])] : [currentResult];
3289
3308
  return previousResults;
3290
3309
  }
3291
3310
  /**
@@ -3663,9 +3682,9 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
3663
3682
  * @param options - The options for resolving the context.
3664
3683
  * @returns A promise that resolves to the new context.
3665
3684
  */
3666
- static async fromOptions(options) {
3685
+ static async init(options, initialConfig) {
3667
3686
  const context = new PowerlinesExecutionContext(options);
3668
- await context.init(options);
3687
+ await context.init(options, initialConfig);
3669
3688
  const powerlinesPath = await resolvePackage("powerlines");
3670
3689
  if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
3671
3690
  context.powerlinesPath = powerlinesPath;
@@ -3677,10 +3696,10 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
3677
3696
  * @param options - The options for resolving the context.
3678
3697
  * @returns A promise that resolves to the new context.
3679
3698
  */
3680
- static async fromConfig(options, config) {
3699
+ static async inline(options, initialConfig, inlineConfig) {
3681
3700
  const context = new PowerlinesExecutionContext(options);
3682
- await context.init(options);
3683
- context.config.inlineConfig = config;
3701
+ await context.init(options, initialConfig);
3702
+ context.config.inlineConfig = inlineConfig;
3684
3703
  if (context.config.inlineConfig.command === "new") {
3685
3704
  const workspacePackageJsonPath = joinPaths$1(context.config.cwd, "package.json");
3686
3705
  if (!existsSync(workspacePackageJsonPath)) throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
@@ -3774,8 +3793,9 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
3774
3793
  * @returns A promise that resolves to the cloned context.
3775
3794
  */
3776
3795
  async clone() {
3777
- const clone = await PowerlinesExecutionContext.fromOptions(this.options);
3796
+ const clone = await PowerlinesExecutionContext.init(this.options, this.initialConfig);
3778
3797
  clone.config.userConfig = deepClone(this.config.userConfig);
3798
+ clone.config.initialConfig = deepClone(this.config.initialConfig);
3779
3799
  clone.config.inlineConfig = deepClone(this.config.inlineConfig);
3780
3800
  clone.config.pluginConfig = deepClone(this.config.pluginConfig);
3781
3801
  await clone.setup();
@@ -4607,47 +4627,53 @@ ${formatTypes(code)}
4607
4627
  `);
4608
4628
  }
4609
4629
  /**
4630
+ * Initialize a Powerlines API instance
4631
+ *
4632
+ * @param options - The options to initialize the API with
4633
+ * @returns A new instance of the Powerlines API
4634
+ */
4635
+ static async init(options, initialConfig) {
4636
+ const api = new PowerlinesExecution(await PowerlinesExecutionContext.init(options, initialConfig ?? {}));
4637
+ api.#context.config.initialConfig = initialConfig ?? {};
4638
+ await api.setup();
4639
+ return api;
4640
+ }
4641
+ /**
4610
4642
  * The Powerlines context
4611
4643
  */
4612
4644
  get context() {
4613
4645
  return this.#context;
4614
4646
  }
4615
4647
  /**
4616
- * Initialize a Powerlines API instance
4617
- *
4618
- * @param options - The options to initialize the API with
4619
- * @returns A new instance of the Powerlines API
4648
+ * Initialize the execution API with the provided configuration options
4620
4649
  */
4621
- static async fromConfig(options, config) {
4622
- const api = new PowerlinesExecution(await PowerlinesExecutionContext.fromOptions(options));
4623
- api.#context.config.inlineConfig = config;
4624
- await api.#context.setup();
4625
- api.#context.$$internal = {
4626
- api,
4627
- addPlugin: api.addPlugin.bind(api)
4650
+ async setup() {
4651
+ await this.#context.setup();
4652
+ this.#context.$$internal = {
4653
+ api: this,
4654
+ addPlugin: this.addPlugin.bind(this)
4628
4655
  };
4629
- const timer = api.context.timer("Initialization");
4630
- for (const plugin of api.context.config.plugins.flatMap((p) => toArray(p)) ?? []) await api.addPlugin(plugin);
4631
- if (api.context.plugins.length === 0) api.context.warn({
4656
+ const timer = this.#context.timer("Initialization");
4657
+ for (const plugin of this.#context.config.plugins.flatMap((p) => toArray(p)) ?? []) await this.addPlugin(plugin);
4658
+ if (this.#context.plugins.length === 0) this.#context.warn({
4632
4659
  meta: { category: "plugins" },
4633
4660
  message: "No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended."
4634
4661
  });
4635
- else api.context.info({
4662
+ else this.#context.info({
4636
4663
  meta: { category: "plugins" },
4637
- message: `Loaded ${api.context.plugins.length} ${titleCase(api.context.config.framework)} plugin${api.context.plugins.length > 1 ? "s" : ""}: \n${api.context.plugins.map((plugin, index) => ` ${index + 1}. ${colorText(plugin.name)}`).join("\n")}`
4664
+ message: `Loaded ${this.#context.plugins.length} ${titleCase(this.#context.config.framework)} plugin${this.#context.plugins.length > 1 ? "s" : ""}: \n${this.#context.plugins.map((plugin, index) => ` ${index + 1}. ${colorText(plugin.name)}`).join("\n")}`
4638
4665
  });
4639
- const pluginConfig = await api.callHook("config", {
4640
- environment: await api.context.getEnvironment(),
4666
+ const pluginConfig = await this.callHook("config", {
4667
+ environment: await this.#context.getEnvironment(),
4641
4668
  sequential: true,
4642
4669
  result: "merge",
4643
4670
  merge: mergeConfigs
4644
4671
  });
4645
4672
  if (pluginConfig) {
4646
- api.#context.config.pluginConfig = pluginConfig;
4647
- await api.#context.setup();
4673
+ this.#context.config.pluginConfig = pluginConfig;
4674
+ await this.#context.setup();
4648
4675
  }
4649
4676
  timer();
4650
- return api;
4651
4677
  }
4652
4678
  /**
4653
4679
  * Generate the Powerlines typescript declaration file
@@ -4661,7 +4687,7 @@ ${formatTypes(code)}
4661
4687
  this.context.debug(" Aggregating configuration options for the Powerlines project");
4662
4688
  inlineConfig.command ??= "types";
4663
4689
  this.context.config.inlineConfig = inlineConfig;
4664
- await this.context.setup();
4690
+ await this.setup();
4665
4691
  await this.#executeEnvironments(async (context) => {
4666
4692
  context.debug(`Initializing the processing options for the Powerlines project.`);
4667
4693
  await this.callHook("configResolved", {
@@ -4712,7 +4738,7 @@ ${formatTypes(code)}
4712
4738
  async prepare(inlineConfig = { command: "prepare" }) {
4713
4739
  inlineConfig.command ??= "prepare";
4714
4740
  this.context.config.inlineConfig = inlineConfig;
4715
- await this.context.setup();
4741
+ await this.setup();
4716
4742
  await this.#executeEnvironments(async (context) => {
4717
4743
  context.debug(`Initializing the processing options for the Powerlines project.`);
4718
4744
  await this.callHook("configResolved", {
@@ -4732,12 +4758,23 @@ ${formatTypes(code)}
4732
4758
  environment: context,
4733
4759
  order: "post"
4734
4760
  });
4735
- context.trace(`Powerlines configuration has been resolved: \n\n${formatLogMessage({
4736
- ...context.config,
4737
- userConfig: isSetObject(context.config.userConfig) ? omit(context.config.userConfig, ["plugins"]) : void 0,
4738
- inlineConfig: isSetObject(context.config.inlineConfig) ? omit(context.config.inlineConfig, ["plugins"]) : void 0,
4739
- plugins: context.plugins.map((plugin) => plugin.plugin.name)
4740
- })}`);
4761
+ context.trace({
4762
+ meta: { category: "config" },
4763
+ message: `Powerlines configuration after configResolved hook: \n${formatLogMessage({
4764
+ ...omit(context.config, [
4765
+ "inlineConfig",
4766
+ "userConfig",
4767
+ "initialConfig",
4768
+ "pluginConfig",
4769
+ "plugins"
4770
+ ]),
4771
+ plugins: context.plugins.map((plugin) => plugin.plugin.name),
4772
+ inlineConfig: isSetObject(context.config.inlineConfig) ? omit(context.config.inlineConfig, ["plugins"]) : void 0,
4773
+ userConfig: isSetObject(context.config.userConfig) ? omit(context.config.userConfig, ["plugins"]) : void 0,
4774
+ initialConfig: isSetObject(context.config.initialConfig) ? omit(context.config.initialConfig, ["plugins"]) : void 0,
4775
+ pluginConfig: isSetObject(context.config.pluginConfig) ? omit(context.config.pluginConfig, ["plugins"]) : void 0
4776
+ })}`
4777
+ });
4741
4778
  if (!context.fs.existsSync(context.cachePath)) await createDirectory(context.cachePath);
4742
4779
  if (!context.fs.existsSync(context.dataPath)) await createDirectory(context.dataPath);
4743
4780
  await this.callHook("prepare", {
@@ -4977,29 +5014,29 @@ ${formatTypes(code)}
4977
5014
 
4978
5015
  //#endregion
4979
5016
  //#region src/_internal/worker.ts
4980
- async function clean({ options, config }) {
4981
- await (await PowerlinesExecution.fromConfig(options, config)).clean(config);
5017
+ async function clean({ options, initialConfig, inlineConfig }) {
5018
+ await (await PowerlinesExecution.init(options, initialConfig)).clean(inlineConfig);
4982
5019
  }
4983
- async function prepare({ options, config }) {
4984
- await (await PowerlinesExecution.fromConfig(options, config)).prepare(config);
5020
+ async function prepare({ options, initialConfig, inlineConfig }) {
5021
+ await (await PowerlinesExecution.init(options, initialConfig)).prepare(inlineConfig);
4985
5022
  }
4986
- async function types({ options, config }) {
4987
- await (await PowerlinesExecution.fromConfig(options, config)).types(config);
5023
+ async function types({ options, initialConfig, inlineConfig }) {
5024
+ await (await PowerlinesExecution.init(options, initialConfig)).types(inlineConfig);
4988
5025
  }
4989
- async function lint({ options, config }) {
4990
- await (await PowerlinesExecution.fromConfig(options, config)).lint(config);
5026
+ async function lint({ options, initialConfig, inlineConfig }) {
5027
+ await (await PowerlinesExecution.init(options, initialConfig)).lint(inlineConfig);
4991
5028
  }
4992
- async function test({ options, config }) {
4993
- await (await PowerlinesExecution.fromConfig(options, config)).test(config);
5029
+ async function test({ options, initialConfig, inlineConfig }) {
5030
+ await (await PowerlinesExecution.init(options, initialConfig)).test(inlineConfig);
4994
5031
  }
4995
- async function build({ options, config }) {
4996
- await (await PowerlinesExecution.fromConfig(options, config)).build(config);
5032
+ async function build({ options, initialConfig, inlineConfig }) {
5033
+ await (await PowerlinesExecution.init(options, initialConfig)).build(inlineConfig);
4997
5034
  }
4998
- async function docs({ options, config }) {
4999
- await (await PowerlinesExecution.fromConfig(options, config)).docs(config);
5035
+ async function docs({ options, initialConfig, inlineConfig }) {
5036
+ await (await PowerlinesExecution.init(options, initialConfig)).docs(inlineConfig);
5000
5037
  }
5001
- async function deploy({ options, config }) {
5002
- await (await PowerlinesExecution.fromConfig(options, config)).deploy(config);
5038
+ async function deploy({ options, initialConfig, inlineConfig }) {
5039
+ await (await PowerlinesExecution.init(options, initialConfig)).deploy(inlineConfig);
5003
5040
  }
5004
5041
 
5005
5042
  //#endregion