@@ -24,15 +24,11 @@ const reactiumConfig = require('./reactium-config');
2424const regenManifest = require ( './manifest/manifest-tools' ) ;
2525const umdWebpackGenerator = require ( './umd.webpack.config' ) ;
2626const rootPath = path . resolve ( __dirname , '..' ) ;
27- const { fork, spawn } = require ( 'child_process' ) ;
27+ const { fork, spawn, execSync } = require ( 'child_process' ) ;
2828const workbox = require ( 'workbox-build' ) ;
2929const { File, FileReader } = require ( 'file-api' ) ;
3030const handlebars = require ( 'handlebars' ) ;
31- const timestamp = ( ) => {
32- const now = new Date ( ) ;
33- const ts = now . getHours ( ) + ':' + now . getMinutes ( ) + ':' + now . getSeconds ( ) ;
34- return `[${ chalk . blue ( ts ) } ]` ;
35- } ;
31+ const { resolve } = require ( 'path' ) ;
3632
3733// For backward compatibility with gulp override tasks using run-sequence module
3834// make compatible with gulp4
@@ -105,12 +101,10 @@ const reactium = (gulp, config, webpackConfig) => {
105101
106102 fs . createReadStream ( e . path )
107103 . pipe ( fs . createWriteStream ( fpath ) )
108- . on ( 'error' , error => console . error ( timestamp ( ) , error ) ) ;
104+ . on ( 'error' , error => console . error ( error ) ) ;
109105 }
110106
111- console . log (
112- `${ timestamp ( ) } File ${ e . event } : ${ displaySrc } -> ${ displayDest } ` ,
113- ) ;
107+ console . log ( `File ${ e . event } : ${ displaySrc } -> ${ displayDest } ` ) ;
114108 } ;
115109
116110 const serve = ( { open } = { open : config . open } ) => done => {
@@ -120,8 +114,7 @@ const reactium = (gulp, config, webpackConfig) => {
120114 . then ( ( ) => {
121115 browserSync ( {
122116 notify : false ,
123- timestamps : true ,
124- logPrefix : '00:00:00' ,
117+ timestamps : false ,
125118 port : config . port . browsersync ,
126119 ui : { port : config . port . browsersync + 1 } ,
127120 proxy,
@@ -144,12 +137,12 @@ const reactium = (gulp, config, webpackConfig) => {
144137 watchProcess . on ( 'message' , message => {
145138 switch ( message ) {
146139 case 'build-started' : {
147- console . log ( timestamp ( ) + " Starting 'build'...") ;
140+ console . log ( " Starting 'build'...") ;
148141 done ( ) ;
149142 return ;
150143 }
151144 case 'restart-watches' : {
152- console . log ( timestamp ( ) + " Restarting 'watch'...") ;
145+ console . log ( " Restarting 'watch'...") ;
153146 watchProcess . kill ( ) ;
154147 watch ( _ => _ , true ) ;
155148 return ;
@@ -166,12 +159,14 @@ const reactium = (gulp, config, webpackConfig) => {
166159 ) => {
167160 const ps = spawn ( cmd , args , { stdio : [ stdin , stdout , stderr ] } ) ;
168161 ps . on ( 'close' , code => {
169- if ( code !== 0 ) console . log ( timestamp ( ) + `Error executing ${ cmd } ` ) ;
162+ if ( code !== 0 ) console . log ( `Error executing ${ cmd } ` ) ;
170163 done ( ) ;
171164 } ) ;
165+
166+ return ps ;
172167 } ;
173168
174- const local = ( { ssr = false } = { } ) => done => {
169+ const local = ( { ssr = false } = { } ) => async done => {
175170 const SSR_MODE = ssr ? 'on' : 'off' ;
176171 const crossEnvModulePath = path . resolve (
177172 path . dirname ( require . resolve ( 'cross-env' ) ) ,
@@ -186,17 +181,7 @@ const reactium = (gulp, config, webpackConfig) => {
186181 crossEnvPackage . bin [ 'cross-env' ] ,
187182 ) ;
188183
189- // warnings here
190- // TODO: convert to useHookComponent
191- if ( ! fs . existsSync ( rootPath , 'src/app/components/Fallback/index.js' ) ) {
192- console . log ( '' ) ;
193- console . log (
194- chalk . magenta (
195- 'Create a `src/app/components/Fallback` component with default export to support lazy loaded components and remove the webpack warning you see below.' ,
196- ) ,
197- ) ;
198- console . log ( '' ) ;
199- }
184+ await gulp . task ( 'mainManifest' ) ( ( ) => Promise . resolve ( ) ) ;
200185
201186 command (
202187 'node' ,
@@ -318,6 +303,7 @@ const reactium = (gulp, config, webpackConfig) => {
318303 ) ,
319304 manifestProcessor : require ( './manifest/processors/manifest' ) ,
320305 } ) ;
306+
321307 done ( ) ;
322308 } ;
323309
@@ -395,9 +381,7 @@ const reactium = (gulp, config, webpackConfig) => {
395381
396382 for ( let umd of umdConfigs ) {
397383 try {
398- console . log (
399- timestamp ( ) + ` Generating UMD library ${ umd . libraryName } ` ,
400- ) ;
384+ console . log ( `Generating UMD library ${ umd . libraryName } ` ) ;
401385 await new Promise ( ( resolve , reject ) => {
402386 webpack ( umdWebpackGenerator ( umd ) , ( err , stats ) => {
403387 if ( err ) {
@@ -433,7 +417,7 @@ const reactium = (gulp, config, webpackConfig) => {
433417 } ;
434418
435419 if ( ! fs . existsSync ( config . umd . defaultWorker ) ) {
436- console . info ( timestamp ( ) + ' Skipping service worker generation.') ;
420+ console . log ( ' Skipping service worker generation.') ;
437421 return Promise . resolve ( ) ;
438422 }
439423
@@ -448,15 +432,10 @@ const reactium = (gulp, config, webpackConfig) => {
448432 for ( const warning of warnings ) {
449433 console . warn ( warning ) ;
450434 }
451- console . info (
452- timestamp ( ) + ' Service worker generation completed.' ,
453- ) ;
435+ console . log ( 'Service worker generation completed.' ) ;
454436 } )
455437 . catch ( error => {
456- console . warn (
457- timestamp ( ) + ' Service worker generation failed:' ,
458- error ,
459- ) ;
438+ console . warn ( 'Service worker generation failed:' , error ) ;
460439 } ) ;
461440 } ;
462441
0 commit comments