nx 19.2.0-canary.20240601-6f22300 → 19.2.0-canary.20240605-5a06daa

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. package/bin/post-install.js +8 -8
  2. package/migrations.json +6 -0
  3. package/package.json +13 -12
  4. package/release/changelog-renderer/index.d.ts +6 -3
  5. package/release/changelog-renderer/index.js +53 -50
  6. package/schemas/nx-schema.json +8 -0
  7. package/src/command-line/add/add.d.ts +1 -1
  8. package/src/command-line/add/command-object.js +3 -1
  9. package/src/command-line/affected/command-object.js +10 -5
  10. package/src/command-line/deprecated/command-objects.js +12 -6
  11. package/src/command-line/examples.js +18 -0
  12. package/src/command-line/generate/generate.d.ts +1 -1
  13. package/src/command-line/migrate/migrate.d.ts +1 -1
  14. package/src/command-line/new/new.d.ts +1 -1
  15. package/src/command-line/release/changelog.d.ts +17 -1
  16. package/src/command-line/release/changelog.js +305 -76
  17. package/src/command-line/release/command-object.d.ts +14 -5
  18. package/src/command-line/release/command-object.js +52 -24
  19. package/src/command-line/release/config/config.js +38 -6
  20. package/src/command-line/release/config/filter-release-groups.d.ts +3 -1
  21. package/src/command-line/release/config/filter-release-groups.js +1 -0
  22. package/src/command-line/release/config/version-plans.d.ts +24 -0
  23. package/src/command-line/release/config/version-plans.js +184 -0
  24. package/src/command-line/release/plan.d.ts +3 -0
  25. package/src/command-line/release/plan.js +184 -0
  26. package/src/command-line/release/publish.d.ts +1 -1
  27. package/src/command-line/release/release.d.ts +1 -1
  28. package/src/command-line/release/release.js +40 -0
  29. package/src/command-line/release/utils/git.d.ts +10 -2
  30. package/src/command-line/release/utils/git.js +45 -10
  31. package/src/command-line/release/utils/shared.d.ts +12 -2
  32. package/src/command-line/release/utils/shared.js +3 -2
  33. package/src/command-line/release/version.d.ts +3 -2
  34. package/src/command-line/release/version.js +43 -5
  35. package/src/command-line/repair/repair.d.ts +1 -1
  36. package/src/command-line/reset/command-object.d.ts +6 -1
  37. package/src/command-line/reset/command-object.js +15 -2
  38. package/src/command-line/reset/reset.d.ts +2 -1
  39. package/src/command-line/reset/reset.js +98 -16
  40. package/src/command-line/run/command-object.js +6 -3
  41. package/src/command-line/run/run.d.ts +2 -2
  42. package/src/command-line/run-many/command-object.js +6 -3
  43. package/src/command-line/show/command-object.js +6 -6
  44. package/src/config/misc-interfaces.d.ts +15 -3
  45. package/src/config/nx-json.d.ts +11 -0
  46. package/src/core/graph/main.js +1 -1
  47. package/src/daemon/server/plugins.js +1 -0
  48. package/src/daemon/tmp-dir.js +1 -1
  49. package/src/devkit-exports.d.ts +1 -1
  50. package/src/migrations/update-19-2-0/move-workspace-data-directory.d.ts +4 -0
  51. package/src/migrations/update-19-2-0/move-workspace-data-directory.js +34 -0
  52. package/src/plugins/js/index.js +2 -2
  53. package/src/plugins/js/project-graph/affected/lock-file-changes.js +11 -0
  54. package/src/plugins/js/project-graph/affected/npm-packages.js +12 -0
  55. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +3 -11
  56. package/src/plugins/js/utils/config.js +4 -0
  57. package/src/plugins/js/utils/register.d.ts +4 -3
  58. package/src/plugins/js/utils/register.js +47 -4
  59. package/src/project-graph/affected/affected-project-graph.js +6 -6
  60. package/src/project-graph/nx-deps-cache.js +6 -6
  61. package/src/project-graph/plugins/loader.js +1 -1
  62. package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
  63. package/src/tasks-runner/task-env.js +12 -0
  64. package/src/utils/cache-directory.d.ts +1 -1
  65. package/src/utils/cache-directory.js +13 -6
  66. package/src/utils/get-package-name-from-import-path.d.ts +1 -0
  67. package/src/utils/get-package-name-from-import-path.js +18 -0
  68. package/src/utils/package-json.d.ts +1 -0
  69. package/src/utils/package-manager.js +42 -9
  70. package/src/utils/params.d.ts +1 -1
  71. package/src/utils/params.js +5 -1
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shouldCreateGitHubRelease = exports.releaseChangelog = exports.releaseChangelogCLIHandler = void 0;
4
4
  const chalk = require("chalk");
5
5
  const enquirer_1 = require("enquirer");
6
+ const fs_extra_1 = require("fs-extra");
6
7
  const node_fs_1 = require("node:fs");
7
8
  const semver_1 = require("semver");
8
9
  const tmp_1 = require("tmp");
@@ -18,6 +19,7 @@ const path_1 = require("../../utils/path");
18
19
  const workspace_root_1 = require("../../utils/workspace-root");
19
20
  const config_1 = require("./config/config");
20
21
  const filter_release_groups_1 = require("./config/filter-release-groups");
22
+ const version_plans_1 = require("./config/version-plans");
21
23
  const git_1 = require("./utils/git");
22
24
  const github_1 = require("./utils/github");
23
25
  const launch_editor_1 = require("./utils/launch-editor");
@@ -67,6 +69,12 @@ async function releaseChangelog(args) {
67
69
  output_1.output.error(filterError);
68
70
  process.exit(1);
69
71
  }
72
+ const rawVersionPlans = await (0, version_plans_1.readRawVersionPlans)();
73
+ (0, version_plans_1.setVersionPlansOnGroups)(rawVersionPlans, releaseGroups, Object.keys(projectGraph.nodes));
74
+ if (args.deleteVersionPlans === undefined) {
75
+ // default to deleting version plans in this command instead of after versioning
76
+ args.deleteVersionPlans = true;
77
+ }
70
78
  const changelogGenerationEnabled = !!nxReleaseConfig.changelog.workspaceChangelog ||
71
79
  Object.values(nxReleaseConfig.groups).some((g) => g.changelog);
72
80
  if (!changelogGenerationEnabled) {
@@ -78,6 +86,7 @@ async function releaseChangelog(args) {
78
86
  });
79
87
  return {};
80
88
  }
89
+ const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, args.verbose);
81
90
  const useAutomaticFromRef = nxReleaseConfig.changelog?.automaticFromRef || args.firstRelease;
82
91
  /**
83
92
  * For determining the versions to use within changelog files, there are a few different possibilities:
@@ -105,7 +114,6 @@ async function releaseChangelog(args) {
105
114
  if (autoCommitEnabled && headSHA !== toSHA) {
106
115
  throw new Error(`You are attempting to recreate the changelog for an old release, but you have enabled auto-commit mode. Please disable auto-commit mode by updating your nx.json, or passing --git-commit=false`);
107
116
  }
108
- const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, args.verbose);
109
117
  const commitMessage = args.gitCommitMessage || nxReleaseConfig.changelog.git.commitMessage;
110
118
  const commitMessageValues = (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, projectsVersionData, commitMessage);
111
119
  // Resolve any git tags as early as possible so that we can hard error in case of any duplicates before reaching the actual git command
@@ -114,23 +122,78 @@ async function releaseChangelog(args) {
114
122
  : [];
115
123
  (0, shared_1.handleDuplicateGitTags)(gitTagValues);
116
124
  const postGitTasks = [];
117
- let workspaceChangelogFromRef = args.from ||
118
- (await (0, git_1.getLatestGitTagForPattern)(nxReleaseConfig.releaseTagPattern))?.tag;
119
- if (!workspaceChangelogFromRef) {
120
- if (useAutomaticFromRef) {
121
- workspaceChangelogFromRef = await (0, git_1.getFirstGitCommit)();
122
- if (args.verbose) {
123
- console.log(`Determined workspace --from ref from the first commit in the workspace: ${workspaceChangelogFromRef}`);
125
+ let workspaceChangelogChanges = [];
126
+ // TODO: remove this after the changelog renderer is refactored to remove coupling with git commits
127
+ let workspaceChangelogCommits = [];
128
+ // If there are multiple release groups, we'll just skip the workspace changelog anyway.
129
+ const versionPlansEnabledForWorkspaceChangelog = releaseGroups[0].versionPlans;
130
+ if (versionPlansEnabledForWorkspaceChangelog) {
131
+ if (releaseGroups.length === 1) {
132
+ const releaseGroup = releaseGroups[0];
133
+ if (releaseGroup.projectsRelationship === 'fixed') {
134
+ const versionPlans = releaseGroup.versionPlans;
135
+ workspaceChangelogChanges = filterHiddenChanges(versionPlans
136
+ .map((vp) => {
137
+ const parsedMessage = (0, git_1.parseConventionalCommitsMessage)(vp.message);
138
+ // only properly formatted conventional commits messages will be included in the changelog
139
+ if (!parsedMessage) {
140
+ return null;
141
+ }
142
+ return {
143
+ type: parsedMessage.type,
144
+ scope: parsedMessage.scope,
145
+ description: parsedMessage.description,
146
+ body: '',
147
+ isBreaking: parsedMessage.breaking,
148
+ githubReferences: [],
149
+ };
150
+ })
151
+ .filter(Boolean), nxReleaseConfig.conventionalCommits);
124
152
  }
125
153
  }
126
- else {
127
- throw new Error(`Unable to determine the previous git tag. If this is the first release of your workspace, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTagPattern" property in nx.json to match the structure of your repository's git tags.`);
128
- }
129
154
  }
130
- // Make sure that the fromRef is actually resolvable
131
- const workspaceChangelogFromSHA = await (0, git_1.getCommitHash)(workspaceChangelogFromRef);
132
- const workspaceChangelogCommits = await getCommits(workspaceChangelogFromSHA, toSHA, nxReleaseConfig.conventionalCommits);
133
- const workspaceChangelog = await generateChangelogForWorkspace(tree, args, projectGraph, nxReleaseConfig, workspaceChangelogVersion, workspaceChangelogCommits);
155
+ else {
156
+ let workspaceChangelogFromRef = args.from ||
157
+ (await (0, git_1.getLatestGitTagForPattern)(nxReleaseConfig.releaseTagPattern))?.tag;
158
+ if (!workspaceChangelogFromRef) {
159
+ if (useAutomaticFromRef) {
160
+ workspaceChangelogFromRef = await (0, git_1.getFirstGitCommit)();
161
+ if (args.verbose) {
162
+ console.log(`Determined workspace --from ref from the first commit in the workspace: ${workspaceChangelogFromRef}`);
163
+ }
164
+ }
165
+ else {
166
+ throw new Error(`Unable to determine the previous git tag. If this is the first release of your workspace, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTagPattern" property in nx.json to match the structure of your repository's git tags.`);
167
+ }
168
+ }
169
+ // Make sure that the fromRef is actually resolvable
170
+ const workspaceChangelogFromSHA = await (0, git_1.getCommitHash)(workspaceChangelogFromRef);
171
+ workspaceChangelogCommits = await getCommits(workspaceChangelogFromSHA, toSHA);
172
+ workspaceChangelogChanges = filterHiddenChanges(workspaceChangelogCommits.map((c) => {
173
+ return {
174
+ type: c.type,
175
+ scope: c.scope,
176
+ description: c.description,
177
+ body: c.body,
178
+ isBreaking: c.isBreaking,
179
+ githubReferences: c.references,
180
+ author: c.author,
181
+ shortHash: c.shortHash,
182
+ revertedHashes: c.revertedHashes,
183
+ affectedProjects: '*',
184
+ };
185
+ }), nxReleaseConfig.conventionalCommits);
186
+ }
187
+ const workspaceChangelog = await generateChangelogForWorkspace({
188
+ tree,
189
+ args,
190
+ projectGraph,
191
+ nxReleaseConfig,
192
+ workspaceChangelogVersion,
193
+ changes: workspaceChangelogChanges,
194
+ // TODO: remove this after the changelog renderer is refactored to remove coupling with git commits
195
+ commits: filterHiddenCommits(workspaceChangelogCommits, nxReleaseConfig.conventionalCommits),
196
+ });
134
197
  if (workspaceChangelog &&
135
198
  shouldCreateGitHubRelease(nxReleaseConfig.changelog.workspaceChangelog, args.createRelease)) {
136
199
  let hasPushed = false;
@@ -159,9 +222,6 @@ async function releaseChangelog(args) {
159
222
  continue;
160
223
  }
161
224
  for (const project of releaseGroup.projects) {
162
- if (projectToAdditionalDependencyBumps.has(project)) {
163
- continue;
164
- }
165
225
  const dependentProjects = (projectsVersionData[project]?.dependentProjects || [])
166
226
  .map((dep) => {
167
227
  return {
@@ -170,7 +230,16 @@ async function releaseChangelog(args) {
170
230
  };
171
231
  })
172
232
  .filter((b) => b.newVersion !== null);
173
- projectToAdditionalDependencyBumps.set(project, dependentProjects);
233
+ for (const dependent of dependentProjects) {
234
+ const additionalDependencyBumpsForProject = projectToAdditionalDependencyBumps.has(dependent.dependencyName)
235
+ ? projectToAdditionalDependencyBumps.get(dependent.dependencyName)
236
+ : [];
237
+ additionalDependencyBumpsForProject.push({
238
+ dependencyName: project,
239
+ newVersion: projectsVersionData[project].newVersion,
240
+ });
241
+ projectToAdditionalDependencyBumps.set(dependent.dependencyName, additionalDependencyBumpsForProject);
242
+ }
174
243
  }
175
244
  }
176
245
  const allProjectChangelogs = {};
@@ -185,7 +254,7 @@ async function releaseChangelog(args) {
185
254
  Array.from(releaseGroupToFilteredProjects.get(releaseGroup)).flatMap((project) => {
186
255
  return [
187
256
  project,
188
- ...(projectToAdditionalDependencyBumps.get(project) || []).map((d) => d.dependencyName),
257
+ ...(projectsVersionData[project]?.dependentProjects.map((dep) => dep.source) || []),
189
258
  ];
190
259
  })
191
260
  : // Otherwise, we use the full list of projects within the release group
@@ -193,29 +262,80 @@ async function releaseChangelog(args) {
193
262
  const projectNodes = projects.map((name) => projectGraph.nodes[name]);
194
263
  if (releaseGroup.projectsRelationship === 'independent') {
195
264
  for (const project of projectNodes) {
196
- let fromRef = args.from ||
197
- (await (0, git_1.getLatestGitTagForPattern)(releaseGroup.releaseTagPattern, {
198
- projectName: project.name,
199
- }))?.tag;
200
- let commits = null;
201
- if (!fromRef && useAutomaticFromRef) {
202
- const firstCommit = await (0, git_1.getFirstGitCommit)();
203
- const allRawCommits = await (0, git_1.getGitDiff)(firstCommit, toSHA);
204
- const allParsedCommits = (0, git_1.parseCommits)(allRawCommits);
205
- const commitsForProject = allParsedCommits.filter((c) => c.affectedFiles.find((f) => f.startsWith(project.data.root)));
206
- fromRef = commitsForProject[0]?.shortHash;
207
- if (args.verbose) {
208
- console.log(`Determined --from ref for ${project.name} from the first commit in which it exists: ${fromRef}`);
209
- }
210
- commits = commitsForProject.filter((c) => applyConventionalCommitsConfigFilter(c, nxReleaseConfig.conventionalCommits));
211
- }
212
- if (!fromRef && !commits) {
213
- throw new Error(`Unable to determine the previous git tag. If this is the first release of your workspace, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTagPattern" property in nx.json to match the structure of your repository's git tags.`);
265
+ let changes = null;
266
+ // TODO: remove this after the changelog renderer is refactored to remove coupling with git commits
267
+ let commits;
268
+ if (releaseGroup.versionPlans) {
269
+ changes = filterHiddenChanges(releaseGroup.versionPlans
270
+ .map((vp) => {
271
+ const parsedMessage = (0, git_1.parseConventionalCommitsMessage)(vp.message);
272
+ // only properly formatted conventional commits messages will be included in the changelog
273
+ if (!parsedMessage) {
274
+ return null;
275
+ }
276
+ return {
277
+ type: parsedMessage.type,
278
+ scope: parsedMessage.scope,
279
+ description: parsedMessage.description,
280
+ body: '',
281
+ isBreaking: parsedMessage.breaking,
282
+ affectedProjects: Object.keys(vp.projectVersionBumps),
283
+ githubReferences: [],
284
+ };
285
+ })
286
+ .filter(Boolean), nxReleaseConfig.conventionalCommits);
214
287
  }
215
- if (!commits) {
216
- commits = await getCommits(fromRef, toSHA, nxReleaseConfig.conventionalCommits);
288
+ else {
289
+ let fromRef = args.from ||
290
+ (await (0, git_1.getLatestGitTagForPattern)(releaseGroup.releaseTagPattern, {
291
+ projectName: project.name,
292
+ }))?.tag;
293
+ if (!fromRef && useAutomaticFromRef) {
294
+ const firstCommit = await (0, git_1.getFirstGitCommit)();
295
+ const allCommits = await getCommits(firstCommit, toSHA);
296
+ const commitsForProject = allCommits.filter((c) => c.affectedFiles.find((f) => f.startsWith(project.data.root)));
297
+ fromRef = commitsForProject[0]?.shortHash;
298
+ if (args.verbose) {
299
+ console.log(`Determined --from ref for ${project.name} from the first commit in which it exists: ${fromRef}`);
300
+ }
301
+ commits = commitsForProject;
302
+ }
303
+ if (!fromRef && !commits) {
304
+ throw new Error(`Unable to determine the previous git tag. If this is the first release of your workspace, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTagPattern" property in nx.json to match the structure of your repository's git tags.`);
305
+ }
306
+ if (!commits) {
307
+ commits = await getCommits(fromRef, toSHA);
308
+ }
309
+ const { fileMap } = await (0, file_map_utils_1.createFileMapUsingProjectGraph)(projectGraph);
310
+ const fileToProjectMap = createFileToProjectMap(fileMap.projectFileMap);
311
+ changes = filterHiddenChanges(commits.map((c) => ({
312
+ type: c.type,
313
+ scope: c.scope,
314
+ description: c.description,
315
+ body: c.body,
316
+ isBreaking: c.isBreaking,
317
+ githubReferences: c.references,
318
+ author: c.author,
319
+ shortHash: c.shortHash,
320
+ revertedHashes: c.revertedHashes,
321
+ affectedProjects: commitChangesNonProjectFiles(c, fileMap.nonProjectFiles)
322
+ ? '*'
323
+ : getProjectsAffectedByCommit(c, fileToProjectMap),
324
+ })), nxReleaseConfig.conventionalCommits);
217
325
  }
218
- const projectChangelogs = await generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, releaseGroup, [project], nxReleaseConfig, projectToAdditionalDependencyBumps);
326
+ const projectChangelogs = await generateChangelogForProjects({
327
+ tree,
328
+ args,
329
+ projectGraph,
330
+ changes,
331
+ projectsVersionData,
332
+ releaseGroup,
333
+ projects: [project],
334
+ nxReleaseConfig,
335
+ projectToAdditionalDependencyBumps,
336
+ // TODO: remove this after the changelog renderer is refactored to remove coupling with git commits
337
+ commits: filterHiddenCommits(commits, nxReleaseConfig.conventionalCommits),
338
+ });
219
339
  let hasPushed = false;
220
340
  for (const [projectName, projectChangelog] of Object.entries(projectChangelogs)) {
221
341
  if (projectChangelogs &&
@@ -240,23 +360,77 @@ async function releaseChangelog(args) {
240
360
  }
241
361
  }
242
362
  else {
243
- let fromRef = args.from ||
244
- (await (0, git_1.getLatestGitTagForPattern)(releaseGroup.releaseTagPattern))?.tag;
245
- if (!fromRef) {
246
- if (useAutomaticFromRef) {
247
- fromRef = await (0, git_1.getFirstGitCommit)();
248
- if (args.verbose) {
249
- console.log(`Determined release group --from ref from the first commit in the workspace: ${fromRef}`);
363
+ let changes = [];
364
+ // TODO: remove this after the changelog renderer is refactored to remove coupling with git commits
365
+ let commits = [];
366
+ if (releaseGroup.versionPlans) {
367
+ changes = filterHiddenChanges(releaseGroup.versionPlans
368
+ .map((vp) => {
369
+ const parsedMessage = (0, git_1.parseConventionalCommitsMessage)(vp.message);
370
+ // only properly formatted conventional commits messages will be included in the changelog
371
+ if (!parsedMessage) {
372
+ return null;
373
+ }
374
+ return {
375
+ type: parsedMessage.type,
376
+ scope: parsedMessage.scope,
377
+ description: parsedMessage.description,
378
+ body: '',
379
+ isBreaking: parsedMessage.breaking,
380
+ githubReferences: [],
381
+ affectedProjects: '*',
382
+ };
383
+ })
384
+ .filter(Boolean), nxReleaseConfig.conventionalCommits);
385
+ }
386
+ else {
387
+ let fromRef = args.from ||
388
+ (await (0, git_1.getLatestGitTagForPattern)(releaseGroup.releaseTagPattern))
389
+ ?.tag;
390
+ if (!fromRef) {
391
+ if (useAutomaticFromRef) {
392
+ fromRef = await (0, git_1.getFirstGitCommit)();
393
+ if (args.verbose) {
394
+ console.log(`Determined release group --from ref from the first commit in the workspace: ${fromRef}`);
395
+ }
396
+ }
397
+ else {
398
+ throw new Error(`Unable to determine the previous git tag. If this is the first release of your release group, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTagPattern" property in nx.json to match the structure of your repository's git tags.`);
250
399
  }
251
400
  }
252
- else {
253
- throw new Error(`Unable to determine the previous git tag. If this is the first release of your release group, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTagPattern" property in nx.json to match the structure of your repository's git tags.`);
254
- }
401
+ // Make sure that the fromRef is actually resolvable
402
+ const fromSHA = await (0, git_1.getCommitHash)(fromRef);
403
+ const { fileMap } = await (0, file_map_utils_1.createFileMapUsingProjectGraph)(projectGraph);
404
+ const fileToProjectMap = createFileToProjectMap(fileMap.projectFileMap);
405
+ commits = await getCommits(fromSHA, toSHA);
406
+ changes = filterHiddenChanges(commits.map((c) => ({
407
+ type: c.type,
408
+ scope: c.scope,
409
+ description: c.description,
410
+ body: c.body,
411
+ isBreaking: c.isBreaking,
412
+ githubReferences: c.references,
413
+ author: c.author,
414
+ shortHash: c.shortHash,
415
+ revertedHashes: c.revertedHashes,
416
+ affectedProjects: commitChangesNonProjectFiles(c, fileMap.nonProjectFiles)
417
+ ? '*'
418
+ : getProjectsAffectedByCommit(c, fileToProjectMap),
419
+ })), nxReleaseConfig.conventionalCommits);
255
420
  }
256
- // Make sure that the fromRef is actually resolvable
257
- const fromSHA = await (0, git_1.getCommitHash)(fromRef);
258
- const commits = await getCommits(fromSHA, toSHA, nxReleaseConfig.conventionalCommits);
259
- const projectChangelogs = await generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, releaseGroup, projectNodes, nxReleaseConfig, projectToAdditionalDependencyBumps);
421
+ const projectChangelogs = await generateChangelogForProjects({
422
+ tree,
423
+ args,
424
+ projectGraph,
425
+ changes,
426
+ projectsVersionData,
427
+ releaseGroup,
428
+ projects: projectNodes,
429
+ nxReleaseConfig,
430
+ projectToAdditionalDependencyBumps,
431
+ // TODO: remove this after the changelog renderer is refactored to remove coupling with git commits
432
+ commits: filterHiddenCommits(commits, nxReleaseConfig.conventionalCommits),
433
+ });
260
434
  let hasPushed = false;
261
435
  for (const [projectName, projectChangelog] of Object.entries(projectChangelogs)) {
262
436
  if (projectChangelogs &&
@@ -280,7 +454,7 @@ async function releaseChangelog(args) {
280
454
  }
281
455
  }
282
456
  }
283
- await applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTasks, commitMessageValues, gitTagValues);
457
+ await applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTasks, commitMessageValues, gitTagValues, releaseGroups);
284
458
  return {
285
459
  workspaceChangelog,
286
460
  projectChangelogs: allProjectChangelogs,
@@ -326,7 +500,7 @@ function resolveChangelogVersions(args, releaseGroups, releaseGroupToFilteredPro
326
500
  projectsVersionData: versionData,
327
501
  };
328
502
  }
329
- async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTasks, commitMessageValues, gitTagValues) {
503
+ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTasks, commitMessageValues, gitTagValues, releaseGroups) {
330
504
  let latestCommit = toSHA;
331
505
  const changes = tree.listChanges();
332
506
  /**
@@ -363,9 +537,30 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
363
537
  }
364
538
  return;
365
539
  }
540
+ const changedFiles = changes.map((f) => f.path);
541
+ let deletedFiles = [];
542
+ if (args.deleteVersionPlans && !args.dryRun) {
543
+ const planFiles = new Set();
544
+ releaseGroups.forEach((group) => {
545
+ if (group.versionPlans) {
546
+ group.versionPlans.forEach((plan) => {
547
+ (0, fs_extra_1.removeSync)(plan.absolutePath);
548
+ planFiles.add(plan.relativePath);
549
+ });
550
+ }
551
+ });
552
+ deletedFiles = Array.from(planFiles);
553
+ }
366
554
  // Generate a new commit for the changes, if configured to do so
367
555
  if (args.gitCommit ?? nxReleaseConfig.changelog.git.commit) {
368
- await (0, shared_1.commitChanges)(changes.map((f) => f.path), !!args.dryRun, !!args.verbose, commitMessageValues, args.gitCommitArgs || nxReleaseConfig.changelog.git.commitArgs);
556
+ await (0, shared_1.commitChanges)({
557
+ changedFiles,
558
+ deletedFiles,
559
+ isDryRun: !!args.dryRun,
560
+ isVerbose: !!args.verbose,
561
+ gitCommitMessages: commitMessageValues,
562
+ gitCommitArgs: args.gitCommitArgs || nxReleaseConfig.changelog.git.commitArgs,
563
+ });
369
564
  // Resolve the commit we just made
370
565
  latestCommit = await (0, git_1.getCommitHash)('HEAD');
371
566
  }
@@ -373,7 +568,8 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
373
568
  changes.length) {
374
569
  output_1.output.logSingleLine(`Staging changed files with git`);
375
570
  await (0, git_1.gitAdd)({
376
- changedFiles: changes.map((f) => f.path),
571
+ changedFiles,
572
+ deletedFiles,
377
573
  dryRun: args.dryRun,
378
574
  verbose: args.verbose,
379
575
  });
@@ -397,7 +593,7 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
397
593
  }
398
594
  return;
399
595
  }
400
- async function generateChangelogForWorkspace(tree, args, projectGraph, nxReleaseConfig, workspaceChangelogVersion, commits) {
596
+ async function generateChangelogForWorkspace({ tree, args, projectGraph, nxReleaseConfig, workspaceChangelogVersion, changes, commits, }) {
401
597
  const config = nxReleaseConfig.changelog.workspaceChangelog;
402
598
  // The entire feature is disabled at the workspace level, exit early
403
599
  if (config === false) {
@@ -458,6 +654,7 @@ async function generateChangelogForWorkspace(tree, args, projectGraph, nxRelease
458
654
  const githubRepoSlug = (0, github_1.getGitHubRepoSlug)(gitRemote);
459
655
  let contents = await changelogRenderer({
460
656
  projectGraph,
657
+ changes,
461
658
  commits,
462
659
  releaseVersion: releaseVersion.rawVersion,
463
660
  project: null,
@@ -507,7 +704,7 @@ async function generateChangelogForWorkspace(tree, args, projectGraph, nxRelease
507
704
  contents,
508
705
  };
509
706
  }
510
- async function generateChangelogForProjects(tree, args, projectGraph, commits, projectsVersionData, releaseGroup, projects, nxReleaseConfig, projectToAdditionalDependencyBumps) {
707
+ async function generateChangelogForProjects({ tree, args, projectGraph, changes, commits, projectsVersionData, releaseGroup, projects, nxReleaseConfig, projectToAdditionalDependencyBumps, }) {
511
708
  const config = releaseGroup.changelog;
512
709
  // The entire feature is disabled at the release group level, exit early
513
710
  if (config === false) {
@@ -551,6 +748,7 @@ async function generateChangelogForProjects(tree, args, projectGraph, commits, p
551
748
  : undefined;
552
749
  let contents = await changelogRenderer({
553
750
  projectGraph,
751
+ changes,
554
752
  commits,
555
753
  releaseVersion: releaseVersion.rawVersion,
556
754
  project: project.name,
@@ -623,24 +821,36 @@ function checkChangelogFilesEnabled(nxReleaseConfig) {
623
821
  }
624
822
  return false;
625
823
  }
626
- async function getCommits(fromSHA, toSHA, conventionalCommitsConfig) {
824
+ async function getCommits(fromSHA, toSHA) {
627
825
  const rawCommits = await (0, git_1.getGitDiff)(fromSHA, toSHA);
628
826
  // Parse as conventional commits
629
- const parsedCommits = (0, git_1.parseCommits)(rawCommits);
630
- if (conventionalCommitsConfig === null) {
631
- return parsedCommits;
632
- }
633
- // Apply filtering based on the conventional commits configuration
634
- return parsedCommits.filter((c) => applyConventionalCommitsConfigFilter(c, conventionalCommitsConfig));
827
+ return (0, git_1.parseCommits)(rawCommits);
635
828
  }
636
- function applyConventionalCommitsConfigFilter(commit, conventionalCommitsConfig) {
637
- const type = commit.type;
638
- const typeConfig = conventionalCommitsConfig.types[type];
639
- if (!typeConfig) {
640
- // don't include commits with unknown types
641
- return false;
642
- }
643
- return !typeConfig.changelog.hidden;
829
+ function filterHiddenChanges(changes, conventionalCommitsConfig) {
830
+ return changes.filter((change) => {
831
+ const type = change.type;
832
+ const typeConfig = conventionalCommitsConfig.types[type];
833
+ if (!typeConfig) {
834
+ // don't include changes with unknown types
835
+ return false;
836
+ }
837
+ return !typeConfig.changelog.hidden;
838
+ });
839
+ }
840
+ // TODO: remove this after the changelog renderer is refactored to remove coupling with git commits
841
+ function filterHiddenCommits(commits, conventionalCommitsConfig) {
842
+ if (!commits) {
843
+ return [];
844
+ }
845
+ return commits.filter((commit) => {
846
+ const type = commit.type;
847
+ const typeConfig = conventionalCommitsConfig.types[type];
848
+ if (!typeConfig) {
849
+ // don't include commits with unknown types
850
+ return false;
851
+ }
852
+ return !typeConfig.changelog.hidden;
853
+ });
644
854
  }
645
855
  function shouldCreateGitHubRelease(changelogConfig, createReleaseArg = undefined) {
646
856
  if (createReleaseArg !== undefined) {
@@ -665,3 +875,22 @@ async function promptForGitHubRelease() {
665
875
  return false;
666
876
  }
667
877
  }
878
+ function getProjectsAffectedByCommit(commit, fileToProjectMap) {
879
+ const affectedProjects = new Set();
880
+ for (const file of commit.affectedFiles) {
881
+ affectedProjects.add(fileToProjectMap[file]);
882
+ }
883
+ return Array.from(affectedProjects);
884
+ }
885
+ function commitChangesNonProjectFiles(commit, nonProjectFiles) {
886
+ return nonProjectFiles.some((fileData) => commit.affectedFiles.includes(fileData.file));
887
+ }
888
+ function createFileToProjectMap(projectFileMap) {
889
+ const fileToProjectMap = {};
890
+ for (const [projectName, projectFiles] of Object.entries(projectFileMap)) {
891
+ for (const file of projectFiles) {
892
+ fileToProjectMap[file.file] = projectName;
893
+ }
894
+ }
895
+ return fileToProjectMap;
896
+ }
@@ -6,7 +6,6 @@ export interface NxReleaseArgs {
6
6
  projects?: string[];
7
7
  dryRun?: boolean;
8
8
  verbose?: boolean;
9
- firstRelease?: boolean;
10
9
  }
11
10
  interface GitCommitAndTagOptions {
12
11
  stageChanges?: boolean;
@@ -17,13 +16,13 @@ interface GitCommitAndTagOptions {
17
16
  gitTagMessage?: string;
18
17
  gitTagArgs?: string;
19
18
  }
20
- export type VersionOptions = NxReleaseArgs & GitCommitAndTagOptions & {
19
+ export type VersionOptions = NxReleaseArgs & GitCommitAndTagOptions & VersionPlanArgs & FirstReleaseArgs & {
21
20
  specifier?: string;
22
21
  preid?: string;
23
22
  stageChanges?: boolean;
24
23
  generatorOptionsOverrides?: Record<string, unknown>;
25
24
  };
26
- export type ChangelogOptions = NxReleaseArgs & GitCommitAndTagOptions & {
25
+ export type ChangelogOptions = NxReleaseArgs & GitCommitAndTagOptions & VersionPlanArgs & FirstReleaseArgs & {
27
26
  version?: string | null;
28
27
  versionData?: VersionData;
29
28
  to?: string;
@@ -34,14 +33,24 @@ export type ChangelogOptions = NxReleaseArgs & GitCommitAndTagOptions & {
34
33
  };
35
34
  export type PublishOptions = NxReleaseArgs & Partial<RunManyOptions> & {
36
35
  outputStyle?: OutputStyle;
37
- } & {
36
+ } & FirstReleaseArgs & {
38
37
  registry?: string;
39
38
  tag?: string;
40
39
  otp?: number;
41
40
  };
42
- export type ReleaseOptions = NxReleaseArgs & {
41
+ export type PlanOptions = NxReleaseArgs & {
42
+ bump?: string;
43
+ message?: string;
44
+ };
45
+ export type ReleaseOptions = NxReleaseArgs & FirstReleaseArgs & {
43
46
  yes?: boolean;
44
47
  skipPublish?: boolean;
45
48
  };
49
+ export type VersionPlanArgs = {
50
+ deleteVersionPlans?: boolean;
51
+ };
52
+ export type FirstReleaseArgs = {
53
+ firstRelease?: boolean;
54
+ };
46
55
  export declare const yargsReleaseCommand: CommandModule<Record<string, unknown>, NxReleaseArgs>;
47
56
  export {};