Skip to content

Commit

Permalink
feat: improve changelog output (#7)
Browse files Browse the repository at this point in the history
Just improve the changelog output a bit more.
  • Loading branch information
mheob authored Oct 20, 2022
1 parent bea6a3c commit f3cab4c
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
5 changes: 0 additions & 5 deletions .changeset/clever-berries-pay.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/shy-eels-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mheob/changeset-changelog': minor
---

Improve changelog output
2 changes: 0 additions & 2 deletions .changeset/twelve-rats-repair.md

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
commit: "chore(release): bump version and deploy"
title: "chore(release): bump version and deploy"
publish: pnpm run release
version: pnpm run version-packages
env:
GITHUB_TOKEN: ${{ secrets.MACHINE_USER_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 0 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@ dist
# dependencies
node_modules
pnpm-lock.yaml

# changelog
CHANGELOG.md
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

### Major Changes

- Initial creation of the package ([[#1](https://github.com/mheob/changeset-changelog/pull/1)] - Thanks [@mheob](https://github.com/mheob)!)
- Initial creation of the package --> ([#1](https://github.com/mheob/changeset-changelog/pull/1))
[`57d3b5`](https://github.com/mheob/changeset-changelog/commit/57d3b5c57cf4126c0fdd54d10d51969fe5280fa7) by
[@mheob](https://github.com/mheob))
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"test": "vitest",
"test:cov": "vitest run --coverage",
"test:run": "vitest run",
"test:ui": "vitest --ui"
"test:ui": "vitest --ui",
"version-packages": "changeset version && pnpm run format"
},
"commitlint": {
"extends": [
Expand Down
4 changes: 2 additions & 2 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ describe('getReplacedChangelog', () => {
);
const result = await getReleaseLine(changeset, 'minor', { repo: data.repo });
expect(result).toBe(
'\n- An awesome feature. ([[#2](https://github.com/mheob/changeset-changelog/pull/2)] [`38f35f8`](https://github.com/mheob/changeset-changelog/commit/38f35f8) by [@mheob](https://github.com/mheob))\n',
'\n- An awesome feature. --> ([#2](https://github.com/mheob/changeset-changelog/pull/2)) [`38f35f8`](https://github.com/mheob/changeset-changelog/commit/38f35f8) by [@mheob](https://github.com/mheob)\n',
);
});

it('should return the changelog in a string format but without meta data', async () => {
const changeset = getChangeset('An awesome feature.', data.commit);
const result = await getReleaseLine(changeset, 'minor', { repo: data.repo });
expect(result).toBe(
'\n- An awesome feature. ([[#2](https://github.com/mheob/changeset-changelog/pull/2)] [`38f35f8`](https://github.com/mheob/changeset-changelog/commit/38f35f8) by [@mheob](https://github.com/mheob))\n',
'\n- An awesome feature. --> ([#2](https://github.com/mheob/changeset-changelog/pull/2)) [`38f35f8`](https://github.com/mheob/changeset-changelog/commit/38f35f8) by [@mheob](https://github.com/mheob)\n',
);
});

Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export const getReleaseLine: GetReleaseLine = async (changeset, _type, options)
const userLink = getUserLink(usersFromSummary, user);
const [firstLine, ...futureLines] = replacedChangelog.split('\n').map((line) => line.trimEnd());

const suffix = [pull ? `[${pull}]` : '', commit ?? '', userLink ?? ''].join(' ');
const suffixedMessage = suffix.trim() ? ` (${suffix})` : '';
const suffix = [pull ? `(${pull})` : '', commit ?? '', userLink ?? ''].join(' ');
const suffixedMessage = suffix.trim() ? ` --> ${suffix}` : '';
const futureLinesMessage = futureLines.map((line) => ` ${line}`).join('\n');

return `\n- ${firstLine}${suffixedMessage}\n${futureLinesMessage}`;
Expand Down

0 comments on commit f3cab4c

Please sign in to comment.