@powerlines/engine 0.44.0 → 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.
- package/dist/_internal/worker.cjs +155 -167
- package/dist/_internal/worker.d.cts.map +1 -1
- package/dist/_internal/worker.d.mts.map +1 -1
- package/dist/_internal/worker.mjs +155 -167
- package/dist/_internal/worker.mjs.map +1 -1
- package/dist/api.cjs +4 -4
- package/dist/api.mjs +2 -2
- package/dist/api.mjs.map +1 -1
- package/dist/{base-context-5_AZZYFu.cjs → base-context-DkGTyGX0.cjs} +29 -33
- package/dist/{base-context-D_ZidDDm.mjs → base-context-Dv5OTHxZ.mjs} +30 -34
- package/dist/base-context-Dv5OTHxZ.mjs.map +1 -0
- package/dist/context/index.cjs +3 -3
- package/dist/context/index.d.cts +38 -52
- package/dist/context/index.d.cts.map +1 -1
- package/dist/context/index.d.mts +38 -52
- package/dist/context/index.d.mts.map +1 -1
- package/dist/context/index.mjs +3 -3
- package/dist/{engine-context-w4fts28j.cjs → engine-context-CDSR7PHF.cjs} +1 -1
- package/dist/{engine-context-PQ3BgcgR.mjs → engine-context-CytME-Ht.mjs} +2 -2
- package/dist/{engine-context-PQ3BgcgR.mjs.map → engine-context-CytME-Ht.mjs.map} +1 -1
- package/dist/{execution-context-0GmpbWbs.cjs → execution-context-B-CVP76S.cjs} +119 -111
- package/dist/{execution-context-zedP0h4Z.mjs → execution-context-F7RyGqff.mjs} +121 -113
- package/dist/execution-context-F7RyGqff.mjs.map +1 -0
- package/dist/index.cjs +9 -14
- package/dist/index.mjs +9 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/base-context-D_ZidDDm.mjs.map +0 -1
- package/dist/execution-context-zedP0h4Z.mjs.map +0 -1
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-C0xms8kb.cjs');
|
|
2
|
-
const require_base_context = require('./base-context-
|
|
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 _powerlines_core = require("@powerlines/core");
|
|
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");
|
|
17
15
|
let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
|
|
16
|
+
let _powerlines_core_plugin_utils_logging = require("@powerlines/core/plugin-utils/logging");
|
|
18
17
|
let _stryke_path_is_equal = require("@stryke/path/is-equal");
|
|
19
18
|
let _stryke_path_replace = require("@stryke/path/replace");
|
|
20
19
|
let chalk = require("chalk");
|
|
@@ -46,6 +45,7 @@ let flat_cache = require("flat-cache");
|
|
|
46
45
|
let oxc_parser = require("oxc-parser");
|
|
47
46
|
let undici = require("undici");
|
|
48
47
|
require("@stryke/fs/remove-file");
|
|
48
|
+
let _powerlines_core = require("@powerlines/core");
|
|
49
49
|
let _stryke_capnp = require("@stryke/capnp");
|
|
50
50
|
_stryke_capnp = require_chunk.__toESM(_stryke_capnp, 1);
|
|
51
51
|
let _stryke_fs_buffer = require("@stryke/fs/buffer");
|
|
@@ -147,6 +147,40 @@ async function writeMetaFile(context) {
|
|
|
147
147
|
await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
|
|
148
148
|
}
|
|
149
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
|
+
|
|
150
184
|
//#endregion
|
|
151
185
|
//#region src/_internal/helpers/constants.ts
|
|
152
186
|
const DEFAULT_EXTENSIONS = [
|
|
@@ -258,9 +292,9 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
258
292
|
*/
|
|
259
293
|
#context;
|
|
260
294
|
/**
|
|
261
|
-
* The file system's
|
|
295
|
+
* The file system's logger client utility.
|
|
262
296
|
*/
|
|
263
|
-
#
|
|
297
|
+
#logger;
|
|
264
298
|
/**
|
|
265
299
|
* Normalizes a given module id by resolving it against the built-ins path.
|
|
266
300
|
*
|
|
@@ -474,7 +508,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
474
508
|
}
|
|
475
509
|
}));
|
|
476
510
|
} else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(require_fs.FileSystem));
|
|
477
|
-
result.#
|
|
511
|
+
result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
|
|
478
512
|
return result;
|
|
479
513
|
}
|
|
480
514
|
/**
|
|
@@ -508,7 +542,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
508
542
|
}
|
|
509
543
|
});
|
|
510
544
|
} else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(require_fs.FileSystem));
|
|
511
|
-
result.#
|
|
545
|
+
result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
|
|
512
546
|
return result;
|
|
513
547
|
}
|
|
514
548
|
/**
|
|
@@ -642,7 +676,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
642
676
|
return ret;
|
|
643
677
|
}, {});
|
|
644
678
|
}
|
|
645
|
-
this.#
|
|
679
|
+
this.#logger = context.extendLogger({
|
|
646
680
|
source: "VFS",
|
|
647
681
|
category: "fs"
|
|
648
682
|
});
|
|
@@ -772,7 +806,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
772
806
|
listSync(path) {
|
|
773
807
|
let resolvedPath = path;
|
|
774
808
|
if (resolvedPath.includes("*")) {
|
|
775
|
-
this.#
|
|
809
|
+
this.#logger.warn(`Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
|
|
776
810
|
resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
|
|
777
811
|
}
|
|
778
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));
|
|
@@ -786,7 +820,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
786
820
|
async list(path) {
|
|
787
821
|
let resolvedPath = path;
|
|
788
822
|
if (resolvedPath.includes("*")) {
|
|
789
|
-
this.#
|
|
823
|
+
this.#logger.warn(`Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
|
|
790
824
|
resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
|
|
791
825
|
}
|
|
792
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));
|
|
@@ -798,7 +832,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
798
832
|
*/
|
|
799
833
|
async remove(path) {
|
|
800
834
|
const normalizedPath = this.#normalizePath(path);
|
|
801
|
-
this.#
|
|
835
|
+
this.#logger.trace(`Removing file: ${normalizedPath}`);
|
|
802
836
|
const { relativeKey, adapter } = this.#getStorage(normalizedPath);
|
|
803
837
|
if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) await adapter.remove(relativeKey);
|
|
804
838
|
else await adapter.clear(relativeKey);
|
|
@@ -816,7 +850,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
816
850
|
*/
|
|
817
851
|
removeSync(path) {
|
|
818
852
|
const normalizedPath = this.#normalizePath(path);
|
|
819
|
-
this.#
|
|
853
|
+
this.#logger.trace(`Removing file: ${normalizedPath}`);
|
|
820
854
|
const { relativeKey, adapter } = this.#getStorage(normalizedPath);
|
|
821
855
|
if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) adapter.removeSync(relativeKey);
|
|
822
856
|
else adapter.clearSync(relativeKey);
|
|
@@ -962,7 +996,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
962
996
|
const filePath = await this.resolve(path, void 0, { isFile: true });
|
|
963
997
|
if (!filePath || !this.existsSync(filePath)) return;
|
|
964
998
|
const { adapter } = this.#getStorage(filePath);
|
|
965
|
-
this.#
|
|
999
|
+
this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);
|
|
966
1000
|
return await adapter.get(filePath) ?? void 0;
|
|
967
1001
|
}
|
|
968
1002
|
/**
|
|
@@ -975,7 +1009,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
975
1009
|
const filePath = this.resolveSync(path, void 0, { isFile: true });
|
|
976
1010
|
if (!filePath || !this.existsSync(filePath)) return;
|
|
977
1011
|
const { adapter } = this.#getStorage(filePath);
|
|
978
|
-
this.#
|
|
1012
|
+
this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);
|
|
979
1013
|
return adapter.getSync(filePath) ?? void 0;
|
|
980
1014
|
}
|
|
981
1015
|
/**
|
|
@@ -990,15 +1024,15 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
990
1024
|
const meta = options.meta ?? {};
|
|
991
1025
|
const resolvedPath = await this.resolve(this.#normalizePath(path)) || path;
|
|
992
1026
|
const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
|
|
993
|
-
this.#
|
|
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)})`);
|
|
994
1028
|
let code = data;
|
|
995
1029
|
try {
|
|
996
1030
|
if (!options.skipFormat) code = await (0, _powerlines_core_lib_utilities_format.format)(this.#context, resolvedPath, data);
|
|
997
1031
|
} catch (err) {
|
|
998
|
-
if (DEFAULT_EXTENSIONS.includes((0, _stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#
|
|
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}`);
|
|
999
1033
|
code = data;
|
|
1000
1034
|
}
|
|
1001
|
-
this.#
|
|
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)})`);
|
|
1002
1036
|
const id = this.#normalizeId(meta.id || resolvedPath);
|
|
1003
1037
|
this.metadata[id] = {
|
|
1004
1038
|
type: "normal",
|
|
@@ -1021,7 +1055,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1021
1055
|
const meta = options.meta ?? {};
|
|
1022
1056
|
const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;
|
|
1023
1057
|
const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
|
|
1024
|
-
this.#
|
|
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)})`);
|
|
1025
1059
|
const id = this.#normalizeId(meta.id || resolvedPath);
|
|
1026
1060
|
this.metadata[id] = {
|
|
1027
1061
|
type: "normal",
|
|
@@ -1185,7 +1219,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1185
1219
|
async dispose() {
|
|
1186
1220
|
if (!this.#isDisposed) {
|
|
1187
1221
|
this.#isDisposed = true;
|
|
1188
|
-
this.#
|
|
1222
|
+
this.#logger.debug("Disposing virtual file system...");
|
|
1189
1223
|
await this.remove((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"));
|
|
1190
1224
|
const message = new _stryke_capnp.Message();
|
|
1191
1225
|
const fs = message.initRoot(require_fs.FileSystem);
|
|
@@ -1220,7 +1254,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1220
1254
|
await (0, _stryke_fs_buffer.writeFileBuffer)((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
|
|
1221
1255
|
if (!this.#context.config.skipCache) this.resolverCache.save(true);
|
|
1222
1256
|
await Promise.all(this.#getStorages().map(async (storage) => storage.adapter.dispose()));
|
|
1223
|
-
this.#
|
|
1257
|
+
this.#logger.trace("Virtual file system has been disposed.");
|
|
1224
1258
|
}
|
|
1225
1259
|
}
|
|
1226
1260
|
/**
|
|
@@ -1481,6 +1515,18 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1481
1515
|
}, {}) : this.config.resolve.alias : {});
|
|
1482
1516
|
}
|
|
1483
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
|
+
/**
|
|
1484
1530
|
* Gets the parser cache.
|
|
1485
1531
|
*/
|
|
1486
1532
|
get parserCache() {
|
|
@@ -1535,60 +1581,6 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1535
1581
|
this.options = options;
|
|
1536
1582
|
}
|
|
1537
1583
|
/**
|
|
1538
|
-
* 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.
|
|
1539
|
-
*
|
|
1540
|
-
* @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.
|
|
1541
|
-
* @returns A log function that can be used to log messages with the specified configuration.
|
|
1542
|
-
*/
|
|
1543
|
-
createLog(config) {
|
|
1544
|
-
const log = (0, _powerlines_core.createLogFn)({
|
|
1545
|
-
...config,
|
|
1546
|
-
logLevel: this.logLevel
|
|
1547
|
-
});
|
|
1548
|
-
return (meta, ...args) => {
|
|
1549
|
-
log(meta, ...args);
|
|
1550
|
-
process.send?.({
|
|
1551
|
-
id: (0, _stryke_unique_id_uuid.uuid)(),
|
|
1552
|
-
type: "write-log",
|
|
1553
|
-
executionId: config?.executionId ?? this.options.executionId,
|
|
1554
|
-
executionIndex: config?.executionIndex ?? this.options.executionIndex,
|
|
1555
|
-
timestamp: Date.now(),
|
|
1556
|
-
payload: {
|
|
1557
|
-
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",
|
|
1558
|
-
...config,
|
|
1559
|
-
args
|
|
1560
|
-
}
|
|
1561
|
-
});
|
|
1562
|
-
};
|
|
1563
|
-
}
|
|
1564
|
-
/**
|
|
1565
|
-
* Extend the current log function instance with a new name
|
|
1566
|
-
*
|
|
1567
|
-
* @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.
|
|
1568
|
-
* @returns A log function
|
|
1569
|
-
*/
|
|
1570
|
-
extendLog(config) {
|
|
1571
|
-
const log = (0, _powerlines_core.extendLogFn)(this.log, {
|
|
1572
|
-
...config,
|
|
1573
|
-
logLevel: this.logLevel
|
|
1574
|
-
});
|
|
1575
|
-
return (meta, ...args) => {
|
|
1576
|
-
log(meta, ...args);
|
|
1577
|
-
process.send?.({
|
|
1578
|
-
id: (0, _stryke_unique_id_uuid.uuid)(),
|
|
1579
|
-
type: "write-log",
|
|
1580
|
-
executionId: config.executionId ?? this.options.executionId,
|
|
1581
|
-
executionIndex: config.executionIndex ?? this.options.executionIndex,
|
|
1582
|
-
timestamp: Date.now(),
|
|
1583
|
-
payload: {
|
|
1584
|
-
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",
|
|
1585
|
-
...config,
|
|
1586
|
-
args
|
|
1587
|
-
}
|
|
1588
|
-
});
|
|
1589
|
-
};
|
|
1590
|
-
}
|
|
1591
|
-
/**
|
|
1592
1584
|
* 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.
|
|
1593
1585
|
*
|
|
1594
1586
|
* @remarks
|
|
@@ -1631,6 +1623,9 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1631
1623
|
headers: cached.headers
|
|
1632
1624
|
});
|
|
1633
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()}`);
|
|
1634
1629
|
const response = await (0, _stryke_http_fetch.fetchRequest)(input, {
|
|
1635
1630
|
timeout: 12e3,
|
|
1636
1631
|
...options
|
|
@@ -1644,6 +1639,7 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1644
1639
|
if (!this.config.skipCache && !options.skipCache) try {
|
|
1645
1640
|
this.requestCache.set(cacheKey, result);
|
|
1646
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]"}`);
|
|
1647
1643
|
return new undici.Response(result.body, {
|
|
1648
1644
|
status: result.status,
|
|
1649
1645
|
statusText: result.statusText,
|
|
@@ -2019,6 +2015,13 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
2019
2015
|
* Initialize the context with the provided configuration options
|
|
2020
2016
|
*/
|
|
2021
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)}`);
|
|
2022
2025
|
if (!this.inputOptions.mode && !this.config.userConfig?.mode && !this.config.inlineConfig?.mode && !this.config.pluginConfig?.mode) {
|
|
2023
2026
|
this.options.mode = "production";
|
|
2024
2027
|
this.config.mode = "production";
|
|
@@ -2090,7 +2093,12 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
2090
2093
|
}));
|
|
2091
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;
|
|
2092
2095
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
2093
|
-
|
|
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)}`);
|
|
2094
2102
|
}
|
|
2095
2103
|
};
|
|
2096
2104
|
|
|
@@ -2140,7 +2148,7 @@ function mergeConfigs(currentResult, previousResults) {
|
|
|
2140
2148
|
async function callHook(context, key, options, ...args) {
|
|
2141
2149
|
const hooks = context.selectHooks(key, options);
|
|
2142
2150
|
if (hooks.length > 0) {
|
|
2143
|
-
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,
|
|
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")}`);
|
|
2144
2152
|
const invokeHook = async (hook, hookArgs) => {
|
|
2145
2153
|
return Reflect.apply(hook.handler, hook.context, hookArgs);
|
|
2146
2154
|
};
|
|
@@ -2240,7 +2248,7 @@ function createPluginContext(pluginId, plugin, environment) {
|
|
|
2240
2248
|
const normalizeMessage = (message) => {
|
|
2241
2249
|
return (0, _stryke_type_checks_is_string.isString)(message) ? message : message.message;
|
|
2242
2250
|
};
|
|
2243
|
-
const
|
|
2251
|
+
const logger = environment.extendLogger({ plugin: plugin.name.replaceAll(":", " - ") });
|
|
2244
2252
|
const callHookFn = async (hook, options, ...args) => {
|
|
2245
2253
|
return environment.$$internal.api.callHook(hook, {
|
|
2246
2254
|
sequential: true,
|
|
@@ -2259,24 +2267,24 @@ function createPluginContext(pluginId, plugin, environment) {
|
|
|
2259
2267
|
meta
|
|
2260
2268
|
};
|
|
2261
2269
|
if (prop === "id") return pluginId;
|
|
2262
|
-
if (prop === "
|
|
2270
|
+
if (prop === "logger") return logger;
|
|
2263
2271
|
if (prop === "fatal") return (message) => {
|
|
2264
|
-
|
|
2272
|
+
logger.error(normalizeMessage(message));
|
|
2265
2273
|
};
|
|
2266
2274
|
if (prop === "error") return (message) => {
|
|
2267
|
-
|
|
2275
|
+
logger.error(normalizeMessage(message));
|
|
2268
2276
|
};
|
|
2269
2277
|
if (prop === "warn") return (message) => {
|
|
2270
|
-
|
|
2278
|
+
logger.warn(normalizeMessage(message));
|
|
2271
2279
|
};
|
|
2272
2280
|
if (prop === "info") return (message) => {
|
|
2273
|
-
|
|
2281
|
+
logger.info(normalizeMessage(message));
|
|
2274
2282
|
};
|
|
2275
2283
|
if (prop === "debug") return (message) => {
|
|
2276
|
-
|
|
2284
|
+
logger.debug(normalizeMessage(message));
|
|
2277
2285
|
};
|
|
2278
2286
|
if (prop === "trace") return (message) => {
|
|
2279
|
-
|
|
2287
|
+
logger.trace(normalizeMessage(message));
|
|
2280
2288
|
};
|
|
2281
2289
|
return environment[prop];
|
|
2282
2290
|
},
|
|
@@ -2295,7 +2303,7 @@ function createPluginContext(pluginId, plugin, environment) {
|
|
|
2295
2303
|
"addPlugin",
|
|
2296
2304
|
"selectHooks"
|
|
2297
2305
|
].includes(prop)) {
|
|
2298
|
-
|
|
2306
|
+
logger.warn(`Cannot set the read-only "${String(prop)}" property`);
|
|
2299
2307
|
return false;
|
|
2300
2308
|
}
|
|
2301
2309
|
environment[prop] = value;
|
|
@@ -2347,26 +2355,26 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
2347
2355
|
return this.#hooks;
|
|
2348
2356
|
}
|
|
2349
2357
|
/**
|
|
2350
|
-
* Create a new
|
|
2358
|
+
* Create a new logger instance
|
|
2351
2359
|
*
|
|
2352
|
-
* @param
|
|
2353
|
-
* @returns A
|
|
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.
|
|
2354
2362
|
*/
|
|
2355
|
-
|
|
2356
|
-
return super.
|
|
2357
|
-
...
|
|
2363
|
+
createLogger(options, callback) {
|
|
2364
|
+
return super.createLogger({
|
|
2365
|
+
...options,
|
|
2358
2366
|
environment: this.environment?.name
|
|
2359
|
-
});
|
|
2367
|
+
}, callback);
|
|
2360
2368
|
}
|
|
2361
2369
|
/**
|
|
2362
|
-
* Extend the
|
|
2370
|
+
* Extend the base logger with additional configuration options
|
|
2363
2371
|
*
|
|
2364
|
-
* @param
|
|
2365
|
-
* @returns A
|
|
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.
|
|
2366
2374
|
*/
|
|
2367
|
-
|
|
2368
|
-
return super.
|
|
2369
|
-
...
|
|
2375
|
+
extendLogger(options) {
|
|
2376
|
+
return super.extendLogger({
|
|
2377
|
+
...options,
|
|
2370
2378
|
environment: this.environment?.name
|
|
2371
2379
|
});
|
|
2372
2380
|
}
|
|
@@ -2552,27 +2560,27 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
2552
2560
|
super(options);
|
|
2553
2561
|
}
|
|
2554
2562
|
/**
|
|
2555
|
-
* Create a new
|
|
2563
|
+
* Create a new logger instance
|
|
2556
2564
|
*
|
|
2557
|
-
* @param
|
|
2558
|
-
* @returns A
|
|
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.
|
|
2559
2567
|
*/
|
|
2560
|
-
|
|
2561
|
-
return super.
|
|
2562
|
-
...
|
|
2568
|
+
createLogger(options, callback) {
|
|
2569
|
+
return super.createLogger({
|
|
2570
|
+
...options,
|
|
2563
2571
|
executionId: this.id,
|
|
2564
2572
|
executionIndex: this.options.executionIndex
|
|
2565
|
-
});
|
|
2573
|
+
}, callback);
|
|
2566
2574
|
}
|
|
2567
2575
|
/**
|
|
2568
|
-
* Extend the
|
|
2576
|
+
* Extend the base logger with additional configuration options
|
|
2569
2577
|
*
|
|
2570
|
-
* @param
|
|
2571
|
-
* @returns A
|
|
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.
|
|
2572
2580
|
*/
|
|
2573
|
-
|
|
2574
|
-
return super.
|
|
2575
|
-
...
|
|
2581
|
+
extendLogger(options) {
|
|
2582
|
+
return super.extendLogger({
|
|
2583
|
+
...options,
|
|
2576
2584
|
executionId: this.id,
|
|
2577
2585
|
executionIndex: this.options.executionIndex
|
|
2578
2586
|
});
|