Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc/add changeset link #294

Merged
merged 2 commits into from
May 17, 2024
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
57 changes: 57 additions & 0 deletions .changeset/changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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,
options
) => {
if (dependenciesUpdated.length === 0) return "";


const changesetLinks = changesets.map(
(changeset) => {
const commitShortId = changeset.commit.slice(0, 7);
const commitLink = options?.repo ? `[${commitShortId}](https://github.com/${options.repo}/commit/${changeset.commit})` : commitShortId;
return `- Updated dependencies${changeset.commit ? ` [${commitLink}]` : ""
}`;
}
);

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.

Loading