Skip to content

Commit

Permalink
Change format changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
cregourd committed May 17, 2024
1 parent 3973396 commit 66c2933
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 6 deletions.
52 changes: 52 additions & 0 deletions .changeset/changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const getReleaseLine = async (
changeset,
_type,
options
) => {

const [firstLine, ...futureLines] = changeset.summary
.split("\n")
.map((l) => l.trimRight());

const commitShortId = changeset.commit.slice(0, 7);
const commitLink = options?.repo ? `[${commitShortId}](https://github.com/${options.repo}/commit/${changeset.commit})` : commitShortId;
let returnVal = `- ${changeset.commit ? `${commitLink}: ` : ""
}${firstLine}`;

if (futureLines.length > 0) {
returnVal += `\n${futureLines.map((l) => ` ${l}`).join("\n")}`;
}

const issueRegex = /#(\d+)/g;
returnVal = returnVal.replace(issueRegex, (_, issueNumber) => {
return `[#${issueNumber}](https://github.com/${options.repo}/issues/${issueNumber})`;
});

return returnVal;
};

const getDependencyReleaseLine = async (
changesets,
dependenciesUpdated
) => {
if (dependenciesUpdated.length === 0) return "";

const changesetLinks = changesets.map(
(changeset) =>
`- Updated dependencies${changeset.commit ? ` [${changeset.commit.slice(0, 7)}]` : ""
}`
);

const updatedDependenciesList = dependenciesUpdated.map(
(dependency) => ` - ${dependency.name}@${dependency.newVersion}`
);

return [...changesetLinks, ...updatedDependenciesList].join("\n");
};

const defaultChangelogFunctions = {
getReleaseLine,
getDependencyReleaseLine,
};

module.exports = defaultChangelogFunctions;
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "premieroctet/next-admin"}],
"changelog": ["./changelog.js", { "repo": "premieroctet/next-admin" }],
"commit": false,
"fixed": [],
"linked": [],
Expand Down
5 changes: 0 additions & 5 deletions .changeset/forty-tips-burn.md

This file was deleted.

0 comments on commit 66c2933

Please sign in to comment.