@powerlines/engine 0.44.0 → 0.44.2
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 +186 -169
- package/dist/_internal/worker.d.cts.map +1 -1
- package/dist/_internal/worker.d.mts.map +1 -1
- package/dist/_internal/worker.mjs +187 -170
- package/dist/_internal/worker.mjs.map +1 -1
- package/dist/api.cjs +7 -7
- package/dist/api.mjs +5 -5
- package/dist/api.mjs.map +1 -1
- package/dist/{base-context-5_AZZYFu.cjs → base-context-CAA1druQ.cjs} +62 -33
- package/dist/{base-context-D_ZidDDm.mjs → base-context-fOM4ZWUo.mjs} +67 -38
- package/dist/base-context-fOM4ZWUo.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-PQ3BgcgR.mjs → engine-context-BWGxMU_n.mjs} +2 -2
- package/dist/{engine-context-PQ3BgcgR.mjs.map → engine-context-BWGxMU_n.mjs.map} +1 -1
- package/dist/{engine-context-w4fts28j.cjs → engine-context-CUPubmrM.cjs} +1 -1
- package/dist/{execution-context-0GmpbWbs.cjs → execution-context-BoJhCK0d.cjs} +125 -117
- package/dist/{execution-context-zedP0h4Z.mjs → execution-context-CFJst4Fz.mjs} +127 -119
- package/dist/execution-context-CFJst4Fz.mjs.map +1 -0
- package/dist/index.cjs +114 -53
- package/dist/index.d.cts +8 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +114 -53
- package/dist/index.mjs.map +1 -1
- package/dist/storage/index.cjs +1 -1
- package/dist/storage/index.mjs +1 -1
- package/dist/{tsconfig-Cstsoprg.mjs → tsconfig-CI6bla4E.mjs} +2 -2
- package/dist/{tsconfig-Cstsoprg.mjs.map → tsconfig-CI6bla4E.mjs.map} +1 -1
- package/dist/{tsconfig-DeyWQC2N.cjs → tsconfig-QMSxSwBD.cjs} +1 -1
- package/dist/typescript/index.cjs +1 -1
- package/dist/typescript/index.mjs +1 -1
- package/dist/{virtual-CUgOdyIa.mjs → virtual-CYGZHTDd.mjs} +5 -5
- package/dist/virtual-CYGZHTDd.mjs.map +1 -0
- package/dist/{virtual-1hYa9zCy.cjs → virtual-Ct3ZqPeN.cjs} +2 -2
- package/package.json +3 -3
- package/dist/base-context-D_ZidDDm.mjs.map +0 -1
- package/dist/execution-context-zedP0h4Z.mjs.map +0 -1
- package/dist/virtual-CUgOdyIa.mjs.map +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { t as PowerlinesBaseContext } from "./base-context-
|
|
1
|
+
import { t as PowerlinesBaseContext } from "./base-context-fOM4ZWUo.mjs";
|
|
2
2
|
import { a as FileSystem } from "./fs-D1nIP45P.mjs";
|
|
3
|
-
import { n as FileSystemStorageAdapter, t as VirtualStorageAdapter } from "./virtual-
|
|
4
|
-
import { i as getTsconfigFilePath } from "./tsconfig-
|
|
3
|
+
import { n as FileSystemStorageAdapter, t as VirtualStorageAdapter } from "./virtual-CYGZHTDd.mjs";
|
|
4
|
+
import { i as getTsconfigFilePath } from "./tsconfig-CI6bla4E.mjs";
|
|
5
5
|
import { CACHE_HASH_LENGTH, DEFAULT_DEVELOPMENT_LOG_LEVEL, DEFAULT_ENVIRONMENT, DEFAULT_PRODUCTION_LOG_LEVEL, DEFAULT_TEST_LOG_LEVEL, GLOBAL_ENVIRONMENT, PLUGIN_NON_HOOK_FIELDS, ROOT_HASH_LENGTH } from "@powerlines/core/constants";
|
|
6
|
+
import { toArray } from "@stryke/convert/to-array";
|
|
6
7
|
import { getResolutionCombinations, resolve, resolvePackage, resolveSync } from "@stryke/fs/resolve";
|
|
7
8
|
import { joinPaths } from "@stryke/path/join";
|
|
8
|
-
import { createLogFn, extendLogFn } from "@powerlines/core";
|
|
9
9
|
import { isSet } from "@stryke/type-checks/is-set";
|
|
10
10
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
11
11
|
import { isString } from "@stryke/type-checks/is-string";
|
|
12
|
-
import { toArray } from "@stryke/convert/to-array";
|
|
13
12
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
14
13
|
import { uuid } from "@stryke/unique-id/uuid";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import { addPluginHook, createLogger, dedupeHooklist, isDuplicate, isPlugin, isPluginConfig, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens, withCustomLogger, withLogger } from "@powerlines/core/plugin-utils";
|
|
15
|
+
import { colorText } from "@powerlines/core/plugin-utils/logging";
|
|
16
|
+
import { appendPath } from "@stryke/path/append";
|
|
17
17
|
import { isEqual } from "@stryke/path/is-equal";
|
|
18
18
|
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
19
19
|
import chalk from "chalk";
|
|
@@ -24,7 +24,6 @@ import { format } from "@powerlines/core/lib/utilities/format";
|
|
|
24
24
|
import { existsSync } from "@stryke/fs/exists";
|
|
25
25
|
import { getUnique, getUniqueBy } from "@stryke/helpers/get-unique";
|
|
26
26
|
import { omit } from "@stryke/helpers/omit";
|
|
27
|
-
import { appendPath } from "@stryke/path/append";
|
|
28
27
|
import { findFileDotExtensionSafe, findFileExtensionSafe, findFileName, findFilePath, hasFileExtension } from "@stryke/path/file-path-fns";
|
|
29
28
|
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
30
29
|
import { isFunction } from "@stryke/type-checks/is-function";
|
|
@@ -43,6 +42,7 @@ import { create } from "flat-cache";
|
|
|
43
42
|
import { parse } from "oxc-parser";
|
|
44
43
|
import { Agent, Response, interceptors, setGlobalDispatcher } from "undici";
|
|
45
44
|
import "@stryke/fs/remove-file";
|
|
45
|
+
import { LogCategories } from "@powerlines/core";
|
|
46
46
|
import * as capnp from "@stryke/capnp";
|
|
47
47
|
import { readFileBuffer, readFileBufferSync, writeFileBuffer } from "@stryke/fs/buffer";
|
|
48
48
|
import { correctPath, stripStars } from "@stryke/path/correct-path";
|
|
@@ -143,6 +143,40 @@ async function writeMetaFile(context) {
|
|
|
143
143
|
await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/_internal/ipc/send.ts
|
|
148
|
+
function sendWriteLogMessage(context, type, message) {
|
|
149
|
+
const meta = {
|
|
150
|
+
...isSetObject(message) && isSetObject(message.meta) ? message.meta : {},
|
|
151
|
+
...context.logger.options
|
|
152
|
+
};
|
|
153
|
+
process.send?.({
|
|
154
|
+
id: uuid(),
|
|
155
|
+
type: "write-log",
|
|
156
|
+
executionId: meta.executionId ?? context.config.executionId,
|
|
157
|
+
executionIndex: meta.executionIndex ?? context.config.executionIndex,
|
|
158
|
+
environment: meta.environment,
|
|
159
|
+
timestamp: Date.now(),
|
|
160
|
+
payload: {
|
|
161
|
+
meta: {
|
|
162
|
+
type,
|
|
163
|
+
category: meta.category ?? LogCategories.GENERAL,
|
|
164
|
+
logId: meta.logId ?? uuid(),
|
|
165
|
+
timestamp: meta.timestamp ?? Date.now(),
|
|
166
|
+
name: meta.name ?? context.config.name,
|
|
167
|
+
executionId: meta.executionId ?? context.config.executionId,
|
|
168
|
+
executionIndex: meta.executionIndex ?? context.config.executionIndex,
|
|
169
|
+
command: meta.command ?? context.config.command,
|
|
170
|
+
hook: meta.hook,
|
|
171
|
+
environment: meta.environment,
|
|
172
|
+
plugin: meta.plugin,
|
|
173
|
+
source: meta.source
|
|
174
|
+
},
|
|
175
|
+
message: isSetString(message) ? message : message.message
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
146
180
|
//#endregion
|
|
147
181
|
//#region src/_internal/helpers/constants.ts
|
|
148
182
|
const DEFAULT_EXTENSIONS = [
|
|
@@ -254,9 +288,9 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
254
288
|
*/
|
|
255
289
|
#context;
|
|
256
290
|
/**
|
|
257
|
-
* The file system's
|
|
291
|
+
* The file system's logger client utility.
|
|
258
292
|
*/
|
|
259
|
-
#
|
|
293
|
+
#logger;
|
|
260
294
|
/**
|
|
261
295
|
* Normalizes a given module id by resolving it against the built-ins path.
|
|
262
296
|
*
|
|
@@ -470,7 +504,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
470
504
|
}
|
|
471
505
|
}));
|
|
472
506
|
} else result = new VirtualFileSystem(context, new capnp.Message().initRoot(FileSystem));
|
|
473
|
-
result.#
|
|
507
|
+
result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
|
|
474
508
|
return result;
|
|
475
509
|
}
|
|
476
510
|
/**
|
|
@@ -504,7 +538,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
504
538
|
}
|
|
505
539
|
});
|
|
506
540
|
} else result = new VirtualFileSystem(context, new capnp.Message().initRoot(FileSystem));
|
|
507
|
-
result.#
|
|
541
|
+
result.#logger.debug("Successfully completed virtual file system (VFS) initialization.");
|
|
508
542
|
return result;
|
|
509
543
|
}
|
|
510
544
|
/**
|
|
@@ -638,7 +672,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
638
672
|
return ret;
|
|
639
673
|
}, {});
|
|
640
674
|
}
|
|
641
|
-
this.#
|
|
675
|
+
this.#logger = context.extendLogger({
|
|
642
676
|
source: "VFS",
|
|
643
677
|
category: "fs"
|
|
644
678
|
});
|
|
@@ -768,7 +802,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
768
802
|
listSync(path) {
|
|
769
803
|
let resolvedPath = path;
|
|
770
804
|
if (resolvedPath.includes("*")) {
|
|
771
|
-
this.#
|
|
805
|
+
this.#logger.warn(`Invoking "listSync" with a glob pattern is not supported. It is likely you meant to use "globSync". Path: ${path}`);
|
|
772
806
|
resolvedPath = stripStars(resolvedPath);
|
|
773
807
|
}
|
|
774
808
|
return getUnique(this.#getStorages(resolvedPath, true).map((storage) => storage.adapter.listSync(storage.relativeBase ? storage.base ? appendPath(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)).flat().filter(Boolean));
|
|
@@ -782,7 +816,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
782
816
|
async list(path) {
|
|
783
817
|
let resolvedPath = path;
|
|
784
818
|
if (resolvedPath.includes("*")) {
|
|
785
|
-
this.#
|
|
819
|
+
this.#logger.warn(`Invoking "list" with a glob pattern is not supported. It is likely you meant to use "glob". Path: ${path}`);
|
|
786
820
|
resolvedPath = stripStars(resolvedPath);
|
|
787
821
|
}
|
|
788
822
|
return getUnique((await Promise.all(this.#getStorages(resolvedPath, true).map(async (storage) => storage.adapter.list(storage.relativeBase ? storage.base ? appendPath(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)))).flat().filter(Boolean));
|
|
@@ -794,7 +828,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
794
828
|
*/
|
|
795
829
|
async remove(path) {
|
|
796
830
|
const normalizedPath = this.#normalizePath(path);
|
|
797
|
-
this.#
|
|
831
|
+
this.#logger.trace(`Removing file: ${normalizedPath}`);
|
|
798
832
|
const { relativeKey, adapter } = this.#getStorage(normalizedPath);
|
|
799
833
|
if (hasFileExtension(normalizedPath)) await adapter.remove(relativeKey);
|
|
800
834
|
else await adapter.clear(relativeKey);
|
|
@@ -812,7 +846,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
812
846
|
*/
|
|
813
847
|
removeSync(path) {
|
|
814
848
|
const normalizedPath = this.#normalizePath(path);
|
|
815
|
-
this.#
|
|
849
|
+
this.#logger.trace(`Removing file: ${normalizedPath}`);
|
|
816
850
|
const { relativeKey, adapter } = this.#getStorage(normalizedPath);
|
|
817
851
|
if (hasFileExtension(normalizedPath)) adapter.removeSync(relativeKey);
|
|
818
852
|
else adapter.clearSync(relativeKey);
|
|
@@ -958,7 +992,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
958
992
|
const filePath = await this.resolve(path, void 0, { isFile: true });
|
|
959
993
|
if (!filePath || !this.existsSync(filePath)) return;
|
|
960
994
|
const { adapter } = this.#getStorage(filePath);
|
|
961
|
-
this.#
|
|
995
|
+
this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);
|
|
962
996
|
return await adapter.get(filePath) ?? void 0;
|
|
963
997
|
}
|
|
964
998
|
/**
|
|
@@ -971,7 +1005,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
971
1005
|
const filePath = this.resolveSync(path, void 0, { isFile: true });
|
|
972
1006
|
if (!filePath || !this.existsSync(filePath)) return;
|
|
973
1007
|
const { adapter } = this.#getStorage(filePath);
|
|
974
|
-
this.#
|
|
1008
|
+
this.#logger.trace(`Reading ${adapter.name} file: ${filePath}`);
|
|
975
1009
|
return adapter.getSync(filePath) ?? void 0;
|
|
976
1010
|
}
|
|
977
1011
|
/**
|
|
@@ -986,15 +1020,15 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
986
1020
|
const meta = options.meta ?? {};
|
|
987
1021
|
const resolvedPath = await this.resolve(this.#normalizePath(path)) || path;
|
|
988
1022
|
const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
|
|
989
|
-
this.#
|
|
1023
|
+
this.#logger.trace(`Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(data)).size)})`);
|
|
990
1024
|
let code = data;
|
|
991
1025
|
try {
|
|
992
1026
|
if (!options.skipFormat) code = await format(this.#context, resolvedPath, data);
|
|
993
1027
|
} catch (err) {
|
|
994
|
-
if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#
|
|
1028
|
+
if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#logger.warn(`Failed to format file ${resolvedPath} before writing: ${err.message}`);
|
|
995
1029
|
code = data;
|
|
996
1030
|
}
|
|
997
|
-
this.#
|
|
1031
|
+
this.#logger.trace(`Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
|
|
998
1032
|
const id = this.#normalizeId(meta.id || resolvedPath);
|
|
999
1033
|
this.metadata[id] = {
|
|
1000
1034
|
type: "normal",
|
|
@@ -1017,7 +1051,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1017
1051
|
const meta = options.meta ?? {};
|
|
1018
1052
|
const resolvedPath = this.resolveSync(this.#normalizePath(path)) || path;
|
|
1019
1053
|
const { relativeKey, adapter } = this.#getStorage(resolvedPath, options.storage);
|
|
1020
|
-
this.#
|
|
1054
|
+
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: ${prettyBytes(new Blob(toArray(data)).size)})`);
|
|
1021
1055
|
const id = this.#normalizeId(meta.id || resolvedPath);
|
|
1022
1056
|
this.metadata[id] = {
|
|
1023
1057
|
type: "normal",
|
|
@@ -1181,7 +1215,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1181
1215
|
async dispose() {
|
|
1182
1216
|
if (!this.#isDisposed) {
|
|
1183
1217
|
this.#isDisposed = true;
|
|
1184
|
-
this.#
|
|
1218
|
+
this.#logger.debug("Disposing virtual file system...");
|
|
1185
1219
|
await this.remove(joinPaths(this.#context.dataPath, "fs.bin"));
|
|
1186
1220
|
const message = new capnp.Message();
|
|
1187
1221
|
const fs = message.initRoot(FileSystem);
|
|
@@ -1216,7 +1250,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1216
1250
|
await writeFileBuffer(joinPaths(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
|
|
1217
1251
|
if (!this.#context.config.skipCache) this.resolverCache.save(true);
|
|
1218
1252
|
await Promise.all(this.#getStorages().map(async (storage) => storage.adapter.dispose()));
|
|
1219
|
-
this.#
|
|
1253
|
+
this.#logger.trace("Virtual file system has been disposed.");
|
|
1220
1254
|
}
|
|
1221
1255
|
}
|
|
1222
1256
|
/**
|
|
@@ -1477,6 +1511,18 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1477
1511
|
}, {}) : this.config.resolve.alias : {});
|
|
1478
1512
|
}
|
|
1479
1513
|
/**
|
|
1514
|
+
* 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.
|
|
1515
|
+
*/
|
|
1516
|
+
get logger() {
|
|
1517
|
+
const options = {
|
|
1518
|
+
...this.config,
|
|
1519
|
+
...this.options
|
|
1520
|
+
};
|
|
1521
|
+
const logger = withLogger(createLogger(this.config.name, options), createLogger(this.config.name, options, (type, message) => sendWriteLogMessage(this, type, message)));
|
|
1522
|
+
if (this.config.customLogger) return withCustomLogger(logger, this.config.customLogger);
|
|
1523
|
+
return logger;
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1480
1526
|
* Gets the parser cache.
|
|
1481
1527
|
*/
|
|
1482
1528
|
get parserCache() {
|
|
@@ -1531,60 +1577,6 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1531
1577
|
this.options = options;
|
|
1532
1578
|
}
|
|
1533
1579
|
/**
|
|
1534
|
-
* 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.
|
|
1535
|
-
*
|
|
1536
|
-
* @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.
|
|
1537
|
-
* @returns A log function that can be used to log messages with the specified configuration.
|
|
1538
|
-
*/
|
|
1539
|
-
createLog(config) {
|
|
1540
|
-
const log = createLogFn({
|
|
1541
|
-
...config,
|
|
1542
|
-
logLevel: this.logLevel
|
|
1543
|
-
});
|
|
1544
|
-
return (meta, ...args) => {
|
|
1545
|
-
log(meta, ...args);
|
|
1546
|
-
process.send?.({
|
|
1547
|
-
id: uuid(),
|
|
1548
|
-
type: "write-log",
|
|
1549
|
-
executionId: config?.executionId ?? this.options.executionId,
|
|
1550
|
-
executionIndex: config?.executionIndex ?? this.options.executionIndex,
|
|
1551
|
-
timestamp: Date.now(),
|
|
1552
|
-
payload: {
|
|
1553
|
-
level: meta && isSetObject(meta) && isSetString(meta.level) ? meta.level : isSetString(meta) ? meta : "info",
|
|
1554
|
-
...config,
|
|
1555
|
-
args
|
|
1556
|
-
}
|
|
1557
|
-
});
|
|
1558
|
-
};
|
|
1559
|
-
}
|
|
1560
|
-
/**
|
|
1561
|
-
* Extend the current log function instance with a new name
|
|
1562
|
-
*
|
|
1563
|
-
* @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.
|
|
1564
|
-
* @returns A log function
|
|
1565
|
-
*/
|
|
1566
|
-
extendLog(config) {
|
|
1567
|
-
const log = extendLogFn(this.log, {
|
|
1568
|
-
...config,
|
|
1569
|
-
logLevel: this.logLevel
|
|
1570
|
-
});
|
|
1571
|
-
return (meta, ...args) => {
|
|
1572
|
-
log(meta, ...args);
|
|
1573
|
-
process.send?.({
|
|
1574
|
-
id: uuid(),
|
|
1575
|
-
type: "write-log",
|
|
1576
|
-
executionId: config.executionId ?? this.options.executionId,
|
|
1577
|
-
executionIndex: config.executionIndex ?? this.options.executionIndex,
|
|
1578
|
-
timestamp: Date.now(),
|
|
1579
|
-
payload: {
|
|
1580
|
-
level: meta && isSetObject(meta) && isSetString(meta.level) ? meta.level : isSetString(meta) ? meta : "info",
|
|
1581
|
-
...config,
|
|
1582
|
-
args
|
|
1583
|
-
}
|
|
1584
|
-
});
|
|
1585
|
-
};
|
|
1586
|
-
}
|
|
1587
|
-
/**
|
|
1588
1580
|
* 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.
|
|
1589
1581
|
*
|
|
1590
1582
|
* @remarks
|
|
@@ -1627,6 +1619,9 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1627
1619
|
headers: cached.headers
|
|
1628
1620
|
});
|
|
1629
1621
|
}
|
|
1622
|
+
const logger = this.extendLogger({ category: "network" });
|
|
1623
|
+
const startTime = Date.now();
|
|
1624
|
+
logger.trace(`Sending fetch request (${options.method?.toUpperCase() || "GET"}): ${input.toString()}`);
|
|
1630
1625
|
const response = await fetchRequest(input, {
|
|
1631
1626
|
timeout: 12e3,
|
|
1632
1627
|
...options
|
|
@@ -1640,6 +1635,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1640
1635
|
if (!this.config.skipCache && !options.skipCache) try {
|
|
1641
1636
|
this.requestCache.set(cacheKey, result);
|
|
1642
1637
|
} catch {}
|
|
1638
|
+
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]"}`);
|
|
1643
1639
|
return new Response(result.body, {
|
|
1644
1640
|
status: result.status,
|
|
1645
1641
|
statusText: result.statusText,
|
|
@@ -2015,6 +2011,13 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2015
2011
|
* Initialize the context with the provided configuration options
|
|
2016
2012
|
*/
|
|
2017
2013
|
async innerSetup() {
|
|
2014
|
+
const logger = this.extendLogger({ category: "config" });
|
|
2015
|
+
logger.trace(`Pre-setup Powerlines configuration object: \n${JSON.stringify({
|
|
2016
|
+
...omit(this.config, ["plugins"]),
|
|
2017
|
+
userConfig: this.config.userConfig ? omit(this.config.userConfig, ["plugins"]) : {},
|
|
2018
|
+
inlineConfig: this.config.inlineConfig ? omit(this.config.inlineConfig, ["plugins"]) : {},
|
|
2019
|
+
pluginConfig: this.config.pluginConfig ? omit(this.config.pluginConfig, ["plugins"]) : {}
|
|
2020
|
+
}, null, 2)}`);
|
|
2018
2021
|
if (!this.inputOptions.mode && !this.config.userConfig?.mode && !this.config.inlineConfig?.mode && !this.config.pluginConfig?.mode) {
|
|
2019
2022
|
this.options.mode = "production";
|
|
2020
2023
|
this.config.mode = "production";
|
|
@@ -2041,8 +2044,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2041
2044
|
else this.config.logLevel = DEFAULT_PRODUCTION_LOG_LEVEL;
|
|
2042
2045
|
if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = getTsconfigFilePath(this.config.cwd, this.config.root);
|
|
2043
2046
|
else if (this.config.tsconfig) this.config.tsconfig = replacePath(replacePathTokens(this, this.config.tsconfig), this.config.cwd);
|
|
2044
|
-
this.
|
|
2045
|
-
path: joinPaths(this.config.root, "dist"),
|
|
2047
|
+
this.config.output = defu(this.config.output ?? {}, {
|
|
2046
2048
|
copy: { assets: [
|
|
2047
2049
|
{ glob: "LICENSE" },
|
|
2048
2050
|
{
|
|
@@ -2059,6 +2061,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2059
2061
|
});
|
|
2060
2062
|
this.config.output.format = getUnique(toArray(this.config.output?.format ?? (this.config.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
|
|
2061
2063
|
if (this.config.output.path) this.config.output.path = appendPath(replacePathTokens(this, this.config.output.path), this.config.cwd);
|
|
2064
|
+
else this.config.output.path = appendPath(joinPaths(this.config.root, "dist"), this.config.cwd);
|
|
2062
2065
|
if (this.config.output.copy !== false) {
|
|
2063
2066
|
this.config.output.copy ??= {};
|
|
2064
2067
|
if (!this.config.root.replace(/^\.\/?/, "")) this.config.output.copy.path = this.config.output.copy.path ? appendPath(replacePathTokens(this, this.config.output.copy.path), this.config.cwd) : this.config.output.path;
|
|
@@ -2086,7 +2089,12 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2086
2089
|
}));
|
|
2087
2090
|
if (isSetString(this.config.output?.storage) && this.config.output.storage === "virtual" || isSetObject(this.config.output?.storage) && Object.values(this.config.output.storage).every((adapter) => adapter.preset === "virtual")) this.config.output.overwrite = true;
|
|
2088
2091
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
2089
|
-
this.
|
|
2092
|
+
if (isSetObject(this.config.userConfig) && isSetObject(this.config.inlineConfig) && isSetObject(this.config.pluginConfig)) logger.debug(`Resolved Powerlines configuration object: \n${JSON.stringify({
|
|
2093
|
+
...omit(this.config, ["plugins"]),
|
|
2094
|
+
userConfig: this.config.userConfig ? omit(this.config.userConfig, ["plugins"]) : {},
|
|
2095
|
+
inlineConfig: this.config.inlineConfig ? omit(this.config.inlineConfig, ["plugins"]) : {},
|
|
2096
|
+
pluginConfig: this.config.pluginConfig ? omit(this.config.pluginConfig, ["plugins"]) : {}
|
|
2097
|
+
}, null, 2)}`);
|
|
2090
2098
|
}
|
|
2091
2099
|
};
|
|
2092
2100
|
|
|
@@ -2136,7 +2144,7 @@ function mergeConfigs(currentResult, previousResults) {
|
|
|
2136
2144
|
async function callHook(context, key, options, ...args) {
|
|
2137
2145
|
const hooks = context.selectHooks(key, options);
|
|
2138
2146
|
if (hooks.length > 0) {
|
|
2139
|
-
context.debug(` 🧩 Calling ${hooks.length} ${chalk.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)} plugin hook${hooks.length > 1 ? "s" : ""}:\n${hooks.map((hook, index) => ` ${index + 1}. ${colorText(hook.plugin.name)}`).join("\n")}`);
|
|
2147
|
+
context.extendLogger({ category: "hooks" }).debug(` 🧩 Calling ${hooks.length} ${chalk.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)} plugin hook${hooks.length > 1 ? "s" : ""}:\n${hooks.map((hook, index) => ` ${index + 1}. ${colorText(hook.plugin.name)}`).join("\n")}`);
|
|
2140
2148
|
const invokeHook = async (hook, hookArgs) => {
|
|
2141
2149
|
return Reflect.apply(hook.handler, hook.context, hookArgs);
|
|
2142
2150
|
};
|
|
@@ -2236,7 +2244,7 @@ function createPluginContext(pluginId, plugin, environment) {
|
|
|
2236
2244
|
const normalizeMessage = (message) => {
|
|
2237
2245
|
return isString(message) ? message : message.message;
|
|
2238
2246
|
};
|
|
2239
|
-
const
|
|
2247
|
+
const logger = environment.extendLogger({ plugin: plugin.name.replaceAll(":", " - ") });
|
|
2240
2248
|
const callHookFn = async (hook, options, ...args) => {
|
|
2241
2249
|
return environment.$$internal.api.callHook(hook, {
|
|
2242
2250
|
sequential: true,
|
|
@@ -2255,24 +2263,24 @@ function createPluginContext(pluginId, plugin, environment) {
|
|
|
2255
2263
|
meta
|
|
2256
2264
|
};
|
|
2257
2265
|
if (prop === "id") return pluginId;
|
|
2258
|
-
if (prop === "
|
|
2266
|
+
if (prop === "logger") return logger;
|
|
2259
2267
|
if (prop === "fatal") return (message) => {
|
|
2260
|
-
|
|
2268
|
+
logger.error(normalizeMessage(message));
|
|
2261
2269
|
};
|
|
2262
2270
|
if (prop === "error") return (message) => {
|
|
2263
|
-
|
|
2271
|
+
logger.error(normalizeMessage(message));
|
|
2264
2272
|
};
|
|
2265
2273
|
if (prop === "warn") return (message) => {
|
|
2266
|
-
|
|
2274
|
+
logger.warn(normalizeMessage(message));
|
|
2267
2275
|
};
|
|
2268
2276
|
if (prop === "info") return (message) => {
|
|
2269
|
-
|
|
2277
|
+
logger.info(normalizeMessage(message));
|
|
2270
2278
|
};
|
|
2271
2279
|
if (prop === "debug") return (message) => {
|
|
2272
|
-
|
|
2280
|
+
logger.debug(normalizeMessage(message));
|
|
2273
2281
|
};
|
|
2274
2282
|
if (prop === "trace") return (message) => {
|
|
2275
|
-
|
|
2283
|
+
logger.trace(normalizeMessage(message));
|
|
2276
2284
|
};
|
|
2277
2285
|
return environment[prop];
|
|
2278
2286
|
},
|
|
@@ -2291,7 +2299,7 @@ function createPluginContext(pluginId, plugin, environment) {
|
|
|
2291
2299
|
"addPlugin",
|
|
2292
2300
|
"selectHooks"
|
|
2293
2301
|
].includes(prop)) {
|
|
2294
|
-
|
|
2302
|
+
logger.warn(`Cannot set the read-only "${String(prop)}" property`);
|
|
2295
2303
|
return false;
|
|
2296
2304
|
}
|
|
2297
2305
|
environment[prop] = value;
|
|
@@ -2343,26 +2351,26 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
2343
2351
|
return this.#hooks;
|
|
2344
2352
|
}
|
|
2345
2353
|
/**
|
|
2346
|
-
* Create a new
|
|
2354
|
+
* Create a new logger instance
|
|
2347
2355
|
*
|
|
2348
|
-
* @param
|
|
2349
|
-
* @returns A
|
|
2356
|
+
* @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.
|
|
2357
|
+
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
2350
2358
|
*/
|
|
2351
|
-
|
|
2352
|
-
return super.
|
|
2353
|
-
...
|
|
2359
|
+
createLogger(options, callback) {
|
|
2360
|
+
return super.createLogger({
|
|
2361
|
+
...options,
|
|
2354
2362
|
environment: this.environment?.name
|
|
2355
|
-
});
|
|
2363
|
+
}, callback);
|
|
2356
2364
|
}
|
|
2357
2365
|
/**
|
|
2358
|
-
* Extend the
|
|
2366
|
+
* Extend the base logger with additional configuration options
|
|
2359
2367
|
*
|
|
2360
|
-
* @param
|
|
2361
|
-
* @returns A
|
|
2368
|
+
* @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.
|
|
2369
|
+
* @returns A new logger client instance that extends the base logger with the provided configuration options.
|
|
2362
2370
|
*/
|
|
2363
|
-
|
|
2364
|
-
return super.
|
|
2365
|
-
...
|
|
2371
|
+
extendLogger(options) {
|
|
2372
|
+
return super.extendLogger({
|
|
2373
|
+
...options,
|
|
2366
2374
|
environment: this.environment?.name
|
|
2367
2375
|
});
|
|
2368
2376
|
}
|
|
@@ -2548,27 +2556,27 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
2548
2556
|
super(options);
|
|
2549
2557
|
}
|
|
2550
2558
|
/**
|
|
2551
|
-
* Create a new
|
|
2559
|
+
* Create a new logger instance
|
|
2552
2560
|
*
|
|
2553
|
-
* @param
|
|
2554
|
-
* @returns A
|
|
2561
|
+
* @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.
|
|
2562
|
+
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
2555
2563
|
*/
|
|
2556
|
-
|
|
2557
|
-
return super.
|
|
2558
|
-
...
|
|
2564
|
+
createLogger(options, callback) {
|
|
2565
|
+
return super.createLogger({
|
|
2566
|
+
...options,
|
|
2559
2567
|
executionId: this.id,
|
|
2560
2568
|
executionIndex: this.options.executionIndex
|
|
2561
|
-
});
|
|
2569
|
+
}, callback);
|
|
2562
2570
|
}
|
|
2563
2571
|
/**
|
|
2564
|
-
* Extend the
|
|
2572
|
+
* Extend the base logger with additional configuration options
|
|
2565
2573
|
*
|
|
2566
|
-
* @param
|
|
2567
|
-
* @returns A
|
|
2574
|
+
* @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.
|
|
2575
|
+
* @returns A new logger client instance that extends the base logger with the provided configuration options.
|
|
2568
2576
|
*/
|
|
2569
|
-
|
|
2570
|
-
return super.
|
|
2571
|
-
...
|
|
2577
|
+
extendLogger(options) {
|
|
2578
|
+
return super.extendLogger({
|
|
2579
|
+
...options,
|
|
2572
2580
|
executionId: this.id,
|
|
2573
2581
|
executionIndex: this.options.executionIndex
|
|
2574
2582
|
});
|
|
@@ -2675,4 +2683,4 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
2675
2683
|
|
|
2676
2684
|
//#endregion
|
|
2677
2685
|
export { mergeConfigs as a, callHook as i, PowerlinesEnvironmentContext as n, PowerlinesContext as o, createPluginContext as r, writeMetaFile as s, PowerlinesExecutionContext as t };
|
|
2678
|
-
//# sourceMappingURL=execution-context-
|
|
2686
|
+
//# sourceMappingURL=execution-context-CFJst4Fz.mjs.map
|