@powerlines/engine 0.46.4 → 0.46.5
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 +36 -25
- package/dist/_internal/worker.mjs +37 -26
- package/dist/_internal/worker.mjs.map +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +1 -1
- package/dist/{base-context-D7G_24-i.cjs → base-context-CbFlRUd-.cjs} +8 -6
- package/dist/{base-context-DU0NRHDt.mjs → base-context-Ce9PuQ9z.mjs} +9 -7
- package/dist/{base-context-DU0NRHDt.mjs.map → base-context-Ce9PuQ9z.mjs.map} +1 -1
- package/dist/context/index.cjs +3 -3
- package/dist/context/index.mjs +3 -3
- package/dist/{engine-context-BvDfqfY7.mjs → engine-context-CEbC9dHR.mjs} +2 -2
- package/dist/{engine-context-BvDfqfY7.mjs.map → engine-context-CEbC9dHR.mjs.map} +1 -1
- package/dist/{engine-context-BuJQY312.cjs → engine-context-D-rpz-J2.cjs} +1 -1
- package/dist/execution-context-CghMd-eP.d.cts.map +1 -1
- package/dist/{execution-context-Bb5pfsyN.mjs → execution-context-D-djno_x.mjs} +35 -25
- package/dist/execution-context-D-djno_x.mjs.map +1 -0
- package/dist/{execution-context-Dxa103Qg.cjs → execution-context-Lj_23Ps4.cjs} +29 -19
- package/dist/execution-context-rKd-zSZy.d.mts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/execution-context-Bb5pfsyN.mjs.map +0 -1
|
@@ -75,9 +75,12 @@ let _stryke_hash = require("@stryke/hash");
|
|
|
75
75
|
let _stryke_hash_node = require("@stryke/hash/node");
|
|
76
76
|
let _stryke_http_fetch = require("@stryke/http/fetch");
|
|
77
77
|
let _stryke_path_is_equal = require("@stryke/path/is-equal");
|
|
78
|
+
let _stryke_type_checks_is_regexp = require("@stryke/type-checks/is-regexp");
|
|
79
|
+
let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
78
80
|
let bundle_require = require("bundle-require");
|
|
79
81
|
let compatx = require("compatx");
|
|
80
82
|
let flat_cache = require("flat-cache");
|
|
83
|
+
let node_fs = require("node:fs");
|
|
81
84
|
let oxc_parser = require("oxc-parser");
|
|
82
85
|
let undici = require("undici");
|
|
83
86
|
require("@stryke/fs/remove-file");
|
|
@@ -91,13 +94,11 @@ let _stryke_path_glob_to_regex = require("@stryke/path/glob-to-regex");
|
|
|
91
94
|
let _stryke_path_is_type = require("@stryke/path/is-type");
|
|
92
95
|
let _stryke_path_slash = require("@stryke/path/slash");
|
|
93
96
|
let _stryke_string_format_pretty_bytes = require("@stryke/string-format/pretty-bytes");
|
|
94
|
-
let _stryke_type_checks_is_regexp = require("@stryke/type-checks/is-regexp");
|
|
95
97
|
let node_buffer = require("node:buffer");
|
|
96
98
|
let node_url = require("node:url");
|
|
97
99
|
let _stryke_fs_is_file = require("@stryke/fs/is-file");
|
|
98
100
|
let _stryke_fs_read_file = require("@stryke/fs/read-file");
|
|
99
101
|
let _stryke_fs_write_file = require("@stryke/fs/write-file");
|
|
100
|
-
let node_fs = require("node:fs");
|
|
101
102
|
let node_fs_promises = require("node:fs/promises");
|
|
102
103
|
let node_path = require("node:path");
|
|
103
104
|
let typescript = require("typescript");
|
|
@@ -2435,12 +2436,14 @@ var PowerlinesBaseContext = class {
|
|
|
2435
2436
|
* @returns A promise that resolves when the package configurations have been loaded and stored in the context.
|
|
2436
2437
|
*/
|
|
2437
2438
|
async resolvePackageConfigs(cwd = this.options.cwd, root = this.options.root) {
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2439
|
+
if (cwd || root) {
|
|
2440
|
+
const projectJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root || ".", cwd || "."), "project.json");
|
|
2441
|
+
if ((0, node_fs.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs.readJsonFile)(projectJsonPath);
|
|
2442
|
+
const packageJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root || ".", cwd || "."), "package.json");
|
|
2443
|
+
if ((0, node_fs.existsSync)(packageJsonPath)) {
|
|
2444
|
+
this.packageJson = await (0, _stryke_fs.readJsonFile)(packageJsonPath);
|
|
2445
|
+
this.options.organization ??= (0, _stryke_type_checks_is_set_object.isSetObject)(this.packageJson?.author) ? (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author?.name) : (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author);
|
|
2446
|
+
}
|
|
2444
2447
|
}
|
|
2445
2448
|
}
|
|
2446
2449
|
/**
|
|
@@ -3224,7 +3227,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3224
3227
|
const mergedConfig = this.mergeConfig();
|
|
3225
3228
|
this.logger.trace({
|
|
3226
3229
|
meta: { category: "config" },
|
|
3227
|
-
message: `Pre-setup Powerlines configuration object: \n --- Merged Config --- \n
|
|
3230
|
+
message: `Pre-setup Powerlines configuration object: \n --- Merged Config --- \n${this.logConfig(mergedConfig)} \n\n --- Initial Options --- \n${this.logConfig(this.initialOptions)} \n\n --- Initial Config --- \n${this.logConfig(this.initialConfig)} \n\n --- User Config --- \n${this.logConfig(this.userConfig)} \n\n --- Inline Config --- \n${this.logConfig(this.inlineConfig)} \n\n --- Plugin Config --- \n${this.logConfig(this.pluginConfig)} \n\n --- Environment Config --- \n${this.logConfig(this.environmentConfig)} \n\n --- Overridden Config --- \n${this.logConfig(this.overriddenConfig)}`
|
|
3228
3231
|
});
|
|
3229
3232
|
mergedConfig.output = (0, defu.default)(mergedConfig.output ?? {}, {
|
|
3230
3233
|
copy: { assets: [
|
|
@@ -3240,14 +3243,17 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3240
3243
|
] },
|
|
3241
3244
|
dts: true
|
|
3242
3245
|
});
|
|
3243
|
-
if (
|
|
3244
|
-
if (
|
|
3245
|
-
if (
|
|
3246
|
-
if (!mergedConfig.platform) mergedConfig.platform = "neutral";
|
|
3246
|
+
if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.mode)) mergedConfig.mode = await this.getDefaultMode();
|
|
3247
|
+
if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.framework)) mergedConfig.framework = "powerlines";
|
|
3248
|
+
if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.platform)) mergedConfig.platform = "neutral";
|
|
3247
3249
|
mergedConfig.compatibilityDate = (0, compatx.resolveCompatibilityDates)(mergedConfig.compatibilityDate, "latest");
|
|
3250
|
+
if (!this.packageJson && (0, node_fs.existsSync)((0, _stryke_path_join.joinPaths)((0, _stryke_path_append.appendPath)(mergedConfig.root, mergedConfig.cwd), "package.json")) || !this.projectJson && (0, node_fs.existsSync)((0, _stryke_path_join.joinPaths)((0, _stryke_path_append.appendPath)(mergedConfig.root, mergedConfig.cwd), "project.json"))) {
|
|
3251
|
+
await this.resolvePackageConfigs(mergedConfig.cwd, mergedConfig.root);
|
|
3252
|
+
if (this.packageJson) mergedConfig.organization ??= (0, _powerlines_core_plugin_utils.getPackageJsonOrganization)(this.packageJson) || "powerlines";
|
|
3253
|
+
}
|
|
3254
|
+
if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.projectType)) mergedConfig.projectType = this.projectJson?.projectType || "application";
|
|
3248
3255
|
this.resolvedConfig = mergedConfig;
|
|
3249
3256
|
this.#configProxy = this.createConfigProxy();
|
|
3250
|
-
if (!this.packageJson) await this.resolvePackageConfigs();
|
|
3251
3257
|
mergedConfig.input = (0, _powerlines_core_lib_entry.getUniqueInputs)(mergedConfig.input);
|
|
3252
3258
|
if (mergedConfig.name?.startsWith("@") && mergedConfig.name.split("/").filter(Boolean).length > 1) mergedConfig.name = mergedConfig.name.split("/").filter(Boolean)[1];
|
|
3253
3259
|
mergedConfig.title ??= (0, _stryke_string_format_title_case.titleCase)(mergedConfig.name);
|
|
@@ -3258,18 +3264,18 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3258
3264
|
ret.push(plugin);
|
|
3259
3265
|
return ret;
|
|
3260
3266
|
}, []);
|
|
3261
|
-
if (
|
|
3267
|
+
if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.logLevel)) if (mergedConfig.mode === "development") mergedConfig.logLevel = _powerlines_core_constants.DEFAULT_DEVELOPMENT_LOG_LEVEL;
|
|
3262
3268
|
else if (mergedConfig.mode === "test") mergedConfig.logLevel = _powerlines_core_constants.DEFAULT_TEST_LOG_LEVEL;
|
|
3263
3269
|
else mergedConfig.logLevel = _powerlines_core_constants.DEFAULT_PRODUCTION_LOG_LEVEL;
|
|
3264
3270
|
mergedConfig.logLevel = (0, _powerlines_core_plugin_utils.resolveLogLevel)(mergedConfig.logLevel);
|
|
3265
|
-
if (mergedConfig.tsconfig) mergedConfig.tsconfig = (0, _stryke_path_replace.replacePath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.tsconfig), mergedConfig.cwd);
|
|
3271
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(mergedConfig.tsconfig)) mergedConfig.tsconfig = (0, _stryke_path_replace.replacePath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.tsconfig), mergedConfig.cwd);
|
|
3266
3272
|
else mergedConfig.tsconfig = getTsconfigFilePath(mergedConfig.cwd, mergedConfig.root);
|
|
3267
3273
|
mergedConfig.output.format = (0, _stryke_helpers_get_unique.getUnique)((0, _stryke_convert_to_array.toArray)(mergedConfig.output?.format ?? (mergedConfig.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
|
|
3268
|
-
if (mergedConfig.output.path) mergedConfig.output.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.path), mergedConfig.cwd);
|
|
3274
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(mergedConfig.output.path)) mergedConfig.output.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.path), mergedConfig.cwd);
|
|
3269
3275
|
else mergedConfig.output.path = (0, _stryke_path_append.appendPath)((0, _stryke_path_join.joinPaths)(mergedConfig.root, "dist"), mergedConfig.cwd);
|
|
3270
3276
|
mergedConfig.output.copy ??= {};
|
|
3271
|
-
if (mergedConfig.output.copy !== false) if (!mergedConfig.root.replace(/^\.\/?/, "")) mergedConfig.output.copy.path = mergedConfig.output.copy.path ? (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.copy.path), mergedConfig.cwd) : mergedConfig.output.path;
|
|
3272
|
-
else mergedConfig.output.copy.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.copy.path
|
|
3277
|
+
if (mergedConfig.output.copy !== false) if (!mergedConfig.root.replace(/^\.\/?/, "")) mergedConfig.output.copy.path = (0, _stryke_type_checks_is_set_string.isSetString)(mergedConfig.output.copy.path) ? (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.copy.path), mergedConfig.cwd) : mergedConfig.output.path;
|
|
3278
|
+
else mergedConfig.output.copy.path = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, (0, _stryke_type_checks_is_set_string.isSetString)(mergedConfig.output.copy.path) ? mergedConfig.output.copy.path : (0, _stryke_path_join.joinPaths)("dist", mergedConfig.root)), mergedConfig.cwd);
|
|
3273
3279
|
if (mergedConfig.output.types !== false) mergedConfig.output.types = (0, _stryke_path_append.appendPath)((0, _powerlines_core_plugin_utils.replacePathTokens)(this, mergedConfig.output.types || (0, _stryke_path_join.joinPaths)(mergedConfig.root, `${mergedConfig.framework ?? "powerlines"}.d.ts`)), mergedConfig.cwd);
|
|
3274
3280
|
if (mergedConfig.output.copy && mergedConfig.output.copy.path && mergedConfig.output.copy.assets && Array.isArray(mergedConfig.output.copy.assets)) mergedConfig.output.copy.assets = (0, _stryke_helpers_get_unique.getUniqueBy)(mergedConfig.output.copy.assets.map((asset) => {
|
|
3275
3281
|
return {
|
|
@@ -3279,11 +3285,11 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3279
3285
|
ignore: (0, _stryke_type_checks_is_set_object.isSetObject)(asset) && asset.ignore ? (0, _stryke_convert_to_array.toArray)(asset.ignore) : void 0
|
|
3280
3286
|
};
|
|
3281
3287
|
}), (a) => `${a.input}-${a.glob}-${a.output}`);
|
|
3282
|
-
if (
|
|
3288
|
+
if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.output?.sourceMap)) if (mergedConfig.mode === "development") mergedConfig.output.sourceMap = true;
|
|
3283
3289
|
else mergedConfig.output.sourceMap = false;
|
|
3284
|
-
if (
|
|
3290
|
+
if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.output?.minify)) if (mergedConfig.mode === "production") mergedConfig.output.minify = true;
|
|
3285
3291
|
else mergedConfig.output.minify = false;
|
|
3286
|
-
if (
|
|
3292
|
+
if ((0, _stryke_type_checks_is_undefined.isUndefined)(mergedConfig.output?.artifactsPath)) mergedConfig.output.artifactsPath = `.${mergedConfig.framework || "powerlines"}`;
|
|
3287
3293
|
if (mergedConfig.output.copy && mergedConfig.output.copy.assets) mergedConfig.output.copy.assets = mergedConfig.output.copy.assets.map((asset) => ({
|
|
3288
3294
|
...asset,
|
|
3289
3295
|
glob: (0, _powerlines_core_plugin_utils.replacePathTokens)(this, asset.glob),
|
|
@@ -3294,14 +3300,14 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3294
3300
|
if ((0, _stryke_type_checks_is_set_string.isSetString)(mergedConfig.output?.storage) && mergedConfig.output.storage === "virtual" || (0, _stryke_type_checks_is_set_object.isSetObject)(mergedConfig.output?.storage) && Object.values(mergedConfig.output.storage).every((adapter) => adapter.preset === "virtual")) mergedConfig.output.overwrite = true;
|
|
3295
3301
|
this.resolvedConfig = mergedConfig;
|
|
3296
3302
|
this.#configProxy = this.createConfigProxy();
|
|
3297
|
-
this.logger.
|
|
3303
|
+
this.logger.info({
|
|
3298
3304
|
meta: { category: "config" },
|
|
3299
3305
|
message: `Resolved Powerlines configuration object: \n${this.logConfig(this.resolvedConfig)}`
|
|
3300
3306
|
});
|
|
3301
3307
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
3302
3308
|
}
|
|
3303
3309
|
logConfig(config) {
|
|
3304
|
-
return JSON.stringify({
|
|
3310
|
+
return JSON.stringify(Object.fromEntries(Object.entries({
|
|
3305
3311
|
...(0, _stryke_helpers_omit.omit)(config, [
|
|
3306
3312
|
"plugins",
|
|
3307
3313
|
"initialConfig",
|
|
@@ -3310,8 +3316,13 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3310
3316
|
"pluginConfig",
|
|
3311
3317
|
"environmentConfig"
|
|
3312
3318
|
]),
|
|
3319
|
+
resolve: {
|
|
3320
|
+
...config.resolve,
|
|
3321
|
+
external: (config.resolve?.external ?? []).filter(Boolean).map((external) => (0, _stryke_type_checks_is_set_string.isSetString)(external) ? external : (0, _stryke_type_checks_is_regexp.isRegExp)(external) ? external.source : "<unknown-external>"),
|
|
3322
|
+
noExternal: (config.resolve?.noExternal ?? []).filter(Boolean).map((noExternal) => (0, _stryke_type_checks_is_set_string.isSetString)(noExternal) ? noExternal : (0, _stryke_type_checks_is_regexp.isRegExp)(noExternal) ? noExternal.source : "<unknown-no-external>")
|
|
3323
|
+
},
|
|
3313
3324
|
plugins: config.plugins ? config.plugins.flatMap((plugin) => (0, _stryke_convert_to_array.toArray)(plugin)).map((plugin) => String((0, _stryke_type_checks_is_set_string.isSetString)(plugin) ? plugin : (0, _stryke_type_checks_is_set_object.isSetObject)(plugin) && (0, _stryke_type_checks_is_set_string.isSetString)(plugin.name) ? plugin.name : Array.isArray(plugin) && (0, _stryke_type_checks_is_set_string.isSetString)(plugin[0]) ? plugin[0] : "<function-plugin>")) : []
|
|
3314
|
-
}, null,
|
|
3325
|
+
}).sort(([key1], [key2]) => key1.localeCompare(key2))), null, 4).replace(/"([^"]+)":/g, "$1:").replace(/,$/g, "");
|
|
3315
3326
|
}
|
|
3316
3327
|
createConfigProxy() {
|
|
3317
3328
|
return new Proxy(this.resolvedConfig, {
|
|
@@ -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, withLogFn } from "@powerlines/core/plugin-utils";
|
|
4
|
+
import { addPluginHook, createLogger, dedupeHooklist, findInvalidPluginConfig, getPackageJsonOrganization, 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";
|
|
@@ -44,9 +44,12 @@ import { murmurhash } from "@stryke/hash";
|
|
|
44
44
|
import { hashDirectory } from "@stryke/hash/node";
|
|
45
45
|
import { fetchRequest } from "@stryke/http/fetch";
|
|
46
46
|
import { isEqual } from "@stryke/path/is-equal";
|
|
47
|
+
import { isRegExp } from "@stryke/type-checks/is-regexp";
|
|
48
|
+
import { isUndefined } from "@stryke/type-checks/is-undefined";
|
|
47
49
|
import { match, tsconfigPathsToRegExp } from "bundle-require";
|
|
48
50
|
import { resolveCompatibilityDates } from "compatx";
|
|
49
51
|
import { create } from "flat-cache";
|
|
52
|
+
import { existsSync as existsSync$1, unlinkSync } from "node:fs";
|
|
50
53
|
import { parse } from "oxc-parser";
|
|
51
54
|
import { Agent, Response, interceptors, setGlobalDispatcher } from "undici";
|
|
52
55
|
import "@stryke/fs/remove-file";
|
|
@@ -59,13 +62,11 @@ import { globToRegex } from "@stryke/path/glob-to-regex";
|
|
|
59
62
|
import { isAbsolutePath } from "@stryke/path/is-type";
|
|
60
63
|
import { slash } from "@stryke/path/slash";
|
|
61
64
|
import { prettyBytes } from "@stryke/string-format/pretty-bytes";
|
|
62
|
-
import { isRegExp } from "@stryke/type-checks/is-regexp";
|
|
63
65
|
import { Blob as Blob$1 } from "node:buffer";
|
|
64
66
|
import { fileURLToPath } from "node:url";
|
|
65
67
|
import { isDirectory, isFile } from "@stryke/fs/is-file";
|
|
66
68
|
import { readFile, readFileSync } from "@stryke/fs/read-file";
|
|
67
69
|
import { writeFile, writeFileSync } from "@stryke/fs/write-file";
|
|
68
|
-
import { existsSync as existsSync$1, unlinkSync } from "node:fs";
|
|
69
70
|
import { unlink } from "node:fs/promises";
|
|
70
71
|
import { resolve as resolve$1 } from "node:path";
|
|
71
72
|
import ts from "typescript";
|
|
@@ -2402,12 +2403,14 @@ var PowerlinesBaseContext = class {
|
|
|
2402
2403
|
* @returns A promise that resolves when the package configurations have been loaded and stored in the context.
|
|
2403
2404
|
*/
|
|
2404
2405
|
async resolvePackageConfigs(cwd = this.options.cwd, root = this.options.root) {
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2406
|
+
if (cwd || root) {
|
|
2407
|
+
const projectJsonPath = joinPaths$2(appendPath(root || ".", cwd || "."), "project.json");
|
|
2408
|
+
if (existsSync$1(projectJsonPath)) this.projectJson = await readJsonFile$1(projectJsonPath);
|
|
2409
|
+
const packageJsonPath = joinPaths$2(appendPath(root || ".", cwd || "."), "package.json");
|
|
2410
|
+
if (existsSync$1(packageJsonPath)) {
|
|
2411
|
+
this.packageJson = await readJsonFile$1(packageJsonPath);
|
|
2412
|
+
this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
|
|
2413
|
+
}
|
|
2411
2414
|
}
|
|
2412
2415
|
}
|
|
2413
2416
|
/**
|
|
@@ -3191,7 +3194,7 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3191
3194
|
const mergedConfig = this.mergeConfig();
|
|
3192
3195
|
this.logger.trace({
|
|
3193
3196
|
meta: { category: "config" },
|
|
3194
|
-
message: `Pre-setup Powerlines configuration object: \n --- Merged Config --- \n
|
|
3197
|
+
message: `Pre-setup Powerlines configuration object: \n --- Merged Config --- \n${this.logConfig(mergedConfig)} \n\n --- Initial Options --- \n${this.logConfig(this.initialOptions)} \n\n --- Initial Config --- \n${this.logConfig(this.initialConfig)} \n\n --- User Config --- \n${this.logConfig(this.userConfig)} \n\n --- Inline Config --- \n${this.logConfig(this.inlineConfig)} \n\n --- Plugin Config --- \n${this.logConfig(this.pluginConfig)} \n\n --- Environment Config --- \n${this.logConfig(this.environmentConfig)} \n\n --- Overridden Config --- \n${this.logConfig(this.overriddenConfig)}`
|
|
3195
3198
|
});
|
|
3196
3199
|
mergedConfig.output = defu(mergedConfig.output ?? {}, {
|
|
3197
3200
|
copy: { assets: [
|
|
@@ -3207,14 +3210,17 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3207
3210
|
] },
|
|
3208
3211
|
dts: true
|
|
3209
3212
|
});
|
|
3210
|
-
if (
|
|
3211
|
-
if (
|
|
3212
|
-
if (
|
|
3213
|
-
if (!mergedConfig.platform) mergedConfig.platform = "neutral";
|
|
3213
|
+
if (isUndefined(mergedConfig.mode)) mergedConfig.mode = await this.getDefaultMode();
|
|
3214
|
+
if (isUndefined(mergedConfig.framework)) mergedConfig.framework = "powerlines";
|
|
3215
|
+
if (isUndefined(mergedConfig.platform)) mergedConfig.platform = "neutral";
|
|
3214
3216
|
mergedConfig.compatibilityDate = resolveCompatibilityDates(mergedConfig.compatibilityDate, "latest");
|
|
3217
|
+
if (!this.packageJson && existsSync$1(joinPaths$1(appendPath(mergedConfig.root, mergedConfig.cwd), "package.json")) || !this.projectJson && existsSync$1(joinPaths$1(appendPath(mergedConfig.root, mergedConfig.cwd), "project.json"))) {
|
|
3218
|
+
await this.resolvePackageConfigs(mergedConfig.cwd, mergedConfig.root);
|
|
3219
|
+
if (this.packageJson) mergedConfig.organization ??= getPackageJsonOrganization(this.packageJson) || "powerlines";
|
|
3220
|
+
}
|
|
3221
|
+
if (isUndefined(mergedConfig.projectType)) mergedConfig.projectType = this.projectJson?.projectType || "application";
|
|
3215
3222
|
this.resolvedConfig = mergedConfig;
|
|
3216
3223
|
this.#configProxy = this.createConfigProxy();
|
|
3217
|
-
if (!this.packageJson) await this.resolvePackageConfigs();
|
|
3218
3224
|
mergedConfig.input = getUniqueInputs(mergedConfig.input);
|
|
3219
3225
|
if (mergedConfig.name?.startsWith("@") && mergedConfig.name.split("/").filter(Boolean).length > 1) mergedConfig.name = mergedConfig.name.split("/").filter(Boolean)[1];
|
|
3220
3226
|
mergedConfig.title ??= titleCase(mergedConfig.name);
|
|
@@ -3225,18 +3231,18 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3225
3231
|
ret.push(plugin);
|
|
3226
3232
|
return ret;
|
|
3227
3233
|
}, []);
|
|
3228
|
-
if (
|
|
3234
|
+
if (isUndefined(mergedConfig.logLevel)) if (mergedConfig.mode === "development") mergedConfig.logLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;
|
|
3229
3235
|
else if (mergedConfig.mode === "test") mergedConfig.logLevel = DEFAULT_TEST_LOG_LEVEL;
|
|
3230
3236
|
else mergedConfig.logLevel = DEFAULT_PRODUCTION_LOG_LEVEL;
|
|
3231
3237
|
mergedConfig.logLevel = resolveLogLevel(mergedConfig.logLevel);
|
|
3232
|
-
if (mergedConfig.tsconfig) mergedConfig.tsconfig = replacePath(replacePathTokens(this, mergedConfig.tsconfig), mergedConfig.cwd);
|
|
3238
|
+
if (isSetString(mergedConfig.tsconfig)) mergedConfig.tsconfig = replacePath(replacePathTokens(this, mergedConfig.tsconfig), mergedConfig.cwd);
|
|
3233
3239
|
else mergedConfig.tsconfig = getTsconfigFilePath(mergedConfig.cwd, mergedConfig.root);
|
|
3234
3240
|
mergedConfig.output.format = getUnique(toArray(mergedConfig.output?.format ?? (mergedConfig.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
|
|
3235
|
-
if (mergedConfig.output.path) mergedConfig.output.path = appendPath(replacePathTokens(this, mergedConfig.output.path), mergedConfig.cwd);
|
|
3241
|
+
if (isSetString(mergedConfig.output.path)) mergedConfig.output.path = appendPath(replacePathTokens(this, mergedConfig.output.path), mergedConfig.cwd);
|
|
3236
3242
|
else mergedConfig.output.path = appendPath(joinPaths$1(mergedConfig.root, "dist"), mergedConfig.cwd);
|
|
3237
3243
|
mergedConfig.output.copy ??= {};
|
|
3238
|
-
if (mergedConfig.output.copy !== false) if (!mergedConfig.root.replace(/^\.\/?/, "")) mergedConfig.output.copy.path = mergedConfig.output.copy.path ? appendPath(replacePathTokens(this, mergedConfig.output.copy.path), mergedConfig.cwd) : mergedConfig.output.path;
|
|
3239
|
-
else mergedConfig.output.copy.path = appendPath(replacePathTokens(this, mergedConfig.output.copy.path
|
|
3244
|
+
if (mergedConfig.output.copy !== false) if (!mergedConfig.root.replace(/^\.\/?/, "")) mergedConfig.output.copy.path = isSetString(mergedConfig.output.copy.path) ? appendPath(replacePathTokens(this, mergedConfig.output.copy.path), mergedConfig.cwd) : mergedConfig.output.path;
|
|
3245
|
+
else mergedConfig.output.copy.path = appendPath(replacePathTokens(this, isSetString(mergedConfig.output.copy.path) ? mergedConfig.output.copy.path : joinPaths$1("dist", mergedConfig.root)), mergedConfig.cwd);
|
|
3240
3246
|
if (mergedConfig.output.types !== false) mergedConfig.output.types = appendPath(replacePathTokens(this, mergedConfig.output.types || joinPaths$1(mergedConfig.root, `${mergedConfig.framework ?? "powerlines"}.d.ts`)), mergedConfig.cwd);
|
|
3241
3247
|
if (mergedConfig.output.copy && mergedConfig.output.copy.path && mergedConfig.output.copy.assets && Array.isArray(mergedConfig.output.copy.assets)) mergedConfig.output.copy.assets = getUniqueBy(mergedConfig.output.copy.assets.map((asset) => {
|
|
3242
3248
|
return {
|
|
@@ -3246,11 +3252,11 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3246
3252
|
ignore: isSetObject(asset) && asset.ignore ? toArray(asset.ignore) : void 0
|
|
3247
3253
|
};
|
|
3248
3254
|
}), (a) => `${a.input}-${a.glob}-${a.output}`);
|
|
3249
|
-
if (
|
|
3255
|
+
if (isUndefined(mergedConfig.output?.sourceMap)) if (mergedConfig.mode === "development") mergedConfig.output.sourceMap = true;
|
|
3250
3256
|
else mergedConfig.output.sourceMap = false;
|
|
3251
|
-
if (
|
|
3257
|
+
if (isUndefined(mergedConfig.output?.minify)) if (mergedConfig.mode === "production") mergedConfig.output.minify = true;
|
|
3252
3258
|
else mergedConfig.output.minify = false;
|
|
3253
|
-
if (
|
|
3259
|
+
if (isUndefined(mergedConfig.output?.artifactsPath)) mergedConfig.output.artifactsPath = `.${mergedConfig.framework || "powerlines"}`;
|
|
3254
3260
|
if (mergedConfig.output.copy && mergedConfig.output.copy.assets) mergedConfig.output.copy.assets = mergedConfig.output.copy.assets.map((asset) => ({
|
|
3255
3261
|
...asset,
|
|
3256
3262
|
glob: replacePathTokens(this, asset.glob),
|
|
@@ -3261,14 +3267,14 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3261
3267
|
if (isSetString(mergedConfig.output?.storage) && mergedConfig.output.storage === "virtual" || isSetObject(mergedConfig.output?.storage) && Object.values(mergedConfig.output.storage).every((adapter) => adapter.preset === "virtual")) mergedConfig.output.overwrite = true;
|
|
3262
3268
|
this.resolvedConfig = mergedConfig;
|
|
3263
3269
|
this.#configProxy = this.createConfigProxy();
|
|
3264
|
-
this.logger.
|
|
3270
|
+
this.logger.info({
|
|
3265
3271
|
meta: { category: "config" },
|
|
3266
3272
|
message: `Resolved Powerlines configuration object: \n${this.logConfig(this.resolvedConfig)}`
|
|
3267
3273
|
});
|
|
3268
3274
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
3269
3275
|
}
|
|
3270
3276
|
logConfig(config) {
|
|
3271
|
-
return JSON.stringify({
|
|
3277
|
+
return JSON.stringify(Object.fromEntries(Object.entries({
|
|
3272
3278
|
...omit(config, [
|
|
3273
3279
|
"plugins",
|
|
3274
3280
|
"initialConfig",
|
|
@@ -3277,8 +3283,13 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3277
3283
|
"pluginConfig",
|
|
3278
3284
|
"environmentConfig"
|
|
3279
3285
|
]),
|
|
3286
|
+
resolve: {
|
|
3287
|
+
...config.resolve,
|
|
3288
|
+
external: (config.resolve?.external ?? []).filter(Boolean).map((external) => isSetString(external) ? external : isRegExp(external) ? external.source : "<unknown-external>"),
|
|
3289
|
+
noExternal: (config.resolve?.noExternal ?? []).filter(Boolean).map((noExternal) => isSetString(noExternal) ? noExternal : isRegExp(noExternal) ? noExternal.source : "<unknown-no-external>")
|
|
3290
|
+
},
|
|
3280
3291
|
plugins: config.plugins ? config.plugins.flatMap((plugin) => toArray(plugin)).map((plugin) => String(isSetString(plugin) ? plugin : isSetObject(plugin) && isSetString(plugin.name) ? plugin.name : Array.isArray(plugin) && isSetString(plugin[0]) ? plugin[0] : "<function-plugin>")) : []
|
|
3281
|
-
}, null,
|
|
3292
|
+
}).sort(([key1], [key2]) => key1.localeCompare(key2))), null, 4).replace(/"([^"]+)":/g, "$1:").replace(/,$/g, "");
|
|
3282
3293
|
}
|
|
3283
3294
|
createConfigProxy() {
|
|
3284
3295
|
return new Proxy(this.resolvedConfig, {
|