@powerlines/engine 0.43.31 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,13 +63,12 @@ let defu = require("defu");
63
63
  defu = __toESM(defu, 1);
64
64
  let handlebars = require("handlebars");
65
65
  handlebars = __toESM(handlebars, 1);
66
- let _powerlines_core = require("@powerlines/core");
67
66
  let _powerlines_core_constants = require("@powerlines/core/constants");
68
67
  let _stryke_fs_json = require("@stryke/fs/json");
69
68
  let _stryke_helpers_deep_clone = require("@stryke/helpers/deep-clone");
70
69
  let _stryke_path_join = require("@stryke/path/join");
71
- let _stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
72
70
  let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
71
+ let _powerlines_core = require("@powerlines/core");
73
72
  let _powerlines_core_lib_entry = require("@powerlines/core/lib/entry");
74
73
  let _stryke_fs_get_workspace_root = require("@stryke/fs/get-workspace-root");
75
74
  let _stryke_hash = require("@stryke/hash");
@@ -83,7 +82,6 @@ let flat_cache = require("flat-cache");
83
82
  let oxc_parser = require("oxc-parser");
84
83
  let undici = require("undici");
85
84
  require("@stryke/fs/remove-file");
86
- let _storm_software_config_tools_types = require("@storm-software/config-tools/types");
87
85
  let _stryke_capnp = require("@stryke/capnp");
88
86
  _stryke_capnp = __toESM(_stryke_capnp, 1);
89
87
  let _stryke_fs_buffer = require("@stryke/fs/buffer");
@@ -1234,7 +1232,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1234
1232
  }
1235
1233
  }));
1236
1234
  } else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(FileSystem));
1237
- result.#log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Successfully completed virtual file system (VFS) initialization.");
1235
+ result.#log("debug", "Successfully completed virtual file system (VFS) initialization.");
1238
1236
  return result;
1239
1237
  }
1240
1238
  /**
@@ -1268,7 +1266,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1268
1266
  }
1269
1267
  });
1270
1268
  } else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(FileSystem));
1271
- result.#log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Successfully completed virtual file system (VFS) initialization.");
1269
+ result.#log("debug", "Successfully completed virtual file system (VFS) initialization.");
1272
1270
  return result;
1273
1271
  }
1274
1272
  /**
@@ -1402,7 +1400,10 @@ var VirtualFileSystem = class VirtualFileSystem {
1402
1400
  return ret;
1403
1401
  }, {});
1404
1402
  }
1405
- this.#log = context.extendLog("VFS");
1403
+ this.#log = context.extendLog({
1404
+ source: "VFS",
1405
+ category: "fs"
1406
+ });
1406
1407
  }
1407
1408
  /**
1408
1409
  * Asynchronously checks if a file exists in the virtual file system (VFS).
@@ -1529,7 +1530,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1529
1530
  listSync(path) {
1530
1531
  let resolvedPath = path;
1531
1532
  if (resolvedPath.includes("*")) {
1532
- 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}`);
1533
+ this.#log("warn", `Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
1533
1534
  resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
1534
1535
  }
1535
1536
  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));
@@ -1543,7 +1544,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1543
1544
  async list(path) {
1544
1545
  let resolvedPath = path;
1545
1546
  if (resolvedPath.includes("*")) {
1546
- 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}`);
1547
+ this.#log("warn", `Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
1547
1548
  resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
1548
1549
  }
1549
1550
  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));
@@ -1555,7 +1556,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1555
1556
  */
1556
1557
  async remove(path) {
1557
1558
  const normalizedPath = this.#normalizePath(path);
1558
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
1559
+ this.#log("trace", `Removing file: ${normalizedPath}`);
1559
1560
  const { relativeKey, adapter } = this.#getStorage(normalizedPath);
1560
1561
  if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) await adapter.remove(relativeKey);
1561
1562
  else await adapter.clear(relativeKey);
@@ -1573,7 +1574,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1573
1574
  */
1574
1575
  removeSync(path) {
1575
1576
  const normalizedPath = this.#normalizePath(path);
1576
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Removing file: ${normalizedPath}`);
1577
+ this.#log("trace", `Removing file: ${normalizedPath}`);
1577
1578
  const { relativeKey, adapter } = this.#getStorage(normalizedPath);
1578
1579
  if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) adapter.removeSync(relativeKey);
1579
1580
  else adapter.clearSync(relativeKey);
@@ -1719,7 +1720,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1719
1720
  const filePath = await this.resolve(path, void 0, { isFile: true });
1720
1721
  if (!filePath || !this.existsSync(filePath)) return;
1721
1722
  const { adapter } = this.#getStorage(filePath);
1722
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
1723
+ this.#log("trace", `Reading ${adapter.name} file: ${filePath}`);
1723
1724
  return await adapter.get(filePath) ?? void 0;
1724
1725
  }
1725
1726
  /**
@@ -1732,7 +1733,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1732
1733
  const filePath = this.resolveSync(path, void 0, { isFile: true });
1733
1734
  if (!filePath || !this.existsSync(filePath)) return;
1734
1735
  const { adapter } = this.#getStorage(filePath);
1735
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, `Reading ${adapter.name} file: ${filePath}`);
1736
+ this.#log("trace", `Reading ${adapter.name} file: ${filePath}`);
1736
1737
  return adapter.getSync(filePath) ?? void 0;
1737
1738
  }
1738
1739
  /**
@@ -1747,15 +1748,15 @@ var VirtualFileSystem = class VirtualFileSystem {
1747
1748
  const meta = options.meta ?? {};
1748
1749
  const resolvedPath = await this.resolve(this.#normalizePath(path)) || path;
1749
1750
  const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
1750
- 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)})`);
1751
+ this.#log("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)})`);
1751
1752
  let code = data;
1752
1753
  try {
1753
1754
  if (!options.skipFormat) code = await (0, _powerlines_core_lib_utilities_format.format)(this.#context, resolvedPath, data);
1754
1755
  } catch (err) {
1755
- 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}`);
1756
+ if (DEFAULT_EXTENSIONS.includes((0, _stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#log("warn", `Failed to format file ${resolvedPath} before writing: ${err.message}`);
1756
1757
  code = data;
1757
1758
  }
1758
- 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)})`);
1759
+ this.#log("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)})`);
1759
1760
  const id = this.#normalizeId(meta.id || resolvedPath);
1760
1761
  this.metadata[id] = {
1761
1762
  type: "normal",
@@ -1778,7 +1779,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1778
1779
  const meta = options.meta ?? {};
1779
1780
  const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;
1780
1781
  const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
1781
- 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)})`);
1782
+ this.#log("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)})`);
1782
1783
  const id = this.#normalizeId(meta.id || resolvedPath);
1783
1784
  this.metadata[id] = {
1784
1785
  type: "normal",
@@ -1942,7 +1943,7 @@ var VirtualFileSystem = class VirtualFileSystem {
1942
1943
  async dispose() {
1943
1944
  if (!this.#isDisposed) {
1944
1945
  this.#isDisposed = true;
1945
- this.#log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Disposing virtual file system...");
1946
+ this.#log("debug", "Disposing virtual file system...");
1946
1947
  await this.remove((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"));
1947
1948
  const message = new _stryke_capnp.Message();
1948
1949
  const fs = message.initRoot(FileSystem);
@@ -1977,9 +1978,15 @@ var VirtualFileSystem = class VirtualFileSystem {
1977
1978
  await (0, _stryke_fs_buffer.writeFileBuffer)((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
1978
1979
  if (!this.#context.config.skipCache) this.resolverCache.save(true);
1979
1980
  await Promise.all(this.#getStorages().map(async (storage) => storage.adapter.dispose()));
1980
- this.#log(_storm_software_config_tools_types.LogLevelLabel.TRACE, "Virtual file system has been disposed.");
1981
+ this.#log("trace", "Virtual file system has been disposed.");
1981
1982
  }
1982
1983
  }
1984
+ /**
1985
+ * Asynchronously disposes of the virtual file system (VFS) by saving its state to disk.
1986
+ *
1987
+ * @remarks
1988
+ * 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.
1989
+ */
1983
1990
  async [Symbol.asyncDispose]() {
1984
1991
  return this.dispose();
1985
1992
  }
@@ -2152,7 +2159,6 @@ function createResolver(options) {
2152
2159
  //#region src/context/base-context.ts
2153
2160
  var PowerlinesBaseContext = class PowerlinesBaseContext {
2154
2161
  #timestamp = Date.now();
2155
- #logLevel = "info";
2156
2162
  /**
2157
2163
  * The path to the Powerlines package
2158
2164
  */
@@ -2177,24 +2183,16 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2177
2183
  * A timestamp representing when the context was initialized
2178
2184
  */
2179
2185
  get timestamp() {
2180
- return new Date(this.#timestamp);
2186
+ return this.#timestamp;
2181
2187
  }
2182
2188
  get logLevel() {
2183
- return this.#logLevel || "info";
2184
- }
2185
- set logLevel(level) {
2186
- this.#logLevel = level;
2189
+ return (0, _powerlines_core_plugin_utils.resolveLogLevel)(this.options.logLevel, this.options.mode);
2187
2190
  }
2188
2191
  /**
2189
2192
  * The logger function
2190
2193
  */
2191
2194
  get log() {
2192
- const level = this.logLevel || "info";
2193
- if (!this.logger || this.logger.level !== level) this.logger = {
2194
- log: this.createLog(),
2195
- level
2196
- };
2197
- return this.logger.log;
2195
+ return this.createLog();
2198
2196
  }
2199
2197
  /**
2200
2198
  * The environment paths for the project
@@ -2225,7 +2223,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2225
2223
  * @param message - The message to log.
2226
2224
  */
2227
2225
  fatal(message) {
2228
- this.log(_storm_software_config_tools_types.LogLevelLabel.FATAL, (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2226
+ this.log("error", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2229
2227
  }
2230
2228
  /**
2231
2229
  * A logging function for error messages
@@ -2233,7 +2231,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2233
2231
  * @param message - The message to log.
2234
2232
  */
2235
2233
  error(message) {
2236
- this.log(_storm_software_config_tools_types.LogLevelLabel.ERROR, (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2234
+ this.log("error", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2237
2235
  }
2238
2236
  /**
2239
2237
  * A logging function for warning messages
@@ -2241,7 +2239,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2241
2239
  * @param message - The message to log.
2242
2240
  */
2243
2241
  warn(message) {
2244
- this.log(_storm_software_config_tools_types.LogLevelLabel.WARN, (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2242
+ this.log("warn", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2245
2243
  }
2246
2244
  /**
2247
2245
  * A logging function for informational messages
@@ -2249,7 +2247,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2249
2247
  * @param message - The message to log.
2250
2248
  */
2251
2249
  info(message) {
2252
- this.log(_storm_software_config_tools_types.LogLevelLabel.INFO, (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2250
+ this.log("info", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2253
2251
  }
2254
2252
  /**
2255
2253
  * A logging function for debug messages
@@ -2257,7 +2255,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2257
2255
  * @param message - The message to log.
2258
2256
  */
2259
2257
  debug(message) {
2260
- this.log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2258
+ this.log("debug", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2261
2259
  }
2262
2260
  /**
2263
2261
  * A logging function for trace messages
@@ -2265,7 +2263,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2265
2263
  * @param message - The message to log.
2266
2264
  */
2267
2265
  trace(message) {
2268
- this.log(_storm_software_config_tools_types.LogLevelLabel.TRACE, (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2266
+ this.log("trace", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2269
2267
  }
2270
2268
  /**
2271
2269
  * A function to create a timer for measuring the duration of asynchronous operations
@@ -2285,29 +2283,32 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2285
2283
  const startDuration = performance.now();
2286
2284
  return () => {
2287
2285
  const duration = performance.now() - startDuration;
2288
- this.log(_storm_software_config_tools_types.LogLevelLabel.PERFORMANCE, `${chalk.default.bold.cyanBright(name)} completed in ${chalk.default.bold.cyanBright(duration < 1e3 ? `${duration.toFixed(2)} milliseconds` : (0, date_fns_formatDistanceToNowStrict.formatDistanceToNowStrict)(startDate))}`);
2286
+ this.log({
2287
+ level: "info",
2288
+ category: "performance"
2289
+ }, `${chalk.default.bold.cyanBright(name)} completed in ${chalk.default.bold.cyanBright(duration < 1e3 ? `${duration.toFixed(2)} milliseconds` : (0, date_fns_formatDistanceToNowStrict.formatDistanceToNowStrict)(startDate))}`);
2289
2290
  };
2290
2291
  }
2291
2292
  /**
2292
2293
  * Create a new logger instance
2293
2294
  *
2294
- * @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.
2295
+ * @param config - 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.
2295
2296
  * @returns A logger function
2296
2297
  */
2297
- createLog(source = null) {
2298
- return (0, _powerlines_core_lib_logger.createLog)(source, {
2298
+ createLog(config) {
2299
+ return (0, _powerlines_core_lib_logger.createLogFn)({
2299
2300
  ...this.options,
2300
- logLevel: (0, _stryke_type_checks_is_null.isNull)(this.logLevel) ? "silent" : this.logLevel
2301
+ ...config
2301
2302
  });
2302
2303
  }
2303
2304
  /**
2304
2305
  * Extend the current logger instance with a new source
2305
2306
  *
2306
- * @param source - The source 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.
2307
- * @returns A logger function
2307
+ * @param config - The overlay metadata to use for the badge in the log output, which can be used to customize the appearance and behavior of the log messages generated by the extended logger. This typically includes the name of the plugin or module that is creating the logger instance, and can also include other metadata such as the command or environment.
2308
+ * @returns A new logger function that includes the badge in its output.
2308
2309
  */
2309
- extendLog(source) {
2310
- return (0, _powerlines_core_lib_logger.extendLog)(this.log, source);
2310
+ extendLog(config) {
2311
+ return (0, _powerlines_core_lib_logger.extendLogFn)(this.log, config);
2311
2312
  }
2312
2313
  /**
2313
2314
  * A logger function specific to this context
@@ -2322,7 +2323,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2322
2323
  * @param options - The configuration options to initialize the context with
2323
2324
  */
2324
2325
  async init(options = {}) {
2325
- this.inputOptions = options;
2326
+ this.inputOptions = { ...options };
2326
2327
  if (!this.powerlinesPath) {
2327
2328
  const powerlinesPath = await (0, _stryke_fs_resolve.resolvePackage)("powerlines");
2328
2329
  if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
@@ -2334,6 +2335,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
2334
2335
  root,
2335
2336
  cwd,
2336
2337
  mode: options.mode,
2338
+ logLevel: options.logLevel,
2337
2339
  framework: options.framework,
2338
2340
  organization: options.organization,
2339
2341
  configFile: options.configFile
@@ -2495,7 +2497,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2495
2497
  buildId: this.#buildId,
2496
2498
  releaseId: this.#releaseId,
2497
2499
  checksum: this.#checksum,
2498
- timestamp: this.timestamp.getTime(),
2500
+ timestamp: this.timestamp,
2499
2501
  rootHash: (0, _stryke_hash.murmurhash)({
2500
2502
  workspaceRoot: this.options?.cwd,
2501
2503
  root: this.config?.root
@@ -2653,6 +2655,60 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
2653
2655
  this.options = options;
2654
2656
  }
2655
2657
  /**
2658
+ * Create a new log function with the specified configuration, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
2659
+ *
2660
+ * @param config - Optional configuration for the log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
2661
+ * @returns A log function that can be used to log messages with the specified configuration.
2662
+ */
2663
+ createLog(config) {
2664
+ const log = (0, _powerlines_core.createLogFn)({
2665
+ ...config,
2666
+ logLevel: this.logLevel
2667
+ });
2668
+ return (meta, ...args) => {
2669
+ log(meta, ...args);
2670
+ process.send?.({
2671
+ id: (0, _stryke_unique_id_uuid.uuid)(),
2672
+ type: "write-log",
2673
+ executionId: config?.executionId ?? this.options.executionId,
2674
+ executionIndex: config?.executionIndex ?? this.options.executionIndex,
2675
+ timestamp: Date.now(),
2676
+ payload: {
2677
+ level: meta && (0, _stryke_type_checks_is_set_object.isSetObject)(meta) && (0, _stryke_type_checks_is_set_string.isSetString)(meta.level) ? meta.level : (0, _stryke_type_checks_is_set_string.isSetString)(meta) ? meta : "info",
2678
+ ...config,
2679
+ args
2680
+ }
2681
+ });
2682
+ };
2683
+ }
2684
+ /**
2685
+ * Extend the current log function instance with a new name
2686
+ *
2687
+ * @param config - The configuration for the extended log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the log function instance according to your needs.
2688
+ * @returns A log function
2689
+ */
2690
+ extendLog(config) {
2691
+ const log = (0, _powerlines_core.extendLogFn)(this.log, {
2692
+ ...config,
2693
+ logLevel: this.logLevel
2694
+ });
2695
+ return (meta, ...args) => {
2696
+ log(meta, ...args);
2697
+ process.send?.({
2698
+ id: (0, _stryke_unique_id_uuid.uuid)(),
2699
+ type: "write-log",
2700
+ executionId: config.executionId ?? this.options.executionId,
2701
+ executionIndex: config.executionIndex ?? this.options.executionIndex,
2702
+ timestamp: Date.now(),
2703
+ payload: {
2704
+ level: meta && (0, _stryke_type_checks_is_set_object.isSetObject)(meta) && (0, _stryke_type_checks_is_set_string.isSetString)(meta.level) ? meta.level : (0, _stryke_type_checks_is_set_string.isSetString)(meta) ? meta : "info",
2705
+ ...config,
2706
+ args
2707
+ }
2708
+ });
2709
+ };
2710
+ }
2711
+ /**
2656
2712
  * 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.
2657
2713
  *
2658
2714
  * @remarks
@@ -3062,6 +3118,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3062
3118
  */
3063
3119
  async init(options = {}) {
3064
3120
  await super.init(options);
3121
+ this.options.executionId = options.executionId ?? this.options.executionId;
3065
3122
  this.options.executionIndex = options.executionIndex ?? this.options.executionIndex ?? 0;
3066
3123
  const projectJsonPath = (0, _stryke_path_join.joinPaths)(this.options.cwd, this.options.root, "project.json");
3067
3124
  if ((0, _stryke_fs_exists.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs_json.readJsonFile)(projectJsonPath);
@@ -3091,10 +3148,6 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3091
3148
  this.config.framework = "powerlines";
3092
3149
  }
3093
3150
  this.resolvedConfig.compatibilityDate = (0, compatx.resolveCompatibilityDates)(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
3094
- this.logger = {
3095
- log: this.createLog(this.config.name),
3096
- level: (0, _stryke_type_checks_is_null.isNull)(this.logLevel) ? "silent" : this.logLevel
3097
- };
3098
3151
  this.config.input = (0, _powerlines_core_lib_entry.getUniqueInputs)(this.config.input);
3099
3152
  if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
3100
3153
  this.config.title ??= (0, _stryke_string_format_title_case.titleCase)(this.config.name);
@@ -3107,11 +3160,12 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3107
3160
  ret.push(plugin);
3108
3161
  return ret;
3109
3162
  }, []);
3110
- if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = "debug";
3111
- else this.config.logLevel = "info";
3112
- if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = getTsconfigFilePath(this.options.cwd, this.options.root);
3163
+ if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = _powerlines_core_constants.DEFAULT_DEVELOPMENT_LOG_LEVEL;
3164
+ else if (this.config.mode === "test") this.config.logLevel = _powerlines_core_constants.DEFAULT_TEST_LOG_LEVEL;
3165
+ else this.config.logLevel = _powerlines_core_constants.DEFAULT_PRODUCTION_LOG_LEVEL;
3166
+ if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = getTsconfigFilePath(this.config.cwd, this.config.root);
3113
3167
  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);
3114
- this.resolvedConfig.output = (0, defu.default)(this.resolvedConfig.output ?? {}, {
3168
+ this.resolvedConfig.output = (0, defu.default)(this.config.output ?? {}, {
3115
3169
  path: (0, _stryke_path_join.joinPaths)(this.config.root, "dist"),
3116
3170
  copy: { assets: [
3117
3171
  { glob: "LICENSE" },
@@ -3156,6 +3210,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
3156
3210
  }));
3157
3211
  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;
3158
3212
  this.#fs ??= await VirtualFileSystem.create(this);
3213
+ this.extendLog({ category: "config" })("debug", `Resolved Powerlines configuration object: \n${JSON.stringify(this.resolvedConfig, null, 2)}`);
3159
3214
  }
3160
3215
  };
3161
3216
 
@@ -3305,7 +3360,7 @@ function createPluginContext(pluginId, plugin, environment) {
3305
3360
  const normalizeMessage = (message) => {
3306
3361
  return (0, _stryke_type_checks_is_string.isString)(message) ? message : message.message;
3307
3362
  };
3308
- const log = environment.extendLog(pluginId, plugin.name.replaceAll(":", " - "));
3363
+ const log = environment.extendLog({ plugin: plugin.name.replaceAll(":", " - ") });
3309
3364
  const callHookFn = async (hook, options, ...args) => {
3310
3365
  return environment.$$internal.api.callHook(hook, {
3311
3366
  sequential: true,
@@ -3326,22 +3381,22 @@ function createPluginContext(pluginId, plugin, environment) {
3326
3381
  if (prop === "id") return pluginId;
3327
3382
  if (prop === "log" || prop === "logger") return log;
3328
3383
  if (prop === "fatal") return (message) => {
3329
- log(_storm_software_config_tools_types.LogLevelLabel.FATAL, normalizeMessage(message));
3384
+ log("error", normalizeMessage(message));
3330
3385
  };
3331
3386
  if (prop === "error") return (message) => {
3332
- log(_storm_software_config_tools_types.LogLevelLabel.ERROR, normalizeMessage(message));
3387
+ log("error", normalizeMessage(message));
3333
3388
  };
3334
3389
  if (prop === "warn") return (message) => {
3335
- log(_storm_software_config_tools_types.LogLevelLabel.WARN, normalizeMessage(message));
3390
+ log("warn", normalizeMessage(message));
3336
3391
  };
3337
3392
  if (prop === "info") return (message) => {
3338
- log(_storm_software_config_tools_types.LogLevelLabel.INFO, normalizeMessage(message));
3393
+ log("info", normalizeMessage(message));
3339
3394
  };
3340
3395
  if (prop === "debug") return (message) => {
3341
- log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, normalizeMessage(message));
3396
+ log("debug", normalizeMessage(message));
3342
3397
  };
3343
3398
  if (prop === "trace") return (message) => {
3344
- log(_storm_software_config_tools_types.LogLevelLabel.TRACE, normalizeMessage(message));
3399
+ log("trace", normalizeMessage(message));
3345
3400
  };
3346
3401
  return environment[prop];
3347
3402
  },
@@ -3360,7 +3415,7 @@ function createPluginContext(pluginId, plugin, environment) {
3360
3415
  "addPlugin",
3361
3416
  "selectHooks"
3362
3417
  ].includes(prop)) {
3363
- log(_storm_software_config_tools_types.LogLevelLabel.WARN, `Cannot set read-only property "${String(prop)}"`);
3418
+ log("warn", `Cannot set read-only property "${String(prop)}"`);
3364
3419
  return false;
3365
3420
  }
3366
3421
  environment[prop] = value;
@@ -3412,52 +3467,28 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
3412
3467
  return this.#hooks;
3413
3468
  }
3414
3469
  /**
3415
- * Create a new logger instance
3470
+ * Create a new log function with the specified configuration, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
3416
3471
  *
3417
- * @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.
3418
- * @returns A logger function
3472
+ * @param config - Optional configuration for the log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
3473
+ * @returns A log function that can be used to log messages with the specified configuration.
3419
3474
  */
3420
- createLog(source = null) {
3421
- return (level, ...args) => {
3422
- process.send?.({
3423
- id: (0, _stryke_unique_id_uuid.uuid)(),
3424
- type: "write-log",
3425
- executionId: this.options.executionId,
3426
- executionIndex: this.options.executionIndex,
3427
- timestamp: Date.now(),
3428
- payload: {
3429
- level,
3430
- source,
3431
- environment: this.environment?.name,
3432
- args
3433
- }
3434
- });
3435
- };
3475
+ createLog(config) {
3476
+ return super.createLog({
3477
+ ...config,
3478
+ environment: this.environment?.name
3479
+ });
3436
3480
  }
3437
3481
  /**
3438
- * Extend the current logger instance with a new name
3482
+ * Extend the current log function instance with a new name
3439
3483
  *
3440
- * @param source - The name of the source to use for the extended logger instance
3441
- * @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.
3442
- * @returns A logger function
3484
+ * @param config - The configuration for the extended log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the log function instance according to your needs.
3485
+ * @returns A log function
3443
3486
  */
3444
- extendLog(source, plugin) {
3445
- return (level, ...args) => {
3446
- process.send?.({
3447
- id: (0, _stryke_unique_id_uuid.uuid)(),
3448
- type: "write-log",
3449
- executionId: this.options.executionId,
3450
- executionIndex: this.options.executionIndex,
3451
- timestamp: Date.now(),
3452
- payload: {
3453
- level,
3454
- source,
3455
- plugin,
3456
- environment: this.environment?.name,
3457
- args
3458
- }
3459
- });
3460
- };
3487
+ extendLog(config) {
3488
+ return super.extendLog({
3489
+ ...config,
3490
+ environment: this.environment?.name
3491
+ });
3461
3492
  }
3462
3493
  /**
3463
3494
  * 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.
@@ -3641,31 +3672,30 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
3641
3672
  super(options);
3642
3673
  }
3643
3674
  /**
3644
- * Create a new logger instance
3675
+ * Create a new log function with the specified configuration, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
3645
3676
  *
3646
- * @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.
3647
- * @returns A logger function
3677
+ * @param config - Optional configuration for the log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the logger instance according to your needs.
3678
+ * @returns A log function that can be used to log messages with the specified configuration.
3648
3679
  */
3649
- createLog(source = null) {
3650
- const logger = (0, _powerlines_core.createLog)(source, {
3651
- ...this.config,
3652
- logLevel: (0, _stryke_type_checks_is_null.isNull)(this.config.logLevel) ? "silent" : this.config.logLevel
3680
+ createLog(config) {
3681
+ return super.createLog({
3682
+ ...config,
3683
+ executionId: this.id,
3684
+ executionIndex: this.options.executionIndex
3685
+ });
3686
+ }
3687
+ /**
3688
+ * Extend the current log function instance with a new name
3689
+ *
3690
+ * @param config - The configuration for the extended log function instance, which can include properties such as log level, colors, and other metadata to be included with each log message. This allows you to customize the behavior and appearance of the log function instance according to your needs.
3691
+ * @returns A log function
3692
+ */
3693
+ extendLog(config) {
3694
+ return super.extendLog({
3695
+ ...config,
3696
+ executionId: this.id,
3697
+ executionIndex: this.options.executionIndex
3653
3698
  });
3654
- return (level, ...args) => {
3655
- logger(level, ...args);
3656
- process.send?.({
3657
- id: (0, _stryke_unique_id_uuid.uuid)(),
3658
- type: "write-log",
3659
- executionId: this.id,
3660
- executionIndex: this.options.executionIndex,
3661
- timestamp: Date.now(),
3662
- payload: {
3663
- source,
3664
- level,
3665
- args
3666
- }
3667
- });
3668
- };
3669
3699
  }
3670
3700
  /**
3671
3701
  * 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.