From 661f390650a9c75848bf6fed9b2d01200053cc21 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 23 Aug 2019 11:42:26 -0400 Subject: [PATCH] remove console logs; fix events --- packages/embark-code-runner/src/index.ts | 5 ----- packages/embark-compiler/src/index.ts | 3 --- packages/embark-contracts-manager/src/index.js | 3 --- packages/embark-deployment/src/index.js | 3 --- packages/embark-ipfs/src/index.js | 2 -- packages/embark-ipfs/src/upload.js | 2 -- packages/embark-pipeline/src/index.js | 2 -- packages/embark-test-runner/src/index.js | 5 ----- .../embark-web3/src/contract-artifact.js.ejs | 1 - packages/embark-web3/src/web3_init.js.ejs | 6 ------ packages/embark/src/cmd/cmd_controller.js | 8 -------- packages/embark/src/cmd/dashboard/dashboard.js | 3 --- packages/embark/src/lib/core/engine.js | 1 - packages/embark/src/lib/core/events.js | 15 +-------------- packages/embark/src/lib/core/services_monitor.js | 2 -- .../src/lib/modules/basic-pipeline/index.js | 16 ---------------- .../modules/ethereum-blockchain-client/index.js | 9 --------- packages/embark/src/lib/modules/geth/index.js | 4 ---- packages/embark/src/lib/modules/parity/index.js | 2 -- 19 files changed, 1 insertion(+), 91 deletions(-) diff --git a/packages/embark-code-runner/src/index.ts b/packages/embark-code-runner/src/index.ts index 8099b4257..d05fa0881 100644 --- a/packages/embark-code-runner/src/index.ts +++ b/packages/embark-code-runner/src/index.ts @@ -58,13 +58,8 @@ class CodeRunner { return cb(null, ""); } - console.dir("running"); - console.dir(code); - this.vm.doEval(code, tolerateError, (err, result) => { if (err) { - console.dir("error") - console.dir(err) return cb(err); } diff --git a/packages/embark-compiler/src/index.ts b/packages/embark-compiler/src/index.ts index ca904ab13..e93a71684 100644 --- a/packages/embark-compiler/src/index.ts +++ b/packages/embark-compiler/src/index.ts @@ -18,9 +18,6 @@ class Compiler { } private compile_contracts(contractFiles: any[], cb: any) { - console.dir("----- compile_contracts") - console.dir(contractFiles) - console.dir(cb) if (contractFiles.length === 0) { return cb(null, {}); } diff --git a/packages/embark-contracts-manager/src/index.js b/packages/embark-contracts-manager/src/index.js index 132b8c544..3c2d4eda6 100644 --- a/packages/embark-contracts-manager/src/index.js +++ b/packages/embark-contracts-manager/src/index.js @@ -38,8 +38,6 @@ class ContractsManager { cb(null, this.contracts[contract.className]); }); - console.dir("---- contracts manager---- "); - // this.registerCommands() // this.registerAPIs() } @@ -536,7 +534,6 @@ class ContractsManager { self.compileError = false; } self.logger.trace("finished".underline); - console.dir("done!!"); done(err, self.contracts, self.contractDependencies); }); diff --git a/packages/embark-deployment/src/index.js b/packages/embark-deployment/src/index.js index 033307689..f99dcec15 100644 --- a/packages/embark-deployment/src/index.js +++ b/packages/embark-deployment/src/index.js @@ -44,7 +44,6 @@ class Deployment { } deployContract(contract, callback) { - console.dir("requesting to deploy contract") this.events.request('deployment:contract:deploy', contract, (err) => { if (err) { contract.error = err.message || err; @@ -61,13 +60,11 @@ class Deployment { deployAll(contracts, contractDependencies, done) { const self = this; - console.dir("doing deployAll") const contractDeploys = {}; const errors = []; Object.values(contracts).forEach((contract) => { function deploy(result, callback) { - console.dir("== deploy") if (typeof result === 'function') callback = result; self.deployContract(contract, (err) => { if (err) { diff --git a/packages/embark-ipfs/src/index.js b/packages/embark-ipfs/src/index.js index 454473cc9..b0ef32517 100644 --- a/packages/embark-ipfs/src/index.js +++ b/packages/embark-ipfs/src/index.js @@ -226,8 +226,6 @@ class IPFS { } self.logger.trace(`Storage module: Launching ipfs process...`); return this.storageProcessesLauncher.launchProcess('ipfs', (err) => { - console.dir("--- launchProcess callback") - console.dir(err) callback(err, true); }); }); diff --git a/packages/embark-ipfs/src/upload.js b/packages/embark-ipfs/src/upload.js index 75e55c1f6..3f55cec38 100644 --- a/packages/embark-ipfs/src/upload.js +++ b/packages/embark-ipfs/src/upload.js @@ -81,9 +81,7 @@ class IPFS { ], function (err, dir_hash) { if (err) { console.log(__("error uploading to ipfs").red); - console.log("---------------"); console.dir(err); - console.log("---------------"); cb(err); } else cb(null, dir_hash); diff --git a/packages/embark-pipeline/src/index.js b/packages/embark-pipeline/src/index.js index 10e658051..9550a8848 100644 --- a/packages/embark-pipeline/src/index.js +++ b/packages/embark-pipeline/src/index.js @@ -22,8 +22,6 @@ class Pipeline { } generateAll(cb) { - console.dir("generating all files"); - async.waterfall([ (next) => { this.plugins.runActionsForEvent("pipeline:generateAll:before", {}, (err) => { diff --git a/packages/embark-test-runner/src/index.js b/packages/embark-test-runner/src/index.js index 5475106e2..d68992bf1 100644 --- a/packages/embark-test-runner/src/index.js +++ b/packages/embark-test-runner/src/index.js @@ -194,19 +194,14 @@ class TestRunner { return next(err); } - console.log('got accounts from web3'); - console.dir(accts); accounts = accts; next(); }); }, (next) => { // get contract files - console.log('getting contract files'); events.request("config:contractsFiles", next); }, (cf, next) => { // compile contracts - console.log('compiling contracts'); - console.dir(cf); events.request("compiler:contracts:compile", cf, next); }, (cc, next) => { // override require diff --git a/packages/embark-web3/src/contract-artifact.js.ejs b/packages/embark-web3/src/contract-artifact.js.ejs index 9e2b34bb5..8dbdccd40 100644 --- a/packages/embark-web3/src/contract-artifact.js.ejs +++ b/packages/embark-web3/src/contract-artifact.js.ejs @@ -7,7 +7,6 @@ let <%- className %> = new web3.eth.Contract(<%- className %>Abi); <%- className %>.options.from = web3.eth.defaultAccount; web3.execWhenReady(() => { - console.dir("running execWhenReady") <%- className %>.options.from = web3.eth.defaultAccount; if (!<%- className %>.currentProvider) { <%- className %>.setProvider(web3.currentProvider); diff --git a/packages/embark-web3/src/web3_init.js.ejs b/packages/embark-web3/src/web3_init.js.ejs index a115c84c2..03b519187 100644 --- a/packages/embark-web3/src/web3_init.js.ejs +++ b/packages/embark-web3/src/web3_init.js.ejs @@ -6,9 +6,7 @@ let todo = []; let done = false; web3.execWhenReady = function(cb) { - console.dir("adding execWhenReady") if (done) { - console.dir("already done") return cb(); } todo.push(cb); @@ -93,8 +91,6 @@ let doConnect = function(connectionList, opts, doneCb) { if (connectionString === '$WEB3') { connectWeb3(next); } else if (connectionString.indexOf('ws://') >= 0) { - console.dir("connectionString") - console.dir(connectionString) connectWebsocket(connectionString, next); } else { connectHttp(connectionString, next); @@ -140,8 +136,6 @@ let doConnect = function(connectionList, opts, doneCb) { __whenEnvIsLoaded(() => { let connectList = [<%- connectionList.map(x => "'" + x + "'").join(",") %>]; - console.dir(connectList); - console.log("test2") doConnect(connectList, { warnAboutMetamask: false, // TODO: can/should be part as the code generation instead... diff --git a/packages/embark/src/cmd/cmd_controller.js b/packages/embark/src/cmd/cmd_controller.js index feb23239b..a68befdfb 100644 --- a/packages/embark/src/cmd/cmd_controller.js +++ b/packages/embark/src/cmd/cmd_controller.js @@ -62,7 +62,6 @@ class EmbarkController { engine.startService("blockchain"); engine.startEngine(() => { - console.dir("done!") // callback(); }); }); @@ -176,9 +175,7 @@ class EmbarkController { engine.registerModulePackage('embark-deploy-tracker', {plugins: engine.plugins}); engine.events.on('deployment:deployContracts:afterAll', () => { - console.dir("--- generating files...") engine.events.request('pipeline:generateAll', () => { - console.dir("outputDone") engine.events.emit('outputDone'); }); }); @@ -214,7 +211,6 @@ class EmbarkController { 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') { try { @@ -224,7 +220,6 @@ class EmbarkController { } } else if (fileType === 'asset') { engine.events.request('pipeline:generateAll', () => { - console.dir("outputDone") engine.events.emit('outputDone'); }); } @@ -242,7 +237,6 @@ class EmbarkController { let contractsConfig = cloneDeep(_contractsConfig); let [contractsList, contractDependencies] = await engine.events.request2("contracts:build", contractsConfig, compiledContracts); await engine.events.request2("deployment:contracts:deploy", contractsList, contractDependencies); - console.dir("deployment done"); await engine.events.request2("watcher:start"); } catch (e) { @@ -874,7 +868,6 @@ class EmbarkController { } runTests(options) { - console.dir(options); this.context = [constants.contexts.test]; const Engine = require('../lib/core/engine.js'); @@ -916,7 +909,6 @@ class EmbarkController { let plugin = engine.plugins.createPlugin('cmdcontrollerplugin', {}); plugin.registerActionForEvent("embark:engine:started", async (_params, cb) => { - console.dir(engine.config.blockchainConfig); await engine.events.request2("blockchain:node:start", engine.config.blockchainConfig, cb); }); diff --git a/packages/embark/src/cmd/dashboard/dashboard.js b/packages/embark/src/cmd/dashboard/dashboard.js index be2e5336a..f1c97e304 100644 --- a/packages/embark/src/cmd/dashboard/dashboard.js +++ b/packages/embark/src/cmd/dashboard/dashboard.js @@ -60,7 +60,6 @@ class Dashboard { // this.events.on('contractsState', monitor.setContracts); this.events.on("deployment:contract:error", (_contract) => { - console.dir("---- contract error event") this.events.request("contracts:state", (err, contracts) => { monitor.setContracts(contracts) }); @@ -68,7 +67,6 @@ class Dashboard { }); this.events.on("deployment:contract:deployed", (_contract) => { - console.dir("---- contract deployed event") // self.events.emit('contractsState', self.contractsState()); this.events.request("contracts:state", (err, contracts) => { monitor.setContracts(contracts) @@ -76,7 +74,6 @@ class Dashboard { }); this.events.on("deployment:contract:undeployed", (_contract) => { - console.dir("---- contract undeployed event") // self.events.emit('contractsState', self.contractsState()); this.events.request("contracts:state", (err, contracts) => { monitor.setContracts(contracts) diff --git a/packages/embark/src/lib/core/engine.js b/packages/embark/src/lib/core/engine.js index 6afb97b17..ae4ecd29c 100644 --- a/packages/embark/src/lib/core/engine.js +++ b/packages/embark/src/lib/core/engine.js @@ -134,7 +134,6 @@ class Engine { let plugin = this.plugins.createPlugin('coreservicesplugin', {}); plugin.registerActionForEvent("embark:engine:started", (_params, cb) => { - console.dir("----- startMonitor") this.servicesMonitor.startMonitor(); cb(); }); diff --git a/packages/embark/src/lib/core/events.js b/packages/embark/src/lib/core/events.js index 9181734f8..176978483 100644 --- a/packages/embark/src/lib/core/events.js +++ b/packages/embark/src/lib/core/events.js @@ -32,6 +32,7 @@ function log(eventType, eventName, origin) { // origin = getOrigin(); } + fs.ensureDirSync(".embark/"); fs.appendFileSync(".embark/events.log", eventType + ": " + eventName + " -- (" + origin + ")\n"); } @@ -96,7 +97,6 @@ EmbarkEmitter.prototype.request2 = function() { let other_args = [].slice.call(arguments, 1); log("\nREQUEST", requestName); - console.log("requesting: " + requestName); warnIfLegacy(requestName); if (this._events && !this._events['request:' + requestName]) { log("NO REQUEST LISTENER", requestName) @@ -105,8 +105,6 @@ EmbarkEmitter.prototype.request2 = function() { } let promise = new Promise((resolve, reject) => { - console.dir("emitting... " + requestName) - other_args.push( (err, ...res) => { if (err) return reject(err); @@ -117,10 +115,6 @@ EmbarkEmitter.prototype.request2 = function() { } ) - console.dir("----- other_args") - console.dir(other_args) - - // this.emit('request:' + requestName, ...other_args) this._emit('request:' + requestName, ...other_args) }); @@ -132,7 +126,6 @@ EmbarkEmitter.prototype.request = function() { let other_args = [].slice.call(arguments, 1); log("\nREQUEST(OLD)", requestName); - console.log("requesting: " + requestName); warnIfLegacy(requestName); if (this._events && !this._events['request:' + requestName]) { log("NO REQUEST LISTENER", requestName) @@ -167,12 +160,6 @@ EmbarkEmitter.prototype.setCommandHandler = function(requestName, cb) { let listener = function(_cb) { log("== REQUEST RESPONSE", requestName, origin); - console.dir(requestName) - // console.dir(cb) - // console.dir(Object.getOwnPropertyNames(cb)) - // console.dir(cb.length) - // console.dir(Object.values(cb)) - // process.exit(0) cb.call(this, ...arguments); }; const listenerName = 'request:' + requestName; diff --git a/packages/embark/src/lib/core/services_monitor.js b/packages/embark/src/lib/core/services_monitor.js index 098f67989..d34cb9563 100644 --- a/packages/embark/src/lib/core/services_monitor.js +++ b/packages/embark/src/lib/core/services_monitor.js @@ -59,8 +59,6 @@ ServicesMonitor.prototype.addCheck = function (checkName, checkFn, time, initial this.logger.trace('add check: ' + checkName); this.checkList[checkName] = {fn: checkFn, interval: time || 5000, status: initialState}; - console.dir("this.working") - console.dir(this.working) if (this.working) { this.initCheck(checkName); } diff --git a/packages/embark/src/lib/modules/basic-pipeline/index.js b/packages/embark/src/lib/modules/basic-pipeline/index.js index 4b51893c8..522d256c3 100644 --- a/packages/embark/src/lib/modules/basic-pipeline/index.js +++ b/packages/embark/src/lib/modules/basic-pipeline/index.js @@ -37,7 +37,6 @@ class BasicPipeline { } webpackAssets(params, done) { - console.dir("=======================> webpackAssets"); let self = this; let placeholderPage; const importsList = {}; @@ -50,13 +49,11 @@ class BasicPipeline { async.waterfall([ (next) => { - console.dir("=======================> importsList"); importsList["Embark/EmbarkJS"] = dappPath(self.embarkConfig.generationDir, 'embarkjs.js'); importsList["Embark/contracts"] = this.embarkConfig.generationDir; next(); }, function shouldRunWebpack(next) { - console.dir("=======================> shouldRunWebpack"); // assuming we got here because an asset was changed, let's check our webpack config // to see if the changed asset requires webpack to run if (!(modifiedAssets && modifiedAssets.length)) return next(null, false); @@ -73,7 +70,6 @@ class BasicPipeline { }); }, function runWebpack(shouldNotRun, next) { - console.dir("=======================> runWebpack"); if (shouldNotRun) return next(); const assets = Object.keys(self.assetFiles).filter(key => key.match(/\.js$/)); if (!assets || !assets.length) { @@ -135,7 +131,6 @@ class BasicPipeline { }); }, function assetFileWrite(next) { - console.dir("=======================> assetFileWrite 136"); async.eachOf( // assetFileWrite should not process .js files Object.keys(self.assetFiles) @@ -145,20 +140,17 @@ class BasicPipeline { return obj; }, {}), function (files, targetFile, cb) { - console.dir("== eachOf: " + targetFile); const isDir = targetFile.slice(-1) === '/' || targetFile.slice(-1) === '\\' || targetFile.indexOf('.') === -1; // if it's not a directory if (!isDir) { self.logger.info('Pipeline: '.cyan + __("_1_ writing file") + " " + (joinPath(self.buildDir, targetFile)).bold.dim); } - console.dir("async.map") // async.map( async.mapLimit( files, 1, function (file, fileCb) { self.logger.trace("reading " + file.path); - console.dir(":::::::: reading " + file.path); file.content.then((fileContent) => { self.runPlugins(file, fileContent, fileCb); }).catch(fileCb); @@ -167,7 +159,6 @@ class BasicPipeline { try { if (err) { self.logger.error('Pipeline: '.cyan + __('errors found while generating') + ' ' + targetFile); - console.dir(err); } let dir = targetFile.split('/').slice(0, -1).join('/'); self.logger.trace(`${'Pipeline:'.cyan} creating dir ` + joinPath(self.buildDir, dir)); @@ -175,16 +166,12 @@ class BasicPipeline { // if it's a directory if (isDir) { - console.dir("---> isDir") let targetDir = targetFile; if (targetDir.slice(-1) !== '/') { targetDir = targetDir + '/'; } - console.dir("===> contentFiles") - console.dir(contentFiles) - console.dir("----------") async.each(contentFiles, function (file, eachCb) { let filename = file.path.replace(file.basedir + '/', ''); self.logger.info(`${'Pipeline:'.cyan} __ writing file ` + (joinPath(self.buildDir, targetDir, filename)).bold.dim); @@ -194,7 +181,6 @@ class BasicPipeline { return; } - console.dir("---> not a dir") let content = contentFiles.map(file => { if (file === undefined) { return ""; @@ -206,7 +192,6 @@ class BasicPipeline { targetFile = targetFile.replace('index', 'index-temp'); placeholderPage = targetFile; } - console.dir("--> writing file") self.fs.writeFile(joinPath(self.buildDir, targetFile), content, cb); } catch(err) { console.dir(err) @@ -218,7 +203,6 @@ class BasicPipeline { ); }, function removePlaceholderPage(next) { - console.dir("=======================> removePlaceholderPage"); let placeholderFile = joinPath(self.buildDir, placeholderPage); self.fs.access(joinPath(self.buildDir, placeholderPage), (err) => { if (err) return next(); // index-temp doesn't exist, do nothing diff --git a/packages/embark/src/lib/modules/ethereum-blockchain-client/index.js b/packages/embark/src/lib/modules/ethereum-blockchain-client/index.js index 73d0aba3f..77e3fac32 100644 --- a/packages/embark/src/lib/modules/ethereum-blockchain-client/index.js +++ b/packages/embark/src/lib/modules/ethereum-blockchain-client/index.js @@ -34,7 +34,6 @@ class EthereumBlockchainClient { let accounts = await web3.eth.getAccounts(); let account = accounts[0]; // let contractObject = this.blockchain.ContractObject({abi: contract.abiDefinition}); - console.dir("== ethereum contract deployer"); let contractObj = new web3.eth.Contract(contract.abiDefinition, contract.address); // let deployObject = this.blockchain.deployContractObject(contractObject, {arguments: contractParams, data: dataCode}); let contractObject = contractObj.deploy({arguments: (contract.args || []), data: ("0x" + contract.code)}); @@ -50,10 +49,6 @@ class EthereumBlockchainClient { contract.gasPrice = contract.gasPrice || gasPrice; } - // this.blockchain.deployContractFromObject(deployObject, - console.dir({arguments: contract.args, data: ("0x" + contract.code)}); - console.dir("------- send"); - embarkJsUtils.secureSend(web3, contractObject, { from: account, gas: contract.gas }, true, (err, receipt) => { @@ -65,7 +60,6 @@ class EthereumBlockchainClient { contract.log(`${contract.className.bold.cyan} ${__('deployed at').green} ${receipt.contractAddress.bold.cyan} ${__("using").green} ${receipt.gasUsed} ${__("gas").green} (txHash: ${receipt.transactionHash.bold.cyan})`); done(err, receipt); }, (hash) => { - console.dir('hash is ' + hash); }); // }) } @@ -73,8 +67,6 @@ class EthereumBlockchainClient { async doLinking(params, callback) { let contract = params.contract; - console.dir("= doLinking"); - if (!contract.linkReferences || !Object.keys(contract.linkReferences).length) { return callback(null, params); } @@ -205,7 +197,6 @@ class EthereumBlockchainClient { } addContractJSONToPipeline(params, cb) { - console.dir("-- addContractJSONToPipeline"); // TODO: check if this is correct json object to generate const contract = params.contract; diff --git a/packages/embark/src/lib/modules/geth/index.js b/packages/embark/src/lib/modules/geth/index.js index 57b35d10b..208192fbe 100644 --- a/packages/embark/src/lib/modules/geth/index.js +++ b/packages/embark/src/lib/modules/geth/index.js @@ -15,15 +15,12 @@ class Geth { this.isDev = options.isDev; this.events = embark.events; this.plugins = options.plugins; - // let plugin = this.plugins.createPlugin('gethplugin', {}); if (!this.shouldInit()) { return; } this.events.request("blockchain:node:register", constants.blockchain.clients.geth, (readyCb) => { - console.dir('registering blockchain node'); - console.dir(readyCb); this.events.request('processes:register', 'blockchain', { launchFn: (cb) => { // this.startBlockchainNode(readyCb); @@ -71,7 +68,6 @@ class Geth { } startBlockchainNode(callback) { - console.log('startBlockchainNode'); this.blockchainProcess = new BlockchainProcessLauncher({ events: this.events, logger: this.logger, diff --git a/packages/embark/src/lib/modules/parity/index.js b/packages/embark/src/lib/modules/parity/index.js index 224052658..047f3008b 100644 --- a/packages/embark/src/lib/modules/parity/index.js +++ b/packages/embark/src/lib/modules/parity/index.js @@ -22,8 +22,6 @@ class Parity { } this.events.request("blockchain:node:register", constants.blockchain.clients.parity, (readyCb) => { - console.dir('registering blockchain node'); - console.dir(readyCb); this.events.request('processes:register', 'blockchain', { launchFn: (cb) => { // this.startBlockchainNode(readyCb);