@powerlines/engine 0.43.31 → 0.44.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/_internal/worker.cjs +187 -169
  2. package/dist/_internal/worker.d.cts.map +1 -1
  3. package/dist/_internal/worker.d.mts.map +1 -1
  4. package/dist/_internal/worker.mjs +188 -170
  5. package/dist/_internal/worker.mjs.map +1 -1
  6. package/dist/api.cjs +6 -5
  7. package/dist/api.d.cts.map +1 -1
  8. package/dist/api.d.mts.map +1 -1
  9. package/dist/api.mjs +4 -3
  10. package/dist/api.mjs.map +1 -1
  11. package/dist/{base-context-CPoqO4io.cjs → base-context-DkGTyGX0.cjs} +34 -44
  12. package/dist/{base-context-SmQ6OfXm.mjs → base-context-Dv5OTHxZ.mjs} +35 -45
  13. package/dist/base-context-Dv5OTHxZ.mjs.map +1 -0
  14. package/dist/context/index.cjs +3 -3
  15. package/dist/context/index.d.cts +40 -36
  16. package/dist/context/index.d.cts.map +1 -1
  17. package/dist/context/index.d.mts +40 -36
  18. package/dist/context/index.d.mts.map +1 -1
  19. package/dist/context/index.mjs +3 -3
  20. package/dist/{engine-context-CEu21ZZf.cjs → engine-context-CDSR7PHF.cjs} +1 -1
  21. package/dist/{engine-context-D7CWyTsr.mjs → engine-context-CytME-Ht.mjs} +2 -2
  22. package/dist/{engine-context-D7CWyTsr.mjs.map → engine-context-CytME-Ht.mjs.map} +1 -1
  23. package/dist/{execution-context-DsT6s1du.cjs → execution-context-B-CVP76S.cjs} +148 -105
  24. package/dist/{execution-context-C_7IC8er.mjs → execution-context-F7RyGqff.mjs} +150 -107
  25. package/dist/execution-context-F7RyGqff.mjs.map +1 -0
  26. package/dist/index.cjs +8 -12
  27. package/dist/index.mjs +8 -12
  28. package/dist/index.mjs.map +1 -1
  29. package/package.json +3 -3
  30. package/dist/base-context-SmQ6OfXm.mjs.map +0 -1
  31. package/dist/execution-context-C_7IC8er.mjs.map +0 -1
@@ -1,27 +1,25 @@
1
- import { t as PowerlinesBaseContext } from "./base-context-SmQ6OfXm.mjs";
1
+ import { t as PowerlinesBaseContext } from "./base-context-Dv5OTHxZ.mjs";
2
2
  import { a as FileSystem } from "./fs-D1nIP45P.mjs";
3
3
  import { n as FileSystemStorageAdapter, t as VirtualStorageAdapter } from "./virtual-CUgOdyIa.mjs";
4
4
  import { i as getTsconfigFilePath } from "./tsconfig-Cstsoprg.mjs";
5
- import { CACHE_HASH_LENGTH, DEFAULT_ENVIRONMENT, GLOBAL_ENVIRONMENT, PLUGIN_NON_HOOK_FIELDS, ROOT_HASH_LENGTH } from "@powerlines/core/constants";
5
+ 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";
6
6
  import { getResolutionCombinations, resolve, resolvePackage, resolveSync } from "@stryke/fs/resolve";
7
7
  import { joinPaths } from "@stryke/path/join";
8
- import { LogLevelLabel } from "@storm-software/config-tools/types";
9
8
  import { isSet } from "@stryke/type-checks/is-set";
10
9
  import { isSetObject } from "@stryke/type-checks/is-set-object";
11
10
  import { isString } from "@stryke/type-checks/is-string";
12
11
  import { toArray } from "@stryke/convert/to-array";
13
12
  import { isSetString } from "@stryke/type-checks/is-set-string";
14
13
  import { uuid } from "@stryke/unique-id/uuid";
15
- import { colorText } from "@powerlines/core/lib/logger";
14
+ import { addPluginHook, createLogger, dedupeHooklist, isDuplicate, isPlugin, isPluginConfig, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens, withCustomLogger, withLogger } from "@powerlines/core/plugin-utils";
15
+ import { colorText } from "@powerlines/core/plugin-utils/logging";
16
16
  import { isEqual } from "@stryke/path/is-equal";
17
17
  import { replaceExtension, replacePath } from "@stryke/path/replace";
18
- import { isNull } from "@stryke/type-checks/is-null";
19
18
  import chalk from "chalk";
20
19
  import defu, { createDefu, defu as defu$1 } from "defu";
21
20
  import { joinPaths as joinPaths$1 } from "@stryke/path/join-paths";
22
21
  import { titleCase } from "@stryke/string-format/title-case";
23
22
  import { format } from "@powerlines/core/lib/utilities/format";
24
- import { addPluginHook, dedupeHooklist, isDuplicate, isPlugin, isPluginConfig, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens } from "@powerlines/core/plugin-utils";
25
23
  import { existsSync } from "@stryke/fs/exists";
26
24
  import { getUnique, getUniqueBy } from "@stryke/helpers/get-unique";
27
25
  import { omit } from "@stryke/helpers/omit";
@@ -30,7 +28,6 @@ import { findFileDotExtensionSafe, findFileExtensionSafe, findFileName, findFile
30
28
  import { isParentPath } from "@stryke/path/is-parent-path";
31
29
  import { isFunction } from "@stryke/type-checks/is-function";
32
30
  import { isObject } from "@stryke/type-checks/is-object";
33
- import { createLog as createLog$1 } from "@powerlines/core";
34
31
  import { readJsonFile } from "@stryke/fs/json";
35
32
  import { deepClone } from "@stryke/helpers/deep-clone";
36
33
  import { getUniqueInputs, isTypeDefinition, resolveInputsSync } from "@powerlines/core/lib/entry";
@@ -45,6 +42,7 @@ import { create } from "flat-cache";
45
42
  import { parse } from "oxc-parser";
46
43
  import { Agent, Response, interceptors, setGlobalDispatcher } from "undici";
47
44
  import "@stryke/fs/remove-file";
45
+ import { LogCategories } from "@powerlines/core";
48
46
  import * as capnp from "@stryke/capnp";
49
47
  import { readFileBuffer, readFileBufferSync, writeFileBuffer } from "@stryke/fs/buffer";
50
48
  import { correctPath, stripStars } from "@stryke/path/correct-path";
@@ -145,6 +143,40 @@ async function writeMetaFile(context) {
145
143
  await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
146
144
  }
147
145
 
146
+ //#endregion
147
+ //#region src/_internal/ipc/send.ts
148
+ function sendWriteLogMessage(context, type, message) {
149
+ const meta = {
150
+ ...isSetObject(message) && isSetObject(message.meta) ? message.meta : {},
151
+ ...context.logger.options
152
+ };
153
+ process.send?.({
154
+ id: uuid(),
155
+ type: "write-log",
156
+ executionId: meta.executionId ?? context.config.executionId,
157
+ executionIndex: meta.executionIndex ?? context.config.executionIndex,
158
+ environment: meta.environment,
159
+ timestamp: Date.now(),
160
+ payload: {
161
+ meta: {
162
+ type,
163
+ category: meta.category ?? LogCategories.GENERAL,
164
+ logId: meta.logId ?? uuid(),
165
+ timestamp: meta.timestamp ?? Date.now(),
166
+ name: meta.name ?? context.config.name,
167
+ executionId: meta.executionId ?? context.config.executionId,
168
+ executionIndex: meta.executionIndex ?? context.config.executionIndex,
169
+ command: meta.command ?? context.config.command,
170
+ hook: meta.hook,
171
+ environment: meta.environment,
172
+ plugin: meta.plugin,
173
+ source: meta.source
174
+ },
175
+ message: isSetString(message) ? message : message.message
176
+ }
177
+ });
178
+ }
179
+
148
180
  //#endregion
149
181
  //#region src/_internal/helpers/constants.ts
150
182
  const DEFAULT_EXTENSIONS = [
@@ -256,9 +288,9 @@ var VirtualFileSystem = class VirtualFileSystem {
256
288
  */
257
289
  #context;
258
290
  /**
259
- * The file system's logging function.
291
+ * The file system's logger client utility.
260
292
  */
261
- #log;
293
+ #logger;
262
294
  /**
263
295
  * Normalizes a given module id by resolving it against the built-ins path.
264
296
  *
@@ -472,7 +504,7 @@ var VirtualFileSystem = class VirtualFileSystem {
472
504
  }
473
505
  }));
474
506
  } else result = new VirtualFileSystem(context, new capnp.Message().initRoot(FileSystem));
475
- result.#log(LogLevelLabel.DEBUG, "Successfully completed virtual file system (VFS) initialization.");
507
+ result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
476
508
  return result;
477
509
  }
478
510
  /**
@@ -506,7 +538,7 @@ var VirtualFileSystem = class VirtualFileSystem {
506
538
  }
507
539
  });
508
540
  } else result = new VirtualFileSystem(context, new capnp.Message().initRoot(FileSystem));
509
- result.#log(LogLevelLabel.DEBUG, "Successfully completed virtual file system (VFS) initialization.");
541
+ result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
510
542
  return result;
511
543
  }
512
544
  /**
@@ -640,7 +672,10 @@ var VirtualFileSystem = class VirtualFileSystem {
640
672
  return ret;
641
673
  }, {});
642
674
  }
643
- this.#log = context.extendLog("VFS");
675
+ this.#logger = context.extendLogger({
676
+ source: "VFS",
677
+ category: "fs"
678
+ });
644
679
  }
645
680
  /**
646
681
  * Asynchronously checks if a file exists in the virtual file system (VFS).
@@ -767,7 +802,7 @@ var VirtualFileSystem = class VirtualFileSystem {
767
802
  listSync(path) {
768
803
  let resolvedPath = path;
769
804
  if (resolvedPath.includes("*")) {
770
- this.#log(LogLevelLabel.WARN, `Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
805
+ this.#logger.warn(`Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
771
806
  resolvedPath = stripStars(resolvedPath);
772
807
  }
773
808
  return getUnique(this.#getStorages(resolvedPath, true).map((storage) => storage.adapter.listSync(storage.relativeBase ? storage.base ? appendPath(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)).flat().filter(Boolean));
@@ -781,7 +816,7 @@ var VirtualFileSystem = class VirtualFileSystem {
781
816
  async list(path) {
782
817
  let resolvedPath = path;
783
818
  if (resolvedPath.includes("*")) {
784
- this.#log(LogLevelLabel.WARN, `Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
819
+ this.#logger.warn(`Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
785
820
  resolvedPath = stripStars(resolvedPath);
786
821
  }
787
822
  return getUnique((await Promise.all(this.#getStorages(resolvedPath, true).map(async (storage) => storage.adapter.list(storage.relativeBase ? storage.base ? appendPath(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)))).flat().filter(Boolean));
@@ -793,7 +828,7 @@ var VirtualFileSystem = class VirtualFileSystem {
793
828
  */
794
829
  async remove(path) {
795
830
  const normalizedPath = this.#normalizePath(path);
796
- this.#log(LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
831
+ this.#logger.trace(`Removing file: ${normalizedPath}`);
797
832
  const { relativeKey, adapter } = this.#getStorage(normalizedPath);
798
833
  if (hasFileExtension(normalizedPath)) await adapter.remove(relativeKey);
799
834
  else await adapter.clear(relativeKey);
@@ -811,7 +846,7 @@ var VirtualFileSystem = class VirtualFileSystem {
811
846
  */
812
847
  removeSync(path) {
813
848
  const normalizedPath = this.#normalizePath(path);
814
- this.#log(LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
849
+ this.#logger.trace(`Removing file: ${normalizedPath}`);
815
850
  const { relativeKey, adapter } = this.#getStorage(normalizedPath);
816
851
  if (hasFileExtension(normalizedPath)) adapter.removeSync(relativeKey);
817
852
  else adapter.clearSync(relativeKey);
@@ -957,7 +992,7 @@ var VirtualFileSystem = class VirtualFileSystem {
957
992
  const filePath = await this.resolve(path, void 0, { isFile: true });
958
993
  if (!filePath || !this.existsSync(filePath)) return;
959
994
  const { adapter } = this.#getStorage(filePath);
960
- this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
995
+ this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);
961
996
  return await adapter.get(filePath) ?? void 0;
962
997
  }
963
998
  /**
@@ -970,7 +1005,7 @@ var VirtualFileSystem = class VirtualFileSystem {
970
1005
  const filePath = this.resolveSync(path, void 0, { isFile: true });
971
1006
  if (!filePath || !this.existsSync(filePath)) return;
972
1007
  const { adapter } = this.#getStorage(filePath);
973
- this.#log(LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
1008
+ this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);
974
1009
  return adapter.getSync(filePath) ?? void 0;
975
1010
  }
976
1011
  /**
@@ -985,15 +1020,15 @@ var VirtualFileSystem = class VirtualFileSystem {
985
1020
  const meta = options.meta ?? {};
986
1021
  const resolvedPath = await this.resolve(this.#normalizePath(path)) || path;
987
1022
  const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
988
- this.#log(LogLevelLabel.TRACE, `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
1023
+ this.#logger.trace(`Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
989
1024
  let code = data;
990
1025
  try {
991
1026
  if (!options.skipFormat) code = await format(this.#context, resolvedPath, data);
992
1027
  } catch (err) {
993
- if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#log(LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
1028
+ if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#logger.warn(`Failed to format file ${resolvedPath} before writing: ${err.message}`);
994
1029
  code = data;
995
1030
  }
996
- this.#log(LogLevelLabel.TRACE, `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1031
+ this.#logger.trace(`Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
997
1032
  const id = this.#normalizeId(meta.id || resolvedPath);
998
1033
  this.metadata[id] = {
999
1034
  type: "normal",
@@ -1016,7 +1051,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1016
1051
  const meta = options.meta ?? {};
1017
1052
  const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;
1018
1053
  const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
1019
- this.#log(LogLevelLabel.TRACE, `Writing ${resolvedPath} file to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
1054
+ this.#logger.trace(`Writing ${resolvedPath} file to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
1020
1055
  const id = this.#normalizeId(meta.id || resolvedPath);
1021
1056
  this.metadata[id] = {
1022
1057
  type: "normal",
@@ -1180,7 +1215,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1180
1215
  async dispose() {
1181
1216
  if (!this.#isDisposed) {
1182
1217
  this.#isDisposed = true;
1183
- this.#log(LogLevelLabel.DEBUG, "Disposing virtual file system...");
1218
+ this.#logger.debug("Disposing virtual file system...");
1184
1219
  await this.remove(joinPaths(this.#context.dataPath, "fs.bin"));
1185
1220
  const message = new capnp.Message();
1186
1221
  const fs = message.initRoot(FileSystem);
@@ -1215,9 +1250,15 @@ var VirtualFileSystem = class VirtualFileSystem {
1215
1250
  await writeFileBuffer(joinPaths(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
1216
1251
  if (!this.#context.config.skipCache) this.resolverCache.save(true);
1217
1252
  await Promise.all(this.#getStorages().map(async (storage) => storage.adapter.dispose()));
1218
- this.#log(LogLevelLabel.TRACE, "Virtual file system has been disposed.");
1253
+ this.#logger.trace("Virtual file system has been disposed.");
1219
1254
  }
1220
1255
  }
1256
+ /**
1257
+ * Asynchronously disposes of the virtual file system (VFS) by saving its state to disk.
1258
+ *
1259
+ * @remarks
1260
+ * This method is automatically called when the VFS instance is used within a `using` block, or can be manually invoked to ensure that the VFS state is saved and resources are cleaned up properly.
1261
+ */
1221
1262
  async [Symbol.asyncDispose]() {
1222
1263
  return this.dispose();
1223
1264
  }
@@ -1366,7 +1407,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1366
1407
  buildId: this.#buildId,
1367
1408
  releaseId: this.#releaseId,
1368
1409
  checksum: this.#checksum,
1369
- timestamp: this.timestamp.getTime(),
1410
+ timestamp: this.timestamp,
1370
1411
  rootHash: murmurhash({
1371
1412
  workspaceRoot: this.options?.cwd,
1372
1413
  root: this.config?.root
@@ -1470,6 +1511,18 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1470
1511
  }, {}) : this.config.resolve.alias : {});
1471
1512
  }
1472
1513
  /**
1514
+ * The logger instance for the context, which can be used to create log messages with consistent formatting and metadata. This logger is extended by plugin contexts to include additional metadata such as the plugin name and category, which can be used to filter and format log messages in a more granular way.
1515
+ */
1516
+ get logger() {
1517
+ const options = {
1518
+ ...this.config,
1519
+ ...this.options
1520
+ };
1521
+ const logger = withLogger(createLogger(this.config.name, options), createLogger(this.config.name, options, (type, message) => sendWriteLogMessage(this, type, message)));
1522
+ if (this.config.customLogger) return withCustomLogger(logger, this.config.customLogger);
1523
+ return logger;
1524
+ }
1525
+ /**
1473
1526
  * Gets the parser cache.
1474
1527
  */
1475
1528
  get parserCache() {
@@ -1566,6 +1619,9 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1566
1619
  headers: cached.headers
1567
1620
  });
1568
1621
  }
1622
+ const logger = this.extendLogger({ category: "network" });
1623
+ const startTime = Date.now();
1624
+ logger.trace(`Sending fetch request (${options.method?.toUpperCase() || "GET"}): ${input.toString()}`);
1569
1625
  const response = await fetchRequest(input, {
1570
1626
  timeout: 12e3,
1571
1627
  ...options
@@ -1579,6 +1635,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1579
1635
  if (!this.config.skipCache && !options.skipCache) try {
1580
1636
  this.requestCache.set(cacheKey, result);
1581
1637
  } catch {}
1638
+ logger.trace(`Fetch request (${options.method?.toUpperCase() || "GET"}) completed in ${Date.now() - startTime}ms: ${input.toString()} - ${response.status} / ${response.statusText} \n - Response Headers: ${JSON.stringify(result.headers)}\n - Response Body: ${typeof result.body === "string" ? result.body.length > 1e3 ? `${result.body.slice(0, 1e3)}... (truncated, total length: ${result.body.length})` : result.body : "[Non-string body]"}`);
1582
1639
  return new Response(result.body, {
1583
1640
  status: result.status,
1584
1641
  statusText: result.statusText,
@@ -1933,6 +1990,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1933
1990
  */
1934
1991
  async init(options = {}) {
1935
1992
  await super.init(options);
1993
+ this.options.executionId = options.executionId ?? this.options.executionId;
1936
1994
  this.options.executionIndex = options.executionIndex ?? this.options.executionIndex ?? 0;
1937
1995
  const projectJsonPath = joinPaths(this.options.cwd, this.options.root, "project.json");
1938
1996
  if (existsSync(projectJsonPath)) this.projectJson = await readJsonFile(projectJsonPath);
@@ -1953,6 +2011,13 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1953
2011
  * Initialize the context with the provided configuration options
1954
2012
  */
1955
2013
  async innerSetup() {
2014
+ const logger = this.extendLogger({ category: "config" });
2015
+ logger.debug(`Pre-setup Powerlines configuration object: \n${JSON.stringify({
2016
+ ...omit(this.config, ["plugins"]),
2017
+ userConfig: this.config.userConfig ? omit(this.config.userConfig, ["plugins"]) : {},
2018
+ inlineConfig: this.config.inlineConfig ? omit(this.config.inlineConfig, ["plugins"]) : {},
2019
+ pluginConfig: this.config.pluginConfig ? omit(this.config.pluginConfig, ["plugins"]) : {}
2020
+ }, null, 2)}`);
1956
2021
  if (!this.inputOptions.mode && !this.config.userConfig?.mode && !this.config.inlineConfig?.mode && !this.config.pluginConfig?.mode) {
1957
2022
  this.options.mode = "production";
1958
2023
  this.config.mode = "production";
@@ -1962,10 +2027,6 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1962
2027
  this.config.framework = "powerlines";
1963
2028
  }
1964
2029
  this.resolvedConfig.compatibilityDate = resolveCompatibilityDates(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
1965
- this.logger = {
1966
- log: this.createLog(this.config.name),
1967
- level: isNull(this.logLevel) ? "silent" : this.logLevel
1968
- };
1969
2030
  this.config.input = getUniqueInputs(this.config.input);
1970
2031
  if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
1971
2032
  this.config.title ??= titleCase(this.config.name);
@@ -1978,11 +2039,12 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
1978
2039
  ret.push(plugin);
1979
2040
  return ret;
1980
2041
  }, []);
1981
- if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = "debug";
1982
- else this.config.logLevel = "info";
1983
- if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = getTsconfigFilePath(this.options.cwd, this.options.root);
2042
+ if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;
2043
+ else if (this.config.mode === "test") this.config.logLevel = DEFAULT_TEST_LOG_LEVEL;
2044
+ else this.config.logLevel = DEFAULT_PRODUCTION_LOG_LEVEL;
2045
+ if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = getTsconfigFilePath(this.config.cwd, this.config.root);
1984
2046
  else if (this.config.tsconfig) this.config.tsconfig = replacePath(replacePathTokens(this, this.config.tsconfig), this.config.cwd);
1985
- this.resolvedConfig.output = defu(this.resolvedConfig.output ?? {}, {
2047
+ this.resolvedConfig.output = defu(this.config.output ?? {}, {
1986
2048
  path: joinPaths(this.config.root, "dist"),
1987
2049
  copy: { assets: [
1988
2050
  { glob: "LICENSE" },
@@ -2027,6 +2089,12 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2027
2089
  }));
2028
2090
  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;
2029
2091
  this.#fs ??= await VirtualFileSystem.create(this);
2092
+ logger.debug(`Post-setup Powerlines configuration object: \n${JSON.stringify({
2093
+ ...omit(this.config, ["plugins"]),
2094
+ userConfig: this.config.userConfig ? omit(this.config.userConfig, ["plugins"]) : {},
2095
+ inlineConfig: this.config.inlineConfig ? omit(this.config.inlineConfig, ["plugins"]) : {},
2096
+ pluginConfig: this.config.pluginConfig ? omit(this.config.pluginConfig, ["plugins"]) : {}
2097
+ }, null, 2)}`);
2030
2098
  }
2031
2099
  };
2032
2100
 
@@ -2076,7 +2144,7 @@ function mergeConfigs(currentResult, previousResults) {
2076
2144
  async function callHook(context, key, options, ...args) {
2077
2145
  const hooks = context.selectHooks(key, options);
2078
2146
  if (hooks.length > 0) {
2079
- context.debug(` 🧩 Calling ${hooks.length} ${chalk.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)} plugin hook${hooks.length > 1 ? "s" : ""}:\n${hooks.map((hook, index) => ` ${index + 1}. ${colorText(hook.plugin.name)}`).join("\n")}`);
2147
+ context.extendLogger({ category: "hooks" }).debug(` 🧩 Calling ${hooks.length} ${chalk.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)} plugin hook${hooks.length > 1 ? "s" : ""}:\n${hooks.map((hook, index) => ` ${index + 1}. ${colorText(hook.plugin.name)}`).join("\n")}`);
2080
2148
  const invokeHook = async (hook, hookArgs) => {
2081
2149
  return Reflect.apply(hook.handler, hook.context, hookArgs);
2082
2150
  };
@@ -2176,7 +2244,7 @@ function createPluginContext(pluginId, plugin, environment) {
2176
2244
  const normalizeMessage = (message) => {
2177
2245
  return isString(message) ? message : message.message;
2178
2246
  };
2179
- const log = environment.extendLog(pluginId, plugin.name.replaceAll(":", " - "));
2247
+ const logger = environment.extendLogger({ plugin: plugin.name.replaceAll(":", " - ") });
2180
2248
  const callHookFn = async (hook, options, ...args) => {
2181
2249
  return environment.$$internal.api.callHook(hook, {
2182
2250
  sequential: true,
@@ -2195,24 +2263,24 @@ function createPluginContext(pluginId, plugin, environment) {
2195
2263
  meta
2196
2264
  };
2197
2265
  if (prop === "id") return pluginId;
2198
- if (prop === "log" || prop === "logger") return log;
2266
+ if (prop === "logger") return logger;
2199
2267
  if (prop === "fatal") return (message) => {
2200
- log(LogLevelLabel.FATAL, normalizeMessage(message));
2268
+ logger.error(normalizeMessage(message));
2201
2269
  };
2202
2270
  if (prop === "error") return (message) => {
2203
- log(LogLevelLabel.ERROR, normalizeMessage(message));
2271
+ logger.error(normalizeMessage(message));
2204
2272
  };
2205
2273
  if (prop === "warn") return (message) => {
2206
- log(LogLevelLabel.WARN, normalizeMessage(message));
2274
+ logger.warn(normalizeMessage(message));
2207
2275
  };
2208
2276
  if (prop === "info") return (message) => {
2209
- log(LogLevelLabel.INFO, normalizeMessage(message));
2277
+ logger.info(normalizeMessage(message));
2210
2278
  };
2211
2279
  if (prop === "debug") return (message) => {
2212
- log(LogLevelLabel.DEBUG, normalizeMessage(message));
2280
+ logger.debug(normalizeMessage(message));
2213
2281
  };
2214
2282
  if (prop === "trace") return (message) => {
2215
- log(LogLevelLabel.TRACE, normalizeMessage(message));
2283
+ logger.trace(normalizeMessage(message));
2216
2284
  };
2217
2285
  return environment[prop];
2218
2286
  },
@@ -2231,7 +2299,7 @@ function createPluginContext(pluginId, plugin, environment) {
2231
2299
  "addPlugin",
2232
2300
  "selectHooks"
2233
2301
  ].includes(prop)) {
2234
- log(LogLevelLabel.WARN, `Cannot set read-only property "${String(prop)}"`);
2302
+ logger.warn(`Cannot set the read-only "${String(prop)}" property`);
2235
2303
  return false;
2236
2304
  }
2237
2305
  environment[prop] = value;
@@ -2285,50 +2353,26 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
2285
2353
  /**
2286
2354
  * Create a new logger instance
2287
2355
  *
2288
- * @param source - The source name to use for the logger instance, which can be used to identify the origin of log messages in the logs for better traceability. This is typically the name of the plugin or module that is creating the logger instance.
2289
- * @returns A logger function
2290
- */
2291
- createLog(source = null) {
2292
- return (level, ...args) => {
2293
- process.send?.({
2294
- id: uuid(),
2295
- type: "write-log",
2296
- executionId: this.options.executionId,
2297
- executionIndex: this.options.executionIndex,
2298
- timestamp: Date.now(),
2299
- payload: {
2300
- level,
2301
- source,
2302
- environment: this.environment?.name,
2303
- args
2304
- }
2305
- });
2306
- };
2356
+ * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
2357
+ * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
2358
+ */
2359
+ createLogger(options, callback) {
2360
+ return super.createLogger({
2361
+ ...options,
2362
+ environment: this.environment?.name
2363
+ }, callback);
2307
2364
  }
2308
2365
  /**
2309
- * Extend the current logger instance with a new name
2310
- *
2311
- * @param source - The name of the source to use for the extended logger instance
2312
- * @param plugin - An optional plugin name to use for the extended logger instance, which can be used to identify the origin of log messages in the logs for better traceability. This is typically the name of the plugin or module that is creating the logger instance.
2313
- * @returns A logger function
2314
- */
2315
- extendLog(source, plugin) {
2316
- return (level, ...args) => {
2317
- process.send?.({
2318
- id: uuid(),
2319
- type: "write-log",
2320
- executionId: this.options.executionId,
2321
- executionIndex: this.options.executionIndex,
2322
- timestamp: Date.now(),
2323
- payload: {
2324
- level,
2325
- source,
2326
- plugin,
2327
- environment: this.environment?.name,
2328
- args
2329
- }
2330
- });
2331
- };
2366
+ * Extend the base logger with additional configuration options
2367
+ *
2368
+ * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
2369
+ * @returns A new logger client instance that extends the base logger with the provided configuration options.
2370
+ */
2371
+ extendLogger(options) {
2372
+ return super.extendLogger({
2373
+ ...options,
2374
+ environment: this.environment?.name
2375
+ });
2332
2376
  }
2333
2377
  /**
2334
2378
  * Creates a clone of the current context with the same configuration and workspace settings. This can be useful for running multiple builds in parallel or for creating isolated contexts for different parts of the build process.
@@ -2514,29 +2558,28 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
2514
2558
  /**
2515
2559
  * Create a new logger instance
2516
2560
  *
2517
- * @param source - The source name to use for the logger instance, which can be used to identify the origin of log messages in the logs for better traceability. This is typically the name of the plugin or module that is creating the logger instance.
2518
- * @returns A logger function
2561
+ * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
2562
+ * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
2519
2563
  */
2520
- createLog(source = null) {
2521
- const logger = createLog$1(source, {
2522
- ...this.config,
2523
- logLevel: isNull(this.config.logLevel) ? "silent" : this.config.logLevel
2564
+ createLogger(options, callback) {
2565
+ return super.createLogger({
2566
+ ...options,
2567
+ executionId: this.id,
2568
+ executionIndex: this.options.executionIndex
2569
+ }, callback);
2570
+ }
2571
+ /**
2572
+ * Extend the base logger with additional configuration options
2573
+ *
2574
+ * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
2575
+ * @returns A new logger client instance that extends the base logger with the provided configuration options.
2576
+ */
2577
+ extendLogger(options) {
2578
+ return super.extendLogger({
2579
+ ...options,
2580
+ executionId: this.id,
2581
+ executionIndex: this.options.executionIndex
2524
2582
  });
2525
- return (level, ...args) => {
2526
- logger(level, ...args);
2527
- process.send?.({
2528
- id: uuid(),
2529
- type: "write-log",
2530
- executionId: this.id,
2531
- executionIndex: this.options.executionIndex,
2532
- timestamp: Date.now(),
2533
- payload: {
2534
- source,
2535
- level,
2536
- args
2537
- }
2538
- });
2539
- };
2540
2583
  }
2541
2584
  /**
2542
2585
  * Creates a clone of the current context with the same configuration and workspace settings. This can be useful for running multiple builds in parallel or for creating isolated contexts for different parts of the build process.
@@ -2640,4 +2683,4 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
2640
2683
 
2641
2684
  //#endregion
2642
2685
  export { mergeConfigs as a, callHook as i, PowerlinesEnvironmentContext as n, PowerlinesContext as o, createPluginContext as r, writeMetaFile as s, PowerlinesExecutionContext as t };
2643
- //# sourceMappingURL=execution-context-C_7IC8er.mjs.map
2686
+ //# sourceMappingURL=execution-context-F7RyGqff.mjs.map