@storm-software/unbuild 0.30.5 → 0.31.0
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 +149 -133
- package/bin/unbuild.js +130 -114
- package/dist/build.cjs +8 -8
- package/dist/build.js +7 -7
- package/dist/{chunk-V627S7QU.cjs → chunk-26OHEX55.cjs} +2 -2
- package/dist/{chunk-KPFCICEG.js → chunk-3Q2ZB7CN.js} +1 -1
- package/dist/{chunk-VD6EE7HD.js → chunk-BZJA6TK2.js} +243 -231
- package/dist/{chunk-5E3NJ26L.cjs → chunk-CUQLNBV5.cjs} +3 -3
- package/dist/{chunk-5S4A4OEA.js → chunk-G2BQ6VSR.js} +1 -1
- package/dist/{chunk-CF2C3GEV.cjs → chunk-GVX7LSWK.cjs} +3 -3
- package/dist/{chunk-PSYW5YJB.cjs → chunk-KDTFDJN3.cjs} +2 -2
- package/dist/{chunk-FG6XQ26M.cjs → chunk-LXCK6Y4C.cjs} +20 -16
- package/dist/{chunk-F77T2VZV.cjs → chunk-N2XPKSKO.cjs} +318 -306
- package/dist/{chunk-C5IHRWT3.js → chunk-NYVG7QMW.js} +1 -1
- package/dist/{chunk-Y2DOCJBE.cjs → chunk-O45RUFL3.cjs} +6 -6
- package/dist/{chunk-K2D7TQ7G.js → chunk-OAOLAATA.js} +3 -3
- package/dist/{chunk-TPFSDZCR.js → chunk-VWXW3RW5.js} +18 -14
- package/dist/{chunk-VC7N2YVM.js → chunk-XGZOR6PZ.js} +1 -1
- package/dist/clean.cjs +3 -3
- package/dist/clean.js +2 -2
- package/dist/config.cjs +6 -6
- package/dist/config.js +5 -5
- package/dist/index.cjs +8 -8
- package/dist/index.js +7 -7
- package/package.json +4 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cleanDirectories
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XGZOR6PZ.js";
|
|
4
4
|
import {
|
|
5
5
|
getDefaultBuildPlugins
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OAOLAATA.js";
|
|
7
7
|
import {
|
|
8
8
|
loadConfig
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NYVG7QMW.js";
|
|
10
10
|
import {
|
|
11
11
|
COLOR_KEYS,
|
|
12
12
|
LogLevel,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
STORM_DEFAULT_DOCS,
|
|
15
15
|
STORM_DEFAULT_HOMEPAGE,
|
|
16
16
|
STORM_DEFAULT_LICENSING,
|
|
17
|
+
StormConfigSchema,
|
|
17
18
|
correctPaths,
|
|
18
19
|
findWorkspaceRoot,
|
|
19
20
|
formatLogMessage,
|
|
@@ -26,16 +27,15 @@ import {
|
|
|
26
27
|
writeDebug,
|
|
27
28
|
writeFatal,
|
|
28
29
|
writeSuccess,
|
|
29
|
-
writeSystem,
|
|
30
30
|
writeTrace,
|
|
31
31
|
writeWarning
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-VWXW3RW5.js";
|
|
33
33
|
import {
|
|
34
34
|
__name
|
|
35
35
|
} from "./chunk-3GQAWCBQ.js";
|
|
36
36
|
|
|
37
37
|
// src/build.ts
|
|
38
|
-
import { readCachedProjectGraph as
|
|
38
|
+
import { readCachedProjectGraph as readCachedProjectGraph2, writeJsonFile } from "@nx/devkit";
|
|
39
39
|
import { getHelperDependency, HelperDependency } from "@nx/js";
|
|
40
40
|
import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies2 } from "@nx/js/src/utils/buildable-libs-utils";
|
|
41
41
|
|
|
@@ -53,29 +53,173 @@ import { stripIndents } from "@nx/devkit";
|
|
|
53
53
|
import { relative } from "path";
|
|
54
54
|
|
|
55
55
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
56
|
-
import {
|
|
57
|
-
import { copyAssets as copyAssetsBase } from "@nx/js";
|
|
56
|
+
import { CopyAssetsHandler } from "@nx/js/src/utils/assets/copy-assets-handler";
|
|
58
57
|
import { glob } from "glob";
|
|
59
|
-
import { readFile
|
|
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");
|
|
60
204
|
|
|
61
205
|
// ../config-tools/src/config-file/get-config-file.ts
|
|
62
206
|
import { loadConfig as loadConfig2 } from "c12";
|
|
63
207
|
import defu from "defu";
|
|
64
208
|
var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, options = {}) => {
|
|
65
209
|
const workspacePath = filePath || findWorkspaceRoot(filePath);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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({
|
|
79
223
|
cwd: workspacePath,
|
|
80
224
|
packageJson: true,
|
|
81
225
|
name: fileName,
|
|
@@ -86,9 +230,9 @@ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, opti
|
|
|
86
230
|
},
|
|
87
231
|
configFile: fileName,
|
|
88
232
|
...options
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
return
|
|
233
|
+
})
|
|
234
|
+
]);
|
|
235
|
+
return defu(configs[0] ?? {}, configs[1] ?? {});
|
|
92
236
|
}, "getConfigFileByName");
|
|
93
237
|
var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames = []) => {
|
|
94
238
|
const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
|
|
@@ -96,7 +240,7 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
|
|
|
96
240
|
let config = result.config;
|
|
97
241
|
const configFile = result.configFile;
|
|
98
242
|
if (config && configFile && Object.keys(config).length > 0) {
|
|
99
|
-
|
|
243
|
+
writeTrace(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
|
|
100
244
|
logLevel: "all"
|
|
101
245
|
});
|
|
102
246
|
}
|
|
@@ -104,7 +248,7 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
|
|
|
104
248
|
const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
|
|
105
249
|
for (const result2 of results) {
|
|
106
250
|
if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
|
|
107
|
-
|
|
251
|
+
writeTrace(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
|
|
108
252
|
logLevel: "all"
|
|
109
253
|
});
|
|
110
254
|
config = defu(result2.config ?? {}, config ?? {});
|
|
@@ -122,6 +266,16 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
|
|
|
122
266
|
import defu2 from "defu";
|
|
123
267
|
|
|
124
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");
|
|
125
279
|
var getConfigEnv = /* @__PURE__ */ __name(() => {
|
|
126
280
|
const prefix = "STORM_";
|
|
127
281
|
let config = {
|
|
@@ -281,7 +435,7 @@ var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
|
|
|
281
435
|
var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
282
436
|
const prefix = "STORM_";
|
|
283
437
|
if (config.extends) {
|
|
284
|
-
process.env[`${prefix}EXTENDS`] = config.extends;
|
|
438
|
+
process.env[`${prefix}EXTENDS`] = Array.isArray(config.extends) ? JSON.stringify(config.extends) : config.extends;
|
|
285
439
|
}
|
|
286
440
|
if (config.name) {
|
|
287
441
|
process.env[`${prefix}NAME`] = config.name;
|
|
@@ -511,217 +665,75 @@ var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
|
|
|
511
665
|
}, "setBaseThemeColorConfigEnv");
|
|
512
666
|
|
|
513
667
|
// ../config-tools/src/create-storm-config.ts
|
|
668
|
+
var _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
514
669
|
var _static_cache = void 0;
|
|
515
|
-
var
|
|
516
|
-
let
|
|
517
|
-
if (_static_cache?.data
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}
|
|
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
|
+
};
|
|
530
695
|
}
|
|
531
|
-
|
|
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);
|
|
532
718
|
setConfigEnv(config);
|
|
533
|
-
|
|
719
|
+
if (!skipLogs) {
|
|
720
|
+
writeTrace(`\u2699\uFE0F Using Storm configuration:
|
|
534
721
|
${formatLogMessage(config)}`, config);
|
|
722
|
+
}
|
|
535
723
|
return config;
|
|
536
724
|
}, "loadStormConfig");
|
|
537
725
|
|
|
538
|
-
// ../
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
let rootDir = workspaceRoot;
|
|
543
|
-
if (!rootDir) {
|
|
544
|
-
const config = await loadStormConfig();
|
|
545
|
-
rootDir = config.workspaceRoot;
|
|
546
|
-
}
|
|
547
|
-
const nxJsonPath = joinPaths(rootDir, "nx.json");
|
|
548
|
-
if (!existsSync(nxJsonPath)) {
|
|
549
|
-
throw new Error("Cannot find project.json configuration");
|
|
550
|
-
}
|
|
551
|
-
const configContent = await readFile(nxJsonPath, "utf8");
|
|
552
|
-
return JSON.parse(configContent);
|
|
553
|
-
}, "readNxConfig");
|
|
726
|
+
// ../config-tools/src/get-config.ts
|
|
727
|
+
var getConfig = /* @__PURE__ */ __name((workspaceRoot, skipLogs = false) => {
|
|
728
|
+
return loadStormConfig(workspaceRoot, skipLogs);
|
|
729
|
+
}, "getConfig");
|
|
554
730
|
|
|
555
|
-
// ../build-tools/src/utilities/
|
|
556
|
-
|
|
557
|
-
const pendingAssets = Array.from(assets ?? []);
|
|
558
|
-
pendingAssets.push({
|
|
559
|
-
input: projectRoot,
|
|
560
|
-
glob: "*.md",
|
|
561
|
-
output: "."
|
|
562
|
-
});
|
|
563
|
-
pendingAssets.push({
|
|
564
|
-
input: config.workspaceRoot,
|
|
565
|
-
glob: "LICENSE",
|
|
566
|
-
output: "."
|
|
567
|
-
});
|
|
568
|
-
if (generatePackageJson2 === false) {
|
|
569
|
-
pendingAssets.push({
|
|
570
|
-
input: projectRoot,
|
|
571
|
-
glob: "package.json",
|
|
572
|
-
output: "."
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
if (includeSrc === true) {
|
|
576
|
-
pendingAssets.push({
|
|
577
|
-
input: sourceRoot,
|
|
578
|
-
glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
|
|
579
|
-
output: "src/"
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
const nxJson = readNxConfig(config.workspaceRoot);
|
|
583
|
-
const projectGraph = readCachedProjectGraph();
|
|
584
|
-
const projectsConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
585
|
-
if (!projectsConfigurations?.projects?.[projectName]) {
|
|
586
|
-
throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
|
|
587
|
-
}
|
|
588
|
-
const buildTarget = projectsConfigurations.projects[projectName].targets?.build;
|
|
589
|
-
if (!buildTarget) {
|
|
590
|
-
throw new Error(`The Build process failed because the project does not have a valid build target in the project.json file. Check if the file exists in the root of the project at ${joinPaths(projectRoot, "project.json")}`);
|
|
591
|
-
}
|
|
592
|
-
writeTrace(`\u{1F4DD} Copying the following assets to the output directory:
|
|
593
|
-
${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`, config);
|
|
594
|
-
const result = await copyAssetsBase({
|
|
595
|
-
assets: pendingAssets,
|
|
596
|
-
watch: false,
|
|
597
|
-
outputPath
|
|
598
|
-
}, {
|
|
599
|
-
root: config.workspaceRoot,
|
|
600
|
-
targetName: "build",
|
|
601
|
-
target: buildTarget,
|
|
602
|
-
projectName,
|
|
603
|
-
projectGraph,
|
|
604
|
-
projectsConfigurations,
|
|
605
|
-
nxJsonConfiguration: nxJson,
|
|
606
|
-
cwd: config.workspaceRoot,
|
|
607
|
-
isVerbose: isVerbose(config.logLevel)
|
|
608
|
-
});
|
|
609
|
-
if (!result.success) {
|
|
610
|
-
throw new Error("The Build process failed trying to copy assets");
|
|
611
|
-
}
|
|
612
|
-
if (includeSrc === true) {
|
|
613
|
-
writeDebug(`\u{1F4DD} Adding banner and writing source files: ${joinPaths(outputPath, "src")}`, config);
|
|
614
|
-
const files = await glob([
|
|
615
|
-
joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
|
|
616
|
-
joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
|
|
617
|
-
joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
618
|
-
joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
619
|
-
]);
|
|
620
|
-
await Promise.allSettled(files.map(async (file) => writeFile(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
621
|
-
|
|
622
|
-
${await readFile2(file, "utf8")}
|
|
623
|
-
|
|
624
|
-
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
|
|
625
|
-
}
|
|
626
|
-
}, "copyAssets");
|
|
731
|
+
// ../build-tools/src/utilities/get-entry-points.ts
|
|
732
|
+
import { glob as glob2 } from "glob";
|
|
627
733
|
|
|
628
|
-
// ../build-tools/src/utilities/
|
|
629
|
-
import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
|
|
630
|
-
import { Glob } from "glob";
|
|
734
|
+
// ../build-tools/src/utilities/read-nx-config.ts
|
|
631
735
|
import { existsSync as existsSync2 } from "node:fs";
|
|
632
736
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
633
|
-
import { readCachedProjectGraph as readCachedProjectGraph2 } from "nx/src/project-graph/project-graph";
|
|
634
|
-
var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projectRoot, projectName, packageJson) => {
|
|
635
|
-
const projectDependencies = calculateProjectBuildableDependencies(void 0, readCachedProjectGraph2(), workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
636
|
-
const localPackages = [];
|
|
637
|
-
for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
|
|
638
|
-
const projectNode = project.node;
|
|
639
|
-
if (projectNode.data.root) {
|
|
640
|
-
const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
|
|
641
|
-
if (existsSync2(projectPackageJsonPath)) {
|
|
642
|
-
const projectPackageJsonContent = await readFile3(projectPackageJsonPath, "utf8");
|
|
643
|
-
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
644
|
-
if (projectPackageJson.private !== false) {
|
|
645
|
-
localPackages.push(projectPackageJson);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
if (localPackages.length > 0) {
|
|
651
|
-
writeTrace(`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
|
|
652
|
-
packageJson.peerDependencies = localPackages.reduce((ret, localPackage) => {
|
|
653
|
-
if (!ret[localPackage.name]) {
|
|
654
|
-
ret[localPackage.name] = `>=${localPackage.version || "0.0.1"}`;
|
|
655
|
-
}
|
|
656
|
-
return ret;
|
|
657
|
-
}, packageJson.peerDependencies ?? {});
|
|
658
|
-
packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
|
|
659
|
-
if (!ret[localPackage.name]) {
|
|
660
|
-
ret[localPackage.name] = {
|
|
661
|
-
optional: false
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
return ret;
|
|
665
|
-
}, packageJson.peerDependenciesMeta ?? {});
|
|
666
|
-
packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
|
|
667
|
-
if (!ret[localPackage.name]) {
|
|
668
|
-
ret[localPackage.name] = localPackage.version || "0.0.1";
|
|
669
|
-
}
|
|
670
|
-
return ret;
|
|
671
|
-
}, packageJson.peerDependencies ?? {});
|
|
672
|
-
} else {
|
|
673
|
-
writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
|
|
674
|
-
}
|
|
675
|
-
return packageJson;
|
|
676
|
-
}, "addPackageDependencies");
|
|
677
|
-
var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
678
|
-
const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
|
|
679
|
-
const workspacePackageJsonContent = await readFile3(joinPaths(workspaceRoot, "package.json"), "utf8");
|
|
680
|
-
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
681
|
-
packageJson.type ??= "module";
|
|
682
|
-
packageJson.sideEffects ??= false;
|
|
683
|
-
if (includeSrc === true) {
|
|
684
|
-
let distSrc = sourceRoot.replace(projectRoot, "");
|
|
685
|
-
if (distSrc.startsWith("/")) {
|
|
686
|
-
distSrc = distSrc.substring(1);
|
|
687
|
-
}
|
|
688
|
-
packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
|
|
689
|
-
}
|
|
690
|
-
packageJson.files ??= [
|
|
691
|
-
"dist/**/*"
|
|
692
|
-
];
|
|
693
|
-
if (includeSrc === true && !packageJson.files.includes("src")) {
|
|
694
|
-
packageJson.files.push("src/**/*");
|
|
695
|
-
}
|
|
696
|
-
packageJson.publishConfig ??= {
|
|
697
|
-
access: "public"
|
|
698
|
-
};
|
|
699
|
-
packageJson.description ??= workspacePackageJson.description;
|
|
700
|
-
packageJson.homepage ??= workspacePackageJson.homepage;
|
|
701
|
-
packageJson.bugs ??= workspacePackageJson.bugs;
|
|
702
|
-
packageJson.license ??= workspacePackageJson.license;
|
|
703
|
-
packageJson.keywords ??= workspacePackageJson.keywords;
|
|
704
|
-
packageJson.funding ??= workspacePackageJson.funding;
|
|
705
|
-
packageJson.author ??= workspacePackageJson.author;
|
|
706
|
-
packageJson.maintainers ??= workspacePackageJson.maintainers;
|
|
707
|
-
if (!packageJson.maintainers && packageJson.author) {
|
|
708
|
-
packageJson.maintainers = [
|
|
709
|
-
packageJson.author
|
|
710
|
-
];
|
|
711
|
-
}
|
|
712
|
-
packageJson.contributors ??= workspacePackageJson.contributors;
|
|
713
|
-
if (!packageJson.contributors && packageJson.author) {
|
|
714
|
-
packageJson.contributors = [
|
|
715
|
-
packageJson.author
|
|
716
|
-
];
|
|
717
|
-
}
|
|
718
|
-
packageJson.repository ??= workspacePackageJson.repository;
|
|
719
|
-
packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
|
|
720
|
-
return packageJson;
|
|
721
|
-
}, "addWorkspacePackageJsonFields");
|
|
722
|
-
|
|
723
|
-
// ../build-tools/src/utilities/get-entry-points.ts
|
|
724
|
-
import { glob as glob2 } from "glob";
|
|
725
737
|
|
|
726
738
|
// ../build-tools/src/utilities/task-graph.ts
|
|
727
739
|
import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-runner/create-task-graph";
|
|
@@ -2176,7 +2188,7 @@ async function resolveOptions(options, config) {
|
|
|
2176
2188
|
}
|
|
2177
2189
|
}
|
|
2178
2190
|
const outputPath = options.outputPath || joinPaths("dist", options.projectRoot);
|
|
2179
|
-
const projectGraph =
|
|
2191
|
+
const projectGraph = readCachedProjectGraph2();
|
|
2180
2192
|
const projectJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "project.json");
|
|
2181
2193
|
if (!existsSync4(projectJsonPath)) {
|
|
2182
2194
|
throw new Error("Cannot find project.json configuration");
|
|
@@ -2453,7 +2465,7 @@ __name(executeUnbuild, "executeUnbuild");
|
|
|
2453
2465
|
async function copyBuildAssets(options) {
|
|
2454
2466
|
writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`, options.config);
|
|
2455
2467
|
const stopwatch = getStopwatch(`${options.name} asset copy`);
|
|
2456
|
-
await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.
|
|
2468
|
+
await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.sourceRoot, options.generatePackageJson, options.includeSrc);
|
|
2457
2469
|
stopwatch();
|
|
2458
2470
|
return options;
|
|
2459
2471
|
}
|
|
@@ -2477,7 +2489,7 @@ async function build2(options) {
|
|
|
2477
2489
|
if (!workspaceRoot) {
|
|
2478
2490
|
throw new Error("Cannot find workspace root");
|
|
2479
2491
|
}
|
|
2480
|
-
const config = await
|
|
2492
|
+
const config = await getConfig(workspaceRoot.dir);
|
|
2481
2493
|
writeDebug(` \u26A1 Executing Storm Unbuild pipeline`, config);
|
|
2482
2494
|
const stopwatch = getStopwatch("Unbuild pipeline");
|
|
2483
2495
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkLXCK6Y4Ccjs = require('./chunk-LXCK6Y4C.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkYDYGZTJKcjs = require('./chunk-YDYGZTJK.cjs');
|
|
@@ -9,8 +9,8 @@ var _chunkYDYGZTJKcjs = require('./chunk-YDYGZTJK.cjs');
|
|
|
9
9
|
// src/clean.ts
|
|
10
10
|
var _promises = require('fs/promises');
|
|
11
11
|
async function clean(name = "Unbuild", directory, config) {
|
|
12
|
-
|
|
13
|
-
const stopwatch =
|
|
12
|
+
_chunkLXCK6Y4Ccjs.writeDebug.call(void 0, ` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
|
|
13
|
+
const stopwatch = _chunkLXCK6Y4Ccjs.getStopwatch.call(void 0, `${name} output clean`);
|
|
14
14
|
await cleanDirectories(name, directory, config);
|
|
15
15
|
stopwatch();
|
|
16
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkLXCK6Y4Ccjs = require('./chunk-LXCK6Y4C.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkYDYGZTJKcjs = require('./chunk-YDYGZTJK.cjs');
|
|
@@ -10,7 +10,7 @@ var onErrorPlugin = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.call(void 0, (optio
|
|
|
10
10
|
name: "storm:on-error",
|
|
11
11
|
buildEnd(error) {
|
|
12
12
|
if (error) {
|
|
13
|
-
|
|
13
|
+
_chunkLXCK6Y4Ccjs.writeError.call(void 0, `The following errors occurred during the build:
|
|
14
14
|
${error ? error.message : "Unknown build error"}
|
|
15
15
|
|
|
16
16
|
`, resolvedOptions.config);
|
|
@@ -18,7 +18,7 @@ ${error ? error.message : "Unknown build error"}
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
renderError(error) {
|
|
21
|
-
|
|
21
|
+
_chunkLXCK6Y4Ccjs.writeError.call(void 0, `The following errors occurred during the build:
|
|
22
22
|
${error ? error.message : "Unknown build error"}
|
|
23
23
|
|
|
24
24
|
`, resolvedOptions.config);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkLXCK6Y4Ccjs = require('./chunk-LXCK6Y4C.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkYDYGZTJKcjs = require('./chunk-YDYGZTJK.cjs');
|
|
@@ -25,7 +25,7 @@ var analyzePlugin = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.call(void 0, (optio
|
|
|
25
25
|
renderChunk(source, chunk) {
|
|
26
26
|
const sourceBytes = formatBytes(source.length);
|
|
27
27
|
const fileName = chunk.fileName;
|
|
28
|
-
|
|
28
|
+
_chunkLXCK6Y4Ccjs.writeInfo.call(void 0, ` - ${fileName} ${sourceBytes}`, resolvedOptions.config);
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
}, "analyzePlugin");
|