-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.js
90 lines (78 loc) · 3.33 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
'use strict';
// Basic template description.
exports.description = 'Simple template to write package.json and set up working directory.';
// Any existing file or directory matching this wildcard will cause a warning.
exports.warnOn = '*';
exports.template = function (grunt, init, done) {
init.process({}, [
// Prompt for these values.
init.prompt('module'),
init.prompt('name'),
init.prompt('title'),
init.prompt('description'),
init.prompt('version', '1.0.0'),
init.prompt('author_name', 'The Open University'),
init.prompt('author_email'),
init.prompt('author_url'),
init.prompt('jquery_version', '>1.11.2'),
init.prompt('webthumbnail', 'y/N')
//init.prompt('licenses', 'MIT'),
], function (err, props) {
// Module dependencies
var join = require("path").join;
// Empty directories will not be copied, so we need to create them manual
grunt.file.mkdir(join(init.destpath(), 'build'));
grunt.file.mkdir(join(init.destpath(), 'src/img'));
grunt.file.mkdir(join(init.destpath(), 'src/img/not_used'));
grunt.file.mkdir(join(init.destpath(), 'src/js'));
grunt.file.mkdir(join(init.destpath(), 'src/js/vendor'));
grunt.file.mkdir(join(init.destpath(), 'src/css/vendor'));
grunt.file.mkdir(join(init.destpath(), 'src/_sources'));
// 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, used by npm and grunt.
init.writePackageJSON('package.json', props, function (pkg, props) {
pkg.devDependencies = {
'grunt': '~0.4.5',
'grunt-contrib-clean': '^0.6.0',
'grunt-contrib-compress': '>0.11.0',
'grunt-contrib-concat': '^0.5.0',
'grunt-contrib-copy': '^0.5.0',
'grunt-contrib-csslint': '^0.3.1',
'grunt-contrib-jshint': '^0.10.0',
'grunt-contrib-uglify': '^0.5.1',
'grunt-contrib-watch': '^0.6.1',
'grunt-contrib-cssmin': '^0.10.0',
'grunt-bower-install-simple': '^1.1.0',
'grunt-open': '^0.2.3',
'grunt-processhtml': '^0.3.3',
'grunt-shell': '^1.1.1',
'grunt-text-replace': '^0.3.12'
};
pkg.module = props.module;
if (props.webthumbnail === 'y/N') {
pkg.width = '512';
pkg.webthumbnail = false;
} else {
pkg.width = '880';
pkg.webthumbnail = true;
}
if (props.jquery_version.charAt(0) === '2') {
pkg.jquery_version = '>=2.0';
} else {
pkg.jquery_version = '>=1.0 <2.0';
}
pkg.height = '820';
pkg.vle_sc_path = '\\\\esaki\\lts-common$\\alex_phillips\\' + props.module + '\\';
pkg.vle_path = 'X:/alex_phillips/' + props.module + '/';
pkg.remote_repository = '\\\\esaki\\LTS-Software\\git-repos\\' + props.name + '.git';
return pkg;
});
// All done!
done();
});
};