Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions bun.lock

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@types/bun": "latest",
"@types/qrcode": "^1.5.6",
"commitizen": "4.3.1",
"conventional-changelog-conventionalcommits": "10.4.0",
"conventional-changelog-conventionalcommits": "8.0.0",
"cz-conventional-changelog": "3.3.0",
"husky": "^9.1.7",
"prettier": "3.7.4",
Expand Down
34 changes: 26 additions & 8 deletions tests/release-config.test.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,52 @@
import { expect, test } from "bun:test";

test("release config recognizes bang syntax as a breaking change", async () => {
const analyzer = Bun.spawn({
test("release config analyzes and renders bang breaking changes", async () => {
const releaseProbe = Bun.spawn({
cmd: [
process.execPath,
"-e",
`
import { analyzeCommits } from "@semantic-release/commit-analyzer";
import { generateNotes } from "@semantic-release/release-notes-generator";
const releaseConfig = await Bun.file(".releaserc.json").json();
const analyzerConfig = releaseConfig.plugins[0][1];
const notesConfig = releaseConfig.plugins[1][1];
const logger = { log() {} };
const commits = [
{ hash: "breaking-commit", message: "feat!: remove a retired surface" },
];
const releaseType = await analyzeCommits(analyzerConfig, {
commits: [{ hash: "breaking-commit", message: "feat!: remove a retired surface" }],
commits,
cwd: process.cwd(),
logger,
});
console.log(releaseType);
const notes = await generateNotes(notesConfig, {
commits,
cwd: process.cwd(),
lastRelease: { gitTag: "v3.5.2" },
nextRelease: { gitTag: "v4.0.0", version: "4.0.0" },
options: { repositoryUrl: "https://github.com/hack-dance/hack.git" },
});
console.log(JSON.stringify({ notes, releaseType }));
`,
],
cwd: process.cwd(),
stderr: "pipe",
stdout: "pipe",
});
const [exitCode, stdout, stderr] = await Promise.all([
analyzer.exited,
new Response(analyzer.stdout).text(),
new Response(analyzer.stderr).text(),
releaseProbe.exited,
new Response(releaseProbe.stdout).text(),
new Response(releaseProbe.stderr).text(),
]);

expect(stderr).toBe("");
expect(exitCode).toBe(0);
expect(stdout.trim()).toBe("major");
const result = JSON.parse(stdout) as {
notes: string;
releaseType: string;
};
expect(result.releaseType).toBe("major");
expect(result.notes).toContain("BREAKING CHANGES");
expect(result.notes).toContain("remove a retired surface");
});
Loading