mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
#156326148 Updates to build and upload process and fixes for test_app/test.html
* Updated build to include deployment of contracts * updated the plugin uploadCmd to be a Promise for better bubbling of errors and messaging. * updated test.js imports so functionality works correctly.
This commit is contained in:
parent
6b7af4b647
commit
31a2a27e9a
29
lib/index.js
29
lib/index.js
@ -274,7 +274,7 @@ class Embark {
|
|||||||
if (cmdPlugin) {
|
if (cmdPlugin) {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
|
|
||||||
function buildDapp(callback){
|
function (callback){
|
||||||
engine.logger.debug('building dapp...');
|
engine.logger.debug('building dapp...');
|
||||||
engine.startMonitor();
|
engine.startMonitor();
|
||||||
engine.startService("libraryManager");
|
engine.startService("libraryManager");
|
||||||
@ -284,23 +284,30 @@ class Embark {
|
|||||||
engine.startService("deployment");
|
engine.startService("deployment");
|
||||||
engine.startService("ipfs");
|
engine.startService("ipfs");
|
||||||
|
|
||||||
|
// 3. upload to storage (outputDone event triggered after webpack finished)
|
||||||
engine.events.on('outputDone', function () {
|
engine.events.on('outputDone', function () {
|
||||||
engine.logger.debug('deploying...');
|
engine.logger.debug('deploying to ' + platform + '...');
|
||||||
cmdPlugin.uploadCmds[0].cb();
|
cmdPlugin.uploadCmds[0].cb()
|
||||||
callback();
|
.then((success) => {
|
||||||
|
callback();
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// build the contracts
|
// 1. build the contracts
|
||||||
engine.contractsManager.build(function(){
|
engine.deployManager.deployContracts(function (err) {
|
||||||
// trigger code generation and dapp webpack
|
if(err){
|
||||||
|
callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. trigger code generation and dapp webpack
|
||||||
engine.events.emit('asset-changed', engine.contractsManager);
|
engine.events.emit('asset-changed', engine.contractsManager);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
function upload(callback){
|
|
||||||
|
|
||||||
callback();
|
|
||||||
}
|
}
|
||||||
], function (err, _result) {
|
], function (err, _result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -12,48 +12,51 @@ class IPFS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deploy() {
|
deploy() {
|
||||||
console.log("deploying!");
|
return new Promise((resolve, reject) => {
|
||||||
let self = this;
|
console.log("deploying!");
|
||||||
async.waterfall([
|
let self = this;
|
||||||
function findBinary(callback) {
|
async.waterfall([
|
||||||
let ipfs_bin = shelljs.which(self.configIpfsBin);
|
function findBinary(callback) {
|
||||||
|
let ipfs_bin = shelljs.which(self.configIpfsBin);
|
||||||
|
|
||||||
if (ipfs_bin === 'ipfs not found' || !ipfs_bin) {
|
if (ipfs_bin === 'ipfs not found' || !ipfs_bin) {
|
||||||
console.log(('=== WARNING: ' + self.configIpfsBin + ' not found or not in the path. Guessing ~/go/bin/ipfs for path').yellow);
|
console.log(('=== WARNING: ' + self.configIpfsBin + ' not found or not in the path. Guessing ~/go/bin/ipfs for path').yellow);
|
||||||
ipfs_bin = "~/go/bin/ipfs";
|
ipfs_bin = "~/go/bin/ipfs";
|
||||||
|
}
|
||||||
|
|
||||||
|
return callback(null, ipfs_bin);
|
||||||
|
},
|
||||||
|
function runCommand(ipfs_bin, callback) {
|
||||||
|
let cmd = `"${ipfs_bin}" add -r ${self.buildDir}`;
|
||||||
|
console.log(("=== adding " + self.buildDir + " to ipfs").green);
|
||||||
|
console.log(cmd.green);
|
||||||
|
let result = shelljs.exec(cmd);
|
||||||
|
|
||||||
|
return callback(null, result);
|
||||||
|
},
|
||||||
|
function getHashFromOutput(result, callback) {
|
||||||
|
let rows = result.output.split("\n");
|
||||||
|
let dir_row = rows[rows.length - 2];
|
||||||
|
let dir_hash = dir_row.split(" ")[1];
|
||||||
|
|
||||||
|
return callback(null, dir_hash);
|
||||||
|
},
|
||||||
|
function printUrls(dir_hash, callback) {
|
||||||
|
console.log(("=== DApp available at http://localhost:8080/ipfs/" + dir_hash + "/").green);
|
||||||
|
console.log(("=== DApp available at http://gateway.ipfs.io/ipfs/" + dir_hash + "/").green);
|
||||||
|
|
||||||
|
return callback();
|
||||||
}
|
}
|
||||||
|
], function (err, _result) {
|
||||||
return callback(null, ipfs_bin);
|
if (err) {
|
||||||
},
|
console.log("error uploading to ipfs".red);
|
||||||
function runCommand(ipfs_bin, callback) {
|
console.log(err);
|
||||||
let cmd = `"${ipfs_bin}" add -r ${self.buildDir}`;
|
reject(err);
|
||||||
console.log(("=== adding " + self.buildDir + " to ipfs").green);
|
}
|
||||||
console.log(cmd.green);
|
else resolve('successfully uploaded to ipfs');
|
||||||
let result = shelljs.exec(cmd);
|
});
|
||||||
|
|
||||||
return callback(null, result);
|
|
||||||
},
|
|
||||||
function getHashFromOutput(result, callback) {
|
|
||||||
let rows = result.output.split("\n");
|
|
||||||
let dir_row = rows[rows.length - 2];
|
|
||||||
let dir_hash = dir_row.split(" ")[1];
|
|
||||||
|
|
||||||
return callback(null, dir_hash);
|
|
||||||
},
|
|
||||||
function printUrls(dir_hash, callback) {
|
|
||||||
console.log(("=== DApp available at http://localhost:8080/ipfs/" + dir_hash + "/").green);
|
|
||||||
console.log(("=== DApp available at http://gateway.ipfs.io/ipfs/" + dir_hash + "/").green);
|
|
||||||
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
], function (err, _result) {
|
|
||||||
if (err) {
|
|
||||||
console.log("error uploading to ipfs".red);
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = IPFS;
|
module.exports = IPFS;
|
||||||
|
@ -9,46 +9,50 @@ class Swarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deploy() {
|
deploy() {
|
||||||
let self = this;
|
return new Promise((resolve, reject) => {
|
||||||
async.waterfall([
|
let self = this;
|
||||||
function findBinary(callback) {
|
async.waterfall([
|
||||||
let swarm_bin = shelljs.which('swarm');
|
function findBinary(callback) {
|
||||||
|
let swarm_bin = shelljs.which('swarm');
|
||||||
|
|
||||||
if (swarm_bin === 'swarm not found' || !swarm_bin) {
|
if (swarm_bin === 'swarm not found' || !swarm_bin) {
|
||||||
console.log('=== WARNING: Swarm not in an executable path. Guessing ~/go/bin/swarm for path'.yellow);
|
console.log('=== WARNING: Swarm not in an executable path. Guessing ~/go/bin/swarm for path'.yellow);
|
||||||
swarm_bin = "~/go/bin/swarm";
|
swarm_bin = "~/go/bin/swarm";
|
||||||
|
}
|
||||||
|
|
||||||
|
return callback(null, swarm_bin);
|
||||||
|
},
|
||||||
|
function runCommand(swarm_bin, callback) {
|
||||||
|
let cmd = `"${swarm_bin}" --defaultpath ${self.buildDir} index.html --recursive up ${self.buildDir}`;
|
||||||
|
console.log(("=== adding " + self.buildDir + " to swarm").green);
|
||||||
|
console.log(cmd.green);
|
||||||
|
let result = shelljs.exec(cmd);
|
||||||
|
|
||||||
|
return callback(null, result);
|
||||||
|
},
|
||||||
|
function getHashFromOutput(result, callback) {
|
||||||
|
if (result.code !== 0) {
|
||||||
|
return callback("couldn't upload, is the swarm daemon running?");
|
||||||
|
}
|
||||||
|
|
||||||
|
let rows = result.output.split("\n");
|
||||||
|
let dir_hash = rows.reverse()[1];
|
||||||
|
|
||||||
|
return callback(null, dir_hash);
|
||||||
|
},
|
||||||
|
function printUrls(dir_hash, callback) {
|
||||||
|
console.log(("=== DApp available at http://localhost:8500/bzz:/" + dir_hash + "/").green);
|
||||||
|
|
||||||
|
return callback();
|
||||||
}
|
}
|
||||||
|
], function (err, _result) {
|
||||||
return callback(null, swarm_bin);
|
if (err) {
|
||||||
},
|
console.log("error uploading to swarm".red);
|
||||||
function runCommand(swarm_bin, callback) {
|
console.log(err);
|
||||||
let cmd = `"${swarm_bin}" --defaultpath ${self.buildDir} index.html --recursive up ${self.buildDir}`;
|
reject(err);
|
||||||
console.log(("=== adding " + self.buildDir + " to swarm").green);
|
|
||||||
console.log(cmd.green);
|
|
||||||
let result = shelljs.exec(cmd);
|
|
||||||
|
|
||||||
return callback(null, result);
|
|
||||||
},
|
|
||||||
function getHashFromOutput(result, callback) {
|
|
||||||
if (result.code !== 0) {
|
|
||||||
return callback("couldn't upload, is the swarm daemon running?");
|
|
||||||
}
|
}
|
||||||
|
else resolve('successfully uploaded to swarm');
|
||||||
let rows = result.output.split("\n");
|
});
|
||||||
let dir_hash = rows.reverse()[1];
|
|
||||||
|
|
||||||
return callback(null, dir_hash);
|
|
||||||
},
|
|
||||||
function printUrls(dir_hash, callback) {
|
|
||||||
console.log(("=== DApp available at http://localhost:8500/bzz:/" + dir_hash + "/").green);
|
|
||||||
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
], function (err, _result) {
|
|
||||||
if (err) {
|
|
||||||
console.log("error uploading to swarm".red);
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
import $ from 'jquery';
|
||||||
|
import AlreadyDeployedToken from 'Embark/contracts/AlreadyDeployedToken';
|
||||||
|
import AnotherStorage from 'Embark/contracts/AnotherStorage';
|
||||||
|
import async from 'async';
|
||||||
|
import MyToken from 'Embark/contracts/MyToken';
|
||||||
|
import MyToken2 from 'Embark/contracts/MyToken2';
|
||||||
|
import SimpleStorage from 'Embark/contracts/SimpleStorage';
|
||||||
|
import Token from 'Embark/contracts/Token';
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user