-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathchangelog.js
30 lines (22 loc) · 1 KB
/
changelog.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const REPO = "aws/aws-sdk-js-codemod";
const getGithubCommitWithLink = (commit) =>
`[${commit}](https://github.com/${REPO}/commit/${commit})`;
const getDependencyReleaseLine = (changesets, dependenciesUpdated) => {
if (dependenciesUpdated.length === 0) return "";
const changesetLink = `- Updated dependencies [${changesets
.map(({ commit }) => (commit ? getGithubCommitWithLink(commit) : ""))
.filter((_) => _)
.join(", ")}]:`;
const updatedDepsList = dependenciesUpdated.map(
(dependency) => ` - ${dependency.name}@${dependency.newVersion}`
);
return [changesetLink, ...updatedDepsList].join("\n");
};
const getReleaseLine = (changeset, _type) => {
const { commit, summary } = changeset;
const [firstLine, ...futureLines] = summary.split("\n").map((l) => l.trimRight());
return `- ${firstLine} (${getGithubCommitWithLink(commit)})${
futureLines.length > 0 ? futureLines.map((l) => ` ${l}`).join("\n") : ""
}`;
};
module.exports = { getReleaseLine, getDependencyReleaseLine };