Skip to content

Commit

Permalink
feat: rework output and use also commit information (#6)
Browse files Browse the repository at this point in the history
Rework the output and use also the commit information.
  • Loading branch information
mheob authored Oct 20, 2022
1 parent d83c2a8 commit bea6a3c
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 155 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-dragons-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mheob/changeset-changelog': minor
---

Rework the output and use also the commit information
12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"license": "MIT",
"author": "Alexander Böhm <tools@boehm.work>",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsup",
"changeset": "changeset",
Expand All @@ -45,7 +41,8 @@
},
"dependencies": {
"@changesets/get-github-info": "^0.5.1",
"@changesets/types": "^5.2.0"
"@changesets/types": "^5.2.0",
"dotenv": "^16.0.3"
},
"devDependencies": {
"@changesets/cli": "^2.25.0",
Expand All @@ -56,7 +53,7 @@
"@mheob/prettier-config": "^2.0.2",
"@mheob/tsconfig": "^1.0.1",
"@types/node": "^18.11.0",
"@vitest/coverage-c8": "^0.24.3",
"@vitest/coverage-istanbul": "^0.24.3",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"ts-node": "^10.9.1",
Expand All @@ -69,7 +66,6 @@
"clean": true,
"entry": [
"src/index.ts"
],
"dts": true
]
}
}
132 changes: 54 additions & 78 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 33 additions & 22 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,6 @@ const getChangeset = (content: string, commit?: string): NewChangesetWithCommit
};
};

describe('getReplacedChangelog', () => {
it('should throw an error if options.repo is missing', async () => {
const changeset = getChangeset('An awesome feature.', data.commit);
const result = getReleaseLine(changeset, 'minor', {});
await expect(result).rejects.toThrowError(errorMessage);
});

it('should return the changelog in a string format', async () => {
const changeset = getChangeset('An awesome feature.\npr: #2\nauthor: @mheob', 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)] - Thanks [@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.\n');
});
});

describe('getDependencyReleaseLine', () => {
it('should throw an error if options.repo is missing', async () => {
const changeset = getChangeset('An awesome feature.', data.commit);
Expand Down Expand Up @@ -118,3 +96,36 @@ describe('getDependencyReleaseLine', () => {
);
});
});

describe('getReplacedChangelog', () => {
it('should throw an error if options.repo is missing', async () => {
const changeset = getChangeset('An awesome feature.', data.commit);
const result = getReleaseLine(changeset, 'minor', {});
await expect(result).rejects.toThrowError(errorMessage);
});

it('should return the changelog in a string format', async () => {
const changeset = getChangeset(
'An awesome feature.\npr: #2\ncommit: 38f35f8\nauthor: @mheob',
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',
);
});

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',
);
});

it('should return the changelog in a string format but without meta data', async () => {
const changeset = getChangeset('An awesome feature.');
const result = await getReleaseLine(changeset, 'minor', { repo: data.repo });
expect(result).toBe('\n- An awesome feature.\n');
});
});
Loading

0 comments on commit bea6a3c

Please sign in to comment.