@@ -176,10 +176,48 @@ function runWithGulp(argv, taskInstance){
176176 } ) ;
177177 }
178178
179+ //No gulpfile
179180 if ( / s e r v e | b u i l d | r u n | e m u l a t e | u p l o a d / . test ( cmdName ) && argv . v2 ) {
180181 console . warn ( 'WARN: No gulpfile found!' ) ;
181182 console . warn ( 'If your app requires a build step, you may want to ensure it runs before ' + cmdName + '.\n' ) ;
183+
184+ if ( fs . existsSync ( 'ionic.config.js' ) ) {
185+ var inquirer = require ( 'inquirer' ) ;
186+ var deferred = Q . defer ( ) ;
187+
188+ console . info ( 'Looks like you are using the deprecated ionic.config.js and have no gulpfile!' ) ;
189+ console . info ( 'As of beta.21 the Ionic CLI relies on gulp hooks to build your web assets\n' ) ;
190+ inquirer . prompt ( [ {
191+ type : 'confirm' ,
192+ name : 'downloadGulp' ,
193+ message : 'Would you like to download the default gulpfile?' . cyan ,
194+ } ] ,
195+ function ( answers ) {
196+ answers . downloadGulp ? deferred . resolve ( ) : deferred . reject ( ) ;
197+ } ) ;
198+ var downloadGulp = false ;
199+ return deferred . promise . then (
200+ function ( ) {
201+ downloadGulp = true ;
202+ return downloadDefaultGulpfile ( ) ;
203+ } ,
204+ function ( ) {
205+ return Q . fcall ( taskInstance . run . bind ( taskInstance ) , Cli , argv ) ;
206+ }
207+ ) . then (
208+ function ( ) {
209+ if ( downloadGulp ) {
210+ console . success ( 'Successfully downloaded gulpfile. Try running \'' + cmdName + '\' again.' ) ;
211+ }
212+ } ,
213+ function ( err ) {
214+ console . error ( 'There was an error downloading the default gulpfile: ' + err ) ;
215+ process . exit ( 1 ) ;
216+ }
217+ ) ;
218+ }
182219 }
220+
183221 return Q . fcall ( taskInstance . run . bind ( taskInstance ) , Cli , argv ) ;
184222}
185223
@@ -207,6 +245,34 @@ function loadGulpfile(){
207245 return false ;
208246}
209247
248+ function downloadDefaultGulpfile ( ) {
249+ var https = require ( 'https' ) ;
250+ var fileStream = fs . createWriteStream ( 'gulpfile.js' ) ;
251+ var deferred = Q . defer ( ) ;
252+ var project = IonicProject . load ( ) ;
253+ var branch = project . get ( 'typescript' ) ? 'typescript' : 'master' ;
254+ var url = 'https://cdn.rawgit.com/driftyco/ionic2-app-base/' + branch + '/gulpfile.js' ;
255+
256+ console . info ( ( 'Downloading default gulpfile from: ' + url ) ) ;
257+
258+ fileStream . on ( 'open' , function ( ) {
259+ https . get ( url , function ( res ) {
260+ res . on ( 'error' , function ( err ) {
261+ deferred . reject ( err ) ;
262+ } ) ;
263+
264+ res . pipe ( fileStream ) ;
265+ } ) ;
266+ } ) . on ( 'error' , function ( err ) {
267+ deferred . reject ( err ) ;
268+ } ) . on ( 'finish' , function ( ) {
269+ deferred . resolve ( ) ;
270+ } ) ;
271+
272+ return deferred . promise ;
273+ }
274+
275+
210276function logEvents ( gulpInst , finalTaskNames ) {
211277 gulpInst . on ( 'task_start' , function ( e ) {
212278 // TODO: batch these
0 commit comments