mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00
chore(publish): prepare task
This commit is contained in:
55
gulpfile.js
55
gulpfile.js
@ -467,11 +467,53 @@ gulp.task('package', ['src.release'], function(done){
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('publish', ['package'], function(done){
|
|
||||||
var spawn = require('child_process').spawn;
|
gulp.task('!prepare', function(){
|
||||||
|
var execSync = require('child_process').execSync;
|
||||||
|
var spawnSync = require('child_process').spawnSync;
|
||||||
var semver = require('semver');
|
var semver = require('semver');
|
||||||
|
var changelog = require('gulp-conventional-changelog');
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
//Check for uncommitted changes
|
||||||
|
var gitStatusResult = execSync('git status --porcelain');
|
||||||
|
if (gitStatusResult.toString().length > 0) {
|
||||||
|
return fail('You have uncommitted changes, please stash or commit them before running prepare');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Pull latest
|
||||||
|
var gitPullResult = spawnSync('git', ['pull', 'origin', '2.0']);
|
||||||
|
if (gitPullResult.status !== 0) {
|
||||||
|
fail('There was an error running \'git pull\':\n' + gitPullResult.stderr.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update package.json version
|
||||||
|
var packageJSON = require('./package.json');
|
||||||
|
packageJSON.version = semver.inc(packageJSON.version, 'prerelease', 'alpha');
|
||||||
|
fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2));
|
||||||
|
|
||||||
|
//Update changelog
|
||||||
|
return gulp.src('./CHANGELOG.md')
|
||||||
|
.pipe(changelog({
|
||||||
|
preset: 'angular'
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest('./'));
|
||||||
|
|
||||||
|
|
||||||
|
function fail(msg) {
|
||||||
|
// remove gulp's 'Finished 'task' after 10ms' message
|
||||||
|
self.removeAllListeners('task_stop');
|
||||||
|
console.error('Prepare aborted.');
|
||||||
|
console.error(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('prepare', ['package', '!prepare']);
|
||||||
|
|
||||||
|
gulp.task('publish', function(done){
|
||||||
|
var spawn = require('child_process').spawn;
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var err = false;
|
|
||||||
|
|
||||||
var npmCmd = spawn('npm', ['publish', './dist']);
|
var npmCmd = spawn('npm', ['publish', './dist']);
|
||||||
|
|
||||||
@ -480,17 +522,10 @@ gulp.task('publish', ['package'], function(done){
|
|||||||
});
|
});
|
||||||
|
|
||||||
npmCmd.stderr.on('data', function (data) {
|
npmCmd.stderr.on('data', function (data) {
|
||||||
err = true;
|
|
||||||
console.log('npm err: ' + data.toString());
|
console.log('npm err: ' + data.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
npmCmd.on('close', function() {
|
npmCmd.on('close', function() {
|
||||||
// update package.json
|
|
||||||
// if (!err) {
|
|
||||||
// var packageJSON = require('./package.json');
|
|
||||||
// packageJSON.version = semver.inc(packageJSON.version, 'prerelease', 'alpha');
|
|
||||||
// fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2));
|
|
||||||
// }
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
"gulp-cached": "^1.1.0",
|
"gulp-cached": "^1.1.0",
|
||||||
"gulp-concat": "~2.5.0",
|
"gulp-concat": "~2.5.0",
|
||||||
"gulp-connect": "^2.2.0",
|
"gulp-connect": "^2.2.0",
|
||||||
|
"gulp-conventional-changelog": "^0.7.0",
|
||||||
"gulp-if": "^1.2.5",
|
"gulp-if": "^1.2.5",
|
||||||
"gulp-insert": "^0.5.0",
|
"gulp-insert": "^0.5.0",
|
||||||
"gulp-minify-css": "^1.2.2",
|
"gulp-minify-css": "^1.2.2",
|
||||||
|
Reference in New Issue
Block a user