diff --git a/.changeset/changelog.js b/.changeset/changelog.js new file mode 100644 index 00000000..429c7623 --- /dev/null +++ b/.changeset/changelog.js @@ -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; \ No newline at end of file diff --git a/.changeset/config.json b/.changeset/config.json index 02251873..058f2471 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -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": [], diff --git a/.changeset/forty-tips-burn.md b/.changeset/forty-tips-burn.md deleted file mode 100644 index 2c229c5a..00000000 --- a/.changeset/forty-tips-burn.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@premieroctet/next-admin": patch ---- - -TEST