UNPKG

2.74 kBJavaScriptView Raw
1/*
2 * grunt
3 * http://gruntjs.com/
4 *
5 * Copyright (c) 2012 "Cowboy" Ben Alman
6 * Licensed under the MIT license.
7 * https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
8 */
9
10// Basic template description.
11exports.description = 'Create a jQuery plugin, including QUnit unit tests.';
12
13// Template-specific notes to be displayed before question prompts.
14exports.notes = '_Project name_ should not contain "jquery" or "js" and ' +
15 'should be a unique ID not already in use at plugins.jquery.com. _Project ' +
16 'title_ should be a human-readable title, and doesn\'t need to contain ' +
17 'the word "jQuery", although it may. For example, a plugin titled "Awesome ' +
18 'jQuery Plugin" might have the name "awesome-plugin". For more information ' +
19 'please see the documentation at ' +
20 'https://github.com/jquery/plugins.jquery.com/blob/master/docs/manifest.md';
21
22// Any existing file or directory matching this wildcard will cause a warning.
23exports.warnOn = '*';
24
25// The actual init template.
26exports.template = function(grunt, init, done) {
27
28 grunt.helper('prompt', {type: 'jquery'}, [
29 // Prompt for these values.
30 grunt.helper('prompt_for', 'name'),
31 grunt.helper('prompt_for', 'title', function(value, data, done) {
32 // Fix jQuery capitalization.
33 value = value.replace(/jquery/gi, 'jQuery');
34 done(null, value);
35 }),
36 grunt.helper('prompt_for', 'description', 'The best jQuery plugin ever.'),
37 grunt.helper('prompt_for', 'version'),
38 grunt.helper('prompt_for', 'repository'),
39 grunt.helper('prompt_for', 'homepage'),
40 grunt.helper('prompt_for', 'bugs'),
41 grunt.helper('prompt_for', 'licenses', 'MIT'),
42 grunt.helper('prompt_for', 'author_name'),
43 grunt.helper('prompt_for', 'author_email'),
44 grunt.helper('prompt_for', 'author_url'),
45 grunt.helper('prompt_for', 'jquery_version')
46 ], function(err, props) {
47 // A few additional properties.
48 props.jqueryjson = props.name + '.jquery.json';
49 props.dependencies = {jquery: props.jquery_version || '>= 1'};
50 props.keywords = [];
51
52 // Files to copy (and process).
53 var files = init.filesToCopy(props);
54
55 // Add properly-named license files.
56 init.addLicenseFiles(files, props.licenses);
57
58 // Actually copy (and process) files.
59 init.copyAndProcess(files, props, {noProcess: 'libs/**'});
60
61 // Generate package.json file, used by npm and grunt.
62 init.writePackageJSON('package.json', {
63 name: 'jquery-plugin',
64 version: '0.0.0-ignored',
65 npm_test: 'grunt qunit',
66 // TODO: pull from grunt's package.json
67 node_version: '>= 0.6.0',
68 });
69
70 // Generate jquery.json file.
71 init.writePackageJSON(props.jqueryjson, props);
72
73 // All done!
74 done();
75 });
76
77};