forked from linkedin/dustjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
228 lines (222 loc) · 6.54 KB
/
Gruntfile.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Released under the <%= pkg.license %> License */\n',
// Task configuration.
shell: {
oldTests: {
command: 'node test/server.js',
options: {
stdout: true,
failOnError: true
}
},
// these are old that should eventually be rewritten to take advantage of grunt and the current build process
buildParser: {
command: 'node src/build.js',
options: {
stdout: true
}
},
bench: {
command: 'node benchmark/server.js',
options: {
stdout: true
}
},
doc: {
command: 'node docs/build.js',
options: {
stdout: true
}
}
},
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
core: {
src: ['lib/dust.js'],
dest: 'tmp/dust-core.js'
},
full: {
src: ['lib/dust.js', 'lib/compiler.js', 'lib/parser.js'],
dest: 'tmp/dust-full.js'
}
},
copy: {
core: {
src: 'tmp/dust-core.js',
dest: 'dist/dust-core.js'
},
coreMin: {
src: 'tmp/dust-core.min.js',
dest: 'dist/dust-core.min.js'
},
full: {
src: 'tmp/dust-full.js',
dest: 'dist/dust-full.js'
},
fullMin: {
src: 'tmp/dust-full.min.js',
dest: 'dist/dust-full.min.js'
},
license: {
src: 'LICENSE',
dest: 'dist/'
}
},
uglify: {
options: {
banner: '<%= banner %>',
mangle: {
except: ['require', 'define', 'module', 'dust']
}
},
core: {
src: '<%= concat.core.dest %>',
dest: 'tmp/dust-core.min.js'
},
full: {
src: '<%= concat.full.dest %>',
dest: 'tmp/dust-full.min.js'
}
},
compress: {
distTarBall: {
options: {
archive: 'archive/dust-<%= pkg.version %>.tar.gz',
mode: 'tgz',
pretty: true
},
files: [
{expand: true, cwd: 'dist', src: ['**'], dest: 'dust-<%= pkg.version %>/', filter: 'isFile'}
]
},
distZip: {
options: {
archive: 'archive/dust-<%= pkg.version %>.zip',
mode: 'zip',
pretty: true
},
files: [
{expand: true, cwd: 'dist', src: ['**'], dest: 'dust-<%= pkg.version %>/', filter: 'isFile'}
]
}
},
clean: {
build: ['tmp/*'],
dist: ['dist/*'],
specRunner: '_SpecRunner.html'
},
jshint: {
options: {
jshintrc: true
},
gruntfile: {
src: 'Gruntfile.js'
},
libs: {
src: ['lib/**/*.js', 'util/**/*.js', 'src/**/*.js', '!lib/parser.js'] // don't hint the parser which is autogenerated from pegjs
}
},
connect: {
testServer: {
options: {
port: 3000,
keepalive: true
}
}
},
jasmine: {
allTests: {
src: 'tmp/dust-full.min.js',
options: {
specs: ['test/jasmine-test/spec/**/*.js'],
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'tmp/coverage/coverage.json',
report: 'tmp/coverage'
}
}
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib_test: {
files: ['<%= jshint.libs.src %>', '<%= jasmine.allTests.options.specs%>'],
tasks: ['jshint:libs', 'jasmine']
}
},
bump: {
options: {
files: ['package.json', 'bower.json'],
updateConfigs: ['pkg']
}
},
log: {
coverage: {
options: {
message: 'Coverage is run with `grunt test`. Look inside tmp/coverage'
}
},
copyForRelease: {
options: {
message: 'OK. Done copying version <%= pkg.version %> build from tmp to dist'
}
},
testClient: {
options: {
message: 'go to http://localhost:<%= connect.testServer.options.port %>/_SpecRunner.html.\n Ctrl-C to kill the server.'
}
},
release: {
options: {
message: ['OK. Done bumping, adding, committing, tagging and pushing the new version',
'',
'You still need to manually do the following:',
' * npm publish'].join('\n')
}
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-shell');
// Npm tasks
grunt.registerTask('default', ['build']);
grunt.registerTask('build', ['clean:build', 'jshint', 'shell:buildParser','concat', 'uglify']);
grunt.registerTask('test', ['clean:specRunner', 'build', 'jasmine', 'shell:oldTests']);
grunt.registerTask('testClient', ['build', 'jasmine:allTests:build', 'log:testClient', 'connect:testServer']);
grunt.registerTask('copyForRelease', ['clean:dist', 'copy:core', 'copy:coreMin', 'copy:full', 'copy:fullMin', 'copy:license', 'log:copyForRelease']);
grunt.registerTask('buildRelease', ['test', 'copyForRelease', 'compress']);
grunt.registerTask('releasePatch', ['bump-only:patch', 'buildRelease', 'bump-commit:patch', 'log:release']);
grunt.registerTask('releaseMinor', ['bump-only:minor', 'buildRelease', 'bump-commit:minor', 'log:release']);
// major release should probably be done with care
// grunt.registerTask('releaseMajor', ['bump-only:major', 'buildRelease', 'bump-commit:major', 'log:release']);
// Custom tasks
grunt.registerMultiTask('log', 'Print some messages', function() {
grunt.log.writeln(this.data.options.message);
});
grunt.registerTask('coverage', ['log:coverage']);
};