@storm-software/terraform-tools 0.66.269 → 0.66.272
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/CHANGELOG.md +40 -0
- package/README.md +1 -1
- package/dist/{chunk-BOLIQGHH.js → chunk-3PPOJGPM.js} +2 -2
- package/dist/{chunk-SVHLNLWI.js → chunk-6XRBUSRZ.js} +2 -2
- package/dist/{chunk-PPWYTBXH.js → chunk-7SJNXGGY.js} +2 -2
- package/dist/{chunk-MH7PQUPL.mjs → chunk-BTFCJA4P.mjs} +1 -1
- package/dist/{chunk-7GR34ULJ.mjs → chunk-DWFH4BRZ.mjs} +1 -1
- package/dist/{chunk-ABYTODGS.mjs → chunk-F3NMHTBD.mjs} +0 -1
- package/dist/{chunk-A6WNSDR7.js → chunk-FUIR6CV3.js} +1 -2
- package/dist/{chunk-QQOA6GG4.js → chunk-LIBELAPY.js} +2 -2
- package/dist/{chunk-NEH3N2A3.mjs → chunk-RN7QGFQC.mjs} +1 -1
- package/dist/{chunk-P4PQWAMH.mjs → chunk-SU4DPIOS.mjs} +1 -1
- package/dist/{chunk-TJMO7T74.js → chunk-T7VMRGBY.js} +630 -1025
- package/dist/{chunk-BGDEJKQP.js → chunk-TL7BE6RW.js} +2 -2
- package/dist/{chunk-LITP5RJ4.mjs → chunk-W3GP53VK.mjs} +1 -1
- package/dist/{chunk-G7C6GYSO.mjs → chunk-Y46WRPCF.mjs} +407 -802
- package/dist/{chunk-VEA5XEHB.mjs → chunk-ZAQLCGRJ.mjs} +1 -1
- package/dist/executors.d.mts +0 -1
- package/dist/executors.d.ts +0 -1
- package/dist/executors.js +6 -6
- package/dist/executors.mjs +7 -7
- package/dist/generators.js +3 -3
- package/dist/generators.mjs +3 -3
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +8 -8
- package/dist/index.mjs +8 -8
- package/dist/src/base/base-terraform-executor.untyped.mjs +1 -1
- package/dist/src/base/index.d.mts +0 -1
- package/dist/src/base/index.d.ts +0 -1
- package/dist/src/base/index.js +3 -3
- package/dist/src/base/index.mjs +3 -3
- package/dist/src/base/terraform-executor.d.mts +1 -2
- package/dist/src/base/terraform-executor.d.ts +1 -2
- package/dist/src/base/terraform-executor.js +3 -3
- package/dist/src/base/terraform-executor.mjs +3 -3
- package/dist/src/executors/apply/executor.d.mts +0 -1
- package/dist/src/executors/apply/executor.d.ts +0 -1
- package/dist/src/executors/apply/executor.js +4 -4
- package/dist/src/executors/apply/executor.mjs +4 -4
- package/dist/src/executors/destroy/executor.d.mts +0 -1
- package/dist/src/executors/destroy/executor.d.ts +0 -1
- package/dist/src/executors/destroy/executor.js +4 -4
- package/dist/src/executors/destroy/executor.mjs +4 -4
- package/dist/src/executors/output/executor.js +4 -4
- package/dist/src/executors/output/executor.mjs +4 -4
- package/dist/src/executors/plan/executor.d.mts +0 -1
- package/dist/src/executors/plan/executor.d.ts +0 -1
- package/dist/src/executors/plan/executor.js +4 -4
- package/dist/src/executors/plan/executor.mjs +4 -4
- package/dist/src/generators/init/init.js +3 -3
- package/dist/src/generators/init/init.mjs +3 -3
- package/dist/tsup.config.mjs +1 -1
- package/package.json +5 -5
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
brandIcon,
|
|
5
5
|
correctPaths,
|
|
6
6
|
findWorkspaceRoot,
|
|
7
|
-
formatLogMessage,
|
|
8
7
|
getConfig,
|
|
9
8
|
getStopwatch,
|
|
10
9
|
getWorkspaceConfig,
|
|
@@ -21,10 +20,10 @@ import {
|
|
|
21
20
|
writeSuccess,
|
|
22
21
|
writeTrace,
|
|
23
22
|
writeWarning
|
|
24
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-F3NMHTBD.mjs";
|
|
25
24
|
import {
|
|
26
25
|
__dirname
|
|
27
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-DWFH4BRZ.mjs";
|
|
28
27
|
|
|
29
28
|
// src/generators/init/init.ts
|
|
30
29
|
import { formatFiles as formatFiles8 } from "@nx/devkit";
|
|
@@ -284,702 +283,8 @@ import { readFileSync as readFileSync2 } from "node:fs";
|
|
|
284
283
|
import https from "node:https";
|
|
285
284
|
var LARGE_BUFFER = 1024 * 1e6;
|
|
286
285
|
|
|
287
|
-
// ../build-tools/src/config.ts
|
|
288
|
-
var DEFAULT_JS_BANNER = `
|
|
289
|
-
// ---------------------------------------
|
|
290
|
-
// \u{1F5F2} Built by Storm Software
|
|
291
|
-
// ---------------------------------------
|
|
292
|
-
`;
|
|
293
|
-
var DEFAULT_CSS_BANNER = `
|
|
294
|
-
/* ---------------------------------------
|
|
295
|
-
\u{1F5F2} Built by Storm Software
|
|
296
|
-
--------------------------------------- */
|
|
297
|
-
`;
|
|
298
|
-
var DEFAULT_ENVIRONMENT = "production";
|
|
299
|
-
var DEFAULT_TARGET = "esnext";
|
|
300
|
-
var DEFAULT_ORGANIZATION = "storm-software";
|
|
301
|
-
|
|
302
|
-
// ../build-tools/src/plugins/swc.ts
|
|
303
|
-
import { transform } from "@swc/core";
|
|
304
|
-
|
|
305
|
-
// ../build-tools/src/plugins/ts-resolve.ts
|
|
306
|
-
import fs from "node:fs";
|
|
307
|
-
import { builtinModules } from "node:module";
|
|
308
|
-
import path from "node:path";
|
|
309
|
-
import _resolve from "resolve";
|
|
310
|
-
|
|
311
|
-
// ../build-tools/src/plugins/type-definitions.ts
|
|
312
|
-
import { stripIndents } from "@nx/devkit";
|
|
313
|
-
import { relative as relative3 } from "path";
|
|
314
|
-
|
|
315
|
-
// ../build-tools/src/utilities/copy-assets.ts
|
|
316
|
-
import { CopyAssetsHandler } from "@nx/js/internal";
|
|
317
|
-
import { glob } from "glob";
|
|
318
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
319
|
-
var copyAssets = async (config, assets, outputPath, projectRoot, sourceRoot, generatePackageJson3 = true, includeSrc = false, banner, footer) => {
|
|
320
|
-
const pendingAssets = Array.from(assets ?? []);
|
|
321
|
-
pendingAssets.push({
|
|
322
|
-
input: projectRoot,
|
|
323
|
-
glob: "*.md",
|
|
324
|
-
output: "."
|
|
325
|
-
});
|
|
326
|
-
pendingAssets.push({
|
|
327
|
-
input: ".",
|
|
328
|
-
glob: "LICENSE",
|
|
329
|
-
output: "."
|
|
330
|
-
});
|
|
331
|
-
if (generatePackageJson3 === false) {
|
|
332
|
-
pendingAssets.push({
|
|
333
|
-
input: projectRoot,
|
|
334
|
-
glob: "package.json",
|
|
335
|
-
output: "."
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
if (includeSrc === true) {
|
|
339
|
-
pendingAssets.push({
|
|
340
|
-
input: sourceRoot,
|
|
341
|
-
glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
|
|
342
|
-
output: "src/"
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
writeTrace(
|
|
346
|
-
`\u{1F4DD} Copying the following assets to the output directory:
|
|
347
|
-
${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`,
|
|
348
|
-
config
|
|
349
|
-
);
|
|
350
|
-
const assetHandler = new CopyAssetsHandler({
|
|
351
|
-
projectDir: projectRoot,
|
|
352
|
-
rootDir: config.workspaceRoot,
|
|
353
|
-
outputDir: outputPath,
|
|
354
|
-
assets: pendingAssets
|
|
355
|
-
});
|
|
356
|
-
await assetHandler.processAllAssetsOnce();
|
|
357
|
-
writeTrace("Completed copying assets to the output directory", config);
|
|
358
|
-
if (includeSrc === true) {
|
|
359
|
-
writeDebug(
|
|
360
|
-
`\u{1F4DD} Adding banner and writing source files: ${joinPaths(
|
|
361
|
-
outputPath,
|
|
362
|
-
"src"
|
|
363
|
-
)}`,
|
|
364
|
-
config
|
|
365
|
-
);
|
|
366
|
-
const files = await glob([
|
|
367
|
-
joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
|
|
368
|
-
joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
|
|
369
|
-
joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
370
|
-
joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
371
|
-
]);
|
|
372
|
-
await Promise.allSettled(
|
|
373
|
-
files.map(
|
|
374
|
-
async (file) => writeFile(
|
|
375
|
-
file,
|
|
376
|
-
`${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
377
|
-
|
|
378
|
-
${await readFile(file, "utf8")}
|
|
379
|
-
|
|
380
|
-
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`
|
|
381
|
-
)
|
|
382
|
-
)
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
// ../build-tools/src/utilities/generate-package-json.ts
|
|
388
|
-
import { calculateProjectBuildableDependencies } from "@nx/js/internal";
|
|
389
|
-
import { Glob } from "glob";
|
|
390
|
-
import { existsSync, readFileSync as readFileSync3 } from "node:fs";
|
|
391
|
-
import { readFile as readFile2 } from "node:fs/promises";
|
|
392
|
-
import {
|
|
393
|
-
createProjectGraphAsync,
|
|
394
|
-
readCachedProjectGraph,
|
|
395
|
-
readProjectsConfigurationFromProjectGraph
|
|
396
|
-
} from "nx/src/project-graph/project-graph";
|
|
397
|
-
var addPackageDependencies = async (workspaceRoot2, projectRoot, projectName, packageJson) => {
|
|
398
|
-
let projectGraph;
|
|
399
|
-
try {
|
|
400
|
-
projectGraph = readCachedProjectGraph();
|
|
401
|
-
} catch {
|
|
402
|
-
await createProjectGraphAsync();
|
|
403
|
-
projectGraph = readCachedProjectGraph();
|
|
404
|
-
}
|
|
405
|
-
if (!projectGraph) {
|
|
406
|
-
throw new Error(
|
|
407
|
-
"The Build process failed because the project graph is not available. Please run the build command again."
|
|
408
|
-
);
|
|
409
|
-
}
|
|
410
|
-
const projectDependencies = calculateProjectBuildableDependencies(
|
|
411
|
-
void 0,
|
|
412
|
-
projectGraph,
|
|
413
|
-
workspaceRoot2,
|
|
414
|
-
projectName,
|
|
415
|
-
process.env.NX_TASK_TARGET_TARGET || "build",
|
|
416
|
-
process.env.NX_TASK_TARGET_CONFIGURATION || "production",
|
|
417
|
-
true
|
|
418
|
-
);
|
|
419
|
-
const localPackages = [];
|
|
420
|
-
for (const project of projectDependencies.dependencies.filter(
|
|
421
|
-
(dep) => dep.node.type === "lib" && dep.node.data?.root !== projectRoot && dep.node.data?.root !== workspaceRoot2
|
|
422
|
-
)) {
|
|
423
|
-
const projectNode = project.node;
|
|
424
|
-
if (projectNode.data.root) {
|
|
425
|
-
const projectPackageJsonPath = joinPaths(
|
|
426
|
-
workspaceRoot2,
|
|
427
|
-
projectNode.data.root,
|
|
428
|
-
"package.json"
|
|
429
|
-
);
|
|
430
|
-
if (existsSync(projectPackageJsonPath)) {
|
|
431
|
-
const projectPackageJsonContent = await readFile2(
|
|
432
|
-
projectPackageJsonPath,
|
|
433
|
-
"utf8"
|
|
434
|
-
);
|
|
435
|
-
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
436
|
-
if (projectPackageJson.private !== true) {
|
|
437
|
-
localPackages.push(projectPackageJson);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
if (localPackages.length > 0) {
|
|
443
|
-
writeTrace(
|
|
444
|
-
`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`
|
|
445
|
-
);
|
|
446
|
-
const projectJsonFile = await readFile2(
|
|
447
|
-
joinPaths(projectRoot, "project.json"),
|
|
448
|
-
"utf8"
|
|
449
|
-
);
|
|
450
|
-
const projectJson = JSON.parse(projectJsonFile);
|
|
451
|
-
const projectName2 = projectJson.name;
|
|
452
|
-
const projectConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
453
|
-
if (!projectConfigurations?.projects?.[projectName2]) {
|
|
454
|
-
throw new Error(
|
|
455
|
-
"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."
|
|
456
|
-
);
|
|
457
|
-
}
|
|
458
|
-
const implicitDependencies = projectConfigurations.projects?.[projectName2].implicitDependencies?.reduce((ret, dep) => {
|
|
459
|
-
if (projectConfigurations.projects?.[dep]) {
|
|
460
|
-
const depPackageJsonPath = joinPaths(
|
|
461
|
-
workspaceRoot2,
|
|
462
|
-
projectConfigurations.projects[dep].root,
|
|
463
|
-
"package.json"
|
|
464
|
-
);
|
|
465
|
-
if (existsSync(depPackageJsonPath)) {
|
|
466
|
-
const depPackageJsonContent = readFileSync3(
|
|
467
|
-
depPackageJsonPath,
|
|
468
|
-
"utf8"
|
|
469
|
-
);
|
|
470
|
-
const depPackageJson = JSON.parse(depPackageJsonContent);
|
|
471
|
-
if (depPackageJson.private !== true && !ret.includes(depPackageJson.name)) {
|
|
472
|
-
ret.push(depPackageJson.name);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
return ret;
|
|
477
|
-
}, []);
|
|
478
|
-
packageJson.dependencies = localPackages.reduce((ret, localPackage) => {
|
|
479
|
-
if (!ret[localPackage.name] && !implicitDependencies?.includes(localPackage.name) && packageJson.devDependencies?.[localPackage.name] === void 0) {
|
|
480
|
-
ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
|
|
481
|
-
}
|
|
482
|
-
return ret;
|
|
483
|
-
}, packageJson.dependencies ?? {});
|
|
484
|
-
packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
|
|
485
|
-
if (!ret[localPackage.name] && implicitDependencies?.includes(localPackage.name) && packageJson.dependencies?.[localPackage.name] === void 0) {
|
|
486
|
-
ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
|
|
487
|
-
}
|
|
488
|
-
return ret;
|
|
489
|
-
}, packageJson.devDependencies ?? {});
|
|
490
|
-
} else {
|
|
491
|
-
writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
|
|
492
|
-
}
|
|
493
|
-
return packageJson;
|
|
494
|
-
};
|
|
495
|
-
var addWorkspacePackageJsonFields = async (workspaceConfig, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
496
|
-
const workspaceRoot2 = workspaceConfig.workspaceRoot ? workspaceConfig.workspaceRoot : findWorkspaceRoot();
|
|
497
|
-
const workspacePackageJsonContent = await readFile2(
|
|
498
|
-
joinPaths(workspaceRoot2, "package.json"),
|
|
499
|
-
"utf8"
|
|
500
|
-
);
|
|
501
|
-
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
502
|
-
packageJson.type ??= "module";
|
|
503
|
-
packageJson.sideEffects ??= false;
|
|
504
|
-
if (includeSrc === true) {
|
|
505
|
-
let distSrc = sourceRoot.replace(projectRoot, "");
|
|
506
|
-
if (distSrc.startsWith("/")) {
|
|
507
|
-
distSrc = distSrc.substring(1);
|
|
508
|
-
}
|
|
509
|
-
packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
|
|
510
|
-
}
|
|
511
|
-
packageJson.files ??= ["dist/**/*"];
|
|
512
|
-
if (includeSrc === true && !packageJson.files.includes("src")) {
|
|
513
|
-
packageJson.files.push("src/**/*");
|
|
514
|
-
}
|
|
515
|
-
packageJson.publishConfig ??= {
|
|
516
|
-
access: "public"
|
|
517
|
-
};
|
|
518
|
-
packageJson.description ??= workspacePackageJson.description;
|
|
519
|
-
packageJson.homepage ??= workspacePackageJson.homepage;
|
|
520
|
-
packageJson.bugs ??= workspacePackageJson.bugs;
|
|
521
|
-
packageJson.license ??= workspacePackageJson.license;
|
|
522
|
-
packageJson.keywords ??= workspacePackageJson.keywords;
|
|
523
|
-
packageJson.funding ??= workspacePackageJson.funding;
|
|
524
|
-
packageJson.author ??= workspacePackageJson.author;
|
|
525
|
-
packageJson.maintainers ??= workspacePackageJson.maintainers;
|
|
526
|
-
if (!packageJson.maintainers && packageJson.author) {
|
|
527
|
-
packageJson.maintainers = [packageJson.author];
|
|
528
|
-
}
|
|
529
|
-
packageJson.contributors ??= workspacePackageJson.contributors;
|
|
530
|
-
if (!packageJson.contributors && packageJson.author) {
|
|
531
|
-
packageJson.contributors = [packageJson.author];
|
|
532
|
-
}
|
|
533
|
-
packageJson.repository ??= workspacePackageJson.repository;
|
|
534
|
-
packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
|
|
535
|
-
return packageJson;
|
|
536
|
-
};
|
|
537
|
-
var addPackageJsonExport = (file, type = "module", sourceRoot) => {
|
|
538
|
-
let entry = file.replaceAll("\\", "/");
|
|
539
|
-
if (sourceRoot) {
|
|
540
|
-
entry = entry.replace(sourceRoot, "");
|
|
541
|
-
}
|
|
542
|
-
return {
|
|
543
|
-
import: {
|
|
544
|
-
types: `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
|
|
545
|
-
default: `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
|
|
546
|
-
},
|
|
547
|
-
require: {
|
|
548
|
-
types: `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
|
|
549
|
-
default: `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
|
|
550
|
-
},
|
|
551
|
-
default: {
|
|
552
|
-
types: `./dist/${entry}.d.${type !== "fixed" ? "ts" : "mts"}`,
|
|
553
|
-
default: `./dist/${entry}.${type !== "fixed" ? "js" : "mjs"}`
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
// ../build-tools/src/utilities/get-entry-points.ts
|
|
559
|
-
import { glob as glob2 } from "glob";
|
|
560
|
-
|
|
561
|
-
// ../build-tools/src/utilities/get-env.ts
|
|
562
|
-
var getEnv = (builder, options) => {
|
|
563
|
-
return {
|
|
564
|
-
STORM_BUILD: builder,
|
|
565
|
-
STORM_ORG: options.orgName || DEFAULT_ORGANIZATION,
|
|
566
|
-
STORM_NAME: options.name,
|
|
567
|
-
STORM_MODE: options.mode || DEFAULT_ENVIRONMENT,
|
|
568
|
-
STORM_PLATFORM: options.platform,
|
|
569
|
-
STORM_FORMAT: JSON.stringify(options.format),
|
|
570
|
-
STORM_TARGET: JSON.stringify(options.target),
|
|
571
|
-
...options.env
|
|
572
|
-
};
|
|
573
|
-
};
|
|
574
|
-
|
|
575
|
-
// ../build-tools/src/utilities/read-nx-config.ts
|
|
576
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
577
|
-
import { readFile as readFile3 } from "node:fs/promises";
|
|
578
|
-
|
|
579
|
-
// ../build-tools/src/utilities/task-graph.ts
|
|
580
|
-
import {
|
|
581
|
-
createTaskGraph,
|
|
582
|
-
mapTargetDefaultsToDependencies
|
|
583
|
-
} from "nx/src/tasks-runner/create-task-graph";
|
|
584
|
-
|
|
585
|
-
// ../esbuild/src/assets.ts
|
|
586
|
-
async function copyBuildAssets(context) {
|
|
587
|
-
if (!context.result?.errors.length && context.options.assets?.length) {
|
|
588
|
-
writeDebug(
|
|
589
|
-
` \u{1F4CB} Copying ${context.options.assets.length} asset files to output directory: ${context.outputPath}`,
|
|
590
|
-
context.workspaceConfig
|
|
591
|
-
);
|
|
592
|
-
const stopwatch = getStopwatch(`${context.options.name} asset copy`);
|
|
593
|
-
await copyAssets(
|
|
594
|
-
context.workspaceConfig,
|
|
595
|
-
context.options.assets ?? [],
|
|
596
|
-
context.outputPath,
|
|
597
|
-
context.options.projectRoot,
|
|
598
|
-
context.sourceRoot,
|
|
599
|
-
true,
|
|
600
|
-
false
|
|
601
|
-
);
|
|
602
|
-
stopwatch();
|
|
603
|
-
}
|
|
604
|
-
return context;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
// ../esbuild/src/clean.ts
|
|
608
|
-
import { rm } from "node:fs/promises";
|
|
609
|
-
async function cleanDirectories(directory) {
|
|
610
|
-
await rm(directory, { recursive: true, force: true });
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
// ../esbuild/src/context.ts
|
|
614
|
-
import {
|
|
615
|
-
createProjectGraphAsync as createProjectGraphAsync2,
|
|
616
|
-
readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph2
|
|
617
|
-
} from "@nx/devkit";
|
|
618
|
-
import defu from "defu";
|
|
619
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
620
|
-
import hf from "node:fs/promises";
|
|
621
|
-
import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
|
|
622
|
-
|
|
623
|
-
// ../esbuild/src/config.ts
|
|
624
|
-
var DEFAULT_BUILD_OPTIONS = {
|
|
625
|
-
platform: "node",
|
|
626
|
-
target: "node22",
|
|
627
|
-
format: "esm",
|
|
628
|
-
mode: "production",
|
|
629
|
-
generatePackageJson: true,
|
|
630
|
-
includeSrc: false,
|
|
631
|
-
keepNames: true,
|
|
632
|
-
metafile: false,
|
|
633
|
-
treeshake: true,
|
|
634
|
-
splitting: true,
|
|
635
|
-
shims: false,
|
|
636
|
-
watch: false,
|
|
637
|
-
bundle: true,
|
|
638
|
-
distDir: "dist",
|
|
639
|
-
loader: {
|
|
640
|
-
".aac": "file",
|
|
641
|
-
".css": "file",
|
|
642
|
-
".eot": "file",
|
|
643
|
-
".flac": "file",
|
|
644
|
-
".gif": "file",
|
|
645
|
-
".jpeg": "file",
|
|
646
|
-
".jpg": "file",
|
|
647
|
-
".mp3": "file",
|
|
648
|
-
".mp4": "file",
|
|
649
|
-
".ogg": "file",
|
|
650
|
-
".otf": "file",
|
|
651
|
-
".png": "file",
|
|
652
|
-
".svg": "file",
|
|
653
|
-
".ttf": "file",
|
|
654
|
-
".wav": "file",
|
|
655
|
-
".webm": "file",
|
|
656
|
-
".webp": "file",
|
|
657
|
-
".woff": "file",
|
|
658
|
-
".woff2": "file"
|
|
659
|
-
},
|
|
660
|
-
banner: {
|
|
661
|
-
js: DEFAULT_JS_BANNER,
|
|
662
|
-
css: DEFAULT_CSS_BANNER
|
|
663
|
-
}
|
|
664
|
-
};
|
|
665
|
-
|
|
666
|
-
// ../esbuild/src/context.ts
|
|
667
|
-
async function resolveContext(userOptions) {
|
|
668
|
-
const projectRoot = userOptions.projectRoot;
|
|
669
|
-
const workspaceRoot2 = findWorkspaceRoot2(projectRoot);
|
|
670
|
-
if (!workspaceRoot2) {
|
|
671
|
-
throw new Error("Cannot find Nx workspace root");
|
|
672
|
-
}
|
|
673
|
-
const workspaceConfig = await getWorkspaceConfig(true, {
|
|
674
|
-
workspaceRoot: workspaceRoot2.dir
|
|
675
|
-
});
|
|
676
|
-
writeDebug(" \u2699\uFE0F Resolving build options", workspaceConfig);
|
|
677
|
-
const stopwatch = getStopwatch("Build options resolution");
|
|
678
|
-
const projectGraph = await createProjectGraphAsync2({
|
|
679
|
-
exitOnError: true
|
|
680
|
-
});
|
|
681
|
-
const projectJsonPath = joinPaths(
|
|
682
|
-
workspaceRoot2.dir,
|
|
683
|
-
projectRoot,
|
|
684
|
-
"project.json"
|
|
685
|
-
);
|
|
686
|
-
if (!existsSync3(projectJsonPath)) {
|
|
687
|
-
throw new Error("Cannot find project.json configuration");
|
|
688
|
-
}
|
|
689
|
-
const projectJsonFile = await hf.readFile(projectJsonPath, "utf8");
|
|
690
|
-
const projectJson = JSON.parse(projectJsonFile);
|
|
691
|
-
const projectName = projectJson.name || userOptions.name;
|
|
692
|
-
const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
|
|
693
|
-
if (!projectConfigurations?.projects?.[projectName]) {
|
|
694
|
-
throw new Error(
|
|
695
|
-
"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."
|
|
696
|
-
);
|
|
697
|
-
}
|
|
698
|
-
const options = defu(userOptions, DEFAULT_BUILD_OPTIONS);
|
|
699
|
-
options.name ??= projectName;
|
|
700
|
-
const packageJsonPath = joinPaths(
|
|
701
|
-
workspaceRoot2.dir,
|
|
702
|
-
options.projectRoot,
|
|
703
|
-
"package.json"
|
|
704
|
-
);
|
|
705
|
-
if (!existsSync3(packageJsonPath)) {
|
|
706
|
-
throw new Error("Cannot find package.json configuration");
|
|
707
|
-
}
|
|
708
|
-
const env = getEnv("esbuild", options);
|
|
709
|
-
const define = defu(options.define ?? {}, env ?? {});
|
|
710
|
-
const resolvedOptions = {
|
|
711
|
-
...options,
|
|
712
|
-
tsconfig: userOptions.tsconfig === null ? void 0 : userOptions.tsconfig ? userOptions.tsconfig : joinPaths(workspaceRoot2.dir, projectRoot, "tsconfig.json"),
|
|
713
|
-
metafile: userOptions.mode === "development",
|
|
714
|
-
clean: false,
|
|
715
|
-
env,
|
|
716
|
-
define: {
|
|
717
|
-
STORM_FORMAT: JSON.stringify(options.format),
|
|
718
|
-
...Object.keys(define).filter((key) => define[key] !== void 0).reduce((res, key) => {
|
|
719
|
-
const value = JSON.stringify(define[key]);
|
|
720
|
-
const safeKey = key.replaceAll("(", "").replaceAll(")", "");
|
|
721
|
-
return {
|
|
722
|
-
...res,
|
|
723
|
-
[`process.env.${safeKey}`]: value,
|
|
724
|
-
[`import.meta.env.${safeKey}`]: value
|
|
725
|
-
};
|
|
726
|
-
}, {})
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
stopwatch();
|
|
730
|
-
const context = {
|
|
731
|
-
options: resolvedOptions,
|
|
732
|
-
clean: userOptions.clean !== false,
|
|
733
|
-
workspaceConfig,
|
|
734
|
-
projectConfigurations,
|
|
735
|
-
projectName,
|
|
736
|
-
projectGraph,
|
|
737
|
-
sourceRoot: resolvedOptions.sourceRoot || projectJson.sourceRoot || joinPaths(resolvedOptions.projectRoot, "src"),
|
|
738
|
-
outputPath: resolvedOptions.outputPath || joinPaths(
|
|
739
|
-
workspaceConfig.workspaceRoot,
|
|
740
|
-
"dist",
|
|
741
|
-
resolvedOptions.projectRoot
|
|
742
|
-
),
|
|
743
|
-
minify: resolvedOptions.minify || resolvedOptions.mode === "production"
|
|
744
|
-
};
|
|
745
|
-
context.options.esbuildPlugins = [...context.options.esbuildPlugins ?? []];
|
|
746
|
-
if (context.options.verbose) {
|
|
747
|
-
writeDebug(
|
|
748
|
-
` \u2699\uFE0F Build options resolved:
|
|
749
|
-
|
|
750
|
-
${formatLogMessage(context.options)}`,
|
|
751
|
-
workspaceConfig
|
|
752
|
-
);
|
|
753
|
-
}
|
|
754
|
-
return context;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// ../esbuild/src/package-json.ts
|
|
758
|
-
import { writeJsonFile } from "@nx/devkit";
|
|
759
|
-
import { existsSync as existsSync4 } from "node:fs";
|
|
760
|
-
import hf2 from "node:fs/promises";
|
|
761
|
-
async function generatePackageJson(context) {
|
|
762
|
-
if (context.options.generatePackageJson !== false && existsSync4(joinPaths(context.options.projectRoot, "package.json"))) {
|
|
763
|
-
writeDebug(" \u270D\uFE0F Writing package.json file", context.workspaceConfig);
|
|
764
|
-
const stopwatch = getStopwatch("Write package.json file");
|
|
765
|
-
const packageJsonPath = joinPaths(
|
|
766
|
-
context.options.projectRoot,
|
|
767
|
-
"project.json"
|
|
768
|
-
);
|
|
769
|
-
if (!existsSync4(packageJsonPath)) {
|
|
770
|
-
throw new Error("Cannot find package.json configuration");
|
|
771
|
-
}
|
|
772
|
-
const packageJsonFile = await hf2.readFile(
|
|
773
|
-
joinPaths(
|
|
774
|
-
context.workspaceConfig.workspaceRoot,
|
|
775
|
-
context.options.projectRoot,
|
|
776
|
-
"package.json"
|
|
777
|
-
),
|
|
778
|
-
"utf8"
|
|
779
|
-
);
|
|
780
|
-
let packageJson = JSON.parse(packageJsonFile);
|
|
781
|
-
if (!packageJson) {
|
|
782
|
-
throw new Error("Cannot find package.json configuration file");
|
|
783
|
-
}
|
|
784
|
-
packageJson = await addPackageDependencies(
|
|
785
|
-
context.workspaceConfig.workspaceRoot,
|
|
786
|
-
context.options.projectRoot,
|
|
787
|
-
context.projectName,
|
|
788
|
-
packageJson
|
|
789
|
-
);
|
|
790
|
-
packageJson = await addWorkspacePackageJsonFields(
|
|
791
|
-
context.workspaceConfig,
|
|
792
|
-
context.options.projectRoot,
|
|
793
|
-
context.sourceRoot,
|
|
794
|
-
context.projectName,
|
|
795
|
-
false,
|
|
796
|
-
packageJson
|
|
797
|
-
);
|
|
798
|
-
if (context.options.entry) {
|
|
799
|
-
packageJson.exports ??= {};
|
|
800
|
-
packageJson.exports["./package.json"] ??= "./package.json";
|
|
801
|
-
const entryPoints = Array.isArray(context.options.entry) ? context.options.entry : Object.keys(context.options.entry);
|
|
802
|
-
if (entryPoints.length > 0) {
|
|
803
|
-
const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
|
|
804
|
-
const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
|
|
805
|
-
const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
|
|
806
|
-
const isDts = context.options.dts || context.options.experimentalDts;
|
|
807
|
-
packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
|
|
808
|
-
for (const entryPoint of entryPoints) {
|
|
809
|
-
packageJson.exports[`./${entryPoint}`] ??= {};
|
|
810
|
-
if (isEsm) {
|
|
811
|
-
if (isDts) {
|
|
812
|
-
packageJson.exports[`./${entryPoint}`].import = {
|
|
813
|
-
types: `./dist/${entryPoint}.d.mts`,
|
|
814
|
-
default: `./dist/${entryPoint}.mjs`
|
|
815
|
-
};
|
|
816
|
-
} else {
|
|
817
|
-
packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
|
|
818
|
-
}
|
|
819
|
-
if (isDts) {
|
|
820
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
821
|
-
types: `./dist/${entryPoint}.d.mts`,
|
|
822
|
-
default: `./dist/${entryPoint}.mjs`
|
|
823
|
-
};
|
|
824
|
-
} else {
|
|
825
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
if (isCjs) {
|
|
829
|
-
if (isDts) {
|
|
830
|
-
packageJson.exports[`./${entryPoint}`].require = {
|
|
831
|
-
types: `./dist/${entryPoint}.d.cts`,
|
|
832
|
-
default: `./dist/${entryPoint}.cjs`
|
|
833
|
-
};
|
|
834
|
-
} else {
|
|
835
|
-
packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
|
|
836
|
-
}
|
|
837
|
-
if (!isEsm) {
|
|
838
|
-
if (isDts) {
|
|
839
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
840
|
-
types: `./dist/${entryPoint}.d.cts`,
|
|
841
|
-
default: `./dist/${entryPoint}.cjs`
|
|
842
|
-
};
|
|
843
|
-
} else {
|
|
844
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
if (!isEsm && !isCjs) {
|
|
849
|
-
if (isDts) {
|
|
850
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
851
|
-
types: `./dist/${entryPoint}.d.ts`,
|
|
852
|
-
default: `./dist/${entryPoint}.js`
|
|
853
|
-
};
|
|
854
|
-
} else {
|
|
855
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
if (isEsm) {
|
|
860
|
-
packageJson.module = `${defaultEntry}.mjs`;
|
|
861
|
-
} else {
|
|
862
|
-
packageJson.main = `${defaultEntry}.cjs`;
|
|
863
|
-
}
|
|
864
|
-
if (isDts) {
|
|
865
|
-
packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
|
|
866
|
-
}
|
|
867
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce(
|
|
868
|
-
(ret, key) => {
|
|
869
|
-
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
870
|
-
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
871
|
-
}
|
|
872
|
-
return ret;
|
|
873
|
-
},
|
|
874
|
-
packageJson.exports
|
|
875
|
-
);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
await writeJsonFile(
|
|
879
|
-
joinPaths(context.outputPath, "package.json"),
|
|
880
|
-
packageJson
|
|
881
|
-
);
|
|
882
|
-
stopwatch();
|
|
883
|
-
}
|
|
884
|
-
return context;
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
// ../tsup/src/index.ts
|
|
888
|
-
import { build as tsup } from "tsup";
|
|
889
|
-
async function build(options) {
|
|
890
|
-
if (!options.silent) {
|
|
891
|
-
writeDebug(
|
|
892
|
-
` \u{1F680} Running ${options.name || "tsup"} build`,
|
|
893
|
-
options.workspaceConfig
|
|
894
|
-
);
|
|
895
|
-
}
|
|
896
|
-
const stopwatch = getStopwatch(`${options.name || "tsup"} build`);
|
|
897
|
-
await tsup(options);
|
|
898
|
-
if (!options.silent) {
|
|
899
|
-
stopwatch();
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
// ../esbuild/src/tsup.ts
|
|
904
|
-
async function executeTsup(context) {
|
|
905
|
-
writeDebug(
|
|
906
|
-
` \u{1F680} Running ${context.options.name} build`,
|
|
907
|
-
context.workspaceConfig
|
|
908
|
-
);
|
|
909
|
-
const stopwatch = getStopwatch(`${context.options.name} build`);
|
|
910
|
-
await build({
|
|
911
|
-
...context.options,
|
|
912
|
-
outDir: context.options.distDir ? joinPaths(context.outputPath, context.options.distDir) : context.outputPath,
|
|
913
|
-
workspaceConfig: context.workspaceConfig
|
|
914
|
-
});
|
|
915
|
-
stopwatch();
|
|
916
|
-
return context;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
// ../esbuild/src/build.ts
|
|
920
|
-
async function reportResults(context) {
|
|
921
|
-
if (context.result?.errors.length === 0) {
|
|
922
|
-
if (context.result.warnings.length > 0) {
|
|
923
|
-
writeWarning(
|
|
924
|
-
` \u{1F6A7} The following warnings occurred during the build: ${context.result.warnings.map((warning) => warning.text).join("\n")}`,
|
|
925
|
-
context.workspaceConfig
|
|
926
|
-
);
|
|
927
|
-
}
|
|
928
|
-
writeSuccess(
|
|
929
|
-
` \u{1F4E6} The ${context.options.name} build completed successfully`,
|
|
930
|
-
context.workspaceConfig
|
|
931
|
-
);
|
|
932
|
-
} else if (context.result?.errors && context.result?.errors.length > 0) {
|
|
933
|
-
writeError(
|
|
934
|
-
` \u274C The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`,
|
|
935
|
-
context.workspaceConfig
|
|
936
|
-
);
|
|
937
|
-
throw new Error(
|
|
938
|
-
`The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`
|
|
939
|
-
);
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
async function cleanOutputPath(context) {
|
|
943
|
-
if (context.clean !== false && context.outputPath) {
|
|
944
|
-
writeDebug(
|
|
945
|
-
` \u{1F9F9} Cleaning ${context.options.name} output path: ${context.outputPath}`,
|
|
946
|
-
context.workspaceConfig
|
|
947
|
-
);
|
|
948
|
-
const stopwatch = getStopwatch(`${context.options.name} output clean`);
|
|
949
|
-
await cleanDirectories(context.outputPath);
|
|
950
|
-
stopwatch();
|
|
951
|
-
}
|
|
952
|
-
return context;
|
|
953
|
-
}
|
|
954
|
-
async function build2(options) {
|
|
955
|
-
writeDebug(` ${brandIcon()} Executing Storm ESBuild pipeline`);
|
|
956
|
-
const stopwatch = getStopwatch("ESBuild pipeline");
|
|
957
|
-
try {
|
|
958
|
-
const opts = Array.isArray(options) ? options : [options];
|
|
959
|
-
if (opts.length === 0) {
|
|
960
|
-
throw new Error("No build options were provided");
|
|
961
|
-
}
|
|
962
|
-
const context = await resolveContext(options);
|
|
963
|
-
await cleanOutputPath(context);
|
|
964
|
-
await Promise.all([
|
|
965
|
-
// dependencyCheck(context.options),
|
|
966
|
-
generatePackageJson(context),
|
|
967
|
-
copyBuildAssets(context),
|
|
968
|
-
executeTsup(context)
|
|
969
|
-
]);
|
|
970
|
-
await reportResults(context);
|
|
971
|
-
writeSuccess(" \u{1F3C1} ESBuild pipeline build completed successfully");
|
|
972
|
-
} catch (error) {
|
|
973
|
-
writeFatal(
|
|
974
|
-
"Fatal errors that the build process could not recover from have occured. The build process has been terminated."
|
|
975
|
-
);
|
|
976
|
-
throw error;
|
|
977
|
-
} finally {
|
|
978
|
-
stopwatch();
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
|
|
982
286
|
// ../workspace-tools/src/executors/esbuild/executor.ts
|
|
287
|
+
import { createJiti } from "jiti";
|
|
983
288
|
async function esbuildExecutorFn(options, context, config) {
|
|
984
289
|
writeInfo("\u{1F4E6} Running Storm ESBuild executor on the workspace", config);
|
|
985
290
|
if (!context.projectsConfigurations?.projects || !context.projectName || !context.projectsConfigurations.projects[context.projectName] || !context.projectsConfigurations.projects[context.projectName]?.root) {
|
|
@@ -987,6 +292,15 @@ async function esbuildExecutorFn(options, context, config) {
|
|
|
987
292
|
"The Build process failed because the context is not valid. Please run this command from a workspace."
|
|
988
293
|
);
|
|
989
294
|
}
|
|
295
|
+
const jiti = createJiti(config?.workspaceRoot || process.cwd(), {
|
|
296
|
+
fsCache: config?.skipCache ? false : joinPaths(
|
|
297
|
+
config?.workspaceRoot || process.cwd(),
|
|
298
|
+
config?.directories?.cache || "node_modules/.cache/storm",
|
|
299
|
+
"jiti"
|
|
300
|
+
),
|
|
301
|
+
interopDefault: true
|
|
302
|
+
});
|
|
303
|
+
const { build: build2 } = await jiti.import(jiti.esmResolve("@storm-software/esbuild"));
|
|
990
304
|
await build2({
|
|
991
305
|
...options,
|
|
992
306
|
projectRoot: (
|
|
@@ -1019,10 +333,10 @@ var executor_default6 = withRunExecutor(
|
|
|
1019
333
|
);
|
|
1020
334
|
|
|
1021
335
|
// ../workspace-tools/src/executors/napi/executor.ts
|
|
1022
|
-
import { createJiti } from "jiti";
|
|
336
|
+
import { createJiti as createJiti2 } from "jiti";
|
|
1023
337
|
import { fileExists } from "nx/src/utils/fileutils";
|
|
1024
338
|
async function napiExecutor(options, context, config) {
|
|
1025
|
-
const jiti =
|
|
339
|
+
const jiti = createJiti2(config.workspaceRoot, {
|
|
1026
340
|
fsCache: config.skipCache ? false : joinPaths(
|
|
1027
341
|
config.workspaceRoot,
|
|
1028
342
|
config.directories.cache || "node_modules/.cache/storm",
|
|
@@ -1126,38 +440,39 @@ var executor_default7 = withRunExecutor(
|
|
|
1126
440
|
}
|
|
1127
441
|
);
|
|
1128
442
|
|
|
1129
|
-
// ../npm-tools/src/helpers/get-registry.ts
|
|
1130
|
-
import { exec } from "node:child_process";
|
|
1131
|
-
|
|
1132
|
-
// ../pnpm-tools/src/helpers/replace-deps-aliases.ts
|
|
1133
|
-
import {
|
|
1134
|
-
createProjectGraphAsync as createProjectGraphAsync3,
|
|
1135
|
-
readCachedProjectGraph as readCachedProjectGraph2
|
|
1136
|
-
} from "@nx/devkit";
|
|
1137
|
-
import { existsSync as existsSync6 } from "node:fs";
|
|
1138
|
-
import { readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
|
|
1139
|
-
import { format } from "prettier";
|
|
1140
|
-
|
|
1141
443
|
// ../npm-tools/src/helpers/get-version.ts
|
|
1142
444
|
import { exec as exec2 } from "node:child_process";
|
|
1143
445
|
import { valid } from "semver";
|
|
1144
446
|
import stripAnsi from "strip-ansi";
|
|
1145
447
|
|
|
448
|
+
// ../npm-tools/src/helpers/get-registry.ts
|
|
449
|
+
import { exec } from "node:child_process";
|
|
450
|
+
|
|
1146
451
|
// ../pnpm-tools/src/helpers/catalog.ts
|
|
1147
452
|
import { coerce, gt, valid as valid2 } from "semver";
|
|
1148
453
|
|
|
1149
454
|
// ../pnpm-tools/src/helpers/pnpm-workspace.ts
|
|
1150
|
-
import { existsSync
|
|
1151
|
-
import { readFile
|
|
455
|
+
import { existsSync } from "node:fs";
|
|
456
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
1152
457
|
import { parse, stringify } from "yaml";
|
|
1153
458
|
|
|
459
|
+
// ../pnpm-tools/src/helpers/replace-deps-aliases.ts
|
|
460
|
+
import {
|
|
461
|
+
createProjectGraphAsync,
|
|
462
|
+
readCachedProjectGraph
|
|
463
|
+
} from "@nx/devkit";
|
|
464
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
465
|
+
import { readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
466
|
+
import { format } from "prettier";
|
|
467
|
+
|
|
1154
468
|
// ../workspace-tools/src/executors/npm-publish/executor.ts
|
|
469
|
+
import { createJiti as createJiti4 } from "jiti";
|
|
1155
470
|
import { execSync as execSync3 } from "node:child_process";
|
|
1156
|
-
import { readFile as
|
|
471
|
+
import { readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
|
|
1157
472
|
import { format as format3 } from "prettier";
|
|
1158
473
|
|
|
1159
474
|
// ../workspace-tools/src/utils/github.ts
|
|
1160
|
-
import { createJiti as
|
|
475
|
+
import { createJiti as createJiti3 } from "jiti";
|
|
1161
476
|
|
|
1162
477
|
// ../workspace-tools/src/utils/package-helpers.ts
|
|
1163
478
|
import {
|
|
@@ -1165,8 +480,8 @@ import {
|
|
|
1165
480
|
readJsonFile
|
|
1166
481
|
} from "@nx/devkit";
|
|
1167
482
|
import { execFileSync } from "child_process";
|
|
1168
|
-
import { existsSync as
|
|
1169
|
-
import { readFile as
|
|
483
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
484
|
+
import { readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
|
|
1170
485
|
import { dirname, resolve } from "path";
|
|
1171
486
|
import { format as format2 } from "prettier";
|
|
1172
487
|
|
|
@@ -1232,78 +547,368 @@ var hasProjectTag = (project, variant) => {
|
|
|
1232
547
|
);
|
|
1233
548
|
};
|
|
1234
549
|
|
|
1235
|
-
// ../workspace-tools/src/utils/project-tags.ts
|
|
1236
|
-
var addProjectTag = (project, variant, value, options = {
|
|
1237
|
-
overwrite: false
|
|
1238
|
-
}) => {
|
|
1239
|
-
project.tags = project.tags ?? [];
|
|
1240
|
-
if (options.overwrite || !hasProjectTag(project, variant)) {
|
|
1241
|
-
project.tags = project.tags.filter(
|
|
1242
|
-
(tag) => !tag.startsWith(formatProjectTag(variant, ""))
|
|
550
|
+
// ../workspace-tools/src/utils/project-tags.ts
|
|
551
|
+
var addProjectTag = (project, variant, value, options = {
|
|
552
|
+
overwrite: false
|
|
553
|
+
}) => {
|
|
554
|
+
project.tags = project.tags ?? [];
|
|
555
|
+
if (options.overwrite || !hasProjectTag(project, variant)) {
|
|
556
|
+
project.tags = project.tags.filter(
|
|
557
|
+
(tag) => !tag.startsWith(formatProjectTag(variant, ""))
|
|
558
|
+
);
|
|
559
|
+
project.tags.push(formatProjectTag(variant, value));
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
// ../workspace-tools/src/executors/npm-publish/executor.ts
|
|
564
|
+
var LARGE_BUFFER2 = 1024 * 1e6;
|
|
565
|
+
|
|
566
|
+
// ../workspace-tools/src/executors/size-limit/executor.ts
|
|
567
|
+
import { joinPathFragments as joinPathFragments4 } from "@nx/devkit";
|
|
568
|
+
import esBuildPlugin from "@size-limit/esbuild";
|
|
569
|
+
import esBuildWhyPlugin from "@size-limit/esbuild-why";
|
|
570
|
+
import filePlugin from "@size-limit/file";
|
|
571
|
+
import sizeLimit from "size-limit";
|
|
572
|
+
async function sizeLimitExecutorFn(options, context, config) {
|
|
573
|
+
if (!context?.projectName || !context.projectsConfigurations?.projects || !context.projectsConfigurations.projects[context.projectName]) {
|
|
574
|
+
throw new Error(
|
|
575
|
+
"The Size-Limit process failed because the context is not valid. Please run this command from a workspace."
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
writeInfo(`\u{1F4CF} Running Size-Limit on ${context.projectName}`, config);
|
|
579
|
+
sizeLimit([filePlugin, esBuildPlugin, esBuildWhyPlugin], {
|
|
580
|
+
checks: options.entry ?? context.projectsConfigurations.projects[context.projectName]?.sourceRoot ?? joinPathFragments4(
|
|
581
|
+
context.projectsConfigurations.projects[context.projectName]?.root ?? "./",
|
|
582
|
+
"src"
|
|
583
|
+
)
|
|
584
|
+
}).then((result) => {
|
|
585
|
+
writeInfo(
|
|
586
|
+
`\u{1F4CF} ${context.projectName} Size-Limit result: ${JSON.stringify(result)}`,
|
|
587
|
+
config
|
|
588
|
+
);
|
|
589
|
+
});
|
|
590
|
+
return {
|
|
591
|
+
success: true
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
var executor_default8 = withRunExecutor(
|
|
595
|
+
"Size-Limit Performance Test Executor",
|
|
596
|
+
sizeLimitExecutorFn,
|
|
597
|
+
{
|
|
598
|
+
skipReadingConfig: false,
|
|
599
|
+
hooks: {
|
|
600
|
+
applyDefaultOptions: (options) => {
|
|
601
|
+
return options;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
// ../tsdown/src/build.ts
|
|
608
|
+
import {
|
|
609
|
+
createProjectGraphAsync as createProjectGraphAsync3,
|
|
610
|
+
readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph2,
|
|
611
|
+
writeJsonFile
|
|
612
|
+
} from "@nx/devkit";
|
|
613
|
+
|
|
614
|
+
// ../build-tools/src/config.ts
|
|
615
|
+
var DEFAULT_ENVIRONMENT = "production";
|
|
616
|
+
var DEFAULT_TARGET = "esnext";
|
|
617
|
+
var DEFAULT_ORGANIZATION = "storm-software";
|
|
618
|
+
|
|
619
|
+
// ../build-tools/src/plugins/swc.ts
|
|
620
|
+
import { transform } from "@swc/core";
|
|
621
|
+
|
|
622
|
+
// ../build-tools/src/plugins/ts-resolve.ts
|
|
623
|
+
import fs from "node:fs";
|
|
624
|
+
import { builtinModules } from "node:module";
|
|
625
|
+
import path from "node:path";
|
|
626
|
+
import _resolve from "resolve";
|
|
627
|
+
|
|
628
|
+
// ../build-tools/src/plugins/type-definitions.ts
|
|
629
|
+
import { stripIndents } from "@nx/devkit";
|
|
630
|
+
import { relative as relative3 } from "path";
|
|
631
|
+
|
|
632
|
+
// ../build-tools/src/utilities/copy-assets.ts
|
|
633
|
+
import { CopyAssetsHandler } from "@nx/js/internal";
|
|
634
|
+
import { glob } from "glob";
|
|
635
|
+
import { readFile as readFile5, writeFile as writeFile5 } from "node:fs/promises";
|
|
636
|
+
var copyAssets = async (config, assets, outputPath, projectRoot, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
|
|
637
|
+
const pendingAssets = Array.from(assets ?? []);
|
|
638
|
+
pendingAssets.push({
|
|
639
|
+
input: projectRoot,
|
|
640
|
+
glob: "*.md",
|
|
641
|
+
output: "."
|
|
642
|
+
});
|
|
643
|
+
pendingAssets.push({
|
|
644
|
+
input: ".",
|
|
645
|
+
glob: "LICENSE",
|
|
646
|
+
output: "."
|
|
647
|
+
});
|
|
648
|
+
if (generatePackageJson2 === false) {
|
|
649
|
+
pendingAssets.push({
|
|
650
|
+
input: projectRoot,
|
|
651
|
+
glob: "package.json",
|
|
652
|
+
output: "."
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
if (includeSrc === true) {
|
|
656
|
+
pendingAssets.push({
|
|
657
|
+
input: sourceRoot,
|
|
658
|
+
glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
|
|
659
|
+
output: "src/"
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
writeTrace(
|
|
663
|
+
`\u{1F4DD} Copying the following assets to the output directory:
|
|
664
|
+
${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`,
|
|
665
|
+
config
|
|
666
|
+
);
|
|
667
|
+
const assetHandler = new CopyAssetsHandler({
|
|
668
|
+
projectDir: projectRoot,
|
|
669
|
+
rootDir: config.workspaceRoot,
|
|
670
|
+
outputDir: outputPath,
|
|
671
|
+
assets: pendingAssets
|
|
672
|
+
});
|
|
673
|
+
await assetHandler.processAllAssetsOnce();
|
|
674
|
+
writeTrace("Completed copying assets to the output directory", config);
|
|
675
|
+
if (includeSrc === true) {
|
|
676
|
+
writeDebug(
|
|
677
|
+
`\u{1F4DD} Adding banner and writing source files: ${joinPaths(
|
|
678
|
+
outputPath,
|
|
679
|
+
"src"
|
|
680
|
+
)}`,
|
|
681
|
+
config
|
|
682
|
+
);
|
|
683
|
+
const files = await glob([
|
|
684
|
+
joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
|
|
685
|
+
joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
|
|
686
|
+
joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
687
|
+
joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
688
|
+
]);
|
|
689
|
+
await Promise.allSettled(
|
|
690
|
+
files.map(
|
|
691
|
+
async (file) => writeFile5(
|
|
692
|
+
file,
|
|
693
|
+
`${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
694
|
+
|
|
695
|
+
${await readFile5(file, "utf8")}
|
|
696
|
+
|
|
697
|
+
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`
|
|
698
|
+
)
|
|
699
|
+
)
|
|
1243
700
|
);
|
|
1244
|
-
project.tags.push(formatProjectTag(variant, value));
|
|
1245
701
|
}
|
|
1246
702
|
};
|
|
1247
703
|
|
|
1248
|
-
// ../
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
import {
|
|
1253
|
-
import
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
704
|
+
// ../build-tools/src/utilities/generate-package-json.ts
|
|
705
|
+
import { calculateProjectBuildableDependencies } from "@nx/js/internal";
|
|
706
|
+
import { Glob } from "glob";
|
|
707
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "node:fs";
|
|
708
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
709
|
+
import {
|
|
710
|
+
createProjectGraphAsync as createProjectGraphAsync2,
|
|
711
|
+
readCachedProjectGraph as readCachedProjectGraph2,
|
|
712
|
+
readProjectsConfigurationFromProjectGraph
|
|
713
|
+
} from "nx/src/project-graph/project-graph";
|
|
714
|
+
var addPackageDependencies = async (workspaceRoot2, projectRoot, projectName, packageJson) => {
|
|
715
|
+
let projectGraph;
|
|
716
|
+
try {
|
|
717
|
+
projectGraph = readCachedProjectGraph2();
|
|
718
|
+
} catch {
|
|
719
|
+
await createProjectGraphAsync2();
|
|
720
|
+
projectGraph = readCachedProjectGraph2();
|
|
721
|
+
}
|
|
722
|
+
if (!projectGraph) {
|
|
1259
723
|
throw new Error(
|
|
1260
|
-
"The
|
|
724
|
+
"The Build process failed because the project graph is not available. Please run the build command again."
|
|
1261
725
|
);
|
|
1262
726
|
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
727
|
+
const projectDependencies = calculateProjectBuildableDependencies(
|
|
728
|
+
void 0,
|
|
729
|
+
projectGraph,
|
|
730
|
+
workspaceRoot2,
|
|
731
|
+
projectName,
|
|
732
|
+
process.env.NX_TASK_TARGET_TARGET || "build",
|
|
733
|
+
process.env.NX_TASK_TARGET_CONFIGURATION || "production",
|
|
734
|
+
true
|
|
735
|
+
);
|
|
736
|
+
const localPackages = [];
|
|
737
|
+
for (const project of projectDependencies.dependencies.filter(
|
|
738
|
+
(dep) => dep.node.type === "lib" && dep.node.data?.root !== projectRoot && dep.node.data?.root !== workspaceRoot2
|
|
739
|
+
)) {
|
|
740
|
+
const projectNode = project.node;
|
|
741
|
+
if (projectNode.data.root) {
|
|
742
|
+
const projectPackageJsonPath = joinPaths(
|
|
743
|
+
workspaceRoot2,
|
|
744
|
+
projectNode.data.root,
|
|
745
|
+
"package.json"
|
|
746
|
+
);
|
|
747
|
+
if (existsSync4(projectPackageJsonPath)) {
|
|
748
|
+
const projectPackageJsonContent = await readFile6(
|
|
749
|
+
projectPackageJsonPath,
|
|
750
|
+
"utf8"
|
|
751
|
+
);
|
|
752
|
+
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
753
|
+
if (projectPackageJson.private !== true) {
|
|
754
|
+
localPackages.push(projectPackageJson);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
if (localPackages.length > 0) {
|
|
760
|
+
writeTrace(
|
|
761
|
+
`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`
|
|
1273
762
|
);
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
763
|
+
const projectJsonFile = await readFile6(
|
|
764
|
+
joinPaths(projectRoot, "project.json"),
|
|
765
|
+
"utf8"
|
|
766
|
+
);
|
|
767
|
+
const projectJson = JSON.parse(projectJsonFile);
|
|
768
|
+
const projectName2 = projectJson.name;
|
|
769
|
+
const projectConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
770
|
+
if (!projectConfigurations?.projects?.[projectName2]) {
|
|
771
|
+
throw new Error(
|
|
772
|
+
"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."
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
const implicitDependencies = projectConfigurations.projects?.[projectName2].implicitDependencies?.reduce((ret, dep) => {
|
|
776
|
+
if (projectConfigurations.projects?.[dep]) {
|
|
777
|
+
const depPackageJsonPath = joinPaths(
|
|
778
|
+
workspaceRoot2,
|
|
779
|
+
projectConfigurations.projects[dep].root,
|
|
780
|
+
"package.json"
|
|
781
|
+
);
|
|
782
|
+
if (existsSync4(depPackageJsonPath)) {
|
|
783
|
+
const depPackageJsonContent = readFileSync3(
|
|
784
|
+
depPackageJsonPath,
|
|
785
|
+
"utf8"
|
|
786
|
+
);
|
|
787
|
+
const depPackageJson = JSON.parse(depPackageJsonContent);
|
|
788
|
+
if (depPackageJson.private !== true && !ret.includes(depPackageJson.name)) {
|
|
789
|
+
ret.push(depPackageJson.name);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
return ret;
|
|
794
|
+
}, []);
|
|
795
|
+
packageJson.dependencies = localPackages.reduce((ret, localPackage) => {
|
|
796
|
+
if (!ret[localPackage.name] && !implicitDependencies?.includes(localPackage.name) && packageJson.devDependencies?.[localPackage.name] === void 0) {
|
|
797
|
+
ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
|
|
798
|
+
}
|
|
799
|
+
return ret;
|
|
800
|
+
}, packageJson.dependencies ?? {});
|
|
801
|
+
packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
|
|
802
|
+
if (!ret[localPackage.name] && implicitDependencies?.includes(localPackage.name) && packageJson.dependencies?.[localPackage.name] === void 0) {
|
|
803
|
+
ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
|
|
1287
804
|
}
|
|
805
|
+
return ret;
|
|
806
|
+
}, packageJson.devDependencies ?? {});
|
|
807
|
+
} else {
|
|
808
|
+
writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
|
|
809
|
+
}
|
|
810
|
+
return packageJson;
|
|
811
|
+
};
|
|
812
|
+
var addWorkspacePackageJsonFields = async (workspaceConfig, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
813
|
+
const workspaceRoot2 = workspaceConfig.workspaceRoot ? workspaceConfig.workspaceRoot : findWorkspaceRoot();
|
|
814
|
+
const workspacePackageJsonContent = await readFile6(
|
|
815
|
+
joinPaths(workspaceRoot2, "package.json"),
|
|
816
|
+
"utf8"
|
|
817
|
+
);
|
|
818
|
+
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
819
|
+
packageJson.type ??= "module";
|
|
820
|
+
packageJson.sideEffects ??= false;
|
|
821
|
+
if (includeSrc === true) {
|
|
822
|
+
let distSrc = sourceRoot.replace(projectRoot, "");
|
|
823
|
+
if (distSrc.startsWith("/")) {
|
|
824
|
+
distSrc = distSrc.substring(1);
|
|
1288
825
|
}
|
|
826
|
+
packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
|
|
1289
827
|
}
|
|
1290
|
-
|
|
828
|
+
packageJson.files ??= ["dist/**/*"];
|
|
829
|
+
if (includeSrc === true && !packageJson.files.includes("src")) {
|
|
830
|
+
packageJson.files.push("src/**/*");
|
|
831
|
+
}
|
|
832
|
+
packageJson.publishConfig ??= {
|
|
833
|
+
access: "public"
|
|
834
|
+
};
|
|
835
|
+
packageJson.description ??= workspacePackageJson.description;
|
|
836
|
+
packageJson.homepage ??= workspacePackageJson.homepage;
|
|
837
|
+
packageJson.bugs ??= workspacePackageJson.bugs;
|
|
838
|
+
packageJson.license ??= workspacePackageJson.license;
|
|
839
|
+
packageJson.keywords ??= workspacePackageJson.keywords;
|
|
840
|
+
packageJson.funding ??= workspacePackageJson.funding;
|
|
841
|
+
packageJson.author ??= workspacePackageJson.author;
|
|
842
|
+
packageJson.maintainers ??= workspacePackageJson.maintainers;
|
|
843
|
+
if (!packageJson.maintainers && packageJson.author) {
|
|
844
|
+
packageJson.maintainers = [packageJson.author];
|
|
845
|
+
}
|
|
846
|
+
packageJson.contributors ??= workspacePackageJson.contributors;
|
|
847
|
+
if (!packageJson.contributors && packageJson.author) {
|
|
848
|
+
packageJson.contributors = [packageJson.author];
|
|
849
|
+
}
|
|
850
|
+
packageJson.repository ??= workspacePackageJson.repository;
|
|
851
|
+
packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
|
|
852
|
+
return packageJson;
|
|
853
|
+
};
|
|
854
|
+
var addPackageJsonExport = (file, type = "module", sourceRoot) => {
|
|
855
|
+
let entry = file.replaceAll("\\", "/");
|
|
856
|
+
if (sourceRoot) {
|
|
857
|
+
entry = entry.replace(sourceRoot, "");
|
|
858
|
+
}
|
|
859
|
+
return {
|
|
860
|
+
import: {
|
|
861
|
+
types: `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
|
|
862
|
+
default: `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
|
|
863
|
+
},
|
|
864
|
+
require: {
|
|
865
|
+
types: `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
|
|
866
|
+
default: `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
|
|
867
|
+
},
|
|
868
|
+
default: {
|
|
869
|
+
types: `./dist/${entry}.d.${type !== "fixed" ? "ts" : "mts"}`,
|
|
870
|
+
default: `./dist/${entry}.${type !== "fixed" ? "js" : "mjs"}`
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
};
|
|
1291
874
|
|
|
1292
|
-
// ../
|
|
875
|
+
// ../build-tools/src/utilities/get-entry-points.ts
|
|
876
|
+
import { glob as glob2 } from "glob";
|
|
877
|
+
|
|
878
|
+
// ../build-tools/src/utilities/get-env.ts
|
|
879
|
+
var getEnv = (builder, options) => {
|
|
880
|
+
return {
|
|
881
|
+
STORM_BUILD: builder,
|
|
882
|
+
STORM_ORG: options.orgName || DEFAULT_ORGANIZATION,
|
|
883
|
+
STORM_NAME: options.name,
|
|
884
|
+
STORM_MODE: options.mode || DEFAULT_ENVIRONMENT,
|
|
885
|
+
STORM_PLATFORM: options.platform,
|
|
886
|
+
STORM_FORMAT: JSON.stringify(options.format),
|
|
887
|
+
STORM_TARGET: JSON.stringify(options.target),
|
|
888
|
+
...options.env
|
|
889
|
+
};
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
// ../build-tools/src/utilities/read-nx-config.ts
|
|
893
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
894
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
895
|
+
|
|
896
|
+
// ../build-tools/src/utilities/task-graph.ts
|
|
1293
897
|
import {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
import
|
|
1300
|
-
import
|
|
898
|
+
createTaskGraph,
|
|
899
|
+
mapTargetDefaultsToDependencies
|
|
900
|
+
} from "nx/src/tasks-runner/create-task-graph";
|
|
901
|
+
|
|
902
|
+
// ../tsdown/src/build.ts
|
|
903
|
+
import defu from "defu";
|
|
904
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
905
|
+
import hf from "node:fs/promises";
|
|
1301
906
|
import { build as tsdown } from "tsdown";
|
|
1302
907
|
|
|
1303
908
|
// ../tsdown/src/clean.ts
|
|
1304
|
-
import { rm
|
|
1305
|
-
async function
|
|
1306
|
-
await
|
|
909
|
+
import { rm } from "node:fs/promises";
|
|
910
|
+
async function cleanDirectories(name = "TSDown", directory, config) {
|
|
911
|
+
await rm(directory, { recursive: true, force: true });
|
|
1307
912
|
}
|
|
1308
913
|
|
|
1309
914
|
// ../tsdown/src/config.ts
|
|
@@ -1346,7 +951,7 @@ var resolveOptions = async (userOptions) => {
|
|
|
1346
951
|
});
|
|
1347
952
|
writeDebug(" \u2699\uFE0F Resolving build options", workspaceConfig);
|
|
1348
953
|
const stopwatch = getStopwatch("Build options resolution");
|
|
1349
|
-
const projectGraph = await
|
|
954
|
+
const projectGraph = await createProjectGraphAsync3({
|
|
1350
955
|
exitOnError: true
|
|
1351
956
|
});
|
|
1352
957
|
const projectJsonPath = joinPaths(
|
|
@@ -1354,13 +959,13 @@ var resolveOptions = async (userOptions) => {
|
|
|
1354
959
|
options.projectRoot,
|
|
1355
960
|
"project.json"
|
|
1356
961
|
);
|
|
1357
|
-
if (!
|
|
962
|
+
if (!existsSync6(projectJsonPath)) {
|
|
1358
963
|
throw new Error("Cannot find project.json configuration");
|
|
1359
964
|
}
|
|
1360
|
-
const projectJsonFile = await
|
|
965
|
+
const projectJsonFile = await hf.readFile(projectJsonPath, "utf8");
|
|
1361
966
|
const projectJson = JSON.parse(projectJsonFile);
|
|
1362
967
|
const projectName = projectJson.name;
|
|
1363
|
-
const projectConfigurations =
|
|
968
|
+
const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
|
|
1364
969
|
if (!projectConfigurations?.projects?.[projectName]) {
|
|
1365
970
|
throw new Error(
|
|
1366
971
|
"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."
|
|
@@ -1371,7 +976,7 @@ var resolveOptions = async (userOptions) => {
|
|
|
1371
976
|
options.projectRoot,
|
|
1372
977
|
"package.json"
|
|
1373
978
|
);
|
|
1374
|
-
if (!
|
|
979
|
+
if (!existsSync6(packageJsonPath)) {
|
|
1375
980
|
throw new Error("Cannot find package.json configuration");
|
|
1376
981
|
}
|
|
1377
982
|
const debug = options.debug ?? (options.mode || workspaceConfig.mode) === "development";
|
|
@@ -1408,22 +1013,22 @@ var resolveOptions = async (userOptions) => {
|
|
|
1408
1013
|
projectGraph,
|
|
1409
1014
|
projectConfigurations
|
|
1410
1015
|
};
|
|
1411
|
-
result.env =
|
|
1016
|
+
result.env = defu(
|
|
1412
1017
|
options.env,
|
|
1413
1018
|
getEnv("tsdown", result)
|
|
1414
1019
|
);
|
|
1415
1020
|
stopwatch();
|
|
1416
1021
|
return result;
|
|
1417
1022
|
};
|
|
1418
|
-
async function
|
|
1419
|
-
if (options.generatePackageJson !== false &&
|
|
1023
|
+
async function generatePackageJson(options) {
|
|
1024
|
+
if (options.generatePackageJson !== false && existsSync6(joinPaths(options.projectRoot, "package.json"))) {
|
|
1420
1025
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.workspaceConfig);
|
|
1421
1026
|
const stopwatch = getStopwatch("Write package.json file");
|
|
1422
1027
|
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
1423
|
-
if (!
|
|
1028
|
+
if (!existsSync6(packageJsonPath)) {
|
|
1424
1029
|
throw new Error("Cannot find package.json configuration");
|
|
1425
1030
|
}
|
|
1426
|
-
const packageJsonFile = await
|
|
1031
|
+
const packageJsonFile = await hf.readFile(
|
|
1427
1032
|
joinPaths(
|
|
1428
1033
|
options.workspaceConfig.workspaceRoot,
|
|
1429
1034
|
options.projectRoot,
|
|
@@ -1486,7 +1091,7 @@ async function generatePackageJson2(options) {
|
|
|
1486
1091
|
},
|
|
1487
1092
|
packageJson.exports
|
|
1488
1093
|
);
|
|
1489
|
-
await
|
|
1094
|
+
await writeJsonFile(joinPaths(options.outDir, "package.json"), packageJson);
|
|
1490
1095
|
stopwatch();
|
|
1491
1096
|
}
|
|
1492
1097
|
return options;
|
|
@@ -1502,7 +1107,7 @@ async function executeTSDown(options) {
|
|
|
1502
1107
|
stopwatch();
|
|
1503
1108
|
return options;
|
|
1504
1109
|
}
|
|
1505
|
-
async function
|
|
1110
|
+
async function copyBuildAssets(options) {
|
|
1506
1111
|
writeDebug(
|
|
1507
1112
|
` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`,
|
|
1508
1113
|
options.workspaceConfig
|
|
@@ -1520,20 +1125,20 @@ async function copyBuildAssets2(options) {
|
|
|
1520
1125
|
stopwatch();
|
|
1521
1126
|
return options;
|
|
1522
1127
|
}
|
|
1523
|
-
async function
|
|
1128
|
+
async function reportResults(options) {
|
|
1524
1129
|
writeSuccess(
|
|
1525
1130
|
` \u{1F4E6} The ${options.name} build completed successfully`,
|
|
1526
1131
|
options.workspaceConfig
|
|
1527
1132
|
);
|
|
1528
1133
|
}
|
|
1529
|
-
async function
|
|
1134
|
+
async function cleanOutputPath(options) {
|
|
1530
1135
|
if (options.clean !== false && options.workspaceConfig) {
|
|
1531
1136
|
writeDebug(
|
|
1532
1137
|
` \u{1F9F9} Cleaning ${options.name} output path: ${options.workspaceConfig}`,
|
|
1533
1138
|
options.workspaceConfig
|
|
1534
1139
|
);
|
|
1535
1140
|
const stopwatch = getStopwatch(`${options.name} output clean`);
|
|
1536
|
-
await
|
|
1141
|
+
await cleanDirectories(
|
|
1537
1142
|
options.name,
|
|
1538
1143
|
options.outDir,
|
|
1539
1144
|
options.workspaceConfig
|
|
@@ -1542,7 +1147,7 @@ async function cleanOutputPath2(options) {
|
|
|
1542
1147
|
}
|
|
1543
1148
|
return options;
|
|
1544
1149
|
}
|
|
1545
|
-
async function
|
|
1150
|
+
async function build(options) {
|
|
1546
1151
|
writeDebug(` ${brandIcon()} Executing Storm TSDown pipeline`);
|
|
1547
1152
|
const stopwatch = getStopwatch("TSDown pipeline");
|
|
1548
1153
|
try {
|
|
@@ -1554,13 +1159,13 @@ async function build3(options) {
|
|
|
1554
1159
|
opts.map(async (opt) => await resolveOptions(opt))
|
|
1555
1160
|
);
|
|
1556
1161
|
if (resolved.length > 0) {
|
|
1557
|
-
await
|
|
1558
|
-
await
|
|
1162
|
+
await cleanOutputPath(resolved[0]);
|
|
1163
|
+
await generatePackageJson(resolved[0]);
|
|
1559
1164
|
await Promise.all(
|
|
1560
1165
|
resolved.map(async (opt) => {
|
|
1561
1166
|
await executeTSDown(opt);
|
|
1562
|
-
await
|
|
1563
|
-
await
|
|
1167
|
+
await copyBuildAssets(opt);
|
|
1168
|
+
await reportResults(opt);
|
|
1564
1169
|
})
|
|
1565
1170
|
);
|
|
1566
1171
|
} else {
|
|
@@ -1587,7 +1192,7 @@ async function tsdownExecutorFn(options, context, config) {
|
|
|
1587
1192
|
"The Build process failed because the context is not valid. Please run this command from a workspace."
|
|
1588
1193
|
);
|
|
1589
1194
|
}
|
|
1590
|
-
await
|
|
1195
|
+
await build({
|
|
1591
1196
|
...options,
|
|
1592
1197
|
projectRoot: (
|
|
1593
1198
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -1658,8 +1263,8 @@ var executor_default10 = withRunExecutor(
|
|
|
1658
1263
|
);
|
|
1659
1264
|
|
|
1660
1265
|
// ../workspace-tools/src/executors/unbuild/executor.ts
|
|
1661
|
-
import { defu as
|
|
1662
|
-
import { createJiti as
|
|
1266
|
+
import { defu as defu2 } from "defu";
|
|
1267
|
+
import { createJiti as createJiti5 } from "jiti";
|
|
1663
1268
|
async function unbuildExecutorFn(options, context, config) {
|
|
1664
1269
|
writeInfo("\u{1F4E6} Running Storm Unbuild executor on the workspace", config);
|
|
1665
1270
|
if (!context.projectsConfigurations?.projects || !context.projectName || !context.projectsConfigurations.projects[context.projectName]) {
|
|
@@ -1677,7 +1282,7 @@ async function unbuildExecutorFn(options, context, config) {
|
|
|
1677
1282
|
"The Build process failed because the project's source root is not valid. Please run this command from a workspace root directory."
|
|
1678
1283
|
);
|
|
1679
1284
|
}
|
|
1680
|
-
const jiti =
|
|
1285
|
+
const jiti = createJiti5(config.workspaceRoot, {
|
|
1681
1286
|
fsCache: config.skipCache ? false : joinPaths(
|
|
1682
1287
|
config.workspaceRoot,
|
|
1683
1288
|
config.directories.cache || "node_modules/.cache/storm",
|
|
@@ -1689,7 +1294,7 @@ async function unbuildExecutorFn(options, context, config) {
|
|
|
1689
1294
|
jiti.esmResolve("@storm-software/unbuild/build")
|
|
1690
1295
|
);
|
|
1691
1296
|
await stormUnbuild.build(
|
|
1692
|
-
|
|
1297
|
+
defu2(
|
|
1693
1298
|
{
|
|
1694
1299
|
...options,
|
|
1695
1300
|
projectRoot: context.projectsConfigurations.projects[context.projectName].root,
|
|
@@ -3052,7 +2657,7 @@ import {
|
|
|
3052
2657
|
readJsonFile as readJsonFile2,
|
|
3053
2658
|
workspaceRoot
|
|
3054
2659
|
} from "@nx/devkit";
|
|
3055
|
-
import { existsSync as
|
|
2660
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
3056
2661
|
import { join as join2 } from "node:path";
|
|
3057
2662
|
import {
|
|
3058
2663
|
getNpmLockfileDependencies,
|
|
@@ -3321,8 +2926,8 @@ var RELEASE = recommended_default.release;
|
|
|
3321
2926
|
import {
|
|
3322
2927
|
readJsonFile as readJsonFile3
|
|
3323
2928
|
} from "@nx/devkit";
|
|
3324
|
-
import
|
|
3325
|
-
import { existsSync as
|
|
2929
|
+
import defu3 from "defu";
|
|
2930
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
3326
2931
|
import { dirname as dirname2, join as join3 } from "node:path";
|
|
3327
2932
|
|
|
3328
2933
|
// ../workspace-tools/src/utils/typia-transform.ts
|