Skip to content

Commit

Permalink
feat(core): support changelog customizations and project changelogs
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Oct 19, 2023
1 parent b9e671c commit e6c5912
Show file tree
Hide file tree
Showing 16 changed files with 2,320 additions and 671 deletions.
22 changes: 5 additions & 17 deletions docs/generated/cli/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,6 @@ nx release changelog [version]

#### Options

##### createRelease

Type: `string`

Choices: [github]

Create a release for the given version on a supported source control service provider, such as Github.

##### file

Type: `string`

Default: `CHANGELOG.md`

The name of the file to write the changelog to. It can also be set to `false` to disable file generation. Defaults to CHANGELOG.md.

##### from

Type: `string`
Expand All @@ -139,7 +123,11 @@ Show help

##### interactive

Type: `boolean`
Type: `string`

Choices: [all, workspace, projects]

Interactively modify changelog markdown contents in your code editor before applying the changes. You can set it to be interactive for all changelogs, or only the workspace level, or only the project level

##### tagVersionPrefix

Expand Down
4 changes: 2 additions & 2 deletions docs/generated/devkit/FileChange.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Description of a file change in the Nx virtual file system/
- [content](../../devkit/documents/FileChange#content): Buffer
- [options](../../devkit/documents/FileChange#options): TreeWriteOptions
- [path](../../devkit/documents/FileChange#path): string
- [type](../../devkit/documents/FileChange#type): "CREATE" | "DELETE" | "UPDATE"
- [type](../../devkit/documents/FileChange#type): "DELETE" | "CREATE" | "UPDATE"

## Properties

Expand Down Expand Up @@ -39,6 +39,6 @@ Path relative to the workspace root

### type

**type**: `"CREATE"` \| `"DELETE"` \| `"UPDATE"`
**type**: `"DELETE"` \| `"CREATE"` \| `"UPDATE"`

Type of change: 'CREATE' | 'DELETE' | 'UPDATE'
22 changes: 5 additions & 17 deletions docs/generated/packages/nx/documents/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,6 @@ nx release changelog [version]

#### Options

##### createRelease

Type: `string`

Choices: [github]

Create a release for the given version on a supported source control service provider, such as Github.

##### file

Type: `string`

Default: `CHANGELOG.md`

The name of the file to write the changelog to. It can also be set to `false` to disable file generation. Defaults to CHANGELOG.md.

##### from

Type: `string`
Expand All @@ -139,7 +123,11 @@ Show help

##### interactive

Type: `boolean`
Type: `string`

Choices: [all, workspace, projects]

Interactively modify changelog markdown contents in your code editor before applying the changes. You can set it to be interactive for all changelogs, or only the workspace level, or only the project level

##### tagVersionPrefix

Expand Down
99 changes: 96 additions & 3 deletions e2e/release/src/release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ expect.addSnapshotSerializer({
.replaceAll(/\d*B package\.json/g, 'XXXB package.json')
.replaceAll(/size:\s*\d*\s?B/g, 'size: XXXB')
.replaceAll(/\d*\.\d*\s?kB/g, 'XXX.XXX kb')
.replaceAll(/[a-fA-F0-9]{7}/g, '{COMMIT_SHA}')
// We trim each line to reduce the chances of snapshot flakiness
.split('\n')
.map((r) => r.trim())
Expand Down Expand Up @@ -122,10 +123,10 @@ describe('nx release', () => {
const changelogOutput = runCLI(`release changelog 999.9.9`);
expect(changelogOutput).toMatchInlineSnapshot(`
> NX Generating a CHANGELOG.md entry for v999.9.9
> NX Generating an entry in CHANGELOG.md for v999.9.9
+ ## v999.9.9
+ ## 999.9.9
+
+
+ ### 🚀 Features
Expand All @@ -140,7 +141,7 @@ describe('nx release', () => {
`);

expect(readFile('CHANGELOG.md')).toMatchInlineSnapshot(`
## v999.9.9
## 999.9.9
### 🚀 Features
Expand Down Expand Up @@ -544,6 +545,98 @@ describe('nx release', () => {
.trim()
).toEqual('1000.0.0-next.0');

// Update custom nx release config to demonstrate project level changelogs
updateJson<NxJsonConfiguration>('nx.json', (nxJson) => {
nxJson.release = {
groups: {
default: {
// @proj/source will be added as a project by the verdaccio setup, but we aren't versioning or publishing it, so we exclude it here
projects: ['*', '!@proj/source'],
changelog: {
// This should be merged with and take priority over the projectChangelogs config at the root of the config
createRelease: 'github',
},
},
},
changelog: {
projectChangelogs: {
renderOptions: {
createRelease: false, // will be overridden by the group
// Customize the changelog renderer to not print the Thank You section this time (not overridden by the group)
includeAuthors: false,
},
},
},
};
return nxJson;
});

// We need a valid git origin for the command to work when createRelease is set
await runCommandAsync(
`git remote add origin https://github.com/nrwl/fake-repo.git`
);

// Perform a dry-run this time to show that it works but also prevent making any requests to github within the test
const changelogDryRunOutput = runCLI(
`release changelog 1000.0.0-next.0 --dry-run`
);
expect(changelogDryRunOutput).toMatchInlineSnapshot(`
> NX Previewing an entry in CHANGELOG.md for v1000.0.0-next.0
+ ## 1000.0.0-next.0
+
+
+ ### 🚀 Features
+
+ - an awesome new feature
+
+ ### ❤️ Thank You
+
+ - Test
+
## 999.9.9
> NX Previewing a Github release and an entry in {project-name}/CHANGELOG.md for {project-name}@v1000.0.0-next.0
+ ## 1000.0.0-next.0
+
+
+ ### 🚀 Features
+
+ - an awesome new feature ([{COMMIT_SHA}](https://github.com/nrwl/fake-repo/commit/{COMMIT_SHA}))
> NX Previewing a Github release and an entry in {project-name}/CHANGELOG.md for {project-name}@v1000.0.0-next.0
+ ## 1000.0.0-next.0
+
+
+ ### 🚀 Features
+
+ - an awesome new feature ([{COMMIT_SHA}](https://github.com/nrwl/fake-repo/commit/{COMMIT_SHA}))
> NX Previewing a Github release and an entry in {project-name}/CHANGELOG.md for {project-name}@v1000.0.0-next.0
+ ## 1000.0.0-next.0
+
+
+ ### 🚀 Features
+
+ - an awesome new feature ([{COMMIT_SHA}](https://github.com/nrwl/fake-repo/commit/{COMMIT_SHA}))
`);

// port and process cleanup
await killProcessAndPorts(process.pid, verdaccioPort);
}, 500000);
Expand Down
Loading

0 comments on commit e6c5912

Please sign in to comment.