@@ -157,8 +157,9 @@ class Embark {
157157 } ) ;
158158 }
159159
160- build ( options , continueProcessing ) {
160+ build ( options ) {
161161 this . context = options . context || [ constants . contexts . build ] ;
162+
162163 let engine = new Engine ( {
163164 env : options . env ,
164165 version : this . version ,
@@ -202,9 +203,7 @@ class Embark {
202203 engine . logger . info ( "finished building" . underline ) ;
203204 }
204205 // needed due to child processes
205- if ( err || ! continueProcessing ) {
206- process . exit ( ) ;
207- }
206+ process . exit ( ) ;
208207 } ) ;
209208 }
210209
@@ -271,59 +270,81 @@ class Embark {
271270 }
272271
273272 upload ( platform , options ) {
274- this . context = options . context || [ constants . contexts . upload , constants . contexts . build ] ;
275273
276- // populate options that were instantiated with initConfig to pass around
277- options . buildDir = 'dist/' ;
278- options . storageConfig = this . config . storageConfig ;
279- options . events = this . events ;
280- options . logger = this . logger ;
281- options . config = this . config ;
282-
283- // load plugins
284- this . plugins . loadInternalPlugin ( 'ipfs' , options ) ;
285- this . plugins . loadInternalPlugin ( 'swarm' , options ) ;
274+ this . context = options . context || [ constants . contexts . upload , constants . contexts . build ] ;
286275
287- // upddate our options with loaded plugins
288- options . plugins = this . plugins ;
276+ let engine = new Engine ( {
277+ env : options . env ,
278+ version : this . version ,
279+ embarkConfig : 'embark.json' ,
280+ interceptLogs : false ,
281+ logFile : options . logFile ,
282+ logLevel : options . logLevel ,
283+ events : options . events ,
284+ logger : options . logger ,
285+ config : options . config ,
286+ plugins : options . plugins
287+ } ) ;
288+ engine . init ( ) ;
289289
290290 let cmdPlugin ;
291- let self = this ;
292291 async . waterfall ( [
292+
293+ function startServices ( callback ) {
294+
295+ engine . startService ( "libraryManager" ) ;
296+ engine . startService ( "web3" ) ;
297+ engine . startService ( "pipeline" ) ;
298+ engine . startService ( "codeGenerator" ) ;
299+ engine . startService ( "deployment" ) ;
300+ engine . startService ( "ipfs" ) ;
301+ engine . startService ( "swarm" , { buildDir :'dist/' , web3 : engine . web3 } ) ;
302+ callback ( ) ;
303+ } ,
293304 function setupStoragePlugin ( callback ) {
305+ let pluginList = engine . plugins . listPlugins ( ) ;
306+ if ( pluginList . length > 0 ) {
307+ engine . logger . info ( "loaded plugins: " + pluginList . join ( ", " ) ) ;
308+ }
309+
294310 // check use has input existing storage plugin
295- let cmdPlugins = self . plugins . getPluginsFor ( 'uploadCmds' ) ;
311+ let cmdPlugins = engine . plugins . getPluginsFor ( 'uploadCmds' ) ;
296312
297313 if ( cmdPlugins . length > 0 ) {
298314 cmdPlugin = cmdPlugins . find ( ( pluginCmd ) => {
299315 return pluginCmd . name == platform ;
300316 } ) ;
301317 }
302318 if ( ! cmdPlugin ) {
303- self . logger . info ( 'try "embark upload ipfs" or "embark upload swarm"' . green ) ;
319+ engine . logger . info ( 'try "embark upload ipfs" or "embark upload swarm"' . green ) ;
304320 callback ( { message : 'unknown platform: ' + platform } ) ;
305321 } else {
306322 callback ( ) ;
307323 }
308324 } ,
309- function buildAndDeployContracts ( callback ) {
325+ function deploy ( callback ) {
310326 // 2. upload to storage (outputDone event triggered after webpack finished)
311- self . events . on ( 'outputDone' , function ( ) {
327+ engine . events . on ( 'outputDone' , function ( ) {
312328 cmdPlugin . uploadCmds [ 0 ] . cb ( )
313329 . then ( ( success ) => {
314330 callback ( null , success ) ;
315331 } )
316332 . catch ( callback ) ;
317333 } ) ;
318334 // 1. build the contracts and dapp webpack
319- self . build ( options , true ) ;
335+ engine . deployManager . deployContracts ( function ( err ) {
336+ engine . logger . info ( "finished deploying" . underline ) ;
337+ if ( err ) {
338+ callback ( err ) ;
339+ }
340+ } ) ;
320341 }
321342 ] , function ( err , _result ) {
322343 if ( err ) {
323- self . logger . error ( err . message ) ;
324- self . logger . debug ( err . stack ) ;
344+ engine . logger . error ( err . message ) ;
345+ engine . logger . debug ( err . stack ) ;
325346 } else {
326- self . logger . info ( " finished building dapp and deploying to " + platform . underline ) ;
347+ engine . logger . info ( ` finished building DApp and deploying to ${ platform } ` . underline ) ;
327348 }
328349
329350 // needed due to child processes
0 commit comments