@powerlines/engine 0.44.11 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/_internal/worker.cjs +141 -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 +142 -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-C-M-Mxse.cjs → execution-context-BFCOc0mH.cjs} +61 -48
  28. package/dist/{execution-context-D9Enw3J5.mjs → execution-context-Cr_VUBrP.mjs} +63 -50
  29. package/dist/execution-context-Cr_VUBrP.mjs.map +1 -0
  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,12 @@ 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
+ initialConfig,
3173
3185
  userConfig
3174
3186
  };
3175
3187
  }
@@ -3192,28 +3204,33 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3192
3204
  ] },
3193
3205
  dts: true
3194
3206
  });
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) {
3207
+ logger.trace(`Pre-setup Powerlines configuration object: \n${formatLogMessage({
3208
+ ...omit(this.config, [
3209
+ "inlineConfig",
3210
+ "userConfig",
3211
+ "initialConfig",
3212
+ "pluginConfig",
3213
+ "plugins"
3214
+ ]),
3215
+ inlineConfig: isSetObject(this.config.inlineConfig) ? omit(this.config.inlineConfig, ["plugins"]) : void 0,
3216
+ userConfig: isSetObject(this.config.userConfig) ? omit(this.config.userConfig, ["plugins"]) : void 0,
3217
+ initialConfig: isSetObject(this.config.initialConfig) ? omit(this.config.initialConfig, ["plugins"]) : void 0,
3218
+ pluginConfig: isSetObject(this.config.pluginConfig) ? omit(this.config.pluginConfig, ["plugins"]) : void 0
3219
+ })}`);
3220
+ if (!this.initialOptions.mode && !this.config.userConfig?.mode && !this.config.inlineConfig?.mode && !this.config.initialConfig?.mode && !this.config.pluginConfig?.mode) {
3202
3221
  this.options.mode = "production";
3203
3222
  this.config.mode = "production";
3204
3223
  }
3205
- if (!this.inputOptions.framework && !this.config.userConfig?.framework && !this.config.inlineConfig?.framework && !this.config.pluginConfig?.framework) {
3224
+ if (!this.initialOptions.framework && !this.config.userConfig?.framework && !this.config.inlineConfig?.framework && !this.config.initialConfig?.framework && !this.config.pluginConfig?.framework) {
3206
3225
  this.options.framework = "powerlines";
3207
3226
  this.config.framework = "powerlines";
3208
3227
  }
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");
3228
+ if (!this.config.userConfig?.projectType && !this.config.inlineConfig?.projectType && !this.config.initialConfig?.projectType && !this.config.pluginConfig?.projectType) this.config.projectType = "application";
3229
+ if (!this.config.userConfig?.platform && !this.config.inlineConfig?.platform && !this.config.initialConfig?.platform && !this.config.pluginConfig?.platform) this.config.platform = "neutral";
3230
+ this.resolvedConfig.compatibilityDate = resolveCompatibilityDates(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.initialConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
3212
3231
  this.config.input = getUniqueInputs(this.config.input);
3213
3232
  if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
3214
3233
  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
3234
  if (this.config.resolve.external) this.config.resolve.external = getUnique(this.config.resolve.external);
3218
3235
  if (this.config.resolve.noExternal) this.config.resolve.noExternal = getUnique(this.config.resolve.noExternal);
3219
3236
  this.config.plugins = (this.config.plugins ?? []).flatMap((plugin) => toArray(plugin)).filter(Boolean).reduce((ret, plugin) => {
@@ -3221,10 +3238,10 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3221
3238
  ret.push(plugin);
3222
3239
  return ret;
3223
3240
  }, []);
3224
- if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;
3241
+ 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
3242
  else if (this.config.mode === "test") this.config.logLevel = DEFAULT_TEST_LOG_LEVEL;
3226
3243
  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);
3244
+ 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
3245
  else if (this.config.tsconfig) this.config.tsconfig = replacePath(replacePathTokens(this, this.config.tsconfig), this.config.cwd);
3229
3246
  this.config.output.format = getUnique(toArray(this.config.output?.format ?? (this.config.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
3230
3247
  if (this.config.output.path) this.config.output.path = appendPath(replacePathTokens(this, this.config.output.path), this.config.cwd);
@@ -3234,7 +3251,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3234
3251
  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
3252
  else this.config.output.copy.path = appendPath(replacePathTokens(this, this.config.output.copy.path || joinPaths$1("dist", this.config.root)), this.config.cwd);
3236
3253
  }
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);
3254
+ 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
3255
  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
3256
  return {
3240
3257
  glob: isSetObject(asset) ? asset.glob : asset,
@@ -3243,11 +3260,11 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3243
3260
  ignore: isSetObject(asset) && asset.ignore ? toArray(asset.ignore) : void 0
3244
3261
  };
3245
3262
  }), (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;
3263
+ 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
3264
  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;
3265
+ 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
3266
  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"}`;
3267
+ 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
3268
  if (this.config.output.copy && this.config.output.copy.assets) this.config.output.copy.assets = this.config.output.copy.assets.map((asset) => ({
3252
3269
  ...asset,
3253
3270
  glob: replacePathTokens(this, asset.glob),
@@ -3257,24 +3274,24 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3257
3274
  }));
3258
3275
  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
3276
  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)}`);
3277
+ 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({
3278
+ ...omit(this.config, [
3279
+ "inlineConfig",
3280
+ "userConfig",
3281
+ "initialConfig",
3282
+ "pluginConfig",
3283
+ "plugins"
3284
+ ]),
3285
+ inlineConfig: isSetObject(this.config.inlineConfig) ? omit(this.config.inlineConfig, ["plugins"]) : void 0,
3286
+ userConfig: isSetObject(this.config.userConfig) ? omit(this.config.userConfig, ["plugins"]) : void 0,
3287
+ initialConfig: isSetObject(this.config.initialConfig) ? omit(this.config.initialConfig, ["plugins"]) : void 0,
3288
+ pluginConfig: isSetObject(this.config.pluginConfig) ? omit(this.config.pluginConfig, ["plugins"]) : void 0
3289
+ })}`);
3266
3290
  }
3267
3291
  };
3268
3292
 
3269
3293
  //#endregion
3270
3294
  //#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
3295
  /**
3279
3296
  * Merges the current hook result with the previous results based on their types.
3280
3297
  *
@@ -3285,7 +3302,7 @@ const mergeResultObjects = createDefu((obj, key, value) => {
3285
3302
  function mergeResults(currentResult, previousResults) {
3286
3303
  if (!previousResults || previousResults.length === 0) return [currentResult];
3287
3304
  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] ?? {})];
3305
+ else if (isObject(currentResult)) previousResults = previousResults.length > 0 ? [defu$1(currentResult, previousResults[0])] : [currentResult];
3289
3306
  return previousResults;
3290
3307
  }
3291
3308
  /**
@@ -3663,9 +3680,9 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
3663
3680
  * @param options - The options for resolving the context.
3664
3681
  * @returns A promise that resolves to the new context.
3665
3682
  */
3666
- static async fromOptions(options) {
3683
+ static async init(options, initialConfig) {
3667
3684
  const context = new PowerlinesExecutionContext(options);
3668
- await context.init(options);
3685
+ await context.init(options, initialConfig);
3669
3686
  const powerlinesPath = await resolvePackage("powerlines");
3670
3687
  if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
3671
3688
  context.powerlinesPath = powerlinesPath;
@@ -3677,10 +3694,10 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
3677
3694
  * @param options - The options for resolving the context.
3678
3695
  * @returns A promise that resolves to the new context.
3679
3696
  */
3680
- static async fromConfig(options, config) {
3697
+ static async inline(options, initialConfig, inlineConfig) {
3681
3698
  const context = new PowerlinesExecutionContext(options);
3682
- await context.init(options);
3683
- context.config.inlineConfig = config;
3699
+ await context.init(options, initialConfig);
3700
+ context.config.inlineConfig = inlineConfig;
3684
3701
  if (context.config.inlineConfig.command === "new") {
3685
3702
  const workspacePackageJsonPath = joinPaths$1(context.config.cwd, "package.json");
3686
3703
  if (!existsSync(workspacePackageJsonPath)) throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
@@ -3774,8 +3791,9 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
3774
3791
  * @returns A promise that resolves to the cloned context.
3775
3792
  */
3776
3793
  async clone() {
3777
- const clone = await PowerlinesExecutionContext.fromOptions(this.options);
3794
+ const clone = await PowerlinesExecutionContext.init(this.options, this.initialConfig);
3778
3795
  clone.config.userConfig = deepClone(this.config.userConfig);
3796
+ clone.config.initialConfig = deepClone(this.config.initialConfig);
3779
3797
  clone.config.inlineConfig = deepClone(this.config.inlineConfig);
3780
3798
  clone.config.pluginConfig = deepClone(this.config.pluginConfig);
3781
3799
  await clone.setup();
@@ -4607,47 +4625,53 @@ ${formatTypes(code)}
4607
4625
  `);
4608
4626
  }
4609
4627
  /**
4628
+ * Initialize a Powerlines API instance
4629
+ *
4630
+ * @param options - The options to initialize the API with
4631
+ * @returns A new instance of the Powerlines API
4632
+ */
4633
+ static async init(options, initialConfig) {
4634
+ const api = new PowerlinesExecution(await PowerlinesExecutionContext.init(options, initialConfig ?? {}));
4635
+ api.#context.config.initialConfig = initialConfig ?? {};
4636
+ await api.setup();
4637
+ return api;
4638
+ }
4639
+ /**
4610
4640
  * The Powerlines context
4611
4641
  */
4612
4642
  get context() {
4613
4643
  return this.#context;
4614
4644
  }
4615
4645
  /**
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
4646
+ * Initialize the execution API with the provided configuration options
4620
4647
  */
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)
4648
+ async setup() {
4649
+ await this.#context.setup();
4650
+ this.#context.$$internal = {
4651
+ api: this,
4652
+ addPlugin: this.addPlugin.bind(this)
4628
4653
  };
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({
4654
+ const timer = this.#context.timer("Initialization");
4655
+ for (const plugin of this.#context.config.plugins.flatMap((p) => toArray(p)) ?? []) await this.addPlugin(plugin);
4656
+ if (this.#context.plugins.length === 0) this.#context.warn({
4632
4657
  meta: { category: "plugins" },
4633
4658
  message: "No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended."
4634
4659
  });
4635
- else api.context.info({
4660
+ else this.#context.info({
4636
4661
  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")}`
4662
+ 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
4663
  });
4639
- const pluginConfig = await api.callHook("config", {
4640
- environment: await api.context.getEnvironment(),
4664
+ const pluginConfig = await this.callHook("config", {
4665
+ environment: await this.#context.getEnvironment(),
4641
4666
  sequential: true,
4642
4667
  result: "merge",
4643
4668
  merge: mergeConfigs
4644
4669
  });
4645
4670
  if (pluginConfig) {
4646
- api.#context.config.pluginConfig = pluginConfig;
4647
- await api.#context.setup();
4671
+ this.#context.config.pluginConfig = pluginConfig;
4672
+ await this.#context.setup();
4648
4673
  }
4649
4674
  timer();
4650
- return api;
4651
4675
  }
4652
4676
  /**
4653
4677
  * Generate the Powerlines typescript declaration file
@@ -4661,7 +4685,7 @@ ${formatTypes(code)}
4661
4685
  this.context.debug(" Aggregating configuration options for the Powerlines project");
4662
4686
  inlineConfig.command ??= "types";
4663
4687
  this.context.config.inlineConfig = inlineConfig;
4664
- await this.context.setup();
4688
+ await this.setup();
4665
4689
  await this.#executeEnvironments(async (context) => {
4666
4690
  context.debug(`Initializing the processing options for the Powerlines project.`);
4667
4691
  await this.callHook("configResolved", {
@@ -4712,7 +4736,7 @@ ${formatTypes(code)}
4712
4736
  async prepare(inlineConfig = { command: "prepare" }) {
4713
4737
  inlineConfig.command ??= "prepare";
4714
4738
  this.context.config.inlineConfig = inlineConfig;
4715
- await this.context.setup();
4739
+ await this.setup();
4716
4740
  await this.#executeEnvironments(async (context) => {
4717
4741
  context.debug(`Initializing the processing options for the Powerlines project.`);
4718
4742
  await this.callHook("configResolved", {
@@ -4732,12 +4756,23 @@ ${formatTypes(code)}
4732
4756
  environment: context,
4733
4757
  order: "post"
4734
4758
  });
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
- })}`);
4759
+ context.trace({
4760
+ meta: { category: "config" },
4761
+ message: `Powerlines configuration after configResolved hook: \n${formatLogMessage({
4762
+ ...omit(context.config, [
4763
+ "inlineConfig",
4764
+ "userConfig",
4765
+ "initialConfig",
4766
+ "pluginConfig",
4767
+ "plugins"
4768
+ ]),
4769
+ plugins: context.plugins.map((plugin) => plugin.plugin.name),
4770
+ inlineConfig: isSetObject(context.config.inlineConfig) ? omit(context.config.inlineConfig, ["plugins"]) : void 0,
4771
+ userConfig: isSetObject(context.config.userConfig) ? omit(context.config.userConfig, ["plugins"]) : void 0,
4772
+ initialConfig: isSetObject(context.config.initialConfig) ? omit(context.config.initialConfig, ["plugins"]) : void 0,
4773
+ pluginConfig: isSetObject(context.config.pluginConfig) ? omit(context.config.pluginConfig, ["plugins"]) : void 0
4774
+ })}`
4775
+ });
4741
4776
  if (!context.fs.existsSync(context.cachePath)) await createDirectory(context.cachePath);
4742
4777
  if (!context.fs.existsSync(context.dataPath)) await createDirectory(context.dataPath);
4743
4778
  await this.callHook("prepare", {
@@ -4977,29 +5012,29 @@ ${formatTypes(code)}
4977
5012
 
4978
5013
  //#endregion
4979
5014
  //#region src/_internal/worker.ts
4980
- async function clean({ options, config }) {
4981
- await (await PowerlinesExecution.fromConfig(options, config)).clean(config);
5015
+ async function clean({ options, initialConfig, inlineConfig }) {
5016
+ await (await PowerlinesExecution.init(options, initialConfig)).clean(inlineConfig);
4982
5017
  }
4983
- async function prepare({ options, config }) {
4984
- await (await PowerlinesExecution.fromConfig(options, config)).prepare(config);
5018
+ async function prepare({ options, initialConfig, inlineConfig }) {
5019
+ await (await PowerlinesExecution.init(options, initialConfig)).prepare(inlineConfig);
4985
5020
  }
4986
- async function types({ options, config }) {
4987
- await (await PowerlinesExecution.fromConfig(options, config)).types(config);
5021
+ async function types({ options, initialConfig, inlineConfig }) {
5022
+ await (await PowerlinesExecution.init(options, initialConfig)).types(inlineConfig);
4988
5023
  }
4989
- async function lint({ options, config }) {
4990
- await (await PowerlinesExecution.fromConfig(options, config)).lint(config);
5024
+ async function lint({ options, initialConfig, inlineConfig }) {
5025
+ await (await PowerlinesExecution.init(options, initialConfig)).lint(inlineConfig);
4991
5026
  }
4992
- async function test({ options, config }) {
4993
- await (await PowerlinesExecution.fromConfig(options, config)).test(config);
5027
+ async function test({ options, initialConfig, inlineConfig }) {
5028
+ await (await PowerlinesExecution.init(options, initialConfig)).test(inlineConfig);
4994
5029
  }
4995
- async function build({ options, config }) {
4996
- await (await PowerlinesExecution.fromConfig(options, config)).build(config);
5030
+ async function build({ options, initialConfig, inlineConfig }) {
5031
+ await (await PowerlinesExecution.init(options, initialConfig)).build(inlineConfig);
4997
5032
  }
4998
- async function docs({ options, config }) {
4999
- await (await PowerlinesExecution.fromConfig(options, config)).docs(config);
5033
+ async function docs({ options, initialConfig, inlineConfig }) {
5034
+ await (await PowerlinesExecution.init(options, initialConfig)).docs(inlineConfig);
5000
5035
  }
5001
- async function deploy({ options, config }) {
5002
- await (await PowerlinesExecution.fromConfig(options, config)).deploy(config);
5036
+ async function deploy({ options, initialConfig, inlineConfig }) {
5037
+ await (await PowerlinesExecution.init(options, initialConfig)).deploy(inlineConfig);
5003
5038
  }
5004
5039
 
5005
5040
  //#endregion