@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,22 +1,21 @@
1
1
  const require_chunk = require('./chunk-C0xms8kb.cjs');
2
- const require_base_context = require('./base-context-CPoqO4io.cjs');
2
+ const require_base_context = require('./base-context-DkGTyGX0.cjs');
3
3
  const require_fs = require('./fs-XogSgMqT.cjs');
4
4
  const require_virtual = require('./virtual-1hYa9zCy.cjs');
5
5
  const require_tsconfig = require('./tsconfig-DeyWQC2N.cjs');
6
6
  let _powerlines_core_constants = require("@powerlines/core/constants");
7
7
  let _stryke_fs_resolve = require("@stryke/fs/resolve");
8
8
  let _stryke_path_join = require("@stryke/path/join");
9
- let _storm_software_config_tools_types = require("@storm-software/config-tools/types");
10
9
  let _stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
11
10
  let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
12
11
  let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
13
12
  let _stryke_convert_to_array = require("@stryke/convert/to-array");
14
13
  let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
15
14
  let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
16
- let _powerlines_core_lib_logger = require("@powerlines/core/lib/logger");
15
+ let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
16
+ let _powerlines_core_plugin_utils_logging = require("@powerlines/core/plugin-utils/logging");
17
17
  let _stryke_path_is_equal = require("@stryke/path/is-equal");
18
18
  let _stryke_path_replace = require("@stryke/path/replace");
19
- let _stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
20
19
  let chalk = require("chalk");
21
20
  chalk = require_chunk.__toESM(chalk, 1);
22
21
  let defu = require("defu");
@@ -24,7 +23,6 @@ defu = require_chunk.__toESM(defu, 1);
24
23
  let _stryke_path_join_paths = require("@stryke/path/join-paths");
25
24
  let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
26
25
  let _powerlines_core_lib_utilities_format = require("@powerlines/core/lib/utilities/format");
27
- let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
28
26
  let _stryke_fs_exists = require("@stryke/fs/exists");
29
27
  let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
30
28
  let _stryke_helpers_omit = require("@stryke/helpers/omit");
@@ -33,7 +31,6 @@ let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
33
31
  let _stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
34
32
  let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
35
33
  let _stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
36
- let _powerlines_core = require("@powerlines/core");
37
34
  let _stryke_fs_json = require("@stryke/fs/json");
38
35
  let _stryke_helpers_deep_clone = require("@stryke/helpers/deep-clone");
39
36
  let _powerlines_core_lib_entry = require("@powerlines/core/lib/entry");
@@ -48,6 +45,7 @@ let flat_cache = require("flat-cache");
48
45
  let oxc_parser = require("oxc-parser");
49
46
  let undici = require("undici");
50
47
  require("@stryke/fs/remove-file");
48
+ let _powerlines_core = require("@powerlines/core");
51
49
  let _stryke_capnp = require("@stryke/capnp");
52
50
  _stryke_capnp = require_chunk.__toESM(_stryke_capnp, 1);
53
51
  let _stryke_fs_buffer = require("@stryke/fs/buffer");
@@ -149,6 +147,40 @@ async function writeMetaFile(context) {
149
147
  await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
150
148
  }
151
149
 
150
+ //#endregion
151
+ //#region src/_internal/ipc/send.ts
152
+ function sendWriteLogMessage(context, type, message) {
153
+ const meta = {
154
+ ...(0, _stryke_type_checks_is_set_object.isSetObject)(message) && (0, _stryke_type_checks_is_set_object.isSetObject)(message.meta) ? message.meta : {},
155
+ ...context.logger.options
156
+ };
157
+ process.send?.({
158
+ id: (0, _stryke_unique_id_uuid.uuid)(),
159
+ type: "write-log",
160
+ executionId: meta.executionId ?? context.config.executionId,
161
+ executionIndex: meta.executionIndex ?? context.config.executionIndex,
162
+ environment: meta.environment,
163
+ timestamp: Date.now(),
164
+ payload: {
165
+ meta: {
166
+ type,
167
+ category: meta.category ?? _powerlines_core.LogCategories.GENERAL,
168
+ logId: meta.logId ?? (0, _stryke_unique_id_uuid.uuid)(),
169
+ timestamp: meta.timestamp ?? Date.now(),
170
+ name: meta.name ?? context.config.name,
171
+ executionId: meta.executionId ?? context.config.executionId,
172
+ executionIndex: meta.executionIndex ?? context.config.executionIndex,
173
+ command: meta.command ?? context.config.command,
174
+ hook: meta.hook,
175
+ environment: meta.environment,
176
+ plugin: meta.plugin,
177
+ source: meta.source
178
+ },
179
+ message: (0, _stryke_type_checks_is_set_string.isSetString)(message) ? message : message.message
180
+ }
181
+ });
182
+ }
183
+
152
184
  //#endregion
153
185
  //#region src/_internal/helpers/constants.ts
154
186
  const DEFAULT_EXTENSIONS = [
@@ -260,9 +292,9 @@ var VirtualFileSystem = class VirtualFileSystem {
260
292
  */
261
293
  #context;
262
294
  /**
263
- * The file system's logging function.
295
+ * The file system's logger client utility.
264
296
  */
265
- #log;
297
+ #logger;
266
298
  /**
267
299
  * Normalizes a given module id by resolving it against the built-ins path.
268
300
  *
@@ -476,7 +508,7 @@ var VirtualFileSystem = class VirtualFileSystem {
476
508
  }
477
509
  }));
478
510
  } else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(require_fs.FileSystem));
479
- result.#log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Successfully completed virtual file system (VFS) initialization.");
511
+ result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
480
512
  return result;
481
513
  }
482
514
  /**
@@ -510,7 +542,7 @@ var VirtualFileSystem = class VirtualFileSystem {
510
542
  }
511
543
  });
512
544
  } else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(require_fs.FileSystem));
513
- result.#log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Successfully completed virtual file system (VFS) initialization.");
545
+ result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
514
546
  return result;
515
547
  }
516
548
  /**
@@ -644,7 +676,10 @@ var VirtualFileSystem = class VirtualFileSystem {
644
676
  return ret;
645
677
  }, {});
646
678
  }
647
- this.#log = context.extendLog("VFS");
679
+ this.#logger = context.extendLogger({
680
+ source: "VFS",
681
+ category: "fs"
682
+ });
648
683
  }
649
684
  /**
650
685
  * Asynchronously checks if a file exists in the virtual file system (VFS).
@@ -771,7 +806,7 @@ var VirtualFileSystem = class VirtualFileSystem {
771
806
  listSync(path) {
772
807
  let resolvedPath = path;
773
808
  if (resolvedPath.includes("*")) {
774
- this.#log(_storm_software_config_tools_types.LogLevelLabel.WARN, `Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
809
+ this.#logger.warn(`Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
775
810
  resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
776
811
  }
777
812
  return (0, _stryke_helpers_get_unique.getUnique)(this.#getStorages(resolvedPath, true).map((storage) => storage.adapter.listSync(storage.relativeBase ? storage.base ? (0, _stryke_path_append.appendPath)(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)).flat().filter(Boolean));
@@ -785,7 +820,7 @@ var VirtualFileSystem = class VirtualFileSystem {
785
820
  async list(path) {
786
821
  let resolvedPath = path;
787
822
  if (resolvedPath.includes("*")) {
788
- this.#log(_storm_software_config_tools_types.LogLevelLabel.WARN, `Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
823
+ this.#logger.warn(`Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
789
824
  resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
790
825
  }
791
826
  return (0, _stryke_helpers_get_unique.getUnique)((await Promise.all(this.#getStorages(resolvedPath, true).map(async (storage) => storage.adapter.list(storage.relativeBase ? storage.base ? (0, _stryke_path_append.appendPath)(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)))).flat().filter(Boolean));
@@ -797,7 +832,7 @@ var VirtualFileSystem = class VirtualFileSystem {
797
832
  */
798
833
  async remove(path) {
799
834
  const normalizedPath = this.#normalizePath(path);
800
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
835
+ this.#logger.trace(`Removing file: ${normalizedPath}`);
801
836
  const { relativeKey, adapter } = this.#getStorage(normalizedPath);
802
837
  if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) await adapter.remove(relativeKey);
803
838
  else await adapter.clear(relativeKey);
@@ -815,7 +850,7 @@ var VirtualFileSystem = class VirtualFileSystem {
815
850
  */
816
851
  removeSync(path) {
817
852
  const normalizedPath = this.#normalizePath(path);
818
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
853
+ this.#logger.trace(`Removing file: ${normalizedPath}`);
819
854
  const { relativeKey, adapter } = this.#getStorage(normalizedPath);
820
855
  if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) adapter.removeSync(relativeKey);
821
856
  else adapter.clearSync(relativeKey);
@@ -961,7 +996,7 @@ var VirtualFileSystem = class VirtualFileSystem {
961
996
  const filePath = await this.resolve(path, void 0, { isFile: true });
962
997
  if (!filePath || !this.existsSync(filePath)) return;
963
998
  const { adapter } = this.#getStorage(filePath);
964
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
999
+ this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);
965
1000
  return await adapter.get(filePath) ?? void 0;
966
1001
  }
967
1002
  /**
@@ -974,7 +1009,7 @@ var VirtualFileSystem = class VirtualFileSystem {
974
1009
  const filePath = this.resolveSync(path, void 0, { isFile: true });
975
1010
  if (!filePath || !this.existsSync(filePath)) return;
976
1011
  const { adapter } = this.#getStorage(filePath);
977
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
1012
+ this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);
978
1013
  return adapter.getSync(filePath) ?? void 0;
979
1014
  }
980
1015
  /**
@@ -989,15 +1024,15 @@ var VirtualFileSystem = class VirtualFileSystem {
989
1024
  const meta = options.meta ?? {};
990
1025
  const resolvedPath = await this.resolve(this.#normalizePath(path)) || path;
991
1026
  const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
992
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(data)).size)})`);
1027
+ this.#logger.trace(`Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(data)).size)})`);
993
1028
  let code = data;
994
1029
  try {
995
1030
  if (!options.skipFormat) code = await (0, _powerlines_core_lib_utilities_format.format)(this.#context, resolvedPath, data);
996
1031
  } catch (err) {
997
- if (DEFAULT_EXTENSIONS.includes((0, _stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#log(_storm_software_config_tools_types.LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
1032
+ if (DEFAULT_EXTENSIONS.includes((0, _stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#logger.warn(`Failed to format file ${resolvedPath} before writing: ${err.message}`);
998
1033
  code = data;
999
1034
  }
1000
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(code)).size)})`);
1035
+ this.#logger.trace(`Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(code)).size)})`);
1001
1036
  const id = this.#normalizeId(meta.id || resolvedPath);
1002
1037
  this.metadata[id] = {
1003
1038
  type: "normal",
@@ -1020,7 +1055,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1020
1055
  const meta = options.meta ?? {};
1021
1056
  const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;
1022
1057
  const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
1023
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Writing ${resolvedPath} file to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(data)).size)})`);
1058
+ 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: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new node_buffer.Blob((0, _stryke_convert_to_array.toArray)(data)).size)})`);
1024
1059
  const id = this.#normalizeId(meta.id || resolvedPath);
1025
1060
  this.metadata[id] = {
1026
1061
  type: "normal",
@@ -1184,7 +1219,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1184
1219
  async dispose() {
1185
1220
  if (!this.#isDisposed) {
1186
1221
  this.#isDisposed = true;
1187
- this.#log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Disposing virtual file system...");
1222
+ this.#logger.debug("Disposing virtual file system...");
1188
1223
  await this.remove((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"));
1189
1224
  const message = new _stryke_capnp.Message();
1190
1225
  const fs = message.initRoot(require_fs.FileSystem);
@@ -1219,9 +1254,15 @@ var VirtualFileSystem = class VirtualFileSystem {
1219
1254
  await (0, _stryke_fs_buffer.writeFileBuffer)((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
1220
1255
  if (!this.#context.config.skipCache) this.resolverCache.save(true);
1221
1256
  await Promise.all(this.#getStorages().map(async (storage) => storage.adapter.dispose()));
1222
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, "Virtual file system has been disposed.");
1257
+ this.#logger.trace("Virtual file system has been disposed.");
1223
1258
  }
1224
1259
  }
1260
+ /**
1261
+ * Asynchronously disposes of the virtual file system (VFS) by saving its state to disk.
1262
+ *
1263
+ * @remarks
1264
+ * 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.
1265
+ */
1225
1266
  async [Symbol.asyncDispose]() {
1226
1267
  return this.dispose();
1227
1268
  }
@@ -1370,7 +1411,7 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
1370
1411
  buildId: this.#buildId,
1371
1412
  releaseId: this.#releaseId,
1372
1413
  checksum: this.#checksum,
1373
- timestamp: this.timestamp.getTime(),
1414
+ timestamp: this.timestamp,
1374
1415
  rootHash: (0, _stryke_hash.murmurhash)({
1375
1416
  workspaceRoot: this.options?.cwd,
1376
1417
  root: this.config?.root
@@ -1474,6 +1515,18 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
1474
1515
  }, {}) : this.config.resolve.alias : {});
1475
1516
  }
1476
1517
  /**
1518
+ * 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.
1519
+ */
1520
+ get logger() {
1521
+ const options = {
1522
+ ...this.config,
1523
+ ...this.options
1524
+ };
1525
+ const logger = (0, _powerlines_core_plugin_utils.withLogger)((0, _powerlines_core_plugin_utils.createLogger)(this.config.name, options), (0, _powerlines_core_plugin_utils.createLogger)(this.config.name, options, (type, message) => sendWriteLogMessage(this, type, message)));
1526
+ if (this.config.customLogger) return (0, _powerlines_core_plugin_utils.withCustomLogger)(logger, this.config.customLogger);
1527
+ return logger;
1528
+ }
1529
+ /**
1477
1530
  * Gets the parser cache.
1478
1531
  */
1479
1532
  get parserCache() {
@@ -1570,6 +1623,9 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
1570
1623
  headers: cached.headers
1571
1624
  });
1572
1625
  }
1626
+ const logger = this.extendLogger({ category: "network" });
1627
+ const startTime = Date.now();
1628
+ logger.trace(`Sending fetch request (${options.method?.toUpperCase() || "GET"}): ${input.toString()}`);
1573
1629
  const response = await (0, _stryke_http_fetch.fetchRequest)(input, {
1574
1630
  timeout: 12e3,
1575
1631
  ...options
@@ -1583,6 +1639,7 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
1583
1639
  if (!this.config.skipCache && !options.skipCache) try {
1584
1640
  this.requestCache.set(cacheKey, result);
1585
1641
  } catch {}
1642
+ 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]"}`);
1586
1643
  return new undici.Response(result.body, {
1587
1644
  status: result.status,
1588
1645
  statusText: result.statusText,
@@ -1937,6 +1994,7 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
1937
1994
  */
1938
1995
  async init(options = {}) {
1939
1996
  await super.init(options);
1997
+ this.options.executionId = options.executionId ?? this.options.executionId;
1940
1998
  this.options.executionIndex = options.executionIndex ?? this.options.executionIndex ?? 0;
1941
1999
  const projectJsonPath = (0, _stryke_path_join.joinPaths)(this.options.cwd, this.options.root, "project.json");
1942
2000
  if ((0, _stryke_fs_exists.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs_json.readJsonFile)(projectJsonPath);
@@ -1957,6 +2015,13 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
1957
2015
  * Initialize the context with the provided configuration options
1958
2016
  */
1959
2017
  async innerSetup() {
2018
+ const logger = this.extendLogger({ category: "config" });
2019
+ logger.debug(`Pre-setup Powerlines configuration object: \n${JSON.stringify({
2020
+ ...(0, _stryke_helpers_omit.omit)(this.config, ["plugins"]),
2021
+ userConfig: this.config.userConfig ? (0, _stryke_helpers_omit.omit)(this.config.userConfig, ["plugins"]) : {},
2022
+ inlineConfig: this.config.inlineConfig ? (0, _stryke_helpers_omit.omit)(this.config.inlineConfig, ["plugins"]) : {},
2023
+ pluginConfig: this.config.pluginConfig ? (0, _stryke_helpers_omit.omit)(this.config.pluginConfig, ["plugins"]) : {}
2024
+ }, null, 2)}`);
1960
2025
  if (!this.inputOptions.mode && !this.config.userConfig?.mode && !this.config.inlineConfig?.mode && !this.config.pluginConfig?.mode) {
1961
2026
  this.options.mode = "production";
1962
2027
  this.config.mode = "production";
@@ -1966,10 +2031,6 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
1966
2031
  this.config.framework = "powerlines";
1967
2032
  }
1968
2033
  this.resolvedConfig.compatibilityDate = (0, compatx.resolveCompatibilityDates)(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
1969
- this.logger = {
1970
- log: this.createLog(this.config.name),
1971
- level: (0, _stryke_type_checks_is_null.isNull)(this.logLevel) ? "silent" : this.logLevel
1972
- };
1973
2034
  this.config.input = (0, _powerlines_core_lib_entry.getUniqueInputs)(this.config.input);
1974
2035
  if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
1975
2036
  this.config.title ??= (0, _stryke_string_format_title_case.titleCase)(this.config.name);
@@ -1982,11 +2043,12 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
1982
2043
  ret.push(plugin);
1983
2044
  return ret;
1984
2045
  }, []);
1985
- if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = "debug";
1986
- else this.config.logLevel = "info";
1987
- if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = require_tsconfig.getTsconfigFilePath(this.options.cwd, this.options.root);
2046
+ if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = _powerlines_core_constants.DEFAULT_DEVELOPMENT_LOG_LEVEL;
2047
+ else if (this.config.mode === "test") this.config.logLevel = _powerlines_core_constants.DEFAULT_TEST_LOG_LEVEL;
2048
+ else this.config.logLevel = _powerlines_core_constants.DEFAULT_PRODUCTION_LOG_LEVEL;
2049
+ if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = require_tsconfig.getTsconfigFilePath(this.config.cwd, this.config.root);
1988
2050
  else if (this.config.tsconfig) this.config.tsconfig = (0, _stryke_path_replace.replacePath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, this.config.tsconfig), this.config.cwd);
1989
- this.resolvedConfig.output = (0, defu.default)(this.resolvedConfig.output ?? {}, {
2051
+ this.resolvedConfig.output = (0, defu.default)(this.config.output ?? {}, {
1990
2052
  path: (0, _stryke_path_join.joinPaths)(this.config.root, "dist"),
1991
2053
  copy: { assets: [
1992
2054
  { glob: "LICENSE" },
@@ -2031,6 +2093,12 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
2031
2093
  }));
2032
2094
  if ((0, _stryke_type_checks_is_set_string.isSetString)(this.config.output?.storage) && this.config.output.storage === "virtual" || (0, _stryke_type_checks_is_set_object.isSetObject)(this.config.output?.storage) && Object.values(this.config.output.storage).every((adapter) => adapter.preset === "virtual")) this.config.output.overwrite = true;
2033
2095
  this.#fs ??= await VirtualFileSystem.create(this);
2096
+ logger.debug(`Post-setup Powerlines configuration object: \n${JSON.stringify({
2097
+ ...(0, _stryke_helpers_omit.omit)(this.config, ["plugins"]),
2098
+ userConfig: this.config.userConfig ? (0, _stryke_helpers_omit.omit)(this.config.userConfig, ["plugins"]) : {},
2099
+ inlineConfig: this.config.inlineConfig ? (0, _stryke_helpers_omit.omit)(this.config.inlineConfig, ["plugins"]) : {},
2100
+ pluginConfig: this.config.pluginConfig ? (0, _stryke_helpers_omit.omit)(this.config.pluginConfig, ["plugins"]) : {}
2101
+ }, null, 2)}`);
2034
2102
  }
2035
2103
  };
2036
2104
 
@@ -2080,7 +2148,7 @@ function mergeConfigs(currentResult, previousResults) {
2080
2148
  async function callHook(context, key, options, ...args) {
2081
2149
  const hooks = context.selectHooks(key, options);
2082
2150
  if (hooks.length > 0) {
2083
- context.debug(` 🧩 Calling ${hooks.length} ${chalk.default.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)} plugin hook${hooks.length > 1 ? "s" : ""}:\n${hooks.map((hook, index) => ` ${index + 1}. ${(0, _powerlines_core_lib_logger.colorText)(hook.plugin.name)}`).join("\n")}`);
2151
+ context.extendLogger({ category: "hooks" }).debug(` 🧩 Calling ${hooks.length} ${chalk.default.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)} plugin hook${hooks.length > 1 ? "s" : ""}:\n${hooks.map((hook, index) => ` ${index + 1}. ${(0, _powerlines_core_plugin_utils_logging.colorText)(hook.plugin.name)}`).join("\n")}`);
2084
2152
  const invokeHook = async (hook, hookArgs) => {
2085
2153
  return Reflect.apply(hook.handler, hook.context, hookArgs);
2086
2154
  };
@@ -2180,7 +2248,7 @@ function createPluginContext(pluginId, plugin, environment) {
2180
2248
  const normalizeMessage = (message) => {
2181
2249
  return (0, _stryke_type_checks_is_string.isString)(message) ? message : message.message;
2182
2250
  };
2183
- const log = environment.extendLog(pluginId, plugin.name.replaceAll(":", " - "));
2251
+ const logger = environment.extendLogger({ plugin: plugin.name.replaceAll(":", " - ") });
2184
2252
  const callHookFn = async (hook, options, ...args) => {
2185
2253
  return environment.$$internal.api.callHook(hook, {
2186
2254
  sequential: true,
@@ -2199,24 +2267,24 @@ function createPluginContext(pluginId, plugin, environment) {
2199
2267
  meta
2200
2268
  };
2201
2269
  if (prop === "id") return pluginId;
2202
- if (prop === "log" || prop === "logger") return log;
2270
+ if (prop === "logger") return logger;
2203
2271
  if (prop === "fatal") return (message) => {
2204
- log(_storm_software_config_tools_types.LogLevelLabel.FATAL, normalizeMessage(message));
2272
+ logger.error(normalizeMessage(message));
2205
2273
  };
2206
2274
  if (prop === "error") return (message) => {
2207
- log(_storm_software_config_tools_types.LogLevelLabel.ERROR, normalizeMessage(message));
2275
+ logger.error(normalizeMessage(message));
2208
2276
  };
2209
2277
  if (prop === "warn") return (message) => {
2210
- log(_storm_software_config_tools_types.LogLevelLabel.WARN, normalizeMessage(message));
2278
+ logger.warn(normalizeMessage(message));
2211
2279
  };
2212
2280
  if (prop === "info") return (message) => {
2213
- log(_storm_software_config_tools_types.LogLevelLabel.INFO, normalizeMessage(message));
2281
+ logger.info(normalizeMessage(message));
2214
2282
  };
2215
2283
  if (prop === "debug") return (message) => {
2216
- log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, normalizeMessage(message));
2284
+ logger.debug(normalizeMessage(message));
2217
2285
  };
2218
2286
  if (prop === "trace") return (message) => {
2219
- log(_storm_software_config_tools_types.LogLevelLabel.TRACE, normalizeMessage(message));
2287
+ logger.trace(normalizeMessage(message));
2220
2288
  };
2221
2289
  return environment[prop];
2222
2290
  },
@@ -2235,7 +2303,7 @@ function createPluginContext(pluginId, plugin, environment) {
2235
2303
  "addPlugin",
2236
2304
  "selectHooks"
2237
2305
  ].includes(prop)) {
2238
- log(_storm_software_config_tools_types.LogLevelLabel.WARN, `Cannot set read-only property "${String(prop)}"`);
2306
+ logger.warn(`Cannot set the read-only "${String(prop)}" property`);
2239
2307
  return false;
2240
2308
  }
2241
2309
  environment[prop] = value;
@@ -2289,50 +2357,26 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
2289
2357
  /**
2290
2358
  * Create a new logger instance
2291
2359
  *
2292
- * @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.
2293
- * @returns A logger function
2294
- */
2295
- createLog(source = null) {
2296
- return (level, ...args) => {
2297
- process.send?.({
2298
- id: (0, _stryke_unique_id_uuid.uuid)(),
2299
- type: "write-log",
2300
- executionId: this.options.executionId,
2301
- executionIndex: this.options.executionIndex,
2302
- timestamp: Date.now(),
2303
- payload: {
2304
- level,
2305
- source,
2306
- environment: this.environment?.name,
2307
- args
2308
- }
2309
- });
2310
- };
2360
+ * @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.
2361
+ * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
2362
+ */
2363
+ createLogger(options, callback) {
2364
+ return super.createLogger({
2365
+ ...options,
2366
+ environment: this.environment?.name
2367
+ }, callback);
2311
2368
  }
2312
2369
  /**
2313
- * Extend the current logger instance with a new name
2314
- *
2315
- * @param source - The name of the source to use for the extended logger instance
2316
- * @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.
2317
- * @returns A logger function
2318
- */
2319
- extendLog(source, plugin) {
2320
- return (level, ...args) => {
2321
- process.send?.({
2322
- id: (0, _stryke_unique_id_uuid.uuid)(),
2323
- type: "write-log",
2324
- executionId: this.options.executionId,
2325
- executionIndex: this.options.executionIndex,
2326
- timestamp: Date.now(),
2327
- payload: {
2328
- level,
2329
- source,
2330
- plugin,
2331
- environment: this.environment?.name,
2332
- args
2333
- }
2334
- });
2335
- };
2370
+ * Extend the base logger with additional configuration options
2371
+ *
2372
+ * @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.
2373
+ * @returns A new logger client instance that extends the base logger with the provided configuration options.
2374
+ */
2375
+ extendLogger(options) {
2376
+ return super.extendLogger({
2377
+ ...options,
2378
+ environment: this.environment?.name
2379
+ });
2336
2380
  }
2337
2381
  /**
2338
2382
  * 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.
@@ -2518,29 +2562,28 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
2518
2562
  /**
2519
2563
  * Create a new logger instance
2520
2564
  *
2521
- * @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.
2522
- * @returns A logger function
2565
+ * @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.
2566
+ * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
2523
2567
  */
2524
- createLog(source = null) {
2525
- const logger = (0, _powerlines_core.createLog)(source, {
2526
- ...this.config,
2527
- logLevel: (0, _stryke_type_checks_is_null.isNull)(this.config.logLevel) ? "silent" : this.config.logLevel
2568
+ createLogger(options, callback) {
2569
+ return super.createLogger({
2570
+ ...options,
2571
+ executionId: this.id,
2572
+ executionIndex: this.options.executionIndex
2573
+ }, callback);
2574
+ }
2575
+ /**
2576
+ * Extend the base logger with additional configuration options
2577
+ *
2578
+ * @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.
2579
+ * @returns A new logger client instance that extends the base logger with the provided configuration options.
2580
+ */
2581
+ extendLogger(options) {
2582
+ return super.extendLogger({
2583
+ ...options,
2584
+ executionId: this.id,
2585
+ executionIndex: this.options.executionIndex
2528
2586
  });
2529
- return (level, ...args) => {
2530
- logger(level, ...args);
2531
- process.send?.({
2532
- id: (0, _stryke_unique_id_uuid.uuid)(),
2533
- type: "write-log",
2534
- executionId: this.id,
2535
- executionIndex: this.options.executionIndex,
2536
- timestamp: Date.now(),
2537
- payload: {
2538
- source,
2539
- level,
2540
- args
2541
- }
2542
- });
2543
- };
2544
2587
  }
2545
2588
  /**
2546
2589
  * 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.