Skip to content

Commit 1473a87

Browse files
author
Guy Bedford
committed
fix: changelog formatting
1 parent a87a3d9 commit 1473a87

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

.github/workflows/release-please.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- run: npm run build:files
5555
working-directory: ./documentation/app
5656

57-
- run: npm run format-changelog
57+
- run: yarn && npm run format-changelog
5858

5959
- name: Committing and push changes
6060
run: |

ci/format-changelog.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ try {
4848
}
4949

5050
function getAst(markdownString) {
51-
const tree = unified()
52-
.use(remarkParse)
53-
.parse(markdownString);
51+
const tree = unified().use(remarkParse).parse(markdownString);
5452
return tree;
5553
}
5654

@@ -94,7 +92,8 @@ function format(ast, path) {
9492
) {
9593
const link = item.children[0];
9694
item.children = [item.children[1]];
97-
item.children[0].value = link.children[0].value + item.children[0].value;
95+
item.children[0].value =
96+
link.children[0].value + item.children[0].value;
9897
changed = true;
9998
} else if (item.children.length !== 1) {
10099
console.log(
@@ -189,6 +188,19 @@ function format(ast, path) {
189188
// checks on all ### headings
190189
if (item.type === "heading" && item.depth === 3) {
191190
// check it only uses one of the fixed options for change types
191+
if (item.children.length === 1 && item.children[0].type === "text") {
192+
const val = item.children[0].value;
193+
if (val.toLowerCase().endsWith("breaking changes")) {
194+
item.children[0].value = "Changed";
195+
changed = true;
196+
} else if (val.includes("Bug Fixes")) {
197+
item.children[0].value = "Fixed";
198+
changed = true;
199+
} else if (val.includes("Features")) {
200+
item.children[0].value = "Added";
201+
changed = true;
202+
}
203+
}
192204
if (
193205
item.children.length !== 1 ||
194206
item.children[0].type !== "text" ||
@@ -226,10 +238,10 @@ function format(ast, path) {
226238

227239
if (changed) {
228240
// ...work around convoluted API...
229-
const wat = { data () {} };
241+
const wat = { data() {} };
230242
remarkStringify.call(wat);
231243
const output = wat.compiler(ast);
232-
writeFileSync(path, output, 'utf8');
244+
writeFileSync(path, `# Changelog\n\n${output}`, "utf8");
233245
}
234246

235247
return { correct: true, changed };

0 commit comments

Comments
 (0)