This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
/
Gruntfile.js
444 lines (432 loc) · 16 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
/*
* Copyright (c) 2013 - present Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/*eslint-env node */
/*jslint node: true */
'use strict';
module.exports = function (grunt) {
// load dependencies
require('load-grunt-tasks')(grunt, {
pattern: [
'grunt-*',
'!grunt-cli',
'!grunt-lib-phantomjs',
'!grunt-template-jasmine-requirejs'
]
});
grunt.loadTasks('tasks');
// Project configuration.
grunt.initConfig({
pkg : grunt.file.readJSON("package.json"),
clean: {
dist: {
files: [{
dot: true,
src: [
'dist',
'src/.index.html',
'src/styles/brackets.css'
]
}]
},
node_modules_test_dir : {
files: [{
dot: true,
src: [
'dist/node_modules/npm/test/fixtures',
'dist/node_modules/npm/node_modules/tar/test',
'dist/node_modules/npm/node_modules/npm-registry-client/test'
]
}]
}
},
copy: {
dist: {
files: [
{
'dist/index.html': 'src/.index.html'
},
/* static files */
{
expand: true,
dest: 'dist/',
cwd: 'src/',
src: [
'nls/{,*/}*.js',
'xorigin.js',
'dependencies.js',
'thirdparty/requirejs/require.js',
'LiveDevelopment/launch.html',
'LiveDevelopment/transports/**',
'LiveDevelopment/MultiBrowserImpl/transports/**',
'LiveDevelopment/MultiBrowserImpl/launchers/**'
]
},
/* node domains are not minified and must be copied to dist */
{
expand: true,
dest: 'dist/',
cwd: 'src/',
src: [
'extensibility/node/**',
'JSUtils/node/**',
'languageTools/node/**',
'languageTools/styles/**',
'languageTools/LanguageClient/**',
'!extensibility/node/spec/**',
'!extensibility/node/node_modules/**/{test,tst}/**/*',
'!extensibility/node/node_modules/**/examples/**/*',
'filesystem/impls/appshell/node/**',
'!filesystem/impls/appshell/node/spec/**',
'search/node/**'
]
},
/* extensions and CodeMirror modes */
{
expand: true,
dest: 'dist/',
cwd: 'src/',
src: [
'extensions/default/**/*',
'!extensions/default/*/unittest-files/**/*',
'!extensions/default/*/unittests.js',
'!extensions/default/{*/thirdparty,**/node_modules}/**/test/**/*',
'!extensions/default/{*/thirdparty,**/node_modules}/**/doc/**/*',
'!extensions/default/{*/thirdparty,**/node_modules}/**/examples/**/*',
'!extensions/default/*/thirdparty/**/*.htm{,l}',
'extensions/dev/*',
'extensions/samples/**/*',
'thirdparty/CodeMirror/**',
'thirdparty/i18n/*.js',
'thirdparty/text/*.js'
]
},
/* styles, fonts and images */
{
expand: true,
dest: 'dist/styles',
cwd: 'src/styles',
src: ['jsTreeTheme.css', 'fonts/{,*/}*.*', 'images/*', 'brackets.min.css*']
}
]
},
thirdparty: {
files: [
{
expand: true,
dest: 'src/thirdparty/CodeMirror',
cwd: 'src/node_modules/codemirror',
src: [
'addon/{,*/}*',
'keymap/{,*/}*',
'lib/{,*/}*',
'mode/{,*/}*',
'theme/{,*/}*'
]
},
{
expand: true,
flatten: true,
dest: 'src/thirdparty',
cwd: 'src/node_modules',
src: [
'less/dist/less.min.js'
]
},
{
expand: true,
flatten: true,
dest: 'src/thirdparty/preact-compat',
cwd: 'src/node_modules/preact-compat',
src: [
'dist/preact-compat.min.js'
]
},
{
expand: true,
flatten: true,
dest: 'src/thirdparty/simulate-event',
cwd: 'src/node_modules/simulate-event',
src: [
'simulate-event.js'
]
},
{
expand: true,
flatten: true,
dest: 'src/thirdparty/xtend',
cwd: 'src/node_modules/xtend',
src: [
'mutable.js',
'immutable.js'
]
},
{
expand: true,
dest: 'src/thirdparty/acorn',
cwd: 'src/node_modules/acorn',
src: [
'dist/{,*/}*'
]
}
]
}
},
cleanempty: {
options: {
force: true,
files: false
},
src: ['dist/**/*']
},
less: {
dist: {
files: {
"src/styles/brackets.min.css": "src/styles/brackets.less"
},
options: {
compress: true,
sourceMap: true,
sourceMapFilename: 'src/styles/brackets.min.css.map',
outputSourceFiles: true,
sourceMapRootpath: '',
sourceMapBasepath: 'src/styles'
}
}
},
requirejs: {
dist: {
// Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
options: {
// `name` and `out` is set by grunt-usemin
baseUrl: 'src',
optimize: 'uglify2',
// brackets.js should not be loaded until after polyfills defined in "utils/Compatibility"
// so explicitly include it in main.js
include: ["utils/Compatibility", "brackets"],
// TODO: Figure out how to make sourcemaps work with grunt-usemin
// https://github.com/yeoman/grunt-usemin/issues/30
generateSourceMaps: true,
useSourceUrl: true,
// required to support SourceMaps
// http://requirejs.org/docs/errors.html#sourcemapcomments
preserveLicenseComments: false,
useStrict: true,
// Disable closure, we want define/require to be globals
wrap: false,
exclude: ["text!config.json"],
uglify2: {} // https://github.com/mishoo/UglifyJS2
}
}
},
targethtml: {
dist: {
files: {
'src/.index.html': 'src/index.html'
}
}
},
useminPrepare: {
options: {
dest: 'dist'
},
html: 'src/.index.html'
},
usemin: {
options: {
dirs: ['dist']
},
html: ['dist/{,*/}*.html']
},
htmlmin: {
dist: {
options: {
/*removeCommentsFromCDATA: true,
// https://github.com/yeoman/grunt-usemin/issues/44
//collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeOptionalTags: true*/
},
files: [{
expand: true,
cwd: 'src',
src: '*.html',
dest: 'dist'
}]
}
},
meta : {
src : [
'src/**/*.js',
'!src/thirdparty/**',
'!src/widgets/bootstrap-*.js',
'!src/extensions/**/unittest-files/**/*.js',
'!src/extensions/**/thirdparty/**/*.js',
'!src/extensions/dev/**',
'!src/extensions/disabled/**',
'!**/node_modules/**/*.js',
'!src/**/*-min.js',
'!src/**/*.min.js'
],
test : [
'test/**/*.js',
'!test/perf/*-files/**/*.js',
'!test/spec/*-files/**/*.js',
'!test/spec/*-known-goods/**/*.js',
'!test/spec/FindReplace-test-files-*/**/*.js',
'!test/smokes/**',
'!test/temp/**',
'!test/thirdparty/**',
'!test/**/node_modules/**/*.js'
],
grunt: [
'Gruntfile.js',
'tasks/**/*.js'
],
/* specs that can run in phantom.js */
specs : [
'test/spec/CommandManager-test.js',
//'test/spec/LanguageManager-test.js',
//'test/spec/PreferencesManager-test.js',
'test/spec/ViewUtils-test.js'
]
},
watch: {
grunt: {
files: ['<%= meta.grunt %>'],
tasks: ['eslint:grunt']
},
src: {
files: ['<%= meta.src %>'],
tasks: ['eslint:src']
},
test: {
files: ['<%= meta.test %>'],
tasks: ['eslint:test']
},
options: {
spawn: false
}
},
/* FIXME (jasonsanjose): how to handle extension tests */
jasmine : {
src : 'undefined.js', /* trick the default runner to run without importing src files */
options : {
junit : {
path: 'test/results',
consolidate: true
},
specs : '<%= meta.specs %>',
/* Keep in sync with test/SpecRunner.html dependencies */
vendor : [
// For reference to why this polyfill is needed see Issue #7951.
// The need for this should go away once the version of phantomjs gets upgraded to 2.0
'test/polyfills.js',
'src/thirdparty/jquery-2.1.3.min.js',
'src/thirdparty/less.min.js'
],
helpers : [
'test/spec/PhantomHelper.js'
],
template : require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfig : {
baseUrl: 'src',
paths: {
'test' : '../test',
'perf' : '../test/perf',
'spec' : '../test/spec',
'text' : 'thirdparty/text/text',
'i18n' : 'thirdparty/i18n/i18n'
}
}
}
}
},
'jasmine_node': {
projectRoot: 'src/extensibility/node/spec/'
},
eslint: {
grunt: '<%= meta.grunt %>',
src: '<%= meta.src %>',
test: '<%= meta.test %>',
options: {
quiet: true
}
},
shell: {
repo: grunt.option("shell-repo") || "../brackets-shell",
mac: "<%= shell.repo %>/installer/mac/staging/<%= pkg.name %>.app",
win: "<%= shell.repo %>/installer/win/staging/<%= pkg.name %>.exe",
linux: "<%= shell.repo %>/installer/linux/debian/package-root/opt/brackets/brackets"
}
});
// task: install
grunt.registerTask('install', [
'write-config:dev',
'less',
'npm-download-default-extensions',
'npm-install-source',
'pack-web-dependencies'
]);
// task: test
grunt.registerTask('test', ['eslint', 'jasmine', 'nls-check']);
// grunt.registerTask('test', ['eslint', 'jasmine', 'jasmine_node', 'nls-check']);
// task: set-release
// Update version number in package.json and rewrite src/config.json
grunt.registerTask('set-release', ['update-release-number', 'write-config:dev']);
grunt.registerTask('build-common', [
'eslint:src',
'jasmine',
'clean',
'less',
'targethtml',
'useminPrepare',
'htmlmin',
'requirejs',
'concat',
/*'cssmin',*/
/*'uglify',*/
'copy:dist',
'npm-install',
'cleanempty',
'usemin',
'build-config',
'clean:node_modules_test_dir'
]);
// task: build
grunt.registerTask('build', [
'write-config:dist',
'build-common'
]);
// task: build
grunt.registerTask('build-prerelease', [
'write-config:prerelease',
'build-common'
]);
// Default task.
grunt.registerTask('default', ['test']);
};