release.js 1.1 KB

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