You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

77 lines
2.7 KiB

/*
* grunt
* http://gruntjs.com/
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
* https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
*/
// Basic template description.
exports.description = 'Create a jQuery plugin, including QUnit unit tests.';
// Template-specific notes to be displayed before question prompts.
exports.notes = '_Project name_ should not contain "jquery" or "js" and ' +
'should be a unique ID not already in use at plugins.jquery.com. _Project ' +
'title_ should be a human-readable title, and doesn\'t need to contain ' +
'the word "jQuery", although it may. For example, a plugin titled "Awesome ' +
'jQuery Plugin" might have the name "awesome-plugin". For more information ' +
'please see the documentation at ' +
'https://github.com/jquery/plugins.jquery.com/blob/master/docs/manifest.md';
// Any existing file or directory matching this wildcard will cause a warning.
exports.warnOn = '*';
// The actual init template.
exports.template = function(grunt, init, done) {
grunt.helper('prompt', {type: 'jquery'}, [
// Prompt for these values.
grunt.helper('prompt_for', 'name'),
grunt.helper('prompt_for', 'title', function(value, data, done) {
// Fix jQuery capitalization.
value = value.replace(/jquery/gi, 'jQuery');
done(null, value);
}),
grunt.helper('prompt_for', 'description', 'The best jQuery plugin ever.'),
grunt.helper('prompt_for', 'version'),
grunt.helper('prompt_for', 'repository'),
grunt.helper('prompt_for', 'homepage'),
grunt.helper('prompt_for', 'bugs'),
grunt.helper('prompt_for', 'licenses', 'MIT'),
grunt.helper('prompt_for', 'author_name'),
grunt.helper('prompt_for', 'author_email'),
grunt.helper('prompt_for', 'author_url'),
grunt.helper('prompt_for', 'jquery_version')
], function(err, props) {
// A few additional properties.
props.jqueryjson = props.name + '.jquery.json';
props.dependencies = {jquery: props.jquery_version || '>= 1'};
props.keywords = [];
// Files to copy (and process).
var files = init.filesToCopy(props);
// Add properly-named license files.
init.addLicenseFiles(files, props.licenses);
// Actually copy (and process) files.
init.copyAndProcess(files, props, {noProcess: 'libs/**'});
// Generate package.json file, used by npm and grunt.
init.writePackageJSON('package.json', {
name: 'jquery-plugin',
version: '0.0.0-ignored',
npm_test: 'grunt qunit',
// TODO: pull from grunt's package.json
node_version: '>= 0.6.0',
});
// Generate jquery.json file.
init.writePackageJSON(props.jqueryjson, props);
// All done!
done();
});
};