From 60ff0974063ac14984cbb98c7c4d88a1f300199f Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 29 Apr 2019 16:39:48 -0500 Subject: [PATCH] refactor(@embark/core): create embark-core package, move constants into embark-core --- packages/embark-core/.npmrc | 4 ++ packages/embark-core/README.md | 6 ++ .../src/lib => embark-core}/constants.json | 0 packages/embark-core/package.json | 67 +++++++++++++++++++ packages/embark-core/src/index.js | 1 + packages/embark-core/tsconfig.json | 4 ++ packages/embark-core/tslint.json | 3 + packages/embark-ens/src/index.js | 10 +-- packages/embark/package.json | 1 + packages/embark/src/cmd/cmd_controller.js | 2 +- packages/embark/src/lib/core/config.js | 2 +- packages/embark/src/lib/core/plugin.js | 2 +- .../src/lib/core/processes/eventsWrapper.js | 2 +- .../src/lib/core/processes/processLauncher.js | 2 +- .../src/lib/core/processes/processWrapper.js | 2 +- .../lib/modules/blockchain_connector/index.js | 2 +- .../modules/blockchain_connector/provider.js | 2 +- .../modules/blockchain_listener/dev_txs.js | 2 +- .../lib/modules/blockchain_listener/index.js | 2 +- .../modules/blockchain_process/blockchain.js | 2 +- .../blockchain_process/blockchainProcess.js | 2 +- .../blockchainProcessLauncher.js | 2 +- .../modules/blockchain_process/gethClient.js | 2 +- .../lib/modules/blockchain_process/index.js | 4 +- .../blockchain_process/parityClient.js | 2 +- .../lib/modules/blockchain_process/proxy.js | 4 +- .../modules/blockchain_process/simulator.js | 2 +- .../src/lib/modules/code_generator/index.js | 2 +- .../embark/src/lib/modules/console/index.ts | 2 +- .../lib/modules/contracts_manager/index.js | 2 +- .../src/lib/modules/deployment/index.js | 2 +- packages/embark/src/lib/modules/ipfs/index.js | 2 +- .../embark/src/lib/modules/ipfs/process.js | 10 +-- .../embark/src/lib/modules/pipeline/index.js | 2 +- .../lib/modules/pipeline/webpackProcess.js | 2 +- .../storage/storageProcessesLauncher.js | 2 +- .../embark/src/lib/modules/swarm/index.js | 2 +- .../embark/src/lib/modules/swarm/process.js | 2 +- .../embark/src/lib/modules/tests/index.js | 2 +- packages/embark/src/lib/modules/tests/test.js | 2 +- packages/embark/src/lib/utils/utils.js | 2 +- packages/embark/src/test/blockchain.js | 2 +- packages/embark/src/test/proxy.js | 2 +- packages/embark/src/test/utils.js | 2 +- 44 files changed, 129 insertions(+), 49 deletions(-) create mode 100644 packages/embark-core/.npmrc create mode 100644 packages/embark-core/README.md rename packages/{embark/src/lib => embark-core}/constants.json (100%) create mode 100644 packages/embark-core/package.json create mode 100644 packages/embark-core/src/index.js create mode 100644 packages/embark-core/tsconfig.json create mode 100644 packages/embark-core/tslint.json diff --git a/packages/embark-core/.npmrc b/packages/embark-core/.npmrc new file mode 100644 index 000000000..e031d3432 --- /dev/null +++ b/packages/embark-core/.npmrc @@ -0,0 +1,4 @@ +engine-strict = true +package-lock = false +save-exact = true +scripts-prepend-node-path = true diff --git a/packages/embark-core/README.md b/packages/embark-core/README.md new file mode 100644 index 000000000..e16eb17f7 --- /dev/null +++ b/packages/embark-core/README.md @@ -0,0 +1,6 @@ +# `embark-core` + +> Core library for Embark + +Visit [embark.status.im](https://embark.status.im/) to get started with +[Embark](https://github.com/embark-framework/embark). diff --git a/packages/embark/src/lib/constants.json b/packages/embark-core/constants.json similarity index 100% rename from packages/embark/src/lib/constants.json rename to packages/embark-core/constants.json diff --git a/packages/embark-core/package.json b/packages/embark-core/package.json new file mode 100644 index 000000000..92753af26 --- /dev/null +++ b/packages/embark-core/package.json @@ -0,0 +1,67 @@ +{ + "name": "embark-core", + "version": "4.1.0-beta.0", + "author": "Iuri Matias ", + "contributors": [], + "description": "Core library for Embark", + "homepage": "https://github.com/embark-framework/embark/tree/master/packages/embark-core#readme", + "bugs": "https://github.com/embark-framework/embark/issues", + "keywords": [ + "blockchain", + "dapps", + "ethereum", + "ipfs", + "serverless", + "solc", + "solidity" + ], + "files": [ + "constants.json", + "dist" + ], + "license": "MIT", + "repository": { + "directory": "packages/embark-core", + "type": "git", + "url": "https://github.com/embark-framework/embark.git" + }, + "main": "./dist/index.js", + "scripts": { + "build": "cross-env BABEL_ENV=node babel src --extensions \".js,.ts\" --out-dir dist --root-mode upward --source-maps", + "ci": "npm run qa", + "clean": "npm run reset", + "lint": "npm-run-all lint:*", + "lint:js": "eslint src/", + "// lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", + "package": "npm pack", + "// qa": "npm-run-all lint typecheck build package", + "qa": "npm-run-all lint build package", + "reset": "npx rimraf dist embark-*.tgz package", + "start": "npm run watch", + "// typecheck": "tsc", + "watch": "run-p watch:*", + "watch:build": "npm run build -- --verbose --watch", + "// watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + }, + "eslintConfig": { + "extends": "../../.eslintrc.json" + }, + "dependencies": { + "@babel/runtime-corejs2": "7.3.1" + }, + "devDependencies": { + "@babel/cli": "7.2.3", + "@babel/core": "7.2.2", + "cross-env": "5.2.0", + "eslint": "5.7.0", + "npm-run-all": "4.1.5", + "rimraf": "2.6.3", + "tslint": "5.11.0", + "typescript": "3.3.1" + }, + "engines": { + "node": ">=8.12.0", + "npm": ">=6.4.1", + "yarn": ">=1.12.3" + } +} diff --git a/packages/embark-core/src/index.js b/packages/embark-core/src/index.js new file mode 100644 index 000000000..f053ebf79 --- /dev/null +++ b/packages/embark-core/src/index.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/packages/embark-core/tsconfig.json b/packages/embark-core/tsconfig.json new file mode 100644 index 000000000..52d43eaaa --- /dev/null +++ b/packages/embark-core/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*"] +} diff --git a/packages/embark-core/tslint.json b/packages/embark-core/tslint.json new file mode 100644 index 000000000..0946f2096 --- /dev/null +++ b/packages/embark-core/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../../tslint.json" +} diff --git a/packages/embark-ens/src/index.js b/packages/embark-ens/src/index.js index bf6f3527a..8ed20a892 100644 --- a/packages/embark-ens/src/index.js +++ b/packages/embark-ens/src/index.js @@ -2,20 +2,14 @@ import {joinPath, hashTo32ByteHexString, soliditySha3, recursiveMerge, AddressUt const namehash = require('eth-ens-namehash'); const async = require('async'); const ENSFunctions = require('./ENSFunctions'); -// import {ens} from '../../constants'; TODO uncomment when we move constants +import {ens} from 'embark-core/constants.json'; import EmbarkJS, {Utils as embarkJsUtils} from 'embarkjs'; const ensConfig = require('./ensContractConfigs'); const secureSend = embarkJsUtils.secureSend; -const ensConstants = { - "whitelist": [ - "eth", - "xyz" - ] -}; const reverseAddrSuffix = '.addr.reverse'; const {ZERO_ADDRESS} = AddressUtils; -const ENS_WHITELIST = ensConstants.whitelist; +const ENS_WHITELIST = ens.whitelist; const NOT_REGISTERED_ERROR = 'Name not yet registered'; const MAINNET_ID = '1'; diff --git a/packages/embark/package.json b/packages/embark/package.json index 8a17822c2..f10650df1 100644 --- a/packages/embark/package.json +++ b/packages/embark/package.json @@ -93,6 +93,7 @@ "ejs": "2.6.1", "embark-authenticator": "^4.1.0-beta.0", "embark-compiler": "^4.0.0", + "embark-core": "^4.1.0-beta.0", "embark-ens": "^4.1.0-beta.0", "embark-logger": "^4.1.0-beta.0", "embark-process-logs-api": "^4.1.0-beta.0", diff --git a/packages/embark/src/cmd/cmd_controller.js b/packages/embark/src/cmd/cmd_controller.js index 2be1e98ad..432f14ffd 100644 --- a/packages/embark/src/cmd/cmd_controller.js +++ b/packages/embark/src/cmd/cmd_controller.js @@ -1,5 +1,5 @@ let async = require('async'); -const constants = require('../lib/constants'); +const constants = require('embark-core/constants'); const Logger = require('embark-logger'); const {reset: embarkReset, paths: defaultResetPaths} = require('embark-reset'); const fs = require('../lib/core/fs.js'); diff --git a/packages/embark/src/lib/core/config.js b/packages/embark/src/lib/core/config.js index 1cee0cab7..11574e9d8 100644 --- a/packages/embark/src/lib/core/config.js +++ b/packages/embark/src/lib/core/config.js @@ -4,7 +4,7 @@ const utils = require('../utils/utils.js'); const path = require('path'); const deepEqual = require('deep-equal'); const web3 = require('web3'); -const constants = require('../constants'); +const constants = require('embark-core/constants'); import {canonicalHost, defaultHost, recursiveMerge, AddressUtils} from 'embark-utils'; const cloneDeep = require('lodash.clonedeep'); const { replaceZeroAddressShorthand } = AddressUtils; diff --git a/packages/embark/src/lib/core/plugin.js b/packages/embark/src/lib/core/plugin.js index 2bdd4cd48..72a48f580 100644 --- a/packages/embark/src/lib/core/plugin.js +++ b/packages/embark/src/lib/core/plugin.js @@ -1,6 +1,6 @@ const utils = require('../utils/utils.js'); import {joinPath} from 'embark-utils'; -const constants = require('../constants'); +const constants = require('embark-core/constants'); const fs = require('./fs.js'); const deepEqual = require('deep-equal'); diff --git a/packages/embark/src/lib/core/processes/eventsWrapper.js b/packages/embark/src/lib/core/processes/eventsWrapper.js index 0eee1901d..2dba64b5f 100644 --- a/packages/embark/src/lib/core/processes/eventsWrapper.js +++ b/packages/embark/src/lib/core/processes/eventsWrapper.js @@ -1,5 +1,5 @@ const uuid = require('uuid/v1'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); class Events { diff --git a/packages/embark/src/lib/core/processes/processLauncher.js b/packages/embark/src/lib/core/processes/processLauncher.js index 37e199ee0..7ba92fb50 100644 --- a/packages/embark/src/lib/core/processes/processLauncher.js +++ b/packages/embark/src/lib/core/processes/processLauncher.js @@ -1,5 +1,5 @@ const child_process = require('child_process'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const path = require('path'); const ProcessLogsApi = require('embark-process-logs-api'); diff --git a/packages/embark/src/lib/core/processes/processWrapper.js b/packages/embark/src/lib/core/processes/processWrapper.js index 8c90d67a6..53846c2fd 100644 --- a/packages/embark/src/lib/core/processes/processWrapper.js +++ b/packages/embark/src/lib/core/processes/processWrapper.js @@ -2,7 +2,7 @@ process.on('uncaughtException', function(e) { process.send({error: e.stack}); }); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const Events = require('./eventsWrapper'); class ProcessWrapper { diff --git a/packages/embark/src/lib/modules/blockchain_connector/index.js b/packages/embark/src/lib/modules/blockchain_connector/index.js index ef1abcad9..86f47f0b9 100644 --- a/packages/embark/src/lib/modules/blockchain_connector/index.js +++ b/packages/embark/src/lib/modules/blockchain_connector/index.js @@ -3,7 +3,7 @@ const async = require('async'); const Provider = require('./provider.js'); const ethUtil = require('ethereumjs-util'); const utils = require('../../utils/utils'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const embarkJsUtils = require('embarkjs').Utils; const {bigNumberify} = require('ethers/utils/bignumber'); const RLP = require('ethers/utils/rlp'); diff --git a/packages/embark/src/lib/modules/blockchain_connector/provider.js b/packages/embark/src/lib/modules/blockchain_connector/provider.js index e86991857..db86e4524 100644 --- a/packages/embark/src/lib/modules/blockchain_connector/provider.js +++ b/packages/embark/src/lib/modules/blockchain_connector/provider.js @@ -1,7 +1,7 @@ const async = require('async'); const AccountParser = require('../../utils/accountParser'); const fundAccount = require('./fundAccount'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const Transaction = require('ethereumjs-tx'); const ethUtil = require('ethereumjs-util'); diff --git a/packages/embark/src/lib/modules/blockchain_listener/dev_txs.js b/packages/embark/src/lib/modules/blockchain_listener/dev_txs.js index d4d1f4f6c..ec851c2e6 100644 --- a/packages/embark/src/lib/modules/blockchain_listener/dev_txs.js +++ b/packages/embark/src/lib/modules/blockchain_listener/dev_txs.js @@ -1,6 +1,6 @@ const Web3 = require('web3'); const {buildUrl} = require('../../utils/utils.js'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); class DevTxs { constructor(options) { diff --git a/packages/embark/src/lib/modules/blockchain_listener/index.js b/packages/embark/src/lib/modules/blockchain_listener/index.js index ae5cfecbf..556336b29 100644 --- a/packages/embark/src/lib/modules/blockchain_listener/index.js +++ b/packages/embark/src/lib/modules/blockchain_listener/index.js @@ -1,7 +1,7 @@ const async = require('async'); const DevTxs = require('./dev_txs'); const ProcessLogsApi = require('embark-process-logs-api'); -const constants = require('../../constants.json'); +const constants = require('embark-core/constants'); const PROCESS_NAME = 'blockchain'; diff --git a/packages/embark/src/lib/modules/blockchain_process/blockchain.js b/packages/embark/src/lib/modules/blockchain_process/blockchain.js index 34144b7ec..e16994109 100644 --- a/packages/embark/src/lib/modules/blockchain_process/blockchain.js +++ b/packages/embark/src/lib/modules/blockchain_process/blockchain.js @@ -2,7 +2,7 @@ const async = require('async'); const {spawn, exec} = require('child_process'); const path = require('path'); const fs = require('../../core/fs.js'); -const constants = require('../../constants.json'); +const constants = require('embark-core/constants'); const utils = require('../../utils/utils.js'); const GethClient = require('./gethClient.js'); const ParityClient = require('./parityClient.js'); diff --git a/packages/embark/src/lib/modules/blockchain_process/blockchainProcess.js b/packages/embark/src/lib/modules/blockchain_process/blockchainProcess.js index e44d72223..a60c929b9 100644 --- a/packages/embark/src/lib/modules/blockchain_process/blockchainProcess.js +++ b/packages/embark/src/lib/modules/blockchain_process/blockchainProcess.js @@ -1,7 +1,7 @@ const ProcessWrapper = require('../../core/processes/processWrapper'); const BlockchainClient = require('./blockchain'); const i18n = require('../../core/i18n/i18n.js'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); let blockchainProcess; diff --git a/packages/embark/src/lib/modules/blockchain_process/blockchainProcessLauncher.js b/packages/embark/src/lib/modules/blockchain_process/blockchainProcessLauncher.js index 5c185ec0c..15c87b22f 100644 --- a/packages/embark/src/lib/modules/blockchain_process/blockchainProcessLauncher.js +++ b/packages/embark/src/lib/modules/blockchain_process/blockchainProcessLauncher.js @@ -1,6 +1,6 @@ const ProcessLauncher = require('../../core/processes/processLauncher'); import {joinPath} from 'embark-utils'; -const constants = require('../../constants'); +const constants = require('embark-core/constants'); class BlockchainProcessLauncher { diff --git a/packages/embark/src/lib/modules/blockchain_process/gethClient.js b/packages/embark/src/lib/modules/blockchain_process/gethClient.js index af3c21d36..a60d72817 100644 --- a/packages/embark/src/lib/modules/blockchain_process/gethClient.js +++ b/packages/embark/src/lib/modules/blockchain_process/gethClient.js @@ -4,7 +4,7 @@ const fs = require('../../core/fs'); const path = require('path'); const GethMiner = require('./miner'); const semver = require('semver'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const DEFAULTS = { "BIN": "geth", diff --git a/packages/embark/src/lib/modules/blockchain_process/index.js b/packages/embark/src/lib/modules/blockchain_process/index.js index 066dbd136..c85c39ab6 100644 --- a/packages/embark/src/lib/modules/blockchain_process/index.js +++ b/packages/embark/src/lib/modules/blockchain_process/index.js @@ -1,7 +1,7 @@ const async = require('async'); const utils = require('../../utils/utils.js'); const {normalizeInput} = require('embark-utils'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const BlockchainProcessLauncher = require('./blockchainProcessLauncher'); class BlockchainModule { @@ -140,7 +140,7 @@ class BlockchainModule { if(!this.blockchainProcess) { return cb(); } - + this.blockchainProcess.stopBlockchainNode(() => { this.logger.info(message); cb(); diff --git a/packages/embark/src/lib/modules/blockchain_process/parityClient.js b/packages/embark/src/lib/modules/blockchain_process/parityClient.js index 2d54c5ecd..fa91bda35 100644 --- a/packages/embark/src/lib/modules/blockchain_process/parityClient.js +++ b/packages/embark/src/lib/modules/blockchain_process/parityClient.js @@ -3,7 +3,7 @@ const fs = require('../../core/fs.js'); const path = require('path'); const os = require('os'); const semver = require('semver'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const DEFAULTS = { "BIN": "parity", diff --git a/packages/embark/src/lib/modules/blockchain_process/proxy.js b/packages/embark/src/lib/modules/blockchain_process/proxy.js index 4123a636c..746fe2743 100644 --- a/packages/embark/src/lib/modules/blockchain_process/proxy.js +++ b/packages/embark/src/lib/modules/blockchain_process/proxy.js @@ -3,7 +3,7 @@ require('./httpProxyOverride'); const Asm = require('stream-json/Assembler'); import {canonicalHost} from 'embark-utils'; -const constants = require('../../constants.json'); +const constants = require('embark-core/constants'); const {Duplex} = require('stream'); const http = require('http'); const httpProxy = require('http-proxy'); @@ -101,7 +101,7 @@ class Proxy { txSent: false }; timeout.timeoutId = setInterval(() => { - + if(timeout.txSent) { const message = `[${ws?"WS":"HTTP"} Request ID ${req.id}]: Original tx still not sent, considering it abandoned.`; this.consoleLog(`====================================================================\n${message}\n====================================================================`); diff --git a/packages/embark/src/lib/modules/blockchain_process/simulator.js b/packages/embark/src/lib/modules/blockchain_process/simulator.js index c9ffd4e07..4785b148b 100644 --- a/packages/embark/src/lib/modules/blockchain_process/simulator.js +++ b/packages/embark/src/lib/modules/blockchain_process/simulator.js @@ -3,7 +3,7 @@ const pkgUp = require('pkg-up'); let shelljs = require('shelljs'); let Proxy = require('./proxy'); const Ipc = require('../../core/ipc'); -const constants = require('../../constants.json'); +const constants = require('embark-core/constants'); import {defaultHost, dockerHostSwap} from 'embark-utils'; const fs = require('../../core/fs.js'); diff --git a/packages/embark/src/lib/modules/code_generator/index.js b/packages/embark/src/lib/modules/code_generator/index.js index c11261015..fbdafcd33 100644 --- a/packages/embark/src/lib/modules/code_generator/index.js +++ b/packages/embark/src/lib/modules/code_generator/index.js @@ -1,7 +1,7 @@ let async = require('async'); import {joinPath} from 'embark-utils'; import { transform } from "@babel/core"; -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const path = require('path'); require('ejs'); diff --git a/packages/embark/src/lib/modules/console/index.ts b/packages/embark/src/lib/modules/console/index.ts index abb05437e..6f68b3487 100644 --- a/packages/embark/src/lib/modules/console/index.ts +++ b/packages/embark/src/lib/modules/console/index.ts @@ -3,7 +3,7 @@ const env = require("../../core/env"); const utils = require("../../utils/utils"); const {escapeHtml, exit} = require("embark-utils"); import { Callback } from "embark"; -import constants from "../../constants.json"; +import constants from "embark-core/constants.json"; const stringify = require("json-stringify-safe"); import { waterfall } from "async"; import { Embark, Events } from "embark"; diff --git a/packages/embark/src/lib/modules/contracts_manager/index.js b/packages/embark/src/lib/modules/contracts_manager/index.js index 2cfbc49f8..d3f2254e8 100644 --- a/packages/embark/src/lib/modules/contracts_manager/index.js +++ b/packages/embark/src/lib/modules/contracts_manager/index.js @@ -2,7 +2,7 @@ let async = require('async'); const cloneDeep = require('clone-deep'); const path = require('path'); const utils = require('../../utils/utils.js'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); // TODO: create a contract object diff --git a/packages/embark/src/lib/modules/deployment/index.js b/packages/embark/src/lib/modules/deployment/index.js index 0448edd18..771391994 100644 --- a/packages/embark/src/lib/modules/deployment/index.js +++ b/packages/embark/src/lib/modules/deployment/index.js @@ -2,7 +2,7 @@ let async = require('async'); const ContractDeployer = require('./contract_deployer.js'); const cloneDeep = require('clone-deep'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); class DeployManager { constructor(embark, options) { diff --git a/packages/embark/src/lib/modules/ipfs/index.js b/packages/embark/src/lib/modules/ipfs/index.js index 9c09f59bd..e3ce408c1 100644 --- a/packages/embark/src/lib/modules/ipfs/index.js +++ b/packages/embark/src/lib/modules/ipfs/index.js @@ -3,7 +3,7 @@ const utils = require('../../utils/utils.js'); const IpfsApi = require('ipfs-api'); // TODO: not great, breaks module isolation const StorageProcessesLauncher = require('../storage/storageProcessesLauncher'); -const constants = require('../../constants.json'); +const constants = require('embark-core/constants'); class IPFS { diff --git a/packages/embark/src/lib/modules/ipfs/process.js b/packages/embark/src/lib/modules/ipfs/process.js index 6d765ffda..ac3c8990f 100644 --- a/packages/embark/src/lib/modules/ipfs/process.js +++ b/packages/embark/src/lib/modules/ipfs/process.js @@ -1,6 +1,6 @@ const child_process = require('child_process'); const ProcessWrapper = require('../../core/processes/processWrapper'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const async = require('async'); let ipfsProcess; // eslint-disable-line no-unused-vars @@ -47,7 +47,7 @@ class IPFSProcess extends ProcessWrapper { data = data.toString(); console.log(`IPFS error: ${data}`); // `ipfs daemon called`, but `ipfs init` had not been run yet - if(!self.initCalled && data.indexOf('no IPFS repo found') > -1) { + if(!self.initCalled && data.indexOf('no IPFS repo found') > -1) { self.initCalled = true; let ipfsInitChild = child_process.spawn(this.command, ['init']); self._bindChildEvents(ipfsInitChild); @@ -59,7 +59,7 @@ class IPFSProcess extends ProcessWrapper { // ipfs init just run, and we have a successful result // re-run `ipfs daemon` - if(self.initCalled && !self.readyCalled && data.indexOf('peer identity:') > -1) { + if(self.initCalled && !self.readyCalled && data.indexOf('peer identity:') > -1) { self.startIPFSDaemon(); } else if (!self.readyCalled && data.indexOf('Daemon is ready') > -1) { @@ -78,7 +78,7 @@ class IPFSProcess extends ProcessWrapper { if(err && err.indexOf(IPFS_DEFAULT_CONFIG_ERROR) === -1){ return console.error('Error getting IPFS CORS config: ', err); } - + if(self.corsConfigNeedsUpdate(corsConfig)){ // update IPFS cors config return self.updateCorsConfig(err => { @@ -174,7 +174,7 @@ class IPFSProcess extends ProcessWrapper { startIPFSDaemon() { const self = this; - + // spawn the daemon (muhaha) this.child = child_process.spawn(this.command, ['daemon']); diff --git a/packages/embark/src/lib/modules/pipeline/index.js b/packages/embark/src/lib/modules/pipeline/index.js index db92a6d61..b0beeca9f 100644 --- a/packages/embark/src/lib/modules/pipeline/index.js +++ b/packages/embark/src/lib/modules/pipeline/index.js @@ -3,7 +3,7 @@ const async = require('async'); const utils = require('../../utils/utils.js'); import {joinPath} from 'embark-utils'; const ProcessLauncher = require('../../core/processes/processLauncher'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const WebpackConfigReader = require('../pipeline/webpackConfigReader'); import LongRunningProcessTimer from '../../utils/longRunningProcessTimer'; diff --git a/packages/embark/src/lib/modules/pipeline/webpackProcess.js b/packages/embark/src/lib/modules/pipeline/webpackProcess.js index 9ff1b9942..18c12f296 100644 --- a/packages/embark/src/lib/modules/pipeline/webpackProcess.js +++ b/packages/embark/src/lib/modules/pipeline/webpackProcess.js @@ -1,4 +1,4 @@ -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const fs = require('../../core/fs'); const ProcessWrapper = require('../../core/processes/processWrapper'); const webpack = require('webpack'); diff --git a/packages/embark/src/lib/modules/storage/storageProcessesLauncher.js b/packages/embark/src/lib/modules/storage/storageProcessesLauncher.js index aec01516b..8e39e06e7 100644 --- a/packages/embark/src/lib/modules/storage/storageProcessesLauncher.js +++ b/packages/embark/src/lib/modules/storage/storageProcessesLauncher.js @@ -2,7 +2,7 @@ const shellJs = require('shelljs'); const utils = require('../../utils/utils'); import {joinPath, canonicalHost} from 'embark-utils'; const ProcessLauncher = require('../../core/processes/processLauncher'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const cloneDeep = require('lodash.clonedeep'); let References = { diff --git a/packages/embark/src/lib/modules/swarm/index.js b/packages/embark/src/lib/modules/swarm/index.js index 5305d23a4..c6b445f67 100644 --- a/packages/embark/src/lib/modules/swarm/index.js +++ b/packages/embark/src/lib/modules/swarm/index.js @@ -3,7 +3,7 @@ const utils = require('../../utils/utils.js'); const SwarmAPI = require('swarm-api'); // TODO: not great, breaks module isolation const StorageProcessesLauncher = require('../storage/storageProcessesLauncher'); -const constants = require('../../constants.json'); +const constants = require('embark-core/constants'); require('colors'); class Swarm { diff --git a/packages/embark/src/lib/modules/swarm/process.js b/packages/embark/src/lib/modules/swarm/process.js index 554c2c890..ed7f9b300 100644 --- a/packages/embark/src/lib/modules/swarm/process.js +++ b/packages/embark/src/lib/modules/swarm/process.js @@ -1,6 +1,6 @@ const child_process = require('child_process'); const ProcessWrapper = require('../../core/processes/processWrapper'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const fs = require('../../core/fs'); let swarmProcess; diff --git a/packages/embark/src/lib/modules/tests/index.js b/packages/embark/src/lib/modules/tests/index.js index c698f766b..58b1af11b 100644 --- a/packages/embark/src/lib/modules/tests/index.js +++ b/packages/embark/src/lib/modules/tests/index.js @@ -7,7 +7,7 @@ const assert = require('assert'); const Test = require('./test'); const {EmbarkSpec, EmbarkApiSpec} = require('./reporter'); const SolcTest = require('./solc_test'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); class TestRunner { constructor(embark, options) { diff --git a/packages/embark/src/lib/modules/tests/test.js b/packages/embark/src/lib/modules/tests/test.js index cb4b9be50..7bbcf4c4b 100644 --- a/packages/embark/src/lib/modules/tests/test.js +++ b/packages/embark/src/lib/modules/tests/test.js @@ -3,7 +3,7 @@ import * as utilsContractsConfig from "../../utils/contractsConfig"; const async = require('async'); const AccountParser = require('../../utils/accountParser'); const utils = require('../../utils/utils'); -const constants = require('../../constants'); +const constants = require('embark-core/constants'); const web3Utils = require('web3-utils'); const BALANCE_10_ETHER_IN_HEX = '0x8AC7230489E80000'; diff --git a/packages/embark/src/lib/utils/utils.js b/packages/embark/src/lib/utils/utils.js index 99ea9b614..6885bd107 100644 --- a/packages/embark/src/lib/utils/utils.js +++ b/packages/embark/src/lib/utils/utils.js @@ -188,7 +188,7 @@ function proposeAlternative(word, _dictionary, _exceptions) { } function getExternalContractUrl(file,providerUrl) { - const constants = require('../constants'); + const constants = require('embark-core/constants'); let url; const RAW_URL = 'https://raw.githubusercontent.com/'; const DEFAULT_SWARM_GATEWAY = 'https://swarm-gateways.net/'; diff --git a/packages/embark/src/test/blockchain.js b/packages/embark/src/test/blockchain.js index a62b04cf1..b0e4fca65 100644 --- a/packages/embark/src/test/blockchain.js +++ b/packages/embark/src/test/blockchain.js @@ -1,6 +1,6 @@ /*globals describe, it*/ const Blockchain = require('../lib/modules/blockchain_process/blockchain.js'); -const constants = require('../lib/constants.json'); +const constants = require('embark-core/constants'); import {defaultHost} from 'embark-utils'; const path = require('path'); const fs = require('../lib/core/fs.js'); diff --git a/packages/embark/src/test/proxy.js b/packages/embark/src/test/proxy.js index f700e94d8..5c35a91bd 100644 --- a/packages/embark/src/test/proxy.js +++ b/packages/embark/src/test/proxy.js @@ -5,7 +5,7 @@ const { const sinon = require('sinon'); let IPC = require('../lib/core/ipc.js'); let Proxy = require('../lib/modules/blockchain_process/proxy'); -const constants = require('../lib/constants'); +const constants = require('embark-core/constants'); describe('embark.Proxy', function () { let ipc, proxy, ipcRequests; diff --git a/packages/embark/src/test/utils.js b/packages/embark/src/test/utils.js index bb9d438a2..f25e3ff05 100644 --- a/packages/embark/src/test/utils.js +++ b/packages/embark/src/test/utils.js @@ -1,7 +1,7 @@ /*global describe, it*/ const Utils = require('../lib/utils/utils'); const assert = require('assert'); -const constants = require('../lib/constants'); +const constants = require('embark-core/constants'); describe('embark.utils', function () { describe('#getExternalContractUrl', function () {