@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
@@ -1,4 +1,4 @@
1
- import { t as PowerlinesBaseContext } from "./base-context-DU0NRHDt.mjs";
1
+ import { t as PowerlinesBaseContext } from "./base-context-Ce9PuQ9z.mjs";
2
2
  import { a as FileSystem } from "./fs-D1nIP45P.mjs";
3
3
  import { n as FileSystemStorageAdapter, t as VirtualStorageAdapter } from "./virtual-CYGZHTDd.mjs";
4
4
  import { i as getTsconfigFilePath } from "./tsconfig-MeFEs21S.mjs";
@@ -12,7 +12,7 @@ import { isString } from "@stryke/type-checks/is-string";
12
12
  import { messageParent } from "jest-worker";
13
13
  import { isSetString } from "@stryke/type-checks/is-set-string";
14
14
  import { uuid } from "@stryke/unique-id/uuid";
15
- import { addPluginHook, createLogger, dedupeHooklist, isDuplicate, isPlugin, isPluginConfig, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn } from "@powerlines/core/plugin-utils";
15
+ import { addPluginHook, createLogger, dedupeHooklist, formatConfig, getPackageJsonOrganization, isDuplicate, isPlugin, isPluginConfig, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn } from "@powerlines/core/plugin-utils";
16
16
  import { colorText } from "@powerlines/core/plugin-utils/logging";
17
17
  import { getEnvPaths } from "@stryke/env/get-env-paths";
18
18
  import { appendPath } from "@stryke/path/append";
@@ -20,9 +20,10 @@ import { replaceExtension, replacePath } from "@stryke/path/replace";
20
20
  import { kebabCase } from "@stryke/string-format/kebab-case";
21
21
  import chalk from "chalk";
22
22
  import defu, { defu as defu$1 } from "defu";
23
+ import { existsSync } from "node:fs";
23
24
  import { joinPaths as joinPaths$1 } from "@stryke/path/join-paths";
24
25
  import { format } from "@powerlines/core/lib/utilities/format";
25
- import { existsSync } from "@stryke/fs/exists";
26
+ import { existsSync as existsSync$1 } from "@stryke/fs/exists";
26
27
  import { getUnique, getUniqueBy } from "@stryke/helpers/get-unique";
27
28
  import { omit } from "@stryke/helpers/omit";
28
29
  import { findFileDotExtensionSafe, findFileExtensionSafe, findFileName, findFilePath, hasFileExtension } from "@stryke/path/file-path-fns";
@@ -38,6 +39,7 @@ import { murmurhash } from "@stryke/hash";
38
39
  import { hashDirectory } from "@stryke/hash/node";
39
40
  import { fetchRequest } from "@stryke/http/fetch";
40
41
  import { isEqual } from "@stryke/path/is-equal";
42
+ import { isUndefined } from "@stryke/type-checks/is-undefined";
41
43
  import { match, tsconfigPathsToRegExp } from "bundle-require";
42
44
  import { resolveCompatibilityDates } from "compatx";
43
45
  import { create } from "flat-cache";
@@ -493,7 +495,7 @@ var VirtualFileSystem = class VirtualFileSystem {
493
495
  static async create(context) {
494
496
  context.debug("Starting virtual file system (VFS) initialization processes...");
495
497
  let result;
496
- if (!context.config.skipCache && existsSync(joinPaths(context.dataPath, "fs.bin"))) {
498
+ if (!context.config.skipCache && existsSync$1(joinPaths(context.dataPath, "fs.bin"))) {
497
499
  const buffer = await readFileBuffer(joinPaths(context.dataPath, "fs.bin"));
498
500
  const fs = new capnp.Message(buffer, false).getRoot(FileSystem);
499
501
  result = new VirtualFileSystem(context, fs);
@@ -527,7 +529,7 @@ var VirtualFileSystem = class VirtualFileSystem {
527
529
  static createSync(context) {
528
530
  context.debug("Starting virtual file system (VFS) initialization processes...");
529
531
  let result;
530
- if (!context.config.skipCache && existsSync(joinPaths(context.dataPath, "fs.bin"))) {
532
+ if (!context.config.skipCache && existsSync$1(joinPaths(context.dataPath, "fs.bin"))) {
531
533
  const buffer = readFileBufferSync(joinPaths(context.dataPath, "fs.bin"));
532
534
  const fs = new capnp.Message(buffer, false).getRoot(FileSystem);
533
535
  result = new VirtualFileSystem(context, fs);
@@ -1940,7 +1942,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1940
1942
  async setInlineConfig(config) {
1941
1943
  this.logger.debug({
1942
1944
  meta: { category: "config" },
1943
- message: `Updating inline configuration object: \n${this.logConfig(config)}`
1945
+ message: `Updating inline configuration object: \n${formatConfig(config)}`
1944
1946
  });
1945
1947
  this.inlineConfig = config;
1946
1948
  await this.resolveConfig();
@@ -1954,7 +1956,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1954
1956
  async setPluginConfig(config) {
1955
1957
  this.logger.debug({
1956
1958
  meta: { category: "config" },
1957
- message: `Updating plugin configuration object: \n${this.logConfig(config)}`
1959
+ message: `Updating plugin configuration object: \n${formatConfig(config)}`
1958
1960
  });
1959
1961
  this.pluginConfig = config;
1960
1962
  await this.resolveConfig();
@@ -1996,7 +1998,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1996
1998
  async setUserConfig(config) {
1997
1999
  this.logger.debug({
1998
2000
  meta: { category: "config" },
1999
- message: `Updating user configuration object: \n${this.logConfig(config)}`
2001
+ message: `Updating user configuration object: \n${formatConfig(config)}`
2000
2002
  });
2001
2003
  this.userConfig = config;
2002
2004
  await this.resolveConfig();
@@ -2033,7 +2035,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2033
2035
  const mergedConfig = this.mergeConfig();
2034
2036
  this.logger.trace({
2035
2037
  meta: { category: "config" },
2036
- 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)}`
2038
+ 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)}`
2037
2039
  });
2038
2040
  mergedConfig.output = defu(mergedConfig.output ?? {}, {
2039
2041
  copy: { assets: [
@@ -2049,14 +2051,17 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2049
2051
  ] },
2050
2052
  dts: true
2051
2053
  });
2052
- if (!mergedConfig.mode) mergedConfig.mode = "production";
2053
- if (!mergedConfig.framework) mergedConfig.framework = "powerlines";
2054
- if (!mergedConfig.projectType) mergedConfig.projectType = "application";
2055
- if (!mergedConfig.platform) mergedConfig.platform = "neutral";
2054
+ if (isUndefined(mergedConfig.mode)) mergedConfig.mode = await this.getDefaultMode();
2055
+ if (isUndefined(mergedConfig.framework)) mergedConfig.framework = "powerlines";
2056
+ if (isUndefined(mergedConfig.platform)) mergedConfig.platform = "neutral";
2056
2057
  mergedConfig.compatibilityDate = resolveCompatibilityDates(mergedConfig.compatibilityDate, "latest");
2058
+ if (!this.packageJson && existsSync(joinPaths(appendPath(mergedConfig.root, mergedConfig.cwd), "package.json")) || !this.projectJson && existsSync(joinPaths(appendPath(mergedConfig.root, mergedConfig.cwd), "project.json"))) {
2059
+ await this.resolvePackageConfigs(mergedConfig.cwd, mergedConfig.root);
2060
+ if (this.packageJson) mergedConfig.organization ??= getPackageJsonOrganization(this.packageJson) || "powerlines";
2061
+ }
2062
+ if (isUndefined(mergedConfig.projectType)) mergedConfig.projectType = this.projectJson?.projectType || "application";
2057
2063
  this.resolvedConfig = mergedConfig;
2058
2064
  this.#configProxy = this.createConfigProxy();
2059
- if (!this.packageJson) await this.resolvePackageConfigs();
2060
2065
  mergedConfig.input = getUniqueInputs(mergedConfig.input);
2061
2066
  if (mergedConfig.name?.startsWith("@") && mergedConfig.name.split("/").filter(Boolean).length > 1) mergedConfig.name = mergedConfig.name.split("/").filter(Boolean)[1];
2062
2067
  mergedConfig.title ??= titleCase(mergedConfig.name);
@@ -2067,18 +2072,18 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2067
2072
  ret.push(plugin);
2068
2073
  return ret;
2069
2074
  }, []);
2070
- if (!mergedConfig.logLevel) if (mergedConfig.mode === "development") mergedConfig.logLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;
2075
+ if (isUndefined(mergedConfig.logLevel)) if (mergedConfig.mode === "development") mergedConfig.logLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;
2071
2076
  else if (mergedConfig.mode === "test") mergedConfig.logLevel = DEFAULT_TEST_LOG_LEVEL;
2072
2077
  else mergedConfig.logLevel = DEFAULT_PRODUCTION_LOG_LEVEL;
2073
2078
  mergedConfig.logLevel = resolveLogLevel(mergedConfig.logLevel);
2074
- if (mergedConfig.tsconfig) mergedConfig.tsconfig = replacePath(replacePathTokens(this, mergedConfig.tsconfig), mergedConfig.cwd);
2079
+ if (isSetString(mergedConfig.tsconfig)) mergedConfig.tsconfig = replacePath(replacePathTokens(this, mergedConfig.tsconfig), mergedConfig.cwd);
2075
2080
  else mergedConfig.tsconfig = getTsconfigFilePath(mergedConfig.cwd, mergedConfig.root);
2076
2081
  mergedConfig.output.format = getUnique(toArray(mergedConfig.output?.format ?? (mergedConfig.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
2077
- if (mergedConfig.output.path) mergedConfig.output.path = appendPath(replacePathTokens(this, mergedConfig.output.path), mergedConfig.cwd);
2082
+ if (isSetString(mergedConfig.output.path)) mergedConfig.output.path = appendPath(replacePathTokens(this, mergedConfig.output.path), mergedConfig.cwd);
2078
2083
  else mergedConfig.output.path = appendPath(joinPaths(mergedConfig.root, "dist"), mergedConfig.cwd);
2079
2084
  mergedConfig.output.copy ??= {};
2080
- 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;
2081
- else mergedConfig.output.copy.path = appendPath(replacePathTokens(this, mergedConfig.output.copy.path || joinPaths("dist", mergedConfig.root)), mergedConfig.cwd);
2085
+ 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;
2086
+ else mergedConfig.output.copy.path = appendPath(replacePathTokens(this, isSetString(mergedConfig.output.copy.path) ? mergedConfig.output.copy.path : joinPaths("dist", mergedConfig.root)), mergedConfig.cwd);
2082
2087
  if (mergedConfig.output.types !== false) mergedConfig.output.types = appendPath(replacePathTokens(this, mergedConfig.output.types || joinPaths(mergedConfig.root, `${mergedConfig.framework ?? "powerlines"}.d.ts`)), mergedConfig.cwd);
2083
2088
  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) => {
2084
2089
  return {
@@ -2088,11 +2093,11 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2088
2093
  ignore: isSetObject(asset) && asset.ignore ? toArray(asset.ignore) : void 0
2089
2094
  };
2090
2095
  }), (a) => `${a.input}-${a.glob}-${a.output}`);
2091
- if (!mergedConfig.output?.sourceMap) if (mergedConfig.mode === "development") mergedConfig.output.sourceMap = true;
2096
+ if (isUndefined(mergedConfig.output?.sourceMap)) if (mergedConfig.mode === "development") mergedConfig.output.sourceMap = true;
2092
2097
  else mergedConfig.output.sourceMap = false;
2093
- if (!mergedConfig.output.minify) if (mergedConfig.mode === "production") mergedConfig.output.minify = true;
2098
+ if (isUndefined(mergedConfig.output?.minify)) if (mergedConfig.mode === "production") mergedConfig.output.minify = true;
2094
2099
  else mergedConfig.output.minify = false;
2095
- if (!mergedConfig.output.artifactsPath) mergedConfig.output.artifactsPath = `.${mergedConfig.framework || "powerlines"}`;
2100
+ if (isUndefined(mergedConfig.output?.artifactsPath)) mergedConfig.output.artifactsPath = `.${mergedConfig.framework || "powerlines"}`;
2096
2101
  if (mergedConfig.output.copy && mergedConfig.output.copy.assets) mergedConfig.output.copy.assets = mergedConfig.output.copy.assets.map((asset) => ({
2097
2102
  ...asset,
2098
2103
  glob: replacePathTokens(this, asset.glob),
@@ -2103,25 +2108,12 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2103
2108
  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;
2104
2109
  this.resolvedConfig = mergedConfig;
2105
2110
  this.#configProxy = this.createConfigProxy();
2106
- this.logger.debug({
2111
+ this.logger.info({
2107
2112
  meta: { category: "config" },
2108
- message: `Resolved Powerlines configuration object: \n${this.logConfig(this.resolvedConfig)}`
2113
+ message: `Resolved Powerlines configuration object: \n${formatConfig(this.resolvedConfig)}`
2109
2114
  });
2110
2115
  this.#fs ??= await VirtualFileSystem.create(this);
2111
2116
  }
2112
- logConfig(config) {
2113
- return JSON.stringify({
2114
- ...omit(config, [
2115
- "plugins",
2116
- "initialConfig",
2117
- "userConfig",
2118
- "inlineConfig",
2119
- "pluginConfig",
2120
- "environmentConfig"
2121
- ]),
2122
- 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>")) : []
2123
- }, null, 2).replace(/"([^"]+)":/g, "$1:").replace(/: "([^"]+)"/g, ": $1");
2124
- }
2125
2117
  createConfigProxy() {
2126
2118
  return new Proxy(this.resolvedConfig, {
2127
2119
  /**
@@ -2479,7 +2471,7 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
2479
2471
  async setEnvironmentConfig(config) {
2480
2472
  this.logger.debug({
2481
2473
  meta: { category: "config" },
2482
- message: `Updating environment configuration object: \n${this.logConfig(config)}`
2474
+ message: `Updating environment configuration object: \n${formatConfig(config)}`
2483
2475
  });
2484
2476
  this.environmentConfig = config;
2485
2477
  await this.resolveConfig();
@@ -2692,7 +2684,7 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
2692
2684
  await super.setInlineConfig(config);
2693
2685
  if (this.inlineConfig.command === "new") {
2694
2686
  const workspacePackageJsonPath = joinPaths(this.config.cwd, "package.json");
2695
- if (!existsSync(workspacePackageJsonPath)) throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
2687
+ if (!existsSync$1(workspacePackageJsonPath)) throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
2696
2688
  this.packageJson = await readJsonFile(workspacePackageJsonPath);
2697
2689
  }
2698
2690
  }
@@ -2849,4 +2841,4 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
2849
2841
 
2850
2842
  //#endregion
2851
2843
  export { mergeConfigs as a, callHook as i, PowerlinesEnvironmentContext as n, PowerlinesContext as o, createPluginContext as r, writeMetaFile as s, PowerlinesExecutionContext as t };
2852
- //# sourceMappingURL=execution-context-Bb5pfsyN.mjs.map
2844
+ //# sourceMappingURL=execution-context-DUtt6PWE.mjs.map