Skip to content

Commit

Permalink
Added publish task.
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Dec 28, 2011
1 parent e2121df commit 9f3e51c
Showing 1 changed file with 74 additions and 22 deletions.
96 changes: 74 additions & 22 deletions Jakefile
@@ -1,15 +1,42 @@
var fs = require('fs') var fs = require('fs')
, pkg = JSON.parse(fs.readFileSync(__dirname + '/package.json').toString())
, version = pkg.version
, child_process = require('child_process') , child_process = require('child_process')
, path = require('path') , path = require('path')
, exec = child_process.exec , exec = child_process.exec
, inflection = require('./deps/inflection') , inflection = require('./deps/inflection')
, utils = require('./lib/utils') , utils = require('./lib/utils')
, ejs = require('./lib/template/adapters/ejs/ejs'); , ejs = require('./lib/template/adapters/ejs/ejs')
, createPackageTask
, getCurrentVersionNumber;


var JSPAT = /\.js$/; var JSPAT = /\.js$/;


getCurrentVersionNumber = function () {
pkg = JSON.parse(fs.readFileSync(__dirname + '/package.json').toString())
version = pkg.version
return version;
};

createPackageTask = function () {
var version = getCurrentVersionNumber()
, t;

t = new jake.PackageTask('geddy', 'v' + version, function () {
var fileList = [
'Makefile'
, 'Jakefile'
, 'README.md'
, 'package.json'
, 'bin/*'
, 'deps/*'
, 'lib/*'
, 'templates/*'
, 'test/*'
];
this.packageFiles.include(fileList);
this.needTarGz = true;
});
};

namespace('gen', function () { namespace('gen', function () {


var _writeTemplate = function (name, filename, dirname, opts) { var _writeTemplate = function (name, filename, dirname, opts) {
Expand Down Expand Up @@ -247,27 +274,52 @@ task('test', function () {
jake.exec(cmds, function () { jake.exec(cmds, function () {
console.log('Tests passed.'); console.log('Tests passed.');
complete(); complete();
}); }, {stdout: true});
}, {async: true}); }, {async: true});


// Don't generate the package-tasks when being called as a generator namespace('npm', function () {
// from an installed geddy -- don't run outside the geddy project dir task('version', function () {
if (!process.env.generator) { cmds = [
var t = new jake.PackageTask('geddy', 'v' + version, function () { 'npm version patch --message "Bumped version number."'
var fileList = [ , 'git push origin master'
'Makefile' , 'git push --tags'
, 'Jakefile'
, 'README.md'
, 'package.json'
, 'bin/*'
, 'deps/*'
, 'lib/*'
, 'templates/*'
, 'test/*'
]; ];
this.packageFiles.include(fileList); jake.exec(cmds, function () {
this.needTarGz = true; console.log('Bumped version number.');
this.needTarBz2 = true; complete();
}); });
}, {async: true});

task('package', function () {
// Recreate the PackageTask with the updated version-number,
// run 'package'
createPackageTask();
// FIXME: Shouldn't have to shell out to get a real prereqs-tree
jake.exec(['jake package'], function () {
console.log('Created package.');
complete();
});

}, {async: true});

task('publish', function () {
var version = getCurrentVersionNumber();
cmds = [
'sudo npm publish pkg/geddy-v' + version + '.tar.gz'
];
jake.exec(cmds, function () {
console.log('Published to NPM.');
complete();
}, {stdout: true});
}, {async: true});
});

desc('Bump version-number, package, and publish to NPM.');
task('publish', ['npm:version', 'npm:package', 'npm:publish'], function () {
});

// Don't create the package-tasks when being called as a generator
if (!process.env.generator) {
createPackageTask();
} }


0 comments on commit 9f3e51c

Please sign in to comment.