@powerlines/engine 0.44.8 → 0.44.10
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 +136 -61
- package/dist/_internal/worker.mjs +137 -62
- package/dist/_internal/worker.mjs.map +1 -1
- package/dist/api.cjs +5 -10
- package/dist/api.d.cts +3 -3
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +3 -3
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +5 -10
- package/dist/api.mjs.map +1 -1
- package/dist/{base-context-fOM4ZWUo.mjs → base-context-C6yzgs6K.mjs} +50 -21
- package/dist/base-context-C6yzgs6K.mjs.map +1 -0
- package/dist/{base-context-CAA1druQ.cjs → base-context-trNQZNsX.cjs} +49 -20
- package/dist/context/index.cjs +3 -3
- package/dist/context/index.d.cts +50 -17
- package/dist/context/index.d.cts.map +1 -1
- package/dist/context/index.d.mts +50 -17
- package/dist/context/index.d.mts.map +1 -1
- package/dist/context/index.mjs +3 -3
- package/dist/{engine-context-BWGxMU_n.mjs → engine-context-C-11i43N.mjs} +2 -2
- package/dist/{engine-context-BWGxMU_n.mjs.map → engine-context-C-11i43N.mjs.map} +1 -1
- package/dist/{engine-context-CUPubmrM.cjs → engine-context-D1_U6xVC.cjs} +1 -1
- package/dist/{execution-context-D-XTNs1z.cjs → execution-context-CsQO4NOI.cjs} +87 -42
- package/dist/{execution-context-BLq0jnIo.mjs → execution-context-DlQIqoRZ.mjs} +89 -44
- package/dist/execution-context-DlQIqoRZ.mjs.map +1 -0
- package/dist/index.cjs +6 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/base-context-fOM4ZWUo.mjs.map +0 -1
- package/dist/execution-context-BLq0jnIo.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PowerlinesBaseContext } from "./base-context-
|
|
1
|
+
import { t as PowerlinesBaseContext } from "./base-context-C6yzgs6K.mjs";
|
|
2
2
|
import { a as FileSystem } from "./fs-D1nIP45P.mjs";
|
|
3
3
|
import { n as FileSystemStorageAdapter, t as VirtualStorageAdapter } from "./virtual-CYGZHTDd.mjs";
|
|
4
4
|
import { i as getTsconfigFilePath } from "./tsconfig-CI6bla4E.mjs";
|
|
@@ -11,8 +11,9 @@ import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
|
11
11
|
import { isString } from "@stryke/type-checks/is-string";
|
|
12
12
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
13
13
|
import { uuid } from "@stryke/unique-id/uuid";
|
|
14
|
-
import { addPluginHook, createLogger, dedupeHooklist, isDuplicate, isPlugin, isPluginConfig, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens, withCustomLogger,
|
|
14
|
+
import { addPluginHook, createLogger, dedupeHooklist, isDuplicate, isPlugin, isPluginConfig, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn } from "@powerlines/core/plugin-utils";
|
|
15
15
|
import { colorText } from "@powerlines/core/plugin-utils/logging";
|
|
16
|
+
import { getEnvPaths } from "@stryke/env/get-env-paths";
|
|
16
17
|
import { appendPath } from "@stryke/path/append";
|
|
17
18
|
import { isEqual } from "@stryke/path/is-equal";
|
|
18
19
|
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
@@ -31,6 +32,7 @@ import { isObject } from "@stryke/type-checks/is-object";
|
|
|
31
32
|
import { readJsonFile } from "@stryke/fs/json";
|
|
32
33
|
import { deepClone } from "@stryke/helpers/deep-clone";
|
|
33
34
|
import { getUniqueInputs, isTypeDefinition, resolveInputsSync } from "@powerlines/core/lib/entry";
|
|
35
|
+
import { toBool } from "@stryke/convert/to-bool";
|
|
34
36
|
import { relativeToWorkspaceRoot } from "@stryke/fs/get-workspace-root";
|
|
35
37
|
import { murmurhash } from "@stryke/hash";
|
|
36
38
|
import { hashDirectory } from "@stryke/hash/node";
|
|
@@ -141,34 +143,34 @@ async function writeMetaFile(context) {
|
|
|
141
143
|
|
|
142
144
|
//#endregion
|
|
143
145
|
//#region src/_internal/ipc/send.ts
|
|
144
|
-
function sendWriteLogMessage(context,
|
|
145
|
-
const
|
|
146
|
-
...
|
|
147
|
-
...
|
|
146
|
+
function sendWriteLogMessage(context, meta, message) {
|
|
147
|
+
const combinedMeta = {
|
|
148
|
+
...context.logger.options,
|
|
149
|
+
...isSetObject(meta) ? meta : { type: meta }
|
|
148
150
|
};
|
|
149
151
|
process.send?.({
|
|
150
152
|
id: uuid(),
|
|
151
153
|
type: "write-log",
|
|
152
|
-
executionId:
|
|
153
|
-
executionIndex:
|
|
154
|
-
environment:
|
|
154
|
+
executionId: combinedMeta.executionId || context.config.executionId,
|
|
155
|
+
executionIndex: combinedMeta.executionIndex ?? context.config.executionIndex,
|
|
156
|
+
environment: combinedMeta.environment,
|
|
155
157
|
timestamp: Date.now(),
|
|
156
158
|
payload: {
|
|
157
159
|
meta: {
|
|
158
|
-
type,
|
|
159
|
-
category:
|
|
160
|
-
logId:
|
|
161
|
-
timestamp:
|
|
162
|
-
name:
|
|
163
|
-
executionId:
|
|
164
|
-
executionIndex:
|
|
165
|
-
command:
|
|
166
|
-
hook:
|
|
167
|
-
environment:
|
|
168
|
-
plugin:
|
|
169
|
-
source:
|
|
160
|
+
type: combinedMeta.type,
|
|
161
|
+
category: combinedMeta.category || LogCategories.GENERAL,
|
|
162
|
+
logId: combinedMeta.logId || uuid(),
|
|
163
|
+
timestamp: combinedMeta.timestamp ?? Date.now(),
|
|
164
|
+
name: combinedMeta.name || context.config.name,
|
|
165
|
+
executionId: combinedMeta.executionId || context.config.executionId,
|
|
166
|
+
executionIndex: combinedMeta.executionIndex ?? context.config.executionIndex,
|
|
167
|
+
command: combinedMeta.command || context.config.command,
|
|
168
|
+
hook: combinedMeta.hook,
|
|
169
|
+
environment: combinedMeta.environment,
|
|
170
|
+
plugin: combinedMeta.plugin,
|
|
171
|
+
source: combinedMeta.source
|
|
170
172
|
},
|
|
171
|
-
message
|
|
173
|
+
message
|
|
172
174
|
}
|
|
173
175
|
});
|
|
174
176
|
}
|
|
@@ -1504,18 +1506,45 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1504
1506
|
}, {}) : this.config.resolve.alias : {});
|
|
1505
1507
|
}
|
|
1506
1508
|
/**
|
|
1507
|
-
*
|
|
1509
|
+
* Create a new logger instance
|
|
1510
|
+
*
|
|
1511
|
+
* @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.
|
|
1512
|
+
* @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.
|
|
1513
|
+
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
1508
1514
|
*/
|
|
1509
|
-
|
|
1510
|
-
|
|
1515
|
+
createLogger(options, logFn) {
|
|
1516
|
+
let logger;
|
|
1517
|
+
if (toBool(process.env.POWERLINES_WORKER_THREAD_EXECUTION)) logger = createLogger(this.config.name, {
|
|
1518
|
+
...this.options,
|
|
1511
1519
|
...this.config,
|
|
1512
|
-
...
|
|
1513
|
-
};
|
|
1514
|
-
|
|
1515
|
-
|
|
1520
|
+
...options
|
|
1521
|
+
}, (meta, message) => sendWriteLogMessage(this, meta, message));
|
|
1522
|
+
else logger = createLogger(this.config.name, {
|
|
1523
|
+
...this.options,
|
|
1524
|
+
...this.config,
|
|
1525
|
+
...options
|
|
1526
|
+
});
|
|
1527
|
+
if (this.config.customLogger) logger = withCustomLogger(logger, this.config.customLogger);
|
|
1528
|
+
if (logFn) logger = withLogFn(logger, logFn);
|
|
1516
1529
|
return logger;
|
|
1517
1530
|
}
|
|
1518
1531
|
/**
|
|
1532
|
+
* The log level for the context, which determines the minimum level of log messages that will be emitted by the logger. This is resolved based on the configuration options provided by the user, and can be set to different levels for development, production, and test environments. The log level can also be overridden by plugins or other parts of the build process to provide more granular control over logging output.
|
|
1533
|
+
*/
|
|
1534
|
+
get logLevel() {
|
|
1535
|
+
return resolveLogLevel(this.config.logLevel, this.config.mode);
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* The environment paths for the project, which provide the locations of various directories and files used by the Powerlines framework. These paths are resolved based on the organization ID, application ID, and workspace root directory, and can be used to access configuration files, cache directories, and other resources in a consistent manner.
|
|
1539
|
+
*/
|
|
1540
|
+
get envPaths() {
|
|
1541
|
+
return getEnvPaths({
|
|
1542
|
+
orgId: this.config.organization,
|
|
1543
|
+
appId: this.config.framework || "powerlines",
|
|
1544
|
+
workspaceRoot: this.config.cwd
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
/**
|
|
1519
1548
|
* Gets the parser cache.
|
|
1520
1549
|
*/
|
|
1521
1550
|
get parserCache() {
|
|
@@ -1928,18 +1957,16 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1928
1957
|
*/
|
|
1929
1958
|
async setup() {
|
|
1930
1959
|
this.resolvedConfig = mergeConfig({
|
|
1960
|
+
root: this.options.root,
|
|
1961
|
+
cwd: this.options.cwd,
|
|
1931
1962
|
inlineConfig: this.config.inlineConfig ?? {},
|
|
1932
1963
|
userConfig: this.config.userConfig ?? {},
|
|
1933
1964
|
pluginConfig: this.config.pluginConfig ?? {}
|
|
1934
|
-
},
|
|
1965
|
+
}, getConfigProps(this.config.inlineConfig), getConfigProps(this.config.userConfig), getConfigProps(this.config.pluginConfig), this.options, {
|
|
1935
1966
|
name: this.projectJson?.name || this.packageJson?.name,
|
|
1936
1967
|
version: this.packageJson?.version,
|
|
1937
1968
|
description: this.packageJson?.description
|
|
1938
1969
|
}, {
|
|
1939
|
-
projectType: "application",
|
|
1940
|
-
platform: "neutral",
|
|
1941
|
-
logLevel: "info",
|
|
1942
|
-
preview: false,
|
|
1943
1970
|
environments: {},
|
|
1944
1971
|
resolve: {}
|
|
1945
1972
|
});
|
|
@@ -1981,7 +2008,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
1981
2008
|
*
|
|
1982
2009
|
* @param options - The configuration options to initialize the context with
|
|
1983
2010
|
*/
|
|
1984
|
-
async init(options
|
|
2011
|
+
async init(options) {
|
|
1985
2012
|
await super.init(options);
|
|
1986
2013
|
this.options.executionId = options.executionId ?? this.options.executionId;
|
|
1987
2014
|
this.options.executionIndex = options.executionIndex ?? this.options.executionIndex ?? 0;
|
|
@@ -2017,7 +2044,6 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2017
2044
|
glob: "package.json"
|
|
2018
2045
|
}
|
|
2019
2046
|
] },
|
|
2020
|
-
artifactsPath: `.${this.config.framework ?? "powerlines"}`,
|
|
2021
2047
|
dts: true
|
|
2022
2048
|
});
|
|
2023
2049
|
logger.trace(`Pre-setup Powerlines configuration object: \n${JSON.stringify({
|
|
@@ -2034,6 +2060,8 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2034
2060
|
this.options.framework = "powerlines";
|
|
2035
2061
|
this.config.framework = "powerlines";
|
|
2036
2062
|
}
|
|
2063
|
+
if (!this.config.userConfig?.projectType && !this.config.inlineConfig?.projectType && !this.config.pluginConfig?.projectType) this.config.projectType = "application";
|
|
2064
|
+
if (!this.config.userConfig?.platform && !this.config.inlineConfig?.platform && !this.config.pluginConfig?.platform) this.config.platform = "neutral";
|
|
2037
2065
|
this.resolvedConfig.compatibilityDate = resolveCompatibilityDates(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
|
|
2038
2066
|
this.config.input = getUniqueInputs(this.config.input);
|
|
2039
2067
|
if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
|
|
@@ -2073,6 +2101,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2073
2101
|
else this.config.output.sourceMap = false;
|
|
2074
2102
|
if (!this.config.userConfig?.output?.minify && !this.config.inlineConfig?.output?.minify) if (this.config.mode === "production") this.config.output.minify = true;
|
|
2075
2103
|
else this.config.output.minify = false;
|
|
2104
|
+
if (!this.config.userConfig?.output?.artifactsPath && !this.config.inlineConfig?.output?.artifactsPath && !this.config.pluginConfig?.output?.artifactsPath) this.config.output.artifactsPath = `.${this.config.framework || "powerlines"}`;
|
|
2076
2105
|
if (this.config.output.copy && this.config.output.copy.assets) this.config.output.copy.assets = this.config.output.copy.assets.map((asset) => ({
|
|
2077
2106
|
...asset,
|
|
2078
2107
|
glob: replacePathTokens(this, asset.glob),
|
|
@@ -2234,10 +2263,17 @@ function extractHooks(context, hooks, plugin, key, parentKey) {
|
|
|
2234
2263
|
* @returns The proxied plugin context
|
|
2235
2264
|
*/
|
|
2236
2265
|
function createPluginContext(pluginId, plugin, environment) {
|
|
2266
|
+
const logger = environment.extendLogger({ plugin: plugin.name });
|
|
2237
2267
|
const normalizeMessage = (message) => {
|
|
2238
|
-
return
|
|
2268
|
+
return {
|
|
2269
|
+
meta: {
|
|
2270
|
+
...isSetObject(message) ? message.meta : {},
|
|
2271
|
+
environment: environment.environment?.name,
|
|
2272
|
+
plugin: plugin.name
|
|
2273
|
+
},
|
|
2274
|
+
message: isString(message) ? message : message.message
|
|
2275
|
+
};
|
|
2239
2276
|
};
|
|
2240
|
-
const logger = environment.extendLogger({ plugin: plugin.name.replaceAll(":", " - ") });
|
|
2241
2277
|
const callHookFn = async (hook, options, ...args) => {
|
|
2242
2278
|
return environment.$$internal.api.callHook(hook, {
|
|
2243
2279
|
sequential: true,
|
|
@@ -2257,6 +2293,9 @@ function createPluginContext(pluginId, plugin, environment) {
|
|
|
2257
2293
|
};
|
|
2258
2294
|
if (prop === "id") return pluginId;
|
|
2259
2295
|
if (prop === "logger") return logger;
|
|
2296
|
+
if (prop === "log") return (type, message) => {
|
|
2297
|
+
logger.log(type, normalizeMessage(message));
|
|
2298
|
+
};
|
|
2260
2299
|
if (prop === "fatal") return (message) => {
|
|
2261
2300
|
logger.error(normalizeMessage(message));
|
|
2262
2301
|
};
|
|
@@ -2347,13 +2386,14 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
2347
2386
|
* Create a new logger instance
|
|
2348
2387
|
*
|
|
2349
2388
|
* @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.
|
|
2389
|
+
* @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.
|
|
2350
2390
|
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
2351
2391
|
*/
|
|
2352
|
-
createLogger(options,
|
|
2392
|
+
createLogger(options, logFn) {
|
|
2353
2393
|
return super.createLogger({
|
|
2354
2394
|
...options,
|
|
2355
2395
|
environment: this.environment?.name
|
|
2356
|
-
},
|
|
2396
|
+
}, logFn);
|
|
2357
2397
|
}
|
|
2358
2398
|
/**
|
|
2359
2399
|
* Extend the base logger with additional configuration options
|
|
@@ -2386,7 +2426,11 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
2386
2426
|
this.resolvedConfig = mergeConfig({
|
|
2387
2427
|
name: this.config.name,
|
|
2388
2428
|
title: this.config.title
|
|
2389
|
-
}, getConfigProps(
|
|
2429
|
+
}, getConfigProps({
|
|
2430
|
+
...this.environment,
|
|
2431
|
+
root: this.options.root,
|
|
2432
|
+
cwd: this.options.cwd
|
|
2433
|
+
}), this.config);
|
|
2390
2434
|
await this.innerSetup();
|
|
2391
2435
|
}
|
|
2392
2436
|
async addPlugin(plugin) {
|
|
@@ -2552,14 +2596,15 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
2552
2596
|
* Create a new logger instance
|
|
2553
2597
|
*
|
|
2554
2598
|
* @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.
|
|
2599
|
+
* @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.
|
|
2555
2600
|
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
2556
2601
|
*/
|
|
2557
|
-
createLogger(options,
|
|
2602
|
+
createLogger(options, logFn) {
|
|
2558
2603
|
return super.createLogger({
|
|
2559
2604
|
...options,
|
|
2560
2605
|
executionId: this.id,
|
|
2561
2606
|
executionIndex: this.options.executionIndex
|
|
2562
|
-
},
|
|
2607
|
+
}, logFn);
|
|
2563
2608
|
}
|
|
2564
2609
|
/**
|
|
2565
2610
|
* Extend the base logger with additional configuration options
|
|
@@ -2676,4 +2721,4 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
2676
2721
|
|
|
2677
2722
|
//#endregion
|
|
2678
2723
|
export { mergeConfigs as a, callHook as i, PowerlinesEnvironmentContext as n, PowerlinesContext as o, createPluginContext as r, writeMetaFile as s, PowerlinesExecutionContext as t };
|
|
2679
|
-
//# sourceMappingURL=execution-context-
|
|
2724
|
+
//# sourceMappingURL=execution-context-DlQIqoRZ.mjs.map
|