mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-10 13:55:45 +00:00
refactor(@embark/core): create embark-core package, move constants into embark-core
This commit is contained in:
parent
d386bffda9
commit
60ff097406
4
packages/embark-core/.npmrc
Normal file
4
packages/embark-core/.npmrc
Normal file
@ -0,0 +1,4 @@
|
||||
engine-strict = true
|
||||
package-lock = false
|
||||
save-exact = true
|
||||
scripts-prepend-node-path = true
|
6
packages/embark-core/README.md
Normal file
6
packages/embark-core/README.md
Normal file
@ -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).
|
67
packages/embark-core/package.json
Normal file
67
packages/embark-core/package.json
Normal file
@ -0,0 +1,67 @@
|
||||
{
|
||||
"name": "embark-core",
|
||||
"version": "4.1.0-beta.0",
|
||||
"author": "Iuri Matias <iuri.matias@gmail.com>",
|
||||
"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"
|
||||
}
|
||||
}
|
1
packages/embark-core/src/index.js
Normal file
1
packages/embark-core/src/index.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = {};
|
4
packages/embark-core/tsconfig.json
Normal file
4
packages/embark-core/tsconfig.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["src/**/*"]
|
||||
}
|
3
packages/embark-core/tslint.json
Normal file
3
packages/embark-core/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../../tslint.json"
|
||||
}
|
@ -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';
|
||||
|
@ -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",
|
||||
|
@ -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');
|
||||
|
@ -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;
|
||||
|
@ -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');
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
const uuid = require('uuid/v1');
|
||||
const constants = require('../../constants');
|
||||
const constants = require('embark-core/constants');
|
||||
|
||||
class Events {
|
||||
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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');
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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();
|
||||
|
@ -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",
|
||||
|
@ -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====================================================================`);
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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');
|
||||
|
@ -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";
|
||||
|
@ -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
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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']);
|
||||
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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');
|
||||
|
@ -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 = {
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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';
|
||||
|
@ -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/';
|
||||
|
@ -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');
|
||||
|
@ -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;
|
||||
|
@ -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 () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user