@powerlines/engine 0.43.30 → 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.
- package/dist/_internal/worker.cjs +195 -95
- package/dist/_internal/worker.mjs +198 -98
- package/dist/_internal/worker.mjs.map +1 -1
- package/dist/api.cjs +11 -8
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +11 -8
- package/dist/api.mjs.map +1 -1
- package/dist/{base-context-B9AROf66.cjs → base-context-5_AZZYFu.cjs} +27 -32
- package/dist/{base-context-D8a2XGIK.mjs → base-context-D_ZidDDm.mjs} +29 -34
- package/dist/base-context-D_ZidDDm.mjs.map +1 -0
- package/dist/context/index.cjs +3 -3
- package/dist/context/index.d.cts +67 -32
- package/dist/context/index.d.cts.map +1 -1
- package/dist/context/index.d.mts +67 -32
- package/dist/context/index.d.mts.map +1 -1
- package/dist/context/index.mjs +3 -3
- package/dist/{engine-context-DsA9XGVb.mjs → engine-context-PQ3BgcgR.mjs} +36 -11
- package/dist/engine-context-PQ3BgcgR.mjs.map +1 -0
- package/dist/{engine-context-qCVw66U_.cjs → engine-context-w4fts28j.cjs} +36 -10
- package/dist/{execution-context-CprxWvYn.cjs → execution-context-0GmpbWbs.cjs} +176 -71
- package/dist/{execution-context-CBJxP2B2.mjs → execution-context-zedP0h4Z.mjs} +179 -74
- package/dist/execution-context-zedP0h4Z.mjs.map +1 -0
- package/dist/index.cjs +140 -58
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +140 -58
- package/dist/index.mjs.map +1 -1
- package/dist/storage/index.cjs +1 -1
- package/dist/storage/index.d.mts +1 -1
- package/dist/storage/index.mjs +1 -1
- package/dist/typescript/index.d.mts +1 -1
- package/dist/{virtual-BNdKVkRw.cjs → virtual-1hYa9zCy.cjs} +1 -1
- package/dist/{virtual-gIlTc3Lj.mjs → virtual-CUgOdyIa.mjs} +2 -2
- package/dist/{virtual-gIlTc3Lj.mjs.map → virtual-CUgOdyIa.mjs.map} +1 -1
- package/package.json +3 -3
- package/dist/base-context-D8a2XGIK.mjs.map +0 -1
- package/dist/engine-context-DsA9XGVb.mjs.map +0 -1
- package/dist/execution-context-CBJxP2B2.mjs.map +0 -1
|
@@ -67,6 +67,8 @@ let _powerlines_core_constants = require("@powerlines/core/constants");
|
|
|
67
67
|
let _stryke_fs_json = require("@stryke/fs/json");
|
|
68
68
|
let _stryke_helpers_deep_clone = require("@stryke/helpers/deep-clone");
|
|
69
69
|
let _stryke_path_join = require("@stryke/path/join");
|
|
70
|
+
let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
|
|
71
|
+
let _powerlines_core = require("@powerlines/core");
|
|
70
72
|
let _powerlines_core_lib_entry = require("@powerlines/core/lib/entry");
|
|
71
73
|
let _stryke_fs_get_workspace_root = require("@stryke/fs/get-workspace-root");
|
|
72
74
|
let _stryke_hash = require("@stryke/hash");
|
|
@@ -74,15 +76,12 @@ let _stryke_hash_node = require("@stryke/hash/node");
|
|
|
74
76
|
let _stryke_http_fetch = require("@stryke/http/fetch");
|
|
75
77
|
let _stryke_path_is_equal = require("@stryke/path/is-equal");
|
|
76
78
|
let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
77
|
-
let _stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
78
|
-
let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
|
|
79
79
|
let bundle_require = require("bundle-require");
|
|
80
80
|
let compatx = require("compatx");
|
|
81
81
|
let flat_cache = require("flat-cache");
|
|
82
82
|
let oxc_parser = require("oxc-parser");
|
|
83
83
|
let undici = require("undici");
|
|
84
84
|
require("@stryke/fs/remove-file");
|
|
85
|
-
let _storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
86
85
|
let _stryke_capnp = require("@stryke/capnp");
|
|
87
86
|
_stryke_capnp = __toESM(_stryke_capnp, 1);
|
|
88
87
|
let _stryke_fs_buffer = require("@stryke/fs/buffer");
|
|
@@ -115,6 +114,7 @@ let _donedeal0_superdiff = require("@donedeal0/superdiff");
|
|
|
115
114
|
//#region src/_internal/helpers/environment.ts
|
|
116
115
|
function createEnvironment(name, config = {}) {
|
|
117
116
|
return (0, defu.default)(config.environments?.[name] ?? {}, {
|
|
117
|
+
environmentId: (0, _stryke_unique_id_uuid.uuid)(),
|
|
118
118
|
name,
|
|
119
119
|
title: config.title ?? (0, _stryke_string_format_title_case.titleCase)(config.name),
|
|
120
120
|
ssr: false,
|
|
@@ -1232,7 +1232,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
}));
|
|
1234
1234
|
} else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(FileSystem));
|
|
1235
|
-
result.#log(
|
|
1235
|
+
result.#log("debug", "Successfully completed virtual file system (VFS) initialization.");
|
|
1236
1236
|
return result;
|
|
1237
1237
|
}
|
|
1238
1238
|
/**
|
|
@@ -1266,7 +1266,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1266
1266
|
}
|
|
1267
1267
|
});
|
|
1268
1268
|
} else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(FileSystem));
|
|
1269
|
-
result.#log(
|
|
1269
|
+
result.#log("debug", "Successfully completed virtual file system (VFS) initialization.");
|
|
1270
1270
|
return result;
|
|
1271
1271
|
}
|
|
1272
1272
|
/**
|
|
@@ -1400,7 +1400,10 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1400
1400
|
return ret;
|
|
1401
1401
|
}, {});
|
|
1402
1402
|
}
|
|
1403
|
-
this.#log =
|
|
1403
|
+
this.#log = context.extendLog({
|
|
1404
|
+
source: "VFS",
|
|
1405
|
+
category: "fs"
|
|
1406
|
+
});
|
|
1404
1407
|
}
|
|
1405
1408
|
/**
|
|
1406
1409
|
* Asynchronously checks if a file exists in the virtual file system (VFS).
|
|
@@ -1527,7 +1530,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1527
1530
|
listSync(path) {
|
|
1528
1531
|
let resolvedPath = path;
|
|
1529
1532
|
if (resolvedPath.includes("*")) {
|
|
1530
|
-
this.#log(
|
|
1533
|
+
this.#log("warn", `Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
|
|
1531
1534
|
resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
|
|
1532
1535
|
}
|
|
1533
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));
|
|
@@ -1541,7 +1544,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1541
1544
|
async list(path) {
|
|
1542
1545
|
let resolvedPath = path;
|
|
1543
1546
|
if (resolvedPath.includes("*")) {
|
|
1544
|
-
this.#log(
|
|
1547
|
+
this.#log("warn", `Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
|
|
1545
1548
|
resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
|
|
1546
1549
|
}
|
|
1547
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));
|
|
@@ -1553,7 +1556,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1553
1556
|
*/
|
|
1554
1557
|
async remove(path) {
|
|
1555
1558
|
const normalizedPath = this.#normalizePath(path);
|
|
1556
|
-
this.#log(
|
|
1559
|
+
this.#log("trace", `Removing file: ${normalizedPath}`);
|
|
1557
1560
|
const { relativeKey, adapter } = this.#getStorage(normalizedPath);
|
|
1558
1561
|
if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) await adapter.remove(relativeKey);
|
|
1559
1562
|
else await adapter.clear(relativeKey);
|
|
@@ -1571,7 +1574,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1571
1574
|
*/
|
|
1572
1575
|
removeSync(path) {
|
|
1573
1576
|
const normalizedPath = this.#normalizePath(path);
|
|
1574
|
-
this.#log(
|
|
1577
|
+
this.#log("trace", `Removing file: ${normalizedPath}`);
|
|
1575
1578
|
const { relativeKey, adapter } = this.#getStorage(normalizedPath);
|
|
1576
1579
|
if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) adapter.removeSync(relativeKey);
|
|
1577
1580
|
else adapter.clearSync(relativeKey);
|
|
@@ -1717,7 +1720,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1717
1720
|
const filePath = await this.resolve(path, void 0, { isFile: true });
|
|
1718
1721
|
if (!filePath || !this.existsSync(filePath)) return;
|
|
1719
1722
|
const { adapter } = this.#getStorage(filePath);
|
|
1720
|
-
this.#log(
|
|
1723
|
+
this.#log("trace", `Reading ${adapter.name} file: ${filePath}`);
|
|
1721
1724
|
return await adapter.get(filePath) ?? void 0;
|
|
1722
1725
|
}
|
|
1723
1726
|
/**
|
|
@@ -1730,7 +1733,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1730
1733
|
const filePath = this.resolveSync(path, void 0, { isFile: true });
|
|
1731
1734
|
if (!filePath || !this.existsSync(filePath)) return;
|
|
1732
1735
|
const { adapter } = this.#getStorage(filePath);
|
|
1733
|
-
this.#log(
|
|
1736
|
+
this.#log("trace", `Reading ${adapter.name} file: ${filePath}`);
|
|
1734
1737
|
return adapter.getSync(filePath) ?? void 0;
|
|
1735
1738
|
}
|
|
1736
1739
|
/**
|
|
@@ -1745,15 +1748,15 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1745
1748
|
const meta = options.meta ?? {};
|
|
1746
1749
|
const resolvedPath = await this.resolve(this.#normalizePath(path)) || path;
|
|
1747
1750
|
const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
|
|
1748
|
-
this.#log(
|
|
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)})`);
|
|
1749
1752
|
let code = data;
|
|
1750
1753
|
try {
|
|
1751
1754
|
if (!options.skipFormat) code = await (0, _powerlines_core_lib_utilities_format.format)(this.#context, resolvedPath, data);
|
|
1752
1755
|
} catch (err) {
|
|
1753
|
-
if (DEFAULT_EXTENSIONS.includes((0, _stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#log(
|
|
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}`);
|
|
1754
1757
|
code = data;
|
|
1755
1758
|
}
|
|
1756
|
-
this.#log(
|
|
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)})`);
|
|
1757
1760
|
const id = this.#normalizeId(meta.id || resolvedPath);
|
|
1758
1761
|
this.metadata[id] = {
|
|
1759
1762
|
type: "normal",
|
|
@@ -1776,7 +1779,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1776
1779
|
const meta = options.meta ?? {};
|
|
1777
1780
|
const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;
|
|
1778
1781
|
const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
|
|
1779
|
-
this.#log(
|
|
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)})`);
|
|
1780
1783
|
const id = this.#normalizeId(meta.id || resolvedPath);
|
|
1781
1784
|
this.metadata[id] = {
|
|
1782
1785
|
type: "normal",
|
|
@@ -1940,7 +1943,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1940
1943
|
async dispose() {
|
|
1941
1944
|
if (!this.#isDisposed) {
|
|
1942
1945
|
this.#isDisposed = true;
|
|
1943
|
-
this.#log(
|
|
1946
|
+
this.#log("debug", "Disposing virtual file system...");
|
|
1944
1947
|
await this.remove((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"));
|
|
1945
1948
|
const message = new _stryke_capnp.Message();
|
|
1946
1949
|
const fs = message.initRoot(FileSystem);
|
|
@@ -1975,9 +1978,15 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1975
1978
|
await (0, _stryke_fs_buffer.writeFileBuffer)((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
|
|
1976
1979
|
if (!this.#context.config.skipCache) this.resolverCache.save(true);
|
|
1977
1980
|
await Promise.all(this.#getStorages().map(async (storage) => storage.adapter.dispose()));
|
|
1978
|
-
this.#log(
|
|
1981
|
+
this.#log("trace", "Virtual file system has been disposed.");
|
|
1979
1982
|
}
|
|
1980
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
|
+
*/
|
|
1981
1990
|
async [Symbol.asyncDispose]() {
|
|
1982
1991
|
return this.dispose();
|
|
1983
1992
|
}
|
|
@@ -2150,7 +2159,6 @@ function createResolver(options) {
|
|
|
2150
2159
|
//#region src/context/base-context.ts
|
|
2151
2160
|
var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
2152
2161
|
#timestamp = Date.now();
|
|
2153
|
-
#logLevel = "info";
|
|
2154
2162
|
/**
|
|
2155
2163
|
* The path to the Powerlines package
|
|
2156
2164
|
*/
|
|
@@ -2175,24 +2183,16 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2175
2183
|
* A timestamp representing when the context was initialized
|
|
2176
2184
|
*/
|
|
2177
2185
|
get timestamp() {
|
|
2178
|
-
return
|
|
2186
|
+
return this.#timestamp;
|
|
2179
2187
|
}
|
|
2180
2188
|
get logLevel() {
|
|
2181
|
-
return this
|
|
2182
|
-
}
|
|
2183
|
-
set logLevel(level) {
|
|
2184
|
-
this.#logLevel = level;
|
|
2189
|
+
return (0, _powerlines_core_plugin_utils.resolveLogLevel)(this.options.logLevel, this.options.mode);
|
|
2185
2190
|
}
|
|
2186
2191
|
/**
|
|
2187
2192
|
* The logger function
|
|
2188
2193
|
*/
|
|
2189
2194
|
get log() {
|
|
2190
|
-
|
|
2191
|
-
if (!this.logger || this.logger.level !== level) this.logger = {
|
|
2192
|
-
log: this.createLog(),
|
|
2193
|
-
level
|
|
2194
|
-
};
|
|
2195
|
-
return this.logger.log;
|
|
2195
|
+
return this.createLog();
|
|
2196
2196
|
}
|
|
2197
2197
|
/**
|
|
2198
2198
|
* The environment paths for the project
|
|
@@ -2223,7 +2223,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2223
2223
|
* @param message - The message to log.
|
|
2224
2224
|
*/
|
|
2225
2225
|
fatal(message) {
|
|
2226
|
-
this.log(
|
|
2226
|
+
this.log("error", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
|
|
2227
2227
|
}
|
|
2228
2228
|
/**
|
|
2229
2229
|
* A logging function for error messages
|
|
@@ -2231,7 +2231,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2231
2231
|
* @param message - The message to log.
|
|
2232
2232
|
*/
|
|
2233
2233
|
error(message) {
|
|
2234
|
-
this.log(
|
|
2234
|
+
this.log("error", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
|
|
2235
2235
|
}
|
|
2236
2236
|
/**
|
|
2237
2237
|
* A logging function for warning messages
|
|
@@ -2239,7 +2239,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2239
2239
|
* @param message - The message to log.
|
|
2240
2240
|
*/
|
|
2241
2241
|
warn(message) {
|
|
2242
|
-
this.log(
|
|
2242
|
+
this.log("warn", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
|
|
2243
2243
|
}
|
|
2244
2244
|
/**
|
|
2245
2245
|
* A logging function for informational messages
|
|
@@ -2247,7 +2247,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2247
2247
|
* @param message - The message to log.
|
|
2248
2248
|
*/
|
|
2249
2249
|
info(message) {
|
|
2250
|
-
this.log(
|
|
2250
|
+
this.log("info", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
|
|
2251
2251
|
}
|
|
2252
2252
|
/**
|
|
2253
2253
|
* A logging function for debug messages
|
|
@@ -2255,7 +2255,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2255
2255
|
* @param message - The message to log.
|
|
2256
2256
|
*/
|
|
2257
2257
|
debug(message) {
|
|
2258
|
-
this.log(
|
|
2258
|
+
this.log("debug", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
|
|
2259
2259
|
}
|
|
2260
2260
|
/**
|
|
2261
2261
|
* A logging function for trace messages
|
|
@@ -2263,7 +2263,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2263
2263
|
* @param message - The message to log.
|
|
2264
2264
|
*/
|
|
2265
2265
|
trace(message) {
|
|
2266
|
-
this.log(
|
|
2266
|
+
this.log("trace", (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
|
|
2267
2267
|
}
|
|
2268
2268
|
/**
|
|
2269
2269
|
* A function to create a timer for measuring the duration of asynchronous operations
|
|
@@ -2283,29 +2283,32 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2283
2283
|
const startDuration = performance.now();
|
|
2284
2284
|
return () => {
|
|
2285
2285
|
const duration = performance.now() - startDuration;
|
|
2286
|
-
this.log(
|
|
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))}`);
|
|
2287
2290
|
};
|
|
2288
2291
|
}
|
|
2289
2292
|
/**
|
|
2290
2293
|
* Create a new logger instance
|
|
2291
2294
|
*
|
|
2292
|
-
* @param
|
|
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.
|
|
2293
2296
|
* @returns A logger function
|
|
2294
2297
|
*/
|
|
2295
|
-
createLog(
|
|
2296
|
-
return (0, _powerlines_core_lib_logger.
|
|
2298
|
+
createLog(config) {
|
|
2299
|
+
return (0, _powerlines_core_lib_logger.createLogFn)({
|
|
2297
2300
|
...this.options,
|
|
2298
|
-
|
|
2301
|
+
...config
|
|
2299
2302
|
});
|
|
2300
2303
|
}
|
|
2301
2304
|
/**
|
|
2302
|
-
* Extend the current logger instance with a new
|
|
2305
|
+
* Extend the current logger instance with a new source
|
|
2303
2306
|
*
|
|
2304
|
-
* @param
|
|
2305
|
-
* @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.
|
|
2306
2309
|
*/
|
|
2307
|
-
extendLog(
|
|
2308
|
-
return (0, _powerlines_core_lib_logger.
|
|
2310
|
+
extendLog(config) {
|
|
2311
|
+
return (0, _powerlines_core_lib_logger.extendLogFn)(this.log, config);
|
|
2309
2312
|
}
|
|
2310
2313
|
/**
|
|
2311
2314
|
* A logger function specific to this context
|
|
@@ -2320,18 +2323,19 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2320
2323
|
* @param options - The configuration options to initialize the context with
|
|
2321
2324
|
*/
|
|
2322
2325
|
async init(options = {}) {
|
|
2323
|
-
this.inputOptions = options;
|
|
2326
|
+
this.inputOptions = { ...options };
|
|
2324
2327
|
if (!this.powerlinesPath) {
|
|
2325
2328
|
const powerlinesPath = await (0, _stryke_fs_resolve.resolvePackage)("powerlines");
|
|
2326
2329
|
if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
|
|
2327
2330
|
this.powerlinesPath = powerlinesPath;
|
|
2328
2331
|
}
|
|
2329
2332
|
const cwd = options.cwd || this.options?.cwd || process.cwd();
|
|
2330
|
-
const root = (options.root || this.options?.root) && (options.root || this.options.root).replace(/^\.\/?/, "") && !(0, _stryke_path_is_equal.isEqual)(options.root || this.options.root, cwd) ? options.root || this.options.root : ".";
|
|
2333
|
+
const root = (0, _stryke_path_replace.replacePath)((options.root || this.options?.root) && (options.root || this.options.root).replace(/^\.\/?/, "") && !(0, _stryke_path_is_equal.isEqual)(options.root || this.options.root, cwd) ? options.root || this.options.root : ".", cwd);
|
|
2331
2334
|
this.options = (0, defu.default)({
|
|
2332
2335
|
root,
|
|
2333
2336
|
cwd,
|
|
2334
2337
|
mode: options.mode,
|
|
2338
|
+
logLevel: options.logLevel,
|
|
2335
2339
|
framework: options.framework,
|
|
2336
2340
|
organization: options.organization,
|
|
2337
2341
|
configFile: options.configFile
|
|
@@ -2493,7 +2497,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2493
2497
|
buildId: this.#buildId,
|
|
2494
2498
|
releaseId: this.#releaseId,
|
|
2495
2499
|
checksum: this.#checksum,
|
|
2496
|
-
timestamp: this.timestamp
|
|
2500
|
+
timestamp: this.timestamp,
|
|
2497
2501
|
rootHash: (0, _stryke_hash.murmurhash)({
|
|
2498
2502
|
workspaceRoot: this.options?.cwd,
|
|
2499
2503
|
root: this.config?.root
|
|
@@ -2651,6 +2655,60 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2651
2655
|
this.options = options;
|
|
2652
2656
|
}
|
|
2653
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
|
+
/**
|
|
2654
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.
|
|
2655
2713
|
*
|
|
2656
2714
|
* @remarks
|
|
@@ -2659,22 +2717,10 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2659
2717
|
* @returns A promise that resolves to the cloned context.
|
|
2660
2718
|
*/
|
|
2661
2719
|
async clone() {
|
|
2662
|
-
const clone = await PowerlinesContext.fromOptions(this.
|
|
2720
|
+
const clone = await PowerlinesContext.fromOptions(this.options);
|
|
2663
2721
|
return this.copyTo(clone);
|
|
2664
2722
|
}
|
|
2665
2723
|
/**
|
|
2666
|
-
* Create a new logger instance
|
|
2667
|
-
*
|
|
2668
|
-
* @param name - The name to use for the logger instance
|
|
2669
|
-
* @returns A logger function
|
|
2670
|
-
*/
|
|
2671
|
-
createLog(name = null) {
|
|
2672
|
-
return (0, _powerlines_core_lib_logger.createLog)(name, {
|
|
2673
|
-
...this.config,
|
|
2674
|
-
logLevel: (0, _stryke_type_checks_is_null.isNull)(this.logLevel) ? "silent" : this.logLevel
|
|
2675
|
-
});
|
|
2676
|
-
}
|
|
2677
|
-
/**
|
|
2678
2724
|
* A function to perform HTTP fetch requests
|
|
2679
2725
|
*
|
|
2680
2726
|
* @remarks
|
|
@@ -3050,6 +3096,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3050
3096
|
for (const [key, value] of Object.entries(this)) if (!SKIP_CLONING_PROPS.includes(key)) if ((0, _stryke_type_checks_is_object.isObject)(value) || Array.isArray(value)) context[key] = (0, _stryke_helpers_deep_clone.deepClone)(value);
|
|
3051
3097
|
else context[key] = value;
|
|
3052
3098
|
context.inputOptions = (0, _stryke_helpers_deep_clone.deepClone)(this.inputOptions);
|
|
3099
|
+
context.options = (0, _stryke_helpers_deep_clone.deepClone)(this.options);
|
|
3053
3100
|
context.dependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.dependencies);
|
|
3054
3101
|
context.devDependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.devDependencies);
|
|
3055
3102
|
context.persistedMeta = this.persistedMeta ? (0, _stryke_helpers_deep_clone.deepClone)(this.persistedMeta) : void 0;
|
|
@@ -3071,7 +3118,8 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3071
3118
|
*/
|
|
3072
3119
|
async init(options = {}) {
|
|
3073
3120
|
await super.init(options);
|
|
3074
|
-
this.options.
|
|
3121
|
+
this.options.executionId = options.executionId ?? this.options.executionId;
|
|
3122
|
+
this.options.executionIndex = options.executionIndex ?? this.options.executionIndex ?? 0;
|
|
3075
3123
|
const projectJsonPath = (0, _stryke_path_join.joinPaths)(this.options.cwd, this.options.root, "project.json");
|
|
3076
3124
|
if ((0, _stryke_fs_exists.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs_json.readJsonFile)(projectJsonPath);
|
|
3077
3125
|
const packageJsonPath = (0, _stryke_path_join.joinPaths)(this.options.cwd, this.options.root, "package.json");
|
|
@@ -3080,7 +3128,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3080
3128
|
this.options.organization ??= (0, _stryke_type_checks_is_set_object.isSetObject)(this.packageJson?.author) ? (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author?.name) : (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author);
|
|
3081
3129
|
}
|
|
3082
3130
|
this.#checksum = await this.generateChecksum((0, _stryke_path_join.joinPaths)(this.options.cwd, this.options.root));
|
|
3083
|
-
const userConfig = this.configFile.config ? Array.isArray(this.configFile.config) && this.configFile.config.length > this.options.
|
|
3131
|
+
const userConfig = this.configFile.config ? Array.isArray(this.configFile.config) && this.configFile.config.length > this.options.executionIndex ? this.configFile.config[this.options.executionIndex] : this.configFile.config : {};
|
|
3084
3132
|
this.resolvedConfig = {
|
|
3085
3133
|
...this.options,
|
|
3086
3134
|
...userConfig,
|
|
@@ -3100,10 +3148,6 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3100
3148
|
this.config.framework = "powerlines";
|
|
3101
3149
|
}
|
|
3102
3150
|
this.resolvedConfig.compatibilityDate = (0, compatx.resolveCompatibilityDates)(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
|
|
3103
|
-
this.logger = {
|
|
3104
|
-
log: this.createLog(this.config.name),
|
|
3105
|
-
level: (0, _stryke_type_checks_is_null.isNull)(this.logLevel) ? "silent" : this.logLevel
|
|
3106
|
-
};
|
|
3107
3151
|
this.config.input = (0, _powerlines_core_lib_entry.getUniqueInputs)(this.config.input);
|
|
3108
3152
|
if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
|
|
3109
3153
|
this.config.title ??= (0, _stryke_string_format_title_case.titleCase)(this.config.name);
|
|
@@ -3111,16 +3155,17 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3111
3155
|
if (this.config.userConfig.resolve?.noExternal) this.config.userConfig.resolve.noExternal = (0, _stryke_helpers_get_unique.getUnique)(this.config.userConfig.resolve.noExternal);
|
|
3112
3156
|
if (this.config.resolve.external) this.config.resolve.external = (0, _stryke_helpers_get_unique.getUnique)(this.config.resolve.external);
|
|
3113
3157
|
if (this.config.resolve.noExternal) this.config.resolve.noExternal = (0, _stryke_helpers_get_unique.getUnique)(this.config.resolve.noExternal);
|
|
3114
|
-
this.config.plugins = (this.config.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
|
|
3158
|
+
this.config.plugins = (this.config.plugins ?? []).flatMap((plugin) => (0, _stryke_convert_to_array.toArray)(plugin)).filter(Boolean).reduce((ret, plugin) => {
|
|
3115
3159
|
if ((0, _powerlines_core_plugin_utils.isPlugin)(plugin) && (0, _powerlines_core_plugin_utils.isDuplicate)(plugin, ret.filter((p) => (0, _powerlines_core_plugin_utils.isPlugin)(p)))) return ret;
|
|
3116
3160
|
ret.push(plugin);
|
|
3117
3161
|
return ret;
|
|
3118
3162
|
}, []);
|
|
3119
|
-
if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel =
|
|
3120
|
-
else this.config.logLevel =
|
|
3121
|
-
|
|
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);
|
|
3122
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);
|
|
3123
|
-
this.resolvedConfig.output = (0, defu.default)(this.
|
|
3168
|
+
this.resolvedConfig.output = (0, defu.default)(this.config.output ?? {}, {
|
|
3124
3169
|
path: (0, _stryke_path_join.joinPaths)(this.config.root, "dist"),
|
|
3125
3170
|
copy: { assets: [
|
|
3126
3171
|
{ glob: "LICENSE" },
|
|
@@ -3143,7 +3188,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3143
3188
|
if (!this.config.root.replace(/^\.\/?/, "")) this.config.output.copy.path = this.config.output.copy.path ? (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, this.config.output.copy.path), this.config.cwd) : this.config.output.path;
|
|
3144
3189
|
else this.config.output.copy.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, this.config.output.copy.path || (0, _stryke_path_join.joinPaths)("dist", this.config.root)), this.config.cwd);
|
|
3145
3190
|
}
|
|
3146
|
-
if (this.config.output.dts !== false && this.config.output.types !== false) this.config.output.types = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, this.config.output.types || (0, _stryke_path_join.joinPaths)(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`)), this.config.cwd);
|
|
3191
|
+
if (this.config.output.dts !== false && this.config.output.types !== false) this.config.output.types = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, this.config.userConfig?.output?.types || this.config.inlineConfig?.output?.types || this.config.pluginConfig?.output?.types || (0, _stryke_path_join.joinPaths)(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`)), this.config.cwd);
|
|
3147
3192
|
if (this.config.output.copy && this.config.output.copy.path && this.config.output.copy.assets && Array.isArray(this.config.output.copy.assets)) this.config.output.copy.assets = (0, _stryke_helpers_get_unique.getUniqueBy)(this.config.output.copy.assets.map((asset) => {
|
|
3148
3193
|
return {
|
|
3149
3194
|
glob: (0, _stryke_type_checks_is_set_object.isSetObject)(asset) ? asset.glob : asset,
|
|
@@ -3165,6 +3210,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3165
3210
|
}));
|
|
3166
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;
|
|
3167
3212
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
3213
|
+
this.extendLog({ category: "config" })("debug", `Resolved Powerlines configuration object: \n${JSON.stringify(this.resolvedConfig, null, 2)}`);
|
|
3168
3214
|
}
|
|
3169
3215
|
};
|
|
3170
3216
|
|
|
@@ -3305,15 +3351,16 @@ function extractHooks(context, hooks, plugin, key, parentKey) {
|
|
|
3305
3351
|
/**
|
|
3306
3352
|
* Create a Proxy-based PluginContext
|
|
3307
3353
|
*
|
|
3354
|
+
* @param pluginId - The unique identifier of the plugin
|
|
3308
3355
|
* @param plugin - The plugin instance
|
|
3309
3356
|
* @param environment - The environment context
|
|
3310
3357
|
* @returns The proxied plugin context
|
|
3311
3358
|
*/
|
|
3312
|
-
function createPluginContext(plugin, environment) {
|
|
3359
|
+
function createPluginContext(pluginId, plugin, environment) {
|
|
3313
3360
|
const normalizeMessage = (message) => {
|
|
3314
3361
|
return (0, _stryke_type_checks_is_string.isString)(message) ? message : message.message;
|
|
3315
3362
|
};
|
|
3316
|
-
const log = environment.extendLog(plugin.name.replaceAll(":", " - "));
|
|
3363
|
+
const log = environment.extendLog({ plugin: plugin.name.replaceAll(":", " - ") });
|
|
3317
3364
|
const callHookFn = async (hook, options, ...args) => {
|
|
3318
3365
|
return environment.$$internal.api.callHook(hook, {
|
|
3319
3366
|
sequential: true,
|
|
@@ -3331,30 +3378,32 @@ function createPluginContext(plugin, environment) {
|
|
|
3331
3378
|
callHook: callHookFn,
|
|
3332
3379
|
meta
|
|
3333
3380
|
};
|
|
3381
|
+
if (prop === "id") return pluginId;
|
|
3334
3382
|
if (prop === "log" || prop === "logger") return log;
|
|
3335
3383
|
if (prop === "fatal") return (message) => {
|
|
3336
|
-
log(
|
|
3384
|
+
log("error", normalizeMessage(message));
|
|
3337
3385
|
};
|
|
3338
3386
|
if (prop === "error") return (message) => {
|
|
3339
|
-
log(
|
|
3387
|
+
log("error", normalizeMessage(message));
|
|
3340
3388
|
};
|
|
3341
3389
|
if (prop === "warn") return (message) => {
|
|
3342
|
-
log(
|
|
3390
|
+
log("warn", normalizeMessage(message));
|
|
3343
3391
|
};
|
|
3344
3392
|
if (prop === "info") return (message) => {
|
|
3345
|
-
log(
|
|
3393
|
+
log("info", normalizeMessage(message));
|
|
3346
3394
|
};
|
|
3347
3395
|
if (prop === "debug") return (message) => {
|
|
3348
|
-
log(
|
|
3396
|
+
log("debug", normalizeMessage(message));
|
|
3349
3397
|
};
|
|
3350
3398
|
if (prop === "trace") return (message) => {
|
|
3351
|
-
log(
|
|
3399
|
+
log("trace", normalizeMessage(message));
|
|
3352
3400
|
};
|
|
3353
3401
|
return environment[prop];
|
|
3354
3402
|
},
|
|
3355
3403
|
set(_, prop, value) {
|
|
3356
3404
|
if ([
|
|
3357
3405
|
"$$internal",
|
|
3406
|
+
"id",
|
|
3358
3407
|
"environment",
|
|
3359
3408
|
"config",
|
|
3360
3409
|
"log",
|
|
@@ -3366,7 +3415,7 @@ function createPluginContext(plugin, environment) {
|
|
|
3366
3415
|
"addPlugin",
|
|
3367
3416
|
"selectHooks"
|
|
3368
3417
|
].includes(prop)) {
|
|
3369
|
-
log(
|
|
3418
|
+
log("warn", `Cannot set read-only property "${String(prop)}"`);
|
|
3370
3419
|
return false;
|
|
3371
3420
|
}
|
|
3372
3421
|
environment[prop] = value;
|
|
@@ -3406,17 +3455,10 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3406
3455
|
*/
|
|
3407
3456
|
plugins = [];
|
|
3408
3457
|
/**
|
|
3409
|
-
*
|
|
3410
|
-
*
|
|
3411
|
-
* @param name - The name to use for the logger instance
|
|
3412
|
-
* @returns A logger function
|
|
3458
|
+
* The unique identifier of the environment associated with this context, which can be used for logging and other purposes to distinguish between different environments in the same process.
|
|
3413
3459
|
*/
|
|
3414
|
-
|
|
3415
|
-
return
|
|
3416
|
-
...this.config,
|
|
3417
|
-
logLevel: (0, _stryke_type_checks_is_null.isNull)(this.config.logLevel) ? "silent" : this.config.logLevel,
|
|
3418
|
-
environment: this.environment?.name
|
|
3419
|
-
});
|
|
3460
|
+
get id() {
|
|
3461
|
+
return this.environment.environmentId;
|
|
3420
3462
|
}
|
|
3421
3463
|
/**
|
|
3422
3464
|
* The hooks registered by plugins in this environment
|
|
@@ -3425,6 +3467,30 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3425
3467
|
return this.#hooks;
|
|
3426
3468
|
}
|
|
3427
3469
|
/**
|
|
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.
|
|
3471
|
+
*
|
|
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.
|
|
3474
|
+
*/
|
|
3475
|
+
createLog(config) {
|
|
3476
|
+
return super.createLog({
|
|
3477
|
+
...config,
|
|
3478
|
+
environment: this.environment?.name
|
|
3479
|
+
});
|
|
3480
|
+
}
|
|
3481
|
+
/**
|
|
3482
|
+
* Extend the current log function instance with a new name
|
|
3483
|
+
*
|
|
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
|
|
3486
|
+
*/
|
|
3487
|
+
extendLog(config) {
|
|
3488
|
+
return super.extendLog({
|
|
3489
|
+
...config,
|
|
3490
|
+
environment: this.environment?.name
|
|
3491
|
+
});
|
|
3492
|
+
}
|
|
3493
|
+
/**
|
|
3428
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.
|
|
3429
3495
|
*
|
|
3430
3496
|
* @remarks
|
|
@@ -3454,8 +3520,10 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3454
3520
|
if ((0, _powerlines_core_plugin_utils.isPluginConfig)(result)) return this.$$internal.addPlugin(result);
|
|
3455
3521
|
resolvedPlugin = (0, _powerlines_core_plugin_utils.isPlugin)(result) ? result : plugin;
|
|
3456
3522
|
}
|
|
3457
|
-
const
|
|
3523
|
+
const pluginId = (0, _stryke_unique_id_uuid.uuid)();
|
|
3524
|
+
const context = createPluginContext(pluginId, resolvedPlugin, this);
|
|
3458
3525
|
this.plugins.push({
|
|
3526
|
+
pluginId,
|
|
3459
3527
|
plugin: resolvedPlugin,
|
|
3460
3528
|
context
|
|
3461
3529
|
});
|
|
@@ -3581,6 +3649,12 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
3581
3649
|
for (const environment of Object.values(this.environments)) environment.$$internal = super.$$internal;
|
|
3582
3650
|
}
|
|
3583
3651
|
/**
|
|
3652
|
+
* The unique identifier of the execution context, which can be used for logging and other purposes to distinguish between different executions in the same process.
|
|
3653
|
+
*/
|
|
3654
|
+
get id() {
|
|
3655
|
+
return this.options.executionId;
|
|
3656
|
+
}
|
|
3657
|
+
/**
|
|
3584
3658
|
* A record of all environments by name
|
|
3585
3659
|
*/
|
|
3586
3660
|
get environments() {
|
|
@@ -3598,6 +3672,32 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
3598
3672
|
super(options);
|
|
3599
3673
|
}
|
|
3600
3674
|
/**
|
|
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.
|
|
3676
|
+
*
|
|
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.
|
|
3679
|
+
*/
|
|
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
|
|
3698
|
+
});
|
|
3699
|
+
}
|
|
3700
|
+
/**
|
|
3601
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.
|
|
3602
3702
|
*
|
|
3603
3703
|
* @remarks
|
|
@@ -4459,7 +4559,7 @@ ${formatTypes(code)}
|
|
|
4459
4559
|
addPlugin: api.addPlugin.bind(api)
|
|
4460
4560
|
};
|
|
4461
4561
|
const timer = api.context.timer("Initialization");
|
|
4462
|
-
for (const plugin of api.context.config.plugins.
|
|
4562
|
+
for (const plugin of api.context.config.plugins.flatMap((p) => (0, _stryke_convert_to_array.toArray)(p)) ?? []) await api.addPlugin(plugin);
|
|
4463
4563
|
if (api.context.plugins.length === 0) api.context.warn("No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.");
|
|
4464
4564
|
else api.context.info(`Loaded ${api.context.plugins.length} ${(0, _stryke_string_format_title_case.titleCase)(api.context.config.framework)} plugin${api.context.plugins.length > 1 ? "s" : ""}: \n${api.context.plugins.map((plugin, index) => ` ${index + 1}. ${(0, _powerlines_core_lib_logger.colorText)(plugin.name)}`).join("\n")}`);
|
|
4465
4565
|
const pluginConfig = await api.callHook("config", {
|