chore(publish): read versions from root package.json

This commit is contained in:
Tim Lancina
2016-01-21 10:50:53 -06:00
parent 55f156366f
commit 9acd56ef51
3 changed files with 23 additions and 24 deletions

View File

@ -456,40 +456,39 @@ gulp.task('package', ['src.release'], function(done){
]) ])
.pipe(gulp.dest(distDir)); .pipe(gulp.dest(distDir));
var inquirer = require('inquirer'); var templateVars = {};
inquirer.prompt([ var packageJSON = require('./package.json');
{ templateVars.ionicVersion = packageJSON.version;
type: 'input', templateVars.angularVersion = packageJSON.dependencies.angular2;
name: 'ionicVersion', var packageTemplate = _.template(fs.readFileSync('scripts/npm/package.json'));
message: '\n\nWhat ionic-framework alpha version number will this be?' fs.writeFileSync(distDir + '/package.json', packageTemplate(templateVars));
}, done();
{
type: 'input',
name: 'angularVersion',
message: '\nWhat angular2 beta version number is a peer dependency?'
}
], function(answers) {
var packageTemplate = _.template(fs.readFileSync('scripts/npm/package.json'));
fs.writeFileSync(distDir + '/package.json', packageTemplate(answers));
done();
});
}); });
gulp.task('publish', ['package'], function(done){ gulp.task('publish', ['package'], function(done){
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var npmCmd = spawn('npm', ['publish', './dist']); var semver = require('semver');
var fs = require('fs');
var err = false;
var npmCmd = spawn('npm', ['pack', './dist']);
npmCmd.stdout.on('data', function (data) { npmCmd.stdout.on('data', function (data) {
console.log(data.toString()); console.log(data.toString());
}); });
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();
}); });

View File

@ -1,7 +1,7 @@
{ {
"private": "true", "private": "true",
"name": "ionic2", "name": "ionic2",
"version": "2.0.0-alpha.48", "version": "2.0.0-alpha.52",
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -1,6 +1,6 @@
{ {
"name": "ionic-framework", "name": "ionic-framework",
"version": "2.0.0-alpha.<%= ionicVersion %>", "version": "<%= ionicVersion %>",
"license": "Apache-2.0", "license": "Apache-2.0",
"keywords": ["ionic", "framework", "mobile", "app", "hybrid", "webapp"], "keywords": ["ionic", "framework", "mobile", "app", "hybrid", "webapp"],
"repository": { "repository": {
@ -16,6 +16,6 @@
"shelljs": "0.5.3" "shelljs": "0.5.3"
}, },
"peerDependencies": { "peerDependencies": {
"angular2": "^2.0.0-beta.<%= angularVersion %>" "angular2": "^<%= angularVersion %>"
} }
} }