@storm-software/unbuild 0.33.9 → 0.33.11
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/README.md +1 -1
- package/bin/unbuild.cjs +33 -1467
- package/bin/unbuild.js +34 -1464
- package/dist/build.cjs +10 -10
- package/dist/build.js +1 -1
- package/dist/{chunk-SHHAZOHN.cjs → chunk-BDHZY5E7.cjs} +2 -2
- package/dist/chunk-BGYQAVKQ.cjs +13 -0
- package/dist/{chunk-FSQI7UVH.cjs → chunk-ELBNF3ZV.cjs} +5 -5
- package/dist/chunk-FYU6QKHN.cjs +1087 -0
- package/dist/chunk-HBOCJ3VS.cjs +27 -0
- package/dist/{chunk-TXZ34CR4.cjs → chunk-I7SGCUR4.cjs} +6 -6
- package/dist/{chunk-36DXI2BP.cjs → chunk-LFUHP3V6.cjs} +37 -37
- package/dist/{chunk-ZPOKDFLY.cjs → chunk-Y3FGYCTG.cjs} +5 -5
- package/dist/chunk-ZGZI67KX.js +1087 -0
- package/dist/{chunk-7JMYS6DV.cjs → chunk-ZYPPSI2Q.cjs} +6 -6
- package/dist/clean.cjs +4 -4
- package/dist/config.cjs +8 -8
- package/dist/index.cjs +10 -10
- package/dist/index.js +1 -1
- package/dist/plugins/analyze.cjs +4 -4
- package/dist/plugins/on-error.cjs +4 -4
- package/dist/plugins/swc.cjs +3 -3
- package/dist/plugins/tsc.cjs +4 -4
- package/dist/plugins/type-definitions.cjs +3 -3
- package/dist/types.cjs +0 -1
- package/package.json +4 -6
- package/dist/chunk-AK65ISF4.cjs +0 -27
- package/dist/chunk-FGTLL4QO.js +0 -2519
- package/dist/chunk-XXT4GSHP.cjs +0 -2520
- package/dist/chunk-YDYGZTJK.cjs +0 -18
|
@@ -0,0 +1,1087 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cleanDirectories
|
|
3
|
+
} from "./chunk-ERYQ4O3N.js";
|
|
4
|
+
import {
|
|
5
|
+
getDefaultBuildPlugins
|
|
6
|
+
} from "./chunk-SRY6IWKG.js";
|
|
7
|
+
import {
|
|
8
|
+
loadConfig
|
|
9
|
+
} from "./chunk-I3ATI525.js";
|
|
10
|
+
import {
|
|
11
|
+
COLOR_KEYS,
|
|
12
|
+
LogLevel,
|
|
13
|
+
LogLevelLabel,
|
|
14
|
+
STORM_DEFAULT_DOCS,
|
|
15
|
+
STORM_DEFAULT_HOMEPAGE,
|
|
16
|
+
STORM_DEFAULT_LICENSING,
|
|
17
|
+
StormConfigSchema,
|
|
18
|
+
correctPaths,
|
|
19
|
+
findWorkspaceRoot,
|
|
20
|
+
formatLogMessage,
|
|
21
|
+
getDefaultConfig,
|
|
22
|
+
getLogLevel,
|
|
23
|
+
getLogLevelLabel,
|
|
24
|
+
getStopwatch,
|
|
25
|
+
isVerbose,
|
|
26
|
+
joinPaths,
|
|
27
|
+
writeDebug,
|
|
28
|
+
writeFatal,
|
|
29
|
+
writeSuccess,
|
|
30
|
+
writeTrace,
|
|
31
|
+
writeWarning
|
|
32
|
+
} from "./chunk-J4VTEQNQ.js";
|
|
33
|
+
import {
|
|
34
|
+
__name
|
|
35
|
+
} from "./chunk-3GQAWCBQ.js";
|
|
36
|
+
|
|
37
|
+
// src/build.ts
|
|
38
|
+
import { readCachedProjectGraph as readCachedProjectGraph2, writeJsonFile } from "@nx/devkit";
|
|
39
|
+
import { getHelperDependency, HelperDependency } from "@nx/js";
|
|
40
|
+
import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies2 } from "@nx/js/src/utils/buildable-libs-utils";
|
|
41
|
+
|
|
42
|
+
// ../build-tools/src/plugins/swc.ts
|
|
43
|
+
import { transform } from "@swc/core";
|
|
44
|
+
|
|
45
|
+
// ../build-tools/src/plugins/ts-resolve.ts
|
|
46
|
+
import fs from "node:fs";
|
|
47
|
+
import { builtinModules } from "node:module";
|
|
48
|
+
import path from "node:path";
|
|
49
|
+
import _resolve from "resolve";
|
|
50
|
+
|
|
51
|
+
// ../build-tools/src/plugins/type-definitions.ts
|
|
52
|
+
import { stripIndents } from "@nx/devkit";
|
|
53
|
+
import { relative } from "path";
|
|
54
|
+
|
|
55
|
+
// ../build-tools/src/utilities/copy-assets.ts
|
|
56
|
+
import { CopyAssetsHandler } from "@nx/js/src/utils/assets/copy-assets-handler";
|
|
57
|
+
import { glob } from "glob";
|
|
58
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
59
|
+
var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, projectRoot, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
|
|
60
|
+
const pendingAssets = Array.from(assets ?? []);
|
|
61
|
+
pendingAssets.push({
|
|
62
|
+
input: projectRoot,
|
|
63
|
+
glob: "*.md",
|
|
64
|
+
output: "."
|
|
65
|
+
});
|
|
66
|
+
pendingAssets.push({
|
|
67
|
+
input: ".",
|
|
68
|
+
glob: "LICENSE",
|
|
69
|
+
output: "."
|
|
70
|
+
});
|
|
71
|
+
if (generatePackageJson2 === false) {
|
|
72
|
+
pendingAssets.push({
|
|
73
|
+
input: projectRoot,
|
|
74
|
+
glob: "package.json",
|
|
75
|
+
output: "."
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (includeSrc === true) {
|
|
79
|
+
pendingAssets.push({
|
|
80
|
+
input: sourceRoot,
|
|
81
|
+
glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
|
|
82
|
+
output: "src/"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
writeTrace(`\u{1F4DD} Copying the following assets to the output directory:
|
|
86
|
+
${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`, config);
|
|
87
|
+
const assetHandler = new CopyAssetsHandler({
|
|
88
|
+
projectDir: projectRoot,
|
|
89
|
+
rootDir: config.workspaceRoot,
|
|
90
|
+
outputDir: outputPath,
|
|
91
|
+
assets: pendingAssets
|
|
92
|
+
});
|
|
93
|
+
await assetHandler.processAllAssetsOnce();
|
|
94
|
+
if (includeSrc === true) {
|
|
95
|
+
writeDebug(`\u{1F4DD} Adding banner and writing source files: ${joinPaths(outputPath, "src")}`, config);
|
|
96
|
+
const files = await glob([
|
|
97
|
+
joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
|
|
98
|
+
joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
|
|
99
|
+
joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
100
|
+
joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
101
|
+
]);
|
|
102
|
+
await Promise.allSettled(files.map(async (file) => writeFile(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
103
|
+
|
|
104
|
+
${await readFile(file, "utf8")}
|
|
105
|
+
|
|
106
|
+
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
|
|
107
|
+
}
|
|
108
|
+
}, "copyAssets");
|
|
109
|
+
|
|
110
|
+
// ../build-tools/src/utilities/generate-package-json.ts
|
|
111
|
+
import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
|
|
112
|
+
import { Glob } from "glob";
|
|
113
|
+
import { existsSync } from "node:fs";
|
|
114
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
115
|
+
import { readCachedProjectGraph } from "nx/src/project-graph/project-graph";
|
|
116
|
+
var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projectRoot, projectName, packageJson) => {
|
|
117
|
+
const projectDependencies = calculateProjectBuildableDependencies(void 0, readCachedProjectGraph(), workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
118
|
+
const localPackages = [];
|
|
119
|
+
for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
|
|
120
|
+
const projectNode = project.node;
|
|
121
|
+
if (projectNode.data.root) {
|
|
122
|
+
const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
|
|
123
|
+
if (existsSync(projectPackageJsonPath)) {
|
|
124
|
+
const projectPackageJsonContent = await readFile2(projectPackageJsonPath, "utf8");
|
|
125
|
+
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
126
|
+
if (projectPackageJson.private !== false) {
|
|
127
|
+
localPackages.push(projectPackageJson);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (localPackages.length > 0) {
|
|
133
|
+
writeTrace(`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
|
|
134
|
+
packageJson.peerDependencies = localPackages.reduce((ret, localPackage) => {
|
|
135
|
+
if (!ret[localPackage.name]) {
|
|
136
|
+
ret[localPackage.name] = `>=${localPackage.version || "0.0.1"}`;
|
|
137
|
+
}
|
|
138
|
+
return ret;
|
|
139
|
+
}, packageJson.peerDependencies ?? {});
|
|
140
|
+
packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
|
|
141
|
+
if (!ret[localPackage.name]) {
|
|
142
|
+
ret[localPackage.name] = {
|
|
143
|
+
optional: false
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return ret;
|
|
147
|
+
}, packageJson.peerDependenciesMeta ?? {});
|
|
148
|
+
packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
|
|
149
|
+
if (!ret[localPackage.name]) {
|
|
150
|
+
ret[localPackage.name] = localPackage.version || "0.0.1";
|
|
151
|
+
}
|
|
152
|
+
return ret;
|
|
153
|
+
}, packageJson.peerDependencies ?? {});
|
|
154
|
+
} else {
|
|
155
|
+
writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
|
|
156
|
+
}
|
|
157
|
+
return packageJson;
|
|
158
|
+
}, "addPackageDependencies");
|
|
159
|
+
var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
160
|
+
const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
|
|
161
|
+
const workspacePackageJsonContent = await readFile2(joinPaths(workspaceRoot, "package.json"), "utf8");
|
|
162
|
+
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
163
|
+
packageJson.type ??= "module";
|
|
164
|
+
packageJson.sideEffects ??= false;
|
|
165
|
+
if (includeSrc === true) {
|
|
166
|
+
let distSrc = sourceRoot.replace(projectRoot, "");
|
|
167
|
+
if (distSrc.startsWith("/")) {
|
|
168
|
+
distSrc = distSrc.substring(1);
|
|
169
|
+
}
|
|
170
|
+
packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
|
|
171
|
+
}
|
|
172
|
+
packageJson.files ??= [
|
|
173
|
+
"dist/**/*"
|
|
174
|
+
];
|
|
175
|
+
if (includeSrc === true && !packageJson.files.includes("src")) {
|
|
176
|
+
packageJson.files.push("src/**/*");
|
|
177
|
+
}
|
|
178
|
+
packageJson.publishConfig ??= {
|
|
179
|
+
access: "public"
|
|
180
|
+
};
|
|
181
|
+
packageJson.description ??= workspacePackageJson.description;
|
|
182
|
+
packageJson.homepage ??= workspacePackageJson.homepage;
|
|
183
|
+
packageJson.bugs ??= workspacePackageJson.bugs;
|
|
184
|
+
packageJson.license ??= workspacePackageJson.license;
|
|
185
|
+
packageJson.keywords ??= workspacePackageJson.keywords;
|
|
186
|
+
packageJson.funding ??= workspacePackageJson.funding;
|
|
187
|
+
packageJson.author ??= workspacePackageJson.author;
|
|
188
|
+
packageJson.maintainers ??= workspacePackageJson.maintainers;
|
|
189
|
+
if (!packageJson.maintainers && packageJson.author) {
|
|
190
|
+
packageJson.maintainers = [
|
|
191
|
+
packageJson.author
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
packageJson.contributors ??= workspacePackageJson.contributors;
|
|
195
|
+
if (!packageJson.contributors && packageJson.author) {
|
|
196
|
+
packageJson.contributors = [
|
|
197
|
+
packageJson.author
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
packageJson.repository ??= workspacePackageJson.repository;
|
|
201
|
+
packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
|
|
202
|
+
return packageJson;
|
|
203
|
+
}, "addWorkspacePackageJsonFields");
|
|
204
|
+
|
|
205
|
+
// ../config-tools/src/config-file/get-config-file.ts
|
|
206
|
+
import { loadConfig as loadConfig2 } from "c12";
|
|
207
|
+
import defu from "defu";
|
|
208
|
+
var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, options = {}) => {
|
|
209
|
+
const workspacePath = filePath || findWorkspaceRoot(filePath);
|
|
210
|
+
const configs = await Promise.all([
|
|
211
|
+
loadConfig2({
|
|
212
|
+
cwd: workspacePath,
|
|
213
|
+
packageJson: true,
|
|
214
|
+
name: fileName,
|
|
215
|
+
envName: fileName?.toUpperCase(),
|
|
216
|
+
jitiOptions: {
|
|
217
|
+
debug: false,
|
|
218
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
|
|
219
|
+
},
|
|
220
|
+
...options
|
|
221
|
+
}),
|
|
222
|
+
loadConfig2({
|
|
223
|
+
cwd: workspacePath,
|
|
224
|
+
packageJson: true,
|
|
225
|
+
name: fileName,
|
|
226
|
+
envName: fileName?.toUpperCase(),
|
|
227
|
+
jitiOptions: {
|
|
228
|
+
debug: false,
|
|
229
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
|
|
230
|
+
},
|
|
231
|
+
configFile: fileName,
|
|
232
|
+
...options
|
|
233
|
+
})
|
|
234
|
+
]);
|
|
235
|
+
return defu(configs[0] ?? {}, configs[1] ?? {});
|
|
236
|
+
}, "getConfigFileByName");
|
|
237
|
+
var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames = []) => {
|
|
238
|
+
const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
|
|
239
|
+
const result = await getConfigFileByName("storm", workspacePath);
|
|
240
|
+
let config = result.config;
|
|
241
|
+
const configFile = result.configFile;
|
|
242
|
+
if (config && configFile && Object.keys(config).length > 0) {
|
|
243
|
+
writeTrace(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
|
|
244
|
+
logLevel: "all"
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
if (additionalFileNames && additionalFileNames.length > 0) {
|
|
248
|
+
const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
|
|
249
|
+
for (const result2 of results) {
|
|
250
|
+
if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
|
|
251
|
+
writeTrace(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
|
|
252
|
+
logLevel: "all"
|
|
253
|
+
});
|
|
254
|
+
config = defu(result2.config ?? {}, config ?? {});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (!config) {
|
|
259
|
+
return void 0;
|
|
260
|
+
}
|
|
261
|
+
config.configFile = configFile;
|
|
262
|
+
return config;
|
|
263
|
+
}, "getConfigFile");
|
|
264
|
+
|
|
265
|
+
// ../config-tools/src/create-storm-config.ts
|
|
266
|
+
import defu2 from "defu";
|
|
267
|
+
|
|
268
|
+
// ../config-tools/src/env/get-env.ts
|
|
269
|
+
var getExtensionEnv = /* @__PURE__ */ __name((extensionName) => {
|
|
270
|
+
const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
|
|
271
|
+
return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
|
|
272
|
+
const name = key.replace(prefix, "").split("_").map((i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : "").join("");
|
|
273
|
+
if (name) {
|
|
274
|
+
ret[name] = process.env[key];
|
|
275
|
+
}
|
|
276
|
+
return ret;
|
|
277
|
+
}, {});
|
|
278
|
+
}, "getExtensionEnv");
|
|
279
|
+
var getConfigEnv = /* @__PURE__ */ __name(() => {
|
|
280
|
+
const prefix = "STORM_";
|
|
281
|
+
let config = {
|
|
282
|
+
extends: process.env[`${prefix}EXTENDS`] || void 0,
|
|
283
|
+
name: process.env[`${prefix}NAME`] || void 0,
|
|
284
|
+
namespace: process.env[`${prefix}NAMESPACE`] || void 0,
|
|
285
|
+
owner: process.env[`${prefix}OWNER`] || void 0,
|
|
286
|
+
bot: {
|
|
287
|
+
name: process.env[`${prefix}BOT_NAME`] || void 0,
|
|
288
|
+
email: process.env[`${prefix}BOT_EMAIL`] || void 0
|
|
289
|
+
},
|
|
290
|
+
organization: process.env[`${prefix}ORGANIZATION`] || void 0,
|
|
291
|
+
packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
|
|
292
|
+
license: process.env[`${prefix}LICENSE`] || void 0,
|
|
293
|
+
homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
|
|
294
|
+
docs: process.env[`${prefix}DOCS`] || void 0,
|
|
295
|
+
licensing: process.env[`${prefix}LICENSING`] || void 0,
|
|
296
|
+
timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
|
|
297
|
+
locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
|
|
298
|
+
configFile: process.env[`${prefix}CONFIG_FILE`] ? correctPaths(process.env[`${prefix}CONFIG_FILE`]) : void 0,
|
|
299
|
+
workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? correctPaths(process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
|
|
300
|
+
directories: {
|
|
301
|
+
cache: process.env[`${prefix}CACHE_DIR`] ? correctPaths(process.env[`${prefix}CACHE_DIR`]) : void 0,
|
|
302
|
+
data: process.env[`${prefix}DATA_DIR`] ? correctPaths(process.env[`${prefix}DATA_DIR`]) : void 0,
|
|
303
|
+
config: process.env[`${prefix}CONFIG_DIR`] ? correctPaths(process.env[`${prefix}CONFIG_DIR`]) : void 0,
|
|
304
|
+
temp: process.env[`${prefix}TEMP_DIR`] ? correctPaths(process.env[`${prefix}TEMP_DIR`]) : void 0,
|
|
305
|
+
log: process.env[`${prefix}LOG_DIR`] ? correctPaths(process.env[`${prefix}LOG_DIR`]) : void 0,
|
|
306
|
+
build: process.env[`${prefix}BUILD_DIR`] ? correctPaths(process.env[`${prefix}BUILD_DIR`]) : void 0
|
|
307
|
+
},
|
|
308
|
+
skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
|
|
309
|
+
env: (process.env[`${prefix}ENV`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT) || void 0,
|
|
310
|
+
// ci:
|
|
311
|
+
// process.env[`${prefix}CI`] !== undefined
|
|
312
|
+
// ? Boolean(
|
|
313
|
+
// process.env[`${prefix}CI`] ??
|
|
314
|
+
// process.env.CI ??
|
|
315
|
+
// process.env.CONTINUOUS_INTEGRATION
|
|
316
|
+
// )
|
|
317
|
+
// : undefined,
|
|
318
|
+
repository: process.env[`${prefix}REPOSITORY`] || void 0,
|
|
319
|
+
branch: process.env[`${prefix}BRANCH`] || void 0,
|
|
320
|
+
preid: process.env[`${prefix}PRE_ID`] || void 0,
|
|
321
|
+
externalPackagePatterns: process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] ? JSON.parse(process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`]) : [],
|
|
322
|
+
registry: {
|
|
323
|
+
github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
|
|
324
|
+
npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
|
|
325
|
+
cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
|
|
326
|
+
cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
|
|
327
|
+
container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
|
|
328
|
+
},
|
|
329
|
+
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) ? getLogLevelLabel(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) : process.env[`${prefix}LOG_LEVEL`] : void 0
|
|
330
|
+
};
|
|
331
|
+
const themeNames = Object.keys(process.env).filter((envKey) => envKey.startsWith(`${prefix}COLOR_`) && COLOR_KEYS.every((colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)));
|
|
332
|
+
config.colors = themeNames.length > 0 ? themeNames.reduce((ret, themeName) => {
|
|
333
|
+
ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
|
|
334
|
+
return ret;
|
|
335
|
+
}, {}) : getThemeColorConfigEnv(prefix);
|
|
336
|
+
if (config.docs === STORM_DEFAULT_DOCS) {
|
|
337
|
+
if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
|
|
338
|
+
config.docs = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
|
|
339
|
+
} else {
|
|
340
|
+
config.docs = `${config.homepage}/docs`;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (config.licensing === STORM_DEFAULT_LICENSING) {
|
|
344
|
+
if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
|
|
345
|
+
config.licensing = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
|
|
346
|
+
} else {
|
|
347
|
+
config.licensing = `${config.homepage}/docs`;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const serializedConfig = process.env[`${prefix}CONFIG`];
|
|
351
|
+
if (serializedConfig) {
|
|
352
|
+
const parsed = JSON.parse(serializedConfig);
|
|
353
|
+
config = {
|
|
354
|
+
...config,
|
|
355
|
+
...parsed,
|
|
356
|
+
colors: {
|
|
357
|
+
...config.colors,
|
|
358
|
+
...parsed.colors
|
|
359
|
+
},
|
|
360
|
+
extensions: {
|
|
361
|
+
...config.extensions,
|
|
362
|
+
...parsed.extensions
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
return config;
|
|
367
|
+
}, "getConfigEnv");
|
|
368
|
+
var getThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, theme) => {
|
|
369
|
+
const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
|
|
370
|
+
return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
|
|
371
|
+
}, "getThemeColorConfigEnv");
|
|
372
|
+
var getSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
|
|
373
|
+
return {
|
|
374
|
+
dark: process.env[`${prefix}DARK`],
|
|
375
|
+
light: process.env[`${prefix}LIGHT`],
|
|
376
|
+
brand: process.env[`${prefix}BRAND`],
|
|
377
|
+
alternate: process.env[`${prefix}ALTERNATE`],
|
|
378
|
+
accent: process.env[`${prefix}ACCENT`],
|
|
379
|
+
link: process.env[`${prefix}LINK`],
|
|
380
|
+
help: process.env[`${prefix}HELP`],
|
|
381
|
+
success: process.env[`${prefix}SUCCESS`],
|
|
382
|
+
info: process.env[`${prefix}INFO`],
|
|
383
|
+
warning: process.env[`${prefix}WARNING`],
|
|
384
|
+
danger: process.env[`${prefix}DANGER`],
|
|
385
|
+
fatal: process.env[`${prefix}FATAL`],
|
|
386
|
+
positive: process.env[`${prefix}POSITIVE`],
|
|
387
|
+
negative: process.env[`${prefix}NEGATIVE`]
|
|
388
|
+
};
|
|
389
|
+
}, "getSingleThemeColorConfigEnv");
|
|
390
|
+
var getMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
|
|
391
|
+
return {
|
|
392
|
+
light: getBaseThemeColorConfigEnv(`${prefix}_LIGHT_`),
|
|
393
|
+
dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
|
|
394
|
+
};
|
|
395
|
+
}, "getMultiThemeColorConfigEnv");
|
|
396
|
+
var getBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
|
|
397
|
+
return {
|
|
398
|
+
foreground: process.env[`${prefix}FOREGROUND`],
|
|
399
|
+
background: process.env[`${prefix}BACKGROUND`],
|
|
400
|
+
brand: process.env[`${prefix}BRAND`],
|
|
401
|
+
alternate: process.env[`${prefix}ALTERNATE`],
|
|
402
|
+
accent: process.env[`${prefix}ACCENT`],
|
|
403
|
+
link: process.env[`${prefix}LINK`],
|
|
404
|
+
help: process.env[`${prefix}HELP`],
|
|
405
|
+
success: process.env[`${prefix}SUCCESS`],
|
|
406
|
+
info: process.env[`${prefix}INFO`],
|
|
407
|
+
warning: process.env[`${prefix}WARNING`],
|
|
408
|
+
danger: process.env[`${prefix}DANGER`],
|
|
409
|
+
fatal: process.env[`${prefix}FATAL`],
|
|
410
|
+
positive: process.env[`${prefix}POSITIVE`],
|
|
411
|
+
negative: process.env[`${prefix}NEGATIVE`]
|
|
412
|
+
};
|
|
413
|
+
}, "getBaseThemeColorConfigEnv");
|
|
414
|
+
|
|
415
|
+
// ../config-tools/src/env/set-env.ts
|
|
416
|
+
var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
|
|
417
|
+
for (const key of Object.keys(extension ?? {})) {
|
|
418
|
+
if (extension[key]) {
|
|
419
|
+
const result = key?.replace(/([A-Z])+/g, (input) => input ? input[0]?.toUpperCase() + input.slice(1) : "").split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
|
|
420
|
+
let extensionKey;
|
|
421
|
+
if (result.length === 0) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (result.length === 1) {
|
|
425
|
+
extensionKey = result[0]?.toUpperCase() ?? "";
|
|
426
|
+
} else {
|
|
427
|
+
extensionKey = result.reduce((ret, part) => {
|
|
428
|
+
return `${ret}_${part.toLowerCase()}`;
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}, "setExtensionEnv");
|
|
435
|
+
var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
436
|
+
const prefix = "STORM_";
|
|
437
|
+
if (config.extends) {
|
|
438
|
+
process.env[`${prefix}EXTENDS`] = Array.isArray(config.extends) ? JSON.stringify(config.extends) : config.extends;
|
|
439
|
+
}
|
|
440
|
+
if (config.name) {
|
|
441
|
+
process.env[`${prefix}NAME`] = config.name;
|
|
442
|
+
}
|
|
443
|
+
if (config.namespace) {
|
|
444
|
+
process.env[`${prefix}NAMESPACE`] = config.namespace;
|
|
445
|
+
}
|
|
446
|
+
if (config.owner) {
|
|
447
|
+
process.env[`${prefix}OWNER`] = config.owner;
|
|
448
|
+
}
|
|
449
|
+
if (config.bot) {
|
|
450
|
+
process.env[`${prefix}BOT_NAME`] = config.bot.name;
|
|
451
|
+
process.env[`${prefix}BOT_EMAIL`] = config.bot.email;
|
|
452
|
+
}
|
|
453
|
+
if (config.organization) {
|
|
454
|
+
process.env[`${prefix}ORGANIZATION`] = config.organization;
|
|
455
|
+
}
|
|
456
|
+
if (config.packageManager) {
|
|
457
|
+
process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
|
|
458
|
+
}
|
|
459
|
+
if (config.license) {
|
|
460
|
+
process.env[`${prefix}LICENSE`] = config.license;
|
|
461
|
+
}
|
|
462
|
+
if (config.homepage) {
|
|
463
|
+
process.env[`${prefix}HOMEPAGE`] = config.homepage;
|
|
464
|
+
}
|
|
465
|
+
if (config.docs) {
|
|
466
|
+
process.env[`${prefix}DOCS`] = config.docs;
|
|
467
|
+
}
|
|
468
|
+
if (config.licensing) {
|
|
469
|
+
process.env[`${prefix}LICENSING`] = config.licensing;
|
|
470
|
+
}
|
|
471
|
+
if (config.timezone) {
|
|
472
|
+
process.env[`${prefix}TIMEZONE`] = config.timezone;
|
|
473
|
+
process.env.TZ = config.timezone;
|
|
474
|
+
process.env.DEFAULT_TIMEZONE = config.timezone;
|
|
475
|
+
}
|
|
476
|
+
if (config.locale) {
|
|
477
|
+
process.env[`${prefix}LOCALE`] = config.locale;
|
|
478
|
+
process.env.LOCALE = config.locale;
|
|
479
|
+
process.env.DEFAULT_LOCALE = config.locale;
|
|
480
|
+
process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
|
|
481
|
+
}
|
|
482
|
+
if (config.configFile) {
|
|
483
|
+
process.env[`${prefix}CONFIG_FILE`] = correctPaths(config.configFile);
|
|
484
|
+
}
|
|
485
|
+
if (config.workspaceRoot) {
|
|
486
|
+
process.env[`${prefix}WORKSPACE_ROOT`] = correctPaths(config.workspaceRoot);
|
|
487
|
+
process.env.NX_WORKSPACE_ROOT = correctPaths(config.workspaceRoot);
|
|
488
|
+
process.env.NX_WORKSPACE_ROOT_PATH = correctPaths(config.workspaceRoot);
|
|
489
|
+
}
|
|
490
|
+
if (config.directories) {
|
|
491
|
+
if (!config.skipCache && config.directories.cache) {
|
|
492
|
+
process.env[`${prefix}CACHE_DIR`] = correctPaths(config.directories.cache);
|
|
493
|
+
}
|
|
494
|
+
if (config.directories.data) {
|
|
495
|
+
process.env[`${prefix}DATA_DIR`] = correctPaths(config.directories.data);
|
|
496
|
+
}
|
|
497
|
+
if (config.directories.config) {
|
|
498
|
+
process.env[`${prefix}CONFIG_DIR`] = correctPaths(config.directories.config);
|
|
499
|
+
}
|
|
500
|
+
if (config.directories.temp) {
|
|
501
|
+
process.env[`${prefix}TEMP_DIR`] = correctPaths(config.directories.temp);
|
|
502
|
+
}
|
|
503
|
+
if (config.directories.log) {
|
|
504
|
+
process.env[`${prefix}LOG_DIR`] = correctPaths(config.directories.log);
|
|
505
|
+
}
|
|
506
|
+
if (config.directories.build) {
|
|
507
|
+
process.env[`${prefix}BUILD_DIR`] = correctPaths(config.directories.build);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (config.skipCache !== void 0) {
|
|
511
|
+
process.env[`${prefix}SKIP_CACHE`] = String(config.skipCache);
|
|
512
|
+
if (config.skipCache) {
|
|
513
|
+
process.env.NX_SKIP_NX_CACHE ??= String(config.skipCache);
|
|
514
|
+
process.env.NX_CACHE_PROJECT_GRAPH ??= String(config.skipCache);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (config.env) {
|
|
518
|
+
process.env[`${prefix}ENV`] = config.env;
|
|
519
|
+
process.env.NODE_ENV = config.env;
|
|
520
|
+
process.env.ENVIRONMENT = config.env;
|
|
521
|
+
}
|
|
522
|
+
if (config.colors?.base?.light || config.colors?.base?.dark) {
|
|
523
|
+
for (const key of Object.keys(config.colors)) {
|
|
524
|
+
setThemeColorConfigEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
|
|
525
|
+
}
|
|
526
|
+
} else {
|
|
527
|
+
setThemeColorConfigEnv(`${prefix}COLOR_`, config.colors);
|
|
528
|
+
}
|
|
529
|
+
if (config.repository) {
|
|
530
|
+
process.env[`${prefix}REPOSITORY`] = config.repository;
|
|
531
|
+
}
|
|
532
|
+
if (config.branch) {
|
|
533
|
+
process.env[`${prefix}BRANCH`] = config.branch;
|
|
534
|
+
}
|
|
535
|
+
if (config.preid) {
|
|
536
|
+
process.env[`${prefix}PRE_ID`] = String(config.preid);
|
|
537
|
+
}
|
|
538
|
+
if (config.externalPackagePatterns) {
|
|
539
|
+
process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(config.externalPackagePatterns);
|
|
540
|
+
}
|
|
541
|
+
if (config.registry) {
|
|
542
|
+
if (config.registry.github) {
|
|
543
|
+
process.env[`${prefix}REGISTRY_GITHUB`] = String(config.registry.github);
|
|
544
|
+
}
|
|
545
|
+
if (config.registry.npm) {
|
|
546
|
+
process.env[`${prefix}REGISTRY_NPM`] = String(config.registry.npm);
|
|
547
|
+
}
|
|
548
|
+
if (config.registry.cargo) {
|
|
549
|
+
process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
|
|
550
|
+
}
|
|
551
|
+
if (config.registry.cyclone) {
|
|
552
|
+
process.env[`${prefix}REGISTRY_CYCLONE`] = String(config.registry.cyclone);
|
|
553
|
+
}
|
|
554
|
+
if (config.registry.container) {
|
|
555
|
+
process.env[`${prefix}REGISTRY_CONTAINER`] = String(config.registry.cyclone);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
if (config.logLevel) {
|
|
559
|
+
process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
|
|
560
|
+
process.env.LOG_LEVEL = String(config.logLevel);
|
|
561
|
+
process.env.NX_VERBOSE_LOGGING = String(getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false);
|
|
562
|
+
process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
|
|
563
|
+
}
|
|
564
|
+
process.env[`${prefix}CONFIG`] = JSON.stringify(config);
|
|
565
|
+
for (const key of Object.keys(config.extensions ?? {})) {
|
|
566
|
+
config.extensions[key] && Object.keys(config.extensions[key]) && setExtensionEnv(key, config.extensions[key]);
|
|
567
|
+
}
|
|
568
|
+
}, "setConfigEnv");
|
|
569
|
+
var setThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
|
|
570
|
+
return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorConfigEnv(prefix, config) : setSingleThemeColorConfigEnv(prefix, config);
|
|
571
|
+
}, "setThemeColorConfigEnv");
|
|
572
|
+
var setSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
|
|
573
|
+
if (config.dark) {
|
|
574
|
+
process.env[`${prefix}DARK`] = config.dark;
|
|
575
|
+
}
|
|
576
|
+
if (config.light) {
|
|
577
|
+
process.env[`${prefix}LIGHT`] = config.light;
|
|
578
|
+
}
|
|
579
|
+
if (config.brand) {
|
|
580
|
+
process.env[`${prefix}BRAND`] = config.brand;
|
|
581
|
+
}
|
|
582
|
+
if (config.alternate) {
|
|
583
|
+
process.env[`${prefix}ALTERNATE`] = config.alternate;
|
|
584
|
+
}
|
|
585
|
+
if (config.accent) {
|
|
586
|
+
process.env[`${prefix}ACCENT`] = config.accent;
|
|
587
|
+
}
|
|
588
|
+
if (config.link) {
|
|
589
|
+
process.env[`${prefix}LINK`] = config.link;
|
|
590
|
+
}
|
|
591
|
+
if (config.help) {
|
|
592
|
+
process.env[`${prefix}HELP`] = config.help;
|
|
593
|
+
}
|
|
594
|
+
if (config.success) {
|
|
595
|
+
process.env[`${prefix}SUCCESS`] = config.success;
|
|
596
|
+
}
|
|
597
|
+
if (config.info) {
|
|
598
|
+
process.env[`${prefix}INFO`] = config.info;
|
|
599
|
+
}
|
|
600
|
+
if (config.warning) {
|
|
601
|
+
process.env[`${prefix}WARNING`] = config.warning;
|
|
602
|
+
}
|
|
603
|
+
if (config.danger) {
|
|
604
|
+
process.env[`${prefix}DANGER`] = config.danger;
|
|
605
|
+
}
|
|
606
|
+
if (config.fatal) {
|
|
607
|
+
process.env[`${prefix}FATAL`] = config.fatal;
|
|
608
|
+
}
|
|
609
|
+
if (config.positive) {
|
|
610
|
+
process.env[`${prefix}POSITIVE`] = config.positive;
|
|
611
|
+
}
|
|
612
|
+
if (config.negative) {
|
|
613
|
+
process.env[`${prefix}NEGATIVE`] = config.negative;
|
|
614
|
+
}
|
|
615
|
+
}, "setSingleThemeColorConfigEnv");
|
|
616
|
+
var setMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
|
|
617
|
+
return {
|
|
618
|
+
light: setBaseThemeColorConfigEnv(`${prefix}LIGHT_`, config.light),
|
|
619
|
+
dark: setBaseThemeColorConfigEnv(`${prefix}DARK_`, config.dark)
|
|
620
|
+
};
|
|
621
|
+
}, "setMultiThemeColorConfigEnv");
|
|
622
|
+
var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
|
|
623
|
+
if (config.foreground) {
|
|
624
|
+
process.env[`${prefix}FOREGROUND`] = config.foreground;
|
|
625
|
+
}
|
|
626
|
+
if (config.background) {
|
|
627
|
+
process.env[`${prefix}BACKGROUND`] = config.background;
|
|
628
|
+
}
|
|
629
|
+
if (config.brand) {
|
|
630
|
+
process.env[`${prefix}BRAND`] = config.brand;
|
|
631
|
+
}
|
|
632
|
+
if (config.alternate) {
|
|
633
|
+
process.env[`${prefix}ALTERNATE`] = config.alternate;
|
|
634
|
+
}
|
|
635
|
+
if (config.accent) {
|
|
636
|
+
process.env[`${prefix}ACCENT`] = config.accent;
|
|
637
|
+
}
|
|
638
|
+
if (config.link) {
|
|
639
|
+
process.env[`${prefix}LINK`] = config.link;
|
|
640
|
+
}
|
|
641
|
+
if (config.help) {
|
|
642
|
+
process.env[`${prefix}HELP`] = config.help;
|
|
643
|
+
}
|
|
644
|
+
if (config.success) {
|
|
645
|
+
process.env[`${prefix}SUCCESS`] = config.success;
|
|
646
|
+
}
|
|
647
|
+
if (config.info) {
|
|
648
|
+
process.env[`${prefix}INFO`] = config.info;
|
|
649
|
+
}
|
|
650
|
+
if (config.warning) {
|
|
651
|
+
process.env[`${prefix}WARNING`] = config.warning;
|
|
652
|
+
}
|
|
653
|
+
if (config.danger) {
|
|
654
|
+
process.env[`${prefix}DANGER`] = config.danger;
|
|
655
|
+
}
|
|
656
|
+
if (config.fatal) {
|
|
657
|
+
process.env[`${prefix}FATAL`] = config.fatal;
|
|
658
|
+
}
|
|
659
|
+
if (config.positive) {
|
|
660
|
+
process.env[`${prefix}POSITIVE`] = config.positive;
|
|
661
|
+
}
|
|
662
|
+
if (config.negative) {
|
|
663
|
+
process.env[`${prefix}NEGATIVE`] = config.negative;
|
|
664
|
+
}
|
|
665
|
+
}, "setBaseThemeColorConfigEnv");
|
|
666
|
+
|
|
667
|
+
// ../config-tools/src/create-storm-config.ts
|
|
668
|
+
var _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
669
|
+
var _static_cache = void 0;
|
|
670
|
+
var createStormConfig = /* @__PURE__ */ __name(async (extensionName, schema, workspaceRoot, skipLogs = false) => {
|
|
671
|
+
let result;
|
|
672
|
+
if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
|
|
673
|
+
let _workspaceRoot = workspaceRoot;
|
|
674
|
+
if (!_workspaceRoot) {
|
|
675
|
+
_workspaceRoot = findWorkspaceRoot();
|
|
676
|
+
}
|
|
677
|
+
const configEnv = getConfigEnv();
|
|
678
|
+
const defaultConfig = await getDefaultConfig(_workspaceRoot);
|
|
679
|
+
const configFile = await getConfigFile(_workspaceRoot);
|
|
680
|
+
if (!configFile && !skipLogs) {
|
|
681
|
+
writeWarning("No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.json` file to the root of your workspace if it is not.\n", {
|
|
682
|
+
logLevel: "all"
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
result = await StormConfigSchema.parseAsync(defu2(configEnv, configFile, defaultConfig));
|
|
686
|
+
result.workspaceRoot ??= _workspaceRoot;
|
|
687
|
+
} else {
|
|
688
|
+
result = _static_cache.data;
|
|
689
|
+
}
|
|
690
|
+
if (schema && extensionName) {
|
|
691
|
+
result.extensions = {
|
|
692
|
+
...result.extensions,
|
|
693
|
+
[extensionName]: createConfigExtension(extensionName, schema)
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
_static_cache = {
|
|
697
|
+
timestamp: Date.now(),
|
|
698
|
+
data: result
|
|
699
|
+
};
|
|
700
|
+
return result;
|
|
701
|
+
}, "createStormConfig");
|
|
702
|
+
var createConfigExtension = /* @__PURE__ */ __name((extensionName, schema) => {
|
|
703
|
+
const extension_cache_key = {
|
|
704
|
+
extensionName
|
|
705
|
+
};
|
|
706
|
+
if (_extension_cache.has(extension_cache_key)) {
|
|
707
|
+
return _extension_cache.get(extension_cache_key);
|
|
708
|
+
}
|
|
709
|
+
let extension = getExtensionEnv(extensionName);
|
|
710
|
+
if (schema) {
|
|
711
|
+
extension = schema.parse(extension);
|
|
712
|
+
}
|
|
713
|
+
_extension_cache.set(extension_cache_key, extension);
|
|
714
|
+
return extension;
|
|
715
|
+
}, "createConfigExtension");
|
|
716
|
+
var loadStormConfig = /* @__PURE__ */ __name(async (workspaceRoot, skipLogs = false) => {
|
|
717
|
+
const config = await createStormConfig(void 0, void 0, workspaceRoot, skipLogs);
|
|
718
|
+
setConfigEnv(config);
|
|
719
|
+
if (!skipLogs) {
|
|
720
|
+
writeTrace(`\u2699\uFE0F Using Storm configuration:
|
|
721
|
+
${formatLogMessage(config)}`, config);
|
|
722
|
+
}
|
|
723
|
+
return config;
|
|
724
|
+
}, "loadStormConfig");
|
|
725
|
+
|
|
726
|
+
// ../config-tools/src/get-config.ts
|
|
727
|
+
var getConfig = /* @__PURE__ */ __name((workspaceRoot, skipLogs = false) => {
|
|
728
|
+
return loadStormConfig(workspaceRoot, skipLogs);
|
|
729
|
+
}, "getConfig");
|
|
730
|
+
|
|
731
|
+
// ../build-tools/src/utilities/get-entry-points.ts
|
|
732
|
+
import { glob as glob2 } from "glob";
|
|
733
|
+
|
|
734
|
+
// ../build-tools/src/utilities/read-nx-config.ts
|
|
735
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
736
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
737
|
+
|
|
738
|
+
// ../build-tools/src/utilities/task-graph.ts
|
|
739
|
+
import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-runner/create-task-graph";
|
|
740
|
+
|
|
741
|
+
// src/build.ts
|
|
742
|
+
import defu3 from "defu";
|
|
743
|
+
import { Glob as Glob2 } from "glob";
|
|
744
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
745
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
746
|
+
import { relative as relative2 } from "node:path";
|
|
747
|
+
import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
|
|
748
|
+
import { build as unbuild } from "unbuild";
|
|
749
|
+
async function resolveOptions(options, config) {
|
|
750
|
+
writeDebug(" \u2699\uFE0F Resolving build options", config);
|
|
751
|
+
const stopwatch = getStopwatch("Build options resolution");
|
|
752
|
+
if (options.configPath) {
|
|
753
|
+
const configFile = await loadConfig(options.configPath);
|
|
754
|
+
if (configFile) {
|
|
755
|
+
options = defu3(options, configFile);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
const outputPath = options.outputPath || joinPaths("dist", options.projectRoot);
|
|
759
|
+
const projectGraph = readCachedProjectGraph2();
|
|
760
|
+
const projectJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "project.json");
|
|
761
|
+
if (!existsSync3(projectJsonPath)) {
|
|
762
|
+
throw new Error("Cannot find project.json configuration");
|
|
763
|
+
}
|
|
764
|
+
const projectJsonContent = await readFile4(projectJsonPath, "utf8");
|
|
765
|
+
const projectJson = JSON.parse(projectJsonContent);
|
|
766
|
+
const projectName = projectJson.name;
|
|
767
|
+
const packageJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "package.json");
|
|
768
|
+
if (!existsSync3(packageJsonPath)) {
|
|
769
|
+
throw new Error("Cannot find package.json configuration");
|
|
770
|
+
}
|
|
771
|
+
const packageJsonContent = await readFile4(packageJsonPath, "utf8");
|
|
772
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
773
|
+
let tsconfig = options.tsconfig;
|
|
774
|
+
if (!tsconfig) {
|
|
775
|
+
tsconfig = joinPaths(config.workspaceRoot, options.projectRoot, "tsconfig.json");
|
|
776
|
+
}
|
|
777
|
+
if (!existsSync3(tsconfig)) {
|
|
778
|
+
throw new Error("Cannot find tsconfig.json configuration");
|
|
779
|
+
}
|
|
780
|
+
let sourceRoot = projectJson.sourceRoot;
|
|
781
|
+
if (!sourceRoot) {
|
|
782
|
+
sourceRoot = joinPaths(options.projectRoot, "src");
|
|
783
|
+
}
|
|
784
|
+
if (!existsSync3(sourceRoot)) {
|
|
785
|
+
throw new Error("Cannot find sourceRoot directory");
|
|
786
|
+
}
|
|
787
|
+
const result = calculateProjectBuildableDependencies2(void 0, projectGraph, config.workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
788
|
+
let dependencies = result.dependencies;
|
|
789
|
+
const tsLibDependency = getHelperDependency(HelperDependency.tsc, tsconfig, dependencies, projectGraph, true);
|
|
790
|
+
if (tsLibDependency) {
|
|
791
|
+
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
792
|
+
dependencies.push(tsLibDependency);
|
|
793
|
+
}
|
|
794
|
+
const name = options.name || projectName;
|
|
795
|
+
const entries = options.entry ?? [
|
|
796
|
+
sourceRoot
|
|
797
|
+
];
|
|
798
|
+
const resolvedOptions = {
|
|
799
|
+
name,
|
|
800
|
+
config,
|
|
801
|
+
projectRoot: options.projectRoot,
|
|
802
|
+
sourceRoot,
|
|
803
|
+
projectName,
|
|
804
|
+
tsconfig,
|
|
805
|
+
clean: false,
|
|
806
|
+
entries: entries.reduce((ret, entry) => {
|
|
807
|
+
let entryPath = entry.replace(options.projectRoot, "");
|
|
808
|
+
while (entryPath.startsWith(".")) {
|
|
809
|
+
entryPath = entryPath.substring(1);
|
|
810
|
+
}
|
|
811
|
+
while (entryPath.startsWith("/")) {
|
|
812
|
+
entryPath = entryPath.substring(1);
|
|
813
|
+
}
|
|
814
|
+
const outDir = joinPaths(relative2(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist");
|
|
815
|
+
ret.push({
|
|
816
|
+
name: `${name}-esm`,
|
|
817
|
+
builder: "mkdist",
|
|
818
|
+
input: `./${entryPath}`,
|
|
819
|
+
outDir,
|
|
820
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
821
|
+
format: "esm"
|
|
822
|
+
});
|
|
823
|
+
ret.push({
|
|
824
|
+
name: `${name}-cjs`,
|
|
825
|
+
builder: "mkdist",
|
|
826
|
+
input: `./${entryPath}`,
|
|
827
|
+
outDir,
|
|
828
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
829
|
+
format: "cjs",
|
|
830
|
+
ext: "cjs"
|
|
831
|
+
});
|
|
832
|
+
return ret;
|
|
833
|
+
}, []),
|
|
834
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
835
|
+
failOnWarn: false,
|
|
836
|
+
sourcemap: options.sourcemap ?? !!options.debug,
|
|
837
|
+
outDir: outputPath,
|
|
838
|
+
parallel: true,
|
|
839
|
+
stub: false,
|
|
840
|
+
stubOptions: {
|
|
841
|
+
jiti: {}
|
|
842
|
+
},
|
|
843
|
+
externals: options.external ?? [],
|
|
844
|
+
dependencies: [],
|
|
845
|
+
peerDependencies: [],
|
|
846
|
+
devDependencies: [],
|
|
847
|
+
hooks: {},
|
|
848
|
+
alias: {},
|
|
849
|
+
replace: {},
|
|
850
|
+
rollup: {
|
|
851
|
+
replace: {},
|
|
852
|
+
alias: {},
|
|
853
|
+
json: {},
|
|
854
|
+
commonjs: {
|
|
855
|
+
sourceMap: options.sourcemap ?? true
|
|
856
|
+
},
|
|
857
|
+
emitCJS: true,
|
|
858
|
+
cjsBridge: true,
|
|
859
|
+
dts: {
|
|
860
|
+
respectExternal: true,
|
|
861
|
+
tsconfig
|
|
862
|
+
},
|
|
863
|
+
output: {
|
|
864
|
+
banner: options.banner || `
|
|
865
|
+
// \u26A1 Built by Storm Software
|
|
866
|
+
`,
|
|
867
|
+
footer: options.footer
|
|
868
|
+
},
|
|
869
|
+
resolve: {
|
|
870
|
+
preferBuiltins: true,
|
|
871
|
+
extensions: [
|
|
872
|
+
".cjs",
|
|
873
|
+
".mjs",
|
|
874
|
+
".js",
|
|
875
|
+
".jsx",
|
|
876
|
+
".ts",
|
|
877
|
+
".tsx",
|
|
878
|
+
".json"
|
|
879
|
+
]
|
|
880
|
+
},
|
|
881
|
+
esbuild: {
|
|
882
|
+
minify: options.minify ?? !options.debug,
|
|
883
|
+
sourceMap: options.sourcemap ?? !!options.debug,
|
|
884
|
+
splitting: options.splitting !== false,
|
|
885
|
+
treeShaking: options.treeShaking !== false,
|
|
886
|
+
color: true,
|
|
887
|
+
logLevel: config.logLevel === LogLevelLabel.FATAL ? LogLevelLabel.ERROR : isVerbose() ? "verbose" : config.logLevel
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
dependencies = dependencies.filter((dep) => dep.node.type === "npm" || dep.node.type === "lib" || dep.node.type === "app");
|
|
892
|
+
if (dependencies.length > 0) {
|
|
893
|
+
resolvedOptions.dependencies = dependencies.map((dep) => dep.name);
|
|
894
|
+
}
|
|
895
|
+
if (packageJson.devDependencies) {
|
|
896
|
+
resolvedOptions.devDependencies = Object.keys(packageJson.devDependencies);
|
|
897
|
+
}
|
|
898
|
+
if (packageJson.peerDependencies) {
|
|
899
|
+
resolvedOptions.peerDependencies = Object.keys(packageJson.peerDependencies);
|
|
900
|
+
}
|
|
901
|
+
if (options.rollup) {
|
|
902
|
+
let rollup = {};
|
|
903
|
+
if (typeof options.rollup === "string") {
|
|
904
|
+
const rollupFile = await loadConfig(options.rollup);
|
|
905
|
+
if (rollupFile) {
|
|
906
|
+
rollup = rollupFile;
|
|
907
|
+
}
|
|
908
|
+
} else {
|
|
909
|
+
rollup = options.rollup;
|
|
910
|
+
}
|
|
911
|
+
resolvedOptions.rollup = defu3(resolvedOptions.rollup ?? {}, rollup);
|
|
912
|
+
}
|
|
913
|
+
resolvedOptions.hooks = {
|
|
914
|
+
"rollup:options": /* @__PURE__ */ __name(async (ctx, opts) => {
|
|
915
|
+
opts.plugins = options.plugins ?? await getDefaultBuildPlugins(options, resolvedOptions);
|
|
916
|
+
}, "rollup:options")
|
|
917
|
+
};
|
|
918
|
+
stopwatch();
|
|
919
|
+
return resolvedOptions;
|
|
920
|
+
}
|
|
921
|
+
__name(resolveOptions, "resolveOptions");
|
|
922
|
+
var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot, projectRoot) => {
|
|
923
|
+
let root = sourceRoot.replace(projectRoot, "");
|
|
924
|
+
while (root.startsWith(".")) {
|
|
925
|
+
root = root.substring(1);
|
|
926
|
+
}
|
|
927
|
+
while (root.startsWith("/")) {
|
|
928
|
+
root = root.substring(1);
|
|
929
|
+
}
|
|
930
|
+
let entry = file.replaceAll("\\", "/").replace(sourceRoot, "");
|
|
931
|
+
while (entry.startsWith(".")) {
|
|
932
|
+
entry = entry.substring(1);
|
|
933
|
+
}
|
|
934
|
+
while (entry.startsWith("/")) {
|
|
935
|
+
entry = entry.substring(1);
|
|
936
|
+
}
|
|
937
|
+
return {
|
|
938
|
+
"import": {
|
|
939
|
+
"types": `./dist/${entry}.d.ts`,
|
|
940
|
+
"default": `./dist/${entry}.mjs`
|
|
941
|
+
},
|
|
942
|
+
"require": {
|
|
943
|
+
"types": `./dist/${entry}.d.ts`,
|
|
944
|
+
"default": `./dist/${entry}.cjs`
|
|
945
|
+
},
|
|
946
|
+
"default": {
|
|
947
|
+
"types": `./dist/${entry}.d.ts`,
|
|
948
|
+
"default": type === "commonjs" ? `./dist/${entry}.cjs` : `./dist/${entry}.mjs`
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
}, "addPackageJsonExport");
|
|
952
|
+
async function generatePackageJson(options) {
|
|
953
|
+
if (options.generatePackageJson !== false && existsSync3(joinPaths(options.projectRoot, "package.json"))) {
|
|
954
|
+
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
955
|
+
const stopwatch = getStopwatch("Write package.json file");
|
|
956
|
+
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
957
|
+
if (!existsSync3(packageJsonPath)) {
|
|
958
|
+
throw new Error("Cannot find package.json configuration");
|
|
959
|
+
}
|
|
960
|
+
let packageJsonContent = await readFile4(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"), "utf8");
|
|
961
|
+
if (!packageJsonContent) {
|
|
962
|
+
throw new Error("Cannot find package.json configuration file");
|
|
963
|
+
}
|
|
964
|
+
let packageJson = JSON.parse(packageJsonContent);
|
|
965
|
+
packageJson = await addPackageDependencies(options.config.workspaceRoot, options.projectRoot, options.projectName, packageJson);
|
|
966
|
+
packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
|
|
967
|
+
packageJson.exports ??= {};
|
|
968
|
+
await Promise.all(options.entries.reduce((ret, entry) => {
|
|
969
|
+
let entryPath = typeof entry === "string" ? entry : entry.input;
|
|
970
|
+
entryPath = entryPath.replaceAll("\\", "/");
|
|
971
|
+
while (entryPath.startsWith(".")) {
|
|
972
|
+
entryPath = entryPath.substring(1);
|
|
973
|
+
}
|
|
974
|
+
while (entryPath.startsWith("/")) {
|
|
975
|
+
entryPath = entryPath.substring(1);
|
|
976
|
+
}
|
|
977
|
+
entryPath = `./${joinPaths(options.projectRoot, entryPath)}`;
|
|
978
|
+
if (!ret.includes(entryPath)) {
|
|
979
|
+
ret.push(entryPath);
|
|
980
|
+
}
|
|
981
|
+
return ret;
|
|
982
|
+
}, []).map(async (entryPath) => {
|
|
983
|
+
const files = await new Glob2("**/*.{ts,tsx}", {
|
|
984
|
+
absolute: false,
|
|
985
|
+
cwd: entryPath,
|
|
986
|
+
root: entryPath
|
|
987
|
+
}).walk();
|
|
988
|
+
files.forEach((file) => {
|
|
989
|
+
addPackageJsonExport(file, packageJson.type, options.sourceRoot, options.projectRoot);
|
|
990
|
+
const split = file.split(".");
|
|
991
|
+
split.pop();
|
|
992
|
+
const entry = split.join(".").replaceAll("\\", "/");
|
|
993
|
+
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot, options.projectRoot);
|
|
994
|
+
});
|
|
995
|
+
}));
|
|
996
|
+
packageJson.main ??= "./dist/index.cjs";
|
|
997
|
+
packageJson.module ??= "./dist/index.mjs";
|
|
998
|
+
packageJson.types ??= "./dist/index.d.ts";
|
|
999
|
+
packageJson.exports ??= {};
|
|
1000
|
+
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
1001
|
+
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
1002
|
+
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
1003
|
+
}
|
|
1004
|
+
return ret;
|
|
1005
|
+
}, packageJson.exports);
|
|
1006
|
+
packageJson.exports["./package.json"] ??= "./package.json";
|
|
1007
|
+
packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot, options.projectRoot);
|
|
1008
|
+
await writeJsonFile(joinPaths(options.outDir, "package.json"), packageJson);
|
|
1009
|
+
stopwatch();
|
|
1010
|
+
}
|
|
1011
|
+
return options;
|
|
1012
|
+
}
|
|
1013
|
+
__name(generatePackageJson, "generatePackageJson");
|
|
1014
|
+
async function executeUnbuild(options) {
|
|
1015
|
+
writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
|
|
1016
|
+
const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
|
|
1017
|
+
try {
|
|
1018
|
+
const config = {
|
|
1019
|
+
...options,
|
|
1020
|
+
config: null,
|
|
1021
|
+
rootDir: joinPaths(options.config.workspaceRoot, options.projectRoot)
|
|
1022
|
+
};
|
|
1023
|
+
writeTrace(`Running with unbuild configuration:
|
|
1024
|
+
${formatLogMessage(config)}
|
|
1025
|
+
`, options.config);
|
|
1026
|
+
await unbuild(options.projectRoot, false, config);
|
|
1027
|
+
} finally {
|
|
1028
|
+
stopwatch();
|
|
1029
|
+
}
|
|
1030
|
+
return options;
|
|
1031
|
+
}
|
|
1032
|
+
__name(executeUnbuild, "executeUnbuild");
|
|
1033
|
+
async function copyBuildAssets(options) {
|
|
1034
|
+
writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`, options.config);
|
|
1035
|
+
const stopwatch = getStopwatch(`${options.name} asset copy`);
|
|
1036
|
+
await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.sourceRoot, options.generatePackageJson, options.includeSrc);
|
|
1037
|
+
stopwatch();
|
|
1038
|
+
return options;
|
|
1039
|
+
}
|
|
1040
|
+
__name(copyBuildAssets, "copyBuildAssets");
|
|
1041
|
+
async function cleanOutputPath(options) {
|
|
1042
|
+
if (options.clean !== false && options.outDir) {
|
|
1043
|
+
writeDebug(` \u{1F9F9} Cleaning ${options.name} output path: ${options.outDir}`, options.config);
|
|
1044
|
+
const stopwatch = getStopwatch(`${options.name} output clean`);
|
|
1045
|
+
await cleanDirectories(options.name, options.outDir, options.config);
|
|
1046
|
+
stopwatch();
|
|
1047
|
+
}
|
|
1048
|
+
return options;
|
|
1049
|
+
}
|
|
1050
|
+
__name(cleanOutputPath, "cleanOutputPath");
|
|
1051
|
+
async function build(options) {
|
|
1052
|
+
const projectRoot = options.projectRoot;
|
|
1053
|
+
if (!projectRoot) {
|
|
1054
|
+
throw new Error("Cannot find project root");
|
|
1055
|
+
}
|
|
1056
|
+
const workspaceRoot = findWorkspaceRoot2(projectRoot);
|
|
1057
|
+
if (!workspaceRoot) {
|
|
1058
|
+
throw new Error("Cannot find workspace root");
|
|
1059
|
+
}
|
|
1060
|
+
const config = await getConfig(workspaceRoot.dir);
|
|
1061
|
+
writeDebug(` \u26A1 Executing Storm Unbuild pipeline`, config);
|
|
1062
|
+
const stopwatch = getStopwatch("Unbuild pipeline");
|
|
1063
|
+
try {
|
|
1064
|
+
options.projectRoot = correctPaths(projectRoot);
|
|
1065
|
+
const resolvedOptions = await resolveOptions(options, config);
|
|
1066
|
+
await cleanOutputPath(resolvedOptions);
|
|
1067
|
+
await generatePackageJson(resolvedOptions);
|
|
1068
|
+
await executeUnbuild(resolvedOptions);
|
|
1069
|
+
await copyBuildAssets(resolvedOptions);
|
|
1070
|
+
writeSuccess(` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`, config);
|
|
1071
|
+
} catch (error) {
|
|
1072
|
+
writeFatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.", config);
|
|
1073
|
+
throw error;
|
|
1074
|
+
} finally {
|
|
1075
|
+
stopwatch();
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
__name(build, "build");
|
|
1079
|
+
|
|
1080
|
+
export {
|
|
1081
|
+
resolveOptions,
|
|
1082
|
+
generatePackageJson,
|
|
1083
|
+
executeUnbuild,
|
|
1084
|
+
copyBuildAssets,
|
|
1085
|
+
cleanOutputPath,
|
|
1086
|
+
build
|
|
1087
|
+
};
|