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.
- package/bin/post-install.js +8 -8
- package/migrations.json +6 -0
- package/package.json +13 -12
- package/release/changelog-renderer/index.d.ts +6 -3
- package/release/changelog-renderer/index.js +53 -50
- package/schemas/nx-schema.json +8 -0
- package/src/command-line/add/add.d.ts +1 -1
- package/src/command-line/add/command-object.js +3 -1
- package/src/command-line/affected/command-object.js +10 -5
- package/src/command-line/deprecated/command-objects.js +12 -6
- package/src/command-line/examples.js +18 -0
- package/src/command-line/generate/generate.d.ts +1 -1
- package/src/command-line/migrate/migrate.d.ts +1 -1
- package/src/command-line/new/new.d.ts +1 -1
- package/src/command-line/release/changelog.d.ts +17 -1
- package/src/command-line/release/changelog.js +305 -76
- package/src/command-line/release/command-object.d.ts +14 -5
- package/src/command-line/release/command-object.js +52 -24
- package/src/command-line/release/config/config.js +38 -6
- package/src/command-line/release/config/filter-release-groups.d.ts +3 -1
- package/src/command-line/release/config/filter-release-groups.js +1 -0
- package/src/command-line/release/config/version-plans.d.ts +24 -0
- package/src/command-line/release/config/version-plans.js +184 -0
- package/src/command-line/release/plan.d.ts +3 -0
- package/src/command-line/release/plan.js +184 -0
- package/src/command-line/release/publish.d.ts +1 -1
- package/src/command-line/release/release.d.ts +1 -1
- package/src/command-line/release/release.js +40 -0
- package/src/command-line/release/utils/git.d.ts +10 -2
- package/src/command-line/release/utils/git.js +45 -10
- package/src/command-line/release/utils/shared.d.ts +12 -2
- package/src/command-line/release/utils/shared.js +3 -2
- package/src/command-line/release/version.d.ts +3 -2
- package/src/command-line/release/version.js +43 -5
- package/src/command-line/repair/repair.d.ts +1 -1
- package/src/command-line/reset/command-object.d.ts +6 -1
- package/src/command-line/reset/command-object.js +15 -2
- package/src/command-line/reset/reset.d.ts +2 -1
- package/src/command-line/reset/reset.js +98 -16
- package/src/command-line/run/command-object.js +6 -3
- package/src/command-line/run/run.d.ts +2 -2
- package/src/command-line/run-many/command-object.js +6 -3
- package/src/command-line/show/command-object.js +6 -6
- package/src/config/misc-interfaces.d.ts +15 -3
- package/src/config/nx-json.d.ts +11 -0
- package/src/core/graph/main.js +1 -1
- package/src/daemon/server/plugins.js +1 -0
- package/src/daemon/tmp-dir.js +1 -1
- package/src/devkit-exports.d.ts +1 -1
- package/src/migrations/update-19-2-0/move-workspace-data-directory.d.ts +4 -0
- package/src/migrations/update-19-2-0/move-workspace-data-directory.js +34 -0
- package/src/plugins/js/index.js +2 -2
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +11 -0
- package/src/plugins/js/project-graph/affected/npm-packages.js +12 -0
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +3 -11
- package/src/plugins/js/utils/config.js +4 -0
- package/src/plugins/js/utils/register.d.ts +4 -3
- package/src/plugins/js/utils/register.js +47 -4
- package/src/project-graph/affected/affected-project-graph.js +6 -6
- package/src/project-graph/nx-deps-cache.js +6 -6
- package/src/project-graph/plugins/loader.js +1 -1
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
- package/src/tasks-runner/task-env.js +12 -0
- package/src/utils/cache-directory.d.ts +1 -1
- package/src/utils/cache-directory.js +13 -6
- package/src/utils/get-package-name-from-import-path.d.ts +1 -0
- package/src/utils/get-package-name-from-import-path.js +18 -0
- package/src/utils/package-json.d.ts +1 -0
- package/src/utils/package-manager.js +42 -9
- package/src/utils/params.d.ts +1 -1
- 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
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
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
|
-
|
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
|
-
...(
|
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
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
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
|
-
|
216
|
-
|
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(
|
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
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
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
|
-
|
253
|
-
|
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
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
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)(
|
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
|
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
|
824
|
+
async function getCommits(fromSHA, toSHA) {
|
627
825
|
const rawCommits = await (0, git_1.getGitDiff)(fromSHA, toSHA);
|
628
826
|
// Parse as conventional commits
|
629
|
-
|
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
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
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
|
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 {};
|