nx 20.5.0-canary.20250214-ef08108 → 20.5.0-canary.20250218-3d63da2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "20.5.0-canary.20250214-ef08108",
3
+ "version": "20.5.0-canary.20250218-3d63da2",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -82,16 +82,16 @@
82
82
  }
83
83
  },
84
84
  "optionalDependencies": {
85
- "@nx/nx-darwin-arm64": "20.5.0-canary.20250214-ef08108",
86
- "@nx/nx-darwin-x64": "20.5.0-canary.20250214-ef08108",
87
- "@nx/nx-freebsd-x64": "20.5.0-canary.20250214-ef08108",
88
- "@nx/nx-linux-arm-gnueabihf": "20.5.0-canary.20250214-ef08108",
89
- "@nx/nx-linux-arm64-gnu": "20.5.0-canary.20250214-ef08108",
90
- "@nx/nx-linux-arm64-musl": "20.5.0-canary.20250214-ef08108",
91
- "@nx/nx-linux-x64-gnu": "20.5.0-canary.20250214-ef08108",
92
- "@nx/nx-linux-x64-musl": "20.5.0-canary.20250214-ef08108",
93
- "@nx/nx-win32-arm64-msvc": "20.5.0-canary.20250214-ef08108",
94
- "@nx/nx-win32-x64-msvc": "20.5.0-canary.20250214-ef08108"
85
+ "@nx/nx-darwin-arm64": "20.5.0-canary.20250218-3d63da2",
86
+ "@nx/nx-darwin-x64": "20.5.0-canary.20250218-3d63da2",
87
+ "@nx/nx-freebsd-x64": "20.5.0-canary.20250218-3d63da2",
88
+ "@nx/nx-linux-arm-gnueabihf": "20.5.0-canary.20250218-3d63da2",
89
+ "@nx/nx-linux-arm64-gnu": "20.5.0-canary.20250218-3d63da2",
90
+ "@nx/nx-linux-arm64-musl": "20.5.0-canary.20250218-3d63da2",
91
+ "@nx/nx-linux-x64-gnu": "20.5.0-canary.20250218-3d63da2",
92
+ "@nx/nx-linux-x64-musl": "20.5.0-canary.20250218-3d63da2",
93
+ "@nx/nx-win32-arm64-msvc": "20.5.0-canary.20250218-3d63da2",
94
+ "@nx/nx-win32-x64-msvc": "20.5.0-canary.20250218-3d63da2"
95
95
  },
96
96
  "nx-migrations": {
97
97
  "migrations": "./migrations.json",
@@ -21,6 +21,10 @@
21
21
  "additionalProperties": false,
22
22
  "deprecated": "Use `defaultBase` instead. Support for setting `defaultBase` in `affected` will be removed in Nx 20."
23
23
  },
24
+ "extends": {
25
+ "type": "string",
26
+ "description": "Specifies the base config to extend."
27
+ },
24
28
  "defaultBase": {
25
29
  "type": "string",
26
30
  "description": "Default --base used by affected logic."
@@ -169,7 +173,22 @@
169
173
  ]
170
174
  },
171
175
  "releaseTagPattern": {
172
- "type": "string"
176
+ "type": "string",
177
+ "description": "Optionally override the git/release tag pattern to use for this group."
178
+ },
179
+ "releaseTagPatternCheckAllBranchesWhen": {
180
+ "oneOf": [
181
+ {
182
+ "type": "boolean"
183
+ },
184
+ {
185
+ "type": "array",
186
+ "items": {
187
+ "type": "string"
188
+ }
189
+ }
190
+ ],
191
+ "description": "By default, we will try and resolve the latest match for the releaseTagPattern from the current branch, falling back to all branches if no match is found on the current branch. Setting this to true will cause us to ALWAYS check all branches for the latest match. Setting it to false will cause us to ONLY check the current branch for the latest match. Setting it to an array of strings will cause us to check all branches WHEN the current branch is one of the strings in the array. Glob patterns are supported."
173
192
  },
174
193
  "versionPlans": {
175
194
  "oneOf": [
@@ -243,7 +262,22 @@
243
262
  ]
244
263
  },
245
264
  "releaseTagPattern": {
246
- "type": "string"
265
+ "type": "string",
266
+ "description": "Optionally override the git/release tag pattern to use. This field is the source of truth for changelog generation and release tagging, as well as for conventional commits parsing. It supports interpolating the version as {version} and (if releasing independently or forcing project level version control system releases) the project name as {projectName} within the string. The default releaseTagPattern for fixed/unified releases is: \"v{version}\". The default releaseTagPattern for independent releases at the project level is: \"{projectName}@{version}\""
267
+ },
268
+ "releaseTagPatternCheckAllBranchesWhen": {
269
+ "oneOf": [
270
+ {
271
+ "type": "boolean"
272
+ },
273
+ {
274
+ "type": "array",
275
+ "items": {
276
+ "type": "string"
277
+ }
278
+ }
279
+ ],
280
+ "description": "By default, we will try and resolve the latest match for the releaseTagPattern from the current branch, falling back to all branches if no match is found on the current branch. Setting this to true will cause us to ALWAYS check all branches for the latest match. Setting it to false will cause us to ONLY check the current branch for the latest match. Setting it to an array of strings will cause us to check all branches WHEN the current branch is one of the strings in the array. Glob patterns are supported."
247
281
  }
248
282
  }
249
283
  },
@@ -191,8 +191,7 @@ function createAPI(overrideReleaseConfig) {
191
191
  }
192
192
  else {
193
193
  let workspaceChangelogFromRef = args.from ||
194
- (await (0, git_1.getLatestGitTagForPattern)(nxReleaseConfig.releaseTagPattern))
195
- ?.tag;
194
+ (await (0, git_1.getLatestGitTagForPattern)(nxReleaseConfig.releaseTagPattern, {}, nxReleaseConfig.releaseTagPatternCheckAllBranchesWhen))?.tag;
196
195
  if (!workspaceChangelogFromRef) {
197
196
  if (useAutomaticFromRef) {
198
197
  workspaceChangelogFromRef = await (0, git_1.getFirstGitCommit)();
@@ -335,7 +334,7 @@ function createAPI(overrideReleaseConfig) {
335
334
  (await (0, git_1.getLatestGitTagForPattern)(releaseGroup.releaseTagPattern, {
336
335
  projectName: project.name,
337
336
  releaseGroupName: releaseGroup.name,
338
- }))?.tag;
337
+ }, releaseGroup.releaseTagPatternCheckAllBranchesWhen))?.tag;
339
338
  if (!fromRef && useAutomaticFromRef) {
340
339
  const firstCommit = await (0, git_1.getFirstGitCommit)();
341
340
  const allCommits = await getCommits(firstCommit, toSHA);
@@ -442,8 +441,7 @@ function createAPI(overrideReleaseConfig) {
442
441
  }
443
442
  else {
444
443
  let fromRef = args.from ||
445
- (await (0, git_1.getLatestGitTagForPattern)(releaseGroup.releaseTagPattern))
446
- ?.tag;
444
+ (await (0, git_1.getLatestGitTagForPattern)(releaseGroup.releaseTagPattern, {}, releaseGroup.releaseTagPatternCheckAllBranchesWhen))?.tag;
447
445
  if (!fromRef) {
448
446
  if (useAutomaticFromRef) {
449
447
  fromRef = await (0, git_1.getFirstGitCommit)();
@@ -58,6 +58,7 @@ export type PlanCheckOptions = BaseNxReleaseArgs & {
58
58
  export type ReleaseOptions = NxReleaseArgs & FirstReleaseArgs & {
59
59
  specifier?: string;
60
60
  yes?: boolean;
61
+ preid?: VersionOptions['preid'];
61
62
  skipPublish?: boolean;
62
63
  };
63
64
  export type VersionPlanArgs = {
@@ -75,6 +75,11 @@ const releaseCommand = {
75
75
  .positional('specifier', {
76
76
  type: 'string',
77
77
  describe: 'Exact version or semver keyword to apply to the selected release group.',
78
+ })
79
+ .option('preid', {
80
+ type: 'string',
81
+ describe: 'The optional prerelease identifier to apply to the version. This will only be applied in the case that the specifier argument has been set to `prerelease` OR when conventional commits are enabled, in which case it will modify the resolved specifier from conventional commits to be its prerelease equivalent. E.g. minor -> preminor.',
82
+ default: '',
78
83
  })
79
84
  .option('yes', {
80
85
  type: 'boolean',
@@ -177,6 +177,7 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
177
177
  (workspaceProjectsRelationship === 'independent'
178
178
  ? defaultIndependentReleaseTagPattern
179
179
  : defaultFixedReleaseTagPattern),
180
+ releaseTagPatternCheckAllBranchesWhen: userConfig.releaseTagPatternCheckAllBranchesWhen ?? undefined,
180
181
  conventionalCommits: conventional_commits_1.DEFAULT_CONVENTIONAL_COMMITS_CONFIG,
181
182
  versionPlans: (userConfig.versionPlans ||
182
183
  false),
@@ -207,6 +208,7 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
207
208
  groupProjectsRelationship === 'independent'
208
209
  ? defaultIndependentReleaseTagPattern
209
210
  : WORKSPACE_DEFAULTS.releaseTagPattern,
211
+ releaseTagPatternCheckAllBranchesWhen: userConfig.releaseTagPatternCheckAllBranchesWhen ?? undefined,
210
212
  versionPlans: false,
211
213
  };
212
214
  /**
@@ -365,6 +367,9 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
365
367
  (projectsRelationship === 'independent'
366
368
  ? defaultIndependentReleaseTagPattern
367
369
  : userConfig.releaseTagPattern || defaultFixedReleaseTagPattern),
370
+ releaseTagPatternCheckAllBranchesWhen: releaseGroup.releaseTagPatternCheckAllBranchesWhen ??
371
+ userConfig.releaseTagPatternCheckAllBranchesWhen ??
372
+ undefined,
368
373
  versionPlans: releaseGroup.versionPlans ?? rootVersionPlansConfig,
369
374
  };
370
375
  const finalReleaseGroup = deepMergeDefaults([groupDefaults], {
@@ -413,6 +418,7 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
413
418
  nxReleaseConfig: {
414
419
  projectsRelationship: WORKSPACE_DEFAULTS.projectsRelationship,
415
420
  releaseTagPattern: WORKSPACE_DEFAULTS.releaseTagPattern,
421
+ releaseTagPatternCheckAllBranchesWhen: WORKSPACE_DEFAULTS.releaseTagPatternCheckAllBranchesWhen,
416
422
  git: rootGitConfig,
417
423
  version: rootVersionConfig,
418
424
  changelog: rootChangelogConfig,
@@ -22,7 +22,7 @@ export interface GitCommit extends RawGitCommit {
22
22
  affectedFiles: string[];
23
23
  revertedHashes: string[];
24
24
  }
25
- export declare function getLatestGitTagForPattern(releaseTagPattern: string, additionalInterpolationData?: {}): Promise<{
25
+ export declare function getLatestGitTagForPattern(releaseTagPattern: string, additionalInterpolationData?: {}, checkAllBranchesWhen?: boolean | string[]): Promise<{
26
26
  tag: string;
27
27
  extractedVersion: string;
28
28
  } | null>;
@@ -16,6 +16,7 @@ exports.getFirstGitCommit = getFirstGitCommit;
16
16
  * https://github.com/unjs/changelogen
17
17
  */
18
18
  const node_path_1 = require("node:path");
19
+ const minimatch_1 = require("minimatch");
19
20
  const utils_1 = require("../../../tasks-runner/utils");
20
21
  const workspace_root_1 = require("../../../utils/workspace-root");
21
22
  const exec_command_1 = require("./exec-command");
@@ -24,22 +25,69 @@ function escapeRegExp(string) {
24
25
  }
25
26
  // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
26
27
  const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/g;
27
- async function getLatestGitTagForPattern(releaseTagPattern, additionalInterpolationData = {}) {
28
+ async function getLatestGitTagForPattern(releaseTagPattern, additionalInterpolationData = {}, checkAllBranchesWhen) {
29
+ /**
30
+ * By default, we will try and resolve the latest match for the releaseTagPattern from the current branch,
31
+ * falling back to all branches if no match is found on the current branch.
32
+ *
33
+ * - If checkAllBranchesWhen is true it will cause us to ALWAYS check all branches for the latest match.
34
+ * - If checkAllBranchesWhen is explicitly set to false it will cause us to ONLY check the current branch for the latest match.
35
+ * - If checkAllBranchesWhen is an array of strings it will cause us to check all branches WHEN the current branch is one of the strings in the array.
36
+ */
37
+ let alwaysCheckAllBranches = false;
38
+ if (typeof checkAllBranchesWhen !== 'undefined') {
39
+ if (typeof checkAllBranchesWhen === 'boolean') {
40
+ alwaysCheckAllBranches = checkAllBranchesWhen;
41
+ }
42
+ else if (Array.isArray(checkAllBranchesWhen)) {
43
+ /**
44
+ * Get the current git branch and determine whether to check all branches based on the checkAllBranchesWhen parameter
45
+ */
46
+ const currentBranch = await (0, exec_command_1.execCommand)('git', [
47
+ 'rev-parse',
48
+ '--abbrev-ref',
49
+ 'HEAD',
50
+ ]).then((r) => r.trim());
51
+ // Check exact match first
52
+ alwaysCheckAllBranches = checkAllBranchesWhen.includes(currentBranch);
53
+ // Check if any glob pattern matches next
54
+ if (!alwaysCheckAllBranches) {
55
+ alwaysCheckAllBranches = checkAllBranchesWhen.some((pattern) => {
56
+ const r = minimatch_1.minimatch.makeRe(pattern, { dot: true });
57
+ if (!r) {
58
+ return false;
59
+ }
60
+ return r.test(currentBranch);
61
+ });
62
+ }
63
+ }
64
+ }
65
+ const defaultGitArgs = [
66
+ // Apply git config to take version suffixes into account when sorting, e.g. 1.0.0 is newer than 1.0.0-beta.1
67
+ '-c',
68
+ 'versionsort.suffix=-',
69
+ 'tag',
70
+ '--sort',
71
+ '-v:refname',
72
+ ];
28
73
  try {
29
74
  let tags;
30
75
  tags = await (0, exec_command_1.execCommand)('git', [
31
- 'tag',
32
- '--sort',
33
- '-v:refname',
34
- '--merged',
76
+ ...defaultGitArgs,
77
+ ...(alwaysCheckAllBranches ? [] : ['--merged']),
35
78
  ]).then((r) => r
36
79
  .trim()
37
80
  .split('\n')
38
81
  .map((t) => t.trim())
39
82
  .filter(Boolean));
40
- if (!tags.length) {
83
+ if (
84
+ // Do not run this fallback if the user explicitly set checkAllBranchesWhen to false
85
+ checkAllBranchesWhen !== false &&
86
+ !tags.length &&
87
+ // There is no point in running this fallback if we already checked against all branches
88
+ !alwaysCheckAllBranches) {
41
89
  // try again, but include all tags on the repo instead of just --merged ones
42
- tags = await (0, exec_command_1.execCommand)('git', ['tag', '--sort', '-v:refname']).then((r) => r
90
+ tags = await (0, exec_command_1.execCommand)('git', defaultGitArgs).then((r) => r
43
91
  .trim()
44
92
  .split('\n')
45
93
  .map((t) => t.trim())
@@ -215,6 +215,15 @@ export interface NxReleaseConfiguration {
215
215
  * Optionally override the git/release tag pattern to use for this group.
216
216
  */
217
217
  releaseTagPattern?: string;
218
+ /**
219
+ * By default, we will try and resolve the latest match for the releaseTagPattern from the current branch,
220
+ * falling back to all branches if no match is found on the current branch.
221
+ *
222
+ * - Setting this to true will cause us to ALWAYS check all branches for the latest match.
223
+ * - Setting it to false will cause us to ONLY check the current branch for the latest match.
224
+ * - Setting it to an array of strings will cause us to check all branches WHEN the current branch matches one of the strings in the array. Glob patterns are supported.
225
+ */
226
+ releaseTagPatternCheckAllBranchesWhen?: boolean | string[];
218
227
  /**
219
228
  * Enables using version plans as a specifier source for versioning and
220
229
  * to determine changes for changelog generation.
@@ -281,6 +290,15 @@ export interface NxReleaseConfiguration {
281
290
  * The default releaseTagPattern for independent releases at the project level is: "{projectName}@{version}"
282
291
  */
283
292
  releaseTagPattern?: string;
293
+ /**
294
+ * By default, we will try and resolve the latest match for the releaseTagPattern from the current branch,
295
+ * falling back to all branches if no match is found on the current branch.
296
+ *
297
+ * - Setting this to true will cause us to ALWAYS check all branches for the latest match.
298
+ * - Setting it to false will cause us to ONLY check the current branch for the latest match.
299
+ * - Setting it to an array of strings will cause us to check all branches WHEN the current branch matches one of the strings in the array. Glob patterns are supported.
300
+ */
301
+ releaseTagPatternCheckAllBranchesWhen?: boolean | string[];
284
302
  /**
285
303
  * Enable and configure automatic git operations as part of the release
286
304
  */