Jakefile.js | |
---|---|
var releaseTools = require('./lib/main');
var Step = require('step'); | |
This Jakefile exposes the following tasks using the
| |
Customize example files to document via docco | releaseTools.setOptions({
examplePaths: [
'Jakefile.js'
]
}); |
Test taskThis task executes the package tests by calling the standard | desc("execute tests");
task("test",function() {
var spawn = require('child_process').spawn;
var child = spawn('npm', ['test']);
console.log('executing the tests...');
child.stderr.on('data', function(stderr) {
process.stderr.write(stderr);
});
child.stdout.on('data', function(stdout) {
process.stdout.write(stdout);
});
child.on('exit', function(code) {
if (code !== 0) {
fail(code);
} else {
console.log('Done!');
complete();
}
});
}, true); |
Namespace with all the release related tasks | namespace('release', function() { |
Build task | desc('Modify the working copy with all the release information');
task('build', ['test'], function(releaseType) {
Step(
|
Update ChangelogIt updated the | function() {
console.log('Updating History.md file...');
releaseTools.updateChangelog(this);
},
|
Update ContributorsIt overwrites the AUTHORS file with all the GIT commiters | function(err) {
if (err) throw err;
console.log('Updating AUTHORS file...');
releaseTools.updateAuthorsFile(this);
}, |
Create examplesIt converts all the specified example files to HTML files with inline annotated comments, using Docco | function(err) {
if (err) throw err;
console.log('creating examples documentation...');
releaseTools.createExamples(this);
},
function(err) {
if (err) fail();
else complete();
}
);
}, true);
|
Create site task | desc('Create the public site');
task('site', function(releaseType) { |
Create siteIt creates the | console.log('Creating the public site page...');
releaseTools.createSite(function(err) {
if (err) fail();
else complete();
});
}, true); |
Publish task | desc('Publish to GitHub and NPM the new version');
task('publish', ['test'] ,function() {
Step(
|
Check if the | function() {
releaseTools.isWorkingCopyClean('History.md', this);
},
|
Commit to GitMakes the commit and creates the tag | function(err, result) {
if (err) throw('Error while checking if the git tree is clean: ' + err);
if (result) throw('You must run jake release:build before publish');
console.log('Bumping version and creating git tag...');
releaseTools.commitToGit(this);
},
|
Update gh-pages branchIf the branch does not exist, it creates it with the contents of
the | function(err) {
if (err) throw err;
console.log('Merging changes into gh-pages branch...');
releaseTools.updatePagesBranch(this);
},
|
Push to GitHubIt just does a | function(err) {
if (err) throw err;
console.log('Pushing changes to GitHub...');
releaseTools.pushToGit(this);
},
|
Publish to NPMThe same as | function(err) {
if (err) throw err;
console.log('Publishing NPM package...');
releaseTools.npmPublish(this);
},
function(err){
if (err) fail(err);
else complete();
}
);
}, true);
|
Update package.json taskIt accepts a parameter which can be patch, minor or major and then
upgrades the version in the | desc('Bump version in package.json');
task('bump', function(releaseType) {
releaseType = releaseType || 'patch';
console.log('Bumping version in package.json...');
releaseTools.updateVersionInPackageJson(releaseType, function(err, oldVersion, newVersion) {
if (err) {
fail('Error while updating version in package.json: ' + err);
}
console.log(oldVersion + ' --> ' + newVersion);
console.log('Done!');
complete();
});
}, true);
});
desc('Default task is test');
task('default', ['test'], function(){}, true);
|