Skip to content

Commit dcc88e3

Browse files
authored
fix: make useChangelogEntry and useShortPrLink optional (#249)
Fixes 3 issues: 1. In the TypeScript API, the new options `useChangelogEntry` and `useShortPrLink` are now optional 2. Fixes the script called "changelog" by changing it from `node dist/cli.js` to `node dist/cli.mjs` 3. Added documentation to README.md for the new options
1 parent f8c5f7d commit dcc88e3

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ or
2828

2929
`yarn run auto-changelog update --autoCategorize`
3030

31+
#### Read the "CHANGELOG entry:" on the PR
32+
33+
`yarn run auto-changelog update --useChangelogEntry`
34+
35+
#### Use Short PR links
36+
37+
- Like `(#247)` instead of `([#247](https://github.com/MetaMask/auto-changelog/pull/247))`
38+
39+
`yarn run auto-changelog update --useShortPrLink`
40+
3141
#### Update the current release section of the changelog
3242

3343
`yarn run auto-changelog update --rc`
@@ -36,6 +46,10 @@ or
3646

3747
`npm run auto-changelog update --rc`
3848

49+
### Deluxe, as used in metamask-extension
50+
51+
`yarn run auto-changelog update --autoCategorize --useChangelogEntry --useShortPrLink --rc`
52+
3953
#### Update the changelog for a renamed package
4054

4155
This option is designed to be used for packages that live in a monorepo.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
],
3131
"scripts": {
3232
"build": "ts-bridge --project tsconfig.build.json --clean",
33-
"changelog": "node dist/cli.js",
33+
"changelog": "node dist/cli.mjs",
3434
"lint": "yarn lint:eslint && yarn lint:misc --check",
3535
"lint:eslint": "eslint . --cache --ext js,ts",
3636
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",

src/update-changelog.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ describe('updateChangelog', () => {
8383
expect(result).toContain('### Added\n- New cool feature (#124)');
8484
expect(result).toContain('### Fixed\n- Fixed a critical bug (#123)');
8585
});
86+
87+
it('should have default values for useChangelogEntry and useShortPrLink', async () => {
88+
jest
89+
.spyOn(ChangeLogUtils, 'getNewChangeEntries')
90+
.mockResolvedValue(getNewChangeEntriesMockData);
91+
92+
const result = await ChangeLogManager.updateChangelog({
93+
...changelogData,
94+
useChangelogEntry: undefined,
95+
useShortPrLink: undefined,
96+
});
97+
98+
expect(result).toContain('### Added\n- New cool feature (#124)');
99+
expect(result).toContain('### Fixed\n- Fixed a critical bug (#123)');
100+
});
86101
});
87102

88103
describe('getCategory', () => {

src/update-changelog.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ export type UpdateChangelogOptions = {
9696
/**
9797
* Whether to use `CHANGELOG entry:` from the commit body and the no-changelog label
9898
*/
99-
useChangelogEntry: boolean;
99+
useChangelogEntry?: boolean;
100100
/**
101101
* Whether to use short PR links in the changelog entries.
102102
*/
103-
useShortPrLink: boolean;
103+
useShortPrLink?: boolean;
104104
};
105105

106106
/**
@@ -141,8 +141,8 @@ export async function updateChangelog({
141141
formatter = undefined,
142142
packageRename,
143143
autoCategorize,
144-
useChangelogEntry,
145-
useShortPrLink,
144+
useChangelogEntry = false,
145+
useShortPrLink = false,
146146
}: UpdateChangelogOptions): Promise<string | undefined> {
147147
const changelog = parseChangelog({
148148
changelogContent,

0 commit comments

Comments
 (0)