@storm-software/unbuild 0.30.5 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  cleanDirectories
3
- } from "./chunk-VC7N2YVM.js";
3
+ } from "./chunk-XGZOR6PZ.js";
4
4
  import {
5
5
  getDefaultBuildPlugins
6
- } from "./chunk-K2D7TQ7G.js";
6
+ } from "./chunk-OAOLAATA.js";
7
7
  import {
8
8
  loadConfig
9
- } from "./chunk-C5IHRWT3.js";
9
+ } from "./chunk-NYVG7QMW.js";
10
10
  import {
11
11
  COLOR_KEYS,
12
12
  LogLevel,
@@ -14,6 +14,7 @@ import {
14
14
  STORM_DEFAULT_DOCS,
15
15
  STORM_DEFAULT_HOMEPAGE,
16
16
  STORM_DEFAULT_LICENSING,
17
+ StormConfigSchema,
17
18
  correctPaths,
18
19
  findWorkspaceRoot,
19
20
  formatLogMessage,
@@ -26,16 +27,15 @@ import {
26
27
  writeDebug,
27
28
  writeFatal,
28
29
  writeSuccess,
29
- writeSystem,
30
30
  writeTrace,
31
31
  writeWarning
32
- } from "./chunk-TPFSDZCR.js";
32
+ } from "./chunk-VWXW3RW5.js";
33
33
  import {
34
34
  __name
35
35
  } from "./chunk-3GQAWCBQ.js";
36
36
 
37
37
  // src/build.ts
38
- import { readCachedProjectGraph as readCachedProjectGraph3, writeJsonFile } from "@nx/devkit";
38
+ import { readCachedProjectGraph as readCachedProjectGraph2, writeJsonFile } from "@nx/devkit";
39
39
  import { getHelperDependency, HelperDependency } from "@nx/js";
40
40
  import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies2 } from "@nx/js/src/utils/buildable-libs-utils";
41
41
 
@@ -53,29 +53,173 @@ import { stripIndents } from "@nx/devkit";
53
53
  import { relative } from "path";
54
54
 
55
55
  // ../build-tools/src/utilities/copy-assets.ts
56
- import { readCachedProjectGraph, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
57
- import { copyAssets as copyAssetsBase } from "@nx/js";
56
+ import { CopyAssetsHandler } from "@nx/js/src/utils/assets/copy-assets-handler";
58
57
  import { glob } from "glob";
59
- import { readFile as readFile2, writeFile } from "node:fs/promises";
58
+ import { readFile, writeFile } from "node:fs/promises";
59
+ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, projectRoot, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
60
+ const pendingAssets = Array.from(assets ?? []);
61
+ pendingAssets.push({
62
+ input: projectRoot,
63
+ glob: "*.md",
64
+ output: "."
65
+ });
66
+ pendingAssets.push({
67
+ input: ".",
68
+ glob: "LICENSE",
69
+ output: "."
70
+ });
71
+ if (generatePackageJson2 === false) {
72
+ pendingAssets.push({
73
+ input: projectRoot,
74
+ glob: "package.json",
75
+ output: "."
76
+ });
77
+ }
78
+ if (includeSrc === true) {
79
+ pendingAssets.push({
80
+ input: sourceRoot,
81
+ glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
82
+ output: "src/"
83
+ });
84
+ }
85
+ writeTrace(`\u{1F4DD} Copying the following assets to the output directory:
86
+ ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`, config);
87
+ const assetHandler = new CopyAssetsHandler({
88
+ projectDir: projectRoot,
89
+ rootDir: config.workspaceRoot,
90
+ outputDir: outputPath,
91
+ assets: pendingAssets
92
+ });
93
+ await assetHandler.processAllAssetsOnce();
94
+ if (includeSrc === true) {
95
+ writeDebug(`\u{1F4DD} Adding banner and writing source files: ${joinPaths(outputPath, "src")}`, config);
96
+ const files = await glob([
97
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
98
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
99
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
100
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
101
+ ]);
102
+ await Promise.allSettled(files.map(async (file) => writeFile(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
103
+
104
+ ${await readFile(file, "utf8")}
105
+
106
+ ${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
107
+ }
108
+ }, "copyAssets");
109
+
110
+ // ../build-tools/src/utilities/generate-package-json.ts
111
+ import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
112
+ import { Glob } from "glob";
113
+ import { existsSync } from "node:fs";
114
+ import { readFile as readFile2 } from "node:fs/promises";
115
+ import { readCachedProjectGraph } from "nx/src/project-graph/project-graph";
116
+ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projectRoot, projectName, packageJson) => {
117
+ const projectDependencies = calculateProjectBuildableDependencies(void 0, readCachedProjectGraph(), workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
118
+ const localPackages = [];
119
+ for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
120
+ const projectNode = project.node;
121
+ if (projectNode.data.root) {
122
+ const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
123
+ if (existsSync(projectPackageJsonPath)) {
124
+ const projectPackageJsonContent = await readFile2(projectPackageJsonPath, "utf8");
125
+ const projectPackageJson = JSON.parse(projectPackageJsonContent);
126
+ if (projectPackageJson.private !== false) {
127
+ localPackages.push(projectPackageJson);
128
+ }
129
+ }
130
+ }
131
+ }
132
+ if (localPackages.length > 0) {
133
+ writeTrace(`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
134
+ packageJson.peerDependencies = localPackages.reduce((ret, localPackage) => {
135
+ if (!ret[localPackage.name]) {
136
+ ret[localPackage.name] = `>=${localPackage.version || "0.0.1"}`;
137
+ }
138
+ return ret;
139
+ }, packageJson.peerDependencies ?? {});
140
+ packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
141
+ if (!ret[localPackage.name]) {
142
+ ret[localPackage.name] = {
143
+ optional: false
144
+ };
145
+ }
146
+ return ret;
147
+ }, packageJson.peerDependenciesMeta ?? {});
148
+ packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
149
+ if (!ret[localPackage.name]) {
150
+ ret[localPackage.name] = localPackage.version || "0.0.1";
151
+ }
152
+ return ret;
153
+ }, packageJson.peerDependencies ?? {});
154
+ } else {
155
+ writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
156
+ }
157
+ return packageJson;
158
+ }, "addPackageDependencies");
159
+ var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
160
+ const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
161
+ const workspacePackageJsonContent = await readFile2(joinPaths(workspaceRoot, "package.json"), "utf8");
162
+ const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
163
+ packageJson.type ??= "module";
164
+ packageJson.sideEffects ??= false;
165
+ if (includeSrc === true) {
166
+ let distSrc = sourceRoot.replace(projectRoot, "");
167
+ if (distSrc.startsWith("/")) {
168
+ distSrc = distSrc.substring(1);
169
+ }
170
+ packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
171
+ }
172
+ packageJson.files ??= [
173
+ "dist/**/*"
174
+ ];
175
+ if (includeSrc === true && !packageJson.files.includes("src")) {
176
+ packageJson.files.push("src/**/*");
177
+ }
178
+ packageJson.publishConfig ??= {
179
+ access: "public"
180
+ };
181
+ packageJson.description ??= workspacePackageJson.description;
182
+ packageJson.homepage ??= workspacePackageJson.homepage;
183
+ packageJson.bugs ??= workspacePackageJson.bugs;
184
+ packageJson.license ??= workspacePackageJson.license;
185
+ packageJson.keywords ??= workspacePackageJson.keywords;
186
+ packageJson.funding ??= workspacePackageJson.funding;
187
+ packageJson.author ??= workspacePackageJson.author;
188
+ packageJson.maintainers ??= workspacePackageJson.maintainers;
189
+ if (!packageJson.maintainers && packageJson.author) {
190
+ packageJson.maintainers = [
191
+ packageJson.author
192
+ ];
193
+ }
194
+ packageJson.contributors ??= workspacePackageJson.contributors;
195
+ if (!packageJson.contributors && packageJson.author) {
196
+ packageJson.contributors = [
197
+ packageJson.author
198
+ ];
199
+ }
200
+ packageJson.repository ??= workspacePackageJson.repository;
201
+ packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
202
+ return packageJson;
203
+ }, "addWorkspacePackageJsonFields");
60
204
 
61
205
  // ../config-tools/src/config-file/get-config-file.ts
62
206
  import { loadConfig as loadConfig2 } from "c12";
63
207
  import defu from "defu";
64
208
  var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, options = {}) => {
65
209
  const workspacePath = filePath || findWorkspaceRoot(filePath);
66
- let config = await loadConfig2({
67
- cwd: workspacePath,
68
- packageJson: true,
69
- name: fileName,
70
- envName: fileName?.toUpperCase(),
71
- jitiOptions: {
72
- debug: false,
73
- fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
74
- },
75
- ...options
76
- });
77
- if (!config || Object.keys(config).length === 0) {
78
- config = await loadConfig2({
210
+ const configs = await Promise.all([
211
+ loadConfig2({
212
+ cwd: workspacePath,
213
+ packageJson: true,
214
+ name: fileName,
215
+ envName: fileName?.toUpperCase(),
216
+ jitiOptions: {
217
+ debug: false,
218
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
219
+ },
220
+ ...options
221
+ }),
222
+ loadConfig2({
79
223
  cwd: workspacePath,
80
224
  packageJson: true,
81
225
  name: fileName,
@@ -86,9 +230,9 @@ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, opti
86
230
  },
87
231
  configFile: fileName,
88
232
  ...options
89
- });
90
- }
91
- return config;
233
+ })
234
+ ]);
235
+ return defu(configs[0] ?? {}, configs[1] ?? {});
92
236
  }, "getConfigFileByName");
93
237
  var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames = []) => {
94
238
  const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
@@ -96,7 +240,7 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
96
240
  let config = result.config;
97
241
  const configFile = result.configFile;
98
242
  if (config && configFile && Object.keys(config).length > 0) {
99
- writeSystem(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
243
+ writeTrace(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
100
244
  logLevel: "all"
101
245
  });
102
246
  }
@@ -104,7 +248,7 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
104
248
  const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
105
249
  for (const result2 of results) {
106
250
  if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
107
- writeSystem(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
251
+ writeTrace(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
108
252
  logLevel: "all"
109
253
  });
110
254
  config = defu(result2.config ?? {}, config ?? {});
@@ -122,6 +266,16 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
122
266
  import defu2 from "defu";
123
267
 
124
268
  // ../config-tools/src/env/get-env.ts
269
+ var getExtensionEnv = /* @__PURE__ */ __name((extensionName) => {
270
+ const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
271
+ return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
272
+ const name = key.replace(prefix, "").split("_").map((i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : "").join("");
273
+ if (name) {
274
+ ret[name] = process.env[key];
275
+ }
276
+ return ret;
277
+ }, {});
278
+ }, "getExtensionEnv");
125
279
  var getConfigEnv = /* @__PURE__ */ __name(() => {
126
280
  const prefix = "STORM_";
127
281
  let config = {
@@ -281,7 +435,7 @@ var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
281
435
  var setConfigEnv = /* @__PURE__ */ __name((config) => {
282
436
  const prefix = "STORM_";
283
437
  if (config.extends) {
284
- process.env[`${prefix}EXTENDS`] = config.extends;
438
+ process.env[`${prefix}EXTENDS`] = Array.isArray(config.extends) ? JSON.stringify(config.extends) : config.extends;
285
439
  }
286
440
  if (config.name) {
287
441
  process.env[`${prefix}NAME`] = config.name;
@@ -511,217 +665,75 @@ var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
511
665
  }, "setBaseThemeColorConfigEnv");
512
666
 
513
667
  // ../config-tools/src/create-storm-config.ts
668
+ var _extension_cache = /* @__PURE__ */ new WeakMap();
514
669
  var _static_cache = void 0;
515
- var loadStormConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
516
- let config = {};
517
- if (_static_cache?.data && _static_cache?.timestamp && _static_cache.timestamp >= Date.now() + 3e4) {
518
- writeTrace(`Configuration cache hit - ${_static_cache.timestamp}`, _static_cache.data);
519
- return _static_cache.data;
520
- }
521
- let _workspaceRoot = workspaceRoot;
522
- if (!_workspaceRoot) {
523
- _workspaceRoot = findWorkspaceRoot();
524
- }
525
- const configFile = await getConfigFile(_workspaceRoot);
526
- if (!configFile) {
527
- writeWarning("No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.json` file to the root of your workspace if it is not.\n", {
528
- logLevel: "all"
529
- });
670
+ var createStormConfig = /* @__PURE__ */ __name(async (extensionName, schema, workspaceRoot, skipLogs = false) => {
671
+ let result;
672
+ if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
673
+ let _workspaceRoot = workspaceRoot;
674
+ if (!_workspaceRoot) {
675
+ _workspaceRoot = findWorkspaceRoot();
676
+ }
677
+ const configEnv = getConfigEnv();
678
+ const defaultConfig = await getDefaultConfig(_workspaceRoot);
679
+ const configFile = await getConfigFile(_workspaceRoot);
680
+ if (!configFile && !skipLogs) {
681
+ writeWarning("No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.json` file to the root of your workspace if it is not.\n", {
682
+ logLevel: "all"
683
+ });
684
+ }
685
+ result = await StormConfigSchema.parseAsync(defu2(configEnv, configFile, defaultConfig));
686
+ result.workspaceRoot ??= _workspaceRoot;
687
+ } else {
688
+ result = _static_cache.data;
689
+ }
690
+ if (schema && extensionName) {
691
+ result.extensions = {
692
+ ...result.extensions,
693
+ [extensionName]: createConfigExtension(extensionName, schema)
694
+ };
530
695
  }
531
- config = defu2(getConfigEnv(), configFile, getDefaultConfig(_workspaceRoot));
696
+ _static_cache = {
697
+ timestamp: Date.now(),
698
+ data: result
699
+ };
700
+ return result;
701
+ }, "createStormConfig");
702
+ var createConfigExtension = /* @__PURE__ */ __name((extensionName, schema) => {
703
+ const extension_cache_key = {
704
+ extensionName
705
+ };
706
+ if (_extension_cache.has(extension_cache_key)) {
707
+ return _extension_cache.get(extension_cache_key);
708
+ }
709
+ let extension = getExtensionEnv(extensionName);
710
+ if (schema) {
711
+ extension = schema.parse(extension);
712
+ }
713
+ _extension_cache.set(extension_cache_key, extension);
714
+ return extension;
715
+ }, "createConfigExtension");
716
+ var loadStormConfig = /* @__PURE__ */ __name(async (workspaceRoot, skipLogs = false) => {
717
+ const config = await createStormConfig(void 0, void 0, workspaceRoot, skipLogs);
532
718
  setConfigEnv(config);
533
- writeTrace(`\u2699\uFE0F Using Storm configuration:
719
+ if (!skipLogs) {
720
+ writeTrace(`\u2699\uFE0F Using Storm configuration:
534
721
  ${formatLogMessage(config)}`, config);
722
+ }
535
723
  return config;
536
724
  }, "loadStormConfig");
537
725
 
538
- // ../build-tools/src/utilities/read-nx-config.ts
539
- import { existsSync } from "node:fs";
540
- import { readFile } from "node:fs/promises";
541
- var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
542
- let rootDir = workspaceRoot;
543
- if (!rootDir) {
544
- const config = await loadStormConfig();
545
- rootDir = config.workspaceRoot;
546
- }
547
- const nxJsonPath = joinPaths(rootDir, "nx.json");
548
- if (!existsSync(nxJsonPath)) {
549
- throw new Error("Cannot find project.json configuration");
550
- }
551
- const configContent = await readFile(nxJsonPath, "utf8");
552
- return JSON.parse(configContent);
553
- }, "readNxConfig");
726
+ // ../config-tools/src/get-config.ts
727
+ var getConfig = /* @__PURE__ */ __name((workspaceRoot, skipLogs = false) => {
728
+ return loadStormConfig(workspaceRoot, skipLogs);
729
+ }, "getConfig");
554
730
 
555
- // ../build-tools/src/utilities/copy-assets.ts
556
- var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, projectRoot, projectName, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
557
- const pendingAssets = Array.from(assets ?? []);
558
- pendingAssets.push({
559
- input: projectRoot,
560
- glob: "*.md",
561
- output: "."
562
- });
563
- pendingAssets.push({
564
- input: config.workspaceRoot,
565
- glob: "LICENSE",
566
- output: "."
567
- });
568
- if (generatePackageJson2 === false) {
569
- pendingAssets.push({
570
- input: projectRoot,
571
- glob: "package.json",
572
- output: "."
573
- });
574
- }
575
- if (includeSrc === true) {
576
- pendingAssets.push({
577
- input: sourceRoot,
578
- glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
579
- output: "src/"
580
- });
581
- }
582
- const nxJson = readNxConfig(config.workspaceRoot);
583
- const projectGraph = readCachedProjectGraph();
584
- const projectsConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
585
- if (!projectsConfigurations?.projects?.[projectName]) {
586
- throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
587
- }
588
- const buildTarget = projectsConfigurations.projects[projectName].targets?.build;
589
- if (!buildTarget) {
590
- throw new Error(`The Build process failed because the project does not have a valid build target in the project.json file. Check if the file exists in the root of the project at ${joinPaths(projectRoot, "project.json")}`);
591
- }
592
- writeTrace(`\u{1F4DD} Copying the following assets to the output directory:
593
- ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`, config);
594
- const result = await copyAssetsBase({
595
- assets: pendingAssets,
596
- watch: false,
597
- outputPath
598
- }, {
599
- root: config.workspaceRoot,
600
- targetName: "build",
601
- target: buildTarget,
602
- projectName,
603
- projectGraph,
604
- projectsConfigurations,
605
- nxJsonConfiguration: nxJson,
606
- cwd: config.workspaceRoot,
607
- isVerbose: isVerbose(config.logLevel)
608
- });
609
- if (!result.success) {
610
- throw new Error("The Build process failed trying to copy assets");
611
- }
612
- if (includeSrc === true) {
613
- writeDebug(`\u{1F4DD} Adding banner and writing source files: ${joinPaths(outputPath, "src")}`, config);
614
- const files = await glob([
615
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
616
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
617
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
618
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
619
- ]);
620
- await Promise.allSettled(files.map(async (file) => writeFile(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
621
-
622
- ${await readFile2(file, "utf8")}
623
-
624
- ${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
625
- }
626
- }, "copyAssets");
731
+ // ../build-tools/src/utilities/get-entry-points.ts
732
+ import { glob as glob2 } from "glob";
627
733
 
628
- // ../build-tools/src/utilities/generate-package-json.ts
629
- import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
630
- import { Glob } from "glob";
734
+ // ../build-tools/src/utilities/read-nx-config.ts
631
735
  import { existsSync as existsSync2 } from "node:fs";
632
736
  import { readFile as readFile3 } from "node:fs/promises";
633
- import { readCachedProjectGraph as readCachedProjectGraph2 } from "nx/src/project-graph/project-graph";
634
- var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projectRoot, projectName, packageJson) => {
635
- const projectDependencies = calculateProjectBuildableDependencies(void 0, readCachedProjectGraph2(), workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
636
- const localPackages = [];
637
- for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
638
- const projectNode = project.node;
639
- if (projectNode.data.root) {
640
- const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
641
- if (existsSync2(projectPackageJsonPath)) {
642
- const projectPackageJsonContent = await readFile3(projectPackageJsonPath, "utf8");
643
- const projectPackageJson = JSON.parse(projectPackageJsonContent);
644
- if (projectPackageJson.private !== false) {
645
- localPackages.push(projectPackageJson);
646
- }
647
- }
648
- }
649
- }
650
- if (localPackages.length > 0) {
651
- writeTrace(`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
652
- packageJson.peerDependencies = localPackages.reduce((ret, localPackage) => {
653
- if (!ret[localPackage.name]) {
654
- ret[localPackage.name] = `>=${localPackage.version || "0.0.1"}`;
655
- }
656
- return ret;
657
- }, packageJson.peerDependencies ?? {});
658
- packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
659
- if (!ret[localPackage.name]) {
660
- ret[localPackage.name] = {
661
- optional: false
662
- };
663
- }
664
- return ret;
665
- }, packageJson.peerDependenciesMeta ?? {});
666
- packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
667
- if (!ret[localPackage.name]) {
668
- ret[localPackage.name] = localPackage.version || "0.0.1";
669
- }
670
- return ret;
671
- }, packageJson.peerDependencies ?? {});
672
- } else {
673
- writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
674
- }
675
- return packageJson;
676
- }, "addPackageDependencies");
677
- var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
678
- const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
679
- const workspacePackageJsonContent = await readFile3(joinPaths(workspaceRoot, "package.json"), "utf8");
680
- const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
681
- packageJson.type ??= "module";
682
- packageJson.sideEffects ??= false;
683
- if (includeSrc === true) {
684
- let distSrc = sourceRoot.replace(projectRoot, "");
685
- if (distSrc.startsWith("/")) {
686
- distSrc = distSrc.substring(1);
687
- }
688
- packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
689
- }
690
- packageJson.files ??= [
691
- "dist/**/*"
692
- ];
693
- if (includeSrc === true && !packageJson.files.includes("src")) {
694
- packageJson.files.push("src/**/*");
695
- }
696
- packageJson.publishConfig ??= {
697
- access: "public"
698
- };
699
- packageJson.description ??= workspacePackageJson.description;
700
- packageJson.homepage ??= workspacePackageJson.homepage;
701
- packageJson.bugs ??= workspacePackageJson.bugs;
702
- packageJson.license ??= workspacePackageJson.license;
703
- packageJson.keywords ??= workspacePackageJson.keywords;
704
- packageJson.funding ??= workspacePackageJson.funding;
705
- packageJson.author ??= workspacePackageJson.author;
706
- packageJson.maintainers ??= workspacePackageJson.maintainers;
707
- if (!packageJson.maintainers && packageJson.author) {
708
- packageJson.maintainers = [
709
- packageJson.author
710
- ];
711
- }
712
- packageJson.contributors ??= workspacePackageJson.contributors;
713
- if (!packageJson.contributors && packageJson.author) {
714
- packageJson.contributors = [
715
- packageJson.author
716
- ];
717
- }
718
- packageJson.repository ??= workspacePackageJson.repository;
719
- packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
720
- return packageJson;
721
- }, "addWorkspacePackageJsonFields");
722
-
723
- // ../build-tools/src/utilities/get-entry-points.ts
724
- import { glob as glob2 } from "glob";
725
737
 
726
738
  // ../build-tools/src/utilities/task-graph.ts
727
739
  import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-runner/create-task-graph";
@@ -2176,7 +2188,7 @@ async function resolveOptions(options, config) {
2176
2188
  }
2177
2189
  }
2178
2190
  const outputPath = options.outputPath || joinPaths("dist", options.projectRoot);
2179
- const projectGraph = readCachedProjectGraph3();
2191
+ const projectGraph = readCachedProjectGraph2();
2180
2192
  const projectJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "project.json");
2181
2193
  if (!existsSync4(projectJsonPath)) {
2182
2194
  throw new Error("Cannot find project.json configuration");
@@ -2453,7 +2465,7 @@ __name(executeUnbuild, "executeUnbuild");
2453
2465
  async function copyBuildAssets(options) {
2454
2466
  writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`, options.config);
2455
2467
  const stopwatch = getStopwatch(`${options.name} asset copy`);
2456
- await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.projectName, options.sourceRoot, options.generatePackageJson, options.includeSrc);
2468
+ await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.sourceRoot, options.generatePackageJson, options.includeSrc);
2457
2469
  stopwatch();
2458
2470
  return options;
2459
2471
  }
@@ -2477,7 +2489,7 @@ async function build2(options) {
2477
2489
  if (!workspaceRoot) {
2478
2490
  throw new Error("Cannot find workspace root");
2479
2491
  }
2480
- const config = await loadStormConfig(workspaceRoot.dir);
2492
+ const config = await getConfig(workspaceRoot.dir);
2481
2493
  writeDebug(` \u26A1 Executing Storm Unbuild pipeline`, config);
2482
2494
  const stopwatch = getStopwatch("Unbuild pipeline");
2483
2495
  try {
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkFG6XQ26Mcjs = require('./chunk-FG6XQ26M.cjs');
4
+ var _chunkLXCK6Y4Ccjs = require('./chunk-LXCK6Y4C.cjs');
5
5
 
6
6
 
7
7
  var _chunkYDYGZTJKcjs = require('./chunk-YDYGZTJK.cjs');
@@ -9,8 +9,8 @@ var _chunkYDYGZTJKcjs = require('./chunk-YDYGZTJK.cjs');
9
9
  // src/clean.ts
10
10
  var _promises = require('fs/promises');
11
11
  async function clean(name = "Unbuild", directory, config) {
12
- _chunkFG6XQ26Mcjs.writeDebug.call(void 0, ` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
13
- const stopwatch = _chunkFG6XQ26Mcjs.getStopwatch.call(void 0, `${name} output clean`);
12
+ _chunkLXCK6Y4Ccjs.writeDebug.call(void 0, ` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
13
+ const stopwatch = _chunkLXCK6Y4Ccjs.getStopwatch.call(void 0, `${name} output clean`);
14
14
  await cleanDirectories(name, directory, config);
15
15
  stopwatch();
16
16
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  writeError
3
- } from "./chunk-TPFSDZCR.js";
3
+ } from "./chunk-VWXW3RW5.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-3GQAWCBQ.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkFG6XQ26Mcjs = require('./chunk-FG6XQ26M.cjs');
3
+ var _chunkLXCK6Y4Ccjs = require('./chunk-LXCK6Y4C.cjs');
4
4
 
5
5
 
6
6
  var _chunkYDYGZTJKcjs = require('./chunk-YDYGZTJK.cjs');
@@ -10,7 +10,7 @@ var onErrorPlugin = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.call(void 0, (optio
10
10
  name: "storm:on-error",
11
11
  buildEnd(error) {
12
12
  if (error) {
13
- _chunkFG6XQ26Mcjs.writeError.call(void 0, `The following errors occurred during the build:
13
+ _chunkLXCK6Y4Ccjs.writeError.call(void 0, `The following errors occurred during the build:
14
14
  ${error ? error.message : "Unknown build error"}
15
15
 
16
16
  `, resolvedOptions.config);
@@ -18,7 +18,7 @@ ${error ? error.message : "Unknown build error"}
18
18
  }
19
19
  },
20
20
  renderError(error) {
21
- _chunkFG6XQ26Mcjs.writeError.call(void 0, `The following errors occurred during the build:
21
+ _chunkLXCK6Y4Ccjs.writeError.call(void 0, `The following errors occurred during the build:
22
22
  ${error ? error.message : "Unknown build error"}
23
23
 
24
24
  `, resolvedOptions.config);
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkFG6XQ26Mcjs = require('./chunk-FG6XQ26M.cjs');
3
+ var _chunkLXCK6Y4Ccjs = require('./chunk-LXCK6Y4C.cjs');
4
4
 
5
5
 
6
6
  var _chunkYDYGZTJKcjs = require('./chunk-YDYGZTJK.cjs');
@@ -25,7 +25,7 @@ var analyzePlugin = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.call(void 0, (optio
25
25
  renderChunk(source, chunk) {
26
26
  const sourceBytes = formatBytes(source.length);
27
27
  const fileName = chunk.fileName;
28
- _chunkFG6XQ26Mcjs.writeInfo.call(void 0, ` - ${fileName} ${sourceBytes}`, resolvedOptions.config);
28
+ _chunkLXCK6Y4Ccjs.writeInfo.call(void 0, ` - ${fileName} ${sourceBytes}`, resolvedOptions.config);
29
29
  }
30
30
  };
31
31
  }, "analyzePlugin");