@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
|
@@ -1,37 +1,37 @@
|
|
|
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-5_AZZYFu.cjs');
|
|
3
3
|
const require_fs = require('./fs-XogSgMqT.cjs');
|
|
4
|
-
const require_virtual = require('./virtual-
|
|
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
|
|
9
|
+
let _powerlines_core = require("@powerlines/core");
|
|
10
10
|
let _stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
11
|
+
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
11
12
|
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
13
|
+
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
14
|
+
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
15
|
+
let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
|
|
12
16
|
let _powerlines_core_lib_logger = require("@powerlines/core/lib/logger");
|
|
17
|
+
let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
|
|
13
18
|
let _stryke_path_is_equal = require("@stryke/path/is-equal");
|
|
14
|
-
let
|
|
19
|
+
let _stryke_path_replace = require("@stryke/path/replace");
|
|
15
20
|
let chalk = require("chalk");
|
|
16
21
|
chalk = require_chunk.__toESM(chalk, 1);
|
|
17
22
|
let defu = require("defu");
|
|
18
23
|
defu = require_chunk.__toESM(defu, 1);
|
|
19
24
|
let _stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
20
25
|
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
21
|
-
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
22
26
|
let _powerlines_core_lib_utilities_format = require("@powerlines/core/lib/utilities/format");
|
|
23
|
-
let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
|
|
24
|
-
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
25
27
|
let _stryke_fs_exists = require("@stryke/fs/exists");
|
|
26
28
|
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
27
29
|
let _stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
28
30
|
let _stryke_path_append = require("@stryke/path/append");
|
|
29
31
|
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
30
32
|
let _stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
31
|
-
let _stryke_path_replace = require("@stryke/path/replace");
|
|
32
33
|
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
33
34
|
let _stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
34
|
-
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
35
35
|
let _stryke_fs_json = require("@stryke/fs/json");
|
|
36
36
|
let _stryke_helpers_deep_clone = require("@stryke/helpers/deep-clone");
|
|
37
37
|
let _powerlines_core_lib_entry = require("@powerlines/core/lib/entry");
|
|
@@ -40,7 +40,6 @@ let _stryke_hash = require("@stryke/hash");
|
|
|
40
40
|
let _stryke_hash_node = require("@stryke/hash/node");
|
|
41
41
|
let _stryke_http_fetch = require("@stryke/http/fetch");
|
|
42
42
|
let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
43
|
-
let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
|
|
44
43
|
let bundle_require = require("bundle-require");
|
|
45
44
|
let compatx = require("compatx");
|
|
46
45
|
let flat_cache = require("flat-cache");
|
|
@@ -63,6 +62,7 @@ let _stryke_helpers_get_field = require("@stryke/helpers/get-field");
|
|
|
63
62
|
//#region src/_internal/helpers/environment.ts
|
|
64
63
|
function createEnvironment(name, config = {}) {
|
|
65
64
|
return (0, defu.default)(config.environments?.[name] ?? {}, {
|
|
65
|
+
environmentId: (0, _stryke_unique_id_uuid.uuid)(),
|
|
66
66
|
name,
|
|
67
67
|
title: config.title ?? (0, _stryke_string_format_title_case.titleCase)(config.name),
|
|
68
68
|
ssr: false,
|
|
@@ -474,7 +474,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
474
474
|
}
|
|
475
475
|
}));
|
|
476
476
|
} else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(require_fs.FileSystem));
|
|
477
|
-
result.#log(
|
|
477
|
+
result.#log("debug", "Successfully completed virtual file system (VFS) initialization.");
|
|
478
478
|
return result;
|
|
479
479
|
}
|
|
480
480
|
/**
|
|
@@ -508,7 +508,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
508
508
|
}
|
|
509
509
|
});
|
|
510
510
|
} else result = new VirtualFileSystem(context, new _stryke_capnp.Message().initRoot(require_fs.FileSystem));
|
|
511
|
-
result.#log(
|
|
511
|
+
result.#log("debug", "Successfully completed virtual file system (VFS) initialization.");
|
|
512
512
|
return result;
|
|
513
513
|
}
|
|
514
514
|
/**
|
|
@@ -642,7 +642,10 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
642
642
|
return ret;
|
|
643
643
|
}, {});
|
|
644
644
|
}
|
|
645
|
-
this.#log =
|
|
645
|
+
this.#log = context.extendLog({
|
|
646
|
+
source: "VFS",
|
|
647
|
+
category: "fs"
|
|
648
|
+
});
|
|
646
649
|
}
|
|
647
650
|
/**
|
|
648
651
|
* Asynchronously checks if a file exists in the virtual file system (VFS).
|
|
@@ -769,7 +772,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
769
772
|
listSync(path) {
|
|
770
773
|
let resolvedPath = path;
|
|
771
774
|
if (resolvedPath.includes("*")) {
|
|
772
|
-
this.#log(
|
|
775
|
+
this.#log("warn", `Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
|
|
773
776
|
resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
|
|
774
777
|
}
|
|
775
778
|
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));
|
|
@@ -783,7 +786,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
783
786
|
async list(path) {
|
|
784
787
|
let resolvedPath = path;
|
|
785
788
|
if (resolvedPath.includes("*")) {
|
|
786
|
-
this.#log(
|
|
789
|
+
this.#log("warn", `Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
|
|
787
790
|
resolvedPath = (0, _stryke_path_correct_path.stripStars)(resolvedPath);
|
|
788
791
|
}
|
|
789
792
|
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));
|
|
@@ -795,7 +798,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
795
798
|
*/
|
|
796
799
|
async remove(path) {
|
|
797
800
|
const normalizedPath = this.#normalizePath(path);
|
|
798
|
-
this.#log(
|
|
801
|
+
this.#log("trace", `Removing file: ${normalizedPath}`);
|
|
799
802
|
const { relativeKey, adapter } = this.#getStorage(normalizedPath);
|
|
800
803
|
if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) await adapter.remove(relativeKey);
|
|
801
804
|
else await adapter.clear(relativeKey);
|
|
@@ -813,7 +816,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
813
816
|
*/
|
|
814
817
|
removeSync(path) {
|
|
815
818
|
const normalizedPath = this.#normalizePath(path);
|
|
816
|
-
this.#log(
|
|
819
|
+
this.#log("trace", `Removing file: ${normalizedPath}`);
|
|
817
820
|
const { relativeKey, adapter } = this.#getStorage(normalizedPath);
|
|
818
821
|
if ((0, _stryke_path_file_path_fns.hasFileExtension)(normalizedPath)) adapter.removeSync(relativeKey);
|
|
819
822
|
else adapter.clearSync(relativeKey);
|
|
@@ -959,7 +962,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
959
962
|
const filePath = await this.resolve(path, void 0, { isFile: true });
|
|
960
963
|
if (!filePath || !this.existsSync(filePath)) return;
|
|
961
964
|
const { adapter } = this.#getStorage(filePath);
|
|
962
|
-
this.#log(
|
|
965
|
+
this.#log("trace", `Reading ${adapter.name} file: ${filePath}`);
|
|
963
966
|
return await adapter.get(filePath) ?? void 0;
|
|
964
967
|
}
|
|
965
968
|
/**
|
|
@@ -972,7 +975,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
972
975
|
const filePath = this.resolveSync(path, void 0, { isFile: true });
|
|
973
976
|
if (!filePath || !this.existsSync(filePath)) return;
|
|
974
977
|
const { adapter } = this.#getStorage(filePath);
|
|
975
|
-
this.#log(
|
|
978
|
+
this.#log("trace", `Reading ${adapter.name} file: ${filePath}`);
|
|
976
979
|
return adapter.getSync(filePath) ?? void 0;
|
|
977
980
|
}
|
|
978
981
|
/**
|
|
@@ -987,15 +990,15 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
987
990
|
const meta = options.meta ?? {};
|
|
988
991
|
const resolvedPath = await this.resolve(this.#normalizePath(path)) || path;
|
|
989
992
|
const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
|
|
990
|
-
this.#log(
|
|
993
|
+
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)})`);
|
|
991
994
|
let code = data;
|
|
992
995
|
try {
|
|
993
996
|
if (!options.skipFormat) code = await (0, _powerlines_core_lib_utilities_format.format)(this.#context, resolvedPath, data);
|
|
994
997
|
} catch (err) {
|
|
995
|
-
if (DEFAULT_EXTENSIONS.includes((0, _stryke_path_file_path_fns.findFileExtensionSafe)(resolvedPath, { fullExtension: true }))) this.#log(
|
|
998
|
+
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}`);
|
|
996
999
|
code = data;
|
|
997
1000
|
}
|
|
998
|
-
this.#log(
|
|
1001
|
+
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)})`);
|
|
999
1002
|
const id = this.#normalizeId(meta.id || resolvedPath);
|
|
1000
1003
|
this.metadata[id] = {
|
|
1001
1004
|
type: "normal",
|
|
@@ -1018,7 +1021,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1018
1021
|
const meta = options.meta ?? {};
|
|
1019
1022
|
const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;
|
|
1020
1023
|
const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
|
|
1021
|
-
this.#log(
|
|
1024
|
+
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)})`);
|
|
1022
1025
|
const id = this.#normalizeId(meta.id || resolvedPath);
|
|
1023
1026
|
this.metadata[id] = {
|
|
1024
1027
|
type: "normal",
|
|
@@ -1182,7 +1185,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1182
1185
|
async dispose() {
|
|
1183
1186
|
if (!this.#isDisposed) {
|
|
1184
1187
|
this.#isDisposed = true;
|
|
1185
|
-
this.#log(
|
|
1188
|
+
this.#log("debug", "Disposing virtual file system...");
|
|
1186
1189
|
await this.remove((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"));
|
|
1187
1190
|
const message = new _stryke_capnp.Message();
|
|
1188
1191
|
const fs = message.initRoot(require_fs.FileSystem);
|
|
@@ -1217,9 +1220,15 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1217
1220
|
await (0, _stryke_fs_buffer.writeFileBuffer)((0, _stryke_path_join.joinPaths)(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
|
|
1218
1221
|
if (!this.#context.config.skipCache) this.resolverCache.save(true);
|
|
1219
1222
|
await Promise.all(this.#getStorages().map(async (storage) => storage.adapter.dispose()));
|
|
1220
|
-
this.#log(
|
|
1223
|
+
this.#log("trace", "Virtual file system has been disposed.");
|
|
1221
1224
|
}
|
|
1222
1225
|
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Asynchronously disposes of the virtual file system (VFS) by saving its state to disk.
|
|
1228
|
+
*
|
|
1229
|
+
* @remarks
|
|
1230
|
+
* 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.
|
|
1231
|
+
*/
|
|
1223
1232
|
async [Symbol.asyncDispose]() {
|
|
1224
1233
|
return this.dispose();
|
|
1225
1234
|
}
|
|
@@ -1368,7 +1377,7 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1368
1377
|
buildId: this.#buildId,
|
|
1369
1378
|
releaseId: this.#releaseId,
|
|
1370
1379
|
checksum: this.#checksum,
|
|
1371
|
-
timestamp: this.timestamp
|
|
1380
|
+
timestamp: this.timestamp,
|
|
1372
1381
|
rootHash: (0, _stryke_hash.murmurhash)({
|
|
1373
1382
|
workspaceRoot: this.options?.cwd,
|
|
1374
1383
|
root: this.config?.root
|
|
@@ -1526,6 +1535,60 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1526
1535
|
this.options = options;
|
|
1527
1536
|
}
|
|
1528
1537
|
/**
|
|
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
|
+
/**
|
|
1529
1592
|
* 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.
|
|
1530
1593
|
*
|
|
1531
1594
|
* @remarks
|
|
@@ -1534,22 +1597,10 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1534
1597
|
* @returns A promise that resolves to the cloned context.
|
|
1535
1598
|
*/
|
|
1536
1599
|
async clone() {
|
|
1537
|
-
const clone = await PowerlinesContext.fromOptions(this.
|
|
1600
|
+
const clone = await PowerlinesContext.fromOptions(this.options);
|
|
1538
1601
|
return this.copyTo(clone);
|
|
1539
1602
|
}
|
|
1540
1603
|
/**
|
|
1541
|
-
* Create a new logger instance
|
|
1542
|
-
*
|
|
1543
|
-
* @param name - The name to use for the logger instance
|
|
1544
|
-
* @returns A logger function
|
|
1545
|
-
*/
|
|
1546
|
-
createLog(name = null) {
|
|
1547
|
-
return (0, _powerlines_core_lib_logger.createLog)(name, {
|
|
1548
|
-
...this.config,
|
|
1549
|
-
logLevel: (0, _stryke_type_checks_is_null.isNull)(this.logLevel) ? "silent" : this.logLevel
|
|
1550
|
-
});
|
|
1551
|
-
}
|
|
1552
|
-
/**
|
|
1553
1604
|
* A function to perform HTTP fetch requests
|
|
1554
1605
|
*
|
|
1555
1606
|
* @remarks
|
|
@@ -1925,6 +1976,7 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1925
1976
|
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);
|
|
1926
1977
|
else context[key] = value;
|
|
1927
1978
|
context.inputOptions = (0, _stryke_helpers_deep_clone.deepClone)(this.inputOptions);
|
|
1979
|
+
context.options = (0, _stryke_helpers_deep_clone.deepClone)(this.options);
|
|
1928
1980
|
context.dependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.dependencies);
|
|
1929
1981
|
context.devDependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.devDependencies);
|
|
1930
1982
|
context.persistedMeta = this.persistedMeta ? (0, _stryke_helpers_deep_clone.deepClone)(this.persistedMeta) : void 0;
|
|
@@ -1946,7 +1998,8 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1946
1998
|
*/
|
|
1947
1999
|
async init(options = {}) {
|
|
1948
2000
|
await super.init(options);
|
|
1949
|
-
this.options.
|
|
2001
|
+
this.options.executionId = options.executionId ?? this.options.executionId;
|
|
2002
|
+
this.options.executionIndex = options.executionIndex ?? this.options.executionIndex ?? 0;
|
|
1950
2003
|
const projectJsonPath = (0, _stryke_path_join.joinPaths)(this.options.cwd, this.options.root, "project.json");
|
|
1951
2004
|
if ((0, _stryke_fs_exists.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs_json.readJsonFile)(projectJsonPath);
|
|
1952
2005
|
const packageJsonPath = (0, _stryke_path_join.joinPaths)(this.options.cwd, this.options.root, "package.json");
|
|
@@ -1955,7 +2008,7 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1955
2008
|
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);
|
|
1956
2009
|
}
|
|
1957
2010
|
this.#checksum = await this.generateChecksum((0, _stryke_path_join.joinPaths)(this.options.cwd, this.options.root));
|
|
1958
|
-
const userConfig = this.configFile.config ? Array.isArray(this.configFile.config) && this.configFile.config.length > this.options.
|
|
2011
|
+
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 : {};
|
|
1959
2012
|
this.resolvedConfig = {
|
|
1960
2013
|
...this.options,
|
|
1961
2014
|
...userConfig,
|
|
@@ -1975,10 +2028,6 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1975
2028
|
this.config.framework = "powerlines";
|
|
1976
2029
|
}
|
|
1977
2030
|
this.resolvedConfig.compatibilityDate = (0, compatx.resolveCompatibilityDates)(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
|
|
1978
|
-
this.logger = {
|
|
1979
|
-
log: this.createLog(this.config.name),
|
|
1980
|
-
level: (0, _stryke_type_checks_is_null.isNull)(this.logLevel) ? "silent" : this.logLevel
|
|
1981
|
-
};
|
|
1982
2031
|
this.config.input = (0, _powerlines_core_lib_entry.getUniqueInputs)(this.config.input);
|
|
1983
2032
|
if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
|
|
1984
2033
|
this.config.title ??= (0, _stryke_string_format_title_case.titleCase)(this.config.name);
|
|
@@ -1986,16 +2035,17 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
1986
2035
|
if (this.config.userConfig.resolve?.noExternal) this.config.userConfig.resolve.noExternal = (0, _stryke_helpers_get_unique.getUnique)(this.config.userConfig.resolve.noExternal);
|
|
1987
2036
|
if (this.config.resolve.external) this.config.resolve.external = (0, _stryke_helpers_get_unique.getUnique)(this.config.resolve.external);
|
|
1988
2037
|
if (this.config.resolve.noExternal) this.config.resolve.noExternal = (0, _stryke_helpers_get_unique.getUnique)(this.config.resolve.noExternal);
|
|
1989
|
-
this.config.plugins = (this.config.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
|
|
2038
|
+
this.config.plugins = (this.config.plugins ?? []).flatMap((plugin) => (0, _stryke_convert_to_array.toArray)(plugin)).filter(Boolean).reduce((ret, plugin) => {
|
|
1990
2039
|
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;
|
|
1991
2040
|
ret.push(plugin);
|
|
1992
2041
|
return ret;
|
|
1993
2042
|
}, []);
|
|
1994
|
-
if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel =
|
|
1995
|
-
else this.config.logLevel =
|
|
1996
|
-
|
|
2043
|
+
if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = _powerlines_core_constants.DEFAULT_DEVELOPMENT_LOG_LEVEL;
|
|
2044
|
+
else if (this.config.mode === "test") this.config.logLevel = _powerlines_core_constants.DEFAULT_TEST_LOG_LEVEL;
|
|
2045
|
+
else this.config.logLevel = _powerlines_core_constants.DEFAULT_PRODUCTION_LOG_LEVEL;
|
|
2046
|
+
if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = require_tsconfig.getTsconfigFilePath(this.config.cwd, this.config.root);
|
|
1997
2047
|
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);
|
|
1998
|
-
this.resolvedConfig.output = (0, defu.default)(this.
|
|
2048
|
+
this.resolvedConfig.output = (0, defu.default)(this.config.output ?? {}, {
|
|
1999
2049
|
path: (0, _stryke_path_join.joinPaths)(this.config.root, "dist"),
|
|
2000
2050
|
copy: { assets: [
|
|
2001
2051
|
{ glob: "LICENSE" },
|
|
@@ -2018,7 +2068,7 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
2018
2068
|
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;
|
|
2019
2069
|
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);
|
|
2020
2070
|
}
|
|
2021
|
-
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);
|
|
2071
|
+
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);
|
|
2022
2072
|
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) => {
|
|
2023
2073
|
return {
|
|
2024
2074
|
glob: (0, _stryke_type_checks_is_set_object.isSetObject)(asset) ? asset.glob : asset,
|
|
@@ -2040,6 +2090,7 @@ var PowerlinesContext = class PowerlinesContext extends require_base_context.Pow
|
|
|
2040
2090
|
}));
|
|
2041
2091
|
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;
|
|
2042
2092
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
2093
|
+
this.extendLog({ category: "config" })("debug", `Resolved Powerlines configuration object: \n${JSON.stringify(this.resolvedConfig, null, 2)}`);
|
|
2043
2094
|
}
|
|
2044
2095
|
};
|
|
2045
2096
|
|
|
@@ -2180,15 +2231,16 @@ function extractHooks(context, hooks, plugin, key, parentKey) {
|
|
|
2180
2231
|
/**
|
|
2181
2232
|
* Create a Proxy-based PluginContext
|
|
2182
2233
|
*
|
|
2234
|
+
* @param pluginId - The unique identifier of the plugin
|
|
2183
2235
|
* @param plugin - The plugin instance
|
|
2184
2236
|
* @param environment - The environment context
|
|
2185
2237
|
* @returns The proxied plugin context
|
|
2186
2238
|
*/
|
|
2187
|
-
function createPluginContext(plugin, environment) {
|
|
2239
|
+
function createPluginContext(pluginId, plugin, environment) {
|
|
2188
2240
|
const normalizeMessage = (message) => {
|
|
2189
2241
|
return (0, _stryke_type_checks_is_string.isString)(message) ? message : message.message;
|
|
2190
2242
|
};
|
|
2191
|
-
const log = environment.extendLog(plugin.name.replaceAll(":", " - "));
|
|
2243
|
+
const log = environment.extendLog({ plugin: plugin.name.replaceAll(":", " - ") });
|
|
2192
2244
|
const callHookFn = async (hook, options, ...args) => {
|
|
2193
2245
|
return environment.$$internal.api.callHook(hook, {
|
|
2194
2246
|
sequential: true,
|
|
@@ -2206,30 +2258,32 @@ function createPluginContext(plugin, environment) {
|
|
|
2206
2258
|
callHook: callHookFn,
|
|
2207
2259
|
meta
|
|
2208
2260
|
};
|
|
2261
|
+
if (prop === "id") return pluginId;
|
|
2209
2262
|
if (prop === "log" || prop === "logger") return log;
|
|
2210
2263
|
if (prop === "fatal") return (message) => {
|
|
2211
|
-
log(
|
|
2264
|
+
log("error", normalizeMessage(message));
|
|
2212
2265
|
};
|
|
2213
2266
|
if (prop === "error") return (message) => {
|
|
2214
|
-
log(
|
|
2267
|
+
log("error", normalizeMessage(message));
|
|
2215
2268
|
};
|
|
2216
2269
|
if (prop === "warn") return (message) => {
|
|
2217
|
-
log(
|
|
2270
|
+
log("warn", normalizeMessage(message));
|
|
2218
2271
|
};
|
|
2219
2272
|
if (prop === "info") return (message) => {
|
|
2220
|
-
log(
|
|
2273
|
+
log("info", normalizeMessage(message));
|
|
2221
2274
|
};
|
|
2222
2275
|
if (prop === "debug") return (message) => {
|
|
2223
|
-
log(
|
|
2276
|
+
log("debug", normalizeMessage(message));
|
|
2224
2277
|
};
|
|
2225
2278
|
if (prop === "trace") return (message) => {
|
|
2226
|
-
log(
|
|
2279
|
+
log("trace", normalizeMessage(message));
|
|
2227
2280
|
};
|
|
2228
2281
|
return environment[prop];
|
|
2229
2282
|
},
|
|
2230
2283
|
set(_, prop, value) {
|
|
2231
2284
|
if ([
|
|
2232
2285
|
"$$internal",
|
|
2286
|
+
"id",
|
|
2233
2287
|
"environment",
|
|
2234
2288
|
"config",
|
|
2235
2289
|
"log",
|
|
@@ -2241,7 +2295,7 @@ function createPluginContext(plugin, environment) {
|
|
|
2241
2295
|
"addPlugin",
|
|
2242
2296
|
"selectHooks"
|
|
2243
2297
|
].includes(prop)) {
|
|
2244
|
-
log(
|
|
2298
|
+
log("warn", `Cannot set read-only property "${String(prop)}"`);
|
|
2245
2299
|
return false;
|
|
2246
2300
|
}
|
|
2247
2301
|
environment[prop] = value;
|
|
@@ -2281,17 +2335,10 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
2281
2335
|
*/
|
|
2282
2336
|
plugins = [];
|
|
2283
2337
|
/**
|
|
2284
|
-
*
|
|
2285
|
-
*
|
|
2286
|
-
* @param name - The name to use for the logger instance
|
|
2287
|
-
* @returns A logger function
|
|
2338
|
+
* 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.
|
|
2288
2339
|
*/
|
|
2289
|
-
|
|
2290
|
-
return
|
|
2291
|
-
...this.config,
|
|
2292
|
-
logLevel: (0, _stryke_type_checks_is_null.isNull)(this.config.logLevel) ? "silent" : this.config.logLevel,
|
|
2293
|
-
environment: this.environment?.name
|
|
2294
|
-
});
|
|
2340
|
+
get id() {
|
|
2341
|
+
return this.environment.environmentId;
|
|
2295
2342
|
}
|
|
2296
2343
|
/**
|
|
2297
2344
|
* The hooks registered by plugins in this environment
|
|
@@ -2300,6 +2347,30 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
2300
2347
|
return this.#hooks;
|
|
2301
2348
|
}
|
|
2302
2349
|
/**
|
|
2350
|
+
* 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.
|
|
2351
|
+
*
|
|
2352
|
+
* @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.
|
|
2353
|
+
* @returns A log function that can be used to log messages with the specified configuration.
|
|
2354
|
+
*/
|
|
2355
|
+
createLog(config) {
|
|
2356
|
+
return super.createLog({
|
|
2357
|
+
...config,
|
|
2358
|
+
environment: this.environment?.name
|
|
2359
|
+
});
|
|
2360
|
+
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Extend the current log function instance with a new name
|
|
2363
|
+
*
|
|
2364
|
+
* @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.
|
|
2365
|
+
* @returns A log function
|
|
2366
|
+
*/
|
|
2367
|
+
extendLog(config) {
|
|
2368
|
+
return super.extendLog({
|
|
2369
|
+
...config,
|
|
2370
|
+
environment: this.environment?.name
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2303
2374
|
* 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.
|
|
2304
2375
|
*
|
|
2305
2376
|
* @remarks
|
|
@@ -2329,8 +2400,10 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
2329
2400
|
if ((0, _powerlines_core_plugin_utils.isPluginConfig)(result)) return this.$$internal.addPlugin(result);
|
|
2330
2401
|
resolvedPlugin = (0, _powerlines_core_plugin_utils.isPlugin)(result) ? result : plugin;
|
|
2331
2402
|
}
|
|
2332
|
-
const
|
|
2403
|
+
const pluginId = (0, _stryke_unique_id_uuid.uuid)();
|
|
2404
|
+
const context = createPluginContext(pluginId, resolvedPlugin, this);
|
|
2333
2405
|
this.plugins.push({
|
|
2406
|
+
pluginId,
|
|
2334
2407
|
plugin: resolvedPlugin,
|
|
2335
2408
|
context
|
|
2336
2409
|
});
|
|
@@ -2456,6 +2529,12 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
2456
2529
|
for (const environment of Object.values(this.environments)) environment.$$internal = super.$$internal;
|
|
2457
2530
|
}
|
|
2458
2531
|
/**
|
|
2532
|
+
* 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.
|
|
2533
|
+
*/
|
|
2534
|
+
get id() {
|
|
2535
|
+
return this.options.executionId;
|
|
2536
|
+
}
|
|
2537
|
+
/**
|
|
2459
2538
|
* A record of all environments by name
|
|
2460
2539
|
*/
|
|
2461
2540
|
get environments() {
|
|
@@ -2473,6 +2552,32 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
2473
2552
|
super(options);
|
|
2474
2553
|
}
|
|
2475
2554
|
/**
|
|
2555
|
+
* 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.
|
|
2556
|
+
*
|
|
2557
|
+
* @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.
|
|
2558
|
+
* @returns A log function that can be used to log messages with the specified configuration.
|
|
2559
|
+
*/
|
|
2560
|
+
createLog(config) {
|
|
2561
|
+
return super.createLog({
|
|
2562
|
+
...config,
|
|
2563
|
+
executionId: this.id,
|
|
2564
|
+
executionIndex: this.options.executionIndex
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
/**
|
|
2568
|
+
* Extend the current log function instance with a new name
|
|
2569
|
+
*
|
|
2570
|
+
* @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.
|
|
2571
|
+
* @returns A log function
|
|
2572
|
+
*/
|
|
2573
|
+
extendLog(config) {
|
|
2574
|
+
return super.extendLog({
|
|
2575
|
+
...config,
|
|
2576
|
+
executionId: this.id,
|
|
2577
|
+
executionIndex: this.options.executionIndex
|
|
2578
|
+
});
|
|
2579
|
+
}
|
|
2580
|
+
/**
|
|
2476
2581
|
* 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.
|
|
2477
2582
|
*
|
|
2478
2583
|
* @remarks
|