From 3df7f81732c598cb985d1eba72559fbc681aff84 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Thu, 16 May 2019 12:03:19 +0200 Subject: [PATCH] refactor: move `dappPath`, `ipcPath` and `embarkPath` into @embark/utils --- packages/embark-api/package.json | 1 - packages/embark-api/src/server.ts | 2 +- .../embark-blockchain-connector/src/index.js | 3 +- .../src/provider.js | 3 +- .../embark-blockchain-listener/src/index.js | 2 +- .../src/blockchain.js | 4 +-- .../src/gethClient.js | 2 +- .../embark-blockchain-process/src/miner.js | 2 +- .../src/parityClient.js | 2 +- .../src/simulator.js | 5 ++-- packages/embark-code-generator/src/index.js | 3 +- packages/embark-console-listener/src/index.js | 3 +- packages/embark-console/src/lib/index.ts | 3 +- .../embark-contracts-manager/src/index.js | 3 +- packages/embark-core/index.d.ts | 3 -- packages/embark-core/src/index.js | 2 -- packages/embark-core/src/ipc.js | 2 +- packages/embark-core/src/utils.js | 28 ----------------- packages/embark-deploy-tracker/src/index.js | 3 +- packages/embark-ens/package.json | 1 + packages/embark-library-manager/package.json | 2 +- packages/embark-library-manager/src/index.js | 2 +- packages/embark-pipeline/src/index.js | 4 +-- .../src/webpackConfigReader.js | 3 +- .../embark-pipeline/src/webpackProcess.js | 4 +-- packages/embark-scaffolding/package.json | 1 - .../contractLanguage/solidityBuilder/index.ts | 2 +- .../src/framework/reactBuilder/index.ts | 7 ++--- packages/embark-solidity/src/solcW.js | 4 +-- packages/embark-test-runner/package.json | 1 - packages/embark-test-runner/src/index.js | 3 +- packages/embark-utils/src/index.js | 30 +++++++++++++++++++ packages/embark-watcher/package.json | 4 +-- packages/embark-watcher/src/index.js | 2 +- packages/embark-webserver/src/server.js | 3 +- packages/embark/src/cmd/cmd_controller.js | 2 +- packages/embark/src/lib/core/config.js | 2 +- packages/embark/src/lib/core/file.ts | 2 +- packages/embark/src/lib/core/plugin.js | 3 +- packages/embark/src/lib/core/plugins.js | 2 +- .../embark/src/lib/modules/coverage/index.ts | 2 +- packages/embark/src/lib/modules/ipfs/index.js | 3 +- .../embark/src/lib/modules/swarm/process.js | 3 +- .../src/lib/utils/solidity/remapImports.ts | 2 +- .../src/lib/utils/template_generator.js | 3 +- packages/embark/src/test/accountParser.js | 3 +- packages/embark/src/test/blockchain.js | 3 +- packages/embark/src/test/config.js | 2 +- packages/embark/src/test/file.js | 2 +- .../src/test/modules/solidity/remapImports.js | 2 +- packages/embark/src/test/vm_fs.js | 2 +- packages/embarkjs-connector-web3/index.js | 2 +- packages/embarkjs-connector-web3/package.json | 2 +- 53 files changed, 85 insertions(+), 106 deletions(-) delete mode 100644 packages/embark-core/src/utils.js diff --git a/packages/embark-api/package.json b/packages/embark-api/package.json index b99503fa4..494eb0798 100644 --- a/packages/embark-api/package.json +++ b/packages/embark-api/package.json @@ -44,7 +44,6 @@ "@babel/runtime-corejs2": "7.3.1", "colors": "1.3.2", "embark-async-wrapper": "^4.1.0-beta.1", - "embark-core": "^4.1.0-beta.1", "embark-i18n": "^4.1.0-beta.1", "embark-utils": "^4.1.0-beta.1" }, diff --git a/packages/embark-api/src/server.ts b/packages/embark-api/src/server.ts index c614caefb..d792a9fa6 100644 --- a/packages/embark-api/src/server.ts +++ b/packages/embark-api/src/server.ts @@ -2,8 +2,8 @@ import bodyParser from "body-parser"; import "colors"; import cors from "cors"; import {Embark, Plugins} /* supplied by @types/embark in packages/embark-typings */ from "embark"; -import { embarkPath } from "embark-core"; import { __ } from "embark-i18n"; +import { embarkPath } from "embark-utils"; import express, {NextFunction, Request, Response} from "express"; import expressWs from "express-ws"; import findUp from "find-up"; diff --git a/packages/embark-blockchain-connector/src/index.js b/packages/embark-blockchain-connector/src/index.js index 426757468..296060cc6 100644 --- a/packages/embark-blockchain-connector/src/index.js +++ b/packages/embark-blockchain-connector/src/index.js @@ -1,4 +1,3 @@ -import { dappPath } from 'embark-core'; import { __ } from 'embark-i18n'; const Web3 = require('web3'); const async = require('async'); @@ -8,7 +7,7 @@ const constants = require('embark-core/constants'); const embarkJsUtils = require('embarkjs').Utils; const {bigNumberify} = require('ethers/utils/bignumber'); const RLP = require('ethers/utils/rlp'); -import { buildUrl } from 'embark-utils'; +import { buildUrl, dappPath } from 'embark-utils'; const WEB3_READY = 'blockchain:ready'; diff --git a/packages/embark-blockchain-connector/src/provider.js b/packages/embark-blockchain-connector/src/provider.js index 4ab3ff494..f31d18107 100644 --- a/packages/embark-blockchain-connector/src/provider.js +++ b/packages/embark-blockchain-connector/src/provider.js @@ -1,7 +1,6 @@ -import { dappPath } from 'embark-core'; import { __ } from 'embark-i18n'; const async = require('async'); -const { AccountParser } = require('embark-utils'); +const { AccountParser, dappPath } = require('embark-utils'); const fundAccount = require('./fundAccount'); const constants = require('embark-core/constants'); const Transaction = require('ethereumjs-tx'); diff --git a/packages/embark-blockchain-listener/src/index.js b/packages/embark-blockchain-listener/src/index.js index 541118f64..f306325bd 100644 --- a/packages/embark-blockchain-listener/src/index.js +++ b/packages/embark-blockchain-listener/src/index.js @@ -1,4 +1,4 @@ -import { dappPath } from 'embark-core'; +import { dappPath } from 'embark-utils'; import { __ } from 'embark-i18n'; const async = require('async'); const DevTxs = require('./dev_txs'); diff --git a/packages/embark-blockchain-process/src/blockchain.js b/packages/embark-blockchain-process/src/blockchain.js index 135bf73d5..69fab8665 100644 --- a/packages/embark-blockchain-process/src/blockchain.js +++ b/packages/embark-blockchain-process/src/blockchain.js @@ -7,9 +7,9 @@ const constants = require('embark-core/constants'); const GethClient = require('./gethClient.js'); const ParityClient = require('./parityClient.js'); import { Proxy } from './proxy'; -import { IPC, dappPath, embarkPath } from 'embark-core'; +import { IPC } from 'embark-core'; -import { compact, defaultHost, dockerHostSwap, AccountParser} from 'embark-utils'; +import { compact, dappPath, defaultHost, dockerHostSwap, embarkPath, AccountParser} from 'embark-utils'; const Logger = require('embark-logger'); // time between IPC connection attempts (in ms) diff --git a/packages/embark-blockchain-process/src/gethClient.js b/packages/embark-blockchain-process/src/gethClient.js index 41d180766..a311f890f 100644 --- a/packages/embark-blockchain-process/src/gethClient.js +++ b/packages/embark-blockchain-process/src/gethClient.js @@ -1,5 +1,5 @@ import { __ } from 'embark-i18n'; -import { dappPath, ipcPath } from 'embark-core'; +import { dappPath, ipcPath } from 'embark-utils'; const async = require('async'); const {exec, spawn} = require('child_process'); const path = require('path'); diff --git a/packages/embark-blockchain-process/src/miner.js b/packages/embark-blockchain-process/src/miner.js index 55c09bffb..6513fdfd1 100644 --- a/packages/embark-blockchain-process/src/miner.js +++ b/packages/embark-blockchain-process/src/miner.js @@ -1,7 +1,7 @@ const async = require('async'); const NetcatClient = require('netcat/client'); -import { ipcPath } from 'embark-core'; +import { ipcPath } from 'embark-utils'; //Constants const minerStart = 'miner_start'; diff --git a/packages/embark-blockchain-process/src/parityClient.js b/packages/embark-blockchain-process/src/parityClient.js index 529d24620..bc6c97a72 100644 --- a/packages/embark-blockchain-process/src/parityClient.js +++ b/packages/embark-blockchain-process/src/parityClient.js @@ -1,5 +1,5 @@ import { __ } from 'embark-i18n'; -import { dappPath } from 'embark-core'; +import { dappPath } from 'embark-utils'; import * as fs from 'fs-extra'; const async = require('async'); const path = require('path'); diff --git a/packages/embark-blockchain-process/src/simulator.js b/packages/embark-blockchain-process/src/simulator.js index 3a03af98f..8c58ea386 100644 --- a/packages/embark-blockchain-process/src/simulator.js +++ b/packages/embark-blockchain-process/src/simulator.js @@ -2,10 +2,9 @@ const path = require('path'); const pkgUp = require('pkg-up'); let shelljs = require('shelljs'); import { Proxy } from './proxy'; -import { IPC, embarkPath, dappPath } from 'embark-core'; +import { IPC } from 'embark-core'; const constants = require('embark-core/constants'); -import { defaultHost, dockerHostSwap } from 'embark-utils'; -const { AccountParser } = require('embark-utils'); +import { AccountParser, dappPath, defaultHost, dockerHostSwap, embarkPath } from 'embark-utils'; export class Simulator { constructor(options) { diff --git a/packages/embark-code-generator/src/index.js b/packages/embark-code-generator/src/index.js index 8013c72bf..f0279bab6 100644 --- a/packages/embark-code-generator/src/index.js +++ b/packages/embark-code-generator/src/index.js @@ -1,6 +1,5 @@ import { __ } from 'embark-i18n'; -import { dappPath, embarkPath } from 'embark-core'; -import { joinPath } from 'embark-utils'; +import { dappPath, embarkPath, joinPath } from 'embark-utils'; import * as fs from 'fs-extra'; import { transform } from "@babel/core"; const async = require('async'); diff --git a/packages/embark-console-listener/src/index.js b/packages/embark-console-listener/src/index.js index 5b99a1d47..ec844160a 100644 --- a/packages/embark-console-listener/src/index.js +++ b/packages/embark-console-listener/src/index.js @@ -1,7 +1,6 @@ const async = require('async'); -import { dappPath } from 'embark-core'; import { __ } from 'embark-i18n'; -import { getAddressToContract, getTransactionParams, hexToNumber } from 'embark-utils'; +import { dappPath, getAddressToContract, getTransactionParams, hexToNumber } from 'embark-utils'; class ConsoleListener { constructor(embark, options) { diff --git a/packages/embark-console/src/lib/index.ts b/packages/embark-console/src/lib/index.ts index bef922fd8..4270ddaa8 100644 --- a/packages/embark-console/src/lib/index.ts +++ b/packages/embark-console/src/lib/index.ts @@ -1,10 +1,9 @@ import { waterfall } from "async"; import chalk from "chalk"; import { Callback, Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark"; -import { dappPath } from "embark-core"; import constants from "embark-core/constants.json"; import { __ } from "embark-i18n"; -import { escapeHtml, exit, jsonFunctionReplacer } from "embark-utils"; +import { dappPath, escapeHtml, exit, jsonFunctionReplacer } from "embark-utils"; import stringify from "json-stringify-safe"; import { dirname } from "path"; import Suggestions from "./suggestions"; diff --git a/packages/embark-contracts-manager/src/index.js b/packages/embark-contracts-manager/src/index.js index 54decd3c5..c45ad64a9 100644 --- a/packages/embark-contracts-manager/src/index.js +++ b/packages/embark-contracts-manager/src/index.js @@ -1,10 +1,9 @@ -import { dappPath } from 'embark-core'; import { __ } from 'embark-i18n'; const async = require('async'); const cloneDeep = require('clone-deep'); const constants = require('embark-core/constants'); const path = require('path'); -const {proposeAlternative, toposort} = require('embark-utils'); +const { dappPath, proposeAlternative, toposort } = require('embark-utils'); // TODO: create a contract object diff --git a/packages/embark-core/index.d.ts b/packages/embark-core/index.d.ts index a8a44d038..7d0f3d77e 100644 --- a/packages/embark-core/index.d.ts +++ b/packages/embark-core/index.d.ts @@ -1,5 +1,2 @@ declare module "embark-core" { - function dappPath(...names: string[]): string; - function embarkPath(...names: string[]): string; - function ipcPath(basename: string, usePipePathOnWindows?: boolean): string; } diff --git a/packages/embark-core/src/index.js b/packages/embark-core/src/index.js index 8629b0ab4..11d96aec9 100644 --- a/packages/embark-core/src/index.js +++ b/packages/embark-core/src/index.js @@ -3,5 +3,3 @@ export { ProcessManager } from './processes/processManager'; export { ProcessWrapper } from './processes/processWrapper'; export { IPC } from './ipc'; - -export { embarkPath, dappPath, ipcPath } from './utils'; diff --git a/packages/embark-core/src/ipc.js b/packages/embark-core/src/ipc.js index 668b86c10..c4c7ae9b2 100644 --- a/packages/embark-core/src/ipc.js +++ b/packages/embark-core/src/ipc.js @@ -4,7 +4,7 @@ const ipc = require('node-ipc'); const {parse, stringify} = require('flatted/cjs'); const path = require('path'); const fs = require('fs-extra'); -import { ipcPath } from './utils'; +import { ipcPath } from 'embark-utils'; const EMBARK = 'embark'; diff --git a/packages/embark-core/src/utils.js b/packages/embark-core/src/utils.js deleted file mode 100644 index 82771c078..000000000 --- a/packages/embark-core/src/utils.js +++ /dev/null @@ -1,28 +0,0 @@ -import * as path from 'path'; -import {joinPath, sha512, tmpDir} from 'embark-utils'; - -export function dappPath(...names) { - const DAPP_PATH = process.env.DAPP_PATH || process.cwd(); - return path.join(DAPP_PATH, ...names); -} - -export function ipcPath(basename, usePipePathOnWindows = false) { - if (!(basename && typeof basename === 'string')) { - throw new TypeError('first argument must be a non-empty string'); - } - if (process.platform === 'win32' && usePipePathOnWindows) { - return `\\\\.\\pipe\\${basename}`; - } - return joinPath( - tmpDir(`embark-${sha512(dappPath()).slice(0, 8)}`), - basename - ); -} - -export function embarkPath(...names) { - const EMBARK_PATH = process.env.EMBARK_PATH; - if (!EMBARK_PATH) { - throw new Error('environment variable EMBARK_PATH was not set'); - } - return path.join(EMBARK_PATH, ...names); -} diff --git a/packages/embark-deploy-tracker/src/index.js b/packages/embark-deploy-tracker/src/index.js index ff85699d4..b79ad0a21 100644 --- a/packages/embark-deploy-tracker/src/index.js +++ b/packages/embark-deploy-tracker/src/index.js @@ -1,6 +1,5 @@ -import { dappPath } from 'embark-core'; import { __ } from 'embark-i18n'; -import { sha3 } from 'embark-utils'; +import { dappPath, sha3 } from 'embark-utils'; import * as fs from 'fs-extra'; class DeployTracker { diff --git a/packages/embark-ens/package.json b/packages/embark-ens/package.json index 208956aec..bba0f8bbc 100644 --- a/packages/embark-ens/package.json +++ b/packages/embark-ens/package.json @@ -49,6 +49,7 @@ "dependencies": { "@babel/runtime-corejs2": "7.3.1", "async": "^2.6.1", + "embark-core": "^4.1.0-beta.1", "embark-i18n": "^4.1.0-beta.1", "embark-utils": "^4.1.0-beta.1", "embarkjs": "^4.1.0-beta.1", diff --git a/packages/embark-library-manager/package.json b/packages/embark-library-manager/package.json index ee913d0c1..74c8954b7 100644 --- a/packages/embark-library-manager/package.json +++ b/packages/embark-library-manager/package.json @@ -48,7 +48,7 @@ "dependencies": { "@babel/runtime-corejs2": "7.3.1", "colors": "1.3.2", - "embark-core": "^4.1.0-beta.1", + "embark-utils": "^4.1.0-beta.1", "embark-i18n": "^4.1.0-beta.1", "live-plugin-manager-git-fix": "0.12.1" }, diff --git a/packages/embark-library-manager/src/index.js b/packages/embark-library-manager/src/index.js index 0d4e47677..bb29c2c4e 100644 --- a/packages/embark-library-manager/src/index.js +++ b/packages/embark-library-manager/src/index.js @@ -1,5 +1,5 @@ -import { dappPath, embarkPath } from 'embark-core'; import { __ } from 'embark-i18n'; +import { dappPath, embarkPath } from 'embark-utils'; var Npm = require('./npm.js'); class LibraryManager { diff --git a/packages/embark-pipeline/src/index.js b/packages/embark-pipeline/src/index.js index 7fe6e66e5..a8bcc9088 100644 --- a/packages/embark-pipeline/src/index.js +++ b/packages/embark-pipeline/src/index.js @@ -1,8 +1,8 @@ const path = require('path'); const async = require('async'); import { __ } from 'embark-i18n'; -import { joinPath, LongRunningProcessTimer, fileTreeSort } from 'embark-utils'; -import { dappPath, ProcessLauncher } from 'embark-core'; +import { dappPath, joinPath, LongRunningProcessTimer, fileTreeSort } from 'embark-utils'; +import { ProcessLauncher } from 'embark-core'; const constants = require('embark-core/constants'); const WebpackConfigReader = require('./webpackConfigReader'); diff --git a/packages/embark-pipeline/src/webpackConfigReader.js b/packages/embark-pipeline/src/webpackConfigReader.js index 5e55ca16f..db5b7e0c0 100644 --- a/packages/embark-pipeline/src/webpackConfigReader.js +++ b/packages/embark-pipeline/src/webpackConfigReader.js @@ -1,5 +1,4 @@ -import { dappPath } from 'embark-core'; -import { errorMessage } from 'embark-utils'; +import { dappPath, errorMessage } from 'embark-utils'; const fs = require('fs-extra'); import * as path from 'path'; diff --git a/packages/embark-pipeline/src/webpackProcess.js b/packages/embark-pipeline/src/webpackProcess.js index ea77b216e..f6d246f7f 100644 --- a/packages/embark-pipeline/src/webpackProcess.js +++ b/packages/embark-pipeline/src/webpackProcess.js @@ -1,5 +1,5 @@ -import { dappPath, ProcessWrapper } from 'embark-core'; -import { errorMessage } from 'embark-utils'; +import { ProcessWrapper } from 'embark-core'; +import { dappPath, errorMessage } from 'embark-utils'; const constants = require('embark-core/constants'); const webpack = require('webpack'); const writeFile = require('util').promisify(require('fs').writeFile); diff --git a/packages/embark-scaffolding/package.json b/packages/embark-scaffolding/package.json index fe6475fbe..31f9cef60 100644 --- a/packages/embark-scaffolding/package.json +++ b/packages/embark-scaffolding/package.json @@ -42,7 +42,6 @@ }, "dependencies": { "@babel/runtime-corejs2": "7.3.1", - "embark-core": "^4.1.0-beta.1", "embark-i18n": "^4.1.0-beta.1", "embark-utils": "^4.1.0-beta.1" }, diff --git a/packages/embark-scaffolding/src/contractLanguage/solidityBuilder/index.ts b/packages/embark-scaffolding/src/contractLanguage/solidityBuilder/index.ts index 8ecc08439..4073b42af 100644 --- a/packages/embark-scaffolding/src/contractLanguage/solidityBuilder/index.ts +++ b/packages/embark-scaffolding/src/contractLanguage/solidityBuilder/index.ts @@ -1,6 +1,6 @@ import { Embark } /* supplied by @types/embark in packages/embark-typings */ from "embark"; -import { dappPath } from "embark-core"; import { __ } from "embark-i18n"; +import { dappPath } from "embark-utils"; import Handlebars from "handlebars"; import * as path from "path"; import { Builder } from "../../builder"; diff --git a/packages/embark-scaffolding/src/framework/reactBuilder/index.ts b/packages/embark-scaffolding/src/framework/reactBuilder/index.ts index 284d42b3e..9bb4e8880 100644 --- a/packages/embark-scaffolding/src/framework/reactBuilder/index.ts +++ b/packages/embark-scaffolding/src/framework/reactBuilder/index.ts @@ -1,5 +1,4 @@ import { Contract, Embark } /* supplied by @types/embark in packages/embark-typings */ from "embark"; -import { dappPath } from "embark-core"; import { __ } from "embark-i18n"; import Handlebars from "handlebars"; import * as path from "path"; @@ -46,7 +45,7 @@ export class ReactBuilder implements Builder { } private updateEmbarkJson(contractName: string, files: string[]) { - const embarkJsonPath = path.join(dappPath(), "embark.json"); + const embarkJsonPath = path.join(utils.dappPath(), "embark.json"); const embarkJson = this.embark.fs.readJSONSync(embarkJsonPath); embarkJson.app[`js/${contractName}.js`] = `app/${contractName}.js`; embarkJson.app[`${contractName}.html`] = `app/${contractName}.html`; @@ -129,8 +128,8 @@ export class ReactBuilder implements Builder { } private saveFiles(contractName: string, indexCode: string, dappCode: string) { - const indexFilePath = path.join(dappPath(), "app", `${contractName}.html`); - const dappFilePath = path.join(dappPath(), "app", `${contractName}.js`); + const indexFilePath = path.join(utils.dappPath(), "app", `${contractName}.html`); + const dappFilePath = path.join(utils.dappPath(), "app", `${contractName}.js`); if (!this.options.overwrite && (this.embark.fs.existsSync(indexFilePath) || this.embark.fs.existsSync(dappFilePath))) { return []; diff --git a/packages/embark-solidity/src/solcW.js b/packages/embark-solidity/src/solcW.js index 06d2db83d..f310e6751 100644 --- a/packages/embark-solidity/src/solcW.js +++ b/packages/embark-solidity/src/solcW.js @@ -1,6 +1,6 @@ import { __ } from 'embark-i18n'; -import { dappPath, ProcessLauncher } from 'embark-core'; -import {joinPath} from 'embark-utils'; +import { ProcessLauncher } from 'embark-core'; +import { dappPath, joinPath } from 'embark-utils'; const uuid = require('uuid/v1'); class SolcW { diff --git a/packages/embark-test-runner/package.json b/packages/embark-test-runner/package.json index 44f3f75ad..b17d404e9 100644 --- a/packages/embark-test-runner/package.json +++ b/packages/embark-test-runner/package.json @@ -48,7 +48,6 @@ "dependencies": { "@babel/runtime-corejs2": "7.3.1", "async": "2.6.1", - "embark-core": "^4.1.0-beta.1", "embark-i18n": "^4.1.0-beta.1", "embark-utils": "^4.1.0-beta.1", "fs-extra": "7.0.1", diff --git a/packages/embark-test-runner/src/index.js b/packages/embark-test-runner/src/index.js index 4e0c6d330..4b86859fe 100644 --- a/packages/embark-test-runner/src/index.js +++ b/packages/embark-test-runner/src/index.js @@ -1,9 +1,8 @@ -import { dappPath, embarkPath } from 'embark-core'; import { __ } from 'embark-i18n'; const async = require('async'); const Mocha = require('mocha'); const path = require('path'); -const { runCmd, timer } = require('embark-utils'); +const { dappPath, embarkPath, runCmd, timer } = require('embark-utils'); const assert = require('assert'); const Test = require('./test'); const {EmbarkSpec, EmbarkApiSpec} = require('./reporter'); diff --git a/packages/embark-utils/src/index.js b/packages/embark-utils/src/index.js index 54639eab0..9f21947a0 100644 --- a/packages/embark-utils/src/index.js +++ b/packages/embark-utils/src/index.js @@ -254,11 +254,41 @@ function errorMessage(e) { return e; } +function dappPath(...names) { + const DAPP_PATH = process.env.DAPP_PATH || process.cwd(); + return path.join(DAPP_PATH, ...names); +} + +function ipcPath(basename, usePipePathOnWindows = false) { + if (!(basename && typeof basename === 'string')) { + throw new TypeError('first argument must be a non-empty string'); + } + if (process.platform === 'win32' && usePipePathOnWindows) { + return `\\\\.\\pipe\\${basename}`; + } + return joinPath( + tmpDir(`embark-${sha512(dappPath()).slice(0, 8)}`), + basename + ); +} + +function embarkPath(...names) { + const EMBARK_PATH = process.env.EMBARK_PATH; + if (!EMBARK_PATH) { + throw new Error('environment variable EMBARK_PATH was not set'); + } + return path.join(EMBARK_PATH, ...names); +} + + const Utils = { buildUrl, buildUrlFromConfig, joinPath, tmpDir, + ipcPath, + dappPath, + embarkPath, jsonFunctionReplacer, fuzzySearch, canonicalHost, diff --git a/packages/embark-watcher/package.json b/packages/embark-watcher/package.json index 26f5b2bfb..841692a7a 100644 --- a/packages/embark-watcher/package.json +++ b/packages/embark-watcher/package.json @@ -48,8 +48,8 @@ "dependencies": { "@babel/runtime-corejs2": "7.3.1", "chokidar": "2.0.4", - "embark-core": "^4.1.0-beta.1", - "embark-i18n": "^4.1.0-beta.1" + "embark-i18n": "^4.1.0-beta.1", + "embark-utils": "^4.1.0-beta.1" }, "devDependencies": { "@babel/cli": "7.2.3", diff --git a/packages/embark-watcher/src/index.js b/packages/embark-watcher/src/index.js index 5f6078f65..98bbd49fe 100644 --- a/packages/embark-watcher/src/index.js +++ b/packages/embark-watcher/src/index.js @@ -1,5 +1,5 @@ -import { dappPath } from 'embark-core'; import { __ } from 'embark-i18n'; +import { dappPath } from 'embark-utils'; let chokidar = require('chokidar'); let path = require('path'); diff --git a/packages/embark-webserver/src/server.js b/packages/embark-webserver/src/server.js index 3d6f15d77..75e3abe87 100644 --- a/packages/embark-webserver/src/server.js +++ b/packages/embark-webserver/src/server.js @@ -1,8 +1,7 @@ -import { dappPath } from 'embark-core'; const async = require('async'); let serveStatic = require('serve-static'); import { __ } from 'embark-i18n'; -import {canonicalHost, defaultHost, dockerHostSwap} from 'embark-utils'; +import {canonicalHost, dappPath, defaultHost, dockerHostSwap} from 'embark-utils'; const expressWebSocket = require('express-ws'); const express = require('express'); const https = require('https'); diff --git a/packages/embark/src/cmd/cmd_controller.js b/packages/embark/src/cmd/cmd_controller.js index 6334ac2c2..ec703237f 100644 --- a/packages/embark/src/cmd/cmd_controller.js +++ b/packages/embark/src/cmd/cmd_controller.js @@ -1,6 +1,6 @@ import { BlockchainClient, Simulator } from 'embark-blockchain-process'; -import { dappPath, embarkPath } from 'embark-core'; import { __ } from 'embark-i18n'; +import { dappPath, embarkPath } from 'embark-utils'; import findUp from 'find-up'; let async = require('async'); const constants = require('embark-core/constants'); diff --git a/packages/embark/src/lib/core/config.js b/packages/embark/src/lib/core/config.js index f0717b5b6..b2a9206e5 100644 --- a/packages/embark/src/lib/core/config.js +++ b/packages/embark/src/lib/core/config.js @@ -5,11 +5,11 @@ const path = require('path'); const deepEqual = require('deep-equal'); const web3 = require('web3'); const constants = require('embark-core/constants'); -import { dappPath } from 'embark-core'; import { __ } from 'embark-i18n'; import { buildUrlFromConfig, canonicalHost, + dappPath, defaultHost, recursiveMerge, AddressUtils, diff --git a/packages/embark/src/lib/core/file.ts b/packages/embark/src/lib/core/file.ts index 61a8d746b..95157637b 100644 --- a/packages/embark/src/lib/core/file.ts +++ b/packages/embark/src/lib/core/file.ts @@ -1,5 +1,5 @@ -import { dappPath, embarkPath } from "embark-core"; import { __ } from "embark-i18n"; +import { dappPath, embarkPath } from "embark-utils"; import * as path from "path"; import { ImportRemapping, prepareForCompilation } from "../utils/solidity/remapImports"; diff --git a/packages/embark/src/lib/core/plugin.js b/packages/embark/src/lib/core/plugin.js index 2dc419faa..2579fde83 100644 --- a/packages/embark/src/lib/core/plugin.js +++ b/packages/embark/src/lib/core/plugin.js @@ -1,7 +1,6 @@ const utils = require('../utils/utils.js'); -import { dappPath, embarkPath } from 'embark-core'; import { __ } from 'embark-i18n'; -import {joinPath} from 'embark-utils'; +import { dappPath, embarkPath, joinPath } from 'embark-utils'; const constants = require('embark-core/constants'); const fs = require('fs-extra'); const deepEqual = require('deep-equal'); diff --git a/packages/embark/src/lib/core/plugins.js b/packages/embark/src/lib/core/plugins.js index af05793e1..735b0e1d2 100644 --- a/packages/embark/src/lib/core/plugins.js +++ b/packages/embark/src/lib/core/plugins.js @@ -1,4 +1,4 @@ -import { dappPath, embarkPath } from 'embark-core'; +import { dappPath, embarkPath } from 'embark-utils'; const async = require('async'); var Plugin = require('./plugin.js'); var fs = require('../core/fs.js'); diff --git a/packages/embark/src/lib/modules/coverage/index.ts b/packages/embark/src/lib/modules/coverage/index.ts index d0ea21c57..88043c780 100644 --- a/packages/embark/src/lib/modules/coverage/index.ts +++ b/packages/embark/src/lib/modules/coverage/index.ts @@ -1,4 +1,4 @@ -import { dappPath } from "embark-core"; +import { dappPath } from "embark-utils"; import * as globule from "globule"; import * as path from "path"; import Web3Contract from "web3/eth/contract"; diff --git a/packages/embark/src/lib/modules/ipfs/index.js b/packages/embark/src/lib/modules/ipfs/index.js index 852d337c3..de3ad422d 100644 --- a/packages/embark/src/lib/modules/ipfs/index.js +++ b/packages/embark/src/lib/modules/ipfs/index.js @@ -1,4 +1,3 @@ -import { dappPath, embarkPath } from 'embark-core'; import { __ } from 'embark-i18n'; const UploadIPFS = require('./upload.js'); const utils = require('../../utils/utils.js'); @@ -6,7 +5,7 @@ const IpfsApi = require('ipfs-api'); // TODO: not great, breaks module isolation const StorageProcessesLauncher = require('../storage/storageProcessesLauncher'); const constants = require('embark-core/constants'); -import { buildUrlFromConfig } from 'embark-utils'; +import { buildUrlFromConfig, dappPath, embarkPath } from 'embark-utils'; class IPFS { diff --git a/packages/embark/src/lib/modules/swarm/process.js b/packages/embark/src/lib/modules/swarm/process.js index 62ea0849f..22e6f03b6 100644 --- a/packages/embark/src/lib/modules/swarm/process.js +++ b/packages/embark/src/lib/modules/swarm/process.js @@ -1,4 +1,5 @@ -import { dappPath, ProcessWrapper } from 'embark-core'; +import { ProcessWrapper } from 'embark-core'; +import { dappPath } from 'embark-utils'; const child_process = require('child_process'); const constants = require('embark-core/constants'); diff --git a/packages/embark/src/lib/utils/solidity/remapImports.ts b/packages/embark/src/lib/utils/solidity/remapImports.ts index 27f5e004c..2cf7925e3 100644 --- a/packages/embark/src/lib/utils/solidity/remapImports.ts +++ b/packages/embark/src/lib/utils/solidity/remapImports.ts @@ -1,4 +1,4 @@ -import { dappPath, embarkPath } from "embark-core"; +import { dappPath, embarkPath } from "embark-utils"; import * as path from "path"; import { File, Types } from "../../core/file"; import { removePureView, replacePureView } from "./code"; diff --git a/packages/embark/src/lib/utils/template_generator.js b/packages/embark/src/lib/utils/template_generator.js index 5363e9fb5..18b7942dd 100644 --- a/packages/embark/src/lib/utils/template_generator.js +++ b/packages/embark/src/lib/utils/template_generator.js @@ -1,10 +1,9 @@ -import { embarkPath } from 'embark-core'; import { __ } from 'embark-i18n'; const findUp = require('find-up'); const fs = require('../core/fs.js'); const hostedGitInfo = require('hosted-git-info'); const utils = require('./utils.js'); -import { joinPath, runCmd, errorMessage } from 'embark-utils'; +import { embarkPath, joinPath, runCmd, errorMessage } from 'embark-utils'; const semver = require('semver'); const {promisify} = require('util'); const {execSync} = require('child_process'); diff --git a/packages/embark/src/test/accountParser.js b/packages/embark/src/test/accountParser.js index e393c2668..3471415c4 100644 --- a/packages/embark/src/test/accountParser.js +++ b/packages/embark/src/test/accountParser.js @@ -1,12 +1,11 @@ /*global __dirname, describe, it, before, after, require*/ -import { dappPath } from 'embark-core'; import * as i18n from 'embark-i18n'; const assert = require('assert'); const sinon = require('sinon'); let TestLogger = require('../lib/utils/test_logger'); const Web3 = require('web3'); const fs = require('../lib/core/fs'); -import { getWeiBalanceFromString, getHexBalanceFromString, AccountParser } from 'embark-utils'; +import { dappPath, getWeiBalanceFromString, getHexBalanceFromString, AccountParser } from 'embark-utils'; i18n.setOrDetectLocale('en'); describe('embark.AccountParser', function () { diff --git a/packages/embark/src/test/blockchain.js b/packages/embark/src/test/blockchain.js index f8bd1ff87..be6485d3e 100644 --- a/packages/embark/src/test/blockchain.js +++ b/packages/embark/src/test/blockchain.js @@ -1,8 +1,7 @@ /*globals describe, it*/ import { BlockchainClient } from 'embark-blockchain-process'; -import { dappPath } from 'embark-core'; const constants = require('embark-core/constants'); -import {defaultHost} from 'embark-utils'; +import { dappPath, defaultHost} from 'embark-utils'; const path = require('path'); const fs = require('../lib/core/fs.js'); diff --git a/packages/embark/src/test/config.js b/packages/embark/src/test/config.js index 7ea61e907..63a0848da 100644 --- a/packages/embark/src/test/config.js +++ b/packages/embark/src/test/config.js @@ -1,5 +1,5 @@ /*globals describe, it*/ -const { dappPath } = require('embark-core'); +const { dappPath } = require('embark-utils'); const Config = require('../lib/core/config.js'); const Plugins = require('../lib/core/plugins.js'); const assert = require('assert'); diff --git a/packages/embark/src/test/file.js b/packages/embark/src/test/file.js index 4dfe1591c..d495a2fcd 100644 --- a/packages/embark/src/test/file.js +++ b/packages/embark/src/test/file.js @@ -1,5 +1,5 @@ /*globals describe, it*/ -const { dappPath } = require('embark-core'); +const { dappPath } = require('embark-utils'); const {File, Types} = require("../lib/core/file"); const {expect} = require("chai"); const fs = require("../lib/core/fs"); diff --git a/packages/embark/src/test/modules/solidity/remapImports.js b/packages/embark/src/test/modules/solidity/remapImports.js index e06bb9d1b..ab1a9a5a9 100644 --- a/packages/embark/src/test/modules/solidity/remapImports.js +++ b/packages/embark/src/test/modules/solidity/remapImports.js @@ -1,5 +1,5 @@ /*globals describe, it, before*/ -const { dappPath } = require('embark-core'); +const { dappPath } = require('embark-utils'); const {File, Types} = require("../../../lib/core/file"); const path = require("path"); const remapImports = require("../../../lib/utils/solidity/remapImports"); diff --git a/packages/embark/src/test/vm_fs.js b/packages/embark/src/test/vm_fs.js index 26f1611bc..05aad3780 100644 --- a/packages/embark/src/test/vm_fs.js +++ b/packages/embark/src/test/vm_fs.js @@ -1,5 +1,5 @@ /*global after, before, describe, it, require, process*/ -const { embarkPath } = require('embark-core'); +const { embarkPath } = require('embark-utils'); const {assert} = require('chai'); const os = require('os'); const path = require('path'); diff --git a/packages/embarkjs-connector-web3/index.js b/packages/embarkjs-connector-web3/index.js index d80735f5f..256f902e0 100644 --- a/packages/embarkjs-connector-web3/index.js +++ b/packages/embarkjs-connector-web3/index.js @@ -1,4 +1,4 @@ -const { dappPath, embarkPath } = require('embark-core'); +const { dappPath, embarkPath } = require('embark-utils'); const path = require('path'); class EmbarkJSConnectorWeb3 { diff --git a/packages/embarkjs-connector-web3/package.json b/packages/embarkjs-connector-web3/package.json index 5cb97b93d..feadbcdc8 100644 --- a/packages/embarkjs-connector-web3/package.json +++ b/packages/embarkjs-connector-web3/package.json @@ -31,7 +31,7 @@ "reset": "npx rimraf embark-*.tgz package" }, "dependencies": { - "embark-core": "^4.1.0-beta.1" + "embark-utils": "^4.1.0-beta.1" }, "devDependencies": { "rimraf": "2.6.3"