@powerlines/engine 0.43.29 → 0.43.31
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 +112 -42
- package/dist/_internal/worker.mjs +112 -42
- package/dist/_internal/worker.mjs.map +1 -1
- package/dist/api.cjs +9 -7
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +9 -7
- package/dist/api.mjs.map +1 -1
- package/dist/{base-context-B9AROf66.cjs → base-context-CPoqO4io.cjs} +9 -8
- package/dist/{base-context-D8a2XGIK.mjs → base-context-SmQ6OfXm.mjs} +10 -9
- package/dist/base-context-SmQ6OfXm.mjs.map +1 -0
- package/dist/context/index.cjs +3 -3
- package/dist/context/index.d.cts +37 -20
- package/dist/context/index.d.cts.map +1 -1
- package/dist/context/index.d.mts +37 -20
- package/dist/context/index.d.mts.map +1 -1
- package/dist/context/index.mjs +3 -3
- package/dist/{engine-context-qCVw66U_.cjs → engine-context-CEu21ZZf.cjs} +36 -10
- package/dist/{engine-context-DsA9XGVb.mjs → engine-context-D7CWyTsr.mjs} +36 -11
- package/dist/engine-context-D7CWyTsr.mjs.map +1 -0
- package/dist/{execution-context-CBJxP2B2.mjs → execution-context-C_7IC8er.mjs} +110 -40
- package/dist/execution-context-C_7IC8er.mjs.map +1 -0
- package/dist/{execution-context-CprxWvYn.cjs → execution-context-DsT6s1du.cjs} +108 -38
- package/dist/index.cjs +135 -54
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +135 -54
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-context-D7CWyTsr.mjs","names":["#executions"],"sources":["../src/context/engine-context.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n EngineContext,\n EngineOptions,\n ExecutionState\n} from \"@powerlines/core\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { PowerlinesBaseContext } from \"./base-context\";\n\nexport class PowerlinesEngineContext\n extends PowerlinesBaseContext\n implements EngineContext\n{\n #executions: ExecutionState[] = [];\n\n /**\n * Creates a new instance of the PowerlinesEngineContext class.\n *\n * @param options - The options to initialize the context with.\n * @returns A promise that resolves to an instance of the PowerlinesEngineContext class.\n */\n public static async fromOptions(\n options: EngineOptions\n ): Promise<PowerlinesEngineContext> {\n const context = new PowerlinesEngineContext();\n await context.init(options);\n\n if (!context.configFile?.config) {\n context.fatal(\n \"No configuration file found. Please ensure you have a valid configuration file in your project.\"\n );\n throw new Error(\"No configuration file found\");\n }\n\n if (Array.isArray(context.configFile.config)) {\n context.#executions = await Promise.all(\n context.configFile.config.map(async (_, executionIndex) => {\n const executionId = uuid();\n\n return {\n executionId,\n options: { ...context.options, executionId, executionIndex },\n active: {\n command: null,\n hook: null,\n plugin: null\n }\n };\n })\n );\n } else {\n const executionId = uuid();\n context.#executions = [\n {\n executionId,\n options: { ...context.options, executionId, executionIndex: 0 },\n active: {\n command: null,\n hook: null,\n plugin: null\n }\n }\n ];\n }\n\n return context;\n }\n\n /**\n * A list of all command executions that will be run during the lifecycle of the engine\n *\n * @returns An array of {@link ExecutionState} representing each execution context for the engine.\n */\n public get executions(): ExecutionState[] {\n return this.#executions;\n }\n}\n"],"mappings":";;;;AA0BA,IAAa,0BAAb,MAAa,gCACH,sBAEV;CACE,cAAgC,EAAE;;;;;;;CAQlC,aAAoB,YAClB,SACkC;EAClC,MAAM,UAAU,IAAI,yBAAyB;AAC7C,QAAM,QAAQ,KAAK,QAAQ;AAE3B,MAAI,CAAC,QAAQ,YAAY,QAAQ;AAC/B,WAAQ,MACN,kGACD;AACD,SAAM,IAAI,MAAM,8BAA8B;;AAGhD,MAAI,MAAM,QAAQ,QAAQ,WAAW,OAAO,CAC1C,UAAQA,aAAc,MAAM,QAAQ,IAClC,QAAQ,WAAW,OAAO,IAAI,OAAO,GAAG,mBAAmB;GACzD,MAAM,cAAc,MAAM;AAE1B,UAAO;IACL;IACA,SAAS;KAAE,GAAG,QAAQ;KAAS;KAAa;KAAgB;IAC5D,QAAQ;KACN,SAAS;KACT,MAAM;KACN,QAAQ;KACT;IACF;IACD,CACH;OACI;GACL,MAAM,cAAc,MAAM;AAC1B,YAAQA,aAAc,CACpB;IACE;IACA,SAAS;KAAE,GAAG,QAAQ;KAAS;KAAa,gBAAgB;KAAG;IAC/D,QAAQ;KACN,SAAS;KACT,MAAM;KACN,QAAQ;KACT;IACF,CACF;;AAGH,SAAO;;;;;;;CAQT,IAAW,aAA+B;AACxC,SAAO,MAAKA"}
|
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
import { t as PowerlinesBaseContext } from "./base-context-
|
|
1
|
+
import { t as PowerlinesBaseContext } from "./base-context-SmQ6OfXm.mjs";
|
|
2
2
|
import { a as FileSystem } from "./fs-D1nIP45P.mjs";
|
|
3
|
-
import { n as FileSystemStorageAdapter, t as VirtualStorageAdapter } from "./virtual-
|
|
3
|
+
import { n as FileSystemStorageAdapter, t as VirtualStorageAdapter } from "./virtual-CUgOdyIa.mjs";
|
|
4
4
|
import { i as getTsconfigFilePath } from "./tsconfig-Cstsoprg.mjs";
|
|
5
5
|
import { CACHE_HASH_LENGTH, DEFAULT_ENVIRONMENT, GLOBAL_ENVIRONMENT, PLUGIN_NON_HOOK_FIELDS, ROOT_HASH_LENGTH } from "@powerlines/core/constants";
|
|
6
6
|
import { getResolutionCombinations, resolve, resolvePackage, resolveSync } from "@stryke/fs/resolve";
|
|
7
7
|
import { joinPaths } from "@stryke/path/join";
|
|
8
8
|
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
9
9
|
import { isSet } from "@stryke/type-checks/is-set";
|
|
10
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
10
11
|
import { isString } from "@stryke/type-checks/is-string";
|
|
11
|
-
import {
|
|
12
|
+
import { toArray } from "@stryke/convert/to-array";
|
|
13
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
14
|
+
import { uuid } from "@stryke/unique-id/uuid";
|
|
15
|
+
import { colorText } from "@powerlines/core/lib/logger";
|
|
12
16
|
import { isEqual } from "@stryke/path/is-equal";
|
|
17
|
+
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
13
18
|
import { isNull } from "@stryke/type-checks/is-null";
|
|
14
19
|
import chalk from "chalk";
|
|
15
20
|
import defu, { createDefu, defu as defu$1 } from "defu";
|
|
16
21
|
import { joinPaths as joinPaths$1 } from "@stryke/path/join-paths";
|
|
17
22
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
18
|
-
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
19
23
|
import { format } from "@powerlines/core/lib/utilities/format";
|
|
20
24
|
import { addPluginHook, dedupeHooklist, isDuplicate, isPlugin, isPluginConfig, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens } from "@powerlines/core/plugin-utils";
|
|
21
|
-
import { toArray } from "@stryke/convert/to-array";
|
|
22
25
|
import { existsSync } from "@stryke/fs/exists";
|
|
23
26
|
import { getUnique, getUniqueBy } from "@stryke/helpers/get-unique";
|
|
24
27
|
import { omit } from "@stryke/helpers/omit";
|
|
25
28
|
import { appendPath } from "@stryke/path/append";
|
|
26
29
|
import { findFileDotExtensionSafe, findFileExtensionSafe, findFileName, findFilePath, hasFileExtension } from "@stryke/path/file-path-fns";
|
|
27
30
|
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
28
|
-
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
29
31
|
import { isFunction } from "@stryke/type-checks/is-function";
|
|
30
32
|
import { isObject } from "@stryke/type-checks/is-object";
|
|
31
|
-
import {
|
|
33
|
+
import { createLog as createLog$1 } from "@powerlines/core";
|
|
32
34
|
import { readJsonFile } from "@stryke/fs/json";
|
|
33
35
|
import { deepClone } from "@stryke/helpers/deep-clone";
|
|
34
36
|
import { getUniqueInputs, isTypeDefinition, resolveInputsSync } from "@powerlines/core/lib/entry";
|
|
@@ -37,7 +39,6 @@ import { murmurhash } from "@stryke/hash";
|
|
|
37
39
|
import { hashDirectory } from "@stryke/hash/node";
|
|
38
40
|
import { fetchRequest } from "@stryke/http/fetch";
|
|
39
41
|
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
40
|
-
import { uuid } from "@stryke/unique-id/uuid";
|
|
41
42
|
import { match, tsconfigPathsToRegExp } from "bundle-require";
|
|
42
43
|
import { resolveCompatibilityDates } from "compatx";
|
|
43
44
|
import { create } from "flat-cache";
|
|
@@ -59,6 +60,7 @@ import { getField } from "@stryke/helpers/get-field";
|
|
|
59
60
|
//#region src/_internal/helpers/environment.ts
|
|
60
61
|
function createEnvironment(name, config = {}) {
|
|
61
62
|
return defu(config.environments?.[name] ?? {}, {
|
|
63
|
+
environmentId: uuid(),
|
|
62
64
|
name,
|
|
63
65
|
title: config.title ?? titleCase(config.name),
|
|
64
66
|
ssr: false,
|
|
@@ -638,7 +640,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
638
640
|
return ret;
|
|
639
641
|
}, {});
|
|
640
642
|
}
|
|
641
|
-
this.#log = extendLog(
|
|
643
|
+
this.#log = context.extendLog("VFS");
|
|
642
644
|
}
|
|
643
645
|
/**
|
|
644
646
|
* Asynchronously checks if a file exists in the virtual file system (VFS).
|
|
@@ -1530,22 +1532,10 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1530
1532
|
* @returns A promise that resolves to the cloned context.
|
|
1531
1533
|
*/
|
|
1532
1534
|
async clone() {
|
|
1533
|
-
const clone = await PowerlinesContext.fromOptions(this.
|
|
1535
|
+
const clone = await PowerlinesContext.fromOptions(this.options);
|
|
1534
1536
|
return this.copyTo(clone);
|
|
1535
1537
|
}
|
|
1536
1538
|
/**
|
|
1537
|
-
* Create a new logger instance
|
|
1538
|
-
*
|
|
1539
|
-
* @param name - The name to use for the logger instance
|
|
1540
|
-
* @returns A logger function
|
|
1541
|
-
*/
|
|
1542
|
-
createLog(name = null) {
|
|
1543
|
-
return createLog(name, {
|
|
1544
|
-
...this.config,
|
|
1545
|
-
logLevel: isNull(this.logLevel) ? "silent" : this.logLevel
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
|
-
/**
|
|
1549
1539
|
* A function to perform HTTP fetch requests
|
|
1550
1540
|
*
|
|
1551
1541
|
* @remarks
|
|
@@ -1921,6 +1911,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1921
1911
|
for (const [key, value] of Object.entries(this)) if (!SKIP_CLONING_PROPS.includes(key)) if (isObject(value) || Array.isArray(value)) context[key] = deepClone(value);
|
|
1922
1912
|
else context[key] = value;
|
|
1923
1913
|
context.inputOptions = deepClone(this.inputOptions);
|
|
1914
|
+
context.options = deepClone(this.options);
|
|
1924
1915
|
context.dependencies = deepClone(this.dependencies);
|
|
1925
1916
|
context.devDependencies = deepClone(this.devDependencies);
|
|
1926
1917
|
context.persistedMeta = this.persistedMeta ? deepClone(this.persistedMeta) : void 0;
|
|
@@ -1942,7 +1933,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1942
1933
|
*/
|
|
1943
1934
|
async init(options = {}) {
|
|
1944
1935
|
await super.init(options);
|
|
1945
|
-
this.options.
|
|
1936
|
+
this.options.executionIndex = options.executionIndex ?? this.options.executionIndex ?? 0;
|
|
1946
1937
|
const projectJsonPath = joinPaths(this.options.cwd, this.options.root, "project.json");
|
|
1947
1938
|
if (existsSync(projectJsonPath)) this.projectJson = await readJsonFile(projectJsonPath);
|
|
1948
1939
|
const packageJsonPath = joinPaths(this.options.cwd, this.options.root, "package.json");
|
|
@@ -1951,7 +1942,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1951
1942
|
this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
|
|
1952
1943
|
}
|
|
1953
1944
|
this.#checksum = await this.generateChecksum(joinPaths(this.options.cwd, this.options.root));
|
|
1954
|
-
const userConfig = this.configFile.config ? Array.isArray(this.configFile.config) && this.configFile.config.length > this.options.
|
|
1945
|
+
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 : {};
|
|
1955
1946
|
this.resolvedConfig = {
|
|
1956
1947
|
...this.options,
|
|
1957
1948
|
...userConfig,
|
|
@@ -1982,7 +1973,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1982
1973
|
if (this.config.userConfig.resolve?.noExternal) this.config.userConfig.resolve.noExternal = getUnique(this.config.userConfig.resolve.noExternal);
|
|
1983
1974
|
if (this.config.resolve.external) this.config.resolve.external = getUnique(this.config.resolve.external);
|
|
1984
1975
|
if (this.config.resolve.noExternal) this.config.resolve.noExternal = getUnique(this.config.resolve.noExternal);
|
|
1985
|
-
this.config.plugins = (this.config.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
|
|
1976
|
+
this.config.plugins = (this.config.plugins ?? []).flatMap((plugin) => toArray(plugin)).filter(Boolean).reduce((ret, plugin) => {
|
|
1986
1977
|
if (isPlugin(plugin) && isDuplicate(plugin, ret.filter((p) => isPlugin(p)))) return ret;
|
|
1987
1978
|
ret.push(plugin);
|
|
1988
1979
|
return ret;
|
|
@@ -2014,7 +2005,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2014
2005
|
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;
|
|
2015
2006
|
else this.config.output.copy.path = appendPath(replacePathTokens(this, this.config.output.copy.path || joinPaths("dist", this.config.root)), this.config.cwd);
|
|
2016
2007
|
}
|
|
2017
|
-
if (this.config.output.dts !== false && this.config.output.types !== false) this.config.output.types = appendPath(replacePathTokens(this, this.config.output.types || joinPaths(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`)), this.config.cwd);
|
|
2008
|
+
if (this.config.output.dts !== false && this.config.output.types !== false) this.config.output.types = appendPath(replacePathTokens(this, this.config.userConfig?.output?.types || this.config.inlineConfig?.output?.types || this.config.pluginConfig?.output?.types || joinPaths(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`)), this.config.cwd);
|
|
2018
2009
|
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 = getUniqueBy(this.config.output.copy.assets.map((asset) => {
|
|
2019
2010
|
return {
|
|
2020
2011
|
glob: isSetObject(asset) ? asset.glob : asset,
|
|
@@ -2176,15 +2167,16 @@ function extractHooks(context, hooks, plugin, key, parentKey) {
|
|
|
2176
2167
|
/**
|
|
2177
2168
|
* Create a Proxy-based PluginContext
|
|
2178
2169
|
*
|
|
2170
|
+
* @param pluginId - The unique identifier of the plugin
|
|
2179
2171
|
* @param plugin - The plugin instance
|
|
2180
2172
|
* @param environment - The environment context
|
|
2181
2173
|
* @returns The proxied plugin context
|
|
2182
2174
|
*/
|
|
2183
|
-
function createPluginContext(plugin, environment) {
|
|
2175
|
+
function createPluginContext(pluginId, plugin, environment) {
|
|
2184
2176
|
const normalizeMessage = (message) => {
|
|
2185
2177
|
return isString(message) ? message : message.message;
|
|
2186
2178
|
};
|
|
2187
|
-
const log = environment.extendLog(plugin.name.replaceAll(":", " - "));
|
|
2179
|
+
const log = environment.extendLog(pluginId, plugin.name.replaceAll(":", " - "));
|
|
2188
2180
|
const callHookFn = async (hook, options, ...args) => {
|
|
2189
2181
|
return environment.$$internal.api.callHook(hook, {
|
|
2190
2182
|
sequential: true,
|
|
@@ -2202,6 +2194,7 @@ function createPluginContext(plugin, environment) {
|
|
|
2202
2194
|
callHook: callHookFn,
|
|
2203
2195
|
meta
|
|
2204
2196
|
};
|
|
2197
|
+
if (prop === "id") return pluginId;
|
|
2205
2198
|
if (prop === "log" || prop === "logger") return log;
|
|
2206
2199
|
if (prop === "fatal") return (message) => {
|
|
2207
2200
|
log(LogLevelLabel.FATAL, normalizeMessage(message));
|
|
@@ -2226,6 +2219,7 @@ function createPluginContext(plugin, environment) {
|
|
|
2226
2219
|
set(_, prop, value) {
|
|
2227
2220
|
if ([
|
|
2228
2221
|
"$$internal",
|
|
2222
|
+
"id",
|
|
2229
2223
|
"environment",
|
|
2230
2224
|
"config",
|
|
2231
2225
|
"log",
|
|
@@ -2277,17 +2271,10 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
2277
2271
|
*/
|
|
2278
2272
|
plugins = [];
|
|
2279
2273
|
/**
|
|
2280
|
-
*
|
|
2281
|
-
*
|
|
2282
|
-
* @param name - The name to use for the logger instance
|
|
2283
|
-
* @returns A logger function
|
|
2274
|
+
* 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.
|
|
2284
2275
|
*/
|
|
2285
|
-
|
|
2286
|
-
return
|
|
2287
|
-
...this.config,
|
|
2288
|
-
logLevel: isNull(this.config.logLevel) ? "silent" : this.config.logLevel,
|
|
2289
|
-
environment: this.environment?.name
|
|
2290
|
-
});
|
|
2276
|
+
get id() {
|
|
2277
|
+
return this.environment.environmentId;
|
|
2291
2278
|
}
|
|
2292
2279
|
/**
|
|
2293
2280
|
* The hooks registered by plugins in this environment
|
|
@@ -2296,6 +2283,54 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
2296
2283
|
return this.#hooks;
|
|
2297
2284
|
}
|
|
2298
2285
|
/**
|
|
2286
|
+
* Create a new logger instance
|
|
2287
|
+
*
|
|
2288
|
+
* @param source - The source name to use for the logger instance, which can be used to identify the origin of log messages in the logs for better traceability. This is typically the name of the plugin or module that is creating the logger instance.
|
|
2289
|
+
* @returns A logger function
|
|
2290
|
+
*/
|
|
2291
|
+
createLog(source = null) {
|
|
2292
|
+
return (level, ...args) => {
|
|
2293
|
+
process.send?.({
|
|
2294
|
+
id: uuid(),
|
|
2295
|
+
type: "write-log",
|
|
2296
|
+
executionId: this.options.executionId,
|
|
2297
|
+
executionIndex: this.options.executionIndex,
|
|
2298
|
+
timestamp: Date.now(),
|
|
2299
|
+
payload: {
|
|
2300
|
+
level,
|
|
2301
|
+
source,
|
|
2302
|
+
environment: this.environment?.name,
|
|
2303
|
+
args
|
|
2304
|
+
}
|
|
2305
|
+
});
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2308
|
+
/**
|
|
2309
|
+
* Extend the current logger instance with a new name
|
|
2310
|
+
*
|
|
2311
|
+
* @param source - The name of the source to use for the extended logger instance
|
|
2312
|
+
* @param plugin - An optional plugin name to use for the extended logger instance, which can be used to identify the origin of log messages in the logs for better traceability. This is typically the name of the plugin or module that is creating the logger instance.
|
|
2313
|
+
* @returns A logger function
|
|
2314
|
+
*/
|
|
2315
|
+
extendLog(source, plugin) {
|
|
2316
|
+
return (level, ...args) => {
|
|
2317
|
+
process.send?.({
|
|
2318
|
+
id: uuid(),
|
|
2319
|
+
type: "write-log",
|
|
2320
|
+
executionId: this.options.executionId,
|
|
2321
|
+
executionIndex: this.options.executionIndex,
|
|
2322
|
+
timestamp: Date.now(),
|
|
2323
|
+
payload: {
|
|
2324
|
+
level,
|
|
2325
|
+
source,
|
|
2326
|
+
plugin,
|
|
2327
|
+
environment: this.environment?.name,
|
|
2328
|
+
args
|
|
2329
|
+
}
|
|
2330
|
+
});
|
|
2331
|
+
};
|
|
2332
|
+
}
|
|
2333
|
+
/**
|
|
2299
2334
|
* 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.
|
|
2300
2335
|
*
|
|
2301
2336
|
* @remarks
|
|
@@ -2325,8 +2360,10 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
2325
2360
|
if (isPluginConfig(result)) return this.$$internal.addPlugin(result);
|
|
2326
2361
|
resolvedPlugin = isPlugin(result) ? result : plugin;
|
|
2327
2362
|
}
|
|
2328
|
-
const
|
|
2363
|
+
const pluginId = uuid();
|
|
2364
|
+
const context = createPluginContext(pluginId, resolvedPlugin, this);
|
|
2329
2365
|
this.plugins.push({
|
|
2366
|
+
pluginId,
|
|
2330
2367
|
plugin: resolvedPlugin,
|
|
2331
2368
|
context
|
|
2332
2369
|
});
|
|
@@ -2452,6 +2489,12 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
2452
2489
|
for (const environment of Object.values(this.environments)) environment.$$internal = super.$$internal;
|
|
2453
2490
|
}
|
|
2454
2491
|
/**
|
|
2492
|
+
* 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.
|
|
2493
|
+
*/
|
|
2494
|
+
get id() {
|
|
2495
|
+
return this.options.executionId;
|
|
2496
|
+
}
|
|
2497
|
+
/**
|
|
2455
2498
|
* A record of all environments by name
|
|
2456
2499
|
*/
|
|
2457
2500
|
get environments() {
|
|
@@ -2469,6 +2512,33 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
2469
2512
|
super(options);
|
|
2470
2513
|
}
|
|
2471
2514
|
/**
|
|
2515
|
+
* Create a new logger instance
|
|
2516
|
+
*
|
|
2517
|
+
* @param source - The source name to use for the logger instance, which can be used to identify the origin of log messages in the logs for better traceability. This is typically the name of the plugin or module that is creating the logger instance.
|
|
2518
|
+
* @returns A logger function
|
|
2519
|
+
*/
|
|
2520
|
+
createLog(source = null) {
|
|
2521
|
+
const logger = createLog$1(source, {
|
|
2522
|
+
...this.config,
|
|
2523
|
+
logLevel: isNull(this.config.logLevel) ? "silent" : this.config.logLevel
|
|
2524
|
+
});
|
|
2525
|
+
return (level, ...args) => {
|
|
2526
|
+
logger(level, ...args);
|
|
2527
|
+
process.send?.({
|
|
2528
|
+
id: uuid(),
|
|
2529
|
+
type: "write-log",
|
|
2530
|
+
executionId: this.id,
|
|
2531
|
+
executionIndex: this.options.executionIndex,
|
|
2532
|
+
timestamp: Date.now(),
|
|
2533
|
+
payload: {
|
|
2534
|
+
source,
|
|
2535
|
+
level,
|
|
2536
|
+
args
|
|
2537
|
+
}
|
|
2538
|
+
});
|
|
2539
|
+
};
|
|
2540
|
+
}
|
|
2541
|
+
/**
|
|
2472
2542
|
* 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.
|
|
2473
2543
|
*
|
|
2474
2544
|
* @remarks
|
|
@@ -2570,4 +2640,4 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
2570
2640
|
|
|
2571
2641
|
//#endregion
|
|
2572
2642
|
export { mergeConfigs as a, callHook as i, PowerlinesEnvironmentContext as n, PowerlinesContext as o, createPluginContext as r, writeMetaFile as s, PowerlinesExecutionContext as t };
|
|
2573
|
-
//# sourceMappingURL=execution-context-
|
|
2643
|
+
//# sourceMappingURL=execution-context-C_7IC8er.mjs.map
|