Skip to content

Commit

Permalink
chore: better release prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Mar 4, 2018
1 parent addbad7 commit 0d8729d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 9 deletions.
26 changes: 17 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "nerv-build",
"private": true,
"version": "1.0.0",
"workspaces": ["packages/*"],
"workspaces": [
"packages/*"
],
"description": "A react-like framework based on virtual-dom",
"scripts": {
"precommit": "npm run lint && npm run lint-staged",
Expand All @@ -19,21 +21,26 @@
"test:coverage": "jest --coverage",
"test:karma": "karma start karma.conf.js --single-run",
"test:karma:watch": "npm run test:karma -- no-single-run",
"build":
"npm run clean && lerna exec -- rollup -c && npm run build:typing && node afterbuild.js && npm run size",
"build": "npm run clean && lerna exec -- rollup -c && npm run build:typing && node afterbuild.js && npm run size",
"build:typing": "rimraf lib && tsc && lerna exec -- node ../../typing.js",
"size": "gzip-size ./packages/nerv/dist/nerv.min.js",
"build:esm": "lerna exec -- rollup -c --environment TARGET:esm",
"build:umd": "lerna exec -- rollup -c --environment TARGET:umd",
"release": "npm run build && lerna publish --exact --conventional-commits",
"release:beta":
"npm run build && lerna publish --cd-version=prepatch --preid=beta --npm-tag=beta --conventional-commits"
"release": "node ./release.js"
},
"lint-staged": {
"*.{js,jsx}": ["eslint --fix", "git add"],
"*.{ts,tsx}": ["tslint --fix", "git add"]
"*.{js,jsx}": [
"eslint --fix",
"git add"
],
"*.{ts,tsx}": [
"tslint --fix",
"git add"
]
},
"keywords": ["react-like"],
"keywords": [
"react-like"
],
"repository": {
"type": "git",
"url": "git+https://github.com/NervJS/nerv.git"
Expand Down Expand Up @@ -90,6 +97,7 @@
"lint-staged": "^4.0.4",
"npm-run-all": "^4.0.2",
"optimize-js": "^1.0.3",
"prompts": "^0.1.4",
"rimraf": "^2.6.1",
"rollup": "^0.50.0",
"rollup-plugin-alias": "^1.4.0",
Expand Down
39 changes: 39 additions & 0 deletions release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const prompts = require('prompts')
const cp = require('child_process')

async function f () {
const response = await prompts({
type: 'select',
name: 'version',
message: `What's the release version?`,
choices: [
{ title: 'auto (by semver version)', value: 'auto' },
{ title: 'beta', value: 'beta' },
{ title: 'manual', value: 'manual' }
],
initial: 1
})

const { version } = response
const command = 'npm run build && lerna publish --exact --conventional-commits'
switch (version) {
case 'auto':
cp.execSync(command)
break
case 'beta':
cp.execSync(command + '--cd-version=prepatch --preid=beta --npm-tag=beta')
break
case 'manual':
const manual = await prompts({
type: 'text',
name: 'version',
message: `What's the EXACT version that you want to publish?`
})
cp.execFileSync(`${command} --repo-version ${manual.version}`)
break
default:
break
}
}

f()
15 changes: 15 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,10 @@ clone@^1.0.0, clone@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz#260b7a99ebb1edfe247538175f783243cb19d149"

clorox@^1.0.1:
version "1.0.2"
resolved "https://registry.npmjs.org/clorox/-/clorox-1.0.2.tgz#f89dbaba26046f7327dfabc2dd97e76af91d742d"

cmd-shim@^2.0.2:
version "2.0.2"
resolved "https://registry.npmjs.org/cmd-shim/-/cmd-shim-2.0.2.tgz#6fcbda99483a8fd15d7d30a196ca69d688a2efdb"
Expand Down Expand Up @@ -5429,6 +5433,13 @@ progress@^1.1.8:
version "1.1.8"
resolved "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be"

prompts@^0.1.4:
version "0.1.4"
resolved "https://registry.npmjs.org/prompts/-/prompts-0.1.4.tgz#d5376a0441edb8c26a65a208ef964ec287ee2b6e"
dependencies:
clorox "^1.0.1"
sisteransi "^0.1.0"

prr@~0.0.0:
version "0.0.0"
resolved "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz#1a84b85908325501411853d0081ee3fa86e2926a"
Expand Down Expand Up @@ -6092,6 +6103,10 @@ sinon@^2.3.8:
text-encoding "0.6.4"
type-detect "^4.0.0"

sisteransi@^0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/sisteransi/-/sisteransi-0.1.0.tgz#2e6706ac427019b84e60f751d588d87920484f25"

slash@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
Expand Down

0 comments on commit 0d8729d

Please sign in to comment.