@storm-software/tsdown 0.22.2 → 0.22.4

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.
@@ -4,6 +4,7 @@ import {
4
4
  STORM_DEFAULT_DOCS,
5
5
  STORM_DEFAULT_HOMEPAGE,
6
6
  STORM_DEFAULT_LICENSING,
7
+ StormConfigSchema,
7
8
  clean,
8
9
  correctPaths,
9
10
  findWorkspaceRoot,
@@ -17,10 +18,9 @@ import {
17
18
  writeDebug,
18
19
  writeFatal,
19
20
  writeSuccess,
20
- writeSystem,
21
21
  writeTrace,
22
22
  writeWarning
23
- } from "./chunk-MLTU5LTF.js";
23
+ } from "./chunk-QVK624ZI.js";
24
24
  import {
25
25
  DEFAULT_BUILD_OPTIONS
26
26
  } from "./chunk-UQLCBJOS.js";
@@ -30,7 +30,7 @@ import {
30
30
 
31
31
  // src/build.ts
32
32
  import { hfs } from "@humanfs/node";
33
- import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph2, writeJsonFile } from "@nx/devkit";
33
+ import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph, writeJsonFile } from "@nx/devkit";
34
34
 
35
35
  // ../build-tools/src/config.ts
36
36
  var DEFAULT_ENVIRONMENT = "production";
@@ -51,29 +51,193 @@ import { stripIndents } from "@nx/devkit";
51
51
  import { relative } from "path";
52
52
 
53
53
  // ../build-tools/src/utilities/copy-assets.ts
54
- import { readCachedProjectGraph, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
55
- import { copyAssets as copyAssetsBase } from "@nx/js";
54
+ import { CopyAssetsHandler } from "@nx/js/src/utils/assets/copy-assets-handler";
56
55
  import { glob } from "glob";
57
- import { readFile as readFile2, writeFile } from "node:fs/promises";
56
+ import { readFile, writeFile } from "node:fs/promises";
57
+ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, projectRoot, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
58
+ const pendingAssets = Array.from(assets ?? []);
59
+ pendingAssets.push({
60
+ input: projectRoot,
61
+ glob: "*.md",
62
+ output: "."
63
+ });
64
+ pendingAssets.push({
65
+ input: ".",
66
+ glob: "LICENSE",
67
+ output: "."
68
+ });
69
+ if (generatePackageJson2 === false) {
70
+ pendingAssets.push({
71
+ input: projectRoot,
72
+ glob: "package.json",
73
+ output: "."
74
+ });
75
+ }
76
+ if (includeSrc === true) {
77
+ pendingAssets.push({
78
+ input: sourceRoot,
79
+ glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
80
+ output: "src/"
81
+ });
82
+ }
83
+ writeTrace(`\u{1F4DD} Copying the following assets to the output directory:
84
+ ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`, config);
85
+ const assetHandler = new CopyAssetsHandler({
86
+ projectDir: projectRoot,
87
+ rootDir: config.workspaceRoot,
88
+ outputDir: outputPath,
89
+ assets: pendingAssets
90
+ });
91
+ await assetHandler.processAllAssetsOnce();
92
+ if (includeSrc === true) {
93
+ writeDebug(`\u{1F4DD} Adding banner and writing source files: ${joinPaths(outputPath, "src")}`, config);
94
+ const files = await glob([
95
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
96
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
97
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
98
+ joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
99
+ ]);
100
+ await Promise.allSettled(files.map(async (file) => writeFile(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
101
+
102
+ ${await readFile(file, "utf8")}
103
+
104
+ ${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
105
+ }
106
+ }, "copyAssets");
107
+
108
+ // ../build-tools/src/utilities/generate-package-json.ts
109
+ import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
110
+ import { Glob } from "glob";
111
+ import { existsSync } from "node:fs";
112
+ import { readFile as readFile2 } from "node:fs/promises";
113
+ import { readCachedProjectGraph } from "nx/src/project-graph/project-graph";
114
+ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projectRoot, projectName, packageJson) => {
115
+ const projectDependencies = calculateProjectBuildableDependencies(void 0, readCachedProjectGraph(), workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
116
+ const localPackages = [];
117
+ for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
118
+ const projectNode = project.node;
119
+ if (projectNode.data.root) {
120
+ const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
121
+ if (existsSync(projectPackageJsonPath)) {
122
+ const projectPackageJsonContent = await readFile2(projectPackageJsonPath, "utf8");
123
+ const projectPackageJson = JSON.parse(projectPackageJsonContent);
124
+ if (projectPackageJson.private !== false) {
125
+ localPackages.push(projectPackageJson);
126
+ }
127
+ }
128
+ }
129
+ }
130
+ if (localPackages.length > 0) {
131
+ writeTrace(`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
132
+ packageJson.peerDependencies = localPackages.reduce((ret, localPackage) => {
133
+ if (!ret[localPackage.name]) {
134
+ ret[localPackage.name] = `>=${localPackage.version || "0.0.1"}`;
135
+ }
136
+ return ret;
137
+ }, packageJson.peerDependencies ?? {});
138
+ packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
139
+ if (!ret[localPackage.name]) {
140
+ ret[localPackage.name] = {
141
+ optional: false
142
+ };
143
+ }
144
+ return ret;
145
+ }, packageJson.peerDependenciesMeta ?? {});
146
+ packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
147
+ if (!ret[localPackage.name]) {
148
+ ret[localPackage.name] = localPackage.version || "0.0.1";
149
+ }
150
+ return ret;
151
+ }, packageJson.peerDependencies ?? {});
152
+ } else {
153
+ writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
154
+ }
155
+ return packageJson;
156
+ }, "addPackageDependencies");
157
+ var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
158
+ const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
159
+ const workspacePackageJsonContent = await readFile2(joinPaths(workspaceRoot, "package.json"), "utf8");
160
+ const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
161
+ packageJson.type ??= "module";
162
+ packageJson.sideEffects ??= false;
163
+ if (includeSrc === true) {
164
+ let distSrc = sourceRoot.replace(projectRoot, "");
165
+ if (distSrc.startsWith("/")) {
166
+ distSrc = distSrc.substring(1);
167
+ }
168
+ packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
169
+ }
170
+ packageJson.files ??= [
171
+ "dist/**/*"
172
+ ];
173
+ if (includeSrc === true && !packageJson.files.includes("src")) {
174
+ packageJson.files.push("src/**/*");
175
+ }
176
+ packageJson.publishConfig ??= {
177
+ access: "public"
178
+ };
179
+ packageJson.description ??= workspacePackageJson.description;
180
+ packageJson.homepage ??= workspacePackageJson.homepage;
181
+ packageJson.bugs ??= workspacePackageJson.bugs;
182
+ packageJson.license ??= workspacePackageJson.license;
183
+ packageJson.keywords ??= workspacePackageJson.keywords;
184
+ packageJson.funding ??= workspacePackageJson.funding;
185
+ packageJson.author ??= workspacePackageJson.author;
186
+ packageJson.maintainers ??= workspacePackageJson.maintainers;
187
+ if (!packageJson.maintainers && packageJson.author) {
188
+ packageJson.maintainers = [
189
+ packageJson.author
190
+ ];
191
+ }
192
+ packageJson.contributors ??= workspacePackageJson.contributors;
193
+ if (!packageJson.contributors && packageJson.author) {
194
+ packageJson.contributors = [
195
+ packageJson.author
196
+ ];
197
+ }
198
+ packageJson.repository ??= workspacePackageJson.repository;
199
+ packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
200
+ return packageJson;
201
+ }, "addWorkspacePackageJsonFields");
202
+ var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
203
+ let entry = file.replaceAll("\\", "/");
204
+ if (sourceRoot) {
205
+ entry = entry.replace(sourceRoot, "");
206
+ }
207
+ return {
208
+ "import": {
209
+ "types": `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
210
+ "default": `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
211
+ },
212
+ "require": {
213
+ "types": `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
214
+ "default": `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
215
+ },
216
+ "default": {
217
+ "types": `./dist/${entry}.d.ts`,
218
+ "default": `./dist/${entry}.js`
219
+ }
220
+ };
221
+ }, "addPackageJsonExport");
58
222
 
59
223
  // ../config-tools/src/config-file/get-config-file.ts
60
224
  import { loadConfig } from "c12";
61
225
  import defu from "defu";
62
226
  var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, options = {}) => {
63
227
  const workspacePath = filePath || findWorkspaceRoot(filePath);
64
- let config = await loadConfig({
65
- cwd: workspacePath,
66
- packageJson: true,
67
- name: fileName,
68
- envName: fileName?.toUpperCase(),
69
- jitiOptions: {
70
- debug: false,
71
- fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
72
- },
73
- ...options
74
- });
75
- if (!config || Object.keys(config).length === 0) {
76
- config = await loadConfig({
228
+ const configs = await Promise.all([
229
+ loadConfig({
230
+ cwd: workspacePath,
231
+ packageJson: true,
232
+ name: fileName,
233
+ envName: fileName?.toUpperCase(),
234
+ jitiOptions: {
235
+ debug: false,
236
+ fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
237
+ },
238
+ ...options
239
+ }),
240
+ loadConfig({
77
241
  cwd: workspacePath,
78
242
  packageJson: true,
79
243
  name: fileName,
@@ -84,9 +248,9 @@ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, opti
84
248
  },
85
249
  configFile: fileName,
86
250
  ...options
87
- });
88
- }
89
- return config;
251
+ })
252
+ ]);
253
+ return defu(configs[0] ?? {}, configs[1] ?? {});
90
254
  }, "getConfigFileByName");
91
255
  var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames = []) => {
92
256
  const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
@@ -94,7 +258,7 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
94
258
  let config = result.config;
95
259
  const configFile = result.configFile;
96
260
  if (config && configFile && Object.keys(config).length > 0) {
97
- writeSystem(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
261
+ writeTrace(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
98
262
  logLevel: "all"
99
263
  });
100
264
  }
@@ -102,7 +266,7 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
102
266
  const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
103
267
  for (const result2 of results) {
104
268
  if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
105
- writeSystem(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
269
+ writeTrace(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
106
270
  logLevel: "all"
107
271
  });
108
272
  config = defu(result2.config ?? {}, config ?? {});
@@ -120,6 +284,16 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
120
284
  import defu2 from "defu";
121
285
 
122
286
  // ../config-tools/src/env/get-env.ts
287
+ var getExtensionEnv = /* @__PURE__ */ __name((extensionName) => {
288
+ const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
289
+ return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
290
+ const name = key.replace(prefix, "").split("_").map((i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : "").join("");
291
+ if (name) {
292
+ ret[name] = process.env[key];
293
+ }
294
+ return ret;
295
+ }, {});
296
+ }, "getExtensionEnv");
123
297
  var getConfigEnv = /* @__PURE__ */ __name(() => {
124
298
  const prefix = "STORM_";
125
299
  let config = {
@@ -279,7 +453,7 @@ var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
279
453
  var setConfigEnv = /* @__PURE__ */ __name((config) => {
280
454
  const prefix = "STORM_";
281
455
  if (config.extends) {
282
- process.env[`${prefix}EXTENDS`] = config.extends;
456
+ process.env[`${prefix}EXTENDS`] = Array.isArray(config.extends) ? JSON.stringify(config.extends) : config.extends;
283
457
  }
284
458
  if (config.name) {
285
459
  process.env[`${prefix}NAME`] = config.name;
@@ -509,234 +683,68 @@ var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
509
683
  }, "setBaseThemeColorConfigEnv");
510
684
 
511
685
  // ../config-tools/src/create-storm-config.ts
686
+ var _extension_cache = /* @__PURE__ */ new WeakMap();
512
687
  var _static_cache = void 0;
513
- var loadStormConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
514
- let config = {};
515
- if (_static_cache?.data && _static_cache?.timestamp && _static_cache.timestamp >= Date.now() + 3e4) {
516
- writeTrace(`Configuration cache hit - ${_static_cache.timestamp}`, _static_cache.data);
517
- return _static_cache.data;
518
- }
519
- let _workspaceRoot = workspaceRoot;
520
- if (!_workspaceRoot) {
521
- _workspaceRoot = findWorkspaceRoot();
522
- }
523
- const configFile = await getConfigFile(_workspaceRoot);
524
- if (!configFile) {
525
- 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", {
526
- logLevel: "all"
527
- });
528
- }
529
- config = defu2(getConfigEnv(), configFile, getDefaultConfig(_workspaceRoot));
530
- setConfigEnv(config);
531
- writeTrace(`\u2699\uFE0F Using Storm configuration:
532
- ${formatLogMessage(config)}`, config);
533
- return config;
534
- }, "loadStormConfig");
535
-
536
- // ../build-tools/src/utilities/read-nx-config.ts
537
- import { existsSync } from "node:fs";
538
- import { readFile } from "node:fs/promises";
539
- var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
540
- let rootDir = workspaceRoot;
541
- if (!rootDir) {
542
- const config = await loadStormConfig();
543
- rootDir = config.workspaceRoot;
544
- }
545
- const nxJsonPath = joinPaths(rootDir, "nx.json");
546
- if (!existsSync(nxJsonPath)) {
547
- throw new Error("Cannot find project.json configuration");
548
- }
549
- const configContent = await readFile(nxJsonPath, "utf8");
550
- return JSON.parse(configContent);
551
- }, "readNxConfig");
552
-
553
- // ../build-tools/src/utilities/copy-assets.ts
554
- var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, projectRoot, projectName, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
555
- const pendingAssets = Array.from(assets ?? []);
556
- pendingAssets.push({
557
- input: projectRoot,
558
- glob: "*.md",
559
- output: "."
560
- });
561
- pendingAssets.push({
562
- input: config.workspaceRoot,
563
- glob: "LICENSE",
564
- output: "."
565
- });
566
- if (generatePackageJson2 === false) {
567
- pendingAssets.push({
568
- input: projectRoot,
569
- glob: "package.json",
570
- output: "."
571
- });
572
- }
573
- if (includeSrc === true) {
574
- pendingAssets.push({
575
- input: sourceRoot,
576
- glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
577
- output: "src/"
578
- });
579
- }
580
- const nxJson = readNxConfig(config.workspaceRoot);
581
- const projectGraph = readCachedProjectGraph();
582
- const projectsConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
583
- if (!projectsConfigurations?.projects?.[projectName]) {
584
- 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.");
585
- }
586
- const buildTarget = projectsConfigurations.projects[projectName].targets?.build;
587
- if (!buildTarget) {
588
- 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")}`);
589
- }
590
- writeTrace(`\u{1F4DD} Copying the following assets to the output directory:
591
- ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`, config);
592
- const result = await copyAssetsBase({
593
- assets: pendingAssets,
594
- watch: false,
595
- outputPath
596
- }, {
597
- root: config.workspaceRoot,
598
- targetName: "build",
599
- target: buildTarget,
600
- projectName,
601
- projectGraph,
602
- projectsConfigurations,
603
- nxJsonConfiguration: nxJson,
604
- cwd: config.workspaceRoot,
605
- isVerbose: isVerbose(config.logLevel)
606
- });
607
- if (!result.success) {
608
- throw new Error("The Build process failed trying to copy assets");
609
- }
610
- if (includeSrc === true) {
611
- writeDebug(`\u{1F4DD} Adding banner and writing source files: ${joinPaths(outputPath, "src")}`, config);
612
- const files = await glob([
613
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
614
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
615
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
616
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
617
- ]);
618
- await Promise.allSettled(files.map(async (file) => writeFile(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
619
-
620
- ${await readFile2(file, "utf8")}
621
-
622
- ${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
623
- }
624
- }, "copyAssets");
625
-
626
- // ../build-tools/src/utilities/generate-package-json.ts
627
- import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
628
- import { Glob } from "glob";
629
- import { existsSync as existsSync2 } from "node:fs";
630
- import { readFile as readFile3 } from "node:fs/promises";
631
- import { readCachedProjectGraph as readCachedProjectGraph2 } from "nx/src/project-graph/project-graph";
632
- var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projectRoot, projectName, packageJson) => {
633
- const projectDependencies = calculateProjectBuildableDependencies(void 0, readCachedProjectGraph2(), workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
634
- const localPackages = [];
635
- for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
636
- const projectNode = project.node;
637
- if (projectNode.data.root) {
638
- const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
639
- if (existsSync2(projectPackageJsonPath)) {
640
- const projectPackageJsonContent = await readFile3(projectPackageJsonPath, "utf8");
641
- const projectPackageJson = JSON.parse(projectPackageJsonContent);
642
- if (projectPackageJson.private !== false) {
643
- localPackages.push(projectPackageJson);
644
- }
645
- }
688
+ var createStormConfig = /* @__PURE__ */ __name(async (extensionName, schema, workspaceRoot, skipLogs = false) => {
689
+ let result;
690
+ if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
691
+ let _workspaceRoot = workspaceRoot;
692
+ if (!_workspaceRoot) {
693
+ _workspaceRoot = findWorkspaceRoot();
646
694
  }
647
- }
648
- if (localPackages.length > 0) {
649
- writeTrace(`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
650
- packageJson.peerDependencies = localPackages.reduce((ret, localPackage) => {
651
- if (!ret[localPackage.name]) {
652
- ret[localPackage.name] = `>=${localPackage.version || "0.0.1"}`;
653
- }
654
- return ret;
655
- }, packageJson.peerDependencies ?? {});
656
- packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
657
- if (!ret[localPackage.name]) {
658
- ret[localPackage.name] = {
659
- optional: false
660
- };
661
- }
662
- return ret;
663
- }, packageJson.peerDependenciesMeta ?? {});
664
- packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
665
- if (!ret[localPackage.name]) {
666
- ret[localPackage.name] = localPackage.version || "0.0.1";
667
- }
668
- return ret;
669
- }, packageJson.peerDependencies ?? {});
670
- } else {
671
- writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
672
- }
673
- return packageJson;
674
- }, "addPackageDependencies");
675
- var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
676
- const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
677
- const workspacePackageJsonContent = await readFile3(joinPaths(workspaceRoot, "package.json"), "utf8");
678
- const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
679
- packageJson.type ??= "module";
680
- packageJson.sideEffects ??= false;
681
- if (includeSrc === true) {
682
- let distSrc = sourceRoot.replace(projectRoot, "");
683
- if (distSrc.startsWith("/")) {
684
- distSrc = distSrc.substring(1);
695
+ const configEnv = getConfigEnv();
696
+ const defaultConfig = await getDefaultConfig(_workspaceRoot);
697
+ const configFile = await getConfigFile(_workspaceRoot);
698
+ if (!configFile && !skipLogs) {
699
+ 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", {
700
+ logLevel: "all"
701
+ });
685
702
  }
686
- packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
703
+ result = await StormConfigSchema.parseAsync(defu2(configEnv, configFile, defaultConfig));
704
+ result.workspaceRoot ??= _workspaceRoot;
705
+ } else {
706
+ result = _static_cache.data;
687
707
  }
688
- packageJson.files ??= [
689
- "dist/**/*"
690
- ];
691
- if (includeSrc === true && !packageJson.files.includes("src")) {
692
- packageJson.files.push("src/**/*");
708
+ if (schema && extensionName) {
709
+ result.extensions = {
710
+ ...result.extensions,
711
+ [extensionName]: createConfigExtension(extensionName, schema)
712
+ };
693
713
  }
694
- packageJson.publishConfig ??= {
695
- access: "public"
714
+ _static_cache = {
715
+ timestamp: Date.now(),
716
+ data: result
696
717
  };
697
- packageJson.description ??= workspacePackageJson.description;
698
- packageJson.homepage ??= workspacePackageJson.homepage;
699
- packageJson.bugs ??= workspacePackageJson.bugs;
700
- packageJson.license ??= workspacePackageJson.license;
701
- packageJson.keywords ??= workspacePackageJson.keywords;
702
- packageJson.funding ??= workspacePackageJson.funding;
703
- packageJson.author ??= workspacePackageJson.author;
704
- packageJson.maintainers ??= workspacePackageJson.maintainers;
705
- if (!packageJson.maintainers && packageJson.author) {
706
- packageJson.maintainers = [
707
- packageJson.author
708
- ];
709
- }
710
- packageJson.contributors ??= workspacePackageJson.contributors;
711
- if (!packageJson.contributors && packageJson.author) {
712
- packageJson.contributors = [
713
- packageJson.author
714
- ];
715
- }
716
- packageJson.repository ??= workspacePackageJson.repository;
717
- packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
718
- return packageJson;
719
- }, "addWorkspacePackageJsonFields");
720
- var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
721
- let entry = file.replaceAll("\\", "/");
722
- if (sourceRoot) {
723
- entry = entry.replace(sourceRoot, "");
724
- }
725
- return {
726
- "import": {
727
- "types": `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
728
- "default": `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
729
- },
730
- "require": {
731
- "types": `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
732
- "default": `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
733
- },
734
- "default": {
735
- "types": `./dist/${entry}.d.ts`,
736
- "default": `./dist/${entry}.js`
737
- }
718
+ return result;
719
+ }, "createStormConfig");
720
+ var createConfigExtension = /* @__PURE__ */ __name((extensionName, schema) => {
721
+ const extension_cache_key = {
722
+ extensionName
738
723
  };
739
- }, "addPackageJsonExport");
724
+ if (_extension_cache.has(extension_cache_key)) {
725
+ return _extension_cache.get(extension_cache_key);
726
+ }
727
+ let extension = getExtensionEnv(extensionName);
728
+ if (schema) {
729
+ extension = schema.parse(extension);
730
+ }
731
+ _extension_cache.set(extension_cache_key, extension);
732
+ return extension;
733
+ }, "createConfigExtension");
734
+ var loadStormConfig = /* @__PURE__ */ __name(async (workspaceRoot, skipLogs = false) => {
735
+ const config = await createStormConfig(void 0, void 0, workspaceRoot, skipLogs);
736
+ setConfigEnv(config);
737
+ if (!skipLogs) {
738
+ writeTrace(`\u2699\uFE0F Using Storm configuration:
739
+ ${formatLogMessage(config)}`, config);
740
+ }
741
+ return config;
742
+ }, "loadStormConfig");
743
+
744
+ // ../config-tools/src/get-config.ts
745
+ var getConfig = /* @__PURE__ */ __name((workspaceRoot, skipLogs = false) => {
746
+ return loadStormConfig(workspaceRoot, skipLogs);
747
+ }, "getConfig");
740
748
 
741
749
  // ../build-tools/src/utilities/get-entry-points.ts
742
750
  import { glob as glob2 } from "glob";
@@ -792,6 +800,10 @@ var getEnv = /* @__PURE__ */ __name((builder, options) => {
792
800
  };
793
801
  }, "getEnv");
794
802
 
803
+ // ../build-tools/src/utilities/read-nx-config.ts
804
+ import { existsSync as existsSync2 } from "node:fs";
805
+ import { readFile as readFile3 } from "node:fs/promises";
806
+
795
807
  // ../build-tools/src/utilities/task-graph.ts
796
808
  import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-runner/create-task-graph";
797
809
 
@@ -805,7 +817,7 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
805
817
  if (!workspaceRoot) {
806
818
  throw new Error("Cannot find Nx workspace root");
807
819
  }
808
- const config = await loadStormConfig(workspaceRoot.dir);
820
+ const config = await getConfig(workspaceRoot.dir);
809
821
  writeDebug(" \u2699\uFE0F Resolving build options", config);
810
822
  const stopwatch = getStopwatch("Build options resolution");
811
823
  const projectGraph = await createProjectGraphAsync({
@@ -817,7 +829,7 @@ var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
817
829
  }
818
830
  const projectJson = await hfs.json(projectJsonPath);
819
831
  const projectName = projectJson.name;
820
- const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
832
+ const projectConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
821
833
  if (!projectConfigurations?.projects?.[projectName]) {
822
834
  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.");
823
835
  }
@@ -947,7 +959,7 @@ __name(executeTSDown, "executeTSDown");
947
959
  async function copyBuildAssets(options) {
948
960
  writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outdir}`, options.config);
949
961
  const stopwatch = getStopwatch(`${options.name} asset copy`);
950
- await copyAssets(options.config, options.assets ?? [], options.outdir, options.projectRoot, options.projectName, options.sourceRoot, true, false);
962
+ await copyAssets(options.config, options.assets ?? [], options.outdir, options.projectRoot, options.sourceRoot, true, false);
951
963
  stopwatch();
952
964
  return options;
953
965
  }
package/dist/clean.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkEHVHDVI3cjs = require('./chunk-EHVHDVI3.cjs');
3
+ var _chunk2Z7WS4H3cjs = require('./chunk-2Z7WS4H3.cjs');
4
4
  require('./chunk-USNT2KNT.cjs');
5
5
 
6
6
 
7
- exports.clean = _chunkEHVHDVI3cjs.clean;
7
+ exports.clean = _chunk2Z7WS4H3cjs.clean;