11module . exports = function ( grunt ) {
22 'use strict' ;
33
4- var _ = grunt . util . _ ;
5-
64 require ( 'load-grunt-tasks' ) ( grunt ) ;
75
86 // Default task.
97 grunt . registerTask ( 'default' , [ 'jshint' , 'karma:unit' ] ) ;
108 grunt . registerTask ( 'serve' , [ 'connect:continuous' , 'karma:continuous' , 'watch' ] ) ;
11- grunt . registerTask ( 'build-doc' , [ 'uglify' , 'copy' ] ) ;
9+ grunt . registerTask ( 'dist' , [ 'ngmin' , 'uglify' ] ) ;
10+
11+ // HACK TO ACCESS TO THE COMPONENT-PUBLISHER
12+ function fakeTargetTask ( prefix ) {
13+ return function ( ) {
14+
15+ if ( this . args . length !== 1 ) return grunt . log . fail ( 'Just give the name of the ' + prefix + ' you want like :\ngrunt ' + prefix + ':bower' ) ;
16+
17+ var done = this . async ( ) ;
18+ var spawn = require ( 'child_process' ) . spawn ;
19+ spawn ( './node_modules/.bin/gulp' , [ prefix , '--branch=' + this . args [ 0 ] ] . concat ( grunt . option . flags ( ) ) , {
20+ cwd : './node_modules/angular-ui-publisher' ,
21+ stdio : 'inherit'
22+ } ) . on ( 'close' , done ) ;
23+ } ;
24+ }
25+
26+ grunt . registerTask ( 'build' , fakeTargetTask ( 'build' ) ) ;
27+ grunt . registerTask ( 'publish' , fakeTargetTask ( 'publish' ) ) ;
28+ //
1229
1330 var testConfig = function ( configFile , customOptions ) {
1431 var options = { configFile : configFile , singleRun : true } ;
1532 var travisOptions = process . env . TRAVIS && { browsers : [ 'Firefox' , 'PhantomJS' ] , reporters : [ 'dots' ] } ;
1633 return grunt . util . _ . extend ( options , customOptions , travisOptions ) ;
1734 } ;
1835
19- var js_dependencies = [
20- '<%= bower %>/angular-ui-bootstrap-bower/ui-bootstrap-tpls.min.js' ,
21- '<%= bower %>/codemirror/lib/codemirror.js' ,
22- '<%= bower %>/codemirror/mode/scheme/scheme.js' ,
23- '<%= bower %>/codemirror/mode/javascript/javascript.js' ,
24- '<%= bower %>/codemirror/mode/xml/xml.js' ,
25- ] ;
26-
27- var css_dependencies = [
28- '<%= bower %>/codemirror/lib/codemirror.css' ,
29- '<%= bower %>/codemirror/theme/twilight.css'
30- ] ;
31-
3236 // Project configuration.
3337 grunt . initConfig ( {
3438 bower : 'bower_components' ,
@@ -41,26 +45,24 @@ module.exports = function (grunt) {
4145 ' * @link <%= pkg.homepage %>' ,
4246 ' * @license <%= pkg.license %>' ,
4347 ' */' ,
44- '' ] . join ( '\n' ) ,
45- view : {
46- humaName : 'UI CodeMirror' ,
47- repoName : 'ui-codemirror' ,
48- demoHTML : grunt . file . read ( 'demo/demo.html' ) ,
49- demoJS : grunt . file . read ( 'demo/demo.js' ) ,
50- css : css_dependencies . concat ( [ 'assets/css/demo.css' ] ) ,
51- js : js_dependencies . concat ( [ 'build/ui-codemirror.min.js' ] )
52- }
48+ '' ] . join ( '\n' )
5349 } ,
50+
5451 watch : {
52+ src : {
53+ files : [ 'src/*' ] ,
54+ tasks : [ 'jshint:src' , 'karma:unit:run' , 'dist' , 'build:gh-pages' ]
55+ } ,
5556 test : {
56- files : [ '<%= meta.view.repoName %>.js' , ' test/*.js'] ,
57- tasks : [ 'jshint' , 'karma:unit:run' ]
57+ files : [ 'test/*.js' ] ,
58+ tasks : [ 'jshint:test ' , 'karma:unit:run' ]
5859 } ,
5960 demo : {
60- files : [ 'demo/*' , '<%= meta.view.repoName %> .js' ] ,
61- tasks : [ 'uglify ' , 'copy ' ]
61+ files : [ 'demo/*' , 'publish .js' ] ,
62+ tasks : [ 'jshint ' , 'build:gh-pages ' ]
6263 }
6364 } ,
65+
6466 karma : {
6567 unit : testConfig ( 'test/karma.conf.js' ) ,
6668 server : { configFile : 'test/karma.conf.js' } ,
@@ -69,58 +71,66 @@ module.exports = function (grunt) {
6971
7072 connect : {
7173 options : {
72- base : '<%= dist %> ' ,
74+ base : 'out/built/gh-pages ' ,
7375 port : grunt . option ( 'port' ) || '8000' ,
7476 hostname : grunt . option ( 'host' ) || 'localhost' ,
75- open : true
77+ open : 'http://<%= connect.options.hostname %>:<%= connect.options.port %>' ,
78+ livereload : grunt . option ( 'port' ) || '8000'
7679 } ,
7780 server : { options : { keepalive : true } } ,
7881 continuous : { options : { keepalive : false } }
7982 } ,
8083
81- jshint :{
82- all :[ '<%= meta.view.repoName %>.js' , 'gruntFile.js' , 'test/*.js' , 'demo/*.js' ] ,
83- options :{
84- curly :true ,
85- eqeqeq :true ,
86- immed :true ,
87- latedef :true ,
88- newcap :true ,
89- noarg :true ,
90- sub :true ,
91- boss :true ,
92- eqnull :true ,
93- globals :{ }
84+ jshint : {
85+ src : {
86+ files :{ src : [ 'src/*.js' , 'demo/**/*.js' ] } ,
87+ options : { jshintrc : '.jshintrc' }
88+ } ,
89+ test : {
90+ files :{ src : [ 'test/*.spec.js' , 'publish.js' , 'gruntFile.js' ] } ,
91+ options : grunt . util . _ . extend ( { } , grunt . file . readJSON ( '.jshintrc' ) , {
92+ node : true ,
93+ globals : {
94+ angular : false ,
95+ inject : false ,
96+ jQuery : false ,
97+
98+ jasmine : false ,
99+ afterEach : false ,
100+ beforeEach : false ,
101+ ddescribe : false ,
102+ describe : false ,
103+ expect : false ,
104+ iit : false ,
105+ it : false ,
106+ spyOn : false ,
107+ xdescribe : false ,
108+ xit : false
109+ }
110+ } )
94111 }
95112 } ,
113+
96114 uglify : {
97115 options : { banner : '<%= meta.banner %>' } ,
98116 build : {
99- files : {
100- '<%= dist %>/build/<%= meta.view.repoName %>.min.js' : [ '<%= meta.view.repoName %>.js' ]
101- }
117+ expand : true ,
118+ cwd : 'dist' ,
119+ src : [ '*.js' ] ,
120+ ext : '.min.js' ,
121+ dest : 'dist'
102122 }
103123 } ,
104- copy : {
124+
125+ ngmin : {
105126 main : {
106- files : [
107- { src : [ '<%= meta.view.repoName %>.js' ] , dest : '<%= dist %>/build/<%= meta.view.repoName %>.js' , filter : 'isFile' }
108- ]
109- } ,
110- template : {
111- options : { processContent : function ( content ) {
112- return grunt . template . process ( content ) ;
113- } } ,
114- files : [
115- { src : [ '<%= dist %>/.tmpl/index.tmpl' ] , dest : '<%= dist %>/index.html' } ,
116- { src : [ 'demo/demo.css' ] , dest : '<%= dist %>/assets/css/demo.css' }
117- ]
118- . concat (
119- _ . map ( js_dependencies . concat ( css_dependencies ) , function ( f ) {
120- return { src : [ f ] , dest : '<%= dist %>/' + f , filter : 'isFile' } ;
121- } ) )
127+ expand : true ,
128+ cwd : 'src' ,
129+ src : [ '*.js' ] ,
130+ dest : 'dist'
122131 }
123132 } ,
133+
124134 changelog : {
125135 options : {
126136 dest : 'CHANGELOG.md'
0 commit comments