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
Replace changelog versions in ./scripts/draft-blog-post.js #9058
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,17 @@ | |
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
const { execSync } = require("child_process"); | ||
const rimraf = require("rimraf"); | ||
const semver = require("semver"); | ||
|
||
const changelogUnreleasedDir = path.join(__dirname, "../changelog_unreleased"); | ||
const blogDir = path.join(__dirname, "../website/blog"); | ||
const introFile = path.join(changelogUnreleasedDir, "blog-post-intro.md"); | ||
const version = require("../package.json").version.replace(/-.+/, ""); | ||
const previousVersion = execSync("git describe --tags --abbrev=0") | ||
.toString() | ||
.trim(); | ||
const postGlob = path.join(blogDir, `????-??-??-${version}.md`); | ||
const postFile = path.join( | ||
blogDir, | ||
|
@@ -80,22 +85,24 @@ rimraf.sync(postGlob); | |
|
||
fs.writeFileSync( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we run prettier.format on this file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is created when repo linting with stable, and merge when master already released and updated, so there is a chance this file will fail on lint? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There may be a chance. But we use this script when before release. So I'm not sure if the problem is fixed with using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use stable prettier format it, it will fail after merge. 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep as it is, for now. |
||
postFile, | ||
[ | ||
fs.readFileSync(introFile, "utf8").trim(), | ||
"<!--truncate-->", | ||
...printEntries({ | ||
title: "Highlights", | ||
filter: (entry) => entry.highlight, | ||
}), | ||
...printEntries({ | ||
title: "Breaking changes", | ||
filter: (entry) => entry.breaking && !entry.highlight, | ||
}), | ||
...printEntries({ | ||
title: "Other changes", | ||
filter: (entry) => !entry.breaking && !entry.highlight, | ||
}), | ||
].join("\n\n") + "\n" | ||
replaceVersions( | ||
[ | ||
fs.readFileSync(introFile, "utf8").trim(), | ||
"<!--truncate-->", | ||
...printEntries({ | ||
title: "Highlights", | ||
filter: (entry) => entry.highlight, | ||
}), | ||
...printEntries({ | ||
title: "Breaking changes", | ||
filter: (entry) => entry.breaking && !entry.highlight, | ||
}), | ||
...printEntries({ | ||
title: "Other changes", | ||
filter: (entry) => !entry.breaking && !entry.highlight, | ||
}), | ||
].join("\n\n") + "\n" | ||
) | ||
); | ||
|
||
function printEntries({ title, filter }) { | ||
|
@@ -115,3 +122,13 @@ function printEntries({ title, filter }) { | |
|
||
return result; | ||
} | ||
|
||
function formatVersion(version) { | ||
return `${semver.major(version)}.${semver.minor(version)}`; | ||
} | ||
|
||
function replaceVersions(data) { | ||
return data | ||
.replace(/prettier stable/gi, `Prettier ${formatVersion(previousVersion)}`) | ||
.replace(/prettier master/gi, `Prettier ${formatVersion(version)}`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about
require('prettier/package.json').version