@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,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env -S NODE_OPTIONS=--enable-source-maps node
|
|
2
2
|
import { getFileHeaderWarningText, getTypescriptFileHeader } from "@powerlines/core/lib/utilities/file-header";
|
|
3
3
|
import { format, formatFolder } from "@powerlines/core/lib/utilities/format";
|
|
4
|
-
import { addPluginHook, createLogger, dedupeHooklist, findInvalidPluginConfig, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens, resolveLogLevel, withCustomLogger,
|
|
4
|
+
import { addPluginHook, createLogger, dedupeHooklist, findInvalidPluginConfig, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, mergeConfig, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn } from "@powerlines/core/plugin-utils";
|
|
5
5
|
import { colorText, createLogger as createLogger$1, extendLogger } from "@powerlines/core/plugin-utils/logging";
|
|
6
6
|
import { formatLogMessage } from "@storm-software/config-tools/logger/console";
|
|
7
7
|
import { toArray } from "@stryke/convert/to-array";
|
|
@@ -38,6 +38,8 @@ import { deepClone } from "@stryke/helpers/deep-clone";
|
|
|
38
38
|
import { joinPaths as joinPaths$1 } from "@stryke/path/join";
|
|
39
39
|
import { uuid } from "@stryke/unique-id/uuid";
|
|
40
40
|
import { getUniqueInputs, isTypeDefinition, resolveInputsSync } from "@powerlines/core/lib/entry";
|
|
41
|
+
import { toBool } from "@stryke/convert/to-bool";
|
|
42
|
+
import { getEnvPaths } from "@stryke/env/get-env-paths";
|
|
41
43
|
import { relativeToWorkspaceRoot } from "@stryke/fs/get-workspace-root";
|
|
42
44
|
import { murmurhash } from "@stryke/hash";
|
|
43
45
|
import { hashDirectory } from "@stryke/hash/node";
|
|
@@ -69,9 +71,9 @@ import { unlink } from "node:fs/promises";
|
|
|
69
71
|
import { resolve as resolve$1 } from "node:path";
|
|
70
72
|
import ts from "typescript";
|
|
71
73
|
import { loadUserConfigFile } from "@powerlines/core/lib/config";
|
|
72
|
-
import {
|
|
74
|
+
import { tryGetWorkspaceConfig } from "@storm-software/config-tools/get-config";
|
|
75
|
+
import { isDevelopment, isProduction, isTest } from "@stryke/env/environment-checks";
|
|
73
76
|
import { readJsonFile as readJsonFile$1 } from "@stryke/fs";
|
|
74
|
-
import { StormJSON } from "@stryke/json/storm-json";
|
|
75
77
|
import { joinPaths as joinPaths$2 } from "@stryke/path";
|
|
76
78
|
import { formatDistanceToNowStrict } from "date-fns/formatDistanceToNowStrict";
|
|
77
79
|
import { createJiti } from "jiti";
|
|
@@ -79,6 +81,7 @@ import { getField } from "@stryke/helpers/get-field";
|
|
|
79
81
|
import { DiagnosticCategory, InMemoryFileSystemHost, Node, Project } from "ts-morph";
|
|
80
82
|
import { getPackageName, getPackageVersion, hasPackageVersion } from "@stryke/string-format/package";
|
|
81
83
|
import { getObjectDiff } from "@donedeal0/superdiff";
|
|
84
|
+
import { StormJSON } from "@stryke/json/storm-json";
|
|
82
85
|
|
|
83
86
|
//#region src/_internal/helpers/environment.ts
|
|
84
87
|
function createEnvironment(name, config = {}) {
|
|
@@ -166,34 +169,34 @@ async function writeMetaFile(context) {
|
|
|
166
169
|
|
|
167
170
|
//#endregion
|
|
168
171
|
//#region src/_internal/ipc/send.ts
|
|
169
|
-
function sendWriteLogMessage(context,
|
|
170
|
-
const
|
|
171
|
-
...
|
|
172
|
-
...
|
|
172
|
+
function sendWriteLogMessage(context, meta, message) {
|
|
173
|
+
const combinedMeta = {
|
|
174
|
+
...context.logger.options,
|
|
175
|
+
...isSetObject(meta) ? meta : { type: meta }
|
|
173
176
|
};
|
|
174
177
|
process.send?.({
|
|
175
178
|
id: uuid(),
|
|
176
179
|
type: "write-log",
|
|
177
|
-
executionId:
|
|
178
|
-
executionIndex:
|
|
179
|
-
environment:
|
|
180
|
+
executionId: combinedMeta.executionId || context.config.executionId,
|
|
181
|
+
executionIndex: combinedMeta.executionIndex ?? context.config.executionIndex,
|
|
182
|
+
environment: combinedMeta.environment,
|
|
180
183
|
timestamp: Date.now(),
|
|
181
184
|
payload: {
|
|
182
185
|
meta: {
|
|
183
|
-
type,
|
|
184
|
-
category:
|
|
185
|
-
logId:
|
|
186
|
-
timestamp:
|
|
187
|
-
name:
|
|
188
|
-
executionId:
|
|
189
|
-
executionIndex:
|
|
190
|
-
command:
|
|
191
|
-
hook:
|
|
192
|
-
environment:
|
|
193
|
-
plugin:
|
|
194
|
-
source:
|
|
186
|
+
type: combinedMeta.type,
|
|
187
|
+
category: combinedMeta.category || LogCategories.GENERAL,
|
|
188
|
+
logId: combinedMeta.logId || uuid(),
|
|
189
|
+
timestamp: combinedMeta.timestamp ?? Date.now(),
|
|
190
|
+
name: combinedMeta.name || context.config.name,
|
|
191
|
+
executionId: combinedMeta.executionId || context.config.executionId,
|
|
192
|
+
executionIndex: combinedMeta.executionIndex ?? context.config.executionIndex,
|
|
193
|
+
command: combinedMeta.command || context.config.command,
|
|
194
|
+
hook: combinedMeta.hook,
|
|
195
|
+
environment: combinedMeta.environment,
|
|
196
|
+
plugin: combinedMeta.plugin,
|
|
197
|
+
source: combinedMeta.source
|
|
195
198
|
},
|
|
196
|
-
message
|
|
199
|
+
message
|
|
197
200
|
}
|
|
198
201
|
});
|
|
199
202
|
}
|
|
@@ -2155,7 +2158,6 @@ function createResolver(options) {
|
|
|
2155
2158
|
//#region src/context/base-context.ts
|
|
2156
2159
|
var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
2157
2160
|
#timestamp = Date.now();
|
|
2158
|
-
#name = "powerlines";
|
|
2159
2161
|
/**
|
|
2160
2162
|
* The path to the Powerlines package
|
|
2161
2163
|
*/
|
|
@@ -2180,10 +2182,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2180
2182
|
* 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.
|
|
2181
2183
|
*/
|
|
2182
2184
|
get logger() {
|
|
2183
|
-
return this.createLogger({
|
|
2184
|
-
...this.configFile.config,
|
|
2185
|
-
...this.options
|
|
2186
|
-
});
|
|
2185
|
+
return this.createLogger({});
|
|
2187
2186
|
}
|
|
2188
2187
|
/**
|
|
2189
2188
|
* A timestamp representing when the context was initialized
|
|
@@ -2223,7 +2222,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2223
2222
|
* @param message - The message to log.
|
|
2224
2223
|
*/
|
|
2225
2224
|
fatal(message) {
|
|
2226
|
-
this.logger.error(
|
|
2225
|
+
this.logger.error(message);
|
|
2227
2226
|
}
|
|
2228
2227
|
/**
|
|
2229
2228
|
* A logging function for error messages
|
|
@@ -2231,7 +2230,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2231
2230
|
* @param message - The message to log.
|
|
2232
2231
|
*/
|
|
2233
2232
|
error(message) {
|
|
2234
|
-
this.logger.error(
|
|
2233
|
+
this.logger.error(message);
|
|
2235
2234
|
}
|
|
2236
2235
|
/**
|
|
2237
2236
|
* A logging function for warning messages
|
|
@@ -2239,7 +2238,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2239
2238
|
* @param message - The message to log.
|
|
2240
2239
|
*/
|
|
2241
2240
|
warn(message) {
|
|
2242
|
-
this.logger.warn(
|
|
2241
|
+
this.logger.warn(message);
|
|
2243
2242
|
}
|
|
2244
2243
|
/**
|
|
2245
2244
|
* A logging function for informational messages
|
|
@@ -2247,7 +2246,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2247
2246
|
* @param message - The message to log.
|
|
2248
2247
|
*/
|
|
2249
2248
|
info(message) {
|
|
2250
|
-
this.logger.info(
|
|
2249
|
+
this.logger.info(message);
|
|
2251
2250
|
}
|
|
2252
2251
|
/**
|
|
2253
2252
|
* A logging function for debug messages
|
|
@@ -2255,7 +2254,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2255
2254
|
* @param message - The message to log.
|
|
2256
2255
|
*/
|
|
2257
2256
|
debug(message) {
|
|
2258
|
-
this.logger.debug(
|
|
2257
|
+
this.logger.debug(message);
|
|
2259
2258
|
}
|
|
2260
2259
|
/**
|
|
2261
2260
|
* A logging function for trace messages
|
|
@@ -2263,7 +2262,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2263
2262
|
* @param message - The message to log.
|
|
2264
2263
|
*/
|
|
2265
2264
|
trace(message) {
|
|
2266
|
-
this.logger.trace(
|
|
2265
|
+
this.logger.trace(message);
|
|
2267
2266
|
}
|
|
2268
2267
|
/**
|
|
2269
2268
|
* A function to create a timer for measuring the duration of asynchronous operations
|
|
@@ -2293,10 +2292,15 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2293
2292
|
* Create a new logger instance
|
|
2294
2293
|
*
|
|
2295
2294
|
* @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.
|
|
2295
|
+
* @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.
|
|
2296
2296
|
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
2297
2297
|
*/
|
|
2298
|
-
createLogger(options,
|
|
2299
|
-
return createLogger$1(this.options.name || this.options.root,
|
|
2298
|
+
createLogger(options, logFn) {
|
|
2299
|
+
return createLogger$1(this.options.name || this.options.root, {
|
|
2300
|
+
...this.configFile.config,
|
|
2301
|
+
...this.options,
|
|
2302
|
+
...options
|
|
2303
|
+
}, logFn);
|
|
2300
2304
|
}
|
|
2301
2305
|
/**
|
|
2302
2306
|
* Extend the base logger with additional configuration options
|
|
@@ -2308,6 +2312,35 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2308
2312
|
return extendLogger(this.logger, options);
|
|
2309
2313
|
}
|
|
2310
2314
|
/**
|
|
2315
|
+
* Retrieve the workspace configuration for the current project, if it exists. This function will look for a configuration file in the project root and return its contents as a JavaScript object. If no configuration file is found, it will return undefined.
|
|
2316
|
+
*
|
|
2317
|
+
* @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.
|
|
2318
|
+
*/
|
|
2319
|
+
async getWorkspaceConfig() {
|
|
2320
|
+
return tryGetWorkspaceConfig(false, this.options || this.inputOptions ? {
|
|
2321
|
+
cwd: this.options?.root || this.inputOptions?.root ? appendPath(this.options?.root || this.inputOptions?.root || ".", this.options?.cwd || this.inputOptions?.cwd) : void 0,
|
|
2322
|
+
workspaceRoot: this.options?.cwd || this.inputOptions?.cwd
|
|
2323
|
+
} : void 0);
|
|
2324
|
+
}
|
|
2325
|
+
/**
|
|
2326
|
+
* Determine the default mode for the current execution based on the environment and workspace configuration. This function will check the `NODE_ENV` environment variable to determine if the current environment is development, production, or test. If `NODE_ENV` is not set, it will look for a `mode` property in the workspace configuration file. If no mode is specified in the workspace configuration, it will default to "production".
|
|
2327
|
+
*
|
|
2328
|
+
* @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
|
|
2329
|
+
*/
|
|
2330
|
+
async getDefaultMode() {
|
|
2331
|
+
const workspaceConfig = await this.getWorkspaceConfig();
|
|
2332
|
+
return isProduction ? "production" : isDevelopment ? "development" : isTest ? "test" : workspaceConfig?.mode || "production";
|
|
2333
|
+
}
|
|
2334
|
+
/**
|
|
2335
|
+
* Determine the default log level for the current execution based on the environment and workspace configuration. This function will check the `logLevel` property in the workspace configuration file and resolve it to a `LogLevelResolvedConfig` value. If no log level is specified in the workspace configuration, it will default to "info" for development mode and "warn" for production mode.
|
|
2336
|
+
*
|
|
2337
|
+
* @returns A promise that resolves to the default log level for the current execution, which can be "fatal", "error", "warn", "info", "debug", or "trace".
|
|
2338
|
+
*/
|
|
2339
|
+
async getDefaultLogLevel() {
|
|
2340
|
+
const workspaceConfig = await this.getWorkspaceConfig();
|
|
2341
|
+
return resolveLogLevel(workspaceConfig?.logLevel ? workspaceConfig.logLevel === "success" || workspaceConfig.logLevel === "performance" ? "info" : workspaceConfig.logLevel === "all" ? "debug" : workspaceConfig.logLevel === "fatal" ? "error" : workspaceConfig.logLevel : void 0, this.options?.mode || this.inputOptions?.mode || workspaceConfig?.mode || await this.getDefaultMode());
|
|
2342
|
+
}
|
|
2343
|
+
/**
|
|
2311
2344
|
* Initialize the context with the provided configuration options
|
|
2312
2345
|
*
|
|
2313
2346
|
* @remarks
|
|
@@ -2315,7 +2348,7 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2315
2348
|
*
|
|
2316
2349
|
* @param options - The configuration options to initialize the context with
|
|
2317
2350
|
*/
|
|
2318
|
-
async init(options
|
|
2351
|
+
async init(options) {
|
|
2319
2352
|
this.inputOptions = { ...options };
|
|
2320
2353
|
if (!this.powerlinesPath) {
|
|
2321
2354
|
const powerlinesPath = await resolvePackage("powerlines");
|
|
@@ -2334,15 +2367,14 @@ var PowerlinesBaseContext = class PowerlinesBaseContext {
|
|
|
2334
2367
|
organization: options.organization,
|
|
2335
2368
|
configFile: options.configFile
|
|
2336
2369
|
}, this.options ?? {}, {
|
|
2337
|
-
mode:
|
|
2338
|
-
|
|
2370
|
+
mode: await this.getDefaultMode(),
|
|
2371
|
+
logLevel: await this.getDefaultLogLevel()
|
|
2339
2372
|
});
|
|
2340
2373
|
this.resolver = createResolver({
|
|
2341
2374
|
workspaceRoot: cwd,
|
|
2342
2375
|
root,
|
|
2343
2376
|
cacheDir: this.envPaths.cache,
|
|
2344
|
-
mode: this.options.mode
|
|
2345
|
-
logLevel: this.logLevel
|
|
2377
|
+
mode: this.options.mode
|
|
2346
2378
|
});
|
|
2347
2379
|
this.configFile = await loadUserConfigFile(this.options, this.resolver);
|
|
2348
2380
|
if (!this.options.name) {
|
|
@@ -2620,18 +2652,45 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2620
2652
|
}, {}) : this.config.resolve.alias : {});
|
|
2621
2653
|
}
|
|
2622
2654
|
/**
|
|
2623
|
-
*
|
|
2655
|
+
* Create a new logger instance
|
|
2656
|
+
*
|
|
2657
|
+
* @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.
|
|
2658
|
+
* @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.
|
|
2659
|
+
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
2624
2660
|
*/
|
|
2625
|
-
|
|
2626
|
-
|
|
2661
|
+
createLogger(options, logFn) {
|
|
2662
|
+
let logger;
|
|
2663
|
+
if (toBool(process.env.POWERLINES_WORKER_THREAD_EXECUTION)) logger = createLogger(this.config.name, {
|
|
2664
|
+
...this.options,
|
|
2627
2665
|
...this.config,
|
|
2628
|
-
...
|
|
2629
|
-
};
|
|
2630
|
-
|
|
2631
|
-
|
|
2666
|
+
...options
|
|
2667
|
+
}, (meta, message) => sendWriteLogMessage(this, meta, message));
|
|
2668
|
+
else logger = createLogger(this.config.name, {
|
|
2669
|
+
...this.options,
|
|
2670
|
+
...this.config,
|
|
2671
|
+
...options
|
|
2672
|
+
});
|
|
2673
|
+
if (this.config.customLogger) logger = withCustomLogger(logger, this.config.customLogger);
|
|
2674
|
+
if (logFn) logger = withLogFn(logger, logFn);
|
|
2632
2675
|
return logger;
|
|
2633
2676
|
}
|
|
2634
2677
|
/**
|
|
2678
|
+
* 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.
|
|
2679
|
+
*/
|
|
2680
|
+
get logLevel() {
|
|
2681
|
+
return resolveLogLevel(this.config.logLevel, this.config.mode);
|
|
2682
|
+
}
|
|
2683
|
+
/**
|
|
2684
|
+
* 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.
|
|
2685
|
+
*/
|
|
2686
|
+
get envPaths() {
|
|
2687
|
+
return getEnvPaths({
|
|
2688
|
+
orgId: this.config.organization,
|
|
2689
|
+
appId: this.config.framework || "powerlines",
|
|
2690
|
+
workspaceRoot: this.config.cwd
|
|
2691
|
+
});
|
|
2692
|
+
}
|
|
2693
|
+
/**
|
|
2635
2694
|
* Gets the parser cache.
|
|
2636
2695
|
*/
|
|
2637
2696
|
get parserCache() {
|
|
@@ -3044,18 +3103,16 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3044
3103
|
*/
|
|
3045
3104
|
async setup() {
|
|
3046
3105
|
this.resolvedConfig = mergeConfig({
|
|
3106
|
+
root: this.options.root,
|
|
3107
|
+
cwd: this.options.cwd,
|
|
3047
3108
|
inlineConfig: this.config.inlineConfig ?? {},
|
|
3048
3109
|
userConfig: this.config.userConfig ?? {},
|
|
3049
3110
|
pluginConfig: this.config.pluginConfig ?? {}
|
|
3050
|
-
},
|
|
3111
|
+
}, getConfigProps(this.config.inlineConfig), getConfigProps(this.config.userConfig), getConfigProps(this.config.pluginConfig), this.options, {
|
|
3051
3112
|
name: this.projectJson?.name || this.packageJson?.name,
|
|
3052
3113
|
version: this.packageJson?.version,
|
|
3053
3114
|
description: this.packageJson?.description
|
|
3054
3115
|
}, {
|
|
3055
|
-
projectType: "application",
|
|
3056
|
-
platform: "neutral",
|
|
3057
|
-
logLevel: "info",
|
|
3058
|
-
preview: false,
|
|
3059
3116
|
environments: {},
|
|
3060
3117
|
resolve: {}
|
|
3061
3118
|
});
|
|
@@ -3097,7 +3154,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3097
3154
|
*
|
|
3098
3155
|
* @param options - The configuration options to initialize the context with
|
|
3099
3156
|
*/
|
|
3100
|
-
async init(options
|
|
3157
|
+
async init(options) {
|
|
3101
3158
|
await super.init(options);
|
|
3102
3159
|
this.options.executionId = options.executionId ?? this.options.executionId;
|
|
3103
3160
|
this.options.executionIndex = options.executionIndex ?? this.options.executionIndex ?? 0;
|
|
@@ -3133,7 +3190,6 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3133
3190
|
glob: "package.json"
|
|
3134
3191
|
}
|
|
3135
3192
|
] },
|
|
3136
|
-
artifactsPath: `.${this.config.framework ?? "powerlines"}`,
|
|
3137
3193
|
dts: true
|
|
3138
3194
|
});
|
|
3139
3195
|
logger.trace(`Pre-setup Powerlines configuration object: \n${JSON.stringify({
|
|
@@ -3150,6 +3206,8 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3150
3206
|
this.options.framework = "powerlines";
|
|
3151
3207
|
this.config.framework = "powerlines";
|
|
3152
3208
|
}
|
|
3209
|
+
if (!this.config.userConfig?.projectType && !this.config.inlineConfig?.projectType && !this.config.pluginConfig?.projectType) this.config.projectType = "application";
|
|
3210
|
+
if (!this.config.userConfig?.platform && !this.config.inlineConfig?.platform && !this.config.pluginConfig?.platform) this.config.platform = "neutral";
|
|
3153
3211
|
this.resolvedConfig.compatibilityDate = resolveCompatibilityDates(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
|
|
3154
3212
|
this.config.input = getUniqueInputs(this.config.input);
|
|
3155
3213
|
if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
|
|
@@ -3189,6 +3247,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3189
3247
|
else this.config.output.sourceMap = false;
|
|
3190
3248
|
if (!this.config.userConfig?.output?.minify && !this.config.inlineConfig?.output?.minify) if (this.config.mode === "production") this.config.output.minify = true;
|
|
3191
3249
|
else this.config.output.minify = false;
|
|
3250
|
+
if (!this.config.userConfig?.output?.artifactsPath && !this.config.inlineConfig?.output?.artifactsPath && !this.config.pluginConfig?.output?.artifactsPath) this.config.output.artifactsPath = `.${this.config.framework || "powerlines"}`;
|
|
3192
3251
|
if (this.config.output.copy && this.config.output.copy.assets) this.config.output.copy.assets = this.config.output.copy.assets.map((asset) => ({
|
|
3193
3252
|
...asset,
|
|
3194
3253
|
glob: replacePathTokens(this, asset.glob),
|
|
@@ -3350,10 +3409,17 @@ function extractHooks(context, hooks, plugin, key, parentKey) {
|
|
|
3350
3409
|
* @returns The proxied plugin context
|
|
3351
3410
|
*/
|
|
3352
3411
|
function createPluginContext(pluginId, plugin, environment) {
|
|
3412
|
+
const logger = environment.extendLogger({ plugin: plugin.name });
|
|
3353
3413
|
const normalizeMessage = (message) => {
|
|
3354
|
-
return
|
|
3414
|
+
return {
|
|
3415
|
+
meta: {
|
|
3416
|
+
...isSetObject(message) ? message.meta : {},
|
|
3417
|
+
environment: environment.environment?.name,
|
|
3418
|
+
plugin: plugin.name
|
|
3419
|
+
},
|
|
3420
|
+
message: isString(message) ? message : message.message
|
|
3421
|
+
};
|
|
3355
3422
|
};
|
|
3356
|
-
const logger = environment.extendLogger({ plugin: plugin.name.replaceAll(":", " - ") });
|
|
3357
3423
|
const callHookFn = async (hook, options, ...args) => {
|
|
3358
3424
|
return environment.$$internal.api.callHook(hook, {
|
|
3359
3425
|
sequential: true,
|
|
@@ -3373,6 +3439,9 @@ function createPluginContext(pluginId, plugin, environment) {
|
|
|
3373
3439
|
};
|
|
3374
3440
|
if (prop === "id") return pluginId;
|
|
3375
3441
|
if (prop === "logger") return logger;
|
|
3442
|
+
if (prop === "log") return (type, message) => {
|
|
3443
|
+
logger.log(type, normalizeMessage(message));
|
|
3444
|
+
};
|
|
3376
3445
|
if (prop === "fatal") return (message) => {
|
|
3377
3446
|
logger.error(normalizeMessage(message));
|
|
3378
3447
|
};
|
|
@@ -3463,13 +3532,14 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3463
3532
|
* Create a new logger instance
|
|
3464
3533
|
*
|
|
3465
3534
|
* @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.
|
|
3535
|
+
* @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.
|
|
3466
3536
|
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
3467
3537
|
*/
|
|
3468
|
-
createLogger(options,
|
|
3538
|
+
createLogger(options, logFn) {
|
|
3469
3539
|
return super.createLogger({
|
|
3470
3540
|
...options,
|
|
3471
3541
|
environment: this.environment?.name
|
|
3472
|
-
},
|
|
3542
|
+
}, logFn);
|
|
3473
3543
|
}
|
|
3474
3544
|
/**
|
|
3475
3545
|
* Extend the base logger with additional configuration options
|
|
@@ -3502,7 +3572,11 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3502
3572
|
this.resolvedConfig = mergeConfig({
|
|
3503
3573
|
name: this.config.name,
|
|
3504
3574
|
title: this.config.title
|
|
3505
|
-
}, getConfigProps(
|
|
3575
|
+
}, getConfigProps({
|
|
3576
|
+
...this.environment,
|
|
3577
|
+
root: this.options.root,
|
|
3578
|
+
cwd: this.options.cwd
|
|
3579
|
+
}), this.config);
|
|
3506
3580
|
await this.innerSetup();
|
|
3507
3581
|
}
|
|
3508
3582
|
async addPlugin(plugin) {
|
|
@@ -3668,14 +3742,15 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
3668
3742
|
* Create a new logger instance
|
|
3669
3743
|
*
|
|
3670
3744
|
* @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.
|
|
3745
|
+
* @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.
|
|
3671
3746
|
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
3672
3747
|
*/
|
|
3673
|
-
createLogger(options,
|
|
3748
|
+
createLogger(options, logFn) {
|
|
3674
3749
|
return super.createLogger({
|
|
3675
3750
|
...options,
|
|
3676
3751
|
executionId: this.id,
|
|
3677
3752
|
executionIndex: this.options.executionIndex
|
|
3678
|
-
},
|
|
3753
|
+
}, logFn);
|
|
3679
3754
|
}
|
|
3680
3755
|
/**
|
|
3681
3756
|
* Extend the base logger with additional configuration options
|