-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.js
100 lines (88 loc) · 2.93 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
'use strict';
exports.description = 'Create a project dependent module';
exports.notes = '';
exports.after = ''
// 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 : 'DEMO'
},
[
// Prompt for these values.
init.prompt('name'),
init.prompt('licenses', 'MIT'),
init.prompt('author_name'),
init.prompt('author_email','none'),
init.prompt('jquery_version', '*'),
init.prompt('bootstrap_version', '*'),
init.prompt('angularjs_version', '*'), ],
function(err, props) {
props.keywords = [];
if (props.jquery_version == 'n'
|| props.jquery_version == 'N') {
delete props.jquery_version;
}
if (props.bootstrap_version == 'n'
|| props.bootstrap_version == 'N') {
delete props.bootstrap_version;
}
if (props.angularjs_version == 'n'
|| props.angularjs_version == 'N') {
delete props.angularjs_version;
}
props.devDependencies = {
'bower' : '~1.4.1',
'grunt-bower-task' : '~0.4.0',
'grunt-contrib-uglify' : '~0.9.1',
'grunt-contrib-jshint' : '~0.11.1',
'grunt-contrib-concat' : '~0.5.1',
'grunt-contrib-cssmin' : '~0.12.2',
'grunt-contrib-less' : '~1.0.1',
'grunt-contrib-sass' : '~0.9.2',
'grunt-contrib-clean' : '~0.6.0',
'grunt-contrib-qunit' : '~0.7.0',
'grunt-contrib-watch' : '~0.6.1',
'grunt-contrib-csslint' : '~0.4.0',
'grunt-contrib-copy' : '~0.8.0',
'grunt-csscomb' : '~3.0.0',
'grunt-autoprefixer' : '~3.0.0'
};
// 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);
// Generate package.json file.
init.writePackageJSON('package.json', props);
var bowerDependencies = {};
var genBowerJson = false;
if (props.jquery_version) {
bowerDependencies.jquery = props.jquery_version == '*' ? props.jquery_version
: '~' + props.jquery_version;
genBowerJson = true;
}
if (props.bootstrap_version) {
bowerDependencies.bootstrap = props.bootstrap_version == '*' ? props.bootstrap_version
: '~' + props.bootstrap_version;
genBowerJson = true;
}
if (props.angularjs_version) {
bowerDependencies.angularjs = props.angularjs_version == '*' ? props.angularjs_version
: '~' + props.angularjs_version;
genBowerJson = true;
}
if (genBowerJson) {
init.writePackageJSON('bower.json', {
name : props.name,
version : props.version,
dependencies : bowerDependencies
});
}
done();
});
};