2013-02-20 03:14:14 +01:00
/ *
* Copyright ( c ) 2013 Adobe Systems Incorporated . All rights reserved .
2014-12-13 02:58:06 +01:00
*
2013-02-20 03:14:14 +01:00
* Permission is hereby granted , free of charge , to any person obtaining a
2014-12-13 02:58:06 +01:00
* 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
2013-02-20 03:14:14 +01:00
* Software is furnished to do so , subject to the following conditions :
2014-12-13 02:58:06 +01:00
*
2013-02-20 03:14:14 +01:00
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software .
2014-12-13 02:58:06 +01:00
*
2013-02-20 03:14:14 +01:00
* THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR
2014-12-13 02:58:06 +01:00
* IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY ,
2013-02-20 03:14:14 +01:00
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE
2014-12-13 02:58:06 +01:00
* 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
2013-02-20 03:14:14 +01:00
* DEALINGS IN THE SOFTWARE .
2014-12-13 02:58:06 +01:00
*
2013-02-20 03:14:14 +01:00
* /
2013-02-26 01:18:51 +01:00
/*global module, require*/
2013-01-24 19:48:31 +01:00
module . exports = function ( grunt ) {
2013-01-24 19:45:28 +01:00
'use strict' ;
2013-10-30 04:09:01 +01:00
// load dependencies
2015-09-12 10:50:34 +02:00
require ( 'load-grunt-tasks' ) ( grunt , { pattern : [ 'grunt-contrib-*' , 'grunt-targethtml' , 'grunt-usemin' , 'grunt-cleanempty' , 'grunt-eslint' ] } ) ;
2013-10-30 04:09:01 +01:00
grunt . loadTasks ( 'tasks' ) ;
2014-12-13 02:58:06 +01:00
2013-01-24 19:45:28 +01:00
// Project configuration.
grunt . initConfig ( {
2013-03-20 06:44:15 +01:00
pkg : grunt . file . readJSON ( "package.json" ) ,
2013-10-30 04:09:01 +01:00
clean : {
2013-11-01 19:10:32 +01:00
dist : {
files : [ {
dot : true ,
src : [
'dist' ,
'src/.index.html' ,
'src/styles/brackets.css'
]
} ]
}
2013-10-30 04:09:01 +01:00
} ,
copy : {
dist : {
files : [
2013-11-01 19:10:32 +01:00
{
'dist/index.html' : 'src/.index.html'
} ,
2013-10-31 03:01:36 +01:00
/* static files */
{
expand : true ,
dest : 'dist/' ,
cwd : 'src/' ,
src : [
'nls/{,*/}*.js' ,
'xorigin.js' ,
'dependencies.js' ,
2013-11-01 19:10:32 +01:00
'thirdparty/requirejs/require.js' ,
2014-12-13 02:58:06 +01:00
'LiveDevelopment/launch.html' ,
'LiveDevelopment/MultiBrowserImpl/transports/**' ,
'LiveDevelopment/MultiBrowserImpl/launchers/**'
2013-10-31 03:01:36 +01:00
]
} ,
2013-12-18 21:04:07 +01:00
/* node domains are not minified and must be copied to dist */
{
expand : true ,
dest : 'dist/' ,
cwd : 'src/' ,
src : [
'extensibility/node/**' ,
'!extensibility/node/spec/**' ,
2014-12-18 17:32:33 +01:00
'!extensibility/node/node_modules/**/{test,tst}/**/*' ,
'!extensibility/node/node_modules/**/examples/**/*' ,
2013-12-18 21:04:07 +01:00
'filesystem/impls/appshell/node/**' ,
2015-07-23 04:21:29 +02:00
'!filesystem/impls/appshell/node/spec/**' ,
'search/node/**'
2013-12-18 21:04:07 +01:00
]
} ,
2013-10-31 03:01:36 +01:00
/* extensions and CodeMirror modes */
2013-10-30 04:09:01 +01:00
{
expand : true ,
dest : 'dist/' ,
cwd : 'src/' ,
2013-10-31 03:01:36 +01:00
src : [
2014-12-18 17:32:33 +01:00
'extensions/default/**/*' ,
2013-10-31 20:15:29 +01:00
'!extensions/default/*/unittest-files/**/*' ,
'!extensions/default/*/unittests.js' ,
2014-12-18 17:32:33 +01:00
'!extensions/default/{*/thirdparty,**/node_modules}/**/test/**/*' ,
'!extensions/default/{*/thirdparty,**/node_modules}/**/doc/**/*' ,
'!extensions/default/{*/thirdparty,**/node_modules}/**/examples/**/*' ,
'!extensions/default/*/thirdparty/**/*.htm{,l}' ,
2013-12-20 22:27:54 +01:00
'extensions/dev/*' ,
'extensions/samples/**/*' ,
2015-05-21 20:43:31 +02:00
'thirdparty/CodeMirror/addon/{,*/}*' ,
'thirdparty/CodeMirror/keymap/{,*/}*' ,
'thirdparty/CodeMirror/lib/{,*/}*' ,
'thirdparty/CodeMirror/mode/{,*/}*' ,
'!thirdparty/CodeMirror/mode/**/*.html' ,
'!thirdparty/CodeMirror/**/*test.js' ,
'thirdparty/CodeMirror/theme/{,*/}*' ,
2013-10-31 03:01:36 +01:00
'thirdparty/i18n/*.js' ,
2014-07-30 23:42:35 +02:00
'thirdparty/text/*.js'
2013-10-31 03:01:36 +01:00
]
2013-10-30 04:09:01 +01:00
} ,
2013-10-31 03:01:36 +01:00
/* styles, fonts and images */
2013-10-30 04:09:01 +01:00
{
expand : true ,
2013-10-31 03:01:36 +01:00
dest : 'dist/styles' ,
2013-10-30 04:09:01 +01:00
cwd : 'src/styles' ,
2013-11-15 22:24:18 +01:00
src : [ 'jsTreeTheme.css' , 'fonts/{,*/}*.*' , 'images/*' , 'brackets.min.css*' ]
2013-10-30 04:09:01 +01:00
}
]
}
} ,
2014-12-18 17:32:33 +01:00
cleanempty : {
options : {
force : true ,
files : false
} ,
src : [ 'dist/**/*' ] ,
} ,
2013-10-30 04:09:01 +01:00
less : {
2013-11-15 22:24:18 +01:00
dist : {
2013-10-30 04:09:01 +01:00
files : {
2013-11-15 22:24:18 +01:00
"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'
2013-10-30 04:09:01 +01:00
}
}
} ,
2013-10-31 03:01:36 +01:00
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' ,
2013-11-14 22:48:10 +01:00
optimize : 'uglify2' ,
2014-07-30 21:13:28 +02:00
// brackets.js should not be loaded until after polyfills defined in "utils/Compatibility"
2014-12-13 02:58:06 +01:00
// so explicitly include it in main.js
2014-07-30 23:42:35 +02:00
include : [ "utils/Compatibility" , "brackets" ] ,
2013-10-31 03:01:36 +01:00
// TODO: Figure out how to make sourcemaps work with grunt-usemin
// https://github.com/yeoman/grunt-usemin/issues/30
2013-11-14 22:48:10 +01:00
generateSourceMaps : true ,
useSourceUrl : true ,
2013-10-31 03:01:36 +01:00
// required to support SourceMaps
// http://requirejs.org/docs/errors.html#sourcemapcomments
2013-11-14 22:48:10 +01:00
preserveLicenseComments : false ,
2013-10-31 03:01:36 +01:00
useStrict : true ,
// Disable closure, we want define/require to be globals
2013-11-14 22:48:10 +01:00
wrap : false ,
2013-12-02 23:53:17 +01:00
exclude : [ "text!config.json" ] ,
2013-11-14 22:48:10 +01:00
uglify2 : { } // https://github.com/mishoo/UglifyJS2
2013-10-31 03:01:36 +01:00
}
}
} ,
2013-11-01 19:10:32 +01:00
targethtml : {
dist : {
files : {
'src/.index.html' : 'src/index.html'
}
}
} ,
2013-10-30 04:09:01 +01:00
useminPrepare : {
2013-10-31 03:01:36 +01:00
options : {
dest : 'dist'
} ,
2013-11-01 19:10:32 +01:00
html : 'src/.index.html'
2013-10-30 04:09:01 +01:00
} ,
usemin : {
options : {
2013-10-31 03:01:36 +01:00
dirs : [ 'dist' ]
} ,
2013-11-15 22:24:18 +01:00
html : [ 'dist/{,*/}*.html' ]
2013-10-31 03:01:36 +01:00
} ,
htmlmin : {
dist : {
options : {
/ * r e m o v e C o m m e n t s F r o m C D A T A : t r u e ,
// 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'
} ]
2013-10-30 04:09:01 +01:00
}
} ,
2013-01-24 19:45:28 +01:00
meta : {
src : [
'src/**/*.js' ,
'!src/thirdparty/**' ,
'!src/widgets/bootstrap-*.js' ,
'!src/extensions/**/unittest-files/**/*.js' ,
2013-02-15 20:52:18 +01:00
'!src/extensions/**/thirdparty/**/*.js' ,
2013-02-01 18:19:47 +01:00
'!src/extensions/dev/**' ,
'!src/extensions/disabled/**' ,
2013-03-12 20:26:21 +01:00
'!**/node_modules/**/*.js' ,
2013-01-24 19:45:28 +01:00
'!src/**/*-min.js' ,
'!src/**/*.min.js'
] ,
test : [
'test/**/*.js' ,
'!test/perf/*-files/**/*.js' ,
'!test/spec/*-files/**/*.js' ,
2014-06-19 01:56:17 +02:00
'!test/spec/*-known-goods/**/*.js' ,
'!test/spec/FindReplace-test-files-*/**/*.js' ,
2013-01-24 19:45:28 +01:00
'!test/smokes/**' ,
'!test/temp/**' ,
2013-03-22 00:15:30 +01:00
'!test/thirdparty/**' ,
'!test/**/node_modules/**/*.js'
2013-01-24 19:45:28 +01:00
] ,
2013-03-20 06:44:15 +01:00
grunt : [
'Gruntfile.js' ,
'tasks/**/*.js'
] ,
2013-01-24 19:45:28 +01:00
/* specs that can run in phantom.js */
specs : [
'test/spec/CommandManager-test.js' ,
2013-03-19 22:47:18 +01:00
//'test/spec/LanguageManager-test.js',
//'test/spec/PreferencesManager-test.js',
2013-01-24 19:45:28 +01:00
'test/spec/ViewUtils-test.js'
]
} ,
watch : {
2013-03-28 19:25:50 +01:00
all : {
files : [ '**/*' , '!**/node_modules/**' ] ,
2015-09-12 10:50:34 +02:00
tasks : [ 'eslint' ]
2013-03-28 19:25:50 +01:00
} ,
grunt : {
files : [ '<%= meta.grunt %>' , 'tasks/**/*' ] ,
2015-09-12 10:50:34 +02:00
tasks : [ 'eslint:grunt' ]
2013-03-28 19:25:50 +01:00
} ,
src : {
files : [ '<%= meta.src %>' , 'src/**/*' ] ,
2015-09-12 10:50:34 +02:00
tasks : [ 'eslint:src' ]
2013-03-28 19:25:50 +01:00
} ,
2013-01-24 19:45:28 +01:00
test : {
2013-03-28 19:25:50 +01:00
files : [ '<%= meta.test %>' , 'test/**/*' ] ,
2015-09-12 10:50:34 +02:00
tasks : [ 'eslint:test' ]
2013-01-24 19:45:28 +01:00
}
} ,
/* 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 %>' ,
2013-01-26 05:00:47 +01:00
/* Keep in sync with test/SpecRunner.html dependencies */
2013-01-24 19:45:28 +01:00
vendor : [
2014-05-28 21:02:27 +02:00
'test/polyfills.js' , /* 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 */
2015-02-04 15:47:42 +01:00
'src/thirdparty/jquery-2.1.3.min.js' ,
2015-05-21 20:43:31 +02:00
'src/thirdparty/CodeMirror/lib/codemirror.js' ,
'src/thirdparty/CodeMirror/lib/util/dialog.js' ,
'src/thirdparty/CodeMirror/lib/util/searchcursor.js' ,
'src/thirdparty/CodeMirror/addon/edit/closetag.js' ,
'src/thirdparty/CodeMirror/addon/selection/active-line.js' ,
2013-02-26 01:18:51 +01:00
'src/thirdparty/mustache/mustache.js' ,
2015-09-26 04:55:54 +02:00
'src/thirdparty/path-utils/path-utils.min' ,
2014-12-19 21:50:56 +01:00
'src/thirdparty/less-2.5.1.min.js'
2013-01-24 19:45:28 +01:00
] ,
2013-02-26 01:44:19 +01:00
helpers : [
'test/spec/PhantomHelper.js'
2013-01-24 19:45:28 +01:00
] ,
template : require ( 'grunt-template-jasmine-requirejs' ) ,
templateOptions : {
requireConfig : {
baseUrl : 'src' ,
paths : {
'test' : '../test' ,
'perf' : '../test/perf' ,
'spec' : '../test/spec' ,
2013-05-10 04:24:19 +02:00
'text' : 'thirdparty/text/text' ,
'i18n' : 'thirdparty/i18n/i18n'
2013-01-24 19:45:28 +01:00
}
}
}
}
} ,
2013-10-21 18:04:48 +02:00
'jasmine_node' : {
projectRoot : 'src/extensibility/node/spec/'
2013-05-16 19:48:29 +02:00
} ,
2015-09-12 10:50:34 +02:00
eslint : {
2013-03-28 19:25:50 +01:00
grunt : '<%= meta.grunt %>' ,
src : '<%= meta.src %>' ,
test : '<%= meta.test %>' ,
2013-01-24 19:45:28 +01:00
options : {
2015-12-11 23:02:47 +01:00
quiet : true
2013-01-24 19:45:28 +01:00
}
2013-03-20 06:44:15 +01:00
} ,
shell : {
repo : grunt . option ( "shell-repo" ) || "../brackets-shell" ,
mac : "<%= shell.repo %>/installer/mac/staging/<%= pkg.name %>.app" ,
2013-09-18 00:21:48 +02:00
win : "<%= shell.repo %>/installer/win/staging/<%= pkg.name %>.exe" ,
linux : "<%= shell.repo %>/installer/linux/debian/package-root/opt/brackets/brackets"
2013-01-24 19:45:28 +01:00
}
} ) ;
2014-12-13 02:58:06 +01:00
2013-01-24 19:45:28 +01:00
// task: install
2013-10-31 20:15:29 +01:00
grunt . registerTask ( 'install' , [ 'write-config' , 'less' ] ) ;
2013-01-24 19:45:28 +01:00
// task: test
2015-09-12 10:50:34 +02:00
grunt . registerTask ( 'test' , [ 'eslint' , 'jasmine' , 'nls-check' ] ) ;
// grunt.registerTask('test', ['eslint', 'jasmine', 'jasmine_node', 'nls-check']);
2013-01-24 19:45:28 +01:00
2014-08-07 01:31:40 +02:00
// task: set-release
// Update version number in package.json and rewrite src/config.json
grunt . registerTask ( 'set-release' , [ 'update-release-number' , 'write-config' ] ) ;
2013-02-21 20:54:56 +01:00
2013-11-15 01:41:51 +01:00
// task: build
grunt . registerTask ( 'build' , [
2015-09-12 10:50:34 +02:00
'eslint:src' ,
2013-12-02 23:53:17 +01:00
'jasmine' ,
2013-10-31 03:01:36 +01:00
'clean' ,
2013-11-01 19:10:32 +01:00
'less' ,
'targethtml' ,
2013-10-30 04:09:01 +01:00
'useminPrepare' ,
2013-10-31 03:01:36 +01:00
'htmlmin' ,
'requirejs' ,
'concat' ,
2013-11-15 22:24:18 +01:00
/*'cssmin',*/
2013-11-14 22:48:10 +01:00
/*'uglify',*/
2013-10-31 03:01:36 +01:00
'copy' ,
2014-12-18 17:32:33 +01:00
'cleanempty' ,
2013-12-02 23:53:17 +01:00
'usemin' ,
'build-config'
2013-10-30 04:09:01 +01:00
] ) ;
2013-11-15 01:41:51 +01:00
// Default task.
grunt . registerTask ( 'default' , [ 'test' ] ) ;
2013-02-01 18:19:47 +01:00
} ;