This repository has been archived by the owner on Feb 5, 2019. It is now read-only.
forked from vuetifyjs/vuetify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: convert release script to js, add PR template
(cherry picked from commit e8ca8bc)
- Loading branch information
Showing
6 changed files
with
223 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- | ||
Remember to read the contributing guide first: | ||
https://github.com/vuetifyjs/vuetify/blob/master/.github/CONTRIBUTING.md | ||
--> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
const inquirer = require('inquirer') | ||
const semver = require('semver') | ||
const shell = require('shelljs') | ||
|
||
shell.set('-e') | ||
|
||
if (!shell.which('git')) { | ||
shell.echo('Sorry, this script requires git') | ||
shell.exit(1) | ||
} | ||
|
||
if (!shell.which('npm')) { | ||
shell.echo('Sorry, this script requires npm') | ||
shell.exit(1) | ||
} | ||
|
||
let tag | ||
let branch = exec('git symbolic-ref --short HEAD') | ||
const latest = exec('npm view vuetify version') | ||
let latestGit = exec('git describe --abbrev=0 --tags') | ||
|
||
shell.echo(` | ||
Current branch is ${branch} | ||
Last git version (from the current location) was ${latestGit} | ||
Latest npm version is ${latest} | ||
`) | ||
|
||
promptForVersion() | ||
.then(verifyBranch) | ||
.then(confirmVersion) | ||
.then(version => { | ||
lint() | ||
release(version) | ||
afterRelease() | ||
}) | ||
|
||
//============================ FUNCTIONS =============================// | ||
|
||
function exec (command) { | ||
const result = shell.exec(command, { silent: true }) | ||
if (result.code) { | ||
shell.echo('') | ||
console.error(result.stdout.trim()) | ||
shell.exit(1) | ||
} | ||
return result.stdout.trim() | ||
} | ||
|
||
function createVersionOption (name) { | ||
const prerelease = (semver.prerelease(latestGit) || [])[0] | ||
const version = semver.inc(latestGit, name.toLowerCase(), false, prerelease || 'beta') | ||
return { | ||
name: `${name} (${version})`, | ||
value: version, | ||
short: version | ||
} | ||
} | ||
|
||
function promptForVersion () { | ||
return inquirer.prompt({ | ||
type: 'list', | ||
name: 'version', | ||
message: 'Select new version:', | ||
choices: [ | ||
createVersionOption('Major'), | ||
createVersionOption('Minor'), | ||
createVersionOption('Patch'), | ||
createVersionOption('Prerelease'), | ||
createVersionOption('Premajor'), | ||
createVersionOption('Preminor'), | ||
createVersionOption('Prepatch'), | ||
{ | ||
name: 'Other', | ||
value: 'other' | ||
} | ||
], | ||
default: () => ( | ||
semver.prerelease(latestGit) == null | ||
? createVersionOption('Patch').value | ||
: createVersionOption('Prerelease').value | ||
), | ||
pageSize: 8 | ||
}).then(({ version }) => { | ||
if (version === 'other') { | ||
return inquirer.prompt({ | ||
type: 'input', | ||
name: 'version', | ||
message: 'Enter new version:', | ||
validate: val => !!semver.valid(val) || `'${val}' is not a valid version number`, | ||
filter: val => semver(val).version | ||
}).then(({ version }) => version) | ||
} | ||
return version | ||
}) | ||
} | ||
|
||
function verifyBranch (version) { | ||
tag = semver.prerelease(version) == null ? 'latest' : 'next' | ||
|
||
if (tag === 'latest' && branch !== 'master') { | ||
shell.echo('\nReleasing on a branch other than \'master\'') | ||
shell.echo('This may have unintended side-effects') | ||
return inquirer.prompt({ | ||
type: 'confirm', | ||
name: 'yes', | ||
message: 'Do you want to continue?', | ||
default: false | ||
}).then(({ yes }) => yes ? version : shell.exit(1)) | ||
} | ||
return Promise.resolve(version) | ||
} | ||
|
||
function confirmVersion (version) { | ||
shell.echo(`Releasing ${version} on ${branch}`) | ||
shell.echo(`Tag: ${tag}`) | ||
return inquirer.prompt({ | ||
type: 'confirm', | ||
name: 'yes', | ||
message: 'Are you sure?', | ||
default: true | ||
}).then(({ yes }) => yes ? version : shell.exit(1)) | ||
} | ||
|
||
function lint () { | ||
shell.exec('npm run lint') | ||
shell.exec('npm run test') | ||
} | ||
|
||
function release (version) { | ||
process.env.npm_config_commit_hooks = 'false' | ||
|
||
shell.exec(`npm version ${version} --message "[release] ${version}"`) | ||
if (exec(`git config branch.${branch}.remote`)) { | ||
shell.exec(`git push --no-verify --follow-tags`) | ||
} else { | ||
const remote = exec(`git config branch.master.remote`) | ||
shell.exec(`git push --no-verify --follow-tags -u ${remote}`) | ||
} | ||
} | ||
|
||
function afterRelease () { | ||
if (branch.match(/release\/.*/)) { | ||
const previousBranch = branch | ||
shell.exec('git checkout master') | ||
branch = 'master' | ||
shell.exec('git pull --ff-only') | ||
shell.exec(`git merge ${previousBranch}`) | ||
shell.echo(`\n\nYou can now push if there are no conflicts`) | ||
} | ||
} | ||
|
||
function getBranches () { | ||
return exec(`git for-each-ref refs/heads refs/remotes --format='%(refname)'`) | ||
.split('\n') | ||
.map(ref => ( | ||
/refs\/.*?\/(.*)/.exec(ref)[1] | ||
)) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1308,6 +1308,10 @@ character-parser@^2.1.1: | |
dependencies: | ||
is-regex "^1.0.3" | ||
|
||
chardet@^0.4.0: | ||
version "0.4.2" | ||
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" | ||
|
||
chokidar@^1.6.0, chokidar@^1.6.1, chokidar@^1.7.0: | ||
version "1.7.0" | ||
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" | ||
|
@@ -2433,6 +2437,14 @@ external-editor@^2.0.4: | |
jschardet "^1.4.2" | ||
tmp "^0.0.31" | ||
|
||
external-editor@^2.1.0: | ||
version "2.1.0" | ||
resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.1.0.tgz#3d026a21b7f95b5726387d4200ac160d372c3b48" | ||
dependencies: | ||
chardet "^0.4.0" | ||
iconv-lite "^0.4.17" | ||
tmp "^0.0.33" | ||
|
||
extglob@^0.3.1: | ||
version "0.3.2" | ||
resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" | ||
|
@@ -2718,7 +2730,7 @@ [email protected]: | |
once "^1.3.0" | ||
path-is-absolute "^1.0.0" | ||
|
||
glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2: | ||
glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2: | ||
version "7.1.2" | ||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" | ||
dependencies: | ||
|
@@ -3041,6 +3053,25 @@ inquirer@^3.0.6: | |
strip-ansi "^4.0.0" | ||
through "^2.3.6" | ||
|
||
inquirer@^4.0.1: | ||
version "4.0.1" | ||
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-4.0.1.tgz#b25cd541789394b4bb56f6440fb213b121149096" | ||
dependencies: | ||
ansi-escapes "^3.0.0" | ||
chalk "^2.0.0" | ||
cli-cursor "^2.1.0" | ||
cli-width "^2.0.0" | ||
external-editor "^2.1.0" | ||
figures "^2.0.0" | ||
lodash "^4.3.0" | ||
mute-stream "0.0.7" | ||
run-async "^2.2.0" | ||
rx-lite "^4.0.8" | ||
rx-lite-aggregates "^4.0.8" | ||
string-width "^2.1.0" | ||
strip-ansi "^4.0.0" | ||
through "^2.3.6" | ||
|
||
internal-ip@^2.0.2: | ||
version "2.0.2" | ||
resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-2.0.2.tgz#bed2b35491e8b42aee087de7614e870908ee80f2" | ||
|
@@ -4302,7 +4333,7 @@ os-locale@^2.0.0: | |
lcid "^1.0.0" | ||
mem "^1.1.0" | ||
|
||
os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1: | ||
os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" | ||
|
||
|
@@ -5098,6 +5129,12 @@ readdirp@^2.0.0: | |
readable-stream "^2.0.2" | ||
set-immediate-shim "^1.0.1" | ||
|
||
rechoir@^0.6.2: | ||
version "0.6.2" | ||
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" | ||
dependencies: | ||
resolve "^1.1.6" | ||
|
||
reduce-css-calc@^1.2.6: | ||
version "1.3.0" | ||
resolved "https://registry.yarnpkg.com/reduce-css-calc/-/reduce-css-calc-1.3.0.tgz#747c914e049614a4c9cfbba629871ad1d2927716" | ||
|
@@ -5432,6 +5469,14 @@ shebang-regex@^1.0.0: | |
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" | ||
|
||
shelljs@^0.7.8: | ||
version "0.7.8" | ||
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" | ||
dependencies: | ||
glob "^7.0.0" | ||
interpret "^1.0.0" | ||
rechoir "^0.6.2" | ||
|
||
shellwords@^0.1.0: | ||
version "0.1.0" | ||
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.0.tgz#66afd47b6a12932d9071cbfd98a52e785cd0ba14" | ||
|
@@ -5834,6 +5879,12 @@ tmp@^0.0.31: | |
dependencies: | ||
os-tmpdir "~1.0.1" | ||
|
||
tmp@^0.0.33: | ||
version "0.0.33" | ||
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" | ||
dependencies: | ||
os-tmpdir "~1.0.2" | ||
|
||
[email protected]: | ||
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1" | ||
|