@storm-software/tsdown 0.28.22 → 0.28.24
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/tsdown.cjs +245 -122
- package/dist/build.cjs +4 -5
- package/dist/build.js +3 -4
- package/dist/{chunk-PR5HLZXS.js → chunk-2YE3GBQH.js} +2 -7
- package/dist/{chunk-DEWYQH4B.cjs → chunk-65E5RX7I.cjs} +2 -7
- package/dist/{chunk-3RXXV65R.cjs → chunk-GBBMOENP.cjs} +436 -257
- package/dist/{chunk-X56SYHGK.js → chunk-IUBNNUNA.js} +386 -207
- package/dist/{chunk-2G7S4JNP.cjs → chunk-IUFIA7M2.cjs} +197 -134
- package/dist/{chunk-2WT22RMQ.js → chunk-J4T3BYOA.js} +196 -133
- package/dist/clean.cjs +2 -3
- package/dist/clean.js +1 -2
- package/dist/config.cjs +2 -3
- package/dist/config.js +1 -2
- package/dist/index.cjs +5 -6
- package/dist/index.js +4 -5
- package/dist/types.cjs +1 -1
- package/dist/types.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-SHUYVCID.js +0 -6
- package/dist/chunk-USNT2KNT.cjs +0 -6
- /package/dist/{chunk-GGNOJ77I.js → chunk-6F4PWJZI.js} +0 -0
- /package/dist/{chunk-SFZRYJZ2.cjs → chunk-ZBPRDZS4.cjs} +0 -0
|
@@ -20,16 +20,17 @@ import {
|
|
|
20
20
|
writeSuccess,
|
|
21
21
|
writeTrace,
|
|
22
22
|
writeWarning
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-J4T3BYOA.js";
|
|
24
24
|
import {
|
|
25
25
|
DEFAULT_BUILD_OPTIONS
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
import {
|
|
28
|
-
__name
|
|
29
|
-
} from "./chunk-SHUYVCID.js";
|
|
26
|
+
} from "./chunk-2YE3GBQH.js";
|
|
30
27
|
|
|
31
28
|
// src/build.ts
|
|
32
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
createProjectGraphAsync as createProjectGraphAsync2,
|
|
31
|
+
readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph2,
|
|
32
|
+
writeJsonFile
|
|
33
|
+
} from "@nx/devkit";
|
|
33
34
|
|
|
34
35
|
// ../build-tools/src/config.ts
|
|
35
36
|
var DEFAULT_ENVIRONMENT = "production";
|
|
@@ -53,7 +54,7 @@ import { relative } from "path";
|
|
|
53
54
|
import { CopyAssetsHandler } from "@nx/js/src/utils/assets/copy-assets-handler";
|
|
54
55
|
import { glob } from "glob";
|
|
55
56
|
import { readFile, writeFile } from "node:fs/promises";
|
|
56
|
-
var copyAssets =
|
|
57
|
+
var copyAssets = async (config, assets, outputPath, projectRoot, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
|
|
57
58
|
const pendingAssets = Array.from(assets ?? []);
|
|
58
59
|
pendingAssets.push({
|
|
59
60
|
input: projectRoot,
|
|
@@ -79,8 +80,11 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
|
|
|
79
80
|
output: "src/"
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
|
-
writeTrace(
|
|
83
|
-
|
|
83
|
+
writeTrace(
|
|
84
|
+
`\u{1F4DD} Copying the following assets to the output directory:
|
|
85
|
+
${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`,
|
|
86
|
+
config
|
|
87
|
+
);
|
|
84
88
|
const assetHandler = new CopyAssetsHandler({
|
|
85
89
|
projectDir: projectRoot,
|
|
86
90
|
rootDir: config.workspaceRoot,
|
|
@@ -89,28 +93,45 @@ ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${p
|
|
|
89
93
|
});
|
|
90
94
|
await assetHandler.processAllAssetsOnce();
|
|
91
95
|
if (includeSrc === true) {
|
|
92
|
-
writeDebug(
|
|
96
|
+
writeDebug(
|
|
97
|
+
`\u{1F4DD} Adding banner and writing source files: ${joinPaths(
|
|
98
|
+
outputPath,
|
|
99
|
+
"src"
|
|
100
|
+
)}`,
|
|
101
|
+
config
|
|
102
|
+
);
|
|
93
103
|
const files = await glob([
|
|
94
104
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
|
|
95
105
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
|
|
96
106
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
97
107
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
98
108
|
]);
|
|
99
|
-
await Promise.allSettled(
|
|
109
|
+
await Promise.allSettled(
|
|
110
|
+
files.map(
|
|
111
|
+
async (file) => writeFile(
|
|
112
|
+
file,
|
|
113
|
+
`${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
100
114
|
|
|
101
115
|
${await readFile(file, "utf8")}
|
|
102
116
|
|
|
103
|
-
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`
|
|
117
|
+
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
);
|
|
104
121
|
}
|
|
105
|
-
}
|
|
122
|
+
};
|
|
106
123
|
|
|
107
124
|
// ../build-tools/src/utilities/generate-package-json.ts
|
|
108
125
|
import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
|
|
109
126
|
import { Glob } from "glob";
|
|
110
127
|
import { existsSync, readFileSync } from "node:fs";
|
|
111
128
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
112
|
-
import {
|
|
113
|
-
|
|
129
|
+
import {
|
|
130
|
+
createProjectGraphAsync,
|
|
131
|
+
readCachedProjectGraph,
|
|
132
|
+
readProjectsConfigurationFromProjectGraph
|
|
133
|
+
} from "nx/src/project-graph/project-graph";
|
|
134
|
+
var addPackageDependencies = async (workspaceRoot, projectRoot, projectName, packageJson) => {
|
|
114
135
|
let projectGraph;
|
|
115
136
|
try {
|
|
116
137
|
projectGraph = readCachedProjectGraph();
|
|
@@ -119,16 +140,35 @@ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projec
|
|
|
119
140
|
projectGraph = readCachedProjectGraph();
|
|
120
141
|
}
|
|
121
142
|
if (!projectGraph) {
|
|
122
|
-
throw new Error(
|
|
143
|
+
throw new Error(
|
|
144
|
+
"The Build process failed because the project graph is not available. Please run the build command again."
|
|
145
|
+
);
|
|
123
146
|
}
|
|
124
|
-
const projectDependencies = calculateProjectBuildableDependencies(
|
|
147
|
+
const projectDependencies = calculateProjectBuildableDependencies(
|
|
148
|
+
void 0,
|
|
149
|
+
projectGraph,
|
|
150
|
+
workspaceRoot,
|
|
151
|
+
projectName,
|
|
152
|
+
process.env.NX_TASK_TARGET_TARGET || "build",
|
|
153
|
+
process.env.NX_TASK_TARGET_CONFIGURATION || "production",
|
|
154
|
+
true
|
|
155
|
+
);
|
|
125
156
|
const localPackages = [];
|
|
126
|
-
for (const project of projectDependencies.dependencies.filter(
|
|
157
|
+
for (const project of projectDependencies.dependencies.filter(
|
|
158
|
+
(dep) => dep.node.type === "lib" && dep.node.data?.root !== projectRoot && dep.node.data?.root !== workspaceRoot
|
|
159
|
+
)) {
|
|
127
160
|
const projectNode = project.node;
|
|
128
161
|
if (projectNode.data.root) {
|
|
129
|
-
const projectPackageJsonPath = joinPaths(
|
|
162
|
+
const projectPackageJsonPath = joinPaths(
|
|
163
|
+
workspaceRoot,
|
|
164
|
+
projectNode.data.root,
|
|
165
|
+
"package.json"
|
|
166
|
+
);
|
|
130
167
|
if (existsSync(projectPackageJsonPath)) {
|
|
131
|
-
const projectPackageJsonContent = await readFile2(
|
|
168
|
+
const projectPackageJsonContent = await readFile2(
|
|
169
|
+
projectPackageJsonPath,
|
|
170
|
+
"utf8"
|
|
171
|
+
);
|
|
132
172
|
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
133
173
|
if (projectPackageJson.private !== true) {
|
|
134
174
|
localPackages.push(projectPackageJson);
|
|
@@ -137,19 +177,33 @@ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projec
|
|
|
137
177
|
}
|
|
138
178
|
}
|
|
139
179
|
if (localPackages.length > 0) {
|
|
140
|
-
writeTrace(
|
|
141
|
-
|
|
180
|
+
writeTrace(
|
|
181
|
+
`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`
|
|
182
|
+
);
|
|
183
|
+
const projectJsonFile = await readFile2(
|
|
184
|
+
joinPaths(projectRoot, "project.json"),
|
|
185
|
+
"utf8"
|
|
186
|
+
);
|
|
142
187
|
const projectJson = JSON.parse(projectJsonFile);
|
|
143
188
|
const projectName2 = projectJson.name;
|
|
144
189
|
const projectConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
145
190
|
if (!projectConfigurations?.projects?.[projectName2]) {
|
|
146
|
-
throw new Error(
|
|
191
|
+
throw new Error(
|
|
192
|
+
"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."
|
|
193
|
+
);
|
|
147
194
|
}
|
|
148
195
|
const implicitDependencies = projectConfigurations.projects?.[projectName2].implicitDependencies?.reduce((ret, dep) => {
|
|
149
196
|
if (projectConfigurations.projects?.[dep]) {
|
|
150
|
-
const depPackageJsonPath = joinPaths(
|
|
197
|
+
const depPackageJsonPath = joinPaths(
|
|
198
|
+
workspaceRoot,
|
|
199
|
+
projectConfigurations.projects[dep].root,
|
|
200
|
+
"package.json"
|
|
201
|
+
);
|
|
151
202
|
if (existsSync(depPackageJsonPath)) {
|
|
152
|
-
const depPackageJsonContent = readFileSync(
|
|
203
|
+
const depPackageJsonContent = readFileSync(
|
|
204
|
+
depPackageJsonPath,
|
|
205
|
+
"utf8"
|
|
206
|
+
);
|
|
153
207
|
const depPackageJson = JSON.parse(depPackageJsonContent);
|
|
154
208
|
if (depPackageJson.private !== true && !ret.includes(depPackageJson.name)) {
|
|
155
209
|
ret.push(depPackageJson.name);
|
|
@@ -174,10 +228,13 @@ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projec
|
|
|
174
228
|
writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
|
|
175
229
|
}
|
|
176
230
|
return packageJson;
|
|
177
|
-
}
|
|
178
|
-
var addWorkspacePackageJsonFields =
|
|
231
|
+
};
|
|
232
|
+
var addWorkspacePackageJsonFields = async (workspaceConfig, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
179
233
|
const workspaceRoot = workspaceConfig.workspaceRoot ? workspaceConfig.workspaceRoot : findWorkspaceRoot();
|
|
180
|
-
const workspacePackageJsonContent = await readFile2(
|
|
234
|
+
const workspacePackageJsonContent = await readFile2(
|
|
235
|
+
joinPaths(workspaceRoot, "package.json"),
|
|
236
|
+
"utf8"
|
|
237
|
+
);
|
|
181
238
|
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
182
239
|
packageJson.type ??= "module";
|
|
183
240
|
packageJson.sideEffects ??= false;
|
|
@@ -188,9 +245,7 @@ var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (workspaceConfi
|
|
|
188
245
|
}
|
|
189
246
|
packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
|
|
190
247
|
}
|
|
191
|
-
packageJson.files ??= [
|
|
192
|
-
"dist/**/*"
|
|
193
|
-
];
|
|
248
|
+
packageJson.files ??= ["dist/**/*"];
|
|
194
249
|
if (includeSrc === true && !packageJson.files.includes("src")) {
|
|
195
250
|
packageJson.files.push("src/**/*");
|
|
196
251
|
}
|
|
@@ -206,21 +261,17 @@ var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (workspaceConfi
|
|
|
206
261
|
packageJson.author ??= workspacePackageJson.author;
|
|
207
262
|
packageJson.maintainers ??= workspacePackageJson.maintainers;
|
|
208
263
|
if (!packageJson.maintainers && packageJson.author) {
|
|
209
|
-
packageJson.maintainers = [
|
|
210
|
-
packageJson.author
|
|
211
|
-
];
|
|
264
|
+
packageJson.maintainers = [packageJson.author];
|
|
212
265
|
}
|
|
213
266
|
packageJson.contributors ??= workspacePackageJson.contributors;
|
|
214
267
|
if (!packageJson.contributors && packageJson.author) {
|
|
215
|
-
packageJson.contributors = [
|
|
216
|
-
packageJson.author
|
|
217
|
-
];
|
|
268
|
+
packageJson.contributors = [packageJson.author];
|
|
218
269
|
}
|
|
219
270
|
packageJson.repository ??= workspacePackageJson.repository;
|
|
220
271
|
packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
|
|
221
272
|
return packageJson;
|
|
222
|
-
}
|
|
223
|
-
var addPackageJsonExport =
|
|
273
|
+
};
|
|
274
|
+
var addPackageJsonExport = (file, type = "module", sourceRoot) => {
|
|
224
275
|
let entry = file.replaceAll("\\", "/");
|
|
225
276
|
if (sourceRoot) {
|
|
226
277
|
entry = entry.replace(sourceRoot, "");
|
|
@@ -239,12 +290,12 @@ var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", source
|
|
|
239
290
|
default: `./dist/${entry}.js`
|
|
240
291
|
}
|
|
241
292
|
};
|
|
242
|
-
}
|
|
293
|
+
};
|
|
243
294
|
|
|
244
295
|
// ../config-tools/src/config-file/get-config-file.ts
|
|
245
296
|
import { loadConfig } from "c12";
|
|
246
297
|
import defu from "defu";
|
|
247
|
-
var getConfigFileByName =
|
|
298
|
+
var getConfigFileByName = async (fileName, filePath, options = {}) => {
|
|
248
299
|
const workspacePath = filePath || findWorkspaceRoot(filePath);
|
|
249
300
|
const configs = await Promise.all([
|
|
250
301
|
loadConfig({
|
|
@@ -254,7 +305,10 @@ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, opti
|
|
|
254
305
|
envName: fileName?.toUpperCase(),
|
|
255
306
|
jitiOptions: {
|
|
256
307
|
debug: false,
|
|
257
|
-
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
308
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
309
|
+
process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
|
|
310
|
+
"jiti"
|
|
311
|
+
)
|
|
258
312
|
},
|
|
259
313
|
...options
|
|
260
314
|
}),
|
|
@@ -265,32 +319,45 @@ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, opti
|
|
|
265
319
|
envName: fileName?.toUpperCase(),
|
|
266
320
|
jitiOptions: {
|
|
267
321
|
debug: false,
|
|
268
|
-
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
322
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
323
|
+
process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
|
|
324
|
+
"jiti"
|
|
325
|
+
)
|
|
269
326
|
},
|
|
270
327
|
configFile: fileName,
|
|
271
328
|
...options
|
|
272
329
|
})
|
|
273
330
|
]);
|
|
274
331
|
return defu(configs[0] ?? {}, configs[1] ?? {});
|
|
275
|
-
}
|
|
276
|
-
var getConfigFile =
|
|
332
|
+
};
|
|
333
|
+
var getConfigFile = async (filePath, additionalFileNames = []) => {
|
|
277
334
|
const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
|
|
278
335
|
const result = await getConfigFileByName("storm-workspace", workspacePath);
|
|
279
336
|
let config = result.config;
|
|
280
337
|
const configFile = result.configFile;
|
|
281
338
|
if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) {
|
|
282
|
-
writeTrace(
|
|
283
|
-
|
|
284
|
-
|
|
339
|
+
writeTrace(
|
|
340
|
+
`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`,
|
|
341
|
+
{
|
|
342
|
+
logLevel: "all"
|
|
343
|
+
}
|
|
344
|
+
);
|
|
285
345
|
}
|
|
286
346
|
if (additionalFileNames && additionalFileNames.length > 0) {
|
|
287
|
-
const results = await Promise.all(
|
|
347
|
+
const results = await Promise.all(
|
|
348
|
+
additionalFileNames.map(
|
|
349
|
+
(fileName) => getConfigFileByName(fileName, workspacePath)
|
|
350
|
+
)
|
|
351
|
+
);
|
|
288
352
|
for (const result2 of results) {
|
|
289
353
|
if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
|
|
290
354
|
if (!config.skipConfigLogging && !result2.config.skipConfigLogging) {
|
|
291
|
-
writeTrace(
|
|
292
|
-
|
|
293
|
-
|
|
355
|
+
writeTrace(
|
|
356
|
+
`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`,
|
|
357
|
+
{
|
|
358
|
+
logLevel: "all"
|
|
359
|
+
}
|
|
360
|
+
);
|
|
294
361
|
}
|
|
295
362
|
config = defu(result2.config ?? {}, config ?? {});
|
|
296
363
|
}
|
|
@@ -301,23 +368,25 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
|
|
|
301
368
|
}
|
|
302
369
|
config.configFile = configFile;
|
|
303
370
|
return config;
|
|
304
|
-
}
|
|
371
|
+
};
|
|
305
372
|
|
|
306
373
|
// ../config-tools/src/create-storm-config.ts
|
|
307
374
|
import defu2 from "defu";
|
|
308
375
|
|
|
309
376
|
// ../config-tools/src/env/get-env.ts
|
|
310
|
-
var getExtensionEnv =
|
|
377
|
+
var getExtensionEnv = (extensionName) => {
|
|
311
378
|
const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
|
|
312
379
|
return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
|
|
313
|
-
const name = key.replace(prefix, "").split("_").map(
|
|
380
|
+
const name = key.replace(prefix, "").split("_").map(
|
|
381
|
+
(i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : ""
|
|
382
|
+
).join("");
|
|
314
383
|
if (name) {
|
|
315
384
|
ret[name] = process.env[key];
|
|
316
385
|
}
|
|
317
386
|
return ret;
|
|
318
387
|
}, {});
|
|
319
|
-
}
|
|
320
|
-
var getConfigEnv =
|
|
388
|
+
};
|
|
389
|
+
var getConfigEnv = () => {
|
|
321
390
|
const prefix = "STORM_";
|
|
322
391
|
let config = {
|
|
323
392
|
extends: process.env[`${prefix}EXTENDS`] || void 0,
|
|
@@ -385,14 +454,25 @@ var getConfigEnv = /* @__PURE__ */ __name(() => {
|
|
|
385
454
|
cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
|
|
386
455
|
container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
|
|
387
456
|
},
|
|
388
|
-
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(
|
|
457
|
+
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(
|
|
458
|
+
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
459
|
+
) ? getLogLevelLabel(
|
|
460
|
+
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
461
|
+
) : process.env[`${prefix}LOG_LEVEL`] : void 0,
|
|
389
462
|
skipConfigLogging: process.env[`${prefix}SKIP_CONFIG_LOGGING`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CONFIG_LOGGING`]) : void 0
|
|
390
463
|
};
|
|
391
|
-
const themeNames = Object.keys(process.env).filter(
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
464
|
+
const themeNames = Object.keys(process.env).filter(
|
|
465
|
+
(envKey) => envKey.startsWith(`${prefix}COLOR_`) && COLOR_KEYS.every(
|
|
466
|
+
(colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)
|
|
467
|
+
)
|
|
468
|
+
);
|
|
469
|
+
config.colors = themeNames.length > 0 ? themeNames.reduce(
|
|
470
|
+
(ret, themeName) => {
|
|
471
|
+
ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
|
|
472
|
+
return ret;
|
|
473
|
+
},
|
|
474
|
+
{}
|
|
475
|
+
) : getThemeColorConfigEnv(prefix);
|
|
396
476
|
if (config.docs === STORM_DEFAULT_DOCS) {
|
|
397
477
|
if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
|
|
398
478
|
config.docs = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
|
|
@@ -413,23 +493,17 @@ var getConfigEnv = /* @__PURE__ */ __name(() => {
|
|
|
413
493
|
config = {
|
|
414
494
|
...config,
|
|
415
495
|
...parsed,
|
|
416
|
-
colors: {
|
|
417
|
-
|
|
418
|
-
...parsed.colors
|
|
419
|
-
},
|
|
420
|
-
extensions: {
|
|
421
|
-
...config.extensions,
|
|
422
|
-
...parsed.extensions
|
|
423
|
-
}
|
|
496
|
+
colors: { ...config.colors, ...parsed.colors },
|
|
497
|
+
extensions: { ...config.extensions, ...parsed.extensions }
|
|
424
498
|
};
|
|
425
499
|
}
|
|
426
500
|
return config;
|
|
427
|
-
}
|
|
428
|
-
var getThemeColorConfigEnv =
|
|
501
|
+
};
|
|
502
|
+
var getThemeColorConfigEnv = (prefix, theme) => {
|
|
429
503
|
const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
|
|
430
504
|
return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
|
|
431
|
-
}
|
|
432
|
-
var getSingleThemeColorConfigEnv =
|
|
505
|
+
};
|
|
506
|
+
var getSingleThemeColorConfigEnv = (prefix) => {
|
|
433
507
|
return {
|
|
434
508
|
dark: process.env[`${prefix}DARK`],
|
|
435
509
|
light: process.env[`${prefix}LIGHT`],
|
|
@@ -446,14 +520,16 @@ var getSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
|
|
|
446
520
|
positive: process.env[`${prefix}POSITIVE`],
|
|
447
521
|
negative: process.env[`${prefix}NEGATIVE`]
|
|
448
522
|
};
|
|
449
|
-
}
|
|
450
|
-
var getMultiThemeColorConfigEnv =
|
|
523
|
+
};
|
|
524
|
+
var getMultiThemeColorConfigEnv = (prefix) => {
|
|
451
525
|
return {
|
|
452
|
-
light: getBaseThemeColorConfigEnv(
|
|
526
|
+
light: getBaseThemeColorConfigEnv(
|
|
527
|
+
`${prefix}_LIGHT_`
|
|
528
|
+
),
|
|
453
529
|
dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
|
|
454
530
|
};
|
|
455
|
-
}
|
|
456
|
-
var getBaseThemeColorConfigEnv =
|
|
531
|
+
};
|
|
532
|
+
var getBaseThemeColorConfigEnv = (prefix) => {
|
|
457
533
|
return {
|
|
458
534
|
foreground: process.env[`${prefix}FOREGROUND`],
|
|
459
535
|
background: process.env[`${prefix}BACKGROUND`],
|
|
@@ -470,13 +546,16 @@ var getBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
|
|
|
470
546
|
positive: process.env[`${prefix}POSITIVE`],
|
|
471
547
|
negative: process.env[`${prefix}NEGATIVE`]
|
|
472
548
|
};
|
|
473
|
-
}
|
|
549
|
+
};
|
|
474
550
|
|
|
475
551
|
// ../config-tools/src/env/set-env.ts
|
|
476
|
-
var setExtensionEnv =
|
|
552
|
+
var setExtensionEnv = (extensionName, extension) => {
|
|
477
553
|
for (const key of Object.keys(extension ?? {})) {
|
|
478
554
|
if (extension[key]) {
|
|
479
|
-
const result = key?.replace(
|
|
555
|
+
const result = key?.replace(
|
|
556
|
+
/([A-Z])+/g,
|
|
557
|
+
(input) => input ? input[0]?.toUpperCase() + input.slice(1) : ""
|
|
558
|
+
).split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
|
|
480
559
|
let extensionKey;
|
|
481
560
|
if (result.length === 0) {
|
|
482
561
|
return;
|
|
@@ -491,8 +570,8 @@ var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
|
|
|
491
570
|
process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
|
|
492
571
|
}
|
|
493
572
|
}
|
|
494
|
-
}
|
|
495
|
-
var setConfigEnv =
|
|
573
|
+
};
|
|
574
|
+
var setConfigEnv = (config) => {
|
|
496
575
|
const prefix = "STORM_";
|
|
497
576
|
if (config.extends) {
|
|
498
577
|
process.env[`${prefix}EXTENDS`] = Array.isArray(config.extends) ? JSON.stringify(config.extends) : config.extends;
|
|
@@ -581,7 +660,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
581
660
|
}
|
|
582
661
|
if (config.directories) {
|
|
583
662
|
if (!config.skipCache && config.directories.cache) {
|
|
584
|
-
process.env[`${prefix}CACHE_DIR`] = correctPaths(
|
|
663
|
+
process.env[`${prefix}CACHE_DIR`] = correctPaths(
|
|
664
|
+
config.directories.cache
|
|
665
|
+
);
|
|
585
666
|
process.env[`${prefix}CACHE_DIRECTORY`] = process.env[`${prefix}CACHE_DIR`];
|
|
586
667
|
}
|
|
587
668
|
if (config.directories.data) {
|
|
@@ -589,7 +670,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
589
670
|
process.env[`${prefix}DATA_DIRECTORY`] = process.env[`${prefix}DATA_DIR`];
|
|
590
671
|
}
|
|
591
672
|
if (config.directories.config) {
|
|
592
|
-
process.env[`${prefix}CONFIG_DIR`] = correctPaths(
|
|
673
|
+
process.env[`${prefix}CONFIG_DIR`] = correctPaths(
|
|
674
|
+
config.directories.config
|
|
675
|
+
);
|
|
593
676
|
process.env[`${prefix}CONFIG_DIRECTORY`] = process.env[`${prefix}CONFIG_DIR`];
|
|
594
677
|
}
|
|
595
678
|
if (config.directories.temp) {
|
|
@@ -601,7 +684,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
601
684
|
process.env[`${prefix}LOG_DIRECTORY`] = process.env[`${prefix}LOG_DIR`];
|
|
602
685
|
}
|
|
603
686
|
if (config.directories.build) {
|
|
604
|
-
process.env[`${prefix}BUILD_DIR`] = correctPaths(
|
|
687
|
+
process.env[`${prefix}BUILD_DIR`] = correctPaths(
|
|
688
|
+
config.directories.build
|
|
689
|
+
);
|
|
605
690
|
process.env[`${prefix}BUILD_DIRECTORY`] = process.env[`${prefix}BUILD_DIR`];
|
|
606
691
|
}
|
|
607
692
|
}
|
|
@@ -622,7 +707,10 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
622
707
|
setThemeColorConfigEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
|
|
623
708
|
}
|
|
624
709
|
} else {
|
|
625
|
-
setThemeColorConfigEnv(
|
|
710
|
+
setThemeColorConfigEnv(
|
|
711
|
+
`${prefix}COLOR_`,
|
|
712
|
+
config.colors
|
|
713
|
+
);
|
|
626
714
|
}
|
|
627
715
|
if (config.repository) {
|
|
628
716
|
process.env[`${prefix}REPOSITORY`] = config.repository;
|
|
@@ -634,7 +722,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
634
722
|
process.env[`${prefix}PRE_ID`] = String(config.preid);
|
|
635
723
|
}
|
|
636
724
|
if (config.externalPackagePatterns) {
|
|
637
|
-
process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(
|
|
725
|
+
process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(
|
|
726
|
+
config.externalPackagePatterns
|
|
727
|
+
);
|
|
638
728
|
}
|
|
639
729
|
if (config.registry) {
|
|
640
730
|
if (config.registry.github) {
|
|
@@ -647,20 +737,28 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
647
737
|
process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
|
|
648
738
|
}
|
|
649
739
|
if (config.registry.cyclone) {
|
|
650
|
-
process.env[`${prefix}REGISTRY_CYCLONE`] = String(
|
|
740
|
+
process.env[`${prefix}REGISTRY_CYCLONE`] = String(
|
|
741
|
+
config.registry.cyclone
|
|
742
|
+
);
|
|
651
743
|
}
|
|
652
744
|
if (config.registry.container) {
|
|
653
|
-
process.env[`${prefix}REGISTRY_CONTAINER`] = String(
|
|
745
|
+
process.env[`${prefix}REGISTRY_CONTAINER`] = String(
|
|
746
|
+
config.registry.container
|
|
747
|
+
);
|
|
654
748
|
}
|
|
655
749
|
}
|
|
656
750
|
if (config.logLevel) {
|
|
657
751
|
process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
|
|
658
752
|
process.env.LOG_LEVEL = String(config.logLevel);
|
|
659
|
-
process.env.NX_VERBOSE_LOGGING = String(
|
|
753
|
+
process.env.NX_VERBOSE_LOGGING = String(
|
|
754
|
+
getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false
|
|
755
|
+
);
|
|
660
756
|
process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
|
|
661
757
|
}
|
|
662
758
|
if (config.skipConfigLogging !== void 0) {
|
|
663
|
-
process.env[`${prefix}SKIP_CONFIG_LOGGING`] = String(
|
|
759
|
+
process.env[`${prefix}SKIP_CONFIG_LOGGING`] = String(
|
|
760
|
+
config.skipConfigLogging
|
|
761
|
+
);
|
|
664
762
|
}
|
|
665
763
|
process.env[`${prefix}CONFIG`] = JSON.stringify(config);
|
|
666
764
|
for (const key of Object.keys(config.extensions ?? {})) {
|
|
@@ -668,11 +766,11 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
668
766
|
setExtensionEnv(key, config.extensions[key]);
|
|
669
767
|
}
|
|
670
768
|
}
|
|
671
|
-
}
|
|
672
|
-
var setThemeColorConfigEnv =
|
|
769
|
+
};
|
|
770
|
+
var setThemeColorConfigEnv = (prefix, config) => {
|
|
673
771
|
return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorConfigEnv(prefix, config) : setSingleThemeColorConfigEnv(prefix, config);
|
|
674
|
-
}
|
|
675
|
-
var setSingleThemeColorConfigEnv =
|
|
772
|
+
};
|
|
773
|
+
var setSingleThemeColorConfigEnv = (prefix, config) => {
|
|
676
774
|
if (config.dark) {
|
|
677
775
|
process.env[`${prefix}DARK`] = config.dark;
|
|
678
776
|
}
|
|
@@ -715,14 +813,14 @@ var setSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
|
|
|
715
813
|
if (config.negative) {
|
|
716
814
|
process.env[`${prefix}NEGATIVE`] = config.negative;
|
|
717
815
|
}
|
|
718
|
-
}
|
|
719
|
-
var setMultiThemeColorConfigEnv =
|
|
816
|
+
};
|
|
817
|
+
var setMultiThemeColorConfigEnv = (prefix, config) => {
|
|
720
818
|
return {
|
|
721
819
|
light: setBaseThemeColorConfigEnv(`${prefix}LIGHT_`, config.light),
|
|
722
820
|
dark: setBaseThemeColorConfigEnv(`${prefix}DARK_`, config.dark)
|
|
723
821
|
};
|
|
724
|
-
}
|
|
725
|
-
var setBaseThemeColorConfigEnv =
|
|
822
|
+
};
|
|
823
|
+
var setBaseThemeColorConfigEnv = (prefix, config) => {
|
|
726
824
|
if (config.foreground) {
|
|
727
825
|
process.env[`${prefix}FOREGROUND`] = config.foreground;
|
|
728
826
|
}
|
|
@@ -765,12 +863,12 @@ var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
|
|
|
765
863
|
if (config.negative) {
|
|
766
864
|
process.env[`${prefix}NEGATIVE`] = config.negative;
|
|
767
865
|
}
|
|
768
|
-
}
|
|
866
|
+
};
|
|
769
867
|
|
|
770
868
|
// ../config-tools/src/create-storm-config.ts
|
|
771
869
|
var _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
772
870
|
var _static_cache = void 0;
|
|
773
|
-
var createStormWorkspaceConfig =
|
|
871
|
+
var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
|
|
774
872
|
let result;
|
|
775
873
|
if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
|
|
776
874
|
let _workspaceRoot = workspaceRoot;
|
|
@@ -781,16 +879,19 @@ var createStormWorkspaceConfig = /* @__PURE__ */ __name(async (extensionName, sc
|
|
|
781
879
|
const configFile = await getConfigFile(_workspaceRoot);
|
|
782
880
|
if (!configFile) {
|
|
783
881
|
if (!skipLogs) {
|
|
784
|
-
writeWarning(
|
|
785
|
-
|
|
786
|
-
|
|
882
|
+
writeWarning(
|
|
883
|
+
"No Storm Workspace configuration file found in the current repository. Please ensure this is the expected behavior - you can add a `storm-workspace.json` file to the root of your workspace if it is not.\n",
|
|
884
|
+
{ logLevel: "all" }
|
|
885
|
+
);
|
|
787
886
|
}
|
|
788
887
|
if (useDefault === false) {
|
|
789
888
|
return void 0;
|
|
790
889
|
}
|
|
791
890
|
}
|
|
792
891
|
const defaultConfig = await getDefaultConfig(_workspaceRoot);
|
|
793
|
-
result = await stormWorkspaceConfigSchema.parseAsync(
|
|
892
|
+
result = await stormWorkspaceConfigSchema.parseAsync(
|
|
893
|
+
defu2(configEnv, configFile, defaultConfig)
|
|
894
|
+
);
|
|
794
895
|
result.workspaceRoot ??= _workspaceRoot;
|
|
795
896
|
} else {
|
|
796
897
|
result = _static_cache.data;
|
|
@@ -806,11 +907,9 @@ var createStormWorkspaceConfig = /* @__PURE__ */ __name(async (extensionName, sc
|
|
|
806
907
|
data: result
|
|
807
908
|
};
|
|
808
909
|
return result;
|
|
809
|
-
}
|
|
810
|
-
var createConfigExtension =
|
|
811
|
-
const extension_cache_key = {
|
|
812
|
-
extensionName
|
|
813
|
-
};
|
|
910
|
+
};
|
|
911
|
+
var createConfigExtension = (extensionName, schema) => {
|
|
912
|
+
const extension_cache_key = { extensionName };
|
|
814
913
|
if (_extension_cache.has(extension_cache_key)) {
|
|
815
914
|
return _extension_cache.get(extension_cache_key);
|
|
816
915
|
}
|
|
@@ -820,25 +919,34 @@ var createConfigExtension = /* @__PURE__ */ __name((extensionName, schema) => {
|
|
|
820
919
|
}
|
|
821
920
|
_extension_cache.set(extension_cache_key, extension);
|
|
822
921
|
return extension;
|
|
823
|
-
}
|
|
824
|
-
var loadStormWorkspaceConfig =
|
|
825
|
-
const config = await createStormWorkspaceConfig(
|
|
922
|
+
};
|
|
923
|
+
var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
|
|
924
|
+
const config = await createStormWorkspaceConfig(
|
|
925
|
+
void 0,
|
|
926
|
+
void 0,
|
|
927
|
+
workspaceRoot,
|
|
928
|
+
skipLogs,
|
|
929
|
+
true
|
|
930
|
+
);
|
|
826
931
|
setConfigEnv(config);
|
|
827
932
|
if (!skipLogs && !config.skipConfigLogging) {
|
|
828
|
-
writeTrace(
|
|
829
|
-
|
|
933
|
+
writeTrace(
|
|
934
|
+
`\u2699\uFE0F Using Storm Workspace configuration:
|
|
935
|
+
${formatLogMessage(config)}`,
|
|
936
|
+
config
|
|
937
|
+
);
|
|
830
938
|
}
|
|
831
939
|
return config;
|
|
832
|
-
}
|
|
940
|
+
};
|
|
833
941
|
|
|
834
942
|
// ../config-tools/src/get-config.ts
|
|
835
|
-
var getConfig =
|
|
943
|
+
var getConfig = (workspaceRoot, skipLogs = false) => {
|
|
836
944
|
return loadStormWorkspaceConfig(workspaceRoot, skipLogs);
|
|
837
|
-
}
|
|
945
|
+
};
|
|
838
946
|
|
|
839
947
|
// ../build-tools/src/utilities/get-entry-points.ts
|
|
840
948
|
import { glob as glob2 } from "glob";
|
|
841
|
-
var getEntryPoints =
|
|
949
|
+
var getEntryPoints = async (config, projectRoot, sourceRoot, entry, emitOnAll = false) => {
|
|
842
950
|
const workspaceRoot = config.workspaceRoot || findWorkspaceRoot();
|
|
843
951
|
const entryPoints = [];
|
|
844
952
|
if (entry) {
|
|
@@ -851,35 +959,47 @@ var getEntryPoints = /* @__PURE__ */ __name(async (config, projectRoot, sourceRo
|
|
|
851
959
|
}
|
|
852
960
|
}
|
|
853
961
|
if (emitOnAll) {
|
|
854
|
-
entryPoints.push(
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
962
|
+
entryPoints.push(
|
|
963
|
+
joinPaths(workspaceRoot, sourceRoot || projectRoot, "**/*.{ts,tsx}")
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
const results = await Promise.all(
|
|
967
|
+
entryPoints.map(async (entryPoint) => {
|
|
968
|
+
const paths = [];
|
|
969
|
+
if (entryPoint.includes("*")) {
|
|
970
|
+
const files = await glob2(entryPoint, {
|
|
971
|
+
withFileTypes: true,
|
|
972
|
+
ignore: ["**/node_modules/**"]
|
|
973
|
+
});
|
|
974
|
+
paths.push(
|
|
975
|
+
...files.reduce((ret, filePath) => {
|
|
976
|
+
const result = correctPaths(
|
|
977
|
+
joinPaths(filePath.path, filePath.name).replaceAll(correctPaths(workspaceRoot), "").replaceAll(correctPaths(projectRoot), "")
|
|
978
|
+
);
|
|
979
|
+
if (result) {
|
|
980
|
+
writeDebug(
|
|
981
|
+
`Trying to add entry point ${result} at "${joinPaths(
|
|
982
|
+
filePath.path,
|
|
983
|
+
filePath.name
|
|
984
|
+
)}"`,
|
|
985
|
+
config
|
|
986
|
+
);
|
|
987
|
+
if (!paths.includes(result)) {
|
|
988
|
+
paths.push(result);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
return ret;
|
|
992
|
+
}, [])
|
|
993
|
+
);
|
|
994
|
+
} else {
|
|
995
|
+
writeDebug(`Trying to add entry point ${entryPoint}"`, config);
|
|
996
|
+
if (!paths.includes(entryPoint)) {
|
|
997
|
+
paths.push(entryPoint);
|
|
872
998
|
}
|
|
873
|
-
return ret;
|
|
874
|
-
}, []));
|
|
875
|
-
} else {
|
|
876
|
-
writeDebug(`Trying to add entry point ${entryPoint}"`, config);
|
|
877
|
-
if (!paths.includes(entryPoint)) {
|
|
878
|
-
paths.push(entryPoint);
|
|
879
999
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
1000
|
+
return paths;
|
|
1001
|
+
})
|
|
1002
|
+
);
|
|
883
1003
|
return results.filter(Boolean).reduce((ret, result) => {
|
|
884
1004
|
result.forEach((res) => {
|
|
885
1005
|
if (res && !ret.includes(res)) {
|
|
@@ -888,10 +1008,10 @@ var getEntryPoints = /* @__PURE__ */ __name(async (config, projectRoot, sourceRo
|
|
|
888
1008
|
});
|
|
889
1009
|
return ret;
|
|
890
1010
|
}, []);
|
|
891
|
-
}
|
|
1011
|
+
};
|
|
892
1012
|
|
|
893
1013
|
// ../build-tools/src/utilities/get-env.ts
|
|
894
|
-
var getEnv =
|
|
1014
|
+
var getEnv = (builder, options) => {
|
|
895
1015
|
return {
|
|
896
1016
|
STORM_BUILD: builder,
|
|
897
1017
|
STORM_ORG: options.orgName || DEFAULT_ORGANIZATION,
|
|
@@ -902,14 +1022,17 @@ var getEnv = /* @__PURE__ */ __name((builder, options) => {
|
|
|
902
1022
|
STORM_TARGET: JSON.stringify(options.target),
|
|
903
1023
|
...options.env
|
|
904
1024
|
};
|
|
905
|
-
}
|
|
1025
|
+
};
|
|
906
1026
|
|
|
907
1027
|
// ../build-tools/src/utilities/read-nx-config.ts
|
|
908
1028
|
import { existsSync as existsSync2 } from "node:fs";
|
|
909
1029
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
910
1030
|
|
|
911
1031
|
// ../build-tools/src/utilities/task-graph.ts
|
|
912
|
-
import {
|
|
1032
|
+
import {
|
|
1033
|
+
createTaskGraph,
|
|
1034
|
+
mapTargetDefaultsToDependencies
|
|
1035
|
+
} from "nx/src/tasks-runner/create-task-graph";
|
|
913
1036
|
|
|
914
1037
|
// src/build.ts
|
|
915
1038
|
import defu3 from "defu";
|
|
@@ -917,7 +1040,7 @@ import { existsSync as existsSync3 } from "node:fs";
|
|
|
917
1040
|
import hf from "node:fs/promises";
|
|
918
1041
|
import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
|
|
919
1042
|
import { build as tsdown } from "tsdown";
|
|
920
|
-
var resolveOptions =
|
|
1043
|
+
var resolveOptions = async (userOptions) => {
|
|
921
1044
|
const projectRoot = userOptions.projectRoot;
|
|
922
1045
|
const workspaceRoot = findWorkspaceRoot2(projectRoot);
|
|
923
1046
|
if (!workspaceRoot) {
|
|
@@ -929,7 +1052,11 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
|
|
|
929
1052
|
const projectGraph = await createProjectGraphAsync2({
|
|
930
1053
|
exitOnError: true
|
|
931
1054
|
});
|
|
932
|
-
const projectJsonPath = joinPaths(
|
|
1055
|
+
const projectJsonPath = joinPaths(
|
|
1056
|
+
workspaceRoot.dir,
|
|
1057
|
+
projectRoot,
|
|
1058
|
+
"project.json"
|
|
1059
|
+
);
|
|
933
1060
|
if (!existsSync3(projectJsonPath)) {
|
|
934
1061
|
throw new Error("Cannot find project.json configuration");
|
|
935
1062
|
}
|
|
@@ -938,12 +1065,18 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
|
|
|
938
1065
|
const projectName = projectJson.name;
|
|
939
1066
|
const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
|
|
940
1067
|
if (!projectConfigurations?.projects?.[projectName]) {
|
|
941
|
-
throw new Error(
|
|
1068
|
+
throw new Error(
|
|
1069
|
+
"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."
|
|
1070
|
+
);
|
|
942
1071
|
}
|
|
943
1072
|
const options = defu3(userOptions, DEFAULT_BUILD_OPTIONS);
|
|
944
1073
|
options.name ??= `${projectName}-${options.format}`;
|
|
945
1074
|
options.target ??= DEFAULT_TARGET;
|
|
946
|
-
const packageJsonPath = joinPaths(
|
|
1075
|
+
const packageJsonPath = joinPaths(
|
|
1076
|
+
workspaceRoot.dir,
|
|
1077
|
+
options.projectRoot,
|
|
1078
|
+
"package.json"
|
|
1079
|
+
);
|
|
947
1080
|
if (!existsSync3(packageJsonPath)) {
|
|
948
1081
|
throw new Error("Cannot find package.json configuration");
|
|
949
1082
|
}
|
|
@@ -952,11 +1085,18 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
|
|
|
952
1085
|
...options,
|
|
953
1086
|
config,
|
|
954
1087
|
...userOptions,
|
|
955
|
-
tsconfig: joinPaths(
|
|
1088
|
+
tsconfig: joinPaths(
|
|
1089
|
+
projectRoot,
|
|
1090
|
+
userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"
|
|
1091
|
+
),
|
|
956
1092
|
format: options.format || "cjs",
|
|
957
|
-
entryPoints: await getEntryPoints(
|
|
958
|
-
|
|
959
|
-
|
|
1093
|
+
entryPoints: await getEntryPoints(
|
|
1094
|
+
config,
|
|
1095
|
+
projectRoot,
|
|
1096
|
+
projectJson.sourceRoot,
|
|
1097
|
+
userOptions.entry || ["./src/index.ts"],
|
|
1098
|
+
userOptions.emitOnAll
|
|
1099
|
+
),
|
|
960
1100
|
outdir: userOptions.outputPath || joinPaths("dist", projectRoot),
|
|
961
1101
|
plugins: [],
|
|
962
1102
|
name: userOptions.name || projectName,
|
|
@@ -971,9 +1111,7 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
|
|
|
971
1111
|
generatePackageJson: userOptions.generatePackageJson !== false,
|
|
972
1112
|
clean: userOptions.clean !== false,
|
|
973
1113
|
emitOnAll: userOptions.emitOnAll === true,
|
|
974
|
-
dts: userOptions.dts === true ? {
|
|
975
|
-
transformer: "oxc"
|
|
976
|
-
} : userOptions.dts,
|
|
1114
|
+
dts: userOptions.dts === true ? { transformer: "oxc" } : userOptions.dts,
|
|
977
1115
|
bundleDts: userOptions.dts,
|
|
978
1116
|
assets: userOptions.assets ?? [],
|
|
979
1117
|
shims: userOptions.injectShims !== true,
|
|
@@ -997,7 +1135,7 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
|
|
|
997
1135
|
};
|
|
998
1136
|
stopwatch();
|
|
999
1137
|
return result;
|
|
1000
|
-
}
|
|
1138
|
+
};
|
|
1001
1139
|
async function generatePackageJson(options) {
|
|
1002
1140
|
if (options.generatePackageJson !== false && existsSync3(joinPaths(options.projectRoot, "package.json"))) {
|
|
1003
1141
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
@@ -1006,51 +1144,74 @@ async function generatePackageJson(options) {
|
|
|
1006
1144
|
if (!existsSync3(packageJsonPath)) {
|
|
1007
1145
|
throw new Error("Cannot find package.json configuration");
|
|
1008
1146
|
}
|
|
1009
|
-
const packageJsonFile = await hf.readFile(
|
|
1147
|
+
const packageJsonFile = await hf.readFile(
|
|
1148
|
+
joinPaths(
|
|
1149
|
+
options.config.workspaceRoot,
|
|
1150
|
+
options.projectRoot,
|
|
1151
|
+
"package.json"
|
|
1152
|
+
),
|
|
1153
|
+
"utf8"
|
|
1154
|
+
);
|
|
1010
1155
|
if (!packageJsonFile) {
|
|
1011
1156
|
throw new Error("Cannot find package.json configuration file");
|
|
1012
1157
|
}
|
|
1013
1158
|
let packageJson = JSON.parse(packageJsonFile);
|
|
1014
|
-
packageJson = await addPackageDependencies(
|
|
1015
|
-
|
|
1159
|
+
packageJson = await addPackageDependencies(
|
|
1160
|
+
options.config.workspaceRoot,
|
|
1161
|
+
options.projectRoot,
|
|
1162
|
+
options.projectName,
|
|
1163
|
+
packageJson
|
|
1164
|
+
);
|
|
1165
|
+
packageJson = await addWorkspacePackageJsonFields(
|
|
1166
|
+
options.config,
|
|
1167
|
+
options.projectRoot,
|
|
1168
|
+
options.sourceRoot,
|
|
1169
|
+
options.projectName,
|
|
1170
|
+
false,
|
|
1171
|
+
packageJson
|
|
1172
|
+
);
|
|
1016
1173
|
packageJson.exports ??= {};
|
|
1017
1174
|
packageJson.exports["./package.json"] ??= "./package.json";
|
|
1018
|
-
packageJson.exports["."] ??= addPackageJsonExport(
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
];
|
|
1175
|
+
packageJson.exports["."] ??= addPackageJsonExport(
|
|
1176
|
+
"index",
|
|
1177
|
+
packageJson.type,
|
|
1178
|
+
options.sourceRoot
|
|
1179
|
+
);
|
|
1180
|
+
let entryPoints = [{ in: "./src/index.ts", out: "./src/index.ts" }];
|
|
1025
1181
|
if (options.entryPoints) {
|
|
1026
1182
|
if (Array.isArray(options.entryPoints)) {
|
|
1027
|
-
entryPoints = options.entryPoints.map(
|
|
1028
|
-
in: entryPoint,
|
|
1029
|
-
|
|
1030
|
-
} : entryPoint);
|
|
1183
|
+
entryPoints = options.entryPoints.map(
|
|
1184
|
+
(entryPoint) => typeof entryPoint === "string" ? { in: entryPoint, out: entryPoint } : entryPoint
|
|
1185
|
+
);
|
|
1031
1186
|
}
|
|
1032
1187
|
for (const entryPoint of entryPoints) {
|
|
1033
1188
|
const split = entryPoint.out.split(".");
|
|
1034
1189
|
split.pop();
|
|
1035
1190
|
const entry = split.join(".").replaceAll("\\", "/");
|
|
1036
|
-
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(
|
|
1191
|
+
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(
|
|
1192
|
+
entry,
|
|
1193
|
+
packageJson.type,
|
|
1194
|
+
options.sourceRoot
|
|
1195
|
+
);
|
|
1037
1196
|
}
|
|
1038
1197
|
}
|
|
1039
1198
|
packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
|
|
1040
1199
|
packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
|
|
1041
1200
|
packageJson.types = "./dist/index.d.ts";
|
|
1042
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce(
|
|
1043
|
-
|
|
1044
|
-
ret[key.replace("/index", "")]
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1201
|
+
packageJson.exports = Object.keys(packageJson.exports).reduce(
|
|
1202
|
+
(ret, key) => {
|
|
1203
|
+
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
1204
|
+
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
1205
|
+
}
|
|
1206
|
+
return ret;
|
|
1207
|
+
},
|
|
1208
|
+
packageJson.exports
|
|
1209
|
+
);
|
|
1048
1210
|
await writeJsonFile(joinPaths(options.outdir, "package.json"), packageJson);
|
|
1049
1211
|
stopwatch();
|
|
1050
1212
|
}
|
|
1051
1213
|
return options;
|
|
1052
1214
|
}
|
|
1053
|
-
__name(generatePackageJson, "generatePackageJson");
|
|
1054
1215
|
async function executeTSDown(options) {
|
|
1055
1216
|
writeDebug(` \u{1F680} Running ${options.name} build`, options.config);
|
|
1056
1217
|
const stopwatch = getStopwatch(`${options.name} build`);
|
|
@@ -1063,60 +1224,78 @@ async function executeTSDown(options) {
|
|
|
1063
1224
|
stopwatch();
|
|
1064
1225
|
return options;
|
|
1065
1226
|
}
|
|
1066
|
-
__name(executeTSDown, "executeTSDown");
|
|
1067
1227
|
async function copyBuildAssets(options) {
|
|
1068
|
-
writeDebug(
|
|
1228
|
+
writeDebug(
|
|
1229
|
+
` \u{1F4CB} Copying asset files to output directory: ${options.outdir}`,
|
|
1230
|
+
options.config
|
|
1231
|
+
);
|
|
1069
1232
|
const stopwatch = getStopwatch(`${options.name} asset copy`);
|
|
1070
|
-
await copyAssets(
|
|
1233
|
+
await copyAssets(
|
|
1234
|
+
options.config,
|
|
1235
|
+
options.assets ?? [],
|
|
1236
|
+
options.outdir,
|
|
1237
|
+
options.projectRoot,
|
|
1238
|
+
options.sourceRoot,
|
|
1239
|
+
true,
|
|
1240
|
+
false
|
|
1241
|
+
);
|
|
1071
1242
|
stopwatch();
|
|
1072
1243
|
return options;
|
|
1073
1244
|
}
|
|
1074
|
-
__name(copyBuildAssets, "copyBuildAssets");
|
|
1075
1245
|
async function reportResults(options) {
|
|
1076
|
-
writeSuccess(
|
|
1246
|
+
writeSuccess(
|
|
1247
|
+
` \u{1F4E6} The ${options.name} build completed successfully`,
|
|
1248
|
+
options.config
|
|
1249
|
+
);
|
|
1077
1250
|
}
|
|
1078
|
-
__name(reportResults, "reportResults");
|
|
1079
1251
|
async function cleanOutputPath(options) {
|
|
1080
1252
|
if (options.clean !== false && options.outdir) {
|
|
1081
|
-
writeDebug(
|
|
1253
|
+
writeDebug(
|
|
1254
|
+
` \u{1F9F9} Cleaning ${options.name} output path: ${options.outdir}`,
|
|
1255
|
+
options.config
|
|
1256
|
+
);
|
|
1082
1257
|
const stopwatch = getStopwatch(`${options.name} output clean`);
|
|
1083
1258
|
await cleanDirectories(options.name, options.outdir, options.config);
|
|
1084
1259
|
stopwatch();
|
|
1085
1260
|
}
|
|
1086
1261
|
return options;
|
|
1087
1262
|
}
|
|
1088
|
-
__name(cleanOutputPath, "cleanOutputPath");
|
|
1089
1263
|
async function build(options) {
|
|
1090
1264
|
writeDebug(` \u26A1 Executing Storm TSDown pipeline`);
|
|
1091
1265
|
const stopwatch = getStopwatch("TSDown pipeline");
|
|
1092
1266
|
try {
|
|
1093
|
-
const opts = Array.isArray(options) ? options : [
|
|
1094
|
-
options
|
|
1095
|
-
];
|
|
1267
|
+
const opts = Array.isArray(options) ? options : [options];
|
|
1096
1268
|
if (opts.length === 0) {
|
|
1097
1269
|
throw new Error("No build options were provided");
|
|
1098
1270
|
}
|
|
1099
|
-
const resolved = await Promise.all(
|
|
1271
|
+
const resolved = await Promise.all(
|
|
1272
|
+
opts.map(async (opt) => await resolveOptions(opt))
|
|
1273
|
+
);
|
|
1100
1274
|
if (resolved.length > 0) {
|
|
1101
1275
|
await cleanOutputPath(resolved[0]);
|
|
1102
1276
|
await generatePackageJson(resolved[0]);
|
|
1103
|
-
await Promise.all(
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1277
|
+
await Promise.all(
|
|
1278
|
+
resolved.map(async (opt) => {
|
|
1279
|
+
await executeTSDown(opt);
|
|
1280
|
+
await copyBuildAssets(opt);
|
|
1281
|
+
await reportResults(opt);
|
|
1282
|
+
})
|
|
1283
|
+
);
|
|
1108
1284
|
} else {
|
|
1109
|
-
writeWarning(
|
|
1285
|
+
writeWarning(
|
|
1286
|
+
" \u{1F6A7} No options were passed to TSBuild. Please check the parameters passed to the `build` function."
|
|
1287
|
+
);
|
|
1110
1288
|
}
|
|
1111
1289
|
writeSuccess(" \u{1F3C1} TSDown pipeline build completed successfully");
|
|
1112
1290
|
} catch (error) {
|
|
1113
|
-
writeFatal(
|
|
1291
|
+
writeFatal(
|
|
1292
|
+
"Fatal errors that the build process could not recover from have occured. The build process has been terminated."
|
|
1293
|
+
);
|
|
1114
1294
|
throw error;
|
|
1115
1295
|
} finally {
|
|
1116
1296
|
stopwatch();
|
|
1117
1297
|
}
|
|
1118
1298
|
}
|
|
1119
|
-
__name(build, "build");
|
|
1120
1299
|
|
|
1121
1300
|
export {
|
|
1122
1301
|
cleanOutputPath,
|