@storm-software/workspace-tools 1.277.28 → 1.277.30

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +1 -1
  3. package/dist/chunk-36NLUQF5.mjs +41 -0
  4. package/dist/chunk-3CLZGETU.js +913 -0
  5. package/dist/chunk-3EGPC5BZ.mjs +32 -0
  6. package/dist/chunk-7LBU537S.mjs +253 -0
  7. package/dist/chunk-AWQW74DN.mjs +82 -0
  8. package/dist/chunk-B3D27MSZ.mjs +32 -0
  9. package/dist/chunk-CI2X75PQ.js +250 -0
  10. package/dist/chunk-EFVRHTH3.js +41 -0
  11. package/dist/chunk-L5J57I6V.js +32 -0
  12. package/dist/chunk-OECJG4M5.js +32 -0
  13. package/dist/chunk-ONVPEM3D.mjs +377 -0
  14. package/dist/chunk-QHAPAO2Z.js +377 -0
  15. package/dist/chunk-R7Q3ZOQ6.mjs +32 -0
  16. package/dist/chunk-RC3EGPJE.js +32 -0
  17. package/dist/chunk-RKKY5ZGW.mjs +31 -0
  18. package/dist/chunk-SXGMKPF6.js +31 -0
  19. package/dist/chunk-SY2PSJNN.mjs +913 -0
  20. package/dist/chunk-TD6Z3Z72.js +79 -0
  21. package/dist/executors.js +15 -15
  22. package/dist/executors.mjs +22 -22
  23. package/dist/generators.js +10 -10
  24. package/dist/generators.mjs +9 -9
  25. package/dist/index.js +48 -48
  26. package/dist/index.mjs +62 -62
  27. package/dist/src/base/index.js +8 -8
  28. package/dist/src/base/index.mjs +11 -11
  29. package/dist/src/executors/cargo-build/executor.js +3 -3
  30. package/dist/src/executors/cargo-build/executor.mjs +2 -2
  31. package/dist/src/executors/cargo-check/executor.js +3 -3
  32. package/dist/src/executors/cargo-check/executor.mjs +2 -2
  33. package/dist/src/executors/cargo-clippy/executor.js +3 -3
  34. package/dist/src/executors/cargo-clippy/executor.mjs +2 -2
  35. package/dist/src/executors/cargo-doc/executor.js +3 -3
  36. package/dist/src/executors/cargo-doc/executor.mjs +2 -2
  37. package/dist/src/executors/cargo-format/executor.js +3 -3
  38. package/dist/src/executors/cargo-format/executor.mjs +2 -2
  39. package/dist/src/executors/npm-publish/executor.js +1 -1
  40. package/dist/src/executors/npm-publish/executor.mjs +1 -1
  41. package/dist/src/generators/browser-library/generator.js +2 -2
  42. package/dist/src/generators/browser-library/generator.mjs +2 -2
  43. package/dist/src/generators/neutral-library/generator.js +2 -2
  44. package/dist/src/generators/neutral-library/generator.mjs +2 -2
  45. package/dist/src/generators/node-library/generator.js +4 -4
  46. package/dist/src/generators/node-library/generator.mjs +3 -3
  47. package/dist/src/generators/preset/generator.js +3 -3
  48. package/dist/src/generators/preset/generator.mjs +2 -2
  49. package/dist/src/generators/release-version/generator.js +3 -3
  50. package/dist/src/generators/release-version/generator.mjs +2 -2
  51. package/dist/src/plugins/rust/cargo-toml.js +3 -3
  52. package/dist/src/plugins/rust/cargo-toml.mjs +2 -2
  53. package/dist/src/plugins/rust/index.js +3 -3
  54. package/dist/src/plugins/rust/index.mjs +2 -2
  55. package/dist/src/utils/index.js +10 -10
  56. package/dist/src/utils/index.mjs +22 -22
  57. package/dist/src/utils/package-helpers.js +1 -1
  58. package/dist/src/utils/package-helpers.mjs +1 -1
  59. package/package.json +5 -5
@@ -0,0 +1,913 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkBDA4N25Ejs = require('./chunk-BDA4N25E.js');
4
+
5
+
6
+
7
+
8
+
9
+ var _chunkUXALGSQCjs = require('./chunk-UXALGSQC.js');
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ var _chunkBP22TRDIjs = require('./chunk-BP22TRDI.js');
19
+
20
+
21
+ var _chunk4WHSR4FKjs = require('./chunk-4WHSR4FK.js');
22
+
23
+ // src/generators/release-version/generator.ts
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ var _devkit = require('@nx/devkit');
32
+ var _resolvelocalpackagedependencies = require('@nx/js/src/generators/release-version/utils/resolve-local-package-dependencies');
33
+ var _updatelockfile = require('@nx/js/src/release/utils/update-lock-file');
34
+
35
+ // ../git-tools/src/types.ts
36
+ var COMMIT_TYPES = {
37
+ /* --- Bumps version when selected --- */
38
+ "chore": {
39
+ "description": "Other changes that don't modify src or test files",
40
+ "title": "Chore",
41
+ "emoji": "\u2699\uFE0F ",
42
+ "semverBump": "patch",
43
+ "changelog": {
44
+ "title": "Miscellaneous",
45
+ "hidden": false
46
+ }
47
+ },
48
+ "fix": {
49
+ "description": "A change that resolves an issue previously identified with the package",
50
+ "title": "Bug Fix",
51
+ "emoji": "\u{1FAB2} ",
52
+ "semverBump": "patch",
53
+ "changelog": {
54
+ "title": "Bug Fixes",
55
+ "hidden": false
56
+ }
57
+ },
58
+ "feat": {
59
+ "description": "A change that adds a new feature to the package",
60
+ "title": "Feature",
61
+ "emoji": "\u{1F511} ",
62
+ "semverBump": "minor",
63
+ "changelog": {
64
+ "title": "Features",
65
+ "hidden": false
66
+ }
67
+ },
68
+ "ci": {
69
+ "description": "Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)",
70
+ "title": "Continuous Integration",
71
+ "emoji": "\u{1F9F0} ",
72
+ "semverBump": "patch",
73
+ "changelog": {
74
+ "title": "Continuous Integration",
75
+ "hidden": false
76
+ }
77
+ },
78
+ "refactor": {
79
+ "description": "A code change that neither fixes a bug nor adds a feature",
80
+ "title": "Code Refactoring",
81
+ "emoji": "\u{1F9EA} ",
82
+ "semverBump": "patch",
83
+ "changelog": {
84
+ "title": "Source Code Improvements",
85
+ "hidden": false
86
+ }
87
+ },
88
+ "style": {
89
+ "description": "Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",
90
+ "title": "Style Improvements",
91
+ "emoji": "\u{1F48E} ",
92
+ "semverBump": "patch",
93
+ "changelog": {
94
+ "title": "Style Improvements",
95
+ "hidden": false
96
+ }
97
+ },
98
+ "perf": {
99
+ "description": "A code change that improves performance",
100
+ "title": "Performance Improvement",
101
+ "emoji": "\u23F1\uFE0F ",
102
+ "semverBump": "patch",
103
+ "changelog": {
104
+ "title": "Performance Improvements",
105
+ "hidden": false
106
+ }
107
+ },
108
+ /* --- Does not bump version when selected --- */
109
+ "docs": {
110
+ "description": "A change that only includes documentation updates",
111
+ "title": "Documentation",
112
+ "emoji": "\u{1F4DC} ",
113
+ "semverBump": "none",
114
+ "changelog": {
115
+ "title": "Documentation",
116
+ "hidden": false
117
+ }
118
+ },
119
+ "test": {
120
+ "description": "Adding missing tests or correcting existing tests",
121
+ "title": "Testing",
122
+ "emoji": "\u{1F6A8} ",
123
+ "semverBump": "none",
124
+ "changelog": {
125
+ "title": "Testing",
126
+ "hidden": true
127
+ }
128
+ },
129
+ /* --- Not included in commitlint but included in changelog --- */
130
+ "deps": {
131
+ "description": "Changes that add, update, or remove dependencies. This includes devDependencies and peerDependencies",
132
+ "title": "Dependencies",
133
+ "emoji": "\u{1F4E6} ",
134
+ "hidden": true,
135
+ "semverBump": "patch",
136
+ "changelog": {
137
+ "title": "Dependency Upgrades",
138
+ "hidden": false
139
+ }
140
+ },
141
+ /* --- Not included in commitlint or changelog --- */
142
+ "build": {
143
+ "description": "Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)",
144
+ "title": "Build",
145
+ "emoji": "\u{1F6E0} ",
146
+ "hidden": true,
147
+ "semverBump": "none",
148
+ "changelog": {
149
+ "title": "Build",
150
+ "hidden": true
151
+ }
152
+ },
153
+ "release": {
154
+ "description": "Publishing a commit containing a newly released version",
155
+ "title": "Publish Release",
156
+ "emoji": "\u{1F680} ",
157
+ "hidden": true,
158
+ "semverBump": "none",
159
+ "changelog": {
160
+ "title": "Publish Release",
161
+ "hidden": true
162
+ }
163
+ }
164
+ };
165
+ var DEFAULT_COMMIT_QUESTIONS = {
166
+ type: {
167
+ type: "select",
168
+ title: "Commit Type",
169
+ description: "Select the commit type that best describes your changes",
170
+ enum: Object.keys(COMMIT_TYPES).filter(
171
+ (type) => COMMIT_TYPES[type].hidden !== true
172
+ ).reduce((ret, type) => {
173
+ ret[type] = COMMIT_TYPES[type];
174
+ return ret;
175
+ }, {}),
176
+ defaultValue: "chore",
177
+ maxLength: 20,
178
+ minLength: 3
179
+ },
180
+ scope: {
181
+ type: "select",
182
+ title: "Commit Scope",
183
+ description: "Select the monorepo project that is primarily impacted by this change",
184
+ enum: {},
185
+ defaultValue: "monorepo",
186
+ maxLength: 50,
187
+ minLength: 1
188
+ },
189
+ subject: {
190
+ type: "input",
191
+ title: "Commit Subject",
192
+ description: "Write a short, imperative tense description of the change",
193
+ maxLength: 150,
194
+ minLength: 3
195
+ },
196
+ body: {
197
+ type: "input",
198
+ title: "Commit Body",
199
+ description: "Provide a longer description of the change",
200
+ maxLength: 600
201
+ },
202
+ isBreaking: {
203
+ type: "confirm",
204
+ title: "Breaking Changes",
205
+ description: "Are there any breaking changes as a result of this commit?",
206
+ defaultValue: false
207
+ },
208
+ breakingBody: {
209
+ type: "input",
210
+ title: "Breaking Changes (Details)",
211
+ description: "A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself",
212
+ when: (answers) => answers.isBreaking === true,
213
+ maxLength: 600,
214
+ minLength: 3
215
+ },
216
+ isIssueAffected: {
217
+ type: "confirm",
218
+ title: "Open Issue Affected",
219
+ description: "Does this change impact any open issues?",
220
+ defaultValue: false
221
+ },
222
+ issuesBody: {
223
+ type: "input",
224
+ title: "Open Issue Affected (Details)",
225
+ description: "If issues are closed, the commit requires a body. Please enter a longer description of the commit itself",
226
+ when: (answers) => answers.isIssueAffected === true,
227
+ maxLength: 600,
228
+ minLength: 3
229
+ }
230
+ };
231
+
232
+ // ../git-tools/src/release/config.ts
233
+ var DEFAULT_CONVENTIONAL_COMMITS_CONFIG = {
234
+ questions: DEFAULT_COMMIT_QUESTIONS,
235
+ types: COMMIT_TYPES
236
+ };
237
+
238
+ // src/generators/release-version/generator.ts
239
+ var _child_process = require('child_process');
240
+ var _path = require('path');
241
+ var _config = require('nx/src/command-line/release/config/config');
242
+
243
+
244
+
245
+ var _git = require('nx/src/command-line/release/utils/git');
246
+
247
+
248
+
249
+ var _resolvesemverspecifier = require('nx/src/command-line/release/utils/resolve-semver-specifier');
250
+ var _semver = require('nx/src/command-line/release/utils/semver');
251
+
252
+
253
+
254
+ var _versionlegacy = require('nx/src/command-line/release/version-legacy');
255
+ var _utils = require('nx/src/tasks-runner/utils');
256
+ var _semver3 = require('semver');
257
+ async function releaseVersionGeneratorFn(tree, options, config) {
258
+ _chunkBP22TRDIjs.writeInfo.call(void 0, `\u26A1 Running the Storm Release Version generator...
259
+
260
+ `, config);
261
+ const stopwatch = _chunkBP22TRDIjs.getStopwatch.call(void 0, "Storm Release Version generator");
262
+ try {
263
+ const workspaceRoot = _chunk4WHSR4FKjs.findWorkspaceRoot.call(void 0, );
264
+ _chunkBP22TRDIjs.writeDebug.call(void 0,
265
+ `Loading the Storm Config from environment variables and storm.config.js file...
266
+ - workspaceRoot: ${workspaceRoot}`,
267
+ config
268
+ );
269
+ config = await _chunkBDA4N25Ejs.getConfig.call(void 0, workspaceRoot);
270
+ _chunkBP22TRDIjs.writeTrace.call(void 0,
271
+ `Generator schema options \u2699\uFE0F
272
+ ${Object.keys(_nullishCoalesce(options, () => ( {}))).filter(
273
+ (key) => ![
274
+ "projects",
275
+ "releaseGroup",
276
+ "projectGraph",
277
+ "currentVersionResolverMetadata"
278
+ ].includes(key)
279
+ ).map((key) => ` - ${key}=${JSON.stringify(options[key])}`).join("\n")}`,
280
+ config
281
+ );
282
+ const versionData = {};
283
+ if (options.specifier) {
284
+ if (!_semver.isValidSemverSpecifier.call(void 0, options.specifier)) {
285
+ throw new Error(
286
+ `The given version specifier "${options.specifier}" is not valid. You provide an exact version or a valid semver keyword such as "major", "minor", "patch", etc.`
287
+ );
288
+ }
289
+ options.specifier = options.specifier.replace(/^v/, "");
290
+ }
291
+ if (options.versionPrefix && _versionlegacy.validReleaseVersionPrefixes.indexOf(
292
+ options.versionPrefix
293
+ ) === -1) {
294
+ throw new Error(
295
+ `Invalid value for version.generatorOptions.versionPrefix: "${options.versionPrefix}"
296
+
297
+ Valid values are: ${_versionlegacy.validReleaseVersionPrefixes.map((s) => `"${s}"`).join(", ")}`
298
+ );
299
+ }
300
+ options.fallbackCurrentVersionResolver ??= "disk";
301
+ options.currentVersionResolver ??= "git-tag";
302
+ const projects = options.projects;
303
+ const createResolvePackageRoot = (customPackageRoot) => (projectNode) => {
304
+ if (_optionalChain([projectNode, 'optionalAccess', _3 => _3.data, 'optionalAccess', _4 => _4.root]) === _optionalChain([config, 'optionalAccess', _5 => _5.workspaceRoot]) || _optionalChain([projectNode, 'optionalAccess', _6 => _6.data, 'optionalAccess', _7 => _7.root]) === ".") {
305
+ return _nullishCoalesce(_optionalChain([config, 'optionalAccess', _8 => _8.workspaceRoot]), () => ( _chunk4WHSR4FKjs.findWorkspaceRoot.call(void 0, )));
306
+ }
307
+ if (!customPackageRoot) {
308
+ return projectNode.data.root;
309
+ }
310
+ return _utils.interpolate.call(void 0, customPackageRoot, {
311
+ workspaceRoot: "",
312
+ projectRoot: projectNode.data.root,
313
+ projectName: projectNode.name
314
+ });
315
+ };
316
+ const resolvePackageRoot = createResolvePackageRoot(options.packageRoot);
317
+ const projectNameToPackageRootMap = /* @__PURE__ */ new Map();
318
+ for (const project of projects) {
319
+ projectNameToPackageRootMap.set(
320
+ project.name,
321
+ resolvePackageRoot(project)
322
+ );
323
+ }
324
+ let currentVersion = null;
325
+ let currentVersionResolvedFromFallback = false;
326
+ let latestMatchingGitTag = null;
327
+ let specifier = options.specifier ? options.specifier : void 0;
328
+ for (const project of projects) {
329
+ const projectName = project.name;
330
+ const packageRoot = projectNameToPackageRootMap.get(projectName);
331
+ const packageJsonPath = _devkit.joinPathFragments.call(void 0,
332
+ _nullishCoalesce(packageRoot, () => ( "./")),
333
+ "package.json"
334
+ );
335
+ const cargoTomlPath = _devkit.joinPathFragments.call(void 0,
336
+ _nullishCoalesce(packageRoot, () => ( "./")),
337
+ "Cargo.toml"
338
+ );
339
+ if (!tree.exists(packageJsonPath) && !tree.exists(cargoTomlPath)) {
340
+ throw new Error(
341
+ `The project "${projectName}" does not have a package.json available at ${packageJsonPath} or a Cargo.toml file available at ${cargoTomlPath}.
342
+
343
+ To fix this you will either need to add a package.json or Cargo.toml file at that location, or configure "release" within your nx.json to exclude "${projectName}" from the current release group, or amend the packageRoot configuration to point to where the package.json should be.`
344
+ );
345
+ }
346
+ const workspaceRelativePackagePath = _path.relative.call(void 0,
347
+ _nullishCoalesce(_optionalChain([config, 'optionalAccess', _9 => _9.workspaceRoot]), () => ( _chunk4WHSR4FKjs.findWorkspaceRoot.call(void 0, ))),
348
+ tree.exists(packageJsonPath) ? packageJsonPath : cargoTomlPath
349
+ );
350
+ const log = (msg) => {
351
+ _chunkBP22TRDIjs.writeInfo.call(void 0, `${projectName}: ${msg}`, config);
352
+ };
353
+ _chunkBP22TRDIjs.writeInfo.call(void 0, `Running release version for project: ${project.name}`, config);
354
+ let packageName;
355
+ let currentVersionFromDisk;
356
+ if (tree.exists(packageJsonPath)) {
357
+ const projectPackageJson = _devkit.readJson.call(void 0, tree, packageJsonPath);
358
+ log(
359
+ `\u{1F50D} Reading data for package "${projectPackageJson.name}" from ${workspaceRelativePackagePath}`
360
+ );
361
+ packageName = projectPackageJson.name;
362
+ currentVersionFromDisk = projectPackageJson.version;
363
+ } else if (tree.exists(cargoTomlPath)) {
364
+ const cargoToml = _chunkUXALGSQCjs.parseCargoToml.call(void 0,
365
+ _optionalChain([tree, 'access', _10 => _10.read, 'call', _11 => _11(cargoTomlPath), 'optionalAccess', _12 => _12.toString, 'call', _13 => _13("utf-8")])
366
+ );
367
+ log(
368
+ `\u{1F50D} Reading data for package "${cargoToml.package.name}" from ${workspaceRelativePackagePath}`
369
+ );
370
+ packageName = cargoToml.package.name;
371
+ currentVersionFromDisk = cargoToml.package.version;
372
+ if (options.currentVersionResolver === "registry") {
373
+ options.currentVersionResolver = "disk";
374
+ }
375
+ } else {
376
+ throw new Error(
377
+ `The project "${projectName}" does not have a package.json available at ${workspaceRelativePackagePath} or a Cargo.toml file available at ${cargoTomlPath}.
378
+
379
+ To fix this you will either need to add a package.json or Cargo.toml file at that location, or configure "release" within your nx.json to exclude "${projectName}" from the current release group, or amend the packageRoot configuration to point to where the package.json should be.`
380
+ );
381
+ }
382
+ switch (options.currentVersionResolver) {
383
+ case "registry": {
384
+ const metadata = options.currentVersionResolverMetadata;
385
+ const npmRegistry = await _asyncNullishCoalesce(await _asyncOptionalChain([metadata, 'optionalAccess', async _14 => _14.registry]), async () => ( await getNpmRegistry()));
386
+ const githubRegistry = await _asyncNullishCoalesce(await _asyncOptionalChain([metadata, 'optionalAccess', async _15 => _15.registry]), async () => ( await getGitHubRegistry()));
387
+ const tag = _nullishCoalesce(_optionalChain([metadata, 'optionalAccess', _16 => _16.tag]), () => ( "latest"));
388
+ if (options.releaseGroup.projectsRelationship === "independent") {
389
+ try {
390
+ currentVersion = await new Promise((resolve, reject) => {
391
+ _child_process.exec.call(void 0,
392
+ `npm view ${packageName} version --registry=${npmRegistry} --tag=${tag}`,
393
+ (error, stdout, stderr) => {
394
+ if (error) {
395
+ return reject(error);
396
+ }
397
+ if (stderr) {
398
+ return reject(stderr);
399
+ }
400
+ return resolve(stdout.trim());
401
+ }
402
+ );
403
+ });
404
+ log(
405
+ `\u{1F4C4} Resolved the current version as ${currentVersion} for tag "${tag}" from registry ${npmRegistry}`
406
+ );
407
+ } catch (_) {
408
+ try {
409
+ currentVersion = await new Promise(
410
+ (resolve, reject) => {
411
+ _child_process.exec.call(void 0,
412
+ `npm view ${packageName} version --registry=${githubRegistry} --tag=${tag}`,
413
+ (error, stdout, stderr) => {
414
+ if (error) {
415
+ return reject(error);
416
+ }
417
+ if (stderr) {
418
+ return reject(stderr);
419
+ }
420
+ return resolve(stdout.trim());
421
+ }
422
+ );
423
+ }
424
+ );
425
+ log(
426
+ `\u{1F4C4} Resolved the current version as ${currentVersion} for tag "${tag}" from registry ${githubRegistry}`
427
+ );
428
+ } catch (_2) {
429
+ if (options.fallbackCurrentVersionResolver === "disk") {
430
+ log(
431
+ `\u{1F4C4} Unable to resolve the current version from the registry ${npmRegistry}${githubRegistry ? ` or ${githubRegistry}` : ""}. Falling back to the version on disk of ${currentVersionFromDisk}`
432
+ );
433
+ currentVersion = currentVersionFromDisk;
434
+ currentVersionResolvedFromFallback = true;
435
+ } else {
436
+ throw new Error(
437
+ `Unable to resolve the current version from the registry ${npmRegistry}${githubRegistry ? ` or ${githubRegistry}` : ""}. Please ensure that the package exists in the registry in order to use the "registry" currentVersionResolver. Alternatively, you can use the --first-release option or set "release.version.generatorOptions.fallbackCurrentVersionResolver" to "disk" in order to fallback to the version on disk when the registry lookup fails.`
438
+ );
439
+ }
440
+ }
441
+ }
442
+ } else {
443
+ if (currentVersionResolvedFromFallback) {
444
+ log(
445
+ `\u{1F4C4} Using the current version ${currentVersion} already resolved from disk fallback.`
446
+ );
447
+ } else {
448
+ log(
449
+ `\u{1F4C4} Using the current version ${currentVersion} already resolved from the registry ${_nullishCoalesce(npmRegistry, () => ( githubRegistry))}`
450
+ );
451
+ }
452
+ }
453
+ break;
454
+ }
455
+ case "disk":
456
+ currentVersion = currentVersionFromDisk;
457
+ log(
458
+ `\u{1F4C4} Resolved the current version as ${currentVersion} from ${packageJsonPath}`
459
+ );
460
+ break;
461
+ case "git-tag": {
462
+ if (
463
+ // We always need to independently resolve the current version from git tag per project if the projects are independent
464
+ options.releaseGroup.projectsRelationship === "independent"
465
+ ) {
466
+ const releaseTagPattern = options.releaseGroup.releaseTagPattern;
467
+ latestMatchingGitTag = await _git.getLatestGitTagForPattern.call(void 0,
468
+ releaseTagPattern,
469
+ {
470
+ projectName: project.name
471
+ },
472
+ {
473
+ releaseTagPatternRequireSemver: false,
474
+ releaseTagPatternStrictPreid: false
475
+ }
476
+ );
477
+ if (!latestMatchingGitTag) {
478
+ if (currentVersionFromDisk) {
479
+ log(
480
+ `\u{1F4C4} Unable to resolve the current version from git tag using pattern "${releaseTagPattern}". Falling back to the version on disk of ${currentVersionFromDisk}`
481
+ );
482
+ currentVersion = currentVersionFromDisk;
483
+ } else {
484
+ log(
485
+ `No git tags matching pattern "${releaseTagPattern}" for project "${project.name}" were found. This process also could not determine the version by checking the package files on disk, so we will attempt to use the default version value: "0.0.1".`
486
+ );
487
+ currentVersion = "0.0.1";
488
+ }
489
+ currentVersionResolvedFromFallback = true;
490
+ } else {
491
+ currentVersion = latestMatchingGitTag.extractedVersion;
492
+ log(
493
+ `\u{1F4C4} Resolved the current version as ${currentVersion} from git tag "${latestMatchingGitTag.tag}".`
494
+ );
495
+ }
496
+ } else {
497
+ if (currentVersionResolvedFromFallback) {
498
+ log(
499
+ `\u{1F4C4} Using the current version ${currentVersion} already resolved from disk fallback.`
500
+ );
501
+ } else {
502
+ log(
503
+ `\u{1F4C4} Using the current version ${currentVersion} already resolved from git tag "${latestMatchingGitTag.tag}".`
504
+ );
505
+ }
506
+ }
507
+ break;
508
+ }
509
+ default:
510
+ throw new Error(
511
+ `Invalid value for options.currentVersionResolver: ${options.currentVersionResolver}`
512
+ );
513
+ }
514
+ if (options.specifier) {
515
+ log(`\u{1F4C4} Using the provided version specifier "${options.specifier}".`);
516
+ }
517
+ if (specifier === void 0 || options.releaseGroup.projectsRelationship === "independent" && !options.specifier) {
518
+ const specifierSource = options.specifierSource;
519
+ switch (specifierSource) {
520
+ case "conventional-commits": {
521
+ if (options.currentVersionResolver !== "git-tag") {
522
+ throw new Error(
523
+ `Invalid currentVersionResolver "${options.currentVersionResolver}" provided for release group "${options.releaseGroup.name}". Must be "git-tag" when "specifierSource" is "conventional-commits"`
524
+ );
525
+ }
526
+ const affectedProjects = options.releaseGroup.projectsRelationship === "independent" ? [projectName] : projects.map((p) => p.name);
527
+ let previousVersionRef = _optionalChain([latestMatchingGitTag, 'optionalAccess', _17 => _17.tag]) ? latestMatchingGitTag.tag : await _git.getFirstGitCommit.call(void 0, );
528
+ if (!previousVersionRef) {
529
+ log(
530
+ `Unable to determine previous version ref for the projects ${affectedProjects.join(
531
+ ", "
532
+ )}. This is likely a bug in Storm's Release Versioning. We will attempt to use the default version value "0.0.1" and continue with the process.`
533
+ );
534
+ previousVersionRef = "0.0.1";
535
+ }
536
+ specifier = await _asyncNullishCoalesce(await _resolvesemverspecifier.resolveSemverSpecifierFromConventionalCommits.call(void 0,
537
+ previousVersionRef,
538
+ options.projectGraph,
539
+ affectedProjects,
540
+ DEFAULT_CONVENTIONAL_COMMITS_CONFIG
541
+ ), async () => ( void 0));
542
+ if (!specifier) {
543
+ log(
544
+ "\u{1F6AB} No changes were detected using git history and the conventional commits standard."
545
+ );
546
+ break;
547
+ }
548
+ if (currentVersion && _semver3.prerelease.call(void 0, currentVersion)) {
549
+ specifier = "prerelease";
550
+ log(
551
+ `\u{1F4C4} Resolved the specifier as "${specifier}" since the current version is a prerelease.`
552
+ );
553
+ } else {
554
+ log(
555
+ `\u{1F4C4} Resolved the specifier as "${specifier}" using git history and the conventional commits standard.`
556
+ );
557
+ }
558
+ break;
559
+ }
560
+ case "prompt": {
561
+ const maybeLogReleaseGroup = (log2) => {
562
+ if (options.releaseGroup.name === _config.IMPLICIT_DEFAULT_RELEASE_GROUP) {
563
+ return log2;
564
+ }
565
+ return `${log2} within release group "${options.releaseGroup.name}"`;
566
+ };
567
+ if (options.releaseGroup.projectsRelationship === "independent") {
568
+ specifier = await _resolvesemverspecifier.resolveSemverSpecifierFromPrompt.call(void 0,
569
+ `${maybeLogReleaseGroup(
570
+ `What kind of change is this for project "${projectName}"`
571
+ )}?`,
572
+ `${maybeLogReleaseGroup(`What is the exact version for project "${projectName}"`)}?`
573
+ );
574
+ } else {
575
+ specifier = await _resolvesemverspecifier.resolveSemverSpecifierFromPrompt.call(void 0,
576
+ `${maybeLogReleaseGroup(
577
+ `What kind of change is this for the ${projects.length} matched projects(s)`
578
+ )}?`,
579
+ `${maybeLogReleaseGroup(
580
+ `What is the exact version for the ${projects.length} matched project(s)`
581
+ )}?`
582
+ );
583
+ }
584
+ break;
585
+ }
586
+ default:
587
+ throw new Error(
588
+ `Invalid specifierSource "${specifierSource}" provided. Must be one of "prompt" or "conventional-commits"`
589
+ );
590
+ }
591
+ }
592
+ const localPackageDependencies = resolveLocalPackageDependencies(
593
+ tree,
594
+ options.projectGraph,
595
+ projects.filter(
596
+ (project2) => _optionalChain([project2, 'optionalAccess', _18 => _18.data, 'optionalAccess', _19 => _19.root]) && _optionalChain([project2, 'optionalAccess', _20 => _20.data, 'optionalAccess', _21 => _21.root]) !== _optionalChain([config, 'optionalAccess', _22 => _22.workspaceRoot])
597
+ ),
598
+ projectNameToPackageRootMap,
599
+ resolvePackageRoot,
600
+ // includeAll when the release group is independent, as we may be filtering to a specific subset of projects, but we still want to update their dependents
601
+ options.releaseGroup.projectsRelationship === "independent",
602
+ tree.exists(packageJsonPath)
603
+ );
604
+ const dependentProjects = Object.values(localPackageDependencies).flat().filter((localPackageDependency) => {
605
+ return localPackageDependency.target === project.name;
606
+ });
607
+ if (!currentVersion) {
608
+ throw new Error(
609
+ `Unable to determine the current version for project "${projectName}"`
610
+ );
611
+ }
612
+ versionData[projectName] = {
613
+ currentVersion: currentVersion ? currentVersion : "0.0.1",
614
+ dependentProjects,
615
+ newVersion: null
616
+ // will stay as null in the final result in the case that no changes are detected
617
+ };
618
+ if (!specifier) {
619
+ log(
620
+ `\u{1F6AB} Skipping versioning "${packageName}" as no changes were detected.`
621
+ );
622
+ continue;
623
+ }
624
+ const newVersion = _versionlegacy.deriveNewSemverVersion.call(void 0,
625
+ currentVersion,
626
+ specifier,
627
+ options.preid
628
+ );
629
+ if (versionData[projectName]) {
630
+ versionData[projectName].newVersion = newVersion;
631
+ }
632
+ if (tree.exists(packageJsonPath)) {
633
+ const projectPackageJson = _devkit.readJson.call(void 0, tree, packageJsonPath);
634
+ _devkit.writeJson.call(void 0, tree, packageJsonPath, {
635
+ ...projectPackageJson,
636
+ version: newVersion
637
+ });
638
+ } else if (tree.exists(cargoTomlPath)) {
639
+ const cargoToml = _chunkUXALGSQCjs.parseCargoToml.call(void 0,
640
+ _optionalChain([tree, 'access', _23 => _23.read, 'call', _24 => _24(cargoTomlPath), 'optionalAccess', _25 => _25.toString, 'call', _26 => _26("utf-8")])
641
+ );
642
+ cargoToml.package ??= {};
643
+ cargoToml.package.version = newVersion;
644
+ tree.write(cargoTomlPath, _chunkUXALGSQCjs.stringifyCargoToml.call(void 0, cargoToml));
645
+ }
646
+ log(
647
+ `\u270D\uFE0F New version ${newVersion} written to ${workspaceRelativePackagePath}`
648
+ );
649
+ if (dependentProjects.length > 0) {
650
+ log(
651
+ `\u270D\uFE0F Applying new version ${newVersion} to ${dependentProjects.length} ${dependentProjects.length > 1 ? "packages which depend" : "package which depends"} on ${project.name}`
652
+ );
653
+ }
654
+ for (const dependentProject of dependentProjects) {
655
+ const dependentPackageRoot = projectNameToPackageRootMap.get(
656
+ dependentProject.source
657
+ );
658
+ if (!dependentPackageRoot) {
659
+ throw new Error(
660
+ `The dependent project "${dependentProject.source}" does not have a packageRoot available.
661
+
662
+ Projects with packageRoot configured: ${Array.from(projectNameToPackageRootMap.keys()).join(", ")}`
663
+ );
664
+ }
665
+ const dependentPackageJsonPath = _devkit.joinPathFragments.call(void 0,
666
+ dependentPackageRoot,
667
+ "package.json"
668
+ );
669
+ const dependentCargoTomlPath = _devkit.joinPathFragments.call(void 0,
670
+ dependentPackageRoot,
671
+ "Cargo.toml"
672
+ );
673
+ if (tree.exists(dependentPackageJsonPath)) {
674
+ _devkit.updateJson.call(void 0, tree, dependentPackageJsonPath, (json) => {
675
+ let versionPrefix = _nullishCoalesce(options.versionPrefix, () => ( "auto"));
676
+ if (versionPrefix === "auto") {
677
+ versionPrefix = "";
678
+ const current = json[dependentProject.dependencyCollection][packageName];
679
+ if (current) {
680
+ const prefixMatch = current.match(/^[~^]/);
681
+ if (prefixMatch) {
682
+ versionPrefix = prefixMatch[0];
683
+ } else {
684
+ versionPrefix = "";
685
+ }
686
+ }
687
+ }
688
+ json[dependentProject.dependencyCollection][packageName] = `${versionPrefix}${newVersion}`;
689
+ return json;
690
+ });
691
+ } else if (tree.exists(dependentCargoTomlPath)) {
692
+ const dependentPkg = _chunkUXALGSQCjs.parseCargoTomlWithTree.call(void 0,
693
+ tree,
694
+ dependentPackageRoot,
695
+ dependentProject.source
696
+ );
697
+ let versionPrefix = _nullishCoalesce(options.versionPrefix, () => ( "auto"));
698
+ let updatedDependencyData = "";
699
+ for (const dependency of Object.entries(
700
+ _nullishCoalesce(dependentPkg[dependentProject.dependencyCollection], () => ( {}))
701
+ )) {
702
+ const [dependencyName, dependencyData] = dependency;
703
+ if (dependencyName !== dependentProject.target) {
704
+ continue;
705
+ }
706
+ if (versionPrefix === "auto") {
707
+ versionPrefix = "";
708
+ if (currentVersion) {
709
+ const dependencyVersion = typeof dependencyData === "string" ? dependencyData : dependencyData.version;
710
+ const prefixMatch = _optionalChain([dependencyVersion, 'optionalAccess', _27 => _27.match, 'call', _28 => _28(/^[~^=]/)]);
711
+ if (prefixMatch) {
712
+ versionPrefix = prefixMatch[0];
713
+ } else {
714
+ versionPrefix = "";
715
+ }
716
+ if (versionPrefix === "^") {
717
+ if (typeof dependencyData !== "string" && !_optionalChain([dependencyData, 'access', _29 => _29.version, 'optionalAccess', _30 => _30.startsWith, 'call', _31 => _31("^")])) {
718
+ versionPrefix = "";
719
+ }
720
+ }
721
+ }
722
+ }
723
+ const newVersionWithPrefix = `${versionPrefix}${newVersion}`;
724
+ updatedDependencyData = typeof dependencyData === "string" ? newVersionWithPrefix : {
725
+ ...dependencyData,
726
+ version: newVersionWithPrefix
727
+ };
728
+ break;
729
+ }
730
+ const cargoTomlToUpdate = _devkit.joinPathFragments.call(void 0,
731
+ dependentPackageRoot,
732
+ "Cargo.toml"
733
+ );
734
+ _chunkUXALGSQCjs.modifyCargoTable.call(void 0,
735
+ dependentPkg,
736
+ dependentProject.dependencyCollection,
737
+ dependentProject.target,
738
+ updatedDependencyData
739
+ );
740
+ tree.write(cargoTomlToUpdate, _chunkUXALGSQCjs.stringifyCargoToml.call(void 0, dependentPkg));
741
+ }
742
+ }
743
+ }
744
+ await _devkit.formatFiles.call(void 0, tree);
745
+ _chunkBP22TRDIjs.writeSuccess.call(void 0,
746
+ `Completed running the Storm Release Version generator!
747
+ `,
748
+ config
749
+ );
750
+ return {
751
+ data: versionData,
752
+ callback: async (tree2, opts) => {
753
+ _devkit.output.logSingleLine("Updating Cargo.lock file");
754
+ const cwd = tree2.root;
755
+ const updatedFiles = await _asyncNullishCoalesce(await _updatelockfile.updateLockFile.call(void 0, cwd, opts), async () => ( []));
756
+ const updatedCargoPackages = [];
757
+ for (const [projectName, projectVersionData] of Object.entries(
758
+ versionData
759
+ )) {
760
+ const project = projects.find((proj) => proj.name === projectName);
761
+ if (projectVersionData.newVersion && _optionalChain([project, 'optionalAccess', _32 => _32.name]) && projectNameToPackageRootMap.get(project.name)) {
762
+ const projectRoot = projectNameToPackageRootMap.get(project.name);
763
+ if (projectRoot && tree2.exists(_devkit.joinPathFragments.call(void 0, projectRoot, "Cargo.toml"))) {
764
+ updatedCargoPackages.push(projectName);
765
+ }
766
+ }
767
+ }
768
+ if (updatedCargoPackages.length > 0) {
769
+ _child_process.execSync.call(void 0, `cargo update ${updatedCargoPackages.join(" ")}`, {
770
+ maxBuffer: 1024 * 1024 * 1024,
771
+ env: {
772
+ ...process.env
773
+ },
774
+ cwd: tree2.root
775
+ });
776
+ if (hasGitDiff("Cargo.lock")) {
777
+ updatedFiles.push("Cargo.lock");
778
+ }
779
+ }
780
+ return updatedFiles;
781
+ }
782
+ };
783
+ } catch (error) {
784
+ _chunkBP22TRDIjs.writeFatal.call(void 0,
785
+ "A fatal error occurred while running the Storm Release Version generator - the process was forced to terminate",
786
+ config
787
+ );
788
+ _chunkBP22TRDIjs.writeError.call(void 0,
789
+ `An exception was thrown in the Storm Release Version generator's process
790
+ - Details: ${error.message}
791
+ - Stacktrace: ${error.stack}`,
792
+ config
793
+ );
794
+ throw new Error(
795
+ `An exception was thrown in the Storm Release Version generator's process
796
+ - Details: ${error.message}`,
797
+ { cause: error }
798
+ );
799
+ } finally {
800
+ stopwatch();
801
+ }
802
+ }
803
+ var generator_default = releaseVersionGeneratorFn;
804
+ async function getNpmRegistry() {
805
+ if (process.env.STORM_REGISTRY_NPM) {
806
+ return process.env.STORM_REGISTRY_NPM;
807
+ }
808
+ const registry = await new Promise((resolve, reject) => {
809
+ _child_process.exec.call(void 0, "npm config get registry", (error, stdout, stderr) => {
810
+ if (error) {
811
+ return reject(error);
812
+ }
813
+ if (stderr) {
814
+ return reject(stderr);
815
+ }
816
+ return resolve(stdout.trim());
817
+ });
818
+ });
819
+ return registry ? registry : "https://registry.npmjs.org";
820
+ }
821
+ function getGitHubRegistry() {
822
+ if (process.env.STORM_REGISTRY_GITHUB) {
823
+ return process.env.STORM_REGISTRY_GITHUB;
824
+ }
825
+ return "https://npm.pkg.github.com";
826
+ }
827
+ function hasGitDiff(filePath) {
828
+ try {
829
+ const result = _child_process.execSync.call(void 0, `git diff --name-only "${filePath}"`).toString();
830
+ return result.trim() === filePath;
831
+ } catch (_) {
832
+ return false;
833
+ }
834
+ }
835
+ function resolveLocalPackageDependencies(tree, projectGraph, filteredProjects, projectNameToPackageRootMap, resolvePackageRoot, includeAll = false, isNodeProject = true) {
836
+ if (isNodeProject) {
837
+ return _resolvelocalpackagedependencies.resolveLocalPackageDependencies.call(void 0,
838
+ tree,
839
+ projectGraph,
840
+ filteredProjects,
841
+ projectNameToPackageRootMap,
842
+ resolvePackageRoot,
843
+ includeAll
844
+ );
845
+ }
846
+ return resolveLocalPackageCargoDependencies(
847
+ tree,
848
+ projectGraph,
849
+ filteredProjects,
850
+ projectNameToPackageRootMap,
851
+ resolvePackageRoot,
852
+ includeAll
853
+ );
854
+ }
855
+ function resolveLocalPackageCargoDependencies(tree, projectGraph, filteredProjects, projectNameToPackageRootMap, resolvePackageRoot, includeAll = false) {
856
+ const localPackageDependencies = {};
857
+ const projects = includeAll ? Object.values(projectGraph.nodes) : filteredProjects;
858
+ for (const projectNode of projects) {
859
+ let packageRoot = projectNameToPackageRootMap.get(projectNode.name);
860
+ if (!packageRoot && includeAll) {
861
+ packageRoot = resolvePackageRoot(projectNode);
862
+ if (!packageRoot) {
863
+ continue;
864
+ }
865
+ projectNameToPackageRootMap.set(projectNode.name, packageRoot);
866
+ }
867
+ const cargoTomlPath = _devkit.joinPathFragments.call(void 0, _nullishCoalesce(packageRoot, () => ( "./")), "Cargo.toml");
868
+ if (!tree.exists(cargoTomlPath)) {
869
+ continue;
870
+ }
871
+ const projectDeps = projectGraph.dependencies[projectNode.name];
872
+ if (!projectDeps) {
873
+ continue;
874
+ }
875
+ const localPackageDepsForProject = [];
876
+ for (const dep of projectDeps) {
877
+ const depProject = projectGraph.nodes[dep.target];
878
+ if (!depProject) {
879
+ continue;
880
+ }
881
+ const depProjectRoot = projectNameToPackageRootMap.get(dep.target);
882
+ if (!depProjectRoot) {
883
+ throw new Error(
884
+ `The project "${dep.target}" does not have a packageRoot available.`
885
+ );
886
+ }
887
+ const cargoToml = _chunkUXALGSQCjs.parseCargoTomlWithTree.call(void 0,
888
+ tree,
889
+ resolvePackageRoot(projectNode),
890
+ projectNode.name
891
+ );
892
+ const dependencies = _nullishCoalesce(cargoToml.dependencies, () => ( {}));
893
+ const devDependencies = _nullishCoalesce(cargoToml["dev-dependencies"], () => ( {}));
894
+ const dependencyCollection = dependencies[depProject.name] ? "dependencies" : devDependencies[depProject.name] ? "dev-dependencies" : null;
895
+ if (!dependencyCollection) {
896
+ throw new Error(
897
+ `The project "${projectNode.name}" does not have a local dependency on "${depProject.name}" in its Cargo.toml`
898
+ );
899
+ }
900
+ localPackageDepsForProject.push({
901
+ ...dep,
902
+ dependencyCollection
903
+ });
904
+ }
905
+ localPackageDependencies[projectNode.name] = localPackageDepsForProject;
906
+ }
907
+ return localPackageDependencies;
908
+ }
909
+
910
+
911
+
912
+
913
+ exports.releaseVersionGeneratorFn = releaseVersionGeneratorFn; exports.generator_default = generator_default;