prerelease.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. const fs = require("fs");
  2. const util = require("util");
  3. const exec = util.promisify(require("child_process").exec);
  4. const updateChangelog = require("./updateChangelog");
  5. const excalidrawDir = `${__dirname}/../src/packages/excalidraw`;
  6. const excalidrawPackage = `${excalidrawDir}/package.json`;
  7. const updatePackageVersion = (nextVersion) => {
  8. const pkg = require(excalidrawPackage);
  9. pkg.version = nextVersion;
  10. const content = `${JSON.stringify(pkg, null, 2)}\n`;
  11. fs.writeFileSync(excalidrawPackage, content, "utf-8");
  12. };
  13. const prerelease = async (nextVersion) => {
  14. try {
  15. await updateChangelog(nextVersion);
  16. updatePackageVersion(nextVersion);
  17. await exec(`git add -u`);
  18. await exec(
  19. `git commit -m "docs: release @excalidraw/excalidraw@${nextVersion} 🎉"`,
  20. );
  21. console.info("Done!");
  22. } catch (error) {
  23. console.error(error);
  24. process.exit(1);
  25. }
  26. };
  27. const nextVersion = process.argv.slice(2)[0];
  28. if (!nextVersion) {
  29. console.error("Pass the next version to release!");
  30. process.exit(1);
  31. }
  32. prerelease(nextVersion);