worked out bower release process
This commit is contained in:
37
scripts/_spawn.js
Normal file
37
scripts/_spawn.js
Normal file
@ -0,0 +1,37 @@
|
||||
module.exports = spawn;
|
||||
|
||||
var estream = require('event-stream');
|
||||
var chalk = require('chalk');
|
||||
var cp = require('child_process');
|
||||
|
||||
function spawn(cmd, args, opts, cb) {
|
||||
opts = opts || {};
|
||||
|
||||
console.log(chalk.white.bold('$ ' + cmd + ' ' + args.join(' ')));
|
||||
|
||||
var proc = cp.spawn(cmd, args, {
|
||||
stdio: 'pipe',
|
||||
cwd: opts.cwd
|
||||
});
|
||||
var out = estream.split();
|
||||
|
||||
if (opts.verbose) {
|
||||
proc.stdout.pipe(out);
|
||||
} else {
|
||||
proc.stdout.resume();
|
||||
}
|
||||
|
||||
proc.stderr.pipe(out);
|
||||
|
||||
out
|
||||
.pipe(estream.mapSync(function indent(line) {
|
||||
return ' ' + line + '\n';
|
||||
}))
|
||||
.pipe(process.stdout);
|
||||
|
||||
if (typeof cb === 'function') {
|
||||
proc.on('exit', cb);
|
||||
}
|
||||
|
||||
return proc;
|
||||
}
|
||||
@ -1,8 +1,6 @@
|
||||
var cp = require('child_process');
|
||||
var async = require('async');
|
||||
var estream = require('event-stream');
|
||||
var chalk = require('chalk');
|
||||
var _ = require('lodash');
|
||||
var spawn = require('../_spawn');
|
||||
var argv = require('optimist')
|
||||
.options({
|
||||
force: {
|
||||
@ -41,54 +39,32 @@ if (!argv.force && process.env.FORCE || process.env.FORCE_GEN) {
|
||||
argv.force = argv.f = process.env.FORCE || process.env.FORCE_GEN;
|
||||
}
|
||||
|
||||
function spawn(cmd, args) {
|
||||
console.log(chalk.white.bold('$ ' + cmd + ' ' + args.join(' ')));
|
||||
|
||||
var proc = cp.spawn(cmd, args, { stdio: 'pipe'});
|
||||
var out = estream.split();
|
||||
|
||||
if (argv.verbose) {
|
||||
proc.stdout.pipe(out);
|
||||
} else {
|
||||
proc.stdout.resume();
|
||||
}
|
||||
|
||||
proc.stderr.pipe(out);
|
||||
|
||||
out
|
||||
.pipe(estream.mapSync(function indent(line) {
|
||||
return ' ' + line + '\n';
|
||||
}))
|
||||
.pipe(process.stdout);
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
||||
function initSubmodule(done) {
|
||||
spawn('git', ['submodule', 'update', '--init'])
|
||||
.on('exit', function (status) {
|
||||
done(status ? new Error('Unable to init submodules.') : void 0);
|
||||
});
|
||||
spawn('git', ['submodule', 'update', '--init'], argv, function (status) {
|
||||
done(status ? new Error('Unable to init submodules.') : void 0);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
function fetch(done) {
|
||||
spawn('git', ['submodule', 'foreach', 'git fetch origin'])
|
||||
.on('exit', function (status) {
|
||||
done(status ? new Error('Unable fetch lastest changes.') : void 0);
|
||||
});
|
||||
spawn('git', ['submodule', 'foreach', 'git fetch origin'], argv, function (status) {
|
||||
done(status ? new Error('Unable fetch lastest changes.') : void 0);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
function generateBranch(branch, done) {
|
||||
async.series([
|
||||
function (done) {
|
||||
spawn('git', ['submodule', 'foreach', [
|
||||
'git reset --hard', 'git clean -fdx', 'git checkout origin/' + branch
|
||||
].join(' && ')])
|
||||
.on('exit', function (status) {
|
||||
done(status ? new Error('Unable to checkout ' + branch) : void 0);
|
||||
});
|
||||
var cmd = [
|
||||
'git reset --hard',
|
||||
'git clean -fdx',
|
||||
'git checkout origin/' + branch
|
||||
].join(' && ');
|
||||
|
||||
spawn('git', ['submodule', 'foreach', cmd], function (status) {
|
||||
done(status ? new Error('Unable to checkout ' + branch) : void 0);
|
||||
});
|
||||
},
|
||||
function (done) {
|
||||
var tasks = [];
|
||||
|
||||
40
scripts/release/bower.js
Normal file
40
scripts/release/bower.js
Normal file
@ -0,0 +1,40 @@
|
||||
var fs = require('fs');
|
||||
var spawn = require('../_spawn');
|
||||
var async = require('async');
|
||||
var _ = require('lodash');
|
||||
|
||||
var root = require('path').join(__dirname, '../..');
|
||||
var bowerDir = root + '/src/bower-elasticsearch-js';
|
||||
|
||||
// get both the bower and node package files
|
||||
var bowerJson = require(bowerDir + '/bower.json');
|
||||
var esjsJson = require(root + '/package.json');
|
||||
|
||||
// update the version to match the node version
|
||||
bowerJson.version = esjsJson.version;
|
||||
|
||||
// write the new bower.json file
|
||||
fs.writeFileSync(bowerDir + '/bower.json', JSON.stringify(bowerJson, null, ' '));
|
||||
|
||||
function make(cmd, args) {
|
||||
return _.bind(spawn, null, cmd, args, {
|
||||
verbose: true,
|
||||
cwd: bowerDir
|
||||
});
|
||||
}
|
||||
|
||||
async.series([
|
||||
make('git', ['add', '-A']),
|
||||
make('git', ['commit', '-m', 'version ' + bowerJson.version]),
|
||||
make('git', ['tag', '-a', 'v' + bowerJson.version, '-m', 'version ' + bowerJson.version]),
|
||||
make('git', ['push', 'origin', 'master']),
|
||||
make('git', ['push', '--tags', 'origin'])
|
||||
], function (err) {
|
||||
if (err) {
|
||||
if (_.isNumber(err)) {
|
||||
console.log('Non-zero exit code: %d', err);
|
||||
} else {
|
||||
console.log('Error: ', err.message ? err.message : err);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user