Browse Source
* build: Add script to update package.json and commit for next release * fixpull/3811/head
3 changed files with 61 additions and 18 deletions
@ -0,0 +1,39 @@ |
|||||||
|
const fs = require("fs"); |
||||||
|
const util = require("util"); |
||||||
|
const exec = util.promisify(require("child_process").exec); |
||||||
|
const updateReadme = require("./updateReadme"); |
||||||
|
const updateChangelog = require("./updateChangelog"); |
||||||
|
|
||||||
|
const excalidrawDir = `${__dirname}/../src/packages/excalidraw`; |
||||||
|
const excalidrawPackage = `${excalidrawDir}/package.json`; |
||||||
|
|
||||||
|
const updatePackageVersion = (nextVersion) => { |
||||||
|
const pkg = require(excalidrawPackage); |
||||||
|
pkg.version = nextVersion; |
||||||
|
const content = `${JSON.stringify(pkg, null, 2)}\n`; |
||||||
|
fs.writeFileSync(excalidrawPackage, content, "utf-8"); |
||||||
|
}; |
||||||
|
|
||||||
|
const release = async (nextVersion) => { |
||||||
|
try { |
||||||
|
updateReadme(); |
||||||
|
await updateChangelog(nextVersion); |
||||||
|
updatePackageVersion(); |
||||||
|
await exec(`git add -u`); |
||||||
|
await exec( |
||||||
|
`git commit -m "docs: release excalidraw@excalidraw@${nextVersion} 🎉"`, |
||||||
|
); |
||||||
|
/* eslint-disable no-console */ |
||||||
|
console.log("Done!"); |
||||||
|
} catch (e) { |
||||||
|
console.error(e); |
||||||
|
process.exit(1); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
const nextVersion = process.argv.slice(2)[0]; |
||||||
|
if (!nextVersion) { |
||||||
|
console.error("Pass the next version to release!"); |
||||||
|
process.exit(1); |
||||||
|
} |
||||||
|
release(nextVersion); |
||||||
@ -1,23 +1,27 @@ |
|||||||
const fs = require("fs"); |
const fs = require("fs"); |
||||||
|
|
||||||
const excalidrawDir = `${__dirname}/../src/packages/excalidraw`; |
const updateReadme = () => { |
||||||
let data = fs.readFileSync(`${excalidrawDir}/README_NEXT.md`, "utf8"); |
const excalidrawDir = `${__dirname}/../src/packages/excalidraw`; |
||||||
|
let data = fs.readFileSync(`${excalidrawDir}/README_NEXT.md`, "utf8"); |
||||||
|
|
||||||
// remove note for unstable release
|
// remove note for unstable release
|
||||||
data = data.replace( |
data = data.replace( |
||||||
/<!-- unstable-readme-start-->[\s\S]*?<!-- unstable-readme-end-->/, |
/<!-- unstable-readme-start-->[\s\S]*?<!-- unstable-readme-end-->/, |
||||||
"", |
"", |
||||||
); |
); |
||||||
|
|
||||||
// replace "excalidraw-next" with "excalidraw"
|
// replace "excalidraw-next" with "excalidraw"
|
||||||
data = data.replace(/excalidraw-next/g, "excalidraw"); |
data = data.replace(/excalidraw-next/g, "excalidraw"); |
||||||
data = data.trim(); |
data = data.trim(); |
||||||
|
|
||||||
const demoIndex = data.indexOf("### Demo"); |
const demoIndex = data.indexOf("### Demo"); |
||||||
const excalidrawNextNote = |
const excalidrawNextNote = |
||||||
"#### Note\n\n**If you don't want to wait for the next stable release and try out the unreleased changes you can use [@excalidraw/excalidraw-next](https://www.npmjs.com/package/@excalidraw/excalidraw-next).**\n\n"; |
"#### Note\n\n**If you don't want to wait for the next stable release and try out the unreleased changes you can use [@excalidraw/excalidraw-next](https://www.npmjs.com/package/@excalidraw/excalidraw-next).**\n\n"; |
||||||
// Add excalidraw next note to try out for unreleased changes
|
// Add excalidraw next note to try out for unreleased changes
|
||||||
data = data.slice(0, demoIndex) + excalidrawNextNote + data.slice(demoIndex); |
data = data.slice(0, demoIndex) + excalidrawNextNote + data.slice(demoIndex); |
||||||
|
|
||||||
// update readme
|
// update readme
|
||||||
fs.writeFileSync(`${excalidrawDir}/README.md`, data, "utf8"); |
fs.writeFileSync(`${excalidrawDir}/README.md`, data, "utf8"); |
||||||
|
}; |
||||||
|
|
||||||
|
module.exports = updateReadme; |
||||||
|
|||||||
Loading…
Reference in new issue