@powerlines/engine 0.0.14 → 0.0.16
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 +155 -161
- package/dist/_internal/worker.mjs +155 -161
- package/dist/_internal/worker.mjs.map +1 -1
- package/dist/api.cjs +20 -11
- package/dist/api.d.cts +1 -1
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +20 -11
- package/dist/api.mjs.map +1 -1
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.d.cts +13 -15
- package/dist/context/index.d.cts.map +1 -1
- package/dist/context/index.d.mts +13 -15
- package/dist/context/index.d.mts.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/{execution-context-BfQt0NWO.cjs → execution-context-BuypgQoS.cjs} +146 -157
- package/dist/{execution-context-DaplwLr4.mjs → execution-context-ePeyduze.mjs} +147 -158
- package/dist/execution-context-ePeyduze.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/execution-context-DaplwLr4.mjs.map +0 -1
|
@@ -34,12 +34,12 @@ import defu, { createDefu, defu as defu$1 } from "defu";
|
|
|
34
34
|
import Handlebars from "handlebars";
|
|
35
35
|
import { CACHE_HASH_LENGTH, DEFAULT_ENVIRONMENT, GLOBAL_ENVIRONMENT, PLUGIN_NON_HOOK_FIELDS, ROOT_HASH_LENGTH } from "@powerlines/core/constants";
|
|
36
36
|
import { readJsonFile, readJsonFileSync } from "@stryke/fs/json";
|
|
37
|
+
import { deepClone } from "@stryke/helpers/deep-clone";
|
|
37
38
|
import { joinPaths as joinPaths$1 } from "@stryke/path/join";
|
|
38
39
|
import { getUniqueInputs, isTypeDefinition, resolveInputsSync } from "@powerlines/core/lib/entry";
|
|
39
40
|
import { relativeToWorkspaceRoot } from "@stryke/fs/get-workspace-root";
|
|
40
41
|
import { murmurhash } from "@stryke/hash";
|
|
41
42
|
import { hashDirectory } from "@stryke/hash/node";
|
|
42
|
-
import { deepClone } from "@stryke/helpers/deep-clone";
|
|
43
43
|
import { fetchRequest } from "@stryke/http/fetch";
|
|
44
44
|
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
45
45
|
import { isNull } from "@stryke/type-checks/is-null";
|
|
@@ -79,12 +79,12 @@ import { getPackageName, getPackageVersion, hasPackageVersion } from "@stryke/st
|
|
|
79
79
|
import { getObjectDiff } from "@donedeal0/superdiff";
|
|
80
80
|
|
|
81
81
|
//#region src/_internal/helpers/environment.ts
|
|
82
|
-
function createEnvironment(name,
|
|
83
|
-
return defu(
|
|
82
|
+
function createEnvironment(name, config = {}) {
|
|
83
|
+
return defu(config.environments?.[name] ?? {}, {
|
|
84
84
|
name,
|
|
85
|
-
title:
|
|
85
|
+
title: config.title ?? titleCase(config.name),
|
|
86
86
|
ssr: false,
|
|
87
|
-
mainFields:
|
|
87
|
+
resolve: { mainFields: config.platform === "browser" ? [
|
|
88
88
|
"browser",
|
|
89
89
|
"module",
|
|
90
90
|
"jsnext:main",
|
|
@@ -93,18 +93,9 @@ function createEnvironment(name, userConfig) {
|
|
|
93
93
|
"module",
|
|
94
94
|
"jsnext:main",
|
|
95
95
|
"jsnext"
|
|
96
|
-
],
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
".js",
|
|
100
|
-
".mts",
|
|
101
|
-
".ts",
|
|
102
|
-
".jsx",
|
|
103
|
-
".tsx",
|
|
104
|
-
".json"
|
|
105
|
-
],
|
|
106
|
-
consumer: userConfig?.platform === "browser" ? "client" : "server",
|
|
107
|
-
preview: userConfig?.platform === "browser" ? {
|
|
96
|
+
] },
|
|
97
|
+
consumer: config.platform === "browser" ? "client" : "server",
|
|
98
|
+
preview: config.platform === "browser" ? {
|
|
108
99
|
port: 5173,
|
|
109
100
|
open: true,
|
|
110
101
|
strictPort: false,
|
|
@@ -113,10 +104,37 @@ function createEnvironment(name, userConfig) {
|
|
|
113
104
|
cors: true,
|
|
114
105
|
headers: {}
|
|
115
106
|
} : void 0
|
|
116
|
-
}
|
|
107
|
+
});
|
|
117
108
|
}
|
|
118
|
-
function createDefaultEnvironment(
|
|
119
|
-
return createEnvironment(DEFAULT_ENVIRONMENT,
|
|
109
|
+
function createDefaultEnvironment(config = {}) {
|
|
110
|
+
return createEnvironment(DEFAULT_ENVIRONMENT, config);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/_internal/helpers/context.ts
|
|
115
|
+
function getConfigProps(config = {}, root, cwd) {
|
|
116
|
+
return {
|
|
117
|
+
name: config.name,
|
|
118
|
+
title: config.title,
|
|
119
|
+
description: config.description,
|
|
120
|
+
projectType: config.projectType,
|
|
121
|
+
customLogger: config.customLogger,
|
|
122
|
+
logLevel: config.logLevel,
|
|
123
|
+
tsconfig: config.tsconfig,
|
|
124
|
+
tsconfigRaw: config.tsconfigRaw,
|
|
125
|
+
skipCache: config.skipCache,
|
|
126
|
+
autoInstall: config.autoInstall,
|
|
127
|
+
input: isSetString(config.input) ? [config.input] : config.input,
|
|
128
|
+
plugins: config.plugins,
|
|
129
|
+
mode: config.mode,
|
|
130
|
+
resolve: config.resolve,
|
|
131
|
+
framework: config.framework,
|
|
132
|
+
...config,
|
|
133
|
+
output: {
|
|
134
|
+
...config.output ?? {},
|
|
135
|
+
path: config.output?.path ? appendPath(config.output.path, appendPath(root, cwd)) : void 0
|
|
136
|
+
}
|
|
137
|
+
};
|
|
120
138
|
}
|
|
121
139
|
|
|
122
140
|
//#endregion
|
|
@@ -2318,35 +2336,6 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2318
2336
|
#tsconfig;
|
|
2319
2337
|
#parserCache;
|
|
2320
2338
|
#requestCache;
|
|
2321
|
-
#getConfigProps(config = {}) {
|
|
2322
|
-
return mergeConfig({
|
|
2323
|
-
name: config.name,
|
|
2324
|
-
title: config.title,
|
|
2325
|
-
compatibilityDate: resolveCompatibilityDates(config.compatibilityDate, "latest"),
|
|
2326
|
-
description: config.description,
|
|
2327
|
-
projectType: config.projectType,
|
|
2328
|
-
customLogger: config.customLogger,
|
|
2329
|
-
logLevel: config.logLevel,
|
|
2330
|
-
tsconfig: config.tsconfig,
|
|
2331
|
-
tsconfigRaw: config.tsconfigRaw,
|
|
2332
|
-
skipCache: config.skipCache,
|
|
2333
|
-
autoInstall: config.autoInstall,
|
|
2334
|
-
input: isSetString(config.input) ? [config.input] : config.input,
|
|
2335
|
-
plugins: config.plugins,
|
|
2336
|
-
mode: config.mode,
|
|
2337
|
-
resolve: config.resolve,
|
|
2338
|
-
framework: config.framework,
|
|
2339
|
-
...config,
|
|
2340
|
-
output: {
|
|
2341
|
-
...config.output ?? {},
|
|
2342
|
-
path: config.output?.path ? appendPath(config.output.path, appendPath(this.config.root, this.config.cwd)) : void 0
|
|
2343
|
-
}
|
|
2344
|
-
}, { output: config.framework ? {
|
|
2345
|
-
artifactsPath: `.${config.framework ?? "powerlines"}`,
|
|
2346
|
-
dts: true,
|
|
2347
|
-
types: joinPaths$1(this.config.root, `${config.framework ?? "powerlines"}.d.ts`)
|
|
2348
|
-
} : {} });
|
|
2349
|
-
}
|
|
2350
2339
|
/**
|
|
2351
2340
|
* Create a new Storm context from the workspace root and user config.
|
|
2352
2341
|
*
|
|
@@ -2961,36 +2950,16 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2961
2950
|
}
|
|
2962
2951
|
/**
|
|
2963
2952
|
* Initialize the context with the provided configuration options
|
|
2964
|
-
*
|
|
2965
|
-
* @param config - The partial configuration options to initialize the context with
|
|
2966
2953
|
*/
|
|
2967
|
-
async setup(
|
|
2954
|
+
async setup() {
|
|
2968
2955
|
this.resolvedConfig = mergeConfig({
|
|
2969
2956
|
inlineConfig: this.config.inlineConfig ?? {},
|
|
2970
2957
|
userConfig: this.config.userConfig ?? {},
|
|
2971
|
-
pluginConfig: this.config.pluginConfig ?? {}
|
|
2972
|
-
|
|
2973
|
-
}, this.options, this.#getConfigProps(config), this.#getConfigProps(this.config), {
|
|
2958
|
+
pluginConfig: this.config.pluginConfig ?? {}
|
|
2959
|
+
}, this.options, this.config.inlineConfig ? getConfigProps(this.config.inlineConfig, this.options.root, this.options.cwd) : {}, this.config.userConfig ? getConfigProps(this.config.userConfig, this.options.root, this.options.cwd) : {}, this.config.pluginConfig ? getConfigProps(this.config.pluginConfig, this.options.root, this.options.cwd) : {}, {
|
|
2974
2960
|
name: this.projectJson?.name || this.packageJson?.name,
|
|
2975
2961
|
version: this.packageJson?.version,
|
|
2976
|
-
description: this.packageJson?.description
|
|
2977
|
-
output: mergeConfig(this.config.output ?? {}, {
|
|
2978
|
-
path: this.config.root ? appendPath(joinPaths$1(this.config.root, "dist"), this.config.cwd) : void 0,
|
|
2979
|
-
copy: { assets: [
|
|
2980
|
-
{ glob: "LICENSE" },
|
|
2981
|
-
{
|
|
2982
|
-
input: this.config.root,
|
|
2983
|
-
glob: "*.md"
|
|
2984
|
-
},
|
|
2985
|
-
{
|
|
2986
|
-
input: this.config.root,
|
|
2987
|
-
glob: "package.json"
|
|
2988
|
-
}
|
|
2989
|
-
] },
|
|
2990
|
-
artifactsPath: `.${this.config.framework ?? "powerlines"}`,
|
|
2991
|
-
dts: true,
|
|
2992
|
-
types: joinPaths$1(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`)
|
|
2993
|
-
})
|
|
2962
|
+
description: this.packageJson?.description
|
|
2994
2963
|
}, {
|
|
2995
2964
|
projectType: "application",
|
|
2996
2965
|
platform: "neutral",
|
|
@@ -2999,6 +2968,78 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
2999
2968
|
environments: {},
|
|
3000
2969
|
resolve: {}
|
|
3001
2970
|
});
|
|
2971
|
+
await this.innerSetup();
|
|
2972
|
+
}
|
|
2973
|
+
/**
|
|
2974
|
+
* The resolved configuration for this context
|
|
2975
|
+
*/
|
|
2976
|
+
resolvedConfig = {};
|
|
2977
|
+
/**
|
|
2978
|
+
* 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.
|
|
2979
|
+
*
|
|
2980
|
+
* @remarks
|
|
2981
|
+
* The cloned context will have the same configuration and workspace settings as the original context, but will have a different build ID, release ID, and timestamp. The virtual file system and caches will also be separate between the original and cloned contexts.
|
|
2982
|
+
*
|
|
2983
|
+
* @returns The cloned context.
|
|
2984
|
+
*/
|
|
2985
|
+
copyTo(context) {
|
|
2986
|
+
context.dependencies = deepClone(this.dependencies);
|
|
2987
|
+
context.devDependencies = deepClone(this.devDependencies);
|
|
2988
|
+
context.persistedMeta = this.persistedMeta ? deepClone(this.persistedMeta) : void 0;
|
|
2989
|
+
context.packageJson = deepClone(this.packageJson);
|
|
2990
|
+
context.projectJson = this.projectJson ? deepClone(this.projectJson) : void 0;
|
|
2991
|
+
context.tsconfig = deepClone(this.tsconfig);
|
|
2992
|
+
context.$$internal = this.$$internal;
|
|
2993
|
+
return context;
|
|
2994
|
+
}
|
|
2995
|
+
/**
|
|
2996
|
+
* Initialize the context with the provided configuration options
|
|
2997
|
+
*
|
|
2998
|
+
* @remarks
|
|
2999
|
+
* This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.
|
|
3000
|
+
*
|
|
3001
|
+
* @param options - The configuration options to initialize the context with
|
|
3002
|
+
*/
|
|
3003
|
+
async init(options = {}) {
|
|
3004
|
+
await super.init(options);
|
|
3005
|
+
this.options.configIndex = options.configIndex ?? this.options.configIndex ?? 0;
|
|
3006
|
+
const projectJsonPath = joinPaths$1(this.options.root, "project.json");
|
|
3007
|
+
if (existsSync(projectJsonPath)) this.projectJson = await readJsonFile(projectJsonPath);
|
|
3008
|
+
const packageJsonPath = joinPaths$1(this.options.root, "package.json");
|
|
3009
|
+
if (existsSync(packageJsonPath)) {
|
|
3010
|
+
this.packageJson = await readJsonFile(packageJsonPath);
|
|
3011
|
+
this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
|
|
3012
|
+
}
|
|
3013
|
+
this.#checksum = await this.generateChecksum(this.options.root);
|
|
3014
|
+
const userConfig = this.configFile.config ? Array.isArray(this.configFile.config) && this.configFile.config.length > this.options.configIndex ? this.configFile.config[this.options.configIndex] : this.configFile.config : {};
|
|
3015
|
+
this.resolvedConfig = {
|
|
3016
|
+
...this.options,
|
|
3017
|
+
...userConfig,
|
|
3018
|
+
userConfig
|
|
3019
|
+
};
|
|
3020
|
+
}
|
|
3021
|
+
/**
|
|
3022
|
+
* Initialize the context with the provided configuration options
|
|
3023
|
+
*/
|
|
3024
|
+
async innerSetup() {
|
|
3025
|
+
this.resolvedConfig.compatibilityDate = resolveCompatibilityDates(this.config.inlineConfig.compatibilityDate ?? this.config.userConfig.compatibilityDate ?? this.config.pluginConfig.compatibilityDate, "latest");
|
|
3026
|
+
this.resolvedConfig.output = defu(this.resolvedConfig.output ?? {}, {
|
|
3027
|
+
path: this.config.root ? appendPath(joinPaths$1(this.config.root, "dist"), this.config.cwd) : void 0,
|
|
3028
|
+
copy: { assets: [
|
|
3029
|
+
{ glob: "LICENSE" },
|
|
3030
|
+
{
|
|
3031
|
+
input: this.config.root,
|
|
3032
|
+
glob: "*.md"
|
|
3033
|
+
},
|
|
3034
|
+
{
|
|
3035
|
+
input: this.config.root,
|
|
3036
|
+
glob: "package.json"
|
|
3037
|
+
}
|
|
3038
|
+
] },
|
|
3039
|
+
artifactsPath: `.${this.config.framework ?? "powerlines"}`,
|
|
3040
|
+
dts: true,
|
|
3041
|
+
types: joinPaths$1(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`)
|
|
3042
|
+
});
|
|
3002
3043
|
this.logger = {
|
|
3003
3044
|
log: this.createLog(this.config.name),
|
|
3004
3045
|
level: isNull(this.logLevel) ? "silent" : this.logLevel
|
|
@@ -3036,7 +3077,6 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3036
3077
|
ret.push(plugin);
|
|
3037
3078
|
return ret;
|
|
3038
3079
|
}, []);
|
|
3039
|
-
if (this.config.tsconfig) this.config.tsconfig = replacePathTokens(this, this.config.tsconfig);
|
|
3040
3080
|
if (this.config.output.types) if (isSetString(this.config.output.types)) this.config.output.types = replacePathTokens(this, this.config.output.types);
|
|
3041
3081
|
else this.config.output.types = joinPaths$1(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`);
|
|
3042
3082
|
if (!this.config.userConfig?.logLevel && !this.config.inlineConfig?.logLevel) if (this.config.mode === "development") this.config.logLevel = "debug";
|
|
@@ -3045,6 +3085,8 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3045
3085
|
else this.config.output.sourceMap = false;
|
|
3046
3086
|
if (!this.config.userConfig?.output?.minify && !this.config.inlineConfig?.output?.minify) if (this.config.mode === "production") this.config.output.minify = true;
|
|
3047
3087
|
else this.config.output.minify = false;
|
|
3088
|
+
if (!this.config.userConfig?.tsconfig && !this.config.inlineConfig?.tsconfig) this.config.tsconfig = getTsconfigFilePath(this.options.cwd, this.options.root);
|
|
3089
|
+
else if (this.config.tsconfig) this.config.tsconfig = replacePath(replacePathTokens(this, this.config.tsconfig), this.config.cwd);
|
|
3048
3090
|
if (this.config.output.copy && this.config.output.copy.assets) this.config.output.copy.assets = this.config.output.copy.assets.map((asset) => ({
|
|
3049
3091
|
...asset,
|
|
3050
3092
|
glob: replacePathTokens(this, asset.glob),
|
|
@@ -3055,54 +3097,6 @@ var PowerlinesContext = class PowerlinesContext extends PowerlinesBaseContext {
|
|
|
3055
3097
|
if (isSetString(this.config.output?.storage) && this.config.output.storage === "virtual" || isSetObject(this.config.output?.storage) && Object.values(this.config.output.storage).every((adapter) => adapter.preset === "virtual")) this.config.output.overwrite = true;
|
|
3056
3098
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
3057
3099
|
}
|
|
3058
|
-
/**
|
|
3059
|
-
* The resolved configuration for this context
|
|
3060
|
-
*/
|
|
3061
|
-
resolvedConfig = {};
|
|
3062
|
-
/**
|
|
3063
|
-
* 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.
|
|
3064
|
-
*
|
|
3065
|
-
* @remarks
|
|
3066
|
-
* The cloned context will have the same configuration and workspace settings as the original context, but will have a different build ID, release ID, and timestamp. The virtual file system and caches will also be separate between the original and cloned contexts.
|
|
3067
|
-
*
|
|
3068
|
-
* @returns The cloned context.
|
|
3069
|
-
*/
|
|
3070
|
-
copyTo(context) {
|
|
3071
|
-
context.dependencies = deepClone(this.dependencies);
|
|
3072
|
-
context.devDependencies = deepClone(this.devDependencies);
|
|
3073
|
-
context.persistedMeta = this.persistedMeta ? deepClone(this.persistedMeta) : void 0;
|
|
3074
|
-
context.packageJson = deepClone(this.packageJson);
|
|
3075
|
-
context.projectJson = this.projectJson ? deepClone(this.projectJson) : void 0;
|
|
3076
|
-
context.tsconfig = deepClone(this.tsconfig);
|
|
3077
|
-
context.$$internal = this.$$internal;
|
|
3078
|
-
return context;
|
|
3079
|
-
}
|
|
3080
|
-
/**
|
|
3081
|
-
* Initialize the context with the provided configuration options
|
|
3082
|
-
*
|
|
3083
|
-
* @remarks
|
|
3084
|
-
* This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.
|
|
3085
|
-
*
|
|
3086
|
-
* @param options - The configuration options to initialize the context with
|
|
3087
|
-
*/
|
|
3088
|
-
async init(options = {}) {
|
|
3089
|
-
await super.init(options);
|
|
3090
|
-
this.options.configIndex = options.configIndex ?? this.options.configIndex ?? 0;
|
|
3091
|
-
const projectJsonPath = joinPaths$1(this.options.root, "project.json");
|
|
3092
|
-
if (existsSync(projectJsonPath)) this.projectJson = await readJsonFile(projectJsonPath);
|
|
3093
|
-
const packageJsonPath = joinPaths$1(this.options.root, "package.json");
|
|
3094
|
-
if (existsSync(packageJsonPath)) {
|
|
3095
|
-
this.packageJson = await readJsonFile(packageJsonPath);
|
|
3096
|
-
this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
|
|
3097
|
-
}
|
|
3098
|
-
this.#checksum = await this.generateChecksum(this.options.root);
|
|
3099
|
-
const userConfig = this.configFile.config ? Array.isArray(this.configFile.config) && this.configFile.config.length > this.options.configIndex ? this.configFile.config[this.options.configIndex] : this.configFile.config : {};
|
|
3100
|
-
this.resolvedConfig = {
|
|
3101
|
-
...this.options,
|
|
3102
|
-
...userConfig,
|
|
3103
|
-
userConfig
|
|
3104
|
-
};
|
|
3105
|
-
}
|
|
3106
3100
|
};
|
|
3107
3101
|
|
|
3108
3102
|
//#endregion
|
|
@@ -3326,10 +3320,9 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3326
3320
|
* @param config - The user configuration options.
|
|
3327
3321
|
* @returns A promise that resolves to the new context.
|
|
3328
3322
|
*/
|
|
3329
|
-
static async fromConfig(options, config) {
|
|
3330
|
-
const context = new PowerlinesEnvironmentContext(options, config);
|
|
3331
|
-
await context.
|
|
3332
|
-
await context.setup(config);
|
|
3323
|
+
static async fromConfig(options, config, environment) {
|
|
3324
|
+
const context = new PowerlinesEnvironmentContext(options, config, environment);
|
|
3325
|
+
await context.setup();
|
|
3333
3326
|
const powerlinesPath = await resolvePackage("powerlines");
|
|
3334
3327
|
if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
|
|
3335
3328
|
context.powerlinesPath = powerlinesPath;
|
|
@@ -3371,9 +3364,19 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3371
3364
|
* @returns A promise that resolves to the cloned context.
|
|
3372
3365
|
*/
|
|
3373
3366
|
async clone() {
|
|
3374
|
-
const context = await PowerlinesEnvironmentContext.fromConfig(this.options, this.config);
|
|
3367
|
+
const context = await PowerlinesEnvironmentContext.fromConfig(deepClone(this.options), deepClone(this.config), deepClone(this.environment));
|
|
3375
3368
|
return this.copyTo(context);
|
|
3376
3369
|
}
|
|
3370
|
+
/**
|
|
3371
|
+
* Initialize the context with the provided configuration options
|
|
3372
|
+
*/
|
|
3373
|
+
async setup() {
|
|
3374
|
+
this.resolvedConfig = mergeConfig({
|
|
3375
|
+
name: this.config.name,
|
|
3376
|
+
title: this.config.title
|
|
3377
|
+
}, getConfigProps(this.environment, this.options.root, this.options.cwd), this.config);
|
|
3378
|
+
await this.innerSetup();
|
|
3379
|
+
}
|
|
3377
3380
|
async addPlugin(plugin) {
|
|
3378
3381
|
let resolvedPlugin = plugin;
|
|
3379
3382
|
if (isFunction(plugin.applyToEnvironment)) {
|
|
@@ -3426,9 +3429,10 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3426
3429
|
}
|
|
3427
3430
|
return result;
|
|
3428
3431
|
}
|
|
3429
|
-
constructor(options, config) {
|
|
3432
|
+
constructor(options, config, environment) {
|
|
3430
3433
|
super(options);
|
|
3431
3434
|
this.resolvedConfig = config;
|
|
3435
|
+
this.environment = environment;
|
|
3432
3436
|
}
|
|
3433
3437
|
/**
|
|
3434
3438
|
* 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.
|
|
@@ -3478,7 +3482,7 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
3478
3482
|
if (!existsSync(workspacePackageJsonPath)) throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
|
|
3479
3483
|
context.packageJson = await readJsonFile(workspacePackageJsonPath);
|
|
3480
3484
|
}
|
|
3481
|
-
await context.setup(
|
|
3485
|
+
await context.setup();
|
|
3482
3486
|
const powerlinesPath = await resolvePackage("powerlines");
|
|
3483
3487
|
if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
|
|
3484
3488
|
context.powerlinesPath = powerlinesPath;
|
|
@@ -3534,48 +3538,33 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
3534
3538
|
*/
|
|
3535
3539
|
async clone() {
|
|
3536
3540
|
const clone = await PowerlinesExecutionContext.fromOptions(this.options);
|
|
3537
|
-
clone.config.userConfig = this.config.userConfig;
|
|
3538
|
-
|
|
3541
|
+
clone.config.userConfig = deepClone(this.config.userConfig);
|
|
3542
|
+
clone.config.inlineConfig = deepClone(this.config.inlineConfig);
|
|
3543
|
+
clone.config.pluginConfig = deepClone(this.config.pluginConfig);
|
|
3544
|
+
await clone.setup();
|
|
3545
|
+
clone.$$internal = this.$$internal;
|
|
3539
3546
|
return this.copyTo(clone);
|
|
3540
3547
|
}
|
|
3541
3548
|
/**
|
|
3542
|
-
* Initialize the context with the provided configuration options
|
|
3543
|
-
*
|
|
3544
|
-
* @param options - The resolved execution options to use for initialization.
|
|
3545
|
-
*/
|
|
3546
|
-
async init(options) {
|
|
3547
|
-
await super.init(options);
|
|
3548
|
-
await Promise.all(toArray(this.config.environments && Object.keys(this.config.environments).length > 0 ? Object.keys(this.config.environments).map((name) => createEnvironment(name, this.config)) : createDefaultEnvironment(this.config)).map(async (env) => {
|
|
3549
|
-
this.#environments[env.name] = await this.in(env);
|
|
3550
|
-
}));
|
|
3551
|
-
}
|
|
3552
|
-
/**
|
|
3553
3549
|
* A function to copy the context and update the fields for a specific environment
|
|
3554
3550
|
*
|
|
3555
3551
|
* @param environment - The environment configuration to use.
|
|
3556
3552
|
* @returns A new context instance with the updated environment.
|
|
3557
3553
|
*/
|
|
3558
3554
|
async in(environment) {
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
else context = await PowerlinesEnvironmentContext.fromConfig(this.options, this.config);
|
|
3562
|
-
if (isSetObject(this.config.inlineConfig)) await context.setup(this.config.inlineConfig);
|
|
3563
|
-
context.environment = environment;
|
|
3555
|
+
const context = await PowerlinesEnvironmentContext.fromConfig(deepClone(this.options), deepClone(this.config), deepClone(environment));
|
|
3556
|
+
context.$$internal = this.$$internal;
|
|
3564
3557
|
context.plugins = [];
|
|
3565
3558
|
for (const plugin of this.plugins) await context.addPlugin(plugin);
|
|
3566
3559
|
return context;
|
|
3567
3560
|
}
|
|
3568
3561
|
/**
|
|
3569
3562
|
* Update the context using a new inline configuration options
|
|
3570
|
-
*
|
|
3571
|
-
* @param config - The new inline configuration options.
|
|
3572
3563
|
*/
|
|
3573
|
-
async setup(
|
|
3574
|
-
await super.setup(
|
|
3564
|
+
async setup() {
|
|
3565
|
+
await super.setup();
|
|
3575
3566
|
await Promise.all(toArray(this.config.environments && Object.keys(this.config.environments).length > 0 ? Object.keys(this.config.environments).map((name) => createEnvironment(name, this.config)) : createDefaultEnvironment(this.config)).map(async (env) => {
|
|
3576
|
-
|
|
3577
|
-
await context.setup(config);
|
|
3578
|
-
this.#environments[env.name] = context;
|
|
3567
|
+
this.#environments[env.name] = await this.in(env);
|
|
3579
3568
|
}));
|
|
3580
3569
|
}
|
|
3581
3570
|
/**
|
|
@@ -3604,7 +3593,7 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
3604
3593
|
}
|
|
3605
3594
|
if (!environment) {
|
|
3606
3595
|
if (name) throw new Error(`Environment "${name}" not found.`);
|
|
3607
|
-
environment = await this.in(createDefaultEnvironment(this.config
|
|
3596
|
+
environment = await this.in(createDefaultEnvironment(this.config));
|
|
3608
3597
|
this.warn(`No environment specified, and no default environment found. Using a temporary default environment: ${chalk.bold.cyanBright(environment?.environment.name)}`);
|
|
3609
3598
|
}
|
|
3610
3599
|
return environment;
|
|
@@ -3633,7 +3622,7 @@ var PowerlinesExecutionContext = class PowerlinesExecutionContext extends Powerl
|
|
|
3633
3622
|
async toEnvironment() {
|
|
3634
3623
|
let environment;
|
|
3635
3624
|
if (Object.keys(this.environments).length > 1) {
|
|
3636
|
-
environment = await this.in(createEnvironment(GLOBAL_ENVIRONMENT, this.config
|
|
3625
|
+
environment = await this.in(createEnvironment(GLOBAL_ENVIRONMENT, this.config));
|
|
3637
3626
|
this.debug(`Combined all ${Object.keys(this.environments).length} environments into a single global context.`);
|
|
3638
3627
|
} else environment = await this.getEnvironment();
|
|
3639
3628
|
return environment;
|
|
@@ -4396,7 +4385,7 @@ ${formatTypes(code)}
|
|
|
4396
4385
|
static async fromConfig(options, config) {
|
|
4397
4386
|
const api = new PowerlinesExecution(await PowerlinesExecutionContext.fromOptions(options));
|
|
4398
4387
|
api.#context.config.inlineConfig = config;
|
|
4399
|
-
await api.#context.setup(
|
|
4388
|
+
await api.#context.setup();
|
|
4400
4389
|
api.#context.$$internal = {
|
|
4401
4390
|
api,
|
|
4402
4391
|
addPlugin: api.addPlugin.bind(api)
|
|
@@ -4413,7 +4402,7 @@ ${formatTypes(code)}
|
|
|
4413
4402
|
});
|
|
4414
4403
|
if (pluginConfig) {
|
|
4415
4404
|
api.#context.config.pluginConfig = pluginConfig;
|
|
4416
|
-
await api.#context.setup(
|
|
4405
|
+
await api.#context.setup();
|
|
4417
4406
|
}
|
|
4418
4407
|
timer();
|
|
4419
4408
|
return api;
|
|
@@ -4429,7 +4418,8 @@ ${formatTypes(code)}
|
|
|
4429
4418
|
async types(inlineConfig = { command: "types" }) {
|
|
4430
4419
|
this.context.debug(" Aggregating configuration options for the Powerlines project");
|
|
4431
4420
|
inlineConfig.command ??= "types";
|
|
4432
|
-
|
|
4421
|
+
this.context.config.inlineConfig = inlineConfig;
|
|
4422
|
+
await this.context.setup();
|
|
4433
4423
|
await this.#executeEnvironments(async (context) => {
|
|
4434
4424
|
context.debug(`Initializing the processing options for the Powerlines project.`);
|
|
4435
4425
|
await this.callHook("configResolved", {
|
|
@@ -4479,7 +4469,8 @@ ${formatTypes(code)}
|
|
|
4479
4469
|
*/
|
|
4480
4470
|
async prepare(inlineConfig = { command: "prepare" }) {
|
|
4481
4471
|
inlineConfig.command ??= "prepare";
|
|
4482
|
-
|
|
4472
|
+
this.context.config.inlineConfig = inlineConfig;
|
|
4473
|
+
await this.context.setup();
|
|
4483
4474
|
await this.#executeEnvironments(async (context) => {
|
|
4484
4475
|
context.debug(`Initializing the processing options for the Powerlines project.`);
|
|
4485
4476
|
await this.callHook("configResolved", {
|
|
@@ -4639,11 +4630,14 @@ ${formatTypes(code)}
|
|
|
4639
4630
|
* @returns A promise that resolves when the build command has completed
|
|
4640
4631
|
*/
|
|
4641
4632
|
async build(inlineConfig = { command: "build" }) {
|
|
4633
|
+
inlineConfig.command ??= "build";
|
|
4642
4634
|
await this.context.generateChecksum();
|
|
4643
4635
|
if (this.context.meta.checksum !== this.context.persistedMeta?.checksum || this.context.config.skipCache) {
|
|
4644
4636
|
this.context.info(!this.context.persistedMeta?.checksum ? "No previous build cache found. Preparing the project for the initial build." : this.context.meta.checksum !== this.context.persistedMeta.checksum ? "The project has been modified since the last time `prepare` was ran. Re-preparing the project." : "The project is configured to skip cache. Re-preparing the project.");
|
|
4645
|
-
inlineConfig.command ??= "build";
|
|
4646
4637
|
await this.prepare(inlineConfig);
|
|
4638
|
+
} else {
|
|
4639
|
+
this.context.config.inlineConfig = inlineConfig;
|
|
4640
|
+
await this.context.setup();
|
|
4647
4641
|
}
|
|
4648
4642
|
if (this.context.config.singleBuild) await this.#handleBuild(await this.#context.toEnvironment());
|
|
4649
4643
|
else await this.#executeEnvironments(async (context) => {
|