@@ -256,20 +256,6 @@ class Embark {
256256 }
257257
258258 upload ( platform , options ) {
259-
260- // populate options that were instantiated with initConfig to pass around
261- options . buildDir = 'dist/' ;
262- options . storageConfig = this . config . storageConfig ;
263- options . events = this . events ;
264- options . logger = this . logger ;
265- options . config = this . config ;
266-
267- // load plugins
268- this . plugins . loadInternalPlugin ( 'ipfs' , options ) ;
269- this . plugins . loadInternalPlugin ( 'swarm' , options ) ;
270-
271- // upddate our options with loaded plugins
272- options . plugins = this . plugins ;
273259
274260 let engine = new Engine ( {
275261 env : options . env ,
@@ -286,61 +272,63 @@ class Embark {
286272 engine . init ( ) ;
287273
288274 let cmdPlugin ;
289- let self = this ;
290275 async . waterfall ( [
276+
277+ function startServices ( callback ) {
278+
279+ engine . startService ( "libraryManager" ) ;
280+ engine . startService ( "web3" ) ;
281+ engine . startService ( "pipeline" ) ;
282+ engine . startService ( "codeGenerator" ) ;
283+ engine . startService ( "deployment" ) ;
284+ engine . startService ( "ipfs" ) ;
285+ engine . startService ( "swarm" , { buildDir :'dist/' , web3 : engine . web3 } ) ;
286+ callback ( ) ;
287+ } ,
291288 function setupStoragePlugin ( callback ) {
289+ let pluginList = engine . plugins . listPlugins ( ) ;
290+ if ( pluginList . length > 0 ) {
291+ engine . logger . info ( "loaded plugins: " + pluginList . join ( ", " ) ) ;
292+ }
293+
292294 // check use has input existing storage plugin
293- let cmdPlugins = self . plugins . getPluginsFor ( 'uploadCmds' ) ;
295+ let cmdPlugins = engine . plugins . getPluginsFor ( 'uploadCmds' ) ;
294296
295297 if ( cmdPlugins . length > 0 ) {
296298 cmdPlugin = cmdPlugins . find ( ( pluginCmd ) => {
297299 return pluginCmd . name == platform ;
298300 } ) ;
299301 }
300302 if ( ! cmdPlugin ) {
301- self . logger . info ( 'try "embark upload ipfs" or "embark upload swarm"' . green ) ;
303+ engine . logger . info ( 'try "embark upload ipfs" or "embark upload swarm"' . green ) ;
302304 callback ( { message : 'unknown platform: ' + platform } ) ;
303305 } else {
304306 callback ( ) ;
305307 }
306308 } ,
307- function startServices ( callback ) {
308- let pluginList = engine . plugins . listPlugins ( ) ;
309- if ( pluginList . length > 0 ) {
310- engine . logger . info ( "loaded plugins: " + pluginList . join ( ", " ) ) ;
311- }
312-
313- engine . startService ( "libraryManager" ) ;
314- engine . startService ( "web3" ) ;
315- engine . startService ( "pipeline" ) ;
316- engine . startService ( "codeGenerator" ) ;
317- engine . startService ( "deployment" ) ;
318- engine . startService ( "ipfs" ) ;
319- callback ( ) ;
320- } ,
321309 function deploy ( callback ) {
322310 // 2. upload to storage (outputDone event triggered after webpack finished)
323- self . events . on ( 'outputDone' , function ( ) {
324- cmdPlugin . uploadCmds [ 0 ] . cb ( { web3 : engine . web3 } )
311+ engine . events . on ( 'outputDone' , function ( ) {
312+ cmdPlugin . uploadCmds [ 0 ] . cb ( )
325313 . then ( ( success ) => {
326314 callback ( null , success ) ;
327315 } )
328316 . catch ( callback ) ;
329317 } ) ;
330318 // 1. build the contracts and dapp webpack
331319 engine . deployManager . deployContracts ( function ( err ) {
332- engine . logger . info ( "finished building " . underline ) ;
320+ engine . logger . info ( "finished deploying " . underline ) ;
333321 if ( err ) {
334322 callback ( err ) ;
335323 }
336324 } ) ;
337325 }
338326 ] , function ( err , _result ) {
339327 if ( err ) {
340- self . logger . error ( err . message ) ;
341- self . logger . debug ( err . stack ) ;
328+ engine . logger . error ( err . message ) ;
329+ engine . logger . debug ( err . stack ) ;
342330 } else {
343- self . logger . info ( " finished building dapp and deploying to " + platform . underline ) ;
331+ engine . logger . info ( ` finished building DApp and deploying to ${ platform } ` . underline ) ;
344332 }
345333
346334 // needed due to child processes
0 commit comments