@powerlines/engine 0.46.4 → 0.46.6

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 (35) hide show
  1. package/dist/_internal/worker.cjs +34 -54
  2. package/dist/_internal/worker.mjs +35 -55
  3. package/dist/_internal/worker.mjs.map +1 -1
  4. package/dist/api.cjs +2 -15
  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 +3 -16
  10. package/dist/api.mjs.map +1 -1
  11. package/dist/{base-context-D7G_24-i.cjs → base-context-CbFlRUd-.cjs} +8 -6
  12. package/dist/{base-context-DU0NRHDt.mjs → base-context-Ce9PuQ9z.mjs} +9 -7
  13. package/dist/{base-context-DU0NRHDt.mjs.map → base-context-Ce9PuQ9z.mjs.map} +1 -1
  14. package/dist/context/index.cjs +3 -3
  15. package/dist/context/index.d.cts +1 -1
  16. package/dist/context/index.d.cts.map +1 -1
  17. package/dist/context/index.d.mts +1 -1
  18. package/dist/context/index.d.mts.map +1 -1
  19. package/dist/context/index.mjs +3 -3
  20. package/dist/{engine-context-BvDfqfY7.mjs → engine-context-CEbC9dHR.mjs} +2 -2
  21. package/dist/{engine-context-BvDfqfY7.mjs.map → engine-context-CEbC9dHR.mjs.map} +1 -1
  22. package/dist/{engine-context-BuJQY312.cjs → engine-context-D-rpz-J2.cjs} +1 -1
  23. package/dist/{execution-context-Dxa103Qg.cjs → execution-context-9aXwcpL6.cjs} +26 -34
  24. package/dist/{execution-context-Bb5pfsyN.mjs → execution-context-DUtt6PWE.mjs} +32 -40
  25. package/dist/execution-context-DUtt6PWE.mjs.map +1 -0
  26. package/dist/{execution-context-CghMd-eP.d.cts → execution-context-Da_wozne.d.mts} +5 -6
  27. package/dist/execution-context-Da_wozne.d.mts.map +1 -0
  28. package/dist/{execution-context-rKd-zSZy.d.mts → execution-context-NyDjVZ6T.d.cts} +5 -6
  29. package/dist/execution-context-NyDjVZ6T.d.cts.map +1 -0
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.mjs +1 -1
  32. package/package.json +5 -3
  33. package/dist/execution-context-Bb5pfsyN.mjs.map +0 -1
  34. package/dist/execution-context-CghMd-eP.d.cts.map +0 -1
  35. package/dist/execution-context-rKd-zSZy.d.mts.map +0 -1
@@ -75,9 +75,11 @@ let _stryke_hash = require("@stryke/hash");
75
75
  let _stryke_hash_node = require("@stryke/hash/node");
76
76
  let _stryke_http_fetch = require("@stryke/http/fetch");
77
77
  let _stryke_path_is_equal = require("@stryke/path/is-equal");
78
+ let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
78
79
  let bundle_require = require("bundle-require");
79
80
  let compatx = require("compatx");
80
81
  let flat_cache = require("flat-cache");
82
+ let node_fs = require("node:fs");
81
83
  let oxc_parser = require("oxc-parser");
82
84
  let undici = require("undici");
83
85
  require("@stryke/fs/remove-file");
@@ -97,7 +99,6 @@ let node_url = require("node:url");
97
99
  let _stryke_fs_is_file = require("@stryke/fs/is-file");
98
100
  let _stryke_fs_read_file = require("@stryke/fs/read-file");
99
101
  let _stryke_fs_write_file = require("@stryke/fs/write-file");
100
- let node_fs = require("node:fs");
101
102
  let node_fs_promises = require("node:fs/promises");
102
103
  let node_path = require("node:path");
103
104
  let typescript = require("typescript");
@@ -2435,12 +2436,14 @@ var PowerlinesBaseContext = class {
2435
2436
  * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
2436
2437
  */
2437
2438
  async resolvePackageConfigs(cwd = this.options.cwd, root = this.options.root) {
2438
- const projectJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root, cwd), "project.json");
2439
- if ((0, node_fs.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs.readJsonFile)(projectJsonPath);
2440
- const packageJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root, cwd), "package.json");
2441
- if ((0, node_fs.existsSync)(packageJsonPath)) {
2442
- this.packageJson = await (0, _stryke_fs.readJsonFile)(packageJsonPath);
2443
- 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);
2439
+ if (cwd || root) {
2440
+ const projectJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root || ".", cwd || "."), "project.json");
2441
+ if ((0, node_fs.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs.readJsonFile)(projectJsonPath);
2442
+ const packageJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root || ".", cwd || "."), "package.json");
2443
+ if ((0, node_fs.existsSync)(packageJsonPath)) {
2444
+ this.packageJson = await (0, _stryke_fs.readJsonFile)(packageJsonPath);
2445
+ 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);
2446
+ }
2444
2447
  }
2445
2448
  }
2446
2449
  /**
@@ -3131,7 +3134,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3131
3134
  async setInlineConfig(config) {
3132
3135
  this.logger.debug({
3133
3136
  meta: { category: "config" },
3134
- message: `Updating inline configuration object: \n${this.logConfig(config)}`
3137
+ message: `Updating inline configuration object: \n${(0, _powerlines_core_plugin_utils.formatConfig)(config)}`
3135
3138
  });
3136
3139
  this.inlineConfig = config;
3137
3140
  await this.resolveConfig();
@@ -3145,7 +3148,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3145
3148
  async setPluginConfig(config) {
3146
3149
  this.logger.debug({
3147
3150
  meta: { category: "config" },
3148
- message: `Updating plugin configuration object: \n${this.logConfig(config)}`
3151
+ message: `Updating plugin configuration object: \n${(0, _powerlines_core_plugin_utils.formatConfig)(config)}`
3149
3152
  });
3150
3153
  this.pluginConfig = config;
3151
3154
  await this.resolveConfig();
@@ -3187,7 +3190,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3187
3190
  async setUserConfig(config) {
3188
3191
  this.logger.debug({
3189
3192
  meta: { category: "config" },
3190
- message: `Updating user configuration object: \n${this.logConfig(config)}`
3193
+ message: `Updating user configuration object: \n${(0, _powerlines_core_plugin_utils.formatConfig)(config)}`
3191
3194
  });
3192
3195
  this.userConfig = config;
3193
3196
  await this.resolveConfig();
@@ -3224,7 +3227,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3224
3227
  const mergedConfig = this.mergeConfig();
3225
3228
  this.logger.trace({
3226
3229
  meta: { category: "config" },
3227
- message: `Pre-setup Powerlines configuration object: \n --- Merged Config --- \n\n${this.logConfig(mergedConfig)} \n\n --- Initial Options --- \n\n${this.logConfig(this.initialOptions)} \n\n --- Initial Config --- \n\n${this.logConfig(this.initialConfig)} \n\n --- User Config --- \n\n${this.logConfig(this.userConfig)} \n\n --- Inline Config --- \n\n${this.logConfig(this.inlineConfig)} \n\n --- Plugin Config --- \n\n${this.logConfig(this.pluginConfig)} \n\n --- Environment Config --- \n\n${this.logConfig(this.environmentConfig)} \n\n --- Overridden Config --- \n\n${this.logConfig(this.overriddenConfig)}`
3230
+ message: `Pre-setup Powerlines configuration object: \n --- Merged Config --- \n${(0, _powerlines_core_plugin_utils.formatConfig)(mergedConfig)} \n\n --- Initial Options --- \n${(0, _powerlines_core_plugin_utils.formatConfig)(this.initialOptions)} \n\n --- Initial Config --- \n${(0, _powerlines_core_plugin_utils.formatConfig)(this.initialConfig)} \n\n --- User Config --- \n${(0, _powerlines_core_plugin_utils.formatConfig)(this.userConfig)} \n\n --- Inline Config --- \n${(0, _powerlines_core_plugin_utils.formatConfig)(this.inlineConfig)} \n\n --- Plugin Config --- \n${(0, _powerlines_core_plugin_utils.formatConfig)(this.pluginConfig)} \n\n --- Environment Config --- \n${(0, _powerlines_core_plugin_utils.formatConfig)(this.environmentConfig)} \n\n --- Overridden Config --- \n${(0, _powerlines_core_plugin_utils.formatConfig)(this.overriddenConfig)}`
3228
3231
  });
3229
3232
  mergedConfig.output = (0, defu.default)(mergedConfig.output ?? {}, {
3230
3233
  copy: { assets: [
@@ -3240,14 +3243,17 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3240
3243
  ] },
3241
3244
  dts: true
3242
3245
  });
3243
- if (!mergedConfig.mode) mergedConfig.mode = "production";
3244
- if (!mergedConfig.framework) mergedConfig.framework = "powerlines";
3245
- if (!mergedConfig.projectType) mergedConfig.projectType = "application";
3246
- if (!mergedConfig.platform) mergedConfig.platform = "neutral";
3246
+ if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.mode)) mergedConfig.mode = await this.getDefaultMode();
3247
+ if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.framework)) mergedConfig.framework = "powerlines";
3248
+ if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.platform)) mergedConfig.platform = "neutral";
3247
3249
  mergedConfig.compatibilityDate = (0, compatx.resolveCompatibilityDates)(mergedConfig.compatibilityDate, "latest");
3250
+ if (!this.packageJson && (0, node_fs.existsSync)((0, _stryke_path_join.joinPaths)((0, _stryke_path_append.appendPath)(mergedConfig.root, mergedConfig.cwd), "package.json")) || !this.projectJson && (0, node_fs.existsSync)((0, _stryke_path_join.joinPaths)((0, _stryke_path_append.appendPath)(mergedConfig.root, mergedConfig.cwd), "project.json"))) {
3251
+ await this.resolvePackageConfigs(mergedConfig.cwd, mergedConfig.root);
3252
+ if (this.packageJson) mergedConfig.organization ??= (0, _powerlines_core_plugin_utils.getPackageJsonOrganization)(this.packageJson) || "powerlines";
3253
+ }
3254
+ if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.projectType)) mergedConfig.projectType = this.projectJson?.projectType || "application";
3248
3255
  this.resolvedConfig = mergedConfig;
3249
3256
  this.#configProxy = this.createConfigProxy();
3250
- if (!this.packageJson) await this.resolvePackageConfigs();
3251
3257
  mergedConfig.input = (0, _powerlines_core_lib_entry.getUniqueInputs)(mergedConfig.input);
3252
3258
  if (mergedConfig.name?.startsWith("@") && mergedConfig.name.split("/").filter(Boolean).length > 1) mergedConfig.name = mergedConfig.name.split("/").filter(Boolean)[1];
3253
3259
  mergedConfig.title ??= (0, _stryke_string_format_title_case.titleCase)(mergedConfig.name);
@@ -3258,18 +3264,18 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3258
3264
  ret.push(plugin);
3259
3265
  return ret;
3260
3266
  }, []);
3261
- if (!mergedConfig.logLevel) if (mergedConfig.mode === "development") mergedConfig.logLevel = _powerlines_core_constants.DEFAULT_DEVELOPMENT_LOG_LEVEL;
3267
+ if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.logLevel)) if (mergedConfig.mode === "development") mergedConfig.logLevel = _powerlines_core_constants.DEFAULT_DEVELOPMENT_LOG_LEVEL;
3262
3268
  else if (mergedConfig.mode === "test") mergedConfig.logLevel = _powerlines_core_constants.DEFAULT_TEST_LOG_LEVEL;
3263
3269
  else mergedConfig.logLevel = _powerlines_core_constants.DEFAULT_PRODUCTION_LOG_LEVEL;
3264
3270
  mergedConfig.logLevel = (0, _powerlines_core_plugin_utils.resolveLogLevel)(mergedConfig.logLevel);
3265
- if (mergedConfig.tsconfig) mergedConfig.tsconfig = (0, _stryke_path_replace.replacePath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.tsconfig), mergedConfig.cwd);
3271
+ if ((0, _stryke_type_checks_is_set_string.isSetString)(mergedConfig.tsconfig)) mergedConfig.tsconfig = (0, _stryke_path_replace.replacePath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.tsconfig), mergedConfig.cwd);
3266
3272
  else mergedConfig.tsconfig = getTsconfigFilePath(mergedConfig.cwd, mergedConfig.root);
3267
3273
  mergedConfig.output.format = (0, _stryke_helpers_get_unique.getUnique)((0, _stryke_convert_to_array.toArray)(mergedConfig.output?.format ?? (mergedConfig.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
3268
- if (mergedConfig.output.path) mergedConfig.output.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.path), mergedConfig.cwd);
3274
+ if ((0, _stryke_type_checks_is_set_string.isSetString)(mergedConfig.output.path)) mergedConfig.output.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.path), mergedConfig.cwd);
3269
3275
  else mergedConfig.output.path = (0, _stryke_path_append.appendPath)((0, _stryke_path_join.joinPaths)(mergedConfig.root, "dist"), mergedConfig.cwd);
3270
3276
  mergedConfig.output.copy ??= {};
3271
- if (mergedConfig.output.copy !== false) if (!mergedConfig.root.replace(/^\.\/?/, "")) mergedConfig.output.copy.path = mergedConfig.output.copy.path ? (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.copy.path), mergedConfig.cwd) : mergedConfig.output.path;
3272
- else mergedConfig.output.copy.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.copy.path || (0, _stryke_path_join.joinPaths)("dist", mergedConfig.root)), mergedConfig.cwd);
3277
+ if (mergedConfig.output.copy !== false) if (!mergedConfig.root.replace(/^\.\/?/, "")) mergedConfig.output.copy.path = (0, _stryke_type_checks_is_set_string.isSetString)(mergedConfig.output.copy.path) ? (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.copy.path), mergedConfig.cwd) : mergedConfig.output.path;
3278
+ else mergedConfig.output.copy.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, (0, _stryke_type_checks_is_set_string.isSetString)(mergedConfig.output.copy.path) ? mergedConfig.output.copy.path : (0, _stryke_path_join.joinPaths)("dist", mergedConfig.root)), mergedConfig.cwd);
3273
3279
  if (mergedConfig.output.types !== false) mergedConfig.output.types = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.types || (0, _stryke_path_join.joinPaths)(mergedConfig.root, `${mergedConfig.framework ?? "powerlines"}.d.ts`)), mergedConfig.cwd);
3274
3280
  if (mergedConfig.output.copy && mergedConfig.output.copy.path && mergedConfig.output.copy.assets && Array.isArray(mergedConfig.output.copy.assets)) mergedConfig.output.copy.assets = (0, _stryke_helpers_get_unique.getUniqueBy)(mergedConfig.output.copy.assets.map((asset) => {
3275
3281
  return {
@@ -3279,11 +3285,11 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3279
3285
  ignore: (0, _stryke_type_checks_is_set_object.isSetObject)(asset) && asset.ignore ? (0, _stryke_convert_to_array.toArray)(asset.ignore) : void 0
3280
3286
  };
3281
3287
  }), (a) => `${a.input}-${a.glob}-${a.output}`);
3282
- if (!mergedConfig.output?.sourceMap) if (mergedConfig.mode === "development") mergedConfig.output.sourceMap = true;
3288
+ if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.output?.sourceMap)) if (mergedConfig.mode === "development") mergedConfig.output.sourceMap = true;
3283
3289
  else mergedConfig.output.sourceMap = false;
3284
- if (!mergedConfig.output.minify) if (mergedConfig.mode === "production") mergedConfig.output.minify = true;
3290
+ if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.output?.minify)) if (mergedConfig.mode === "production") mergedConfig.output.minify = true;
3285
3291
  else mergedConfig.output.minify = false;
3286
- if (!mergedConfig.output.artifactsPath) mergedConfig.output.artifactsPath = `.${mergedConfig.framework || "powerlines"}`;
3292
+ if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.output?.artifactsPath)) mergedConfig.output.artifactsPath = `.${mergedConfig.framework || "powerlines"}`;
3287
3293
  if (mergedConfig.output.copy && mergedConfig.output.copy.assets) mergedConfig.output.copy.assets = mergedConfig.output.copy.assets.map((asset) => ({
3288
3294
  ...asset,
3289
3295
  glob: (0, _powerlines_core_plugin_utils.replacePathTokens)(this, asset.glob),
@@ -3294,25 +3300,12 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3294
3300
  if ((0, _stryke_type_checks_is_set_string.isSetString)(mergedConfig.output?.storage) && mergedConfig.output.storage === "virtual" || (0, _stryke_type_checks_is_set_object.isSetObject)(mergedConfig.output?.storage) && Object.values(mergedConfig.output.storage).every((adapter) => adapter.preset === "virtual")) mergedConfig.output.overwrite = true;
3295
3301
  this.resolvedConfig = mergedConfig;
3296
3302
  this.#configProxy = this.createConfigProxy();
3297
- this.logger.debug({
3303
+ this.logger.info({
3298
3304
  meta: { category: "config" },
3299
- message: `Resolved Powerlines configuration object: \n${this.logConfig(this.resolvedConfig)}`
3305
+ message: `Resolved Powerlines configuration object: \n${(0, _powerlines_core_plugin_utils.formatConfig)(this.resolvedConfig)}`
3300
3306
  });
3301
3307
  this.#fs ??= await VirtualFileSystem.create(this);
3302
3308
  }
3303
- logConfig(config) {
3304
- return JSON.stringify({
3305
- ...(0, _stryke_helpers_omit.omit)(config, [
3306
- "plugins",
3307
- "initialConfig",
3308
- "userConfig",
3309
- "inlineConfig",
3310
- "pluginConfig",
3311
- "environmentConfig"
3312
- ]),
3313
- plugins: config.plugins ? config.plugins.flatMap((plugin) => (0, _stryke_convert_to_array.toArray)(plugin)).map((plugin) => String((0, _stryke_type_checks_is_set_string.isSetString)(plugin) ? plugin : (0, _stryke_type_checks_is_set_object.isSetObject)(plugin) && (0, _stryke_type_checks_is_set_string.isSetString)(plugin.name) ? plugin.name : Array.isArray(plugin) && (0, _stryke_type_checks_is_set_string.isSetString)(plugin[0]) ? plugin[0] : "<function-plugin>")) : []
3314
- }, null, 2).replace(/"([^"]+)":/g, "$1:").replace(/: "([^"]+)"/g, ": $1");
3315
- }
3316
3309
  createConfigProxy() {
3317
3310
  return new Proxy(this.resolvedConfig, {
3318
3311
  /**
@@ -3670,7 +3663,7 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
3670
3663
  async setEnvironmentConfig(config) {
3671
3664
  this.logger.debug({
3672
3665
  meta: { category: "config" },
3673
- message: `Updating environment configuration object: \n${this.logConfig(config)}`
3666
+ message: `Updating environment configuration object: \n${(0, _powerlines_core_plugin_utils.formatConfig)(config)}`
3674
3667
  });
3675
3668
  this.environmentConfig = config;
3676
3669
  await this.resolveConfig();
@@ -4646,20 +4639,7 @@ var PowerlinesExecution = class PowerlinesExecution {
4646
4639
  });
4647
4640
  context.trace({
4648
4641
  meta: { category: "config" },
4649
- message: `Powerlines configuration after configResolved hook: \n${(0, _storm_software_config_tools_logger_console.formatLogMessage)({
4650
- ...(0, _stryke_helpers_omit.omit)(context.config, [
4651
- "inlineConfig",
4652
- "userConfig",
4653
- "initialConfig",
4654
- "pluginConfig",
4655
- "plugins"
4656
- ]),
4657
- plugins: context.plugins.map((plugin) => plugin.plugin.name),
4658
- inlineConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.inlineConfig) ? (0, _stryke_helpers_omit.omit)(context.config.inlineConfig, ["plugins"]) : void 0,
4659
- userConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.userConfig) ? (0, _stryke_helpers_omit.omit)(context.config.userConfig, ["plugins"]) : void 0,
4660
- initialConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.initialConfig) ? (0, _stryke_helpers_omit.omit)(context.config.initialConfig, ["plugins"]) : void 0,
4661
- pluginConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.pluginConfig) ? (0, _stryke_helpers_omit.omit)(context.config.pluginConfig, ["plugins"]) : void 0
4662
- })}`
4642
+ message: `Powerlines configuration after configResolved hook: \n${(0, _powerlines_core_plugin_utils.formatConfig)(context.config)}`
4663
4643
  });
4664
4644
  if (!context.fs.existsSync(context.cachePath)) await (0, _stryke_fs_helpers.createDirectory)(context.cachePath);
4665
4645
  if (!context.fs.existsSync(context.dataPath)) await (0, _stryke_fs_helpers.createDirectory)(context.dataPath);
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env -S NODE_OPTIONS=--enable-source-maps node
2
2
  import { getFileHeaderWarningText, getTypescriptFileHeader } from "@powerlines/core/lib/utilities/file-header";
3
3
  import { format, formatFolder } from "@powerlines/core/lib/utilities/format";
4
- import { addPluginHook, createLogger, dedupeHooklist, findInvalidPluginConfig, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn } from "@powerlines/core/plugin-utils";
4
+ import { addPluginHook, createLogger, dedupeHooklist, findInvalidPluginConfig, formatConfig, getPackageJsonOrganization, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn } from "@powerlines/core/plugin-utils";
5
5
  import { colorText, createLogger as createLogger$1, extendLogger } from "@powerlines/core/plugin-utils/logging";
6
6
  import { formatLogMessage } from "@storm-software/config-tools/logger/console";
7
7
  import { toArray } from "@stryke/convert/to-array";
@@ -44,9 +44,11 @@ import { murmurhash } from "@stryke/hash";
44
44
  import { hashDirectory } from "@stryke/hash/node";
45
45
  import { fetchRequest } from "@stryke/http/fetch";
46
46
  import { isEqual } from "@stryke/path/is-equal";
47
+ import { isUndefined } from "@stryke/type-checks/is-undefined";
47
48
  import { match, tsconfigPathsToRegExp } from "bundle-require";
48
49
  import { resolveCompatibilityDates } from "compatx";
49
50
  import { create } from "flat-cache";
51
+ import { existsSync as existsSync$1, unlinkSync } from "node:fs";
50
52
  import { parse } from "oxc-parser";
51
53
  import { Agent, Response, interceptors, setGlobalDispatcher } from "undici";
52
54
  import "@stryke/fs/remove-file";
@@ -65,7 +67,6 @@ import { fileURLToPath } from "node:url";
65
67
  import { isDirectory, isFile } from "@stryke/fs/is-file";
66
68
  import { readFile, readFileSync } from "@stryke/fs/read-file";
67
69
  import { writeFile, writeFileSync } from "@stryke/fs/write-file";
68
- import { existsSync as existsSync$1, unlinkSync } from "node:fs";
69
70
  import { unlink } from "node:fs/promises";
70
71
  import { resolve as resolve$1 } from "node:path";
71
72
  import ts from "typescript";
@@ -2402,12 +2403,14 @@ var PowerlinesBaseContext = class {
2402
2403
  * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
2403
2404
  */
2404
2405
  async resolvePackageConfigs(cwd = this.options.cwd, root = this.options.root) {
2405
- const projectJsonPath = joinPaths$2(appendPath(root, cwd), "project.json");
2406
- if (existsSync$1(projectJsonPath)) this.projectJson = await readJsonFile$1(projectJsonPath);
2407
- const packageJsonPath = joinPaths$2(appendPath(root, cwd), "package.json");
2408
- if (existsSync$1(packageJsonPath)) {
2409
- this.packageJson = await readJsonFile$1(packageJsonPath);
2410
- this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
2406
+ if (cwd || root) {
2407
+ const projectJsonPath = joinPaths$2(appendPath(root || ".", cwd || "."), "project.json");
2408
+ if (existsSync$1(projectJsonPath)) this.projectJson = await readJsonFile$1(projectJsonPath);
2409
+ const packageJsonPath = joinPaths$2(appendPath(root || ".", cwd || "."), "package.json");
2410
+ if (existsSync$1(packageJsonPath)) {
2411
+ this.packageJson = await readJsonFile$1(packageJsonPath);
2412
+ this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
2413
+ }
2411
2414
  }
2412
2415
  }
2413
2416
  /**
@@ -3098,7 +3101,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3098
3101
  async setInlineConfig(config) {
3099
3102
  this.logger.debug({
3100
3103
  meta: { category: "config" },
3101
- message: `Updating inline configuration object: \n${this.logConfig(config)}`
3104
+ message: `Updating inline configuration object: \n${formatConfig(config)}`
3102
3105
  });
3103
3106
  this.inlineConfig = config;
3104
3107
  await this.resolveConfig();
@@ -3112,7 +3115,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3112
3115
  async setPluginConfig(config) {
3113
3116
  this.logger.debug({
3114
3117
  meta: { category: "config" },
3115
- message: `Updating plugin configuration object: \n${this.logConfig(config)}`
3118
+ message: `Updating plugin configuration object: \n${formatConfig(config)}`
3116
3119
  });
3117
3120
  this.pluginConfig = config;
3118
3121
  await this.resolveConfig();
@@ -3154,7 +3157,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3154
3157
  async setUserConfig(config) {
3155
3158
  this.logger.debug({
3156
3159
  meta: { category: "config" },
3157
- message: `Updating user configuration object: \n${this.logConfig(config)}`
3160
+ message: `Updating user configuration object: \n${formatConfig(config)}`
3158
3161
  });
3159
3162
  this.userConfig = config;
3160
3163
  await this.resolveConfig();
@@ -3191,7 +3194,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3191
3194
  const mergedConfig = this.mergeConfig();
3192
3195
  this.logger.trace({
3193
3196
  meta: { category: "config" },
3194
- message: `Pre-setup Powerlines configuration object: \n --- Merged Config --- \n\n${this.logConfig(mergedConfig)} \n\n --- Initial Options --- \n\n${this.logConfig(this.initialOptions)} \n\n --- Initial Config --- \n\n${this.logConfig(this.initialConfig)} \n\n --- User Config --- \n\n${this.logConfig(this.userConfig)} \n\n --- Inline Config --- \n\n${this.logConfig(this.inlineConfig)} \n\n --- Plugin Config --- \n\n${this.logConfig(this.pluginConfig)} \n\n --- Environment Config --- \n\n${this.logConfig(this.environmentConfig)} \n\n --- Overridden Config --- \n\n${this.logConfig(this.overriddenConfig)}`
3197
+ message: `Pre-setup Powerlines configuration object: \n --- Merged Config --- \n${formatConfig(mergedConfig)} \n\n --- Initial Options --- \n${formatConfig(this.initialOptions)} \n\n --- Initial Config --- \n${formatConfig(this.initialConfig)} \n\n --- User Config --- \n${formatConfig(this.userConfig)} \n\n --- Inline Config --- \n${formatConfig(this.inlineConfig)} \n\n --- Plugin Config --- \n${formatConfig(this.pluginConfig)} \n\n --- Environment Config --- \n${formatConfig(this.environmentConfig)} \n\n --- Overridden Config --- \n${formatConfig(this.overriddenConfig)}`
3195
3198
  });
3196
3199
  mergedConfig.output = defu(mergedConfig.output ?? {}, {
3197
3200
  copy: { assets: [
@@ -3207,14 +3210,17 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3207
3210
  ] },
3208
3211
  dts: true
3209
3212
  });
3210
- if (!mergedConfig.mode) mergedConfig.mode = "production";
3211
- if (!mergedConfig.framework) mergedConfig.framework = "powerlines";
3212
- if (!mergedConfig.projectType) mergedConfig.projectType = "application";
3213
- if (!mergedConfig.platform) mergedConfig.platform = "neutral";
3213
+ if (isUndefined(mergedConfig.mode)) mergedConfig.mode = await this.getDefaultMode();
3214
+ if (isUndefined(mergedConfig.framework)) mergedConfig.framework = "powerlines";
3215
+ if (isUndefined(mergedConfig.platform)) mergedConfig.platform = "neutral";
3214
3216
  mergedConfig.compatibilityDate = resolveCompatibilityDates(mergedConfig.compatibilityDate, "latest");
3217
+ if (!this.packageJson && existsSync$1(joinPaths$1(appendPath(mergedConfig.root, mergedConfig.cwd), "package.json")) || !this.projectJson && existsSync$1(joinPaths$1(appendPath(mergedConfig.root, mergedConfig.cwd), "project.json"))) {
3218
+ await this.resolvePackageConfigs(mergedConfig.cwd, mergedConfig.root);
3219
+ if (this.packageJson) mergedConfig.organization ??= getPackageJsonOrganization(this.packageJson) || "powerlines";
3220
+ }
3221
+ if (isUndefined(mergedConfig.projectType)) mergedConfig.projectType = this.projectJson?.projectType || "application";
3215
3222
  this.resolvedConfig = mergedConfig;
3216
3223
  this.#configProxy = this.createConfigProxy();
3217
- if (!this.packageJson) await this.resolvePackageConfigs();
3218
3224
  mergedConfig.input = getUniqueInputs(mergedConfig.input);
3219
3225
  if (mergedConfig.name?.startsWith("@") && mergedConfig.name.split("/").filter(Boolean).length > 1) mergedConfig.name = mergedConfig.name.split("/").filter(Boolean)[1];
3220
3226
  mergedConfig.title ??= titleCase(mergedConfig.name);
@@ -3225,18 +3231,18 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3225
3231
  ret.push(plugin);
3226
3232
  return ret;
3227
3233
  }, []);
3228
- if (!mergedConfig.logLevel) if (mergedConfig.mode === "development") mergedConfig.logLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;
3234
+ if (isUndefined(mergedConfig.logLevel)) if (mergedConfig.mode === "development") mergedConfig.logLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;
3229
3235
  else if (mergedConfig.mode === "test") mergedConfig.logLevel = DEFAULT_TEST_LOG_LEVEL;
3230
3236
  else mergedConfig.logLevel = DEFAULT_PRODUCTION_LOG_LEVEL;
3231
3237
  mergedConfig.logLevel = resolveLogLevel(mergedConfig.logLevel);
3232
- if (mergedConfig.tsconfig) mergedConfig.tsconfig = replacePath(replacePathTokens(this, mergedConfig.tsconfig), mergedConfig.cwd);
3238
+ if (isSetString(mergedConfig.tsconfig)) mergedConfig.tsconfig = replacePath(replacePathTokens(this, mergedConfig.tsconfig), mergedConfig.cwd);
3233
3239
  else mergedConfig.tsconfig = getTsconfigFilePath(mergedConfig.cwd, mergedConfig.root);
3234
3240
  mergedConfig.output.format = getUnique(toArray(mergedConfig.output?.format ?? (mergedConfig.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
3235
- if (mergedConfig.output.path) mergedConfig.output.path = appendPath(replacePathTokens(this, mergedConfig.output.path), mergedConfig.cwd);
3241
+ if (isSetString(mergedConfig.output.path)) mergedConfig.output.path = appendPath(replacePathTokens(this, mergedConfig.output.path), mergedConfig.cwd);
3236
3242
  else mergedConfig.output.path = appendPath(joinPaths$1(mergedConfig.root, "dist"), mergedConfig.cwd);
3237
3243
  mergedConfig.output.copy ??= {};
3238
- if (mergedConfig.output.copy !== false) if (!mergedConfig.root.replace(/^\.\/?/, "")) mergedConfig.output.copy.path = mergedConfig.output.copy.path ? appendPath(replacePathTokens(this, mergedConfig.output.copy.path), mergedConfig.cwd) : mergedConfig.output.path;
3239
- else mergedConfig.output.copy.path = appendPath(replacePathTokens(this, mergedConfig.output.copy.path || joinPaths$1("dist", mergedConfig.root)), mergedConfig.cwd);
3244
+ if (mergedConfig.output.copy !== false) if (!mergedConfig.root.replace(/^\.\/?/, "")) mergedConfig.output.copy.path = isSetString(mergedConfig.output.copy.path) ? appendPath(replacePathTokens(this, mergedConfig.output.copy.path), mergedConfig.cwd) : mergedConfig.output.path;
3245
+ else mergedConfig.output.copy.path = appendPath(replacePathTokens(this, isSetString(mergedConfig.output.copy.path) ? mergedConfig.output.copy.path : joinPaths$1("dist", mergedConfig.root)), mergedConfig.cwd);
3240
3246
  if (mergedConfig.output.types !== false) mergedConfig.output.types = appendPath(replacePathTokens(this, mergedConfig.output.types || joinPaths$1(mergedConfig.root, `${mergedConfig.framework ?? "powerlines"}.d.ts`)), mergedConfig.cwd);
3241
3247
  if (mergedConfig.output.copy && mergedConfig.output.copy.path && mergedConfig.output.copy.assets && Array.isArray(mergedConfig.output.copy.assets)) mergedConfig.output.copy.assets = getUniqueBy(mergedConfig.output.copy.assets.map((asset) => {
3242
3248
  return {
@@ -3246,11 +3252,11 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3246
3252
  ignore: isSetObject(asset) && asset.ignore ? toArray(asset.ignore) : void 0
3247
3253
  };
3248
3254
  }), (a) => `${a.input}-${a.glob}-${a.output}`);
3249
- if (!mergedConfig.output?.sourceMap) if (mergedConfig.mode === "development") mergedConfig.output.sourceMap = true;
3255
+ if (isUndefined(mergedConfig.output?.sourceMap)) if (mergedConfig.mode === "development") mergedConfig.output.sourceMap = true;
3250
3256
  else mergedConfig.output.sourceMap = false;
3251
- if (!mergedConfig.output.minify) if (mergedConfig.mode === "production") mergedConfig.output.minify = true;
3257
+ if (isUndefined(mergedConfig.output?.minify)) if (mergedConfig.mode === "production") mergedConfig.output.minify = true;
3252
3258
  else mergedConfig.output.minify = false;
3253
- if (!mergedConfig.output.artifactsPath) mergedConfig.output.artifactsPath = `.${mergedConfig.framework || "powerlines"}`;
3259
+ if (isUndefined(mergedConfig.output?.artifactsPath)) mergedConfig.output.artifactsPath = `.${mergedConfig.framework || "powerlines"}`;
3254
3260
  if (mergedConfig.output.copy && mergedConfig.output.copy.assets) mergedConfig.output.copy.assets = mergedConfig.output.copy.assets.map((asset) => ({
3255
3261
  ...asset,
3256
3262
  glob: replacePathTokens(this, asset.glob),
@@ -3261,25 +3267,12 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3261
3267
  if (isSetString(mergedConfig.output?.storage) && mergedConfig.output.storage === "virtual" || isSetObject(mergedConfig.output?.storage) && Object.values(mergedConfig.output.storage).every((adapter) => adapter.preset === "virtual")) mergedConfig.output.overwrite = true;
3262
3268
  this.resolvedConfig = mergedConfig;
3263
3269
  this.#configProxy = this.createConfigProxy();
3264
- this.logger.debug({
3270
+ this.logger.info({
3265
3271
  meta: { category: "config" },
3266
- message: `Resolved Powerlines configuration object: \n${this.logConfig(this.resolvedConfig)}`
3272
+ message: `Resolved Powerlines configuration object: \n${formatConfig(this.resolvedConfig)}`
3267
3273
  });
3268
3274
  this.#fs ??= await VirtualFileSystem.create(this);
3269
3275
  }
3270
- logConfig(config) {
3271
- return JSON.stringify({
3272
- ...omit(config, [
3273
- "plugins",
3274
- "initialConfig",
3275
- "userConfig",
3276
- "inlineConfig",
3277
- "pluginConfig",
3278
- "environmentConfig"
3279
- ]),
3280
- plugins: config.plugins ? config.plugins.flatMap((plugin) => toArray(plugin)).map((plugin) => String(isSetString(plugin) ? plugin : isSetObject(plugin) && isSetString(plugin.name) ? plugin.name : Array.isArray(plugin) && isSetString(plugin[0]) ? plugin[0] : "<function-plugin>")) : []
3281
- }, null, 2).replace(/"([^"]+)":/g, "$1:").replace(/: "([^"]+)"/g, ": $1");
3282
- }
3283
3276
  createConfigProxy() {
3284
3277
  return new Proxy(this.resolvedConfig, {
3285
3278
  /**
@@ -3637,7 +3630,7 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
3637
3630
  async setEnvironmentConfig(config) {
3638
3631
  this.logger.debug({
3639
3632
  meta: { category: "config" },
3640
- message: `Updating environment configuration object: \n${this.logConfig(config)}`
3633
+ message: `Updating environment configuration object: \n${formatConfig(config)}`
3641
3634
  });
3642
3635
  this.environmentConfig = config;
3643
3636
  await this.resolveConfig();
@@ -4613,20 +4606,7 @@ var PowerlinesExecution = class PowerlinesExecution {
4613
4606
  });
4614
4607
  context.trace({
4615
4608
  meta: { category: "config" },
4616
- message: `Powerlines configuration after configResolved hook: \n${formatLogMessage({
4617
- ...omit(context.config, [
4618
- "inlineConfig",
4619
- "userConfig",
4620
- "initialConfig",
4621
- "pluginConfig",
4622
- "plugins"
4623
- ]),
4624
- plugins: context.plugins.map((plugin) => plugin.plugin.name),
4625
- inlineConfig: isSetObject(context.config.inlineConfig) ? omit(context.config.inlineConfig, ["plugins"]) : void 0,
4626
- userConfig: isSetObject(context.config.userConfig) ? omit(context.config.userConfig, ["plugins"]) : void 0,
4627
- initialConfig: isSetObject(context.config.initialConfig) ? omit(context.config.initialConfig, ["plugins"]) : void 0,
4628
- pluginConfig: isSetObject(context.config.pluginConfig) ? omit(context.config.pluginConfig, ["plugins"]) : void 0
4629
- })}`
4609
+ message: `Powerlines configuration after configResolved hook: \n${formatConfig(context.config)}`
4630
4610
  });
4631
4611
  if (!context.fs.existsSync(context.cachePath)) await createDirectory(context.cachePath);
4632
4612
  if (!context.fs.existsSync(context.dataPath)) await createDirectory(context.dataPath);