From b46bab7b0f5ced13804b02e4c87aca87612d127f Mon Sep 17 00:00:00 2001 From: co2-git Date: Sun, 29 Apr 2018 16:38:59 +0200 Subject: [PATCH] #72 Add bump script --- package.json | 1 + scripts/bump.js | 15 +++++++++++++++ scripts/bump.sh | 14 ++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 scripts/bump.js create mode 100644 scripts/bump.sh diff --git a/package.json b/package.json index 055439a..b015d54 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "scripts": { "babel": "babel --out-dir dist/ app/", "branch": "bash scripts/branch.sh v$npm_package_version", + "bump": "bash scripts/bump.sh", "eslint": "eslint app --fix", "fix": "yarn test && yarn pr", "flow": "flow", diff --git a/scripts/bump.js b/scripts/bump.js new file mode 100644 index 0000000..d1b59b5 --- /dev/null +++ b/scripts/bump.js @@ -0,0 +1,15 @@ +const [,, action = 'bump', pkg, version] = process.argv; + +const info = JSON.parse(pkg); + +if (action === 'bump') { + const [api, major, minor] = info.version.split(/\./); + const newVersion = `${api}.${major}.${Number(minor) + 1}`; + console.log(newVersion); +} else if (action === 'rewrite') { + info.version = version; + const rw = JSON.stringify(info, null, 2); + console.log(rw) +} else { + throw new Error('Unknown action'); +} diff --git a/scripts/bump.sh b/scripts/bump.sh new file mode 100644 index 0000000..d2177ae --- /dev/null +++ b/scripts/bump.sh @@ -0,0 +1,14 @@ +#! /bin/bash + +JSON="$(cat ./package.json)" +VERSION="$1" + +if [ -z "$VERSION" ]; then + VERSION="$(node ./scripts/bump bump "$JSON")" + echo $VERSION +fi + +# git co master && +# git pull && +# git co -b v$VERSION && +node scripts/bump rewrite "$JSON" $VERSION > ./package.json