UNPKG

2.65 kBJavaScriptView Raw
1/*
2 * grunt
3 * https://github.com/cowboy/grunt
4 *
5 * Copyright (c) 2012 "Cowboy" Ben Alman
6 * Licensed under the MIT license.
7 * http://benalman.com/about/license/
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_ must start with "jquery." and should be a ' +
15 'unique ID not already in use at plugins.jquery.com. _Project title_ ' +
16 'should be a human-readable title, and doesn\'t need to contain the word ' +
17 '"jQuery", although it may. For example, a plugin titled "Awesome Plugin" ' +
18 'might have the name "jquery.awesome-plugin".';
19
20// Any existing file or directory matching this wildcard will cause a warning.
21exports.warnOn = '*';
22
23// The actual init template.
24exports.template = function(grunt, init, done) {
25 // Grunt utilities.
26 var task = grunt.task;
27 var file = grunt.file;
28 var utils = grunt.utils;
29 var log = grunt.log;
30 var verbose = grunt.verbose;
31 var fail = grunt.fail;
32 var option = grunt.option;
33 var config = grunt.config;
34 var template = grunt.template;
35
36 grunt.helper('prompt', {type: 'jquery'}, [
37 // Prompt for these values.
38 grunt.helper('prompt_for', 'name', function(value, data, done) {
39 // Prepend "jquery." to current name.
40 value = data.full_name = 'jquery.' + value;
41 done(null, value);
42 }),
43 grunt.helper('prompt_for', 'title', function(value, data, done) {
44 // Fix jQuery capitalization.
45 value = value.replace(/jquery/gi, 'jQuery');
46 done(null, value);
47 }),
48 grunt.helper('prompt_for', 'description', 'The best jQuery plugin ever.'),
49 grunt.helper('prompt_for', 'version'),
50 grunt.helper('prompt_for', 'repository'),
51 grunt.helper('prompt_for', 'homepage'),
52 grunt.helper('prompt_for', 'bugs'),
53 grunt.helper('prompt_for', 'licenses', 'MIT GPL'),
54 grunt.helper('prompt_for', 'author_name'),
55 grunt.helper('prompt_for', 'author_email'),
56 grunt.helper('prompt_for', 'author_url'),
57 grunt.helper('prompt_for', 'jquery_version')
58 ], function(err, props) {
59 // Files to copy (and process).
60 var files = init.filesToCopy(props);
61
62 // Add properly-named license files.
63 init.addLicenseFiles(files, props.licenses);
64
65 // Actually copy (and process) files.
66 init.copyAndProcess(files, props, {noProcess: 'libs/**'});
67
68 // jQuery plugins depend on jQuery!
69 props.dependencies = {jquery: props.jquery_version || '1'};
70
71 // Generate package.json file.
72 init.writePackageJSON('package.json', props);
73
74 // All done!
75 done();
76 });
77
78};