mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-05 05:27:59 +08:00
grunt release tasks
This commit is contained in:
parent
bfb1495c46
commit
7ee859ef3f
@ -1,3 +1,79 @@
|
||||
module.exports = function () {
|
||||
|
||||
/**
|
||||
* Register release-related tasks.
|
||||
*/
|
||||
|
||||
module.exports = function (grunt) {
|
||||
|
||||
/**
|
||||
* Update manifest file versions.
|
||||
*/
|
||||
|
||||
grunt.registerTask('version', function (version) {
|
||||
var manifests = ['package', 'bower', 'component']
|
||||
manifests.forEach(function (file) {
|
||||
file = file + '.json'
|
||||
var json = grunt.file.read(file)
|
||||
json = json.replace(
|
||||
/"version"\s*:\s*"(.+?)"/,
|
||||
'"version": "' + version + '"'
|
||||
)
|
||||
grunt.file.write(file, json)
|
||||
console.log('updated ' + blue(file))
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* Commit & push to branches & tags + npm publish
|
||||
*/
|
||||
|
||||
grunt.registerTask('git', function (version) {
|
||||
var ShellTask = require('shell-task')
|
||||
new ShellTask('git add -A')
|
||||
.then('git commit -m "[release] ' + version + '"')
|
||||
.then('git tag ' + version)
|
||||
.then('git push')
|
||||
.then('git push origin refs/tags/' + version)
|
||||
.then('npm publish')
|
||||
.run(this.async())
|
||||
})
|
||||
|
||||
/**
|
||||
* Main release routine.
|
||||
*/
|
||||
|
||||
grunt.registerTask('release', function (version) {
|
||||
|
||||
var semver = require('semver')
|
||||
var readline = require('readline')
|
||||
var done = this.async()
|
||||
var current = grunt.config.get('version')
|
||||
var next = semver.inc(current, version || 'patch') || version
|
||||
|
||||
if (!semver.valid(next)) {
|
||||
return grunt.fail.warn('Invalid version.')
|
||||
}
|
||||
if (semver.lt(next, current)) {
|
||||
return grunt.fail.warn('Version is older than current.')
|
||||
}
|
||||
|
||||
readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
}).question('Releasing version ' + next + '. Continue? (Y/n)', function (answer) {
|
||||
if (!answer || answer.toLowerCase() === 'y') {
|
||||
console.log(blue('Releasing: ' + next))
|
||||
grunt.config.set('version', next)
|
||||
grunt.task.run([
|
||||
'default',
|
||||
'version:' + next
|
||||
// 'git:' + next
|
||||
])
|
||||
}
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
function blue (str) {
|
||||
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m'
|
||||
}
|
||||
}
|
@ -34,6 +34,8 @@
|
||||
"karma-jasmine": "^0.2.2",
|
||||
"karma-phantomjs-launcher": "^0.1.4",
|
||||
"karma-sauce-launcher": "^0.2.10",
|
||||
"semver": "^4.0.3",
|
||||
"shell-task": "^1.0.0",
|
||||
"uglify-js": "^2.4.15",
|
||||
"webpack": "^1.4.4"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user