[release script] Update changelog script
This commit is contained in:
1 parent
448328270d
commit
277b92a883
3 files changed
+7
-367
No files matched your search
@@ -4,9 +4,8 @@ const chalk = require("chalk");
|
||||
const dedent = require("dedent");
|
||||
const execa = require("execa");
|
||||
const fs = require("fs");
|
||||
const prsMergedSince = require("prs-merged-since");
|
||||
const semver = require("semver");
|
||||
const { logPromise, waitForEnter } = require("../utils");
|
||||
const { waitForEnter } = require("../utils");
|
||||
|
||||
function getBlogPostInfo(version) {
|
||||
const date = new Date();
|
||||
@@ -20,17 +19,6 @@ function getBlogPostInfo(version) {
|
||||
};
|
||||
}
|
||||
|
||||
async function getMergedPrs(previousVersion) {
|
||||
const prs = await prsMergedSince({
|
||||
repo: "prettier/prettier",
|
||||
tag: previousVersion,
|
||||
githubApiToken: process.env.GITHUB_API_TOKEN
|
||||
});
|
||||
return prs
|
||||
.map(pr => `- ${pr.title} ([#${pr.number}](${pr.html_url}))`)
|
||||
.join("\n");
|
||||
}
|
||||
|
||||
function writeChangelog({ version, previousVersion, releaseNotes }) {
|
||||
const changelog = fs.readFileSync("CHANGELOG.md", "utf-8");
|
||||
const newEntry = dedent`
|
||||
@@ -65,28 +53,12 @@ module.exports = async function({ version, previousVersion }) {
|
||||
`)
|
||||
);
|
||||
} else {
|
||||
if (!process.env.GITHUB_API_TOKEN) {
|
||||
console.log(
|
||||
chalk`{yellow warning} GitHub API access token missing. You can expose a token via {bold GITHUB_API_TOKEN} environment variable.`
|
||||
);
|
||||
}
|
||||
|
||||
const releaseNotes = await logPromise(
|
||||
"Fetching merged PRs",
|
||||
getMergedPrs(previousVersion)
|
||||
);
|
||||
writeChangelog({
|
||||
version,
|
||||
previousVersion,
|
||||
releaseNotes
|
||||
});
|
||||
console.log();
|
||||
console.log(
|
||||
dedent(chalk`
|
||||
{yellow.bold A manual step is necessary.}
|
||||
|
||||
The script has updated the file {bold CHANGELOG.md} with all the merged PRs since the last release.
|
||||
You must edit it to focus only on relevant changes and make sure they have meaningful titles.
|
||||
You can copy the entries from {bold CHANGELOG.unreleased.md} to {bold CHANGELOG.md}
|
||||
and update it accordingly.
|
||||
|
||||
You don't need to commit the file, the script will take care of that.
|
||||
|
||||
|
||||
Reference in new issue
Block a user