JavaScript build tool, similar to Make or Rake
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Specialized task types for common build operations including package creation, publishing, and test execution with built-in conventions and workflow automation.
Creates a PackageTask that generates distributable packages in various formats (tar, zip, jar, etc.).
/**
* Creates a PackageTask for generating distributable packages
* @param {string} name - The name of the project
* @param {string} version - The current project version
* @param {string[]} [prereqs] - Prerequisites to run before packaging
* @param {Function} definition - Function that defines package contents and format
* @returns {PackageTask} The created package task instance
*/
function packageTask(name, version, prereqs, definition);Usage Examples:
// Basic package task
const pkg = packageTask('myproject', '1.0.0', function () {
this.packageFiles.include([
'lib/**',
'bin/**',
'README.md',
'package.json'
]);
this.packageFiles.exclude(['lib/**/*.test.js']);
this.needTarGz = true;
});
// Package with prerequisites and custom options
const pkg = packageTask('webapp', '2.1.0', ['build', 'test'], function () {
this.packageDir = 'dist/packages';
this.packageFiles.include([
'build/**',
'public/**',
'package.json',
'README.md'
]);
// Create multiple archive types
this.needTar = true;
this.needTarGz = true;
this.needZip = true;
// Archive options
this.archiveNoBaseDir = true;
this.archiveChangeDir = 'build';
});
// JAR package for Java-style projects
const pkg = packageTask('java-tools', '1.5.2', function () {
this.packageFiles.include([
'dist/**/*.class',
'resources/**',
'META-INF/**'
]);
this.needJar = true;
this.manifestFile = 'META-INF/MANIFEST.MF';
});PackageTask Properties:
interface PackageTask {
name: string; // Project name
version: string; // Project version
prereqs: string[]; // Prerequisites
packageDir: string; // Package directory (default: 'pkg')
packageFiles: FileList; // Files to include in package
needTar: boolean; // Create .tgz archive
needTarGz: boolean; // Create .tar.gz archive
needTarBz2: boolean; // Create .tar.bz2 archive
needJar: boolean; // Create .jar archive
needZip: boolean; // Create .zip archive
manifestFile: string; // JAR manifest file path
tarCommand: string; // Tar command (default: 'tar')
jarCommand: string; // Jar command (default: 'jar')
zipCommand: string; // Zip command (default: 'zip')
archiveNoBaseDir: boolean; // Archive without base directory
archiveChangeDir: string; // Change to directory before archiving
archiveContentDir: string; // Specific content directory to archive
packageName(): string; // Get package name
packageDirPath(): string; // Get full package directory path
}Created Tasks:
package - Build the complete packagerepackage - Rebuild the packageclobberPackage - Remove package directoryclobber - Alias for clobberPackageCreates a PublishTask that handles version management and package publishing to repositories.
/**
* Creates a PublishTask for version management and package publishing
* @param {string} name - The project name
* @param {string[]} [prereqs] - Prerequisites to run before publishing
* @param {Object} [opts] - Publishing options
* @param {Function} definition - Function that defines publish configuration
* @returns {PublishTask} The created publish task instance
*/
function publishTask(name, prereqs, opts, definition);
/**
* Legacy alias for publishTask - creates a PublishTask for npm publishing
* @param {string} name - The project name
* @param {string[]} [prereqs] - Prerequisites to run before publishing
* @param {Object} [opts] - Publishing options
* @param {Function} definition - Function that defines publish configuration
* @returns {PublishTask} The created publish task instance
*/
function npmPublishTask(name, prereqs, opts, definition);Publishing Options:
interface PublishOptions {
publishCmd?: string; // Publish command template (default: 'npm publish %filename')
publishMessage?: string; // Success message (default: 'BOOM! Published.')
gitCmd?: string; // Git command (default: 'git')
versionFiles?: string[]; // Files to update with version (default: ['package.json'])
}Usage Examples:
// Basic npm publish task
const pub = publishTask('mypackage', ['package'], function () {
this.packageFiles.include([
'lib/**',
'package.json',
'README.md'
]);
});
// Custom publish configuration
const pub = publishTask('webapp', ['build', 'test', 'package'], {
publishCmd: 'npm publish --registry=https://my-registry.com %filename',
publishMessage: 'Successfully published to private registry!',
versionFiles: ['package.json', 'bower.json', 'VERSION.txt']
}, function () {
this.packageFiles.include([
'dist/**',
'package.json',
'README.md',
'CHANGELOG.md'
]);
});
// Custom publish command function
const pub = publishTask('enterprise-app', ['package'], function () {
this.packageFiles.include(['dist/**', 'package.json']);
this.createPublishCommand = function (version) {
return [
'aws s3 cp ' + this.packageDirPath() + '/' + this.packageName() + '.tar.gz s3://releases/',
'curl -X POST https://api.internal.com/releases -d "version=' + version + '"'
];
};
});Created Tasks:
publish - Create new version and releasepublishExisting - Release existing version without version bumpversion - Update version and push to gitrelease - Package, publish, and cleanuppublish:fetchTags, publish:updateVersionFiles, etc.)Creates a TestTask that provides a framework for running test suites with setup/teardown support.
/**
* Creates a TestTask for running test suites
* @param {string} name - The project name
* @param {string[]} [prereqs] - Prerequisites to run before testing
* @param {Function} definition - Function that defines test configuration
* @returns {TestTask} The created test task instance
*/
function testTask(name, prereqs, definition);Usage Examples:
// Basic test task
const test = testTask('myproject', function () {
this.testFiles.include('test/**/*.js');
});
// Test task with prerequisites and custom name
const test = testTask('webapp', ['build'], function () {
this.testName = 'spec'; // Creates 'spec' task instead of 'test'
this.testFiles.include([
'test/unit/**/*.js',
'test/integration/**/*.js'
]);
this.testFiles.exclude('test/**/*.helper.js');
});
// Hidden test task (not shown in jake -T)
const test = testTask('internal-tests', function () {
this.showDescription = false;
this.testFiles.include('test/internal/**/*.js');
});Test File Structure:
Test files should export functions for individual tests and optional setup/teardown:
// test/math.test.js
exports.before = function () {
// Setup before all tests in this file
console.log('Setting up math tests');
};
exports.after = function () {
// Cleanup after all tests in this file
console.log('Cleaning up math tests');
};
exports.beforeEach = function () {
// Setup before each test
this.calculator = new Calculator();
};
exports.afterEach = function () {
// Cleanup after each test
this.calculator = null;
};
exports.testAddition = function () {
const result = this.calculator.add(2, 3);
if (result !== 5) {
throw new Error('Addition test failed');
}
console.log('Addition test passed');
};
exports.testSubtraction = function () {
const result = this.calculator.subtract(5, 3);
if (result !== 2) {
throw new Error('Subtraction test failed');
}
console.log('Subtraction test passed');
};TestTask Properties:
interface TestTask {
testName: string; // Name of test namespace and task (default: 'test')
testFiles: FileList; // List of test files to load
showDescription: boolean; // Show task in `jake -T` (default: true)
totalTests: number; // Total number of tests to run
executedTests: number; // Number of successfully executed tests
}Created Tasks:
test (or custom testName) - Main task to run all teststest:run (or custom) - Internal task that executes test files// Complete build and deploy pipeline
desc('Clean build artifacts');
task('clean', function () {
jake.rmRf('dist');
jake.rmRf('coverage');
});
desc('Install dependencies');
task('install', function () {
jake.exec(['npm install'], { printStdout: true });
});
desc('Lint source code');
task('lint', ['install'], function () {
jake.exec(['eslint src/**/*.js'], { printStdout: true });
});
desc('Run unit tests');
task('test:unit', ['install'], function () {
jake.exec(['mocha test/unit/**/*.js'], { printStdout: true });
});
desc('Run integration tests');
task('test:integration', ['install'], function () {
jake.exec(['mocha test/integration/**/*.js'], { printStdout: true });
});
desc('Run all tests');
task('test', ['test:unit', 'test:integration']);
desc('Build application');
task('build', ['clean', 'lint', 'test'], function () {
jake.exec(['webpack --mode=production'], { printStdout: true });
});
// Package task
const pkg = packageTask('myapp', '1.0.0', ['build'], function () {
this.packageFiles.include([
'dist/**',
'package.json',
'README.md',
'LICENSE'
]);
this.needTarGz = true;
});
// Publish task
const pub = publishTask('myapp', ['package'], function () {
this.packageFiles.include([
'dist/**',
'package.json',
'README.md'
]);
});
desc('Complete CI/CD pipeline');
task('ci', ['clean', 'install', 'lint', 'test', 'build', 'package']);
desc('Deploy to production');
task('deploy', ['ci', 'publish']);// Environment-specific builds
namespace('build', function () {
desc('Build for development');
task('dev', ['clean'], function () {
process.env.NODE_ENV = 'development';
jake.exec(['webpack --mode=development'], { printStdout: true });
});
desc('Build for staging');
task('staging', ['clean', 'test'], function () {
process.env.NODE_ENV = 'staging';
jake.exec(['webpack --mode=production'], { printStdout: true });
});
desc('Build for production');
task('prod', ['clean', 'test', 'lint'], function () {
process.env.NODE_ENV = 'production';
jake.exec(['webpack --mode=production --optimize-minimize'], { printStdout: true });
});
});
// Environment-specific packages
const devPkg = packageTask('myapp', '1.0.0-dev', ['build:dev'], function () {
this.packageDir = 'packages/dev';
this.packageFiles.include(['dist/**']);
this.needZip = true;
});
const prodPkg = packageTask('myapp', '1.0.0', ['build:prod'], function () {
this.packageDir = 'packages/prod';
this.packageFiles.include(['dist/**']);
this.needTarGz = true;
});