-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #294 from premieroctet/doc/add-changeset-link
Doc/add changeset link
- Loading branch information
Showing
3 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.