-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.js
107 lines (92 loc) · 3.7 KB
/
template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* grunt-init-jquery
* https://gruntjs.com/
*
* Copyright (c) 2013 "Cowboy" Ben Alman, contributors
* Licensed under the MIT license.
*/
'use strict';
// Basic template description.
exports.description = '创建一个谢泽自动化插件,包括,qunit单元化测试,livereload浏览器自动刷新';
// Template-specific notes to be displayed before question prompts.
exports.notes = '项目名称不应包含“jquery”或“js”和 ' +
'应该一个惟一的ID而不是已经在使用plugins.jquery.com。项目 ' +
'标题应该是一个人类可读的标题,并需要包含 ' +
'“jQuery”这个词,虽然它可能。例如,一个插件名为“太棒了 ' +
'插件”可能会“awesome-plugin”。' +
'\n\n'+
'有关更多信息,请参阅以下文档:' +
'\n\n'+
'Naming Your Plugin http://plugins.jquery.com/docs/names/\n' +
'Publishing Your Plugin http://plugins.jquery.com/docs/publish/\n' +
'Package Manifest http://plugins.jquery.com/docs/package-manifest/';
// Template-specific notes to be displayed after question prompts.
exports.after = 'You should now install project dependencies with _npm ' +
'install_. After that, you may execute project tasks with _grunt_. For ' +
'more information about installing and configuring Grunt, please see ' +
'the Getting Started guide:' +
'\n\n' +
'http://gruntjs.com/getting-started';
// Any existing file or directory matching this wildcard will cause a warning.
exports.warnOn = '*';
// The actual init template.
exports.template = function(grunt, init, done) {
init.process({type: 'jquery'}, [
// Prompt for these values.
init.prompt('name',"webapp"),
init.prompt('title', function(value, data, done) {
// Fix jQuery capitalization.
value = value.replace(/jquery/gi, 'webapp');
done(null, value);
}),
init.prompt('description', 'The best xieze plugin ever.'),
init.prompt('version','0.0.1'),
init.prompt('repository','https://github.com/xieze'),
init.prompt('homepage'),
init.prompt('bugs'),
init.prompt('licenses', 'MIT'),
init.prompt('author_name','xieze'),
init.prompt('author_email','[email protected]'),
init.prompt('author_url','http://www.chezhuanger.com'),
init.prompt('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.8.0',
devDependencies: {
'grunt-contrib-jshint': '~0.10.0',
'grunt-contrib-qunit': '~0.2.0',
'grunt-contrib-concat': '~0.3.0',
'grunt-contrib-uglify': '~0.2.0',
'grunt-contrib-watch': '~0.4.0',
'grunt-contrib-clean': '~0.4.0',
"connect-livereload": "~0.5.3",
"grunt-contrib-connect": "~0.11.2",
"serve-static": "~1.10.0",
"serve-index": "~1.7.2"
},
});
// Generate jquery.json file.
init.writePackageJSON(props.jqueryjson, props, function(pkg, props) {
// The jQuery site needs the "bugs" value as a string.
if ('bugs' in props) { pkg.bugs = props.bugs; }
return pkg;
});
// All done!
done();
});
};