From 853321afe053d74536556fc64084ad8ecb120031 Mon Sep 17 00:00:00 2001 From: Erik Koopmans Date: Mon, 1 Jul 2024 01:04:22 -0400 Subject: [PATCH] chore: Remove build-scripts --- build-scripts.js | 69 ----------------------------------------------- package-lock.json | 1 - package.json | 5 +--- 3 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 build-scripts.js diff --git a/build-scripts.js b/build-scripts.js deleted file mode 100644 index 41285d47..00000000 --- a/build-scripts.js +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env node - -const { program } = require('commander'); -const { promisify } = require('util'); -const exec = promisify(require('child_process').exec); -const { readFileSync } = require('fs'); - -program - .command('release [newversion] [tagmessage]') - .description('Bump version, build, commit, tag, and promote to local stable branch') - .action(release) -program - .command('publish-gh') - .description('Push master and stable branches to GitHub with tags') - .action(publishGH) -program.parse(process.argv); - -/* ----- HELPER ----- */ - -function getVersion() { - // Uses readFileSync() instead of require() to prevent caching of values. - const pkg = JSON.parse(readFileSync('./package.json')); - return `v${pkg.version}`; -} - -/* ----- SUBTASKS ----- */ - -// Bump version using NPM (only affects package*.json, doesn't commit). -function bumpVersion(newversion) { - console.log('Bumping version number.'); - return exec(`npm --no-git-tag-version version ${newversion}`); -} - -// Build, commit, and tag in master with the new release version. -async function buildCommitTag(tagmessage) { - console.log('Running build process in master branch.'); - await exec(`git checkout master && npm run build`); - - const version = getVersion(); - const fullTagMessage = tagmessage ? `${version} ${tagmessage}` : version; - - console.log('Adding all changes and performing final commit.'); - await exec(`git add -A && git commit --allow-empty -m "Build ${version}"`); - - console.log('Tagging with provided tag message.'); - return exec(`git tag -a ${version} -m "${fullTagMessage}"`); -} - -// Pushes master into the local stable branch. -async function promoteToStable() { - console.log('Getting repo root location.'); - const res = await exec('git rev-parse --show-toplevel'); - const repoRoot = res.stdout.trim('\n'); - - console.log('Pushing release to local stable branch.'); - return exec(`git push --follow-tags ${repoRoot} master:stable`) -} - -/* ----- TASKS ----- */ - -async function release(newversion, tagmessage) { - await bumpVersion(newversion || 'patch'); - await buildCommitTag(tagmessage); - await promoteToStable(); -} - -function publishGH() { - return exec('git push --follow-tags origin master stable'); -} diff --git a/package-lock.json b/package-lock.json index cbc87ba8..c0492b57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,6 @@ "babel-loader": "^8.2.2", "chai": "^4.2.0", "chai-spies": "^1.0.0", - "commander": "^7.2.0", "core-js": "^3.16.0", "karma": "^6.3.4", "karma-chai": "^0.1.0", diff --git a/package.json b/package.json index afd95ee7..42d62fe1 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ "babel-loader": "^8.2.2", "chai": "^4.2.0", "chai-spies": "^1.0.0", - "commander": "^7.2.0", "core-js": "^3.16.0", "karma": "^6.3.4", "karma-chai": "^0.1.0", @@ -65,8 +64,6 @@ "dev:analyze": "webpack --env=dev --env=analyzer", "test": "start-server-and-test test:serve http://localhost:3000 test:run", "test:serve": "pdftest serve 3000 ./test/reference/snapshot", - "test:run": "npx karma start karma.conf.js", - "release": "node ./build-scripts.js release", - "publish-gh": "node ./build-scripts.js publish-gh" + "test:run": "npx karma start karma.conf.js" } }