2021-07-05 22:29:35 +05:30
|
|
|
const fs = require("fs");
|
|
|
|
const util = require("util");
|
|
|
|
const exec = util.promisify(require("child_process").exec);
|
|
|
|
const updateChangelog = require("./updateChangelog");
|
|
|
|
|
|
|
|
const excalidrawDir = `${__dirname}/../src/packages/excalidraw`;
|
|
|
|
const excalidrawPackage = `${excalidrawDir}/package.json`;
|
2022-07-04 22:19:08 +05:30
|
|
|
const originalReadMe = fs.readFileSync(`${excalidrawDir}/README.md`, "utf8");
|
|
|
|
|
|
|
|
const updateReadme = () => {
|
|
|
|
const excalidrawIndex = originalReadMe.indexOf("### Excalidraw");
|
|
|
|
|
|
|
|
// remove note for stable readme
|
|
|
|
const data = originalReadMe.slice(excalidrawIndex);
|
|
|
|
|
|
|
|
// update readme
|
|
|
|
fs.writeFileSync(`${excalidrawDir}/README.md`, data, "utf8");
|
|
|
|
};
|
2021-07-05 22:29:35 +05:30
|
|
|
|
|
|
|
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);
|
2021-07-06 00:13:56 +05:30
|
|
|
updatePackageVersion(nextVersion);
|
2021-07-05 22:29:35 +05:30
|
|
|
await exec(`git add -u`);
|
|
|
|
await exec(
|
2021-10-13 17:03:50 +05:30
|
|
|
`git commit -m "docs: release @excalidraw/excalidraw@${nextVersion} 🎉"`,
|
2021-07-05 22:29:35 +05:30
|
|
|
);
|
2022-07-04 22:19:08 +05:30
|
|
|
// revert readme after release
|
|
|
|
fs.writeFileSync(`${excalidrawDir}/README.md`, originalReadMe, "utf8");
|
|
|
|
|
|
|
|
console.info("Done!");
|
2021-11-02 14:24:16 +02:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
2021-07-05 22:29:35 +05:30
|
|
|
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);
|