11var fs = require ( './fs.js' ) ;
2+ var File = require ( './file.js' ) ;
23var Plugins = require ( './plugins.js' ) ;
34var utils = require ( '../utils/utils.js' ) ;
45var npm = require ( '../pipeline/npm.js' ) ;
@@ -45,9 +46,9 @@ Config.prototype.loadConfigFiles = function(options) {
4546 this . loadStorageConfigFile ( ) ;
4647 this . loadCommunicationConfigFile ( ) ;
4748
49+ this . loadContractsConfigFile ( ) ;
4850 this . loadPipelineConfigFile ( ) ;
4951
50- this . loadContractsConfigFile ( ) ;
5152 this . loadWebServerConfigFile ( ) ;
5253 this . loadChainTrackerFile ( ) ;
5354 this . loadPluginContractFiles ( ) ;
@@ -58,8 +59,8 @@ Config.prototype.reloadConfig = function() {
5859 this . loadBlockchainConfigFile ( ) ;
5960 this . loadStorageConfigFile ( ) ;
6061 this . loadCommunicationConfigFile ( ) ;
61- this . loadPipelineConfigFile ( ) ;
6262 this . loadContractsConfigFile ( ) ;
63+ this . loadPipelineConfigFile ( ) ;
6364 this . loadChainTrackerFile ( ) ;
6465} ;
6566
@@ -234,34 +235,38 @@ Config.prototype.loadFiles = function(files) {
234235 if ( file === 'embark.js' ) {
235236
236237 if ( self . blockchainConfig . enabled || self . communicationConfig . provider === 'whisper' || self . communicationConfig . available_providers . indexOf ( 'whisper' ) >= 0 ) {
237- readFiles . push ( { filename : 'web3.js' , content : fs . readFileSync ( fs . embarkPath ( "js/web3.js" ) ) . toString ( ) , path : fs . embarkPath ( "js/web3.js" ) } ) ;
238+ let web3Version = self . contractsConfig . versions [ "web3.js" ] ;
239+ if ( web3Version ) {
240+ //if (false) {
241+ //readFiles.push(new File({filename: 'web3-' + web3Version + '.js', type: 'custom', resolver: function(callback) {
242+ readFiles . push ( new File ( { filename : 'web3.js' , type : 'custom' , resolver : function ( callback ) {
243+ npm . getPackageVersion ( 'web3' , web3Version , 'dist/web3.js' , function ( web3Content ) {
244+ callback ( web3Content ) ;
245+ } ) ;
246+ } } ) ) ;
247+ } else {
248+ readFiles . push ( new File ( { filename : 'web3.js' , type : 'embark_internal' , path : "js/web3.js" } ) ) ;
249+ }
238250 }
239251
240252 if ( self . storageConfig . enabled && ( self . storageConfig . provider === 'ipfs' || self . storageConfig . available_providers . indexOf ( 'ipfs' ) >= 0 ) ) {
241- readFiles . push ( { filename : 'ipfs.js' , content : fs . readFileSync ( fs . embarkPath ( "js/ipfs.js" ) ) . toString ( ) , path : fs . embarkPath ( "js/ipfs.js" ) } ) ;
253+ readFiles . push ( new File ( { filename : 'ipfs.js' , type : 'embark_internal' , path : "js/ipfs.js" } ) ) ;
242254 }
243255
244256 if ( self . communicationConfig . enabled && ( self . communicationConfig . provider === 'orbit' || self . communicationConfig . available_providers . indexOf ( 'orbit' ) >= 0 ) ) {
245257 // TODO: remove duplicated files if functionality is the same for storage and orbit
246- readFiles . push ( { filename : 'ipfs-api.js' , content : fs . readFileSync ( fs . embarkPath ( "js/ipfs-api.min.js" ) ) . toString ( ) , path : fs . embarkPath ( "js/ipfs-api.min.js" ) } ) ;
247- readFiles . push ( { filename : 'orbit.js' , content : fs . readFileSync ( fs . embarkPath ( "js/orbit.min.js" ) ) . toString ( ) , path : fs . embarkPath ( "js/orbit.min.js" ) } ) ;
258+ readFiles . push ( new File ( { filename : 'ipfs-api.js' , type : 'embark_internal' , path : "js/ipfs-api.min.js" } ) ) ;
259+ readFiles . push ( new File ( { filename : 'orbit.js' , type : 'embark_internal' , path : "js/orbit.min.js" } ) ) ;
248260 }
249261
250- readFiles . push ( { filename : 'embark.js' , content : fs . readFileSync ( fs . embarkPath ( "js/build/embark.bundle.js" ) ) . toString ( ) , path : fs . embarkPath ( "js/build/embark.bundle.js" ) } ) ;
262+ readFiles . push ( new File ( { filename : 'embark.js' , type : 'embark_internal' , path : "js/build/embark.bundle.js" } ) ) ;
251263 }
252264 if ( file === '$EMBARK_JS' ) {
253- readFiles . push ( { filename : '$EMBARK_JS' , content : fs . readFileSync ( fs . embarkPath ( "js/build/embark.bundle.js" ) ) . toString ( ) , path : fs . embarkPath ( "js/build/embark.bundle.js" ) } ) ;
254- }
255- if ( file . indexOf ( "web3-" ) === 0 ) {
256- let web3Version = file . split ( 'web3-' ) [ 1 ] . split ( ".js" ) [ 0 ] ;
257- npm . getPackageVersion ( 'web3' , web3Version , function ( web3Content ) {
258- self . logger . error ( 'downloaded web3' ) ;
259- readFiles . push ( { filename : file , content : web3Content , path : fs . embarkPath ( "js/web3.js" ) } ) ;
260- } ) ;
261- }
262- if ( file === "web3.js" ) {
263- readFiles . push ( { filename : 'web3.js' , content : fs . readFileSync ( fs . embarkPath ( "js/web3.js" ) ) . toString ( ) , path : fs . embarkPath ( "js/web3.js" ) } ) ;
265+ readFiles . push ( new File ( { filename : '$EMBARK_JS' , type : 'embark_internal' , path : "js/build/embark.bundle.js" } ) ) ;
264266 }
267+ //if (file === "web3.js") {
268+ // readFiles.push(new File({filename: 'web3.js', type: 'embark_internal', path: "js/web3.js"));
269+ //}
265270 } ) ;
266271
267272 // get plugins
@@ -298,13 +303,13 @@ Config.prototype.loadFiles = function(files) {
298303 return ;
299304 } else if ( file . indexOf ( "web3" ) === 0 ) {
300305 return ;
301- } else if ( file === 'abi.js' ) {
302- readFiles . push ( { filename : file , content : "" , path : file } ) ;
306+ // } else if (file === 'abi.js') {
307+ // readFiles.push({filename: file, content: "", path: file});
303308 } else {
304309 if ( file . indexOf ( '.' ) >= 0 ) {
305- readFiles . push ( { filename : file , content : fs . readFileSync ( file ) . toString ( ) , path : file } ) ;
310+ readFiles . push ( new File ( { filename : file , type : "dapp_file" , path : file } ) ) ;
306311 } else if ( file [ 0 ] === '$' ) {
307- readFiles . push ( { filename : file , content : "" , path : file } ) ;
312+ // readFiles.push(new File( {filename: file, type: 'embark_internal' , path: file}) );
308313 }
309314 }
310315 } ) ;
@@ -320,7 +325,10 @@ Config.prototype.loadPluginContractFiles = function() {
320325 contractsPlugins . forEach ( function ( plugin ) {
321326 plugin . contractsFiles . forEach ( function ( file ) {
322327 var filename = file . replace ( './' , '' ) ;
323- self . contractsFiles . push ( { filename : filename , content : plugin . loadPluginFile ( file ) , path : plugin . pathToFile ( file ) } ) ;
328+ //self.contractsFiles.push({filename: filename, content: plugin.loadPluginFile(file), path: plugin.pathToFile(file)});
329+ self . contractsFiles . push ( new File ( { filename : filename , type : 'custom' , resolver : function ( callback ) {
330+ callback ( plugin . loadPluginFile ( file ) ) ;
331+ } } ) ) ;
324332 } ) ;
325333 } ) ;
326334 }
0 commit comments