2021-07-05 18:59:35 +02:00
|
|
|
const fs = require("fs");
|
2022-07-06 11:50:52 +02:00
|
|
|
const { execSync } = require("child_process");
|
2021-07-05 18:59:35 +02:00
|
|
|
|
|
|
|
const excalidrawDir = `${__dirname}/../src/packages/excalidraw`;
|
|
|
|
const excalidrawPackage = `${excalidrawDir}/package.json`;
|
2022-07-06 11:50:52 +02:00
|
|
|
const pkg = require(excalidrawPackage);
|
|
|
|
|
2022-07-04 18:49:08 +02:00
|
|
|
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 18:59:35 +02:00
|
|
|
|
2022-07-06 11:50:52 +02:00
|
|
|
const publish = () => {
|
2021-07-05 18:59:35 +02:00
|
|
|
try {
|
2022-07-06 11:50:52 +02:00
|
|
|
execSync(`yarn --frozen-lockfile`);
|
|
|
|
execSync(`yarn --frozen-lockfile`, { cwd: excalidrawDir });
|
|
|
|
execSync(`yarn run build:umd`, { cwd: excalidrawDir });
|
|
|
|
execSync(`yarn --cwd ${excalidrawDir} publish`);
|
2021-11-02 13:24:16 +01:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
2021-07-05 18:59:35 +02:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-07-06 11:50:52 +02:00
|
|
|
const release = () => {
|
|
|
|
updateReadme();
|
|
|
|
console.info("Note for stable readme removed");
|
|
|
|
|
|
|
|
publish();
|
|
|
|
console.info(`Published ${pkg.version}!`);
|
|
|
|
|
|
|
|
// revert readme after release
|
|
|
|
fs.writeFileSync(`${excalidrawDir}/README.md`, originalReadMe, "utf8");
|
|
|
|
console.info("Readme reverted");
|
|
|
|
};
|
|
|
|
|
|
|
|
release();
|