From 9aa3217331ce6b10ae6fdfd4557d4ebdf8b774bd Mon Sep 17 00:00:00 2001 From: emizzle Date: Thu, 27 Sep 2018 15:35:37 +1000 Subject: [PATCH] After upload message regarding CORS and public gateways --- lib/modules/ipfs/index.js | 3 ++- lib/modules/ipfs/upload.js | 25 +++++++++++++++++++++++++ lib/modules/swarm/index.js | 3 ++- lib/modules/swarm/upload.js | 26 +++++++++++++++++++++++++- 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/lib/modules/ipfs/index.js b/lib/modules/ipfs/index.js index 75dd9b7f9..45b05d477 100644 --- a/lib/modules/ipfs/index.js +++ b/lib/modules/ipfs/index.js @@ -125,7 +125,8 @@ class IPFS { let upload_ipfs = new UploadIPFS({ buildDir: self.buildDir || 'dist/', storageConfig: self.storageConfig, - configIpfsBin: self.storageConfig.ipfs_bin || "ipfs" + configIpfsBin: self.storageConfig.ipfs_bin || "ipfs", + env: this.embark.env }); upload_ipfs.deploy(cb); diff --git a/lib/modules/ipfs/upload.js b/lib/modules/ipfs/upload.js index b53cde3d0..04d2048d2 100644 --- a/lib/modules/ipfs/upload.js +++ b/lib/modules/ipfs/upload.js @@ -10,6 +10,7 @@ class IPFS { this.buildDir = options.buildDir || 'dist/'; this.storageConfig = options.storageConfig; this.configIpfsBin = this.storageConfig.ipfs_bin || "ipfs"; + this.env = options.env; } deploy(cb) { @@ -45,6 +46,30 @@ class IPFS { function printUrls(dir_hash, callback) { console.log(("=== " + __("DApp available at") + " http://localhost:8080/ipfs/" + dir_hash + "/").green); console.log(("=== " + __("DApp available at") + " https://ipfs.infura.io/ipfs/" + dir_hash + "/").green); + if(self.env === 'development') { + console.log(("\n=== " + + "Blockchain must be running".bold + + " ===").yellow); + console.log(( + "embark run".italic + + __(" or ") + + "embark blockchain".italic + + __(" must be running when the site is loaded to interact with the blockchain.\n") + ).yellow); + console.log(("=== " + + "Usage with the public gateway".bold + + " ===").yellow); + console.log(( + __("If you wish to load your development site from the public gateway (ipfs.infura.io), you will need to first update your CORS settings (") + + "config/blockchain.js > wsOrigins".italic + + __(" and ") + + "config/blockchain.js > rpcCorsDomain".italic + + __(") to allow ") + + "ipfs.infura.io".underline + + __(". If these were set to 'auto', they would now need to be set to ") + + "https://ipfs.infura.io,http://localhost:8000,http://localhost:8500,embark".underline + + ".\n").yellow); + } callback(null, dir_hash); } diff --git a/lib/modules/swarm/index.js b/lib/modules/swarm/index.js index 2e0df00e4..fb11881b5 100644 --- a/lib/modules/swarm/index.js +++ b/lib/modules/swarm/index.js @@ -108,7 +108,8 @@ class Swarm { buildDir: self.buildDir || 'dist/', storageConfig: self.storageConfig, providerUrl: self.providerUrl, - swarm: self.swarm + swarm: self.swarm, + env: self.embark.env }); upload_swarm.deploy(cb); diff --git a/lib/modules/swarm/upload.js b/lib/modules/swarm/upload.js index db6918d76..60263cd2d 100644 --- a/lib/modules/swarm/upload.js +++ b/lib/modules/swarm/upload.js @@ -7,6 +7,7 @@ class Swarm { this.buildDir = options.buildDir || 'dist/'; this.swarm = options.swarm; this.providerUrl = options.providerUrl; + this.env = options.env; } deploy(cb) { @@ -24,7 +25,30 @@ class Swarm { } console.log(("=== " + __("DApp available at") + ` ${self.providerUrl}/bzz:/${dir_hash}/index.html`).green); console.log(("=== " + __("DApp available at") + ` https://swarm-gateways.net/bzz:/${dir_hash}/index.html`).green); - console.log(("=== " + __("NOTE: Swarm AND a blockchain node must be running for the dApp to work correctly (ie 'embark run')").yellow)); + if(self.env === 'development') { + console.log(("\n=== " + + "Blockchain must be running".bold + + " ===").yellow); + console.log(( + "embark run".italic + + __(" or ") + + "embark blockchain".italic + + __(" must be running when the site is loaded to interact with the blockchain.\n") + ).yellow); + console.log(("=== " + + "Usage with the public gateway".bold + + " ===").yellow); + console.log(( + __("If you wish to load your development site from the public gateway (swarm-gateways.net), you will need to first update your CORS settings (") + + "config/blockchain.js > wsOrigins".italic + + __(" and ") + + "config/blockchain.js > rpcCorsDomain".italic + + __(") to allow ") + + "swarm-gateways.net".underline + + __(". If these were set to 'auto', they would now need to be set to ") + + "https://swarm-gateways.net,http://localhost:8000,http://localhost:8500,embark".underline + + ".\n").yellow); + } callback(null, dir_hash); }