From 46c18fd81d24867198104d46648f22dcf485c565 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 7 Aug 2018 18:57:49 -0400 Subject: [PATCH 1/4] move simulator & proxy to blockchain process module --- lib/index.js | 2 +- lib/modules/blockchain_process/blockchain.js | 2 +- .../blockchain_process}/proxy.js | 4 +- .../blockchain_process}/simulator.js | 12 +- test_apps/test_app/package-lock.json | 142 ++++++++++-------- 5 files changed, 86 insertions(+), 76 deletions(-) rename lib/{contracts => modules/blockchain_process}/proxy.js (96%) rename lib/{cmds => modules/blockchain_process}/simulator.js (86%) diff --git a/lib/index.js b/lib/index.js index d6d9452b8..e404f2a2d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -41,7 +41,7 @@ class Embark { simulator(options) { this.context = options.context || [constants.contexts.simulator, constants.contexts.blockchain]; - let Simulator = require('./cmds/simulator.js'); + let Simulator = require('./modules/blockchain_process/simulator.js'); let simulator = new Simulator({ blockchainConfig: this.config.blockchainConfig, logger: this.logger diff --git a/lib/modules/blockchain_process/blockchain.js b/lib/modules/blockchain_process/blockchain.js index a2cd6c117..1c974110b 100644 --- a/lib/modules/blockchain_process/blockchain.js +++ b/lib/modules/blockchain_process/blockchain.js @@ -85,7 +85,7 @@ Blockchain.prototype.setupProxy = function() { return; } - const proxy = require('../../contracts/proxy'); + const proxy = require('./proxy'); const Ipc = require('../../core/ipc'); let ipcObject = new Ipc({ipcRole: 'client'}); diff --git a/lib/contracts/proxy.js b/lib/modules/blockchain_process/proxy.js similarity index 96% rename from lib/contracts/proxy.js rename to lib/modules/blockchain_process/proxy.js index ce3ed4b18..a16be5607 100644 --- a/lib/contracts/proxy.js +++ b/lib/modules/blockchain_process/proxy.js @@ -1,12 +1,12 @@ const httpProxy = require('http-proxy'); const http = require('http'); -const constants = require('../constants.json'); +const constants = require('../../constants.json'); let commList = {}; let transactions = {}; let receipts = {}; -const {canonicalHost, defaultHost} = require('../utils/host'); +const {canonicalHost, defaultHost} = require('../../utils/host'); const parseRequest = function(reqBody){ let jsonO; diff --git a/lib/cmds/simulator.js b/lib/modules/blockchain_process/simulator.js similarity index 86% rename from lib/cmds/simulator.js rename to lib/modules/blockchain_process/simulator.js index a1a4d3dd3..4ff64ab24 100644 --- a/lib/cmds/simulator.js +++ b/lib/modules/blockchain_process/simulator.js @@ -1,9 +1,9 @@ const path = require('path'); let shelljs = require('shelljs'); -let proxy = require('../contracts/proxy'); -const Ipc = require('../core/ipc'); -const constants = require('../constants.json'); -const {defaultHost, dockerHostSwap} = require('../utils/host'); +let proxy = require('./proxy'); +const Ipc = require('../../core/ipc'); +const constants = require('../../constants.json'); +const {defaultHost, dockerHostSwap} = require('../../utils/host'); class Simulator { constructor(options) { @@ -14,7 +14,7 @@ class Simulator { run(options) { let cmds = []; - const ganache = path.join(__dirname, '../../node_modules/.bin/ganache-cli'); + const ganache = path.join(__dirname, '../../../node_modules/.bin/ganache-cli'); let useProxy = this.blockchainConfig.proxy || false; let host = (dockerHostSwap(options.host || this.blockchainConfig.rpcHost) || defaultHost); @@ -36,7 +36,7 @@ class Simulator { let simulatorAccounts = this.blockchainConfig.simulatorAccounts || options.simulatorAccounts; if (simulatorAccounts && simulatorAccounts.length > 0) { let web3 = new (require('web3'))(); - let AccountParser = require('../utils/accountParser.js'); + let AccountParser = require('../../utils/accountParser.js'); let parsedAccounts = AccountParser.parseAccountsConfig(simulatorAccounts, web3, this.logger); parsedAccounts.forEach((account) => { let cmd = '--account="' + account.privateKey + ','+account.hexBalance + '"'; diff --git a/test_apps/test_app/package-lock.json b/test_apps/test_app/package-lock.json index e6062fb19..249e9136e 100644 --- a/test_apps/test_app/package-lock.json +++ b/test_apps/test_app/package-lock.json @@ -4,42 +4,68 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "asap": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" - }, - "babel-code-frame": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "@babel/code-frame": { + "version": "7.0.0-beta.56", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.56.tgz", + "integrity": "sha512-OBeGs8UXWpKl0oK2T5nUXNl2yu8RKxqL/7aUnMtKDXCU6VUrNP3npdrPivBA11HPB15TVI49nWf2lntTzoUuAg==", "dev": true, "requires": { - "chalk": "^1.1.3", + "@babel/highlight": "7.0.0-beta.56" + } + }, + "@babel/highlight": { + "version": "7.0.0-beta.56", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.56.tgz", + "integrity": "sha512-q4TfI+jJISul6vVpZJktzH4tupwRiVk6KXRhB8PHqJ7erl966I6ePDXl9mAbE8jMM7YswhnnB0j1SYP7LBVyhg==", + "dev": true, + "requires": { + "chalk": "^2.0.0", "esutils": "^2.0.2", - "js-tokens": "^3.0.2" + "js-tokens": "^3.0.0" }, "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", "dev": true + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } } } }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, "babel-runtime": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", @@ -66,24 +92,26 @@ "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-3.3.7.tgz", "integrity": "sha1-WjiTlFSfIzMIdaOxUGVldPip63E=" }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, "classnames": { "version": "2.2.6", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.6.tgz", "integrity": "sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==" }, + "color-convert": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", + "integrity": "sha512-3NUJZdhMhcdPn8vJ9v2UQJoH0qqoGUkYTgFEPZaPjEtwmmKUfNV46zZmgB2M5M4DCEQHMaCfWHCxiBflLm04Tg==", + "dev": true, + "requires": { + "color-name": "1.1.1" + } + }, + "color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=", + "dev": true + }, "core-js": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", @@ -92,7 +120,7 @@ "dom-helpers": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.3.1.tgz", - "integrity": "sha512-2Sm+JaYn74OiTM2wHvxJOo3roiq/h25Yi69Fqk269cNUwIXsCvATB6CRSFC9Am/20G2b28hGv/+7NiWydIrPvg==" + "integrity": "sha1-/BpOFf/fYN3eA6SAqcD+zoId1KY=" }, "dotenv": { "version": "4.0.0", @@ -154,14 +182,11 @@ "resolved": "https://registry.npmjs.org/haml/-/haml-0.4.3.tgz", "integrity": "sha1-90BTGPPC7dGXpIsbjysvE+C7U3g=" }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true }, "iconv-lite": { "version": "0.4.23", @@ -229,7 +254,7 @@ "node-fetch": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "integrity": "sha1-mA9vcthSEaU0fGsrwYxbhMPrR+8=", "requires": { "encoding": "^0.1.11", "is-stream": "^1.0.1" @@ -252,7 +277,7 @@ "promise": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", - "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "integrity": "sha1-BktyYCsY+Q8pGSuLG8QY/9Hr078=", "requires": { "asap": "~2.0.3" } @@ -289,7 +314,7 @@ "react-bootstrap": { "version": "0.32.1", "resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-0.32.1.tgz", - "integrity": "sha512-RbfzKUbsukWsToWqGHfCCyMFq9QQI0TznutdyxyJw6dih2NvIne25Mrssg8LZsprqtPpyQi8bN0L0Fx3fUsL8Q==", + "integrity": "sha1-YGJMG0ijnXc+9szmQhpPM+zBZrs=", "requires": { "babel-runtime": "^6.11.6", "classnames": "^2.2.5", @@ -329,7 +354,7 @@ "react-overlays": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-0.8.3.tgz", - "integrity": "sha512-h6GT3jgy90PgctleP39Yu3eK1v9vaJAW73GOA/UbN9dJ7aAN4BTZD6793eI1D5U+ukMk17qiqN/wl3diK1Z5LA==", + "integrity": "sha1-+tZe6lskMBzKGSoWn13dsLINOsU=", "requires": { "classnames": "^2.2.5", "dom-helpers": "^3.2.1", @@ -361,7 +386,7 @@ "regenerator-runtime": { "version": "0.11.1", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + "integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk=" }, "safer-buffer": { "version": "2.1.2", @@ -373,15 +398,6 @@ "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, "strip-hex-prefix": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz", @@ -390,12 +406,6 @@ "is-hex-prefixed": "1.0.0" } }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, "ua-parser-js": { "version": "0.7.18", "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.18.tgz", @@ -425,7 +435,7 @@ "zeppelin-solidity": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/zeppelin-solidity/-/zeppelin-solidity-1.8.0.tgz", - "integrity": "sha512-7Mxq6Y7EES0PSLrRF6v0EVYqBVRRo8hFrr7m3jEs69VbbQ5kpANzizeEdbP1/PWKSOmBOg208qP2vSA0FlzFLA==", + "integrity": "sha1-BJ/N59rqn8hSEPjG25+M0auKhTo=", "requires": { "dotenv": "^4.0.0", "ethjs-abi": "^0.2.1" From fa33ed33d837b50edd34a44ca43d2d046e6fcc04 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 7 Aug 2018 19:02:36 -0400 Subject: [PATCH 2/4] move template generator --- lib/index.js | 2 +- lib/{cmds => utils}/template_generator.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename lib/{cmds => utils}/template_generator.js (98%) diff --git a/lib/index.js b/lib/index.js index e404f2a2d..dc7883ac9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -51,7 +51,7 @@ class Embark { generateTemplate(templateName, destinationFolder, name, url) { this.context = [constants.contexts.templateGeneration]; - let TemplateGenerator = require('./cmds/template_generator.js'); + let TemplateGenerator = require('./utils/template_generator.js'); let templateGenerator = new TemplateGenerator(templateName); if (url) { diff --git a/lib/cmds/template_generator.js b/lib/utils/template_generator.js similarity index 98% rename from lib/cmds/template_generator.js rename to lib/utils/template_generator.js index 834ccd0ee..659d6a76d 100644 --- a/lib/cmds/template_generator.js +++ b/lib/utils/template_generator.js @@ -1,5 +1,5 @@ let fs = require('../core/fs.js'); -let utils = require('../utils/utils.js'); +let utils = require('./utils.js'); class TemplateGenerator { constructor(templateName) { From 4efc19d4bc96d392c7269b1e85f3589d4d827abd Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 8 Aug 2018 12:19:49 -0400 Subject: [PATCH 3/4] remove unneded space --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index dc7883ac9..a4fa2296e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -41,7 +41,7 @@ class Embark { simulator(options) { this.context = options.context || [constants.contexts.simulator, constants.contexts.blockchain]; - let Simulator = require('./modules/blockchain_process/simulator.js'); + let Simulator = require('./modules/blockchain_process/simulator.js'); let simulator = new Simulator({ blockchainConfig: this.config.blockchainConfig, logger: this.logger From 9697b963a02d4c02296e0284ff3a11239f981905 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 8 Aug 2018 12:37:22 -0400 Subject: [PATCH 4/4] update test --- test/template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/template.js b/test/template.js index dcbe9b23c..d86732691 100644 --- a/test/template.js +++ b/test/template.js @@ -1,6 +1,6 @@ /*globals describe, it*/ const assert = require('assert'); -const TemplateGenerator = require('../lib/cmds/template_generator'); +const TemplateGenerator = require('../lib/utils/template_generator'); describe('TemplateGenerator', function () { describe('getExternalProject', function () {