@@ -19,72 +19,102 @@ var notify = require('./tasks/notify');
1919var pkg = require ( './package.json' ) ;
2020
2121// Platform specific tasks
22- require ( path . join ( __dirname , 'tasks' , process . platform ) ) . tasks ( gulp ) ;
22+ var platform = require ( path . join ( __dirname , 'tasks' , process . platform ) ) ;
23+ gulp . task ( 'build:electron' , platform . build ) ;
24+ gulp . task ( 'build:electron-installer' , [ 'build:electron' ] , platform . installer ) ;
25+
26+ // @todo : debugging...
27+ var tar = require ( 'gulp-tar' ) ;
28+ var gzip = require ( 'gulp-gzip' ) ;
29+
30+ gulp . task ( 'package:electron' , function ( ) {
31+ return gulp . src ( [ 'dist/MongoDB\ Enterprise\ Scout-darwin-x64/*' , 'dist/MongoDB\ Enterprise\ Scout-darwin-x64/**/*' ] )
32+ . pipe ( tar ( 'MongoDB Enterprise Scout-v0.2.0.tar' ) )
33+ . pipe ( gzip ( ) )
34+ . pipe ( gulp . dest ( 'dist/' ) ) ;
35+ } ) ;
36+
37+ var BUILD = 'build/' ;
2338
2439// `npm start` calls this.
25- gulp . task ( 'default' , [ 'build' , 'start electron' , 'watch' ] ) ;
26-
27- var spinner = new clui . Spinner ( 'Watching for changes...' ) ;
28-
29- /**
30- * Gulp's [fast browserify builds recipe](http://git.io/iiCk-A)
31- */
32- var bundler = watchify ( browserify ( './src/index.js' , {
33- cache : { } ,
34- packageCache : { } ,
35- fullPaths : true ,
36- debug : false
37- } ) )
38- . transform ( 'jadeify' )
39- . on ( 'update' , rebundle ) ;
40-
41- function rebundle ( changed ) {
42- var start = process . hrtime ( ) ;
43- if ( changed ) {
44- spinner . stop ( ) ;
45- gutil . log ( 'Changed' , '\'' + gutil . colors . cyan ( changed [ 1 ] ) + '\'' ) ;
46- gutil . log ( 'Starting' , '\'' + gutil . colors . cyan ( 'rebundle' ) + '\'...' ) ;
47- }
48- return bundler . bundle ( )
49- . on ( 'error' , notify ( 'js' ) )
50- . pipe ( source ( 'index.js' ) )
51- . pipe ( gulp . dest ( 'build/' ) )
52- . on ( 'end' , function ( ) {
53- var time = prettyTime ( process . hrtime ( start ) ) ;
54- gutil . log ( 'Finished' , '\'' + gutil . colors . cyan ( 'rebundle' ) + '\'' ,
55- 'after' , gutil . colors . magenta ( time ) ) ;
56- if ( changed ) {
57- spinner . start ( ) ;
58- }
59- } ) ;
60- }
61-
62- gulp . task ( 'build' , [
63- 'pages' ,
64- 'less' ,
65- 'js' ,
66- 'copy'
67- ] ) ;
40+ gulp . task ( 'start' , [ 'build:app' , 'build:electron' , 'hack:app' ] , function ( ) {
41+ platform . start ( ) ;
42+ return gulp . start ( 'watch' ) ;
43+ } ) ;
44+ gulp . task ( 'hack:app' , function ( ) {
45+ return del ( platform . BUILD ) ;
46+ } ) ;
47+
48+ gulp . task ( 'build:release' , function ( ) {
49+ BUILD = platform . BUILD ;
50+ return gulp . start ( 'build:app-release' ) ;
51+ } ) ;
6852
69- gulp . task ( 'js' , function ( cb ) {
70- bundler . bundle ( )
53+ gulp . task ( 'build:app' , [ 'pages' , 'less' , 'js' , 'copy' , 'build:npm-install' ] , function ( ) { } ) ;
54+ gulp . task ( 'build:app-release' , [ 'pages' , 'less' , 'js' , 'copy' , 'build:npm-install-release' ] , function ( ) {
55+ return gulp . start ( 'build:electron-installer' ) ;
56+ } ) ;
57+
58+ // @todo : sourcemaps https://github.com/gulpjs/gulp/blob/master/docs/recipes/fast-browserify-builds-with-watchify.md
59+ gulp . task ( 'js' , function ( ) {
60+ return browserify ( './src/index.js' , {
61+ cache : { } ,
62+ packageCache : { } ,
63+ fullPaths : true ,
64+ debug : false
65+ } )
66+ . transform ( 'jadeify' )
67+ . bundle ( )
7168 . on ( 'error' , notify ( 'js' ) )
72- . on ( 'error' , cb )
7369 . pipe ( source ( 'index.js' ) )
74- . pipe ( gulp . dest ( 'build/' ) )
75- . on ( 'end' , cb ) ;
70+ . pipe ( gulp . dest ( BUILD ) ) ;
7671} ) ;
7772
78- gulp . task ( 'watch' , function ( ) {
73+ gulp . task ( 'watch' , [ 'build:app' ] , function ( ) {
7974 gulp . watch ( [ 'src/{*,**/*}.less' , 'styles/*.less' ] , [ 'less' ] ) ;
8075 gulp . watch ( [ 'src/*.jade' ] , [ 'pages' ] ) ;
8176 gulp . watch ( 'images/{*,**/*}' , [ 'copy images' ] ) ;
8277 gulp . watch ( 'fonts/*' , [ 'copy fonts' ] ) ;
83- gulp . watch ( [ 'main.js' , 'src/electron/*' ] , [ 'copy app electron files' ] ) ;
84- gulp . watch ( 'package.json' , [ 'install build' ] ) ;
85-
86- gulp . watch ( 'build/*.js' , [ 'copy build files to electron' ] ) ;
87- return rebundle ( true ) ;
78+ gulp . watch ( [ 'main.js' , 'src/electron/*' ] , [ 'copy:electron' ] ) ;
79+ gulp . watch ( 'package.json' , [ 'copy:electron' , 'build:npm-install' ] ) ;
80+
81+ var spinner = new clui . Spinner ( 'Watching for changes...' ) ;
82+
83+ /**
84+ * Gulp's [fast browserify builds recipe](http://git.io/iiCk-A)
85+ */
86+ var bundler = watchify ( browserify ( './src/index.js' , {
87+ cache : { } ,
88+ packageCache : { } ,
89+ fullPaths : true ,
90+ debug : false
91+ } ) )
92+ . transform ( 'jadeify' )
93+ . on ( 'update' , rebundle ) ;
94+ var started = false ;
95+
96+ function rebundle ( changed ) {
97+ var start = process . hrtime ( ) ;
98+ if ( changed ) {
99+ spinner . stop ( ) ;
100+ gutil . log ( 'Changed' , '\'' + gutil . colors . cyan ( changed [ 1 ] ) + '\'' ) ;
101+ gutil . log ( 'Starting' , '\'' + gutil . colors . cyan ( 'rebundle' ) + '\'...' ) ;
102+ }
103+ return bundler . bundle ( )
104+ . on ( 'error' , notify ( 'js' ) )
105+ . pipe ( source ( 'index.js' ) )
106+ . pipe ( gulp . dest ( BUILD ) )
107+ . on ( 'end' , function ( ) {
108+ var time = prettyTime ( process . hrtime ( start ) ) ;
109+ gutil . log ( 'Finished' , '\'' + gutil . colors . cyan ( 'rebundle' ) + '\'' ,
110+ 'after' , gutil . colors . magenta ( time ) ) ;
111+ spinner . start ( ) ;
112+ if ( ! started ) {
113+ started = true ;
114+ }
115+ } ) ;
116+ }
117+ return rebundle ( ) ;
88118} ) ;
89119
90120// Compile LESS to CSS.
@@ -94,50 +124,49 @@ gulp.task('less', function() {
94124 . pipe ( less ( pkg . less ) )
95125 . on ( 'error' , notify ( 'less' ) )
96126 . pipe ( sourcemaps . write ( './maps' ) )
97- . pipe ( gulp . dest ( 'build' ) ) ;
127+ . pipe ( gulp . dest ( BUILD ) ) ;
98128} ) ;
99129
100130// Compile jade templates to HTML files.
101131gulp . task ( 'pages' , function ( ) {
102132 return gulp . src ( 'src/index.jade' )
103133 . pipe ( jade ( ) )
104134 . on ( 'error' , notify ( 'jade' ) )
105- . pipe ( gulp . dest ( 'build' ) ) ;
135+ . pipe ( gulp . dest ( BUILD ) ) ;
106136} ) ;
107137
108- // Things that should be copied into `build/ `.
138+ // Things that should be copied into `BUILD `.
109139gulp . task ( 'copy' , [
110- 'copy fonts' ,
111- 'copy images' ,
112- 'copy app electron files '
140+ 'copy: fonts' ,
141+ 'copy: images' ,
142+ 'copy: electron'
113143] ) ;
114144
115- gulp . task ( 'copy fonts' , function ( ) {
145+ gulp . task ( 'copy: fonts' , function ( ) {
116146 return gulp . src ( pkg . fonts )
117- . pipe ( gulp . dest ( 'build/ fonts') ) ;
147+ . pipe ( gulp . dest ( path . join ( BUILD , ' fonts') ) ) ;
118148} ) ;
119149
120- gulp . task ( 'copy fonts' , function ( ) {
121- return gulp . src ( pkg . fonts )
122- . pipe ( gulp . dest ( 'build/fonts' ) ) ;
123- } ) ;
124-
125- gulp . task ( 'copy images' , function ( ) {
150+ gulp . task ( 'copy:images' , function ( ) {
126151 return gulp . src ( 'images/{*,**/*}' )
127- . pipe ( gulp . dest ( 'build/ images') ) ;
152+ . pipe ( gulp . dest ( path . join ( BUILD , ' images') ) ) ;
128153} ) ;
129154
130- gulp . task ( 'copy app electron files ' , function ( ) {
155+ gulp . task ( 'copy: electron' , function ( ) {
131156 return merge (
132- gulp . src ( [ 'main.js' , 'package.json' ] ) . pipe ( gulp . dest ( 'build/' ) ) ,
133- gulp . src ( [ 'src/electron/*' ] ) . pipe ( gulp . dest ( 'build/ src/electron') )
157+ gulp . src ( [ 'main.js' , 'package.json' ] ) . pipe ( gulp . dest ( BUILD ) ) ,
158+ gulp . src ( [ 'src/electron/*' ] ) . pipe ( gulp . dest ( path . join ( BUILD , ' src/electron') ) )
134159 ) ;
135160} ) ;
136161
137- gulp . task ( 'install build' , [ 'copy' ] , shell . task ( 'npm install' , {
138- cwd : 'build'
162+ gulp . task ( 'build:npm-install' , [ 'copy:electron' ] , shell . task ( 'npm install' , {
163+ cwd : BUILD
164+ } ) ) ;
165+
166+ gulp . task ( 'build:npm-install-release' , [ 'copy:electron' ] , shell . task ( 'npm install --production' , {
167+ cwd : platform . BUILD
139168} ) ) ;
140169
141170gulp . task ( 'clean' , function ( done ) {
142- del ( [ 'dist/' , 'build/' , ' node_modules/'] , done ) ;
171+ del ( [ 'dist/' , 'node_modules/' ] , done ) ;
143172} ) ;
0 commit comments