mirror of https://github.com/embarklabs/embark.git
add file changes workflow to cmd controller
This commit is contained in:
parent
f838739e17
commit
c9edd48f2f
|
@ -2,6 +2,6 @@
|
||||||
//console.log("foo");
|
//console.log("foo");
|
||||||
//console.log(web3);
|
//console.log(web3);
|
||||||
|
|
||||||
const FOO = "dude";
|
const FOO = "hello";
|
||||||
|
|
||||||
export default FOO;
|
export default FOO;
|
||||||
|
|
|
@ -178,29 +178,42 @@ class EmbarkController {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// this.events.request('watcher:start');
|
let plugin = engine.plugins.createPlugin('cmdcontrollerplugin', {});
|
||||||
|
plugin.registerActionForEvent("embark:engine:started", async (_params, cb) => {
|
||||||
|
await engine.events.request2("blockchain:node:start", cb)
|
||||||
|
});
|
||||||
|
|
||||||
// engine.events.on('check:backOnline:Ethereum', function () {
|
engine.events.request('watcher:start');
|
||||||
// engine.logger.info(__('Ethereum node detected') + '..');
|
|
||||||
// engine.config.reloadConfig();
|
|
||||||
// engine.events.request('deploy:contracts', function (err) {
|
|
||||||
// if (err) {
|
|
||||||
// return engine.logger.error(err.message || err);
|
|
||||||
// }
|
|
||||||
// engine.logger.info(__('Deployment Done'));
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// engine.events.on('outputDone', function () {
|
engine.events.on('check:backOnline:Ethereum', function () {
|
||||||
// engine.logger.info((__("Looking for documentation? You can find it at") + " ").cyan + "http://embark.status.im/docs/".green.underline + ".".cyan);
|
engine.logger.info(__('Ethereum node detected') + '..');
|
||||||
// engine.logger.info(__("Ready").underline);
|
// TODO: deploy contracts, etc...
|
||||||
// engine.events.emit("status", __("Ready").green);
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
// if (webServerConfig.enabled !== false) {
|
engine.events.on('outputDone', function () {
|
||||||
// engine.startService("webServer");
|
engine.logger.info((__("Looking for documentation? You can find it at") + " ").cyan + "http://embark.status.im/docs/".green.underline + ".".cyan);
|
||||||
// }
|
engine.logger.info(__("Ready").underline);
|
||||||
// engine.startService("fileWatcher");
|
engine.events.emit("status", __("Ready").green);
|
||||||
|
});
|
||||||
|
|
||||||
|
engine.events.on('file-event', async ({ fileType, path }) => {
|
||||||
|
// TODO: re-add async.cargo / or use rxjs to use latest request in the queue
|
||||||
|
console.dir("-- before timeout - file changed")
|
||||||
|
|
||||||
|
if (fileType === 'contract' || fileType === 'config') {
|
||||||
|
let contractsFiles = await engine.events.request2("config:contractsFiles");
|
||||||
|
let compiledContracts = await engine.events.request2("compiler:contracts:compile", contractsFiles);
|
||||||
|
let _contractsConfig = await engine.events.request2("config:contractsConfig");
|
||||||
|
let contractsConfig = cloneDeep(_contractsConfig);
|
||||||
|
let [contractsList, contractDependencies] = await engine.events.request2("contracts:build", contractsConfig, compiledContracts);
|
||||||
|
await engine.events.request2("deployment:contracts:deploy", contractsList, contractDependencies);
|
||||||
|
} else if (fileType === 'asset') {
|
||||||
|
engine.events.request('pipeline:generateAll', () => {
|
||||||
|
console.dir("outputDone")
|
||||||
|
engine.events.emit('outputDone');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
engine.startEngine(async () => {
|
engine.startEngine(async () => {
|
||||||
callback();
|
callback();
|
||||||
|
@ -208,35 +221,14 @@ class EmbarkController {
|
||||||
engine.events.request("webserver:start")
|
engine.events.request("webserver:start")
|
||||||
|
|
||||||
let contractsFiles = await engine.events.request2("config:contractsFiles");
|
let contractsFiles = await engine.events.request2("config:contractsFiles");
|
||||||
|
|
||||||
// engine.events.request("config:contractsFiles", (contractsFiles) => {
|
|
||||||
// engine.events.request("compiler:contracts:compile", contractsFiles, (err, compiledContracts) => {
|
|
||||||
let compiledContracts = await engine.events.request2("compiler:contracts:compile", contractsFiles);
|
let compiledContracts = await engine.events.request2("compiler:contracts:compile", contractsFiles);
|
||||||
console.dir("compilation done")
|
let _contractsConfig = await engine.events.request2("config:contractsConfig");
|
||||||
console.dir(compiledContracts)
|
let contractsConfig = cloneDeep(_contractsConfig);
|
||||||
|
let [contractsList, contractDependencies] = await engine.events.request2("contracts:build", contractsConfig, compiledContracts);
|
||||||
console.dir("requesting contracts configuration")
|
await engine.events.request2("deployment:contracts:deploy", contractsList, contractDependencies);
|
||||||
// engine.events.request("config:contractsConfig", (_contractsConfig) => {
|
console.dir("deployment done")
|
||||||
let _contractsConfig = await engine.events.request2("config:contractsConfig");
|
|
||||||
console.dir(_contractsConfig);
|
|
||||||
let contractsConfig = cloneDeep(_contractsConfig);
|
|
||||||
|
|
||||||
// engine.events.request("contracts:build", contractsConfig, compiledContracts, (err, contractsList, contractDependencies) => {
|
|
||||||
let [contractsList, contractDependencies] = await engine.events.request2("contracts:build", contractsConfig, compiledContracts);
|
|
||||||
|
|
||||||
// let [contractsList, contractDependencies] = await engine.events.request2("contracts:build", contractsConfig, compiledContracts);
|
|
||||||
console.dir("contracts config build done")
|
|
||||||
console.dir(contractsList)
|
|
||||||
console.dir(contractDependencies)
|
|
||||||
|
|
||||||
// engine.events.request("deployment:contracts:deploy", contractsList, contractDependencies, () => {
|
|
||||||
await engine.events.request2("deployment:contracts:deploy", contractsList, contractDependencies);
|
|
||||||
console.dir("deployment done")
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
|
|
||||||
|
await engine.events.request2("watcher:start")
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function startDashboard(callback) {
|
function startDashboard(callback) {
|
||||||
|
|
|
@ -330,29 +330,6 @@ class Engine {
|
||||||
this.registerModulePackage('embark-deployment', {plugins: this.plugins, onlyCompile: options.onlyCompile});
|
this.registerModulePackage('embark-deployment', {plugins: this.plugins, onlyCompile: options.onlyCompile});
|
||||||
this.registerModulePackage('embark-transaction-tracker');
|
this.registerModulePackage('embark-transaction-tracker');
|
||||||
this.registerModulePackage('embark-debugger');
|
this.registerModulePackage('embark-debugger');
|
||||||
|
|
||||||
this.events.on('file-event', function ({fileType, path}) {
|
|
||||||
clearTimeout(self.fileTimeout);
|
|
||||||
self.fileTimeout = setTimeout(() => {
|
|
||||||
// TODO: still need to redeploy contracts because the original contracts
|
|
||||||
// config is being corrupted
|
|
||||||
self.config.reloadConfig();
|
|
||||||
|
|
||||||
if (fileType === 'asset') {
|
|
||||||
// Throttle file changes so we re-write only once for all files
|
|
||||||
self.events.emit('asset-changed', path);
|
|
||||||
}
|
|
||||||
// TODO: for now need to deploy on asset changes as well
|
|
||||||
// because the contractsManager config is corrupted after a deploy
|
|
||||||
if (fileType === 'contract' || fileType === 'config') {
|
|
||||||
self.events.request('deploy:contracts', (err) => {
|
|
||||||
if (err) {
|
|
||||||
self.logger.error(err.message || err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, 50);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileWatchService() {
|
fileWatchService() {
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Blockchain {
|
||||||
this.blockchainNodes[clientName] = startCb
|
this.blockchainNodes[clientName] = startCb
|
||||||
})
|
})
|
||||||
|
|
||||||
plugin.registerActionForEvent("embark:engine:started", (_params, cb) => {
|
this.events.setCommandHandler("blockchain:node:start", (cb) => {
|
||||||
const clientName = this.blockchainConfig.client;
|
const clientName = this.blockchainConfig.client;
|
||||||
const client = this.blockchainNodes[clientName];
|
const client = this.blockchainNodes[clientName];
|
||||||
if (!client) return cb("client " + clientName + " not found");
|
if (!client) return cb("client " + clientName + " not found");
|
||||||
|
|
Loading…
Reference in New Issue