From ee56f3771389a00e019eadce595dcf30468f0afe Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Wed, 11 Dec 2019 11:01:38 -0600 Subject: [PATCH] build: implement collective typecheck This PR replaces #2057. Implement a collective typecheck action that can be invoked in the root of the monorepo with `yarn typecheck` or in watch-mode with `yarn watch:typecheck`. Include the watch-mode typecheck action as part of `yarn start` (a.k.a `yarn watch`). To activate collective typecheck for a package in the monorepo, its `package.json` file should specify: ``` { "embark-collective": { "typecheck": true } } ``` *-or-* ``` { "embark-collective": { "typecheck": {...} } } ``` Where `{...}` above is a `tsconfig.json` fragment that will be merged into the config generated for the package according the same rules that `tsc` applies when merging [configs][config]. When collective typecheck begins, it generates a `tsconfig.json` for the root of the monorepo and for each package that is activated for the action. If the generated JSON is different than what's on disk for the respective root/package config, or if the config is not present on disk, then it will be written. Changes to generated `tsconfig.json` files should be committed; such changes will arise when there are structural changes to the monorepo, e.g. a package is added, removed, moved and/or the directory containing it is renamed. Since the configs are only generated at the beginning of collective typecheck, when structural changes are made in the monorepo `yarn typecheck` (or `yarn start` or `yarn watch:typecheck`) should be restarted. Nearly all of the packages in the monorepo (i.e. all those for which it makes sense) have been activated for collective typecheck. Even those packages that don't contain `.ts` sources are activated because `tsc` can make better sense of the code base as a whole owing to the project references included in the generated `tsconfig.json` files. Also, owing to the fully cross-referenced `tsconfig.json` files, it's possible for `tsc` to type check the whole code base without babel (`yarn build` or `yarn watch:build`) having been run beforehand. **NOTE** that a *"cold typecheck"* of the whole monorepo is resource intensive: on this author's 2019 MacBook Pro it takes around three minutes, the fans spin up, and `tsc` uses nearly 0.5 GB of RAM. However, once a full typecheck has completed, the next full typecheck will complete in a few seconds or less; and when running in watch-mode there is likewise a *big* speedup once a full typecheck has completed, whether that full check happened before it's running in watch-mode or when watch-mode itself resulted in a full check before switching automatically to incremental check, as well a corresponding *big* reduction in resource consumption. A full check will be needed any time `yarn typecheck` (or `yarn start` or `yarn watch:typecheck`) is run in a fresh clone plus `yarn install`, or after doing `yarn reboot[:full]` or `yarn reset`. The combination of options in each generated package-level `tsconfig.json` and the root `tsconfig.base.json` result in `tsc` writing `.d.ts` files (TypeScript declaration files) into the `dist/` directory of each package. That output is intended to live side-by-side with babel's output, and therefore the `"rootDir"` option in each generated config is set to `"./src"`. In projects activated for collective typecheck, `.js` may be converted to `.ts` and/or `.ts` sources may be added without any additional changes needed in package-level `package.json`. --- Reorganize types in `packages/core/typings` (a.k.a `@types/embark`) into `packages/core/core` (`embark-core`), refactor other packages' imports accordingly, and delete `packages/core/typings` from the monorepo. This results in some similarly named but incompatible types exported from `embark-core` (e.g. `Events` and `EmbarkEvents`, the latter being the one from `packages/core/typings`); future refactoring should consolidate those types. To avoid circular dependency relationships it's also necessary to split out `Engine` from `embark-core` into its own package (`embark-engine`) and to introduce a bit of duplication, e.g. the `Maybe` type that's now defined in both `embark-i18n` and `embark-core`. In the process of the types reorg, move many dependencies spec'd in various `package.json` to the `package.json` of the package/s that actually depend on them, e.g. many are moved from `packages/embark/package.json` to `packages/core/engine/package.json`. Related to those moves, fix some Node.js `require`-logic related to bug-prone dependency resolution. Fix all type errors that appeared as a result of activating collective typecheck across the whole monorepo. Reactivate `tslint` in `packages/core/core` and fix the remaining linter errors. Tidy up and add a few items in the root `package.json` scripts. Bump lerna from `3.16.4` to `3.19.0`. Bumpt typescript from `3.6.3` to `3.7.2`. Bumpt tslint from `5.16.0` to `5.20.1`. Make various changes related to packages' `import`/`require`ing packages that weren't spec'd in their respective `package.json`. More refactoring is needed in this regard, but changes were made as the problems were observed in the process of authoring this PR. [config]: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html --- .gitignore | 2 + dapps/tests/app/package.json | 3 +- dapps/tests/contracts/package.json | 5 +- dapps/tests/service/package.json | 7 + package.json | 16 +- packages/cockpit/api-client/package.json | 7 +- packages/cockpit/api-client/tsconfig.json | 12 + packages/cockpit/ui/package.json | 2 +- packages/core/code-runner/package.json | 18 +- packages/core/code-runner/src/index.ts | 4 +- packages/core/code-runner/src/vm.ts | 2 +- packages/core/code-runner/tsconfig.json | 26 +- packages/core/console/package.json | 19 +- packages/core/console/src/lib/index.ts | 11 +- packages/core/console/src/lib/suggestions.ts | 9 +- packages/core/console/tsconfig.json | 26 +- packages/core/core/package.json | 25 +- packages/core/core/src/config.ts | 37 +- packages/core/core/src/configDefaults.ts | 6 +- packages/core/core/src/index.ts | 129 ++- packages/core/core/src/plugin.ts | 29 +- packages/core/core/src/plugins.ts | 28 +- .../core/core/src/processes/eventsWrapper.js | 5 +- .../core/src/processes/processLauncher.js | 4 +- .../core/core/src/processes/processWrapper.js | 5 +- packages/core/core/src/services_monitor.ts | 10 +- packages/core/core/tsconfig.json | 24 +- packages/core/core/tslint.json | 1 - packages/core/{typings => engine}/.npmrc | 0 packages/core/{typings => engine}/README.md | 4 +- packages/core/engine/package.json | 110 +++ .../src/engine.ts => engine/src/index.ts} | 42 +- packages/core/engine/tsconfig.json | 158 ++++ packages/core/{typings => engine}/tslint.json | 0 packages/core/i18n/index.d.ts | 14 - packages/core/i18n/package.json | 18 +- packages/core/i18n/src/index.ts | 4 +- packages/core/i18n/tsconfig.json | 12 +- packages/core/logger/package.json | 10 +- packages/core/logger/src/index.js | 20 +- packages/core/logger/src/utils.js | 10 + packages/core/logger/tsconfig.json | 12 + packages/core/reset/bin.js | 2 +- packages/core/reset/package.json | 19 +- packages/core/reset/{ => src}/index.js | 0 packages/core/reset/tsconfig.json | 12 + packages/core/typings/.gitignore | 1 - packages/core/typings/CHANGELOG.md | 144 ---- packages/core/typings/index.d.ts | 12 - packages/core/typings/package.json | 33 - packages/core/typings/src/callbacks.d.ts | 1 - packages/core/typings/src/contract.d.ts | 8 - .../core/typings/src/contractsConfig.d.ts | 16 - packages/core/typings/src/embark.d.ts | 85 -- packages/core/typings/src/embarkConfig.d.ts | 3 - packages/core/typings/src/logger.d.ts | 7 - packages/core/typings/src/maybe.d.ts | 1 - .../core/typings/src/omg-js-util/index.d.ts | 1 - packages/core/typings/src/plugins.d.ts | 22 - .../src/prettier-plugin-solidity/index.d.ts | 1 - .../src/remix-debug-debugtest/index.d.ts | 1 - packages/core/typings/tsconfig.json | 7 - packages/core/utils/foo.d.ts | 42 - packages/core/utils/package.json | 24 +- packages/core/utils/src/accountParser.js | 2 +- packages/core/utils/src/index.ts | 1 - .../core/utils/src/solidity/remapImports.ts | 15 +- packages/core/utils/tsconfig.json | 20 +- packages/embark/package.json | 66 +- packages/embark/src/cmd/cmd_controller.js | 13 +- packages/embark/src/lib/index.js | 9 +- packages/embark/src/test/cmd.js | 2 +- packages/embark/src/test/contracts.js | 4 +- .../src/test/modules/compiler/compiler.js | 2 +- .../test/modules/console_listener.js.disabled | 190 ---- packages/embark/src/test/transactionUtils.js | 2 +- packages/embark/tsconfig.json | 61 ++ packages/embarkjs/embarkjs/package.json | 12 +- .../embarkjs/embarkjs/src/lib/blockchain.js | 5 +- packages/embarkjs/embarkjs/tsconfig.json | 15 + packages/embarkjs/ens/package.json | 9 +- packages/embarkjs/ens/src/node/index.js | 4 +- packages/embarkjs/ens/tsconfig.json | 17 + packages/embarkjs/ipfs/package.json | 9 +- packages/embarkjs/ipfs/src/node/index.js | 4 +- packages/embarkjs/ipfs/tsconfig.json | 12 + packages/embarkjs/swarm/package.json | 9 +- packages/embarkjs/swarm/src/node/index.js | 4 +- packages/embarkjs/swarm/tsconfig.json | 12 + packages/embarkjs/web3/package.json | 9 +- packages/embarkjs/web3/src/node/index.js | 4 +- packages/embarkjs/web3/tsconfig.json | 12 + packages/embarkjs/whisper/package.json | 9 +- packages/embarkjs/whisper/src/node/index.js | 4 +- packages/embarkjs/whisper/tsconfig.json | 12 + .../plugins/accounts-manager/package.json | 16 +- .../plugins/accounts-manager/src/index.ts | 4 +- .../plugins/accounts-manager/tsconfig.json | 27 +- packages/plugins/basic-pipeline/package.json | 12 +- packages/plugins/basic-pipeline/tsconfig.json | 30 + packages/plugins/coverage/package.json | 28 +- packages/plugins/coverage/src/lib/index.ts | 2 +- packages/plugins/coverage/tsconfig.json | 20 +- packages/plugins/debugger/package.json | 16 +- packages/plugins/debugger/src/index.ts | 4 +- packages/plugins/debugger/tsconfig.json | 17 +- packages/plugins/deploy-tracker/package.json | 7 +- packages/plugins/deploy-tracker/tsconfig.json | 20 + packages/plugins/ens/package.json | 8 +- packages/plugins/ens/tsconfig.json | 32 + .../ethereum-blockchain-client/package.json | 7 +- .../ethereum-blockchain-client/tsconfig.json | 26 + packages/plugins/ganache/package.json | 7 +- packages/plugins/ganache/tsconfig.json | 12 + packages/plugins/geth/package.json | 16 +- packages/plugins/geth/src/blockchain.js | 803 ++++++++--------- .../plugins/geth/src/blockchainProcess.js | 2 +- packages/plugins/geth/src/devtxs.ts | 5 +- packages/plugins/geth/tsconfig.json | 26 +- packages/plugins/graph/package.json | 7 +- packages/plugins/graph/tsconfig.json | 12 + packages/plugins/ipfs/package.json | 7 +- packages/plugins/ipfs/tsconfig.json | 32 + packages/plugins/mocha-tests/package.json | 11 +- packages/plugins/mocha-tests/tsconfig.json | 23 + packages/plugins/parity/package.json | 19 +- packages/plugins/parity/src/blockchain.js | 813 +++++++++--------- .../plugins/parity/src/blockchainProcess.js | 2 +- packages/plugins/parity/tsconfig.json | 24 +- packages/plugins/plugin-cmd/package.json | 7 +- packages/plugins/plugin-cmd/tsconfig.json | 20 + packages/plugins/profiler/package.json | 7 +- packages/plugins/profiler/tsconfig.json | 12 + packages/plugins/rpc-manager/package.json | 21 +- .../rpc-manager/src/lib/eth_accounts.ts | 7 +- .../src/lib/eth_sendTransaction.ts | 5 +- .../rpc-manager/src/lib/eth_signData.ts | 4 +- .../rpc-manager/src/lib/eth_signTypedData.ts | 5 +- .../rpc-manager/src/lib/eth_subscribe.ts | 4 +- .../rpc-manager/src/lib/eth_unsubscribe.ts | 4 +- packages/plugins/rpc-manager/src/lib/index.ts | 9 +- .../src/lib/personal_newAccount.ts | 4 +- .../rpc-manager/src/lib/rpcModifier.ts | 7 +- packages/plugins/rpc-manager/tsconfig.json | 26 +- packages/plugins/scaffolding/package.json | 17 +- .../contractLanguage/solidityBuilder/index.ts | 2 +- .../src/framework/reactBuilder/index.ts | 2 +- packages/plugins/scaffolding/src/index.ts | 2 +- packages/plugins/scaffolding/tsconfig.json | 27 +- packages/plugins/scaffolding/tslint.json | 1 - packages/plugins/snark/package.json | 9 +- packages/plugins/snark/tsconfig.json | 12 + packages/plugins/solc/package.json | 7 +- packages/plugins/solc/tsconfig.json | 12 + packages/plugins/solidity-tests/package.json | 10 +- packages/plugins/solidity-tests/tsconfig.json | 17 + packages/plugins/solidity/package.json | 7 +- packages/plugins/solidity/tsconfig.json | 23 + packages/plugins/specialconfigs/package.json | 7 +- packages/plugins/specialconfigs/tsconfig.json | 17 + packages/plugins/swarm/package.json | 7 +- packages/plugins/swarm/tsconfig.json | 32 + .../plugins/transaction-logger/package.json | 16 +- .../plugins/transaction-logger/src/index.js | 9 +- .../src/transactionUtils.ts | 4 +- .../plugins/transaction-logger/tsconfig.json | 23 + .../tslint.json | 0 .../plugins/transaction-tracker/package.json | 7 +- .../plugins/transaction-tracker/tsconfig.json | 12 + packages/plugins/vyper/package.json | 9 +- packages/plugins/vyper/tsconfig.json | 17 + packages/plugins/web3/package.json | 7 +- packages/plugins/web3/tsconfig.json | 23 + packages/plugins/whisper-geth/package.json | 7 +- .../plugins/whisper-geth/src/blockchain.js | 537 ++++++------ .../whisper-geth/src/blockchainProcess.js | 4 +- packages/plugins/whisper-geth/tsconfig.json | 26 + packages/plugins/whisper-parity/package.json | 7 +- packages/plugins/whisper-parity/tsconfig.json | 26 + packages/stack/api/package.json | 29 +- packages/stack/api/src/index.ts | 2 +- packages/stack/api/src/server.ts | 18 +- packages/stack/api/tsconfig.json | 23 +- packages/stack/authenticator/package.json | 7 +- packages/stack/authenticator/tsconfig.json | 20 + packages/stack/blockchain-client/package.json | 7 +- .../stack/blockchain-client/tsconfig.json | 12 + packages/stack/blockchain/package.json | 15 +- packages/stack/blockchain/src/api.ts | 4 +- packages/stack/blockchain/src/index.js | 4 +- packages/stack/blockchain/tsconfig.json | 29 +- packages/stack/blockchain/tslint.json | 2 +- packages/stack/communication/package.json | 7 +- packages/stack/communication/tsconfig.json | 26 + packages/stack/compiler/package.json | 17 +- packages/stack/compiler/src/index.ts | 8 +- packages/stack/compiler/tsconfig.json | 26 +- packages/stack/contracts-manager/package.json | 16 +- .../stack/contracts-manager/src/contract.ts | 2 +- packages/stack/contracts-manager/src/index.js | 4 +- .../stack/contracts-manager/tsconfig.json | 26 +- packages/stack/deployment/package.json | 7 +- packages/stack/deployment/tsconfig.json | 26 + packages/stack/embarkjs/package.json | 7 +- packages/stack/embarkjs/tsconfig.json | 20 + packages/stack/library-manager/package.json | 7 +- packages/stack/library-manager/tsconfig.json | 20 + packages/stack/namesystem/package.json | 7 +- packages/stack/namesystem/tsconfig.json | 17 + packages/stack/pipeline/package.json | 7 +- packages/stack/pipeline/tsconfig.json | 23 + .../process-logs-api-manager/package.json | 7 +- .../process-logs-api-manager/tsconfig.json | 17 + packages/stack/proxy/package.json | 22 +- packages/stack/proxy/src/index.ts | 7 +- packages/stack/proxy/tsconfig.json | 27 +- packages/stack/storage/package.json | 7 +- packages/stack/storage/tsconfig.json | 23 + packages/stack/test-runner/package.json | 8 +- packages/stack/test-runner/tsconfig.json | 23 + packages/stack/watcher/package.json | 7 +- packages/stack/watcher/tsconfig.json | 20 + packages/stack/webserver/package.json | 7 +- packages/stack/webserver/tsconfig.json | 20 + packages/utils/collective/index.js | 285 +++++- packages/utils/collective/package.json | 17 +- packages/utils/inside-monorepo/package.json | 8 +- packages/utils/solo/index.js | 12 +- packages/utils/solo/package.json | 8 +- packages/utils/testing/package.json | 18 +- packages/utils/testing/tsconfig.json | 12 +- scripts/monorun.js | 12 +- tsconfig.base.json | 17 + tsconfig.json | 207 ++++- yarn.lock | 663 +++++++------- 235 files changed, 4366 insertions(+), 2594 deletions(-) create mode 100644 packages/cockpit/api-client/tsconfig.json rename packages/core/{typings => engine}/.npmrc (100%) rename packages/core/{typings => engine}/README.md (70%) create mode 100644 packages/core/engine/package.json rename packages/core/{core/src/engine.ts => engine/src/index.ts} (88%) create mode 100644 packages/core/engine/tsconfig.json rename packages/core/{typings => engine}/tslint.json (100%) delete mode 100644 packages/core/i18n/index.d.ts create mode 100644 packages/core/logger/src/utils.js create mode 100644 packages/core/logger/tsconfig.json rename packages/core/reset/{ => src}/index.js (100%) create mode 100644 packages/core/reset/tsconfig.json delete mode 100644 packages/core/typings/.gitignore delete mode 100644 packages/core/typings/CHANGELOG.md delete mode 100644 packages/core/typings/index.d.ts delete mode 100644 packages/core/typings/package.json delete mode 100644 packages/core/typings/src/callbacks.d.ts delete mode 100644 packages/core/typings/src/contract.d.ts delete mode 100644 packages/core/typings/src/contractsConfig.d.ts delete mode 100644 packages/core/typings/src/embark.d.ts delete mode 100644 packages/core/typings/src/embarkConfig.d.ts delete mode 100644 packages/core/typings/src/logger.d.ts delete mode 100644 packages/core/typings/src/maybe.d.ts delete mode 100644 packages/core/typings/src/omg-js-util/index.d.ts delete mode 100644 packages/core/typings/src/plugins.d.ts delete mode 100644 packages/core/typings/src/prettier-plugin-solidity/index.d.ts delete mode 100644 packages/core/typings/src/remix-debug-debugtest/index.d.ts delete mode 100644 packages/core/typings/tsconfig.json delete mode 100644 packages/core/utils/foo.d.ts delete mode 100644 packages/embark/src/test/modules/console_listener.js.disabled create mode 100644 packages/embark/tsconfig.json create mode 100644 packages/embarkjs/embarkjs/tsconfig.json create mode 100644 packages/embarkjs/ens/tsconfig.json create mode 100644 packages/embarkjs/ipfs/tsconfig.json create mode 100644 packages/embarkjs/swarm/tsconfig.json create mode 100644 packages/embarkjs/web3/tsconfig.json create mode 100644 packages/embarkjs/whisper/tsconfig.json create mode 100644 packages/plugins/basic-pipeline/tsconfig.json create mode 100644 packages/plugins/deploy-tracker/tsconfig.json create mode 100644 packages/plugins/ens/tsconfig.json create mode 100644 packages/plugins/ethereum-blockchain-client/tsconfig.json create mode 100644 packages/plugins/ganache/tsconfig.json create mode 100644 packages/plugins/graph/tsconfig.json create mode 100644 packages/plugins/ipfs/tsconfig.json create mode 100644 packages/plugins/mocha-tests/tsconfig.json create mode 100644 packages/plugins/plugin-cmd/tsconfig.json create mode 100644 packages/plugins/profiler/tsconfig.json create mode 100644 packages/plugins/snark/tsconfig.json create mode 100644 packages/plugins/solc/tsconfig.json create mode 100644 packages/plugins/solidity-tests/tsconfig.json create mode 100644 packages/plugins/solidity/tsconfig.json create mode 100644 packages/plugins/specialconfigs/tsconfig.json create mode 100644 packages/plugins/swarm/tsconfig.json rename packages/{core/utils => plugins/transaction-logger}/src/transactionUtils.ts (93%) create mode 100644 packages/plugins/transaction-logger/tsconfig.json rename packages/plugins/{parity => transaction-logger}/tslint.json (100%) create mode 100644 packages/plugins/transaction-tracker/tsconfig.json create mode 100644 packages/plugins/vyper/tsconfig.json create mode 100644 packages/plugins/web3/tsconfig.json create mode 100644 packages/plugins/whisper-geth/tsconfig.json create mode 100644 packages/plugins/whisper-parity/tsconfig.json create mode 100644 packages/stack/authenticator/tsconfig.json create mode 100644 packages/stack/blockchain-client/tsconfig.json create mode 100644 packages/stack/communication/tsconfig.json create mode 100644 packages/stack/deployment/tsconfig.json create mode 100644 packages/stack/embarkjs/tsconfig.json create mode 100644 packages/stack/library-manager/tsconfig.json create mode 100644 packages/stack/namesystem/tsconfig.json create mode 100644 packages/stack/pipeline/tsconfig.json create mode 100644 packages/stack/process-logs-api-manager/tsconfig.json create mode 100644 packages/stack/storage/tsconfig.json create mode 100644 packages/stack/test-runner/tsconfig.json create mode 100644 packages/stack/watcher/tsconfig.json create mode 100644 packages/stack/webserver/tsconfig.json create mode 100644 tsconfig.base.json diff --git a/.gitignore b/.gitignore index 4f37b9b21..3109f8189 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store .idea .nyc_output +.tsconfig.collective.json .vscode @embark*.tgz NOTES @@ -14,6 +15,7 @@ npm-debug.log* npm-shrinkwrap.json package package-lock.json +tsconfig.tsbuildinfo yarn-debug.log* yarn-error.log* yarn.lock diff --git a/dapps/tests/app/package.json b/dapps/tests/app/package.json index c308de39e..72d825fcf 100644 --- a/dapps/tests/app/package.json +++ b/dapps/tests/app/package.json @@ -13,6 +13,7 @@ "react": "16.12.0", "react-bootstrap": "0.32.4", "react-dom": "16.12.0", + "rimraf": "3.0.0", "zeppelin-solidity": "1.12.0" }, "license": "MIT", @@ -22,7 +23,7 @@ "ci": "npm run qa", "clean": "npm run reset", "qa": "npm run test", - "reset": "npx embark-reset", + "reset": "npx embark-reset && npx rimraf embark-*.tgz package", "test": "npx embark test" }, "version": "5.0.0-alpha.4" diff --git a/dapps/tests/contracts/package.json b/dapps/tests/contracts/package.json index 901e0371a..1bc71a5e1 100644 --- a/dapps/tests/contracts/package.json +++ b/dapps/tests/contracts/package.json @@ -2,7 +2,8 @@ "description": "Test DApp for integration testing purposes", "devDependencies": { "embark": "^5.0.0-alpha.4", - "embark-reset": "^5.0.0-alpha.2" + "embark-reset": "^5.0.0-alpha.2", + "rimraf": "3.0.0" }, "license": "MIT", "name": "embark-dapp-test-contracts", @@ -11,7 +12,7 @@ "ci": "npm run qa", "clean": "npm run reset", "qa": "npm run test", - "reset": "npx embark-reset", + "reset": "npx embark-reset && npx rimraf embark-*.tgz package", "test": "npx embark test" }, "version": "5.0.0-alpha.4" diff --git a/dapps/tests/service/package.json b/dapps/tests/service/package.json index dba1e18dc..2f9c2fbe5 100644 --- a/dapps/tests/service/package.json +++ b/dapps/tests/service/package.json @@ -3,9 +3,16 @@ "dependencies": { "haml": "0.4.3" }, + "devDependencies": { + "rimraf": "3.0.0" + }, "license": "MIT", "main": "index.js", "name": "embark-dapp-test-service", "private": true, + "scripts": { + "clean": "npm run reset", + "reset": "npx rimraf embark-*.tgz package" + }, "version": "5.0.0-alpha.0" } diff --git a/package.json b/package.json index b3e586aaf..b6535b952 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "find-up": "4.1.0", "form-data": "2.5.1", "fs-extra": "8.1.0", - "lerna": "3.16.4", + "lerna": "3.19.0", "minimist": "1.2.0", "npm-run-all": "4.1.5", "nyc": "13.1.0", @@ -29,7 +29,7 @@ "ci:full": "npm-run-all cwtree \"ci -- --concurrency={1}\" ci:dapps cwtree -- 1", "clean": "node scripts/monorun --stream clean", "clean:full": "npx npm-run-all clean clean:top", - "clean:top": "npx rimraf node_modules", + "clean:top": "npm run reset:top && npx rimraf node_modules", "coverage": "npm-run-all coverage:collect coverage:report", "coverage:collect": "node scripts/coverage-collect", "coverage:coveralls": "nyc report --reporter=text-lcov | coveralls || exit 0", @@ -39,12 +39,11 @@ "deploy:site": "node site/deploy-site", "globalize": "node scripts/globalize", "lint": "node scripts/monorun --parallel lint", - "package": "lerna exec --stream --concurrency=1 -- npm pack", + "package": "lerna exec --concurrency=1 --no-private --stream -- npm pack", "postclean": "npx lerna clean --yes", "postreboot": "yarn install", "postreboot:full": "yarn install", "preci:full": "yarn install", - "preclean": "npm run reset:top", "preqa:full": "yarn install", "qa": "node scripts/monorun --ignore embark-dapp-* --stream qa", "qa:dapps": "lerna run --concurrency=1 --scope embark-dapp-* --stream qa", @@ -52,14 +51,15 @@ "reboot": "npm run clean", "reboot:full": "npm run clean:full", "release": "node scripts/release", - "reset": "node scripts/monorun --stream reset", - "reset:full": "npx npm-run-all reset reset:top", - "reset:top": "npx rimraf .nyc_output coverage", + "reset": "node scripts/monorun --stream reset && npm-run-all reset:*", + "reset:top": "npx rimraf .tsconfig.collective.json .nyc_output coverage", + "reset:tsbuildinfo": "npx lerna exec --parallel -- npx rimraf node_modules/.cache/tsc", "start": "node scripts/monorun --parallel start", "test": "node scripts/monorun --ignore embark-dapp-* --stream test", "test:dapps": "lerna run --concurrency=1 --scope embark-dapp-* --stream test", "test:full": "npm-run-all test test:dapps", - "typecheck": "node scripts/monorun --parallel typecheck", + "typecheck": "node scripts/monorun --stream typecheck", + "typecheck:clean": "npm run typecheck -- -- -- --clean", "watch": "node scripts/monorun --parallel watch", "watch:build": "node scripts/monorun --parallel watch:build", "watch:lint": "node scripts/monorun --parallel watch:lint", diff --git a/packages/cockpit/api-client/package.json b/packages/cockpit/api-client/package.json index 33fcd4670..60f54356a 100644 --- a/packages/cockpit/api-client/package.json +++ b/packages/cockpit/api-client/package.json @@ -22,18 +22,21 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "files": [ "dist" ], "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/cockpit/api-client/tsconfig.json b/packages/cockpit/api-client/tsconfig.json new file mode 100644 index 000000000..0719fd4b7 --- /dev/null +++ b/packages/cockpit/api-client/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-api-client.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/cockpit/ui/package.json b/packages/cockpit/ui/package.json index 9a4c26158..146c8f858 100644 --- a/packages/cockpit/ui/package.json +++ b/packages/cockpit/ui/package.json @@ -98,7 +98,7 @@ "redux-saga": "1.1.3", "rimraf": "3.0.0", "simple-line-icons": "2.4.1", - "typescript": "3.6.3", + "typescript": "3.7.2", "uuid": "3.3.2", "velocity-react": "1.4.1", "web3": "1.2.1", diff --git a/packages/core/code-runner/package.json b/packages/core/code-runner/package.json index be28192b4..01590ecae 100644 --- a/packages/core/code-runner/package.json +++ b/packages/core/code-runner/package.json @@ -25,28 +25,29 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "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\"", - "qa": "npm-run-all lint typecheck _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "solo": "embark-solo" }, "eslintConfig": { "extends": "../../../.eslintrc.json" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", + "@types/async": "3.0.3", "async": "2.6.1", "colors": "1.3.2", "core-js": "3.4.3", @@ -60,13 +61,12 @@ "web3": "1.2.1" }, "devDependencies": { - "@types/async": "3.0.3", "embark-solo": "^5.0.0-alpha.2", "eslint": "5.7.0", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/core/code-runner/src/index.ts b/packages/core/code-runner/src/index.ts index 5c626ed02..0442b3783 100644 --- a/packages/core/code-runner/src/index.ts +++ b/packages/core/code-runner/src/index.ts @@ -1,4 +1,4 @@ -import { Callback, Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Callback, Embark, EmbarkEvents } from "embark-core"; import { __ } from "embark-i18n"; import { Logger } from 'embark-logger'; import * as fs from "./fs"; @@ -8,7 +8,7 @@ export { fs, VM }; class CodeRunner { private logger: Logger; - private events: Events; + private events: EmbarkEvents; private vm: VM; constructor(embark: Embark, _options: any) { diff --git a/packages/core/code-runner/src/vm.ts b/packages/core/code-runner/src/vm.ts index e0dd5848a..ae62ad445 100644 --- a/packages/core/code-runner/src/vm.ts +++ b/packages/core/code-runner/src/vm.ts @@ -1,5 +1,5 @@ import { each } from "async"; -import { Callback } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Callback } from "embark-core"; import { compact, dappPath, isEs6Module, recursiveMerge } from "embark-utils"; import { Logger } from 'embark-logger'; import * as path from "path"; diff --git a/packages/core/code-runner/tsconfig.json b/packages/core/code-runner/tsconfig.json index 1bb65da9e..2d3a546cf 100644 --- a/packages/core/code-runner/tsconfig.json +++ b/packages/core/code-runner/tsconfig.json @@ -1,4 +1,26 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-code-runner.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../embarkjs/embarkjs" + }, + { + "path": "../core" + }, + { + "path": "../logger" + }, + { + "path": "../utils" + } + ] } diff --git a/packages/core/console/package.json b/packages/core/console/package.json index 941303bee..05896017b 100644 --- a/packages/core/console/package.json +++ b/packages/core/console/package.json @@ -26,39 +26,40 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/lib/index.js", + "types": "./dist/lib/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "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\"", - "qa": "npm-run-all lint typecheck _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf .nyc_output coverage dist embark-*.tgz package", "solo": "embark-solo", - "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register" }, "eslintConfig": { "extends": "../../../.eslintrc.json" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", + "@types/json-stringify-safe": "5.0.0", "async": "2.6.1", "chalk": "2.4.2", "core-js": "3.4.3", "embark-core": "^5.0.0-alpha.4", "embark-i18n": "^5.0.0-alpha.2", "embark-utils": "^5.0.0-alpha.4", + "fs-extra": "8.1.0", "json-stringify-safe": "5.0.1" }, "devDependencies": { - "@types/json-stringify-safe": "5.0.0", "embark-logger": "^5.0.0-alpha.4", "embark-solo": "^5.0.0-alpha.2", "eslint": "5.7.0", @@ -67,8 +68,8 @@ "nyc": "13.1.0", "rimraf": "3.0.0", "source-map-support": "0.5.13", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/core/console/src/lib/index.ts b/packages/core/console/src/lib/index.ts index 1c6d72d9a..4f91bae41 100644 --- a/packages/core/console/src/lib/index.ts +++ b/packages/core/console/src/lib/index.ts @@ -1,6 +1,5 @@ -import { waterfall } from "async"; import chalk from "chalk"; -import { Callback, Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Embark, EmbarkEvents } from "embark-core"; import constants from "embark-core/constants.json"; import { __ } from "embark-i18n"; import { dappPath, escapeHtml, exit, jsonFunctionReplacer } from "embark-utils"; @@ -16,9 +15,9 @@ interface HelpDescription { usage?: string; } -class Console { +export default class Console { private embark: Embark; - private events: Events; + private events: EmbarkEvents; private plugins: any; private version: string; private logger: any; @@ -150,7 +149,7 @@ class Console { __("The web3 object and the interfaces for the deployed contracts and their methods are also available")); return helpText.join("\n"); } else if (["quit", "exit", "sair", "sortir", __("quit")].indexOf(cmd) >= 0) { - exit(); + exit(0); } return false; } @@ -285,5 +284,3 @@ class Console { } } } - -module.exports = Console; diff --git a/packages/core/console/src/lib/suggestions.ts b/packages/core/console/src/lib/suggestions.ts index 5414624c6..41bd7e47c 100644 --- a/packages/core/console/src/lib/suggestions.ts +++ b/packages/core/console/src/lib/suggestions.ts @@ -1,6 +1,9 @@ -import { Contract, Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Contract, Embark, EmbarkEvents } from "embark-core"; import { fuzzySearch } from "embark-utils"; -import { suggestions as defaultSuggestions } from "../../suggestions.json"; +import { readJsonSync } from "fs-extra"; +import { join } from "path"; + +const { suggestions: defaultSuggestions } = readJsonSync(join(__dirname, "../../suggestions.json")); interface ContractsManager { [key: string]: any; @@ -23,7 +26,7 @@ type SuggestionsList = Suggestion[]; export default class Suggestions { private embark: Embark; - private events: Events; + private events: EmbarkEvents; private contracts: ContractsManager; private static readonly DEFAULT_SUGGESTIONS = defaultSuggestions; private _suggestions: SuggestionsList = []; diff --git a/packages/core/console/tsconfig.json b/packages/core/console/tsconfig.json index 1bb65da9e..7510c18f6 100644 --- a/packages/core/console/tsconfig.json +++ b/packages/core/console/tsconfig.json @@ -1,4 +1,26 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-console.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/lib/**/*" + ], + "references": [ + { + "path": "../core" + }, + { + "path": "../i18n" + }, + { + "path": "../logger" + }, + { + "path": "../utils" + } + ] } diff --git a/packages/core/core/package.json b/packages/core/core/package.json index 573f3dd75..185b5019c 100644 --- a/packages/core/core/package.json +++ b/packages/core/core/package.json @@ -27,35 +27,38 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "npm-run-all lint:*", "lint:js": "eslint process.js src/", - "// lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", - "qa": "npm-run-all lint typecheck _build", + "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc" + "solo": "embark-solo" }, "eslintConfig": { "extends": "../../../.eslintrc.json" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", + "@types/deep-equal": "1.0.1", + "@types/web3": "1.0.12", "colors": "1.3.2", "core-js": "3.4.3", "decompress": "4.2.0", + "deep-equal": "1.0.1", "embark-i18n": "^5.0.0-alpha.2", "embark-logger": "^5.0.0-alpha.4", - "embark-rpc-manager": "^5.0.0-alpha.4", "embark-utils": "^5.0.0-alpha.4", - "embark-whisper-geth": "^5.0.0-alpha.4", - "embark-whisper-parity": "^5.0.0-alpha.4", + "find-up": "4.1.0", "flatted": "0.2.3", "fs-extra": "8.1.0", "globule": "1.2.1", @@ -67,14 +70,12 @@ "window-size": "1.1.1" }, "devDependencies": { - "@babel/core": "7.7.4", - "babel-jest": "24.9.0", "embark-solo": "^5.0.0-alpha.2", "eslint": "5.7.0", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/core/core/src/config.ts b/packages/core/core/src/config.ts index 419b92215..4e8683395 100644 --- a/packages/core/core/src/config.ts +++ b/packages/core/core/src/config.ts @@ -6,7 +6,6 @@ import { filesMatchingPattern, fileMatchesPattern } from './utils/utils'; const path = require('path'); const deepEqual = require('deep-equal'); const web3 = require('web3'); -const constants = require('embark-core/constants'); import { __ } from 'embark-i18n'; import { buildUrlFromConfig, @@ -24,11 +23,14 @@ import { getExternalContractUrl } from 'embark-utils'; import { Logger } from 'embark-logger'; +import { readJsonSync } from 'fs-extra'; const cloneDeep = require('lodash.clonedeep'); const { replaceZeroAddressShorthand } = AddressUtils; import { getBlockchainDefaults, getContractDefaults } from './configDefaults'; +const constants = readJsonSync(path.join(__dirname, '../constants.json')); + const DEFAULT_CONFIG_PATH = 'config/'; const embark5ChangesUrl = 'https://embark.status.im/docs/migrating_from_3.x.html#Updating-to-v5'; @@ -79,7 +81,7 @@ export class Config { corsParts: string[] = []; - providerUrl = null; + providerUrl = ''; contractDirectories: string[] = []; @@ -133,8 +135,8 @@ export class Config { // TODO: refactor this so reading the file can be done with a normal resolver or something that takes advantage of the plugin api this.events.setCommandHandler("config:contractsFiles:add", (filename, resolver) => { - resolver = resolver || function (callback) { callback(fs.readFileSync(filename).toString()); }; - this.contractsFiles.push(new File({ path: filename, originalPath: filename, type: Types.custom, resolver })); + resolver = resolver || (callback => { callback(fs.readFileSync(filename).toString()); }); + this.contractsFiles.push(new File({path: filename, originalPath: filename, type: Types.custom, resolver})); }); this.events.setCommandHandler("config:contractsFiles:reset", (cb) => { @@ -375,17 +377,17 @@ export class Config { } if (this.blockchainConfig.targetGasLimit && this.blockchainConfig.targetGasLimit.toString().match(unitRegex)) { - this.blockchainConfig.targetGasLimit = getWeiBalanceFromString(this.blockchainConfig.targetGasLimit, web3); + this.blockchainConfig.targetGasLimit = getWeiBalanceFromString(this.blockchainConfig.targetGasLimit); } if (this.blockchainConfig.gasPrice && this.blockchainConfig.gasPrice.toString().match(unitRegex)) { - this.blockchainConfig.gasPrice = getWeiBalanceFromString(this.blockchainConfig.gasPrice, web3); + this.blockchainConfig.gasPrice = getWeiBalanceFromString(this.blockchainConfig.gasPrice); } if (this.blockchainConfig.accounts) { this.blockchainConfig.accounts.forEach(acc => { if (acc.balance && acc.balance.toString().match(unitRegex)) { - acc.balance = getWeiBalanceFromString(acc.balance, web3); + acc.balance = getWeiBalanceFromString(acc.balance); } }); } @@ -460,7 +462,7 @@ export class Config { let configObject = getContractDefaults(this.embarkConfig.versions); const contractsConfigs = this.plugins.getPluginsProperty('contractsConfig', 'contractsConfigs'); - contractsConfigs.forEach(function (pluginConfig) { + contractsConfigs.forEach(pluginConfig => { configObject = recursiveMerge(configObject, pluginConfig); }); @@ -475,7 +477,7 @@ export class Config { process.exit(1); } if (newContractsConfig.gas.match(unitRegex)) { - newContractsConfig.gas = getWeiBalanceFromString(newContractsConfig.gas, web3); + newContractsConfig.gas = getWeiBalanceFromString(newContractsConfig.gas); } newContractsConfig = prepareContractsConfig(newContractsConfig); @@ -499,9 +501,7 @@ export class Config { if (storageConfig && storageConfig.upload && storageConfig.upload.getUrl) { this.providerUrl = storageConfig.upload.getUrl; } - for (const contractName in contracts) { - const contract = contracts[contractName]; - + for (const contract of Object.values(contracts) as any[]) { if (!contract.file) { continue; } @@ -711,27 +711,28 @@ export class Config { const readFiles: File[] = []; const storageConfig = self.storageConfig; - originalFiles.filter(function (file) { + originalFiles.filter(file => { return (file[0] === '$' || file.indexOf('.') >= 0); - }).filter(function (file) { + }).filter(file => { const basedir = findMatchingExpression(file, files); readFiles.push(new File({ path: file, originalPath: file, type: Types.dappFile, basedir, storageConfig })); }); - const filesFromPlugins: File[] = []; + type _File = File & { intendedPath?: string, file?: string }; + const filesFromPlugins: _File[] = []; const filePlugins = self.plugins.getPluginsFor('pipelineFiles'); filePlugins.forEach((plugin: Plugin) => { try { const fileObjects = plugin.runFilePipeline(); - for (let i = 0; i < fileObjects.length; i++) { - const fileObject = fileObjects[i]; + for (const fileObject of fileObjects) { filesFromPlugins.push(fileObject); } } catch (err) { self.logger.error(err.message); } }); - filesFromPlugins.filter(function (file) { + + filesFromPlugins.filter(file => { if ((file.intendedPath && fileMatchesPattern(files, file.intendedPath)) || fileMatchesPattern(files, file.file)) { readFiles.push(file); } diff --git a/packages/core/core/src/configDefaults.ts b/packages/core/core/src/configDefaults.ts index 445b1e7f8..934ea8271 100644 --- a/packages/core/core/src/configDefaults.ts +++ b/packages/core/core/src/configDefaults.ts @@ -1,6 +1,8 @@ import {recursiveMerge} from "embark-utils"; +import { readJsonSync } from 'fs-extra'; +import { join } from "path"; -const constants = require('embark-core/constants'); +const constants = readJsonSync(join(__dirname, '../constants.json')); export function getBlockchainDefaults(env) { const defaults = { @@ -45,7 +47,7 @@ export function getContractDefaults(embarkConfigVersions) { return { default: { - versions: versions, + versions, dappConnection: [ "$WEB3", "ws://localhost:8546", diff --git a/packages/core/core/src/index.ts b/packages/core/core/src/index.ts index dd6a190cc..6a69ecec1 100644 --- a/packages/core/core/src/index.ts +++ b/packages/core/core/src/index.ts @@ -1,12 +1,139 @@ +export type Callback = (err?: Error | null, val?: Tv) => void; + +export type Maybe = false | 0 | undefined | null | T; + +import { ABIDefinition } from 'web3/eth/abi'; + +export interface Contract { + abiDefinition: ABIDefinition[]; + deployedAddress: string; + className: string; + silent?: boolean; +} + +export interface ContractConfig { + address?: string; + args?: any[]; + instanceOf?: string; + gas?: number; + gasPrice?: number; + silent?: boolean; + track?: boolean; + deploy?: boolean; +} + +export interface Plugin { + dappGenerators: any; + name: string; +} + +export interface EmbarkPlugins { + getPluginsFor(name: string): [Plugin]; + loadInternalPlugin(name: string, options: any): void; + getPluginsProperty(pluginType: string, property: string, sub_property?: string): any[]; + plugins: Plugin[]; + runActionsForEvent(event: string, args: any, cb: Callback): void; +} + +export interface CompilerPluginObject { + extension: string; + cb: any; +} + +type CommandCallback = ( + opt1?: any, + opt2?: any, + opt3?: any, + opt4?: any, + opt5?: any, + opt6?: any, + opt7?: any, + opt8?: any, + opt9?: any, + opt10?: any, + opt11?: any, + opt12?: any, +) => any; + +export interface EmbarkEvents { + on: any; + request: any; + request2: any; + emit: any; + once: any; + setCommandHandler( + name: string, + callback: CommandCallback, + ): void; +} + +export interface EmbarkConfig { + contractsFiles: any[]; + embarkConfig: { + contracts: string[] | string; + config: { + contracts: string; + }; + versions: { + solc: string; + }; + generationDir: string; + }; + blockchainConfig: { + endpoint: string; + accounts: any[]; + proxy: boolean; + rpcPort: string | number; + wsPort: string | number; + rpcHost: string | number; + wsHost: string | number; + wsOrigins: string; + rpcCorsDomain: string; + wsRPC: boolean; + isDev: boolean; + client: string; + }; + webServerConfig: { + certOptions: { + key: string; + cert: string; + }; + }; + plugins: EmbarkPlugins; + reloadConfig(): void; +} + +type ActionCallback = (params: any, cb: Callback) => void; + +import { Logger } from 'embark-logger'; + +export interface Embark { + env: string; + events: EmbarkEvents; + plugins: EmbarkPlugins; + registerAPICall(method: string, endpoint: string, cb: (...args: any[]) => void): void; + registerConsoleCommand: any; + logger: Logger; + fs: any; + config: EmbarkConfig; + currentContext: string[]; + registerActionForEvent( + name: string, + options?: ActionCallback | { priority: number }, + action?: ActionCallback, + ): void; +} + export { ProcessLauncher } from './processes/processLauncher'; export { ProcessWrapper } from './processes/processWrapper'; export { Config } from './config'; export { IPC } from './ipc'; -export { Engine } from './engine'; import { EmbarkEmitter as Events } from './events'; export { Events }; export { Plugins } from './plugins'; +export { ProcessManager } from './processes/processManager'; +export { ServicesMonitor } from './services_monitor'; export { TestLogger } from './utils/test_logger'; export { TemplateGenerator } from './utils/template_generator'; diff --git a/packages/core/core/src/plugin.ts b/packages/core/core/src/plugin.ts index fde7d36af..9455b39dc 100644 --- a/packages/core/core/src/plugin.ts +++ b/packages/core/core/src/plugin.ts @@ -2,9 +2,12 @@ import { fileMatchesPattern } from './utils/utils'; import { __ } from 'embark-i18n'; import { dappPath, embarkPath, isEs6Module, joinPath } from 'embark-utils'; import { Logger } from 'embark-logger'; -const constants = require('embark-core/constants'); -const fs = require('fs-extra'); const deepEqual = require('deep-equal'); +import * as fs from 'fs-extra'; +import { readFileSync, readJsonSync } from 'fs-extra'; +import { join } from "path"; + +const constants = readJsonSync(join(__dirname, '../constants.json')); // Default priority of actions with no specified priority. 1 => Highest const DEFAULT_ACTION_PRIORITY = 50; @@ -136,15 +139,7 @@ export class Plugin { } setUpLogger() { - this.logger = { - log: this._log.bind(this, 'log'), - warn: this._log.bind(this, 'warn'), - error: this._log.bind(this, 'error'), - info: this._log.bind(this, 'info'), - debug: this._log.bind(this, 'debug'), - trace: this._log.bind(this, 'trace'), - dir: this._log.bind(this, 'dir') - }; + this.logger = new Logger({}); } isContextValid() { @@ -188,7 +183,7 @@ export class Plugin { } loadPluginFile(filename) { - return fs.readFileSync(this.pathToFile(filename)).toString(); + return readFileSync(this.pathToFile(filename)).toString(); } pathToFile(filename) { @@ -272,13 +267,13 @@ export class Plugin { } generateProvider(args) { - return this.clientWeb3Providers.map(function (cb) { + return this.clientWeb3Providers.map(function(cb) { return cb.call(this, args); }).join("\n"); } generateContracts(args) { - return this.contractsGenerators.map(function (cb) { + return this.contractsGenerators.map(function(cb) { return cb.call(this, args); }).join("\n"); } @@ -351,7 +346,7 @@ export class Plugin { runFilePipeline() { return this.pipelineFiles.map(file => { - let obj: any = {}; + const obj: any = {}; obj.filename = file.file.replace('./', ''); obj.content = this.loadPluginFile(file.file).toString(); obj.intendedPath = file.intendedPath; @@ -364,8 +359,8 @@ export class Plugin { runPipeline(args) { // TODO: should iterate the pipelines - let pipeline = this.pipeline[0]; - let shouldRunPipeline = fileMatchesPattern(pipeline.matcthingFiles, args.targetFile); + const pipeline = this.pipeline[0]; + const shouldRunPipeline = fileMatchesPattern(pipeline.matcthingFiles, args.targetFile); if (shouldRunPipeline) { return pipeline.cb.call(this, args); } diff --git a/packages/core/core/src/plugins.ts b/packages/core/core/src/plugins.ts index 91f4bf473..f10244aba 100644 --- a/packages/core/core/src/plugins.ts +++ b/packages/core/core/src/plugins.ts @@ -6,6 +6,8 @@ import { Config } from './config'; import * as async from 'async'; import { dappPath, embarkPath } from 'embark-utils'; import { Logger } from 'embark-logger'; +import findUp from 'find-up'; +import { dirname } from 'path'; export class Plugins { @@ -90,7 +92,8 @@ export class Plugins { } loadInternalPlugin(pluginName, pluginConfig, isPackage?: boolean) { - let pluginPath, plugin; + let pluginPath; + let plugin; if (isPackage) { pluginPath = pluginName; plugin = require(pluginName); @@ -124,7 +127,9 @@ export class Plugins { } loadPlugin(pluginName, pluginConfig) { - const pluginPath = dappPath('node_modules', pluginName); + const pluginPath = dirname(findUp.sync('package.json', { + cwd: dirname(require.resolve(pluginName, {paths: [dappPath()]})) + }) as string); let plugin = require(pluginPath); if (plugin.default) { @@ -151,13 +156,13 @@ export class Plugins { } getPluginsFor(pluginType) { - return this.plugins.filter(function(plugin) { + return this.plugins.filter(plugin => { return plugin.has(pluginType); }); } getPluginsProperty(pluginType, property, sub_property?: any) { - const matchingPlugins = this.plugins.filter(function(plugin) { + const matchingPlugins = this.plugins.filter(plugin => { return plugin.has(pluginType); }); @@ -180,7 +185,7 @@ export class Plugins { }); // Remove empty properties - matchingProperties = matchingProperties.filter((property) => property); + matchingProperties = matchingProperties.filter(prop => prop); // return flattened list if (matchingProperties.length === 0) { return []; } @@ -188,7 +193,7 @@ export class Plugins { } getPluginsPropertyAndPluginName(pluginType, property, sub_property) { - const matchingPlugins = this.plugins.filter(function(plugin) { + const matchingPlugins = this.plugins.filter(plugin => { return plugin.has(pluginType); }); @@ -204,24 +209,21 @@ export class Plugins { }); let matchingProperties: any[] = []; - matchingPlugins.map((plugin) => { + matchingPlugins.forEach(plugin => { if (sub_property) { - const newList = []; for (const kall of (plugin[property][sub_property] || [])) { matchingProperties.push([kall, plugin.name]); } - return newList; + return; } - const newList = []; for (const kall of (plugin[property] || [])) { matchingProperties.push([kall, plugin.name]); } - return newList; }); // Remove empty properties - matchingProperties = matchingProperties.filter((property) => property[0]); + matchingProperties = matchingProperties.filter(prop => prop[0]); // return flattened list if (matchingProperties.length === 0) { return []; } @@ -256,7 +258,7 @@ export class Plugins { this.events.log("ACTION", eventName, ""); - async.reduce(actionPlugins, args, function(current_args, pluginObj: any, nextEach) { + async.reduce(actionPlugins, args, (current_args, pluginObj: any, nextEach) => { const [plugin, pluginName] = pluginObj; self.events.log("== ACTION FOR " + eventName, plugin.action.name, pluginName); diff --git a/packages/core/core/src/processes/eventsWrapper.js b/packages/core/core/src/processes/eventsWrapper.js index bcf2caf2f..54ebf7cc3 100644 --- a/packages/core/core/src/processes/eventsWrapper.js +++ b/packages/core/core/src/processes/eventsWrapper.js @@ -1,5 +1,8 @@ +import { readJsonSync } from 'fs-extra'; +import { join } from "path"; const uuid = require('uuid/v1'); -const constants = require('../../constants'); + +const constants = readJsonSync(join(__dirname, '../../constants.json')); export class Events { diff --git a/packages/core/core/src/processes/processLauncher.js b/packages/core/core/src/processes/processLauncher.js index b0383dd78..5f934e300 100644 --- a/packages/core/core/src/processes/processLauncher.js +++ b/packages/core/core/src/processes/processLauncher.js @@ -1,7 +1,9 @@ const child_process = require('child_process'); -const constants = require('../../constants'); +import { readJsonSync } from 'fs-extra'; const path = require('path'); +const constants = readJsonSync(path.join(__dirname, '../../constants.json')); + let processCount = 1; export class ProcessLauncher { diff --git a/packages/core/core/src/processes/processWrapper.js b/packages/core/core/src/processes/processWrapper.js index 592020b5d..a955f93a0 100644 --- a/packages/core/core/src/processes/processWrapper.js +++ b/packages/core/core/src/processes/processWrapper.js @@ -1,5 +1,8 @@ +import { readJsonSync } from 'fs-extra'; +import { join } from "path"; import { Events } from './eventsWrapper'; -const constants = require('../../constants'); + +const constants = readJsonSync(join(__dirname, '../../constants.json')); export class ProcessWrapper { diff --git a/packages/core/core/src/services_monitor.ts b/packages/core/core/src/services_monitor.ts index aea3beb9a..46adb8bc1 100644 --- a/packages/core/core/src/services_monitor.ts +++ b/packages/core/core/src/services_monitor.ts @@ -37,7 +37,7 @@ export class ServicesMonitor { return false; } - self.events.on('check:' + checkName, function(obj) { + self.events.on('check:' + checkName, obj => { if (check && check.status === 'off' && obj.status === 'on') { self.events.emit('check:backOnline:' + checkName); } @@ -53,14 +53,14 @@ export class ServicesMonitor { }); if (check.interval !== 0) { - self.checkTimers[checkName] = setInterval(function() { - check.fn.call(check.fn, function(obj) { + self.checkTimers[checkName] = setInterval(() => { + check.fn.call(check.fn, obj => { self.events.emit('check:' + checkName, obj); }); }, check.interval); } - check.fn.call(check.fn, function(obj) { + check.fn.call(check.fn, obj => { self.events.emit('check:' + checkName, obj); }); } @@ -87,7 +87,7 @@ export class ServicesMonitor { this.logger.trace('startMonitor'); const servicePlugins = this.plugins.getPluginsProperty('serviceChecks', 'serviceChecks'); - servicePlugins.forEach(function(pluginCheck) { + servicePlugins.forEach(pluginCheck => { self.addCheck(pluginCheck.checkName, pluginCheck.checkFn, pluginCheck.time); }); diff --git a/packages/core/core/tsconfig.json b/packages/core/core/tsconfig.json index 1dc6632e6..eb54d0d81 100644 --- a/packages/core/core/tsconfig.json +++ b/packages/core/core/tsconfig.json @@ -1,5 +1,23 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-core.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../i18n" + }, + { + "path": "../logger" + }, + { + "path": "../utils" + } + ] } - diff --git a/packages/core/core/tslint.json b/packages/core/core/tslint.json index 1bdfa34f9..1f63906f0 100644 --- a/packages/core/core/tslint.json +++ b/packages/core/core/tslint.json @@ -1,4 +1,3 @@ { "extends": "../../../tslint.json" } - diff --git a/packages/core/typings/.npmrc b/packages/core/engine/.npmrc similarity index 100% rename from packages/core/typings/.npmrc rename to packages/core/engine/.npmrc diff --git a/packages/core/typings/README.md b/packages/core/engine/README.md similarity index 70% rename from packages/core/typings/README.md rename to packages/core/engine/README.md index 8a1a68cd5..bdee7f7f0 100644 --- a/packages/core/typings/README.md +++ b/packages/core/engine/README.md @@ -1,6 +1,6 @@ -# `@types/embark` +# `embark-engine` -> TypeScript definitions for Embark +> Engine 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/core/engine/package.json b/packages/core/engine/package.json new file mode 100644 index 000000000..be3d785ce --- /dev/null +++ b/packages/core/engine/package.json @@ -0,0 +1,110 @@ +{ + "name": "embark-engine", + "version": "5.0.0-alpha.4", + "author": "Iuri Matias ", + "contributors": [], + "description": "Engine library for Embark", + "homepage": "https://github.com/embark-framework/embark/tree/master/packages/core/engine#readme", + "bugs": "https://github.com/embark-framework/embark/issues", + "keywords": [ + "blockchain", + "dapps", + "ethereum", + "ipfs", + "serverless", + "solc", + "solidity" + ], + "files": [ + "dist" + ], + "license": "MIT", + "repository": { + "directory": "packages/core/engine", + "type": "git", + "url": "https://github.com/embark-framework/embark.git" + }, + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "embark-collective": { + "build:node": true, + "typecheck": true + }, + "scripts": { + "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", + "ci": "npm run qa", + "clean": "npm run reset", + "lint": "tslint -c tslint.json \"src/**/*.ts\"", + "qa": "npm-run-all lint _typecheck _build", + "reset": "npx rimraf dist embark-*.tgz package", + "solo": "embark-solo" + }, + "eslintConfig": { + "extends": "../../../.eslintrc.json" + }, + "dependencies": { + "@babel/runtime-corejs3": "7.7.4", + "core-js": "3.4.3", + "embark-accounts-manager": "^5.0.0-alpha.4", + "embark-api": "^5.0.0-alpha.4", + "embark-authenticator": "^5.0.0-alpha.4", + "embark-basic-pipeline": "^5.0.0-alpha.4", + "embark-blockchain": "^5.0.0-alpha.4", + "embark-blockchain-client": "^5.0.0-alpha.2", + "embark-code-runner": "^5.0.0-alpha.4", + "embark-communication": "^5.0.0-alpha.4", + "embark-compiler": "^5.0.0-alpha.4", + "embark-console": "^5.0.0-alpha.4", + "embark-contracts-manager": "^5.0.0-alpha.4", + "embark-core": "^5.0.0-alpha.4", + "embark-coverage": "^5.0.0-alpha.4", + "embark-debugger": "^5.0.0-alpha.4", + "embark-deployment": "^5.0.0-alpha.4", + "embark-embarkjs": "^5.0.0-alpha.4", + "embark-ens": "^5.0.0-alpha.4", + "embark-ethereum-blockchain-client": "^5.0.0-alpha.4", + "embark-ganache": "^5.0.0-alpha.2", + "embark-geth": "^5.0.0-alpha.4", + "embark-ipfs": "^5.0.0-alpha.4", + "embark-library-manager": "^5.0.0-alpha.4", + "embark-logger": "^5.0.0-alpha.4", + "embark-mocha-tests": "^5.0.0-alpha.4", + "embark-namesystem": "^5.0.0-alpha.2", + "embark-parity": "^5.0.0-alpha.4", + "embark-pipeline": "^5.0.0-alpha.4", + "embark-plugin-cmd": "^5.0.0-alpha.4", + "embark-process-logs-api-manager": "^5.0.0-alpha.4", + "embark-profiler": "^5.0.0-alpha.2", + "embark-proxy": "^5.0.0-alpha.4", + "embark-rpc-manager": "^5.0.0-alpha.4", + "embark-scaffolding": "^5.0.0-alpha.2", + "embark-solidity": "^5.0.0-alpha.4", + "embark-solidity-tests": "^5.0.0-alpha.4", + "embark-specialconfigs": "^5.0.0-alpha.2", + "embark-storage": "^5.0.0-alpha.4", + "embark-swarm": "^5.0.0-alpha.4", + "embark-test-runner": "^5.0.0-alpha.4", + "embark-transaction-logger": "^5.0.0-alpha.4", + "embark-transaction-tracker": "^5.0.0-alpha.2", + "embark-utils": "^5.0.0-alpha.4", + "embark-vyper": "^5.0.0-alpha.2", + "embark-watcher": "^5.0.0-alpha.4", + "embark-web3": "^5.0.0-alpha.4", + "embark-webserver": "^5.0.0-alpha.4", + "embark-whisper-geth": "^5.0.0-alpha.4", + "embark-whisper-parity": "^5.0.0-alpha.4" + }, + "devDependencies": { + "embark-solo": "^5.0.0-alpha.2", + "npm-run-all": "4.1.5", + "rimraf": "3.0.0", + "tslint": "5.20.1", + "typescript": "3.7.2" + }, + "engines": { + "node": ">=10.17.0 <12.0.0", + "npm": ">=6.11.3", + "yarn": ">=1.19.1" + } +} diff --git a/packages/core/core/src/engine.ts b/packages/core/engine/src/index.ts similarity index 88% rename from packages/core/core/src/engine.ts rename to packages/core/engine/src/index.ts index 6218d1a43..e5259b780 100644 --- a/packages/core/core/src/engine.ts +++ b/packages/core/engine/src/index.ts @@ -1,10 +1,11 @@ -import { Config } from './config'; -import { Plugins } from './plugins'; -import { EmbarkEmitter as Events } from './events'; -import { ProcessManager } from './processes/processManager'; -import { IPC } from './ipc'; -import { ServicesMonitor } from './services_monitor'; - +import { + Config, + Events, + IPC, + Plugins, + ProcessManager, + ServicesMonitor +} from 'embark-core'; import { normalizeInput } from 'embark-utils'; import { Logger } from 'embark-logger'; @@ -67,6 +68,7 @@ export class Engine { this.version = options.version; this.logFile = options.logFile; this.logLevel = options.logLevel; + this.logger = options.logger; this.events = options.events; this.context = options.context; this.useDashboard = options.useDashboard; @@ -78,13 +80,13 @@ export class Engine { } init(_options, callback) { - callback = callback || function () { }; + callback = callback || (() => {}); const options = _options || {}; this.events = options.events || this.events || new Events(); - this.logger = options.logger || new Logger({ context: this.context, logLevel: options.logLevel || this.logLevel || 'info', events: this.events, logFile: this.logFile }); - this.config = new Config({ env: this.env, logger: this.logger, events: this.events, context: this.context, webServerConfig: this.webServerConfig, version: this.version, package: this.package }); - this.config.loadConfigFiles({ embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs }); + this.logger = this.logger || new Logger({context: this.context, logLevel: options.logLevel || this.logLevel || 'info', events: this.events, logFile: this.logFile}); + this.config = new Config({env: this.env, logger: this.logger, events: this.events, context: this.context, webServerConfig: this.webServerConfig, version: this.version, package: this.package}); + this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs}); this.plugins = this.config.plugins; this.isDev = this.config && this.config.blockchainConfig && (this.config.blockchainConfig.isDev || this.config.blockchainConfig.default); @@ -127,13 +129,13 @@ export class Engine { registerModule(moduleName, options) { if (this.plugins) { - this.plugins.loadInternalPlugin(moduleName, options || {}); + this.plugins.loadInternalPlugin(require.resolve(moduleName), options || {}); } } registerModulePackage(moduleName, options?: any) { if (this.plugins) { - return this.plugins.loadInternalPlugin(moduleName, options || {}, true); + return this.plugins.loadInternalPlugin(require.resolve(moduleName), options || {}, true); } } @@ -204,7 +206,7 @@ export class Engine { if (this.plugins) { const plugin = this.plugins.createPlugin('coreservicesplugin', {}); plugin.registerActionForEvent("embark:engine:started", (_params, cb) => { - this.servicesMonitor && this.servicesMonitor.startMonitor(); + if (this.servicesMonitor) { this.servicesMonitor.startMonitor(); } cb(); }); } @@ -321,23 +323,23 @@ function interceptLogs(consoleContext, logger) { const context: any = {}; context.console = consoleContext; - context.console.log = function () { + context.console.log = () => { logger.info(normalizeInput(arguments)); }; - context.console.warn = function () { + context.console.warn = () => { logger.warn(normalizeInput(arguments)); }; - context.console.info = function () { + context.console.info = () => { logger.info(normalizeInput(arguments)); }; - context.console.debug = function () { + context.console.debug = () => { // TODO: ue JSON.stringify logger.debug(normalizeInput(arguments)); }; - context.console.trace = function () { + context.console.trace = () => { logger.trace(normalizeInput(arguments)); }; - context.console.dir = function () { + context.console.dir = () => { logger.dir(normalizeInput(arguments)); }; } diff --git a/packages/core/engine/tsconfig.json b/packages/core/engine/tsconfig.json new file mode 100644 index 000000000..3c7234d69 --- /dev/null +++ b/packages/core/engine/tsconfig.json @@ -0,0 +1,158 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-engine.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../plugins/accounts-manager" + }, + { + "path": "../../plugins/basic-pipeline" + }, + { + "path": "../../plugins/coverage" + }, + { + "path": "../../plugins/debugger" + }, + { + "path": "../../plugins/ens" + }, + { + "path": "../../plugins/ethereum-blockchain-client" + }, + { + "path": "../../plugins/ganache" + }, + { + "path": "../../plugins/geth" + }, + { + "path": "../../plugins/ipfs" + }, + { + "path": "../../plugins/mocha-tests" + }, + { + "path": "../../plugins/parity" + }, + { + "path": "../../plugins/plugin-cmd" + }, + { + "path": "../../plugins/profiler" + }, + { + "path": "../../plugins/rpc-manager" + }, + { + "path": "../../plugins/scaffolding" + }, + { + "path": "../../plugins/solidity" + }, + { + "path": "../../plugins/solidity-tests" + }, + { + "path": "../../plugins/specialconfigs" + }, + { + "path": "../../plugins/swarm" + }, + { + "path": "../../plugins/transaction-logger" + }, + { + "path": "../../plugins/transaction-tracker" + }, + { + "path": "../../plugins/vyper" + }, + { + "path": "../../plugins/web3" + }, + { + "path": "../../plugins/whisper-geth" + }, + { + "path": "../../plugins/whisper-parity" + }, + { + "path": "../../stack/api" + }, + { + "path": "../../stack/authenticator" + }, + { + "path": "../../stack/blockchain" + }, + { + "path": "../../stack/blockchain-client" + }, + { + "path": "../../stack/communication" + }, + { + "path": "../../stack/compiler" + }, + { + "path": "../../stack/contracts-manager" + }, + { + "path": "../../stack/deployment" + }, + { + "path": "../../stack/embarkjs" + }, + { + "path": "../../stack/library-manager" + }, + { + "path": "../../stack/namesystem" + }, + { + "path": "../../stack/pipeline" + }, + { + "path": "../../stack/process-logs-api-manager" + }, + { + "path": "../../stack/proxy" + }, + { + "path": "../../stack/storage" + }, + { + "path": "../../stack/test-runner" + }, + { + "path": "../../stack/watcher" + }, + { + "path": "../../stack/webserver" + }, + { + "path": "../code-runner" + }, + { + "path": "../console" + }, + { + "path": "../core" + }, + { + "path": "../logger" + }, + { + "path": "../utils" + } + ] +} diff --git a/packages/core/typings/tslint.json b/packages/core/engine/tslint.json similarity index 100% rename from packages/core/typings/tslint.json rename to packages/core/engine/tslint.json diff --git a/packages/core/i18n/index.d.ts b/packages/core/i18n/index.d.ts deleted file mode 100644 index 6e35ad128..000000000 --- a/packages/core/i18n/index.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Maybe } from 'embark'; -import * as i18n from 'i18n'; - -declare module 'embark-i18n' { - function setOrDetectLocale(locale: Maybe): void; - function __( - phraseOrOptions: string | i18n.TranslateOptions, - ...replace: string[] - ): string; - function __( - phraseOrOptions: string | i18n.TranslateOptions, - replacements: i18n.Replacements - ): string; -} diff --git a/packages/core/i18n/package.json b/packages/core/i18n/package.json index fccccfc0a..82b4b3062 100644 --- a/packages/core/i18n/package.json +++ b/packages/core/i18n/package.json @@ -26,36 +26,36 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "npm-run-all lint:*", "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", - "qa": "npm-run-all lint typecheck _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "solo": "embark-solo" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", + "@types/i18n": "0.8.3", "colors": "1.3.2", "core-js": "3.4.3", "i18n": "0.8.3", "os-locale": "4.0.0" }, "devDependencies": { - "@types/i18n": "0.8.3", "embark-solo": "^5.0.0-alpha.2", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/core/i18n/src/index.ts b/packages/core/i18n/src/index.ts index 1a497abce..6ccd64bc7 100644 --- a/packages/core/i18n/src/index.ts +++ b/packages/core/i18n/src/index.ts @@ -3,7 +3,7 @@ import * as i18n from 'i18n'; import * as osLocale from 'os-locale'; import * as path from 'path'; -import { Maybe } /* supplied by @types/embark in packages/embark-typings */ from 'embark'; +type Maybe = false | 0 | undefined | null | T; enum LocalType { Specified = 'specified', @@ -49,4 +49,4 @@ export const setOrDetectLocale = (locale: Maybe) => { i18n.setLocale(DEFAULT_LANGUAGE); -export const __ = i18nEmbark.__; +export const __ = (i18nEmbark.__ as unknown) as i18nAPI["__"]; diff --git a/packages/core/i18n/tsconfig.json b/packages/core/i18n/tsconfig.json index 1bb65da9e..a07f71b66 100644 --- a/packages/core/i18n/tsconfig.json +++ b/packages/core/i18n/tsconfig.json @@ -1,4 +1,12 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-i18n.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] } diff --git a/packages/core/logger/package.json b/packages/core/logger/package.json index df057bcfe..ab860316f 100644 --- a/packages/core/logger/package.json +++ b/packages/core/logger/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, @@ -44,8 +47,7 @@ "@babel/runtime-corejs3": "7.7.4", "colors": "1.3.2", "core-js": "3.4.3", - "date-and-time": "0.6.2", - "embark-utils": "^5.0.0-alpha.4" + "date-and-time": "0.6.2" }, "devDependencies": { "embark-solo": "^5.0.0-alpha.2", diff --git a/packages/core/logger/src/index.js b/packages/core/logger/src/index.js index 5f7240284..3edb8b011 100644 --- a/packages/core/logger/src/index.js +++ b/packages/core/logger/src/index.js @@ -1,16 +1,24 @@ require('colors'); const fs = require('fs'); const date = require('date-and-time'); -const { escapeHtml } = require('embark-utils'); +const { escapeHtml } = require('./utils'); const util = require('util'); const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss:SSS'; const LOG_REGEX = new RegExp(/\[(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d:\d\d\d)\] (?:\[(\w*)\]:?)?\s?\s?(.*)/gmi); +export const LogLevels = { + error: 'error', + warn: 'warn', + info: 'info', + debug: 'debug', + trace: 'trace' +}; + export class Logger { constructor(options) { this.events = options.events || {emit: function(){}}; - this.logLevels = Object.keys(Logger.logLevels); + this.logLevels = Object.keys(LogLevels); this.logLevel = options.logLevel || 'info'; this._logFunction = options.logFunction || console.log; this.logFunction = function() { @@ -67,14 +75,6 @@ export class Logger { } } -Logger.logLevels = { - error: 'error', - warn: 'warn', - info: 'info', - debug: 'debug', - trace: 'trace' -}; - Logger.prototype.registerAPICall = function (plugins) { const self = this; diff --git a/packages/core/logger/src/utils.js b/packages/core/logger/src/utils.js new file mode 100644 index 000000000..a5fcfb5ad --- /dev/null +++ b/packages/core/logger/src/utils.js @@ -0,0 +1,10 @@ +exports.escapeHtml = function(message) { + if(typeof message !== "string") return message; + + return message + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/\"/g, """) + .replace(/\'/g, "'"); +}; diff --git a/packages/core/logger/tsconfig.json b/packages/core/logger/tsconfig.json new file mode 100644 index 000000000..ab874d3c4 --- /dev/null +++ b/packages/core/logger/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-logger.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/core/reset/bin.js b/packages/core/reset/bin.js index 1b239c75c..5310da38c 100755 --- a/packages/core/reset/bin.js +++ b/packages/core/reset/bin.js @@ -2,4 +2,4 @@ /* global module require */ -require('./').reset(); +require('./src').reset(); diff --git a/packages/core/reset/package.json b/packages/core/reset/package.json index 0cd5e2d92..4d17ca485 100644 --- a/packages/core/reset/package.json +++ b/packages/core/reset/package.json @@ -13,19 +13,30 @@ "url": "https://github.com/embark-framework/embark.git" }, "bin": "./bin.js", - "main": "index.js", + "main": "./src/index.js", + "types": "./dist/index.d.ts", "files": [ - "bin.js" + "bin.js", + "dist", + "src" ], - "embark-collective": {}, + "embark-collective": { + "typecheck": true + }, "scripts": { + "_typecheck": "npm run solo -- typecheck", + "ci": "npm run qa", + "clean": "npm run reset", + "qa": "npm-run-all _typecheck", + "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, "dependencies": { "rimraf": "3.0.0" }, "devDependencies": { - "embark-solo": "^5.0.0-alpha.2" + "embark-solo": "^5.0.0-alpha.2", + "npm-run-all": "4.1.5" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/core/reset/index.js b/packages/core/reset/src/index.js similarity index 100% rename from packages/core/reset/index.js rename to packages/core/reset/src/index.js diff --git a/packages/core/reset/tsconfig.json b/packages/core/reset/tsconfig.json new file mode 100644 index 000000000..8e4dc27af --- /dev/null +++ b/packages/core/reset/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-reset.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/core/typings/.gitignore b/packages/core/typings/.gitignore deleted file mode 100644 index 407ab2240..000000000 --- a/packages/core/typings/.gitignore +++ /dev/null @@ -1 +0,0 @@ -types-embark-*.tgz diff --git a/packages/core/typings/CHANGELOG.md b/packages/core/typings/CHANGELOG.md deleted file mode 100644 index 50a3d7ec1..000000000 --- a/packages/core/typings/CHANGELOG.md +++ /dev/null @@ -1,144 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [5.0.0-alpha.2](https://github.com/embark-framework/embark/compare/v5.0.0-alpha.1...v5.0.0-alpha.2) (2019-12-05) - - -### Bug Fixes - -* **@embark/core:** ensure type declaration for Plugin.registerActionForEvent() is legit ([5dc4b21](https://github.com/embark-framework/embark/commit/5dc4b21)), closes [/github.com/embark-framework/embark/commit/776db1b7f71e9a78f216cf2acc6c1387c60b3604#diff-5cab125016e6d753f03b6cd0241d5ebbR267](https://github.com//github.com/embark-framework/embark/commit/776db1b7f71e9a78f216cf2acc6c1387c60b3604/issues/diff-5cab125016e6d753f03b6cd0241d5ebbR267) -* **@embark/proxy:** Fix unsubsribe handling and add new provider ([f6f4507](https://github.com/embark-framework/embark/commit/f6f4507)) - - -### Features - -* **@embark/embark-rpc-manager:** Add support for `eth_signTypedData_v3` ([c7ec49a](https://github.com/embark-framework/embark/commit/c7ec49a)), closes [#1850](https://github.com/embark-framework/embark/issues/1850) [#1850](https://github.com/embark-framework/embark/issues/1850) - - - - - -# [5.0.0-alpha.1](https://github.com/embark-framework/embark/compare/v5.0.0-alpha.0...v5.0.0-alpha.1) (2019-11-05) - - -### Bug Fixes - -* **@embark/proxy:** Fix contract event subscriptions ([f9ad486](https://github.com/embark-framework/embark/commit/f9ad486)) - - - - - -# [5.0.0-alpha.0](https://github.com/embark-framework/embark/compare/v4.1.1...v5.0.0-alpha.0) (2019-10-28) - - -### Bug Fixes - -* **@embark/proxy:** Fix contract event subscriptions ([173d53d](https://github.com/embark-framework/embark/commit/173d53d)) - - -### Build System - -* bump all packages' engines settings ([#1985](https://github.com/embark-framework/embark/issues/1985)) ([ed02cc8](https://github.com/embark-framework/embark/commit/ed02cc8)) - - -### Features - -* **@embark/compiler:** support :before and :after hooks on event compiler:contracts:compile ([#1878](https://github.com/embark-framework/embark/issues/1878)) ([043ccc0](https://github.com/embark-framework/embark/commit/043ccc0)) - - -### BREAKING CHANGES - -* node: >=10.17.0 <12.0.0 -npm: >=6.11.3 -yarn: >=1.19.1 - -node v10.17.0 is the latest in the 10.x series and is still in the Active LTS -lifecycle. Embark is still not compatible with node's 12.x and 13.x -series (because of some dependencies), otherwise it would probably make sense -to bump our minimum supported node version all the way to the most recent 12.x -release. - -npm v6.11.3 is the version that's bundled with node v10.17.0. - -yarn v1.19.1 is the most recent version as of the time node v10.17.0 was -released. - - - - - -# [4.1.0](https://github.com/embark-framework/embark/compare/v4.1.0-beta.6...v4.1.0) (2019-08-12) - -**Note:** Version bump only for package @types/embark - - - - - -# [4.1.0-beta.5](https://github.com/embark-framework/embark/compare/v4.1.0-beta.4...v4.1.0-beta.5) (2019-07-10) - - -### Bug Fixes - -* **@embark/code-runner:** restore EmbarkJS.environment property in the cli dashboard ([7d27125](https://github.com/embark-framework/embark/commit/7d27125)) - - - - - -# [4.1.0-beta.4](https://github.com/embark-framework/embark/compare/v4.1.0-beta.3...v4.1.0-beta.4) (2019-06-27) - - -### Bug Fixes - -* **@embark/coverage:** function types and single statement ifs ([2ce9ca6](https://github.com/embark-framework/embark/commit/2ce9ca6)) - - - - - -# [4.1.0-beta.3](https://github.com/embark-framework/embark/compare/v4.1.0-beta.2...v4.1.0-beta.3) (2019-06-07) - -**Note:** Version bump only for package @types/embark - - - - - -# [4.1.0-beta.1](https://github.com/embark-framework/embark/compare/v4.1.0-beta.0...v4.1.0-beta.1) (2019-05-15) - - -### Features - -* **@embark/api:** Add command `service api on/off` ([634feb5](https://github.com/embark-framework/embark/commit/634feb5)) - - - - - -# [4.0.0](https://github.com/embark-framework/embark/compare/v4.0.0-beta.2...v4.0.0) (2019-03-18) - -**Note:** Version bump only for package @types/embark - - - - - -# [4.0.0-beta.1](https://github.com/embark-framework/embark/compare/v4.0.0-beta.0...v4.0.0-beta.1) (2019-03-18) - - -### Bug Fixes - -* **@embark/cockpit:** Fix cockpit not suggesting console commands ([0eaad43](https://github.com/embark-framework/embark/commit/0eaad43)) -* **console:** fix ENS tests not working with embark side by side ([e20c08a](https://github.com/embark-framework/embark/commit/e20c08a)) - - -### Features - -* **@embark/core:** Auto generate EmbarkJS events ([d378ccf](https://github.com/embark-framework/embark/commit/d378ccf)) -* **test/reporter:** log tx functions during tests ([87d92b6](https://github.com/embark-framework/embark/commit/87d92b6)) -* add repository.directory field to package.json ([a9c5e1a](https://github.com/embark-framework/embark/commit/a9c5e1a)) -* normalize README and package.json bugs, homepage, description ([5418f16](https://github.com/embark-framework/embark/commit/5418f16)) diff --git a/packages/core/typings/index.d.ts b/packages/core/typings/index.d.ts deleted file mode 100644 index ee62d5193..000000000 --- a/packages/core/typings/index.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import './src/omg-js-util'; -import './src/prettier-plugin-solidity'; -import './src/remix-debug-debugtest'; - -export * from './src/callbacks'; -export * from './src/contract'; -export * from './src/embark'; -export * from './src/contractsConfig'; -export * from './src/embarkConfig'; -export * from './src/logger'; -export * from './src/maybe'; -export * from './src/plugins'; diff --git a/packages/core/typings/package.json b/packages/core/typings/package.json deleted file mode 100644 index ac6744bbe..000000000 --- a/packages/core/typings/package.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "@types/embark", - "private": true, - "version": "5.0.0-alpha.2", - "author": "Iuri Matias ", - "contributors": [], - "description": "TypeScript definitions for Embark", - "license": "MIT", - "main": "", - "types": "index", - "embark-collective": {}, - "scripts": { - "ci": "npm run qa", - "lint": "tslint -c tslint.json index.d.ts \"src/**/*.ts\"", - "qa": "npm-run-all lint typecheck", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" - }, - "devDependencies": { - "@types/web3": "1.0.12", - "embark-solo": "^5.0.0-alpha.2", - "npm-run-all": "4.1.5", - "tslint": "5.16.0", - "typescript": "3.6.3" - }, - "engines": { - "node": ">=10.17.0 <12.0.0", - "npm": ">=6.11.3", - "yarn": ">=1.19.1" - } -} diff --git a/packages/core/typings/src/callbacks.d.ts b/packages/core/typings/src/callbacks.d.ts deleted file mode 100644 index a7a620a85..000000000 --- a/packages/core/typings/src/callbacks.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type Callback = (err?: Error | null, val?: Tv) => void; diff --git a/packages/core/typings/src/contract.d.ts b/packages/core/typings/src/contract.d.ts deleted file mode 100644 index fa3041afb..000000000 --- a/packages/core/typings/src/contract.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ABIDefinition } from 'web3/eth/abi'; - -export interface Contract { - abiDefinition: ABIDefinition[]; - deployedAddress: string; - className: string; - silent?: boolean; -} diff --git a/packages/core/typings/src/contractsConfig.d.ts b/packages/core/typings/src/contractsConfig.d.ts deleted file mode 100644 index 9bbe78ef0..000000000 --- a/packages/core/typings/src/contractsConfig.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface ContractsConfig { - deploy: { [name: string]: ContractConfig }; - gas: string | number; - tracking: boolean | string; -} - -export interface ContractConfig { - address?: string; - args?: any[]; - instanceOf?: string; - gas?: number; - gasPrice?: number; - silent?: boolean; - track?: boolean; - deploy?: boolean; -} diff --git a/packages/core/typings/src/embark.d.ts b/packages/core/typings/src/embark.d.ts deleted file mode 100644 index 440f89b10..000000000 --- a/packages/core/typings/src/embark.d.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { Logger } from './logger'; -import { Plugins } from './plugins'; -import { Callback } from './callbacks'; - -type CommandCallback = ( - opt1?: any, - opt2?: any, - opt3?: any, - opt4?: any, - opt5?: any, - opt6?: any, - opt7?: any, - opt8?: any, - opt9?: any, - opt10?: any, - opt11?: any, - opt12?: any, -) => any; - -export interface Events { - on: any; - request: any; - request2: any; - emit: any; - once: any; - setCommandHandler( - name: string, - callback: CommandCallback, - ): void; -} - -export interface Config { - contractsFiles: any[]; - embarkConfig: { - contracts: string[] | string; - config: { - contracts: string; - }; - versions: { - solc: string; - }; - generationDir: string; - }; - blockchainConfig: { - endpoint: string; - accounts: any[]; - proxy: boolean; - rpcPort: string | number; - wsPort: string | number; - rpcHost: string | number; - wsHost: string | number; - wsOrigins: string; - rpcCorsDomain: string; - wsRPC: boolean; - isDev: boolean; - client: string; - }; - webServerConfig: { - certOptions: { - key: string; - cert: string; - }; - }; - plugins: Plugins; - reloadConfig(): void; -} - -type ActionCallback = (params: any, cb: Callback) => void; - -export interface Embark { - env: string; - events: Events; - plugins: Plugins; - registerAPICall(method: string, endpoint: string, cb: (...args: any[]) => void): void; - registerConsoleCommand: any; - logger: Logger; - fs: any; - config: Config; - currentContext: string[]; - registerActionForEvent( - name: string, - options?: ActionCallback | { priority: number }, - action?: ActionCallback, - ): void; -} diff --git a/packages/core/typings/src/embarkConfig.d.ts b/packages/core/typings/src/embarkConfig.d.ts deleted file mode 100644 index 1917dcd6e..000000000 --- a/packages/core/typings/src/embarkConfig.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface EmbarkConfig { - contracts: [string]; -} diff --git a/packages/core/typings/src/logger.d.ts b/packages/core/typings/src/logger.d.ts deleted file mode 100644 index a27920016..000000000 --- a/packages/core/typings/src/logger.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface Logger { - info(text: string): void; - warn(text: string): void; - debug(text: string): void; - trace(text: string): void; - error(text: string, ...args: Array): void; -} diff --git a/packages/core/typings/src/maybe.d.ts b/packages/core/typings/src/maybe.d.ts deleted file mode 100644 index 99774bacc..000000000 --- a/packages/core/typings/src/maybe.d.ts +++ /dev/null @@ -1 +0,0 @@ -export type Maybe = false | 0 | undefined | null | T; diff --git a/packages/core/typings/src/omg-js-util/index.d.ts b/packages/core/typings/src/omg-js-util/index.d.ts deleted file mode 100644 index d01b2140e..000000000 --- a/packages/core/typings/src/omg-js-util/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module '@omisego/omg-js-util'; diff --git a/packages/core/typings/src/plugins.d.ts b/packages/core/typings/src/plugins.d.ts deleted file mode 100644 index d417f5dc1..000000000 --- a/packages/core/typings/src/plugins.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import {Callback} from './callbacks'; - -export interface Plugin { - dappGenerators: any; -} - -export interface Plugins { - getPluginsFor(name: string): [Plugin]; - loadInternalPlugin(name: string, options: any): void; - getPluginsProperty(pluginType: string, property: string, sub_property?: string): any[]; - plugins: Plugin[]; - runActionsForEvent(event: string, args: any, cb: Callback): void; -} - -export interface Plugin { - name: string; -} - -export interface CompilerPluginObject { - extension: string; - cb: any; -} diff --git a/packages/core/typings/src/prettier-plugin-solidity/index.d.ts b/packages/core/typings/src/prettier-plugin-solidity/index.d.ts deleted file mode 100644 index 09f21d221..000000000 --- a/packages/core/typings/src/prettier-plugin-solidity/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module 'prettier-plugin-solidity'; diff --git a/packages/core/typings/src/remix-debug-debugtest/index.d.ts b/packages/core/typings/src/remix-debug-debugtest/index.d.ts deleted file mode 100644 index 8ac57156c..000000000 --- a/packages/core/typings/src/remix-debug-debugtest/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module 'remix-debug-debugtest'; diff --git a/packages/core/typings/tsconfig.json b/packages/core/typings/tsconfig.json deleted file mode 100644 index fbc8f004c..000000000 --- a/packages/core/typings/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "files": [ - "index.d.ts" - ], - "include": ["src/**/*"] -} diff --git a/packages/core/utils/foo.d.ts b/packages/core/utils/foo.d.ts deleted file mode 100644 index aa0d5a583..000000000 --- a/packages/core/utils/foo.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -declare module "embark-utils" { - import {Logger} from "embark"; - - export class File { - public path: string; - constructor(options: any); - public prepareForCompilation(isCoverage?: boolean): any; - } - - function anchoredValue(anchor: string|null, value: string): string; - function anchoredPath(anchor: string|null, ...args: string[]): string; - function compact(array: any): any; - function checkIsAvailable(url: string, callback: any): void; - function dockerHostSwap(host: string): string; - function buildUrl(protocol: string, host: string, port: number, type: string): string; - function buildUrlFromConfig(config: any): string; - function canonicalHost(host: string): string; - function dappPath(...names: string[]): string; - function diagramPath(...names: string[]): string; - function escapeHtml(message: any): string; - function embarkPath(...names: string[]): string; - function exit(code?: any): void; - function findMonorepoPackageFromRoot(pkgName: string, prefilter?: null | ((pkgName: string) => (pkgJsonPath: string) => boolean)): Promise; - function findMonorepoPackageFromRootSync(pkgName: string, prefilter?: null | ((pkgName: string) => (pkgJsonPath: string) => boolean)): string; - function findNextPort(port: number): Promise; - function isEs6Module(module: any): boolean; - function isInsideMonorepo(): Promise; - function isInsideMonorepoSync(): boolean; - function monorepoRootPath(): Promise; - function monorepoRootPathSync(): string; - function jsonFunctionReplacer(key: any, value: any): any; - function fuzzySearch(text: string, list: any, filter: any): any; - function getExternalContractUrl(file: string, provideUrl: string): string; - function recursiveMerge(target: any, source: any): any; - function pkgPath(...names: string[]): string; - function removePureView(dir: string): void; - function pingEndpoint(host: string, port: number, type: string, protocol: string, origin: string, callback: any): void; - - export class AccountParser { - public static parseAccountsConfig(accountsConfig: any[], web3: any, dappPath: string, logger: Logger, nodeAccounts?: any[]): any[]; - } -} diff --git a/packages/core/utils/package.json b/packages/core/utils/package.json index 3d08f64b2..3644db96a 100644 --- a/packages/core/utils/package.json +++ b/packages/core/utils/package.json @@ -25,28 +25,32 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "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\"", - "qa": "npm-run-all lint typecheck _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "solo": "embark-solo" }, "eslintConfig": { "extends": "../../../.eslintrc.json" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", + "@types/follow-redirects": "1.5.0", + "@types/fs-extra": "7.0.0", + "@types/node": "12.7.8", + "@types/pretty-ms": "5.0.1", "bip39": "3.0.2", "clipboardy": "1.2.3", "colors": "1.3.2", @@ -71,17 +75,13 @@ "ws": "7.1.2" }, "devDependencies": { - "@types/follow-redirects": "1.5.0", - "@types/fs-extra": "7.0.0", - "@types/node": "12.7.8", - "@types/pretty-ms": "5.0.1", "embark-inside-monorepo": "^5.0.0-alpha.0", "embark-solo": "^5.0.0-alpha.2", "eslint": "5.7.0", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/core/utils/src/accountParser.js b/packages/core/utils/src/accountParser.js index 4d44c8f66..4a934af57 100644 --- a/packages/core/utils/src/accountParser.js +++ b/packages/core/utils/src/accountParser.js @@ -35,7 +35,7 @@ export default class AccountParser { } /*eslint complexity: ["error", 30]*/ - static getAccount(accountConfig, web3, dappPath, logger = console, nodeAccounts) { + static getAccount(accountConfig, web3, dappPath, logger = console, nodeAccounts = null) { const returnAddress = web3 === false; let hexBalance = null; if (accountConfig.balance && web3) { diff --git a/packages/core/utils/src/index.ts b/packages/core/utils/src/index.ts index 95ec3b736..ea12626dd 100644 --- a/packages/core/utils/src/index.ts +++ b/packages/core/utils/src/index.ts @@ -27,7 +27,6 @@ export { soliditySha3, toChecksumAddress } from './web3Utils'; -export { getAddressToContract, getTransactionParams } from './transactionUtils'; import LongRunningProcessTimer from './longRunningProcessTimer'; export { LongRunningProcessTimer }; import AccountParser from './accountParser'; diff --git a/packages/core/utils/src/solidity/remapImports.ts b/packages/core/utils/src/solidity/remapImports.ts index 96b6e1d6b..ae1f4e836 100644 --- a/packages/core/utils/src/solidity/remapImports.ts +++ b/packages/core/utils/src/solidity/remapImports.ts @@ -30,12 +30,23 @@ const getImports = (source: string) => { }).filter((fileImport) => fileImport.length); }; -const prepareInitialFile = async (file: File) => { +const prepareInitialFile = async (file: File | any) => { if (file.type === Types.http) { return await file.content; } - const to = file.path.includes(dappPath(".embark")) ? path.normalize(file.path) : dappPath(".embark", file.path); + let to: string; + if (file.path.includes(dappPath(".embark"))) { + to = path.normalize(file.path); + } else if (path.isAbsolute(file.path)) { + // don't want 'C:\' in calculated path on Windows + const relativeFrom = path.normalize('/'); + const relativePath = path.relative(relativeFrom, file.path); + to = dappPath(".embark", relativePath); + } else { + to = dappPath(".embark", file.path); + } + if (file.type === Types.dappFile || file.type === Types.custom) { if (file.resolver) { fs.mkdirpSync(path.dirname(to)); diff --git a/packages/core/utils/tsconfig.json b/packages/core/utils/tsconfig.json index 1bb65da9e..4478b3429 100644 --- a/packages/core/utils/tsconfig.json +++ b/packages/core/utils/tsconfig.json @@ -1,4 +1,20 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-utils.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../i18n" + }, + { + "path": "../logger" + } + ] } diff --git a/packages/embark/package.json b/packages/embark/package.json index 261e9fdc1..6c55de015 100644 --- a/packages/embark/package.json +++ b/packages/embark/package.json @@ -25,6 +25,7 @@ "embark": "./bin/embark" }, "main": "./dist/lib/index.js", + "types": "./dist/lib/index.d.ts", "files": [ "bin", "dist/bin", @@ -33,14 +34,22 @@ "locales" ], "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": { + "include": [ + "src/bin/**/*", + "src/cmd/**/*", + "src/lib/**/*" + ] + } }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint bin/embark src/bin/ src/lib/", - "qa": "npm-run-all lint _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf .nyc_output coverage dist embark-*.tgz package", "solo": "embark-solo", "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require ./scripts/test.js --require source-map-support/register" @@ -68,61 +77,15 @@ "core-js": "3.4.3", "date-and-time": "0.6.2", "decompress": "4.2.0", - "deep-equal": "1.0.1", - "embark-accounts-manager": "^5.0.0-alpha.4", - "embark-api": "^5.0.0-alpha.4", - "embark-authenticator": "^5.0.0-alpha.4", - "embark-basic-pipeline": "^5.0.0-alpha.4", - "embark-blockchain": "^5.0.0-alpha.4", - "embark-blockchain-client": "^5.0.0-alpha.2", - "embark-code-runner": "^5.0.0-alpha.4", - "embark-communication": "^5.0.0-alpha.4", - "embark-compiler": "^5.0.0-alpha.4", - "embark-console": "^5.0.0-alpha.4", - "embark-contracts-manager": "^5.0.0-alpha.4", "embark-core": "^5.0.0-alpha.4", - "embark-coverage": "^5.0.0-alpha.4", - "embark-debugger": "^5.0.0-alpha.4", "embark-deploy-tracker": "^5.0.0-alpha.2", - "embark-deployment": "^5.0.0-alpha.4", - "embark-embarkjs": "^5.0.0-alpha.4", - "embark-ens": "^5.0.0-alpha.4", - "embark-ethereum-blockchain-client": "^5.0.0-alpha.4", - "embark-ganache": "^5.0.0-alpha.2", - "embark-geth": "^5.0.0-alpha.4", + "embark-engine": "^5.0.0-alpha.4", "embark-graph": "^5.0.0-alpha.2", "embark-i18n": "^5.0.0-alpha.2", - "embark-ipfs": "^5.0.0-alpha.4", - "embark-library-manager": "^5.0.0-alpha.4", "embark-logger": "^5.0.0-alpha.4", - "embark-mocha-tests": "^5.0.0-alpha.4", - "embark-namesystem": "^5.0.0-alpha.2", - "embark-parity": "^5.0.0-alpha.4", - "embark-pipeline": "^5.0.0-alpha.4", - "embark-plugin-cmd": "^5.0.0-alpha.4", - "embark-process-logs-api-manager": "^5.0.0-alpha.4", - "embark-profiler": "^5.0.0-alpha.2", - "embark-proxy": "^5.0.0-alpha.4", "embark-reset": "^5.0.0-alpha.2", "embark-scaffolding": "^5.0.0-alpha.2", - "embark-solidity": "^5.0.0-alpha.4", - "embark-specialconfigs": "^5.0.0-alpha.2", - "embark-storage": "^5.0.0-alpha.4", - "embark-swarm": "^5.0.0-alpha.4", - "embark-test-runner": "^5.0.0-alpha.4", - "embark-transaction-logger": "^5.0.0-alpha.4", - "embark-transaction-tracker": "^5.0.0-alpha.2", - "embark-ui": "^5.0.0-alpha.4", "embark-utils": "^5.0.0-alpha.4", - "embark-vyper": "^5.0.0-alpha.2", - "embark-watcher": "^5.0.0-alpha.4", - "embark-web3": "^5.0.0-alpha.4", - "embark-webserver": "^5.0.0-alpha.4", - "embarkjs-ens": "^5.0.0-alpha.4", - "embarkjs-ipfs": "^5.0.0-alpha.2", - "embarkjs-swarm": "^5.0.0-alpha.2", - "embarkjs-web3": "^5.0.0-alpha.2", - "embarkjs-whisper": "^5.0.0-alpha.2", "eth-ens-namehash": "2.0.8", "ethereumjs-wallet": "0.6.3", "find-up": "2.1.0", @@ -179,10 +142,15 @@ }, "devDependencies": { "chai": "4.1.2", + "embark-code-runner": "^5.0.0-alpha.4", + "embark-compiler": "^5.0.0-alpha.4", + "embark-contracts-manager": "^5.0.0-alpha.4", + "embark-solidity": "^5.0.0-alpha.3", "embark-solo": "^5.0.0-alpha.2", "embark-test-contract-0": "0.0.2", "embark-test-contract-1": "0.0.1", "embark-testing": "^5.0.0-alpha.4", + "embark-transaction-logger": "^5.0.0-alpha.3", "eslint": "5.7.0", "npm-run-all": "4.1.5", "nyc": "13.1.0", diff --git a/packages/embark/src/cmd/cmd_controller.js b/packages/embark/src/cmd/cmd_controller.js index 9ebd5c17c..295c245cb 100644 --- a/packages/embark/src/cmd/cmd_controller.js +++ b/packages/embark/src/cmd/cmd_controller.js @@ -1,17 +1,20 @@ -import { Config, Engine, Events, fs, TemplateGenerator } from 'embark-core'; +import { Config, Events, fs, TemplateGenerator } from 'embark-core'; +import { Engine } from 'embark-engine'; import { __ } from 'embark-i18n'; import { dappPath, embarkPath, joinPath, setUpEnv } from 'embark-utils'; -import { Logger } from 'embark-logger'; +import { Logger, LogLevels } from 'embark-logger'; let async = require('async'); const constants = require('embark-core/constants'); const { reset: embarkReset, paths: defaultResetPaths } = require('embark-reset'); const cloneDeep = require('clone-deep'); +import { readJsonSync } from 'fs-extra'; +import { join } from 'path'; setUpEnv(joinPath(__dirname, '../../')); require('colors'); -let pkg = require('../../package.json'); +const pkg = readJsonSync(join(__dirname, '../../package.json')); class EmbarkController { @@ -26,7 +29,7 @@ class EmbarkController { initConfig(env, options) { this.events = new Events(); - this.logger = new Logger({ logLevel: Logger.logLevels.debug, events: this.events, context: this.context }); + this.logger = new Logger({ logLevel: LogLevels.debug, events: this.events, context: this.context }); this.config = new Config({ env: env, logger: this.logger, events: this.events, context: this.context, version: this.version }); this.config.loadConfigFiles(options); this.plugins = this.config.plugins; @@ -739,7 +742,7 @@ class EmbarkController { version: this.version, embarkConfig: options.embarkConfig || 'embark.json', logFile: options.logFile, - logLevel: options.logLevel || Logger.logLevels.warn, + logLevel: options.logLevel || LogLevels.warn, context: this.context, useDashboard: false, webpackConfigName: options.webpackConfigName, diff --git a/packages/embark/src/lib/index.js b/packages/embark/src/lib/index.js index 726002668..ed8624e48 100644 --- a/packages/embark/src/lib/index.js +++ b/packages/embark/src/lib/index.js @@ -1,8 +1,11 @@ -let pkg = require('../../package.json'); import { Config, Events } from 'embark-core'; import { Logger } from 'embark-logger'; +import { readJsonSync } from 'fs-extra'; +import { join } from 'path'; -class Embark { +const pkg = readJsonSync(join(__dirname, '../../package.json')); + +export default class Embark { constructor(options) { this.version = pkg.version; @@ -25,5 +28,3 @@ class Embark { this.plugins = this.config.plugins; } } - -module.exports = Embark; diff --git a/packages/embark/src/test/cmd.js b/packages/embark/src/test/cmd.js index 767c82b7c..2dd1a4797 100644 --- a/packages/embark/src/test/cmd.js +++ b/packages/embark/src/test/cmd.js @@ -1,4 +1,4 @@ -let Embark = require('../lib/index'); +import Embark from '../lib/index'; let Cmd = require('../cmd/cmd'); // Function to send a line to stdin diff --git a/packages/embark/src/test/contracts.js b/packages/embark/src/test/contracts.js index 2386f0448..5774ac644 100644 --- a/packages/embark/src/test/contracts.js +++ b/packages/embark/src/test/contracts.js @@ -1,8 +1,8 @@ /*global describe, it, require*/ import { File, Types } from "embark-utils"; -let ContractsManager = require('embark-contracts-manager'); -let Compiler = require('embark-compiler'); +import ContractsManager from 'embark-contracts-manager'; +import Compiler from 'embark-compiler'; import { Logger } from 'embark-logger'; import { Events, fs, IPC, TestLogger, Plugins } from 'embark-core'; let assert = require('assert'); diff --git a/packages/embark/src/test/modules/compiler/compiler.js b/packages/embark/src/test/modules/compiler/compiler.js index 072c144d7..f11ac05ef 100644 --- a/packages/embark/src/test/modules/compiler/compiler.js +++ b/packages/embark/src/test/modules/compiler/compiler.js @@ -4,7 +4,7 @@ import { File, Types } from "embark-utils"; const assert = require('assert'); -const Compiler = require('embark-compiler'); +import Compiler from 'embark-compiler'; const readFile = function(file) { return new File({filename: file, type: Types.dappFile, path: file}); diff --git a/packages/embark/src/test/modules/console_listener.js.disabled b/packages/embark/src/test/modules/console_listener.js.disabled deleted file mode 100644 index 547eda695..000000000 --- a/packages/embark/src/test/modules/console_listener.js.disabled +++ /dev/null @@ -1,190 +0,0 @@ -/*globals describe, it, beforeEach*/ -const {expect} = require('chai'); -const sinon = require('sinon'); -import { Logger } from 'embark-logger'; -import { getAddressToContract } from 'embark-utils'; -const ConsoleListener = require('embark-console-listener'); -import { Events, fs, IPC } from 'embark-core'; -require('colors'); - -let events, - logger, - consoleListener, - ipc, - embark, - loggerInfos = [], - eventsEmitted = [], - ipcRequest, - contractsList; - -function resetTest() { - loggerInfos = []; - eventsEmitted = []; - ipcRequest = { - type: 'contract-log', - address: "0x12345", - data: "0x6d4ce63c", - transactionHash: "hash", - blockNumber: "0x0", - gasUsed: "0x0", - status: "yay" - }; - contractsList = [ - { - abiDefinition: [ - { - "constant": true, - "inputs": [], - "name": "storedData", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "x", - "type": "uint256" - } - ], - "name": "set", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "get", - "outputs": [ - { - "name": "retVal", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "initialValue", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - } - ], - deployedAddress: "0x12345", - className: "SimpleStorage", - silent: true - } - ]; - - events = new Events(); - logger = new Logger(events); - ipc = new IPC({ipcRole: 'none'}); - embark = { - events, - logger, - fs: { - existsSync: () => { return false; }, - dappPath: () => { return "ok"; } - }, - config: { - contractsConfig: {} - }, - registerAPICall: () => {} - }; - - // setup ConsoleListener - consoleListener = new ConsoleListener(embark, {ipc}); - consoleListener.contractsDeployed = true; - consoleListener.outputDone = true; - - sinon.stub(events, 'emit').callsFake((eventName, data) => { - eventsEmitted.push({eventName, data}); - return true; - }); - sinon.stub(logger, 'info').callsFake((args) => { - loggerInfos.push(args); - }); -} - -describe('Console Listener', function () { - beforeEach('reset test', function (done) { - resetTest(); - done(); - }); - - describe('#listenForLogRequests', function () { - it('should emit the correct contracts logs', function (done) { - getAddressToContract(contractsList, consoleListener.addressToContract); - consoleListener._onIpcLogRequest(ipcRequest); - - const expectedContractLog = { - address: "0x12345", - blockNumber: 0, - data: "0x6d4ce63c", - functionName: "get", - gasUsed: 0, - name: "SimpleStorage", - paramString: "", - status: "yay", - transactionHash: "hash", - type: "contract-log" - }; - const {name, functionName, paramString, transactionHash, gasUsed, blockNumber, status} = expectedContractLog; - - const contractLogEmitted = eventsEmitted.find(event => event.eventName === 'contracts:log'); - expect(contractLogEmitted).to.deep.equal({ - eventName: 'contracts:log', - data: expectedContractLog - }); - - const blockchainTxLogEmitted = eventsEmitted.find(event => event.eventName === 'blockchain:tx'); - expect(blockchainTxLogEmitted).to.deep.equal({ - eventName: 'blockchain:tx', - data: { - name, - functionName, - paramString, - transactionHash, - gasUsed, - blockNumber, - status - } - }); - - expect(loggerInfos[0]).to.be.equal(`Blockchain>`.underline + ` ${name}.${functionName}(${paramString})`.bold + ` | ${transactionHash} | gas:${gasUsed} | blk:${blockNumber} | status:${status}`); - done(); - }); - - it('should emit a log for a non-contract log', function (done) { - ipcRequest.type = 'something-other-than-contract-log'; - getAddressToContract(contractsList, consoleListener.addressToContract); - consoleListener._onIpcLogRequest(ipcRequest); - - expect(loggerInfos[0]).to.be.equal(JSON.stringify(ipcRequest)); - done(); - }); - - it('should emit an "unknown contract" log message', function (done) { - consoleListener._onIpcLogRequest(ipcRequest); - - expect(loggerInfos[0]).to.be.equal(`Contract log for unknown contract: ${JSON.stringify(ipcRequest)}`); - done(); - }); - }); -}); diff --git a/packages/embark/src/test/transactionUtils.js b/packages/embark/src/test/transactionUtils.js index 361b4257f..2b9b02dbb 100644 --- a/packages/embark/src/test/transactionUtils.js +++ b/packages/embark/src/test/transactionUtils.js @@ -1,6 +1,6 @@ /*globals describe, it, beforeEach*/ const {expect} = require('chai'); -import { getAddressToContract, getTransactionParams } from 'embark-utils'; +import { getAddressToContract, getTransactionParams } from 'embark-transaction-logger'; require('colors'); let contractsList; diff --git a/packages/embark/tsconfig.json b/packages/embark/tsconfig.json new file mode 100644 index 000000000..3fe1f3e50 --- /dev/null +++ b/packages/embark/tsconfig.json @@ -0,0 +1,61 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark.tsbuildinfo" + }, + "extends": "../../tsconfig.base.json", + "include": [ + "src/bin/**/*", + "src/cmd/**/*", + "src/lib/**/*" + ], + "references": [ + { + "path": "../core/code-runner" + }, + { + "path": "../core/core" + }, + { + "path": "../core/engine" + }, + { + "path": "../core/i18n" + }, + { + "path": "../core/logger" + }, + { + "path": "../core/reset" + }, + { + "path": "../core/utils" + }, + { + "path": "../plugins/deploy-tracker" + }, + { + "path": "../plugins/graph" + }, + { + "path": "../plugins/scaffolding" + }, + { + "path": "../plugins/solidity" + }, + { + "path": "../plugins/transaction-logger" + }, + { + "path": "../stack/compiler" + }, + { + "path": "../stack/contracts-manager" + }, + { + "path": "../utils/testing" + } + ] +} diff --git a/packages/embarkjs/embarkjs/package.json b/packages/embarkjs/embarkjs/package.json index 83e4aef14..c17b13210 100644 --- a/packages/embarkjs/embarkjs/package.json +++ b/packages/embarkjs/embarkjs/package.json @@ -22,10 +22,12 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/lib/node/index.js", + "types": "./dist/lib/node/index.d.ts", "browser": { "./dist/lib/node/index.js": "./dist/browser/lib/index.js", "./dist/browser/lib/async.js": "./dist/browser/lib/browser/async.js" }, + "browserslist": [ "last 1 version", "not dead", @@ -37,13 +39,19 @@ ], "embark-collective": { "build:browser": true, - "build:node": true + "build:node": true, + "typecheck": { + "exclude": [ + "src/lib/browser" + ] + } }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", - "qa": "npm-run-all _build test", + "qa": "npm-run-all _typecheck _build test", "reset": "npx rimraf .nyc_output coverage dist embarkjs-*.tgz package", "solo": "embark-solo", "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register" diff --git a/packages/embarkjs/embarkjs/src/lib/blockchain.js b/packages/embarkjs/embarkjs/src/lib/blockchain.js index a046fa5ac..1cdf179d3 100644 --- a/packages/embarkjs/embarkjs/src/lib/blockchain.js +++ b/packages/embarkjs/embarkjs/src/lib/blockchain.js @@ -3,6 +3,7 @@ import {reduce} from './async'; let Blockchain = { + Contract: Contract, list: [], done: false, err: null @@ -226,7 +227,7 @@ Blockchain.execWhenReady = function(cb) { this.list.push(cb); }; -let Contract = function(options) { +function Contract(options) { var self = this; var ContractClass; @@ -358,8 +359,6 @@ Contract.prototype.send = function(value, unit, _options) { return this.blockchainConnector.send(options); }; -Blockchain.Contract = Contract; - class BlockchainConnectionError extends Error { constructor(connectionErrors) { super("Could not establish a connection to a node."); diff --git a/packages/embarkjs/embarkjs/tsconfig.json b/packages/embarkjs/embarkjs/tsconfig.json new file mode 100644 index 000000000..33e965ca5 --- /dev/null +++ b/packages/embarkjs/embarkjs/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embarkjs.tsbuildinfo" + }, + "exclude": [ + "src/lib/browser" + ], + "extends": "../../../tsconfig.base.json", + "include": [ + "src/lib/**/*" + ] +} diff --git a/packages/embarkjs/ens/package.json b/packages/embarkjs/ens/package.json index fea7f5c59..ff8572e46 100644 --- a/packages/embarkjs/ens/package.json +++ b/packages/embarkjs/ens/package.json @@ -21,7 +21,8 @@ "type": "git", "url": "https://github.com/embark-framework/embark.git" }, - "main": "dist/node/index.js", + "main": "./dist/node/index.js", + "types": "./dist/node/index.d.ts", "browser": "./dist/browser/index.js", "browserslist": [ "last 1 version", @@ -33,13 +34,15 @@ ], "embark-collective": { "build:browser": true, - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", - "qa": "npm-run-all _build", + "qa": "npm-run-all _typecheck _build", "reset": "npx rimraf coverage dist embarkjs-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/embarkjs/ens/src/node/index.js b/packages/embarkjs/ens/src/node/index.js index dd50d42ae..2829f1cbe 100644 --- a/packages/embarkjs/ens/src/node/index.js +++ b/packages/embarkjs/ens/src/node/index.js @@ -1 +1,3 @@ -module.exports = require('..').default; +import embarkENS from '..'; + +module.exports = embarkENS; diff --git a/packages/embarkjs/ens/tsconfig.json b/packages/embarkjs/ens/tsconfig.json new file mode 100644 index 000000000..a9ce81d2e --- /dev/null +++ b/packages/embarkjs/ens/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embarkjs-ens.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../embarkjs" + } + ] +} diff --git a/packages/embarkjs/ipfs/package.json b/packages/embarkjs/ipfs/package.json index 1b325209d..f0681ffd7 100644 --- a/packages/embarkjs/ipfs/package.json +++ b/packages/embarkjs/ipfs/package.json @@ -21,7 +21,8 @@ "type": "git", "url": "https://github.com/embark-framework/embark.git" }, - "main": "dist/node/index.js", + "main": "./dist/node/index.js", + "types": "./dist/node/index.d.ts", "browser": "./dist/browser/index.js", "browserslist": [ "last 1 version", @@ -33,13 +34,15 @@ ], "embark-collective": { "build:browser": true, - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", - "qa": "npm-run-all _build", + "qa": "npm-run-all _typecheck _build", "reset": "npx rimraf coverage dist embarkjs-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/embarkjs/ipfs/src/node/index.js b/packages/embarkjs/ipfs/src/node/index.js index dd50d42ae..b65621d56 100644 --- a/packages/embarkjs/ipfs/src/node/index.js +++ b/packages/embarkjs/ipfs/src/node/index.js @@ -1 +1,3 @@ -module.exports = require('..').default; +import embarkIPFS from '..'; + +module.exports = embarkIPFS; diff --git a/packages/embarkjs/ipfs/tsconfig.json b/packages/embarkjs/ipfs/tsconfig.json new file mode 100644 index 000000000..8b63b94aa --- /dev/null +++ b/packages/embarkjs/ipfs/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embarkjs-ipfs.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/embarkjs/swarm/package.json b/packages/embarkjs/swarm/package.json index cc91a2e49..bad6bcbe8 100644 --- a/packages/embarkjs/swarm/package.json +++ b/packages/embarkjs/swarm/package.json @@ -21,7 +21,8 @@ "type": "git", "url": "https://github.com/embark-framework/embark.git" }, - "main": "dist/node/index.js", + "main": "./dist/node/index.js", + "types": "./dist/node/index.d.ts", "browser": "./dist/browser/index.js", "browserslist": [ "last 1 version", @@ -33,13 +34,15 @@ ], "embark-collective": { "build:browser": true, - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", - "qa": "npm-run-all _build", + "qa": "npm-run-all _typecheck _build", "reset": "npx rimraf coverage dist embarkjs-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/embarkjs/swarm/src/node/index.js b/packages/embarkjs/swarm/src/node/index.js index dd50d42ae..2633bf8f6 100644 --- a/packages/embarkjs/swarm/src/node/index.js +++ b/packages/embarkjs/swarm/src/node/index.js @@ -1 +1,3 @@ -module.exports = require('..').default; +import embarkSwarm from '..'; + +module.exports = embarkSwarm; diff --git a/packages/embarkjs/swarm/tsconfig.json b/packages/embarkjs/swarm/tsconfig.json new file mode 100644 index 000000000..fab04154f --- /dev/null +++ b/packages/embarkjs/swarm/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embarkjs-swarm.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/embarkjs/web3/package.json b/packages/embarkjs/web3/package.json index 679f5ec65..e8eeccb57 100644 --- a/packages/embarkjs/web3/package.json +++ b/packages/embarkjs/web3/package.json @@ -21,7 +21,8 @@ "type": "git", "url": "https://github.com/embark-framework/embark.git" }, - "main": "dist/node/index.js", + "main": "./dist/node/index.js", + "types": "./dist/node/index.d.ts", "browser": "./dist/browser/index.js", "browserslist": [ "last 1 version", @@ -33,13 +34,15 @@ ], "embark-collective": { "build:browser": true, - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", - "qa": "npm-run-all _build", + "qa": "npm-run-all _typecheck _build", "reset": "npx rimraf coverage dist embarkjs-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/embarkjs/web3/src/node/index.js b/packages/embarkjs/web3/src/node/index.js index dd50d42ae..191cbe2df 100644 --- a/packages/embarkjs/web3/src/node/index.js +++ b/packages/embarkjs/web3/src/node/index.js @@ -1 +1,3 @@ -module.exports = require('..').default; +import embarkWeb3 from '..'; + +module.exports = embarkWeb3; diff --git a/packages/embarkjs/web3/tsconfig.json b/packages/embarkjs/web3/tsconfig.json new file mode 100644 index 000000000..81306e1a5 --- /dev/null +++ b/packages/embarkjs/web3/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embarkjs-web3.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/embarkjs/whisper/package.json b/packages/embarkjs/whisper/package.json index ccde3f696..beea069b7 100644 --- a/packages/embarkjs/whisper/package.json +++ b/packages/embarkjs/whisper/package.json @@ -21,7 +21,8 @@ "type": "git", "url": "https://github.com/embark-framework/embark.git" }, - "main": "dist/node/index.js", + "main": "./dist/node/index.js", + "types": "./dist/node/index.d.ts", "browser": "./dist/browser/index.js", "browserslist": [ "last 1 version", @@ -33,13 +34,15 @@ ], "embark-collective": { "build:browser": true, - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", - "qa": "npm-run-all _build", + "qa": "npm-run-all _typecheck _build", "reset": "npx rimraf coverage dist embarkjs-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/embarkjs/whisper/src/node/index.js b/packages/embarkjs/whisper/src/node/index.js index dd50d42ae..fe129f90f 100644 --- a/packages/embarkjs/whisper/src/node/index.js +++ b/packages/embarkjs/whisper/src/node/index.js @@ -1 +1,3 @@ -module.exports = require('..').default; +import embarkWhisper from '..'; + +module.exports = embarkWhisper; diff --git a/packages/embarkjs/whisper/tsconfig.json b/packages/embarkjs/whisper/tsconfig.json new file mode 100644 index 000000000..de2b2ed5f --- /dev/null +++ b/packages/embarkjs/whisper/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embarkjs-whisper.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/plugins/accounts-manager/package.json b/packages/plugins/accounts-manager/package.json index 16b9388eb..90628d6b5 100644 --- a/packages/plugins/accounts-manager/package.json +++ b/packages/plugins/accounts-manager/package.json @@ -25,21 +25,21 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "npm-run-all lint:*", "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", - "qa": "npm-run-all lint typecheck _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "solo": "embark-solo" }, "eslintConfig": { "extends": "../../../.eslintrc.json" @@ -59,8 +59,8 @@ "eslint": "5.7.0", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/plugins/accounts-manager/src/index.ts b/packages/plugins/accounts-manager/src/index.ts index a4229149b..7e4aa1e5a 100644 --- a/packages/plugins/accounts-manager/src/index.ts +++ b/packages/plugins/accounts-manager/src/index.ts @@ -1,5 +1,5 @@ import async from "async"; -import { Callback, Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Embark, EmbarkEvents } from "embark-core"; import { __ } from "embark-i18n"; import { AccountParser, dappPath } from "embark-utils"; import { Logger } from 'embark-logger'; @@ -9,7 +9,7 @@ import fundAccount from "./fundAccount"; export default class AccountsManager { private readonly logger: Logger; - private readonly events: Events; + private readonly events: EmbarkEvents; private _web3: Web3 | null = null; private _accounts: any[] | null = null; diff --git a/packages/plugins/accounts-manager/tsconfig.json b/packages/plugins/accounts-manager/tsconfig.json index 1ffac409c..50f28e647 100644 --- a/packages/plugins/accounts-manager/tsconfig.json +++ b/packages/plugins/accounts-manager/tsconfig.json @@ -1,5 +1,26 @@ { - "compilerOptions": { "baseUrl": ".", "paths": { "*": ["types/*"] } }, - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-accounts-manager.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/logger" + }, + { + "path": "../../core/utils" + } + ] } diff --git a/packages/plugins/basic-pipeline/package.json b/packages/plugins/basic-pipeline/package.json index 861ab71ba..757176b69 100644 --- a/packages/plugins/basic-pipeline/package.json +++ b/packages/plugins/basic-pipeline/package.json @@ -25,15 +25,23 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": { + "exclude": [ + "src/babel-loader-overrides.js", + "src/webpack.config.js" + ] + } }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo", "test": "jest" diff --git a/packages/plugins/basic-pipeline/tsconfig.json b/packages/plugins/basic-pipeline/tsconfig.json new file mode 100644 index 000000000..537b61c65 --- /dev/null +++ b/packages/plugins/basic-pipeline/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-basic-pipeline.tsbuildinfo" + }, + "exclude": [ + "src/babel-loader-overrides.js", + "src/webpack.config.js" + ], + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../utils/testing" + } + ] +} diff --git a/packages/plugins/coverage/package.json b/packages/plugins/coverage/package.json index a2772f74b..60f8f9cc9 100644 --- a/packages/plugins/coverage/package.json +++ b/packages/plugins/coverage/package.json @@ -25,25 +25,31 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/lib/index.js", + "types": "./dist/lib/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "npm-run-all lint:*", "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", - "qa": "npm-run-all lint typecheck _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo", - "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", + "@types/fs-extra": "7.0.0", + "@types/globule": "1.1.3", + "@types/mocha": "5.2.7", + "@types/prettier": "1.16.4", + "@types/semver": "5.5.0", + "@types/web3": "1.0.12", "core-js": "3.4.3", "embark-core": "^5.0.0-alpha.4", "embark-utils": "^5.0.0-alpha.4", @@ -57,20 +63,14 @@ "devDependencies": { "@babel/cli": "7.7.4", "@babel/core": "7.7.4", - "@types/fs-extra": "7.0.0", - "@types/globule": "1.1.3", - "@types/mocha": "5.2.7", - "@types/prettier": "1.16.4", - "@types/semver": "5.5.0", - "@types/web3": "1.0.12", "cross-env": "5.2.0", "embark-solo": "^5.0.0-alpha.2", "eslint": "5.7.0", "mocha": "6.2.2", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/plugins/coverage/src/lib/index.ts b/packages/plugins/coverage/src/lib/index.ts index bac2156d6..01449e44c 100644 --- a/packages/plugins/coverage/src/lib/index.ts +++ b/packages/plugins/coverage/src/lib/index.ts @@ -1,9 +1,9 @@ +import { Contract, Embark } from "embark-core"; import { dappPath, File } from "embark-utils"; import * as globule from "globule"; import * as path from "path"; import Web3Contract from "web3/eth/contract"; -import { Contract, Embark } from "embark"; import { ContractEnhanced } from "./contractEnhanced"; import { coverageContractsPath } from "./path"; import { Coverage as ICoverage } from "./types"; diff --git a/packages/plugins/coverage/tsconfig.json b/packages/plugins/coverage/tsconfig.json index 1bb65da9e..988bd3b2f 100644 --- a/packages/plugins/coverage/tsconfig.json +++ b/packages/plugins/coverage/tsconfig.json @@ -1,4 +1,20 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-coverage.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/lib/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/utils" + } + ] } diff --git a/packages/plugins/debugger/package.json b/packages/plugins/debugger/package.json index fc0be03ee..dbb958a5a 100644 --- a/packages/plugins/debugger/package.json +++ b/packages/plugins/debugger/package.json @@ -25,21 +25,21 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "npm-run-all lint:*", "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", - "qa": "npm-run-all lint typecheck _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf .nyc_output coverage dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "solo": "embark-solo" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", @@ -53,8 +53,8 @@ "embark-solo": "^5.0.0-alpha.2", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/plugins/debugger/src/index.ts b/packages/plugins/debugger/src/index.ts index 8e8ee54a9..4bb9b7ab8 100644 --- a/packages/plugins/debugger/src/index.ts +++ b/packages/plugins/debugger/src/index.ts @@ -17,7 +17,7 @@ interface EmbarkApi { logger: any; } -class TransactionDebugger { +export default class TransactionDebugger { private embark: EmbarkApi; private lastTx: string; private debuggerManager: any; @@ -468,5 +468,3 @@ class TransactionDebugger { }); } } - -module.exports = TransactionDebugger; diff --git a/packages/plugins/debugger/tsconfig.json b/packages/plugins/debugger/tsconfig.json index 1bb65da9e..0990b8d51 100644 --- a/packages/plugins/debugger/tsconfig.json +++ b/packages/plugins/debugger/tsconfig.json @@ -1,4 +1,17 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-debugger.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/i18n" + } + ] } diff --git a/packages/plugins/deploy-tracker/package.json b/packages/plugins/deploy-tracker/package.json index 1fb3e6510..2048c5b9e 100644 --- a/packages/plugins/deploy-tracker/package.json +++ b/packages/plugins/deploy-tracker/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf .nyc_output coverage dist embark-*.tgz package", "solo": "embark-solo", "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register" diff --git a/packages/plugins/deploy-tracker/tsconfig.json b/packages/plugins/deploy-tracker/tsconfig.json new file mode 100644 index 000000000..c3a0600ae --- /dev/null +++ b/packages/plugins/deploy-tracker/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-deploy-tracker.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/logger" + }, + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/plugins/ens/package.json b/packages/plugins/ens/package.json index ab37d7cdd..9f212f229 100644 --- a/packages/plugins/ens/package.json +++ b/packages/plugins/ens/package.json @@ -26,15 +26,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo", "test": "jest" @@ -57,6 +60,7 @@ "babel-eslint": "10.0.3", "babel-jest": "24.9.0", "embark-solo": "^5.0.0-alpha.2", + "embark-testing": "^5.0.0-alpha.2", "eslint": "5.7.0", "eslint-plugin-jest": "22.5.1", "jest": "24.9.0", diff --git a/packages/plugins/ens/tsconfig.json b/packages/plugins/ens/tsconfig.json new file mode 100644 index 000000000..9fe1647cc --- /dev/null +++ b/packages/plugins/ens/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-ens.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../embarkjs/embarkjs" + }, + { + "path": "../../embarkjs/ens" + }, + { + "path": "../../utils/testing" + } + ] +} diff --git a/packages/plugins/ethereum-blockchain-client/package.json b/packages/plugins/ethereum-blockchain-client/package.json index d6b6ee760..cb1697f28 100644 --- a/packages/plugins/ethereum-blockchain-client/package.json +++ b/packages/plugins/ethereum-blockchain-client/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/ethereum-blockchain-client/tsconfig.json b/packages/plugins/ethereum-blockchain-client/tsconfig.json new file mode 100644 index 000000000..69c6b52cb --- /dev/null +++ b/packages/plugins/ethereum-blockchain-client/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-ethereum-blockchain-client.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../embarkjs/embarkjs" + } + ] +} diff --git a/packages/plugins/ganache/package.json b/packages/plugins/ganache/package.json index 9e1723725..4918f34fd 100644 --- a/packages/plugins/ganache/package.json +++ b/packages/plugins/ganache/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/ganache/tsconfig.json b/packages/plugins/ganache/tsconfig.json new file mode 100644 index 000000000..5bd1a1db4 --- /dev/null +++ b/packages/plugins/ganache/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-ganache.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/plugins/geth/package.json b/packages/plugins/geth/package.json index d68100920..e2e71f526 100644 --- a/packages/plugins/geth/package.json +++ b/packages/plugins/geth/package.json @@ -25,22 +25,22 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "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\"", - "qa": "npm-run-all lint typecheck _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "solo": "embark-solo" }, "eslintConfig": { "extends": "../../../.eslintrc.json" @@ -64,8 +64,8 @@ "eslint": "5.7.0", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/plugins/geth/src/blockchain.js b/packages/plugins/geth/src/blockchain.js index 66b5c6e66..c185b7c03 100644 --- a/packages/plugins/geth/src/blockchain.js +++ b/packages/plugins/geth/src/blockchain.js @@ -14,428 +14,433 @@ import { Logger } from 'embark-logger'; // time between IPC connection attempts (in ms) const IPC_CONNECT_INTERVAL = 2000; -/*eslint complexity: ["error", 50]*/ -var Blockchain = function (userConfig, clientClass, communicationConfig) { - this.userConfig = userConfig; - this.env = userConfig.env || 'development'; - this.isDev = userConfig.isDev; - this.onReadyCallback = userConfig.onReadyCallback || (() => { }); - this.onExitCallback = userConfig.onExitCallback; - this.logger = userConfig.logger || new Logger({ logLevel: 'debug', context: constants.contexts.blockchain }); // do not pass in events as we don't want any log events emitted - this.events = userConfig.events; - this.isStandalone = userConfig.isStandalone; - this.certOptions = userConfig.certOptions; - this.isWhisper = !!communicationConfig; +class Blockchain { + /*eslint complexity: ["error", 50]*/ + constructor(userConfig, clientClass, communicationConfig) { + this.userConfig = userConfig; + this.env = userConfig.env || 'development'; + this.isDev = userConfig.isDev; + this.onReadyCallback = userConfig.onReadyCallback || (() => { }); + this.onExitCallback = userConfig.onExitCallback; + this.logger = userConfig.logger || new Logger({ logLevel: 'debug', context: constants.contexts.blockchain }); // do not pass in events as we don't want any log events emitted + this.events = userConfig.events; + this.isStandalone = userConfig.isStandalone; + this.certOptions = userConfig.certOptions; + this.isWhisper = !!communicationConfig; - let defaultWsApi = clientClass.DEFAULTS.WS_API; - if (this.isDev) defaultWsApi = clientClass.DEFAULTS.DEV_WS_API; + let defaultWsApi = clientClass.DEFAULTS.WS_API; + if (this.isDev) defaultWsApi = clientClass.DEFAULTS.DEV_WS_API; - this.config = { - silent: this.userConfig.silent, - client: this.userConfig.client, - ethereumClientBin: this.userConfig.ethereumClientBin || this.userConfig.client, - networkType: this.userConfig.networkType || clientClass.DEFAULTS.NETWORK_TYPE, - networkId: this.userConfig.networkId || clientClass.DEFAULTS.NETWORK_ID, - genesisBlock: this.userConfig.genesisBlock || false, - datadir: this.userConfig.datadir, - mineWhenNeeded: this.userConfig.mineWhenNeeded || false, - rpcHost: dockerHostSwap(this.userConfig.rpcHost) || defaultHost, - rpcPort: this.userConfig.rpcPort || 8545, - rpcCorsDomain: this.userConfig.rpcCorsDomain || false, - rpcApi: this.userConfig.rpcApi || clientClass.DEFAULTS.RPC_API, - port: this.userConfig.port || 30303, - nodiscover: this.userConfig.nodiscover || false, - mine: this.userConfig.mine || false, - account: {}, - whisper: (this.userConfig.whisper !== false), - maxpeers: ((this.userConfig.maxpeers === 0) ? 0 : (this.userConfig.maxpeers || 25)), - bootnodes: this.userConfig.bootnodes || "", - wsRPC: (this.userConfig.wsRPC !== false), - wsHost: dockerHostSwap(this.userConfig.wsHost) || defaultHost, - wsPort: this.userConfig.wsPort || 8546, - wsOrigins: this.userConfig.wsOrigins || false, - wsApi: this.userConfig.wsApi || defaultWsApi, - vmdebug: this.userConfig.vmdebug || false, - targetGasLimit: this.userConfig.targetGasLimit || false, - syncMode: this.userConfig.syncMode || this.userConfig.syncmode, - verbosity: this.userConfig.verbosity, - customOptions: this.userConfig.customOptions - }; + this.config = { + silent: this.userConfig.silent, + client: this.userConfig.client, + ethereumClientBin: this.userConfig.ethereumClientBin || this.userConfig.client, + networkType: this.userConfig.networkType || clientClass.DEFAULTS.NETWORK_TYPE, + networkId: this.userConfig.networkId || clientClass.DEFAULTS.NETWORK_ID, + genesisBlock: this.userConfig.genesisBlock || false, + datadir: this.userConfig.datadir, + mineWhenNeeded: this.userConfig.mineWhenNeeded || false, + rpcHost: dockerHostSwap(this.userConfig.rpcHost) || defaultHost, + rpcPort: this.userConfig.rpcPort || 8545, + rpcCorsDomain: this.userConfig.rpcCorsDomain || false, + rpcApi: this.userConfig.rpcApi || clientClass.DEFAULTS.RPC_API, + port: this.userConfig.port || 30303, + nodiscover: this.userConfig.nodiscover || false, + mine: this.userConfig.mine || false, + account: {}, + whisper: (this.userConfig.whisper !== false), + maxpeers: ((this.userConfig.maxpeers === 0) ? 0 : (this.userConfig.maxpeers || 25)), + bootnodes: this.userConfig.bootnodes || "", + wsRPC: (this.userConfig.wsRPC !== false), + wsHost: dockerHostSwap(this.userConfig.wsHost) || defaultHost, + wsPort: this.userConfig.wsPort || 8546, + wsOrigins: this.userConfig.wsOrigins || false, + wsApi: this.userConfig.wsApi || defaultWsApi, + vmdebug: this.userConfig.vmdebug || false, + targetGasLimit: this.userConfig.targetGasLimit || false, + syncMode: this.userConfig.syncMode || this.userConfig.syncmode, + verbosity: this.userConfig.verbosity, + customOptions: this.userConfig.customOptions + }; - this.devFunds = null; + this.devFunds = null; - if (this.userConfig.accounts) { - const nodeAccounts = this.userConfig.accounts.find(account => account.nodeAccounts); - if (nodeAccounts) { - this.config.account = { - numAccounts: nodeAccounts.numAddresses || 1, - password: nodeAccounts.password, - balance: nodeAccounts.balance - }; - } - } - - if (this.userConfig === {} || this.userConfig.default || JSON.stringify(this.userConfig) === '{"client":"geth"}') { - if (this.env === 'development') { - this.isDev = true; - } else { - this.config.genesisBlock = embarkPath("templates/boilerplate/config/privatenet/genesis.json"); - } - this.config.datadir = dappPath(".embark/development/datadir"); - this.config.wsOrigins = this.config.wsOrigins || "http://localhost:8000"; - this.config.rpcCorsDomain = this.config.rpcCorsDomain || "http://localhost:8000"; - this.config.targetGasLimit = 8000000; - } - this.config.account.devPassword = path.join(this.config.datadir, "devPassword"); - - const spaceMessage = 'The path for %s in blockchain config contains spaces, please remove them'; - if (this.config.datadir && this.config.datadir.indexOf(' ') > 0) { - this.logger.error(__(spaceMessage, 'datadir')); - process.exit(1); - } - if (this.config.account.password && this.config.account.password.indexOf(' ') > 0) { - this.logger.error(__(spaceMessage, 'accounts.password')); - process.exit(1); - } - if (this.config.genesisBlock && this.config.genesisBlock.indexOf(' ') > 0) { - this.logger.error(__(spaceMessage, 'genesisBlock')); - process.exit(1); - } - this.client = new clientClass({ config: this.config, env: this.env, isDev: this.isDev, communicationConfig: communicationConfig }); - - if (this.isStandalone) { - this.initStandaloneProcess(); - } -}; - -/** - * Polls for a connection to an IPC server (generally this is set up - * in the Embark process). Once connected, any logs logged to the - * Logger will be shipped off to the IPC server. In the case of `embark - * run`, the BlockchainListener module is listening for these logs. - * - * @returns {void} - */ -Blockchain.prototype.initStandaloneProcess = function () { - let logQueue = []; - - // on every log logged in logger (say that 3x fast), send the log - // to the IPC serve listening (only if we're connected of course) - this.logger.events.on('log', (logLevel, message) => { - if (this.ipc.connected) { - this.ipc.request('blockchain:log', { logLevel, message }); - } else { - logQueue.push({ logLevel, message }); - } - }); - - this.ipc = new IPC({ ipcRole: 'client' }); - - // Wait for an IPC server to start (ie `embark run`) by polling `.connect()`. - // Do not kill this interval as the IPC server may restart (ie restart - // `embark run` without restarting `embark blockchain`) - setInterval(() => { - if (!this.ipc.connected) { - this.ipc.connect(() => { - if (this.ipc.connected) { - logQueue.forEach(message => { - this.ipc.request('blockchain:log', message); - }); - logQueue = []; - this.ipc.client.on('process:blockchain:stop', () => { - this.kill(); - process.exit(0); - }); - } - }); - } - }, IPC_CONNECT_INTERVAL); -}; - -Blockchain.prototype.runCommand = function (cmd, options, callback) { - this.logger.info(__("running: %s", cmd.underline).green); - if (this.config.silent) { - options.silent = true; - } - return exec(cmd, options, callback); -}; - -Blockchain.prototype.run = function () { - var self = this; - this.logger.info("===============================================================================".magenta); - this.logger.info("===============================================================================".magenta); - this.logger.info(__(`Embark ${this.isWhisper ? "Whisper" : "Blockchain"} using %s`, self.client.prettyName.underline).magenta); - this.logger.info("===============================================================================".magenta); - this.logger.info("===============================================================================".magenta); - - if (self.client.name === constants.blockchain.clients.geth) this.checkPathLength(); - - let address = ''; - async.waterfall([ - function checkInstallation(next) { - self.isClientInstalled((err) => { - if (err) { - return next({ message: err }); - } - next(); - }); - }, - function init(next) { - if (self.isDev) { - return self.initDevChain((err) => { - next(err); - }); + if (this.userConfig.accounts) { + const nodeAccounts = this.userConfig.accounts.find(account => account.nodeAccounts); + if (nodeAccounts) { + this.config.account = { + numAccounts: nodeAccounts.numAddresses || 1, + password: nodeAccounts.password, + balance: nodeAccounts.balance + }; } - return self.initChainAndGetAddress((err, addr) => { - address = addr; - next(err); - }); - }, - function getMainCommand(next) { - self.client.mainCommand(address, function (cmd, args) { - next(null, cmd, args); - }, true); } - ], function (err, cmd, args) { - if (err) { - self.logger.error(err.message || err); + + if (this.userConfig === {} || this.userConfig.default || JSON.stringify(this.userConfig) === '{"client":"geth"}') { + if (this.env === 'development') { + this.isDev = true; + } else { + this.config.genesisBlock = embarkPath("templates/boilerplate/config/privatenet/genesis.json"); + } + this.config.datadir = dappPath(".embark/development/datadir"); + this.config.wsOrigins = this.config.wsOrigins || "http://localhost:8000"; + this.config.rpcCorsDomain = this.config.rpcCorsDomain || "http://localhost:8000"; + this.config.targetGasLimit = 8000000; + } + this.config.account.devPassword = path.join(this.config.datadir, "devPassword"); + + const spaceMessage = 'The path for %s in blockchain config contains spaces, please remove them'; + if (this.config.datadir && this.config.datadir.indexOf(' ') > 0) { + this.logger.error(__(spaceMessage, 'datadir')); process.exit(1); } - args = compact(args); + if (this.config.account.password && this.config.account.password.indexOf(' ') > 0) { + this.logger.error(__(spaceMessage, 'accounts.password')); + process.exit(1); + } + if (this.config.genesisBlock && this.config.genesisBlock.indexOf(' ') > 0) { + this.logger.error(__(spaceMessage, 'genesisBlock')); + process.exit(1); + } + this.client = new clientClass({ config: this.config, env: this.env, isDev: this.isDev, communicationConfig: communicationConfig }); - let full_cmd = cmd + " " + args.join(' '); - self.logger.info(__(">>>>>>>>>>>>>>>> running: %s", full_cmd.underline).green); - self.child = spawn(cmd, args, { cwd: process.cwd() }); + if (this.isStandalone) { + this.initStandaloneProcess(); + } + } - self.child.on('error', (err) => { - err = err.toString(); - self.logger.error('Blockchain error: ', err); - if (self.env === 'development' && err.indexOf('Failed to unlock') > 0) { - self.logger.error('\n' + __('Development blockchain has changed to use the --dev option.').yellow); - self.logger.error(__('You can reset your workspace to fix the problem with').yellow + ' embark reset'.cyan); - self.logger.error(__('Otherwise, you can change your data directory in blockchain.json (datadir)').yellow); - } - }); + /** + * Polls for a connection to an IPC server (generally this is set up + * in the Embark process). Once connected, any logs logged to the + * Logger will be shipped off to the IPC server. In the case of `embark + * run`, the BlockchainListener module is listening for these logs. + * + * @returns {void} + */ + initStandaloneProcess() { + let logQueue = []; - // TOCHECK I don't understand why stderr and stdout are reverted. - // This happens with Geth and Parity, so it does not seems a client problem - self.child.stdout.on('data', (data) => { - self.logger.error(`${self.client.name} error: ${data}`); - }); - - self.child.stderr.on('data', async (data) => { - data = data.toString(); - if (!self.readyCalled && self.client.isReady(data)) { - self.readyCalled = true; - self.readyCallback(); - } - self.logger.info(`${self.client.name}: ${data}`); - }); - - self.child.on('exit', (code) => { - let strCode; - if (code) { - strCode = 'with error code ' + code; + // on every log logged in logger (say that 3x fast), send the log + // to the IPC serve listening (only if we're connected of course) + this.logger.events.on('log', (logLevel, message) => { + if (this.ipc.connected) { + this.ipc.request('blockchain:log', { logLevel, message }); } else { - strCode = 'with no error code (manually killed?)'; - } - self.logger.error(self.client.name + ' exited ' + strCode); - if (self.onExitCallback) { - self.onExitCallback(); + logQueue.push({ logLevel, message }); } }); - self.child.on('uncaughtException', (err) => { - self.logger.error('Uncaught ' + self.client.name + ' exception', err); - if (self.onExitCallback) { - self.onExitCallback(); - } - }); - }); -}; + this.ipc = new IPC({ ipcRole: 'client' }); -Blockchain.prototype.readyCallback = function () { - if (this.onReadyCallback) { - this.onReadyCallback(); - } - if (this.config.mineWhenNeeded && !this.isDev) { - this.miner = this.client.getMiner(); - } -}; - -Blockchain.prototype.kill = function () { - if (this.child) { - this.child.kill(); - } -}; - -Blockchain.prototype.checkPathLength = function () { - let _dappPath = dappPath(''); - if (_dappPath.length > 66) { - // this.logger.error is captured and sent to the console output regardless of silent setting - this.logger.error("===============================================================================".yellow); - this.logger.error("===========> ".yellow + __('WARNING! ÐApp path length is too long: ').yellow + _dappPath.yellow); - this.logger.error("===========> ".yellow + __('This is known to cause issues with starting geth, please consider reducing your ÐApp path\'s length to 66 characters or less.').yellow); - this.logger.error("===============================================================================".yellow); - } -}; - -Blockchain.prototype.isClientInstalled = function (callback) { - let versionCmd = this.client.determineVersionCommand(); - this.runCommand(versionCmd, {}, (err, stdout, stderr) => { - if (err || !stdout || stderr.indexOf("not found") >= 0 || stdout.indexOf("not found") >= 0) { - return callback(__('Ethereum client bin not found:') + ' ' + this.client.getBinaryPath()); - } - const parsedVersion = this.client.parseVersion(stdout); - const supported = this.client.isSupportedVersion(parsedVersion); - if (supported === undefined) { - this.logger.warn((__('WARNING! Ethereum client version could not be determined or compared with version range') + ' ' + this.client.versSupported + __(', for best results please use a supported version'))); - } else if (!supported) { - this.logger.warn((__('WARNING! Ethereum client version unsupported, for best results please use a version in range') + ' ' + this.client.versSupported)); - } - callback(); - }); -}; - -Blockchain.prototype.initDevChain = function (callback) { - const self = this; - const ACCOUNTS_ALREADY_PRESENT = 'accounts_already_present'; - // Init the dev chain - self.client.initDevChain(self.config.datadir, (err) => { - if (err) { - return callback(err); - } - - const accountsToCreate = self.config.account && self.config.account.numAccounts; - if (!accountsToCreate) return callback(); - - // Create other accounts - async.waterfall([ - function listAccounts(next) { - const listAccountsCommand = self.client.listAccountsCommand(); - if (!listAccountsCommand) return next(null, 0); - self.runCommand(listAccountsCommand, {}, (err, stdout, _stderr) => { - if (err || stdout === undefined || stdout.indexOf("Fatal") >= 0) { - console.log(__("no accounts found").green); - return next(); - } - // List current addresses - self.config.unlockAddressList = self.client.parseListAccountsCommandResultToAddressList(stdout); - // Count current addresses and remove the default account from the count (because password can be different) - let addressCount = self.config.unlockAddressList.length; - if (addressCount < accountsToCreate) { - next(null, accountsToCreate - addressCount); - } else { - next(ACCOUNTS_ALREADY_PRESENT); + // Wait for an IPC server to start (ie `embark run`) by polling `.connect()`. + // Do not kill this interval as the IPC server may restart (ie restart + // `embark run` without restarting `embark blockchain`) + setInterval(() => { + if (!this.ipc.connected) { + this.ipc.connect(() => { + if (this.ipc.connected) { + logQueue.forEach(message => { + this.ipc.request('blockchain:log', message); + }); + logQueue = []; + this.ipc.client.on('process:blockchain:stop', () => { + this.kill(); + process.exit(0); + }); } }); - }, - function newAccounts(accountsToCreate, next) { - const newAccountCommand = self.client.newAccountCommand(); - if (!newAccountCommand) return next(); - var accountNumber = 0; - async.whilst( - function () { - return accountNumber < accountsToCreate; - }, - function (callback) { - accountNumber++; - self.runCommand(newAccountCommand, {}, (err, stdout, _stderr) => { - if (err) { - return callback(err, accountNumber); - } - self.config.unlockAddressList.push(self.client.parseNewAccountCommandResultToAddress(stdout)); - callback(null, accountNumber); - }); - }, - function (err) { - next(err); - } - ); } - ], (err) => { - if (err && err !== ACCOUNTS_ALREADY_PRESENT) { - console.log(err); - return callback(err); + }, IPC_CONNECT_INTERVAL); + } + + runCommand(cmd, options, callback) { + this.logger.info(__("running: %s", cmd.underline).green); + if (this.config.silent) { + options.silent = true; + } + return exec(cmd, options, callback); + } + + run() { + var self = this; + this.logger.info("===============================================================================".magenta); + this.logger.info("===============================================================================".magenta); + this.logger.info(__(`Embark ${this.isWhisper ? "Whisper" : "Blockchain"} using %s`, self.client.prettyName.underline).magenta); + this.logger.info("===============================================================================".magenta); + this.logger.info("===============================================================================".magenta); + + if (self.client.name === constants.blockchain.clients.geth) this.checkPathLength(); + + let address = ''; + async.waterfall([ + function checkInstallation(next) { + self.isClientInstalled((err) => { + if (err) { + return next({ message: err }); + } + next(); + }); + }, + function init(next) { + if (self.isDev) { + return self.initDevChain((err) => { + next(err); + }); + } + return self.initChainAndGetAddress((err, addr) => { + address = addr; + next(err); + }); + }, + function getMainCommand(next) { + self.client.mainCommand(address, function (cmd, args) { + next(null, cmd, args); + }, true); + } + ], function (err, cmd, args) { + if (err) { + self.logger.error(err.message || err); + process.exit(1); + } + args = compact(args); + + let full_cmd = cmd + " " + args.join(' '); + self.logger.info(__(">>>>>>>>>>>>>>>> running: %s", full_cmd.underline).green); + self.child = spawn(cmd, args, { cwd: process.cwd() }); + + self.child.on('error', (err) => { + err = err.toString(); + self.logger.error('Blockchain error: ', err); + if (self.env === 'development' && err.indexOf('Failed to unlock') > 0) { + self.logger.error('\n' + __('Development blockchain has changed to use the --dev option.').yellow); + self.logger.error(__('You can reset your workspace to fix the problem with').yellow + ' embark reset'.cyan); + self.logger.error(__('Otherwise, you can change your data directory in blockchain.json (datadir)').yellow); + } + }); + + // TOCHECK I don't understand why stderr and stdout are reverted. + // This happens with Geth and Parity, so it does not seems a client problem + self.child.stdout.on('data', (data) => { + self.logger.error(`${self.client.name} error: ${data}`); + }); + + self.child.stderr.on('data', async (data) => { + data = data.toString(); + if (!self.readyCalled && self.client.isReady(data)) { + self.readyCalled = true; + self.readyCallback(); + } + self.logger.info(`${self.client.name}: ${data}`); + }); + + self.child.on('exit', (code) => { + let strCode; + if (code) { + strCode = 'with error code ' + code; + } else { + strCode = 'with no error code (manually killed?)'; + } + self.logger.error(self.client.name + ' exited ' + strCode); + if (self.onExitCallback) { + self.onExitCallback(); + } + }); + + self.child.on('uncaughtException', (err) => { + self.logger.error('Uncaught ' + self.client.name + ' exception', err); + if (self.onExitCallback) { + self.onExitCallback(); + } + }); + }); + } + + readyCallback() { + if (this.onReadyCallback) { + this.onReadyCallback(); + } + if (this.config.mineWhenNeeded && !this.isDev) { + this.miner = this.client.getMiner(); + } + } + + kill() { + if (this.child) { + this.child.kill(); + } + } + + checkPathLength() { + let _dappPath = dappPath(''); + if (_dappPath.length > 66) { + // this.logger.error is captured and sent to the console output regardless of silent setting + this.logger.error("===============================================================================".yellow); + this.logger.error("===========> ".yellow + __('WARNING! ÐApp path length is too long: ').yellow + _dappPath.yellow); + this.logger.error("===========> ".yellow + __('This is known to cause issues with starting geth, please consider reducing your ÐApp path\'s length to 66 characters or less.').yellow); + this.logger.error("===============================================================================".yellow); + } + } + + isClientInstalled(callback) { + let versionCmd = this.client.determineVersionCommand(); + this.runCommand(versionCmd, {}, (err, stdout, stderr) => { + if (err || !stdout || stderr.indexOf("not found") >= 0 || stdout.indexOf("not found") >= 0) { + return callback(__('Ethereum client bin not found:') + ' ' + this.client.getBinaryPath()); + } + const parsedVersion = this.client.parseVersion(stdout); + const supported = this.client.isSupportedVersion(parsedVersion); + if (supported === undefined) { + this.logger.warn((__('WARNING! Ethereum client version could not be determined or compared with version range') + ' ' + this.client.versSupported + __(', for best results please use a supported version'))); + } else if (!supported) { + this.logger.warn((__('WARNING! Ethereum client version unsupported, for best results please use a version in range') + ' ' + this.client.versSupported)); } callback(); }); - }); -}; - -Blockchain.prototype.initChainAndGetAddress = function (callback) { - const self = this; - let address = null; - const ALREADY_INITIALIZED = 'already'; - - // ensure datadir exists, bypassing the interactive liabilities prompt. - self.datadir = self.config.datadir; - - async.waterfall([ - function makeDir(next) { - fs.mkdirp(self.datadir, (err, _result) => { - next(err); - }); - }, - function listAccounts(next) { - self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, _stderr) => { - if (err || stdout === undefined || stdout.indexOf("Fatal") >= 0) { - self.logger.info(__("no accounts found").green); - return next(); - } - let firstAccountFound = self.client.parseListAccountsCommandResultToAddress(stdout); - if (firstAccountFound === undefined || firstAccountFound === "") { - console.log(__("no accounts found").green); - return next(); - } - self.logger.info(__("already initialized").green); - address = firstAccountFound; - next(ALREADY_INITIALIZED); - }); - }, - function genesisBlock(next) { - //There's no genesis init with Parity. Custom network are set in the chain property at startup - if (!self.config.genesisBlock || self.client.name === constants.blockchain.clients.parity) { - return next(); - } - self.logger.info(__("initializing genesis block").green); - self.runCommand(self.client.initGenesisCommmand(), {}, (err, _stdout, _stderr) => { - next(err); - }); - }, - function newAccount(next) { - self.runCommand(self.client.newAccountCommand(), {}, (err, stdout, _stderr) => { - if (err) { - return next(err); - } - address = self.client.parseNewAccountCommandResultToAddress(stdout); - next(); - }); - } - ], (err) => { - if (err === ALREADY_INITIALIZED) { - err = null; - } - callback(err, address); - }); -}; - -export function BlockchainClient(userConfig, options, communicationConfig) { - if ((userConfig === {} || JSON.stringify(userConfig) === '{"enabled":true}') && options.env !== 'development') { - options.logger.info("===> " + __("warning: running default config on a non-development environment")); } - // if client is not set in preferences, default is geth - if (!userConfig.client) userConfig.client = constants.blockchain.clients.geth; - // if clientName is set, it overrides preferences - if (options.clientName) userConfig.client = options.clientName; - userConfig.isDev = (userConfig.isDev || userConfig.default); - userConfig.env = options.env; - userConfig.onReadyCallback = options.onReadyCallback; - userConfig.onExitCallback = options.onExitCallback; - userConfig.logger = options.logger; - userConfig.certOptions = options.certOptions; - userConfig.isStandalone = options.isStandalone; - return new Blockchain(userConfig, GethClient, communicationConfig); + initDevChain(callback) { + const self = this; + const ACCOUNTS_ALREADY_PRESENT = 'accounts_already_present'; + // Init the dev chain + self.client.initDevChain(self.config.datadir, (err) => { + if (err) { + return callback(err); + } + + const accountsToCreate = self.config.account && self.config.account.numAccounts; + if (!accountsToCreate) return callback(); + + // Create other accounts + async.waterfall([ + function listAccounts(next) { + const listAccountsCommand = self.client.listAccountsCommand(); + if (!listAccountsCommand) return next(null, 0); + self.runCommand(listAccountsCommand, {}, (err, stdout, _stderr) => { + if (err || stdout === undefined || stdout.indexOf("Fatal") >= 0) { + console.log(__("no accounts found").green); + return next(); + } + // List current addresses + self.config.unlockAddressList = self.client.parseListAccountsCommandResultToAddressList(stdout); + // Count current addresses and remove the default account from the count (because password can be different) + let addressCount = self.config.unlockAddressList.length; + if (addressCount < accountsToCreate) { + next(null, accountsToCreate - addressCount); + } else { + next(ACCOUNTS_ALREADY_PRESENT); + } + }); + }, + function newAccounts(accountsToCreate, next) { + const newAccountCommand = self.client.newAccountCommand(); + if (!newAccountCommand) return next(); + var accountNumber = 0; + async.whilst( + function () { + return accountNumber < accountsToCreate; + }, + function (callback) { + accountNumber++; + self.runCommand(newAccountCommand, {}, (err, stdout, _stderr) => { + if (err) { + return callback(err, accountNumber); + } + self.config.unlockAddressList.push(self.client.parseNewAccountCommandResultToAddress(stdout)); + callback(null, accountNumber); + }); + }, + function (err) { + next(err); + } + ); + } + ], (err) => { + if (err && err !== ACCOUNTS_ALREADY_PRESENT) { + console.log(err); + return callback(err); + } + callback(); + }); + }); + } + + initChainAndGetAddress(callback) { + const self = this; + let address = null; + const ALREADY_INITIALIZED = 'already'; + + // ensure datadir exists, bypassing the interactive liabilities prompt. + self.datadir = self.config.datadir; + + async.waterfall([ + function makeDir(next) { + fs.mkdirp(self.datadir, (err, _result) => { + next(err); + }); + }, + function listAccounts(next) { + self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, _stderr) => { + if (err || stdout === undefined || stdout.indexOf("Fatal") >= 0) { + self.logger.info(__("no accounts found").green); + return next(); + } + let firstAccountFound = self.client.parseListAccountsCommandResultToAddress(stdout); + if (firstAccountFound === undefined || firstAccountFound === "") { + console.log(__("no accounts found").green); + return next(); + } + self.logger.info(__("already initialized").green); + address = firstAccountFound; + next(ALREADY_INITIALIZED); + }); + }, + function genesisBlock(next) { + //There's no genesis init with Parity. Custom network are set in the chain property at startup + if (!self.config.genesisBlock || self.client.name === constants.blockchain.clients.parity) { + return next(); + } + self.logger.info(__("initializing genesis block").green); + self.runCommand(self.client.initGenesisCommmand(), {}, (err, _stdout, _stderr) => { + next(err); + }); + }, + function newAccount(next) { + self.runCommand(self.client.newAccountCommand(), {}, (err, stdout, _stderr) => { + if (err) { + return next(err); + } + address = self.client.parseNewAccountCommandResultToAddress(stdout); + next(); + }); + } + ], (err) => { + if (err === ALREADY_INITIALIZED) { + err = null; + } + callback(err, address); + }); + } +} + +export class BlockchainClient extends Blockchain { + constructor(userConfig, options, communicationConfig) { + if ((userConfig === {} || JSON.stringify(userConfig) === '{"enabled":true}') && options.env !== 'development') { + options.logger.info("===> " + __("warning: running default config on a non-development environment")); + } + // if client is not set in preferences, default is geth + if (!userConfig.client) userConfig.client = constants.blockchain.clients.geth; + // if clientName is set, it overrides preferences + if (options.clientName) userConfig.client = options.clientName; + + userConfig.isDev = (userConfig.isDev || userConfig.default); + userConfig.env = options.env; + userConfig.onReadyCallback = options.onReadyCallback; + userConfig.onExitCallback = options.onExitCallback; + userConfig.logger = options.logger; + userConfig.certOptions = options.certOptions; + userConfig.isStandalone = options.isStandalone; + + super(userConfig, GethClient, communicationConfig); + } } diff --git a/packages/plugins/geth/src/blockchainProcess.js b/packages/plugins/geth/src/blockchainProcess.js index 968bb5eb6..21288fb57 100644 --- a/packages/plugins/geth/src/blockchainProcess.js +++ b/packages/plugins/geth/src/blockchainProcess.js @@ -18,7 +18,7 @@ class BlockchainProcess extends ProcessWrapper { i18n.setOrDetectLocale(options.locale); this.blockchainConfig.silent = true; - this.blockchain = BlockchainClient( + this.blockchain = new BlockchainClient( this.blockchainConfig, { clientName: this.client, diff --git a/packages/plugins/geth/src/devtxs.ts b/packages/plugins/geth/src/devtxs.ts index 337750217..3d9261b2b 100644 --- a/packages/plugins/geth/src/devtxs.ts +++ b/packages/plugins/geth/src/devtxs.ts @@ -1,11 +1,12 @@ import { __ } from 'embark-i18n'; -import { Embark, Events, Logger } from "embark"; +import { Embark, EmbarkEvents } from "embark-core"; +import { Logger } from "embark-logger"; import Web3 from "web3"; import constants from "embark-core/constants.json"; export default class DevTxs { private embark: Embark; private blockchainConfig: any; - private events: Events; + private events: EmbarkEvents; private logger: Logger; private web3?: Web3; private regularTxsInt?: NodeJS.Timeout; diff --git a/packages/plugins/geth/tsconfig.json b/packages/plugins/geth/tsconfig.json index 1bb65da9e..6e50100bb 100644 --- a/packages/plugins/geth/tsconfig.json +++ b/packages/plugins/geth/tsconfig.json @@ -1,4 +1,26 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-geth.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/logger" + }, + { + "path": "../../core/utils" + } + ] } diff --git a/packages/plugins/graph/package.json b/packages/plugins/graph/package.json index b238f86c3..138c158d9 100644 --- a/packages/plugins/graph/package.json +++ b/packages/plugins/graph/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/graph/tsconfig.json b/packages/plugins/graph/tsconfig.json new file mode 100644 index 000000000..2121fd4b1 --- /dev/null +++ b/packages/plugins/graph/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-graph.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/plugins/ipfs/package.json b/packages/plugins/ipfs/package.json index 81269f762..2bc486f40 100644 --- a/packages/plugins/ipfs/package.json +++ b/packages/plugins/ipfs/package.json @@ -27,15 +27,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint process.js src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/ipfs/tsconfig.json b/packages/plugins/ipfs/tsconfig.json new file mode 100644 index 000000000..a55e7ff68 --- /dev/null +++ b/packages/plugins/ipfs/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-ipfs.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../embarkjs/embarkjs" + }, + { + "path": "../../embarkjs/ipfs" + }, + { + "path": "../../stack/storage" + } + ] +} diff --git a/packages/plugins/mocha-tests/package.json b/packages/plugins/mocha-tests/package.json index 8d88bf692..f8c193a90 100644 --- a/packages/plugins/mocha-tests/package.json +++ b/packages/plugins/mocha-tests/package.json @@ -2,7 +2,6 @@ "name": "embark-mocha-tests", "version": "5.0.0-alpha.4", "description": "Mocha Test Runner", - "main": "dist/lib/index.js", "homepage": "https://github.com/embark-framework/embark/tree/master/packages/plugins/mocha-tests#readme", "repository": { "directory": "packages/plugins/mocha-tests", @@ -24,15 +23,19 @@ "files": [ "dist" ], + "main": "./dist/lib/index.js", + "types": "./dist/lib/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf .nyc_output dist embark-*.tgz package", "solo": "embark-solo", "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register" @@ -45,6 +48,7 @@ }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", + "@types/async": "3.0.3", "async": "3.1.0", "core-js": "3.4.3", "embark-i18n": "^5.0.0-alpha.2", @@ -54,7 +58,6 @@ "web3": "1.2.1" }, "devDependencies": { - "@types/async": "3.0.3", "embark-solo": "^5.0.0-alpha.2", "eslint": "5.7.0", "npm-run-all": "4.1.5", diff --git a/packages/plugins/mocha-tests/tsconfig.json b/packages/plugins/mocha-tests/tsconfig.json new file mode 100644 index 000000000..e58e1e039 --- /dev/null +++ b/packages/plugins/mocha-tests/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-mocha-tests.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/lib/**/*" + ], + "references": [ + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../embarkjs/embarkjs" + } + ] +} diff --git a/packages/plugins/parity/package.json b/packages/plugins/parity/package.json index 77fec21af..73d11ac00 100644 --- a/packages/plugins/parity/package.json +++ b/packages/plugins/parity/package.json @@ -25,21 +25,20 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", - "lint": "npm-run-all lint:*", - "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", - "qa": "npm-run-all lint typecheck _build", + "lint": "eslint src/", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "solo": "embark-solo" }, "eslintConfig": { "extends": "../../../.eslintrc.json" @@ -60,9 +59,7 @@ "embark-solo": "^5.0.0-alpha.2", "eslint": "5.7.0", "npm-run-all": "4.1.5", - "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "rimraf": "3.0.0" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/plugins/parity/src/blockchain.js b/packages/plugins/parity/src/blockchain.js index d2233feed..153af0774 100644 --- a/packages/plugins/parity/src/blockchain.js +++ b/packages/plugins/parity/src/blockchain.js @@ -15,449 +15,454 @@ import { Logger } from 'embark-logger'; // time between IPC connection attempts (in ms) const IPC_CONNECT_INTERVAL = 2000; -/*eslint complexity: ["error", 50]*/ -var Blockchain = function (userConfig, clientClass) { - this.userConfig = userConfig; - this.env = userConfig.env || 'development'; - this.isDev = userConfig.isDev; - this.onReadyCallback = userConfig.onReadyCallback || (() => {}); - this.onExitCallback = userConfig.onExitCallback; - this.logger = userConfig.logger || new Logger({logLevel: 'debug', context: constants.contexts.blockchain}); // do not pass in events as we don't want any log events emitted - this.events = userConfig.events; - this.proxyIpc = null; - this.isStandalone = userConfig.isStandalone; - this.certOptions = userConfig.certOptions; +class Blockchain { + /*eslint complexity: ["error", 50]*/ + constructor(userConfig, clientClass) { + this.userConfig = userConfig; + this.env = userConfig.env || 'development'; + this.isDev = userConfig.isDev; + this.onReadyCallback = userConfig.onReadyCallback || (() => {}); + this.onExitCallback = userConfig.onExitCallback; + this.logger = userConfig.logger || new Logger({logLevel: 'debug', context: constants.contexts.blockchain}); // do not pass in events as we don't want any log events emitted + this.events = userConfig.events; + this.proxyIpc = null; + this.isStandalone = userConfig.isStandalone; + this.certOptions = userConfig.certOptions; - let defaultWsApi = clientClass.DEFAULTS.WS_API; - if (this.isDev) defaultWsApi = clientClass.DEFAULTS.DEV_WS_API; + let defaultWsApi = clientClass.DEFAULTS.WS_API; + if (this.isDev) defaultWsApi = clientClass.DEFAULTS.DEV_WS_API; - this.config = { - silent: this.userConfig.silent, - client: this.userConfig.client, - ethereumClientBin: this.userConfig.ethereumClientBin || this.userConfig.client, - networkType: this.userConfig.networkType || clientClass.DEFAULTS.NETWORK_TYPE, - networkId: this.userConfig.networkId || clientClass.DEFAULTS.NETWORK_ID, - genesisBlock: this.userConfig.genesisBlock || false, - datadir: this.userConfig.datadir, - mineWhenNeeded: this.userConfig.mineWhenNeeded || false, - rpcHost: dockerHostSwap(this.userConfig.rpcHost) || defaultHost, - rpcPort: this.userConfig.rpcPort || 8545, - rpcCorsDomain: this.userConfig.rpcCorsDomain || false, - rpcApi: this.userConfig.rpcApi || clientClass.DEFAULTS.RPC_API, - port: this.userConfig.port || 30303, - nodiscover: this.userConfig.nodiscover || false, - mine: this.userConfig.mine || false, - account: {}, - whisper: (this.userConfig.whisper !== false), - maxpeers: ((this.userConfig.maxpeers === 0) ? 0 : (this.userConfig.maxpeers || 25)), - bootnodes: this.userConfig.bootnodes || "", - wsRPC: (this.userConfig.wsRPC !== false), - wsHost: dockerHostSwap(this.userConfig.wsHost) || defaultHost, - wsPort: this.userConfig.wsPort || 8546, - wsOrigins: this.userConfig.wsOrigins || false, - wsApi: this.userConfig.wsApi || defaultWsApi, - vmdebug: this.userConfig.vmdebug || false, - targetGasLimit: this.userConfig.targetGasLimit || false, - syncMode: this.userConfig.syncMode || this.userConfig.syncmode, - verbosity: this.userConfig.verbosity, - proxy: this.userConfig.proxy, - customOptions: this.userConfig.customOptions - }; + this.config = { + silent: this.userConfig.silent, + client: this.userConfig.client, + ethereumClientBin: this.userConfig.ethereumClientBin || this.userConfig.client, + networkType: this.userConfig.networkType || clientClass.DEFAULTS.NETWORK_TYPE, + networkId: this.userConfig.networkId || clientClass.DEFAULTS.NETWORK_ID, + genesisBlock: this.userConfig.genesisBlock || false, + datadir: this.userConfig.datadir, + mineWhenNeeded: this.userConfig.mineWhenNeeded || false, + rpcHost: dockerHostSwap(this.userConfig.rpcHost) || defaultHost, + rpcPort: this.userConfig.rpcPort || 8545, + rpcCorsDomain: this.userConfig.rpcCorsDomain || false, + rpcApi: this.userConfig.rpcApi || clientClass.DEFAULTS.RPC_API, + port: this.userConfig.port || 30303, + nodiscover: this.userConfig.nodiscover || false, + mine: this.userConfig.mine || false, + account: {}, + whisper: (this.userConfig.whisper !== false), + maxpeers: ((this.userConfig.maxpeers === 0) ? 0 : (this.userConfig.maxpeers || 25)), + bootnodes: this.userConfig.bootnodes || "", + wsRPC: (this.userConfig.wsRPC !== false), + wsHost: dockerHostSwap(this.userConfig.wsHost) || defaultHost, + wsPort: this.userConfig.wsPort || 8546, + wsOrigins: this.userConfig.wsOrigins || false, + wsApi: this.userConfig.wsApi || defaultWsApi, + vmdebug: this.userConfig.vmdebug || false, + targetGasLimit: this.userConfig.targetGasLimit || false, + syncMode: this.userConfig.syncMode || this.userConfig.syncmode, + verbosity: this.userConfig.verbosity, + proxy: this.userConfig.proxy, + customOptions: this.userConfig.customOptions + }; - this.devFunds = null; + this.devFunds = null; - if (this.userConfig.accounts) { - const nodeAccounts = this.userConfig.accounts.find(account => account.nodeAccounts); - if (nodeAccounts) { - this.config.account = { - numAccounts: nodeAccounts.numAddresses || 1, - password: nodeAccounts.password, - balance: nodeAccounts.balance - }; + if (this.userConfig.accounts) { + const nodeAccounts = this.userConfig.accounts.find(account => account.nodeAccounts); + if (nodeAccounts) { + this.config.account = { + numAccounts: nodeAccounts.numAddresses || 1, + password: nodeAccounts.password, + balance: nodeAccounts.balance + }; + } } - } - if (this.userConfig === {} || this.userConfig.default || JSON.stringify(this.userConfig) === '{"client":"parity"}') { - if (this.env === 'development') { - this.isDev = true; - } else { - this.config.genesisBlock = embarkPath("templates/boilerplate/config/privatenet/genesis.json"); - } - this.config.datadir = dappPath(".embark/development/datadir"); - this.config.wsOrigins = this.config.wsOrigins || "http://localhost:8000"; - this.config.rpcCorsDomain = this.config.rpcCorsDomain || "http://localhost:8000"; - this.config.targetGasLimit = 8000000; - } - this.config.account.devPassword = path.join(this.config.datadir, "devPassword"); - - const spaceMessage = 'The path for %s in blockchain config contains spaces, please remove them'; - if (this.config.datadir && this.config.datadir.indexOf(' ') > 0) { - this.logger.error(__(spaceMessage, 'datadir')); - process.exit(1); - } - if (this.config.account.password && this.config.account.password.indexOf(' ') > 0) { - this.logger.error(__(spaceMessage, 'accounts.password')); - process.exit(1); - } - if (this.config.genesisBlock && this.config.genesisBlock.indexOf(' ') > 0) { - this.logger.error(__(spaceMessage, 'genesisBlock')); - process.exit(1); - } - this.client = new clientClass({config: this.config, env: this.env, isDev: this.isDev}); - - this.initStandaloneProcess(); -}; - -/** - * Polls for a connection to an IPC server (generally this is set up - * in the Embark process). Once connected, any logs logged to the - * Logger will be shipped off to the IPC server. In the case of `embark - * run`, the BlockchainListener module is listening for these logs. - * - * @returns {void} - */ -Blockchain.prototype.initStandaloneProcess = function () { - if (this.isStandalone) { - let logQueue = []; - - // on every log logged in logger (say that 3x fast), send the log - // to the IPC serve listening (only if we're connected of course) - this.logger.events.on('log', (logLevel, message) => { - if (this.ipc.connected) { - this.ipc.request('blockchain:log', {logLevel, message}); + if (this.userConfig === {} || this.userConfig.default || JSON.stringify(this.userConfig) === '{"client":"parity"}') { + if (this.env === 'development') { + this.isDev = true; } else { - logQueue.push({logLevel, message}); + this.config.genesisBlock = embarkPath("templates/boilerplate/config/privatenet/genesis.json"); } - }); + this.config.datadir = dappPath(".embark/development/datadir"); + this.config.wsOrigins = this.config.wsOrigins || "http://localhost:8000"; + this.config.rpcCorsDomain = this.config.rpcCorsDomain || "http://localhost:8000"; + this.config.targetGasLimit = 8000000; + } + this.config.account.devPassword = path.join(this.config.datadir, "devPassword"); - this.ipc = new IPC({ipcRole: 'client'}); + const spaceMessage = 'The path for %s in blockchain config contains spaces, please remove them'; + if (this.config.datadir && this.config.datadir.indexOf(' ') > 0) { + this.logger.error(__(spaceMessage, 'datadir')); + process.exit(1); + } + if (this.config.account.password && this.config.account.password.indexOf(' ') > 0) { + this.logger.error(__(spaceMessage, 'accounts.password')); + process.exit(1); + } + if (this.config.genesisBlock && this.config.genesisBlock.indexOf(' ') > 0) { + this.logger.error(__(spaceMessage, 'genesisBlock')); + process.exit(1); + } + this.client = new clientClass({config: this.config, env: this.env, isDev: this.isDev}); - // Wait for an IPC server to start (ie `embark run`) by polling `.connect()`. - // Do not kill this interval as the IPC server may restart (ie restart - // `embark run` without restarting `embark blockchain`) - setInterval(() => { - if (!this.ipc.connected) { - this.ipc.connect(() => { - if (this.ipc.connected) { - logQueue.forEach(message => { this.ipc.request('blockchain:log', message); }); - logQueue = []; - this.ipc.client.on('process:blockchain:stop', () => { - this.kill(); - process.exit(0); - }); - } - }); - } - }, IPC_CONNECT_INTERVAL); + this.initStandaloneProcess(); } -}; -Blockchain.prototype.setupProxy = async function () { - // if (!this.proxyIpc) this.proxyIpc = new IPC({ipcRole: 'client'}); + /** + * Polls for a connection to an IPC server (generally this is set up + * in the Embark process). Once connected, any logs logged to the + * Logger will be shipped off to the IPC server. In the case of `embark + * run`, the BlockchainListener module is listening for these logs. + * + * @returns {void} + */ + initStandaloneProcess() { + if (this.isStandalone) { + let logQueue = []; - // const addresses = AccountParser.parseAccountsConfig(this.userConfig.accounts, false, dappPath(), this.logger); - - // let wsProxy; - // if (this.config.wsRPC) { - // wsProxy = new Proxy(this.proxyIpc).serve(this.config.wsHost, this.config.wsPort, true, this.config.wsOrigins, addresses, this.certOptions); - // } - - // [this.rpcProxy, this.wsProxy] = await Promise.all([new Proxy(this.proxyIpc).serve(this.config.rpcHost, this.config.rpcPort, false, null, addresses, this.certOptions), wsProxy]); -}; - -Blockchain.prototype.shutdownProxy = function () { - // if (!this.config.proxy) { - // return; - // } - - // if (this.rpcProxy) this.rpcProxy.close(); - // if (this.wsProxy) this.wsProxy.close(); -}; - -Blockchain.prototype.runCommand = function (cmd, options, callback) { - this.logger.info(__("running: %s", cmd.underline).green); - if (this.config.silent) { - options.silent = true; - } - return exec(cmd, options, callback); -}; - -Blockchain.prototype.run = function () { - var self = this; - this.logger.info("===============================================================================".magenta); - this.logger.info("===============================================================================".magenta); - this.logger.info(__("Embark Blockchain using %s", self.client.prettyName.underline).magenta); - this.logger.info("===============================================================================".magenta); - this.logger.info("===============================================================================".magenta); - - let address = ''; - async.waterfall([ - function checkInstallation(next) { - self.isClientInstalled((err) => { - if (err) { - return next({message: err}); + // on every log logged in logger (say that 3x fast), send the log + // to the IPC serve listening (only if we're connected of course) + this.logger.events.on('log', (logLevel, message) => { + if (this.ipc.connected) { + this.ipc.request('blockchain:log', {logLevel, message}); + } else { + logQueue.push({logLevel, message}); } - next(); }); - }, - function init(next) { - if (self.isDev) { - return self.initDevChain((err) => { - next(err); - }); - } - return self.initChainAndGetAddress((err, addr) => { - address = addr; - next(err); - }); - }, - function getMainCommand(next) { - self.client.mainCommand(address, function (cmd, args) { - next(null, cmd, args); - }, true); + + this.ipc = new IPC({ipcRole: 'client'}); + + // Wait for an IPC server to start (ie `embark run`) by polling `.connect()`. + // Do not kill this interval as the IPC server may restart (ie restart + // `embark run` without restarting `embark blockchain`) + setInterval(() => { + if (!this.ipc.connected) { + this.ipc.connect(() => { + if (this.ipc.connected) { + logQueue.forEach(message => { this.ipc.request('blockchain:log', message); }); + logQueue = []; + this.ipc.client.on('process:blockchain:stop', () => { + this.kill(); + process.exit(0); + }); + } + }); + } + }, IPC_CONNECT_INTERVAL); } - ], function (err, cmd, args) { - if (err) { - self.logger.error(err.message); - return; - } - args = compact(args); - - let full_cmd = cmd + " " + args.join(' '); - self.logger.info(__("running: %s", full_cmd.underline).green); - self.child = spawn(cmd, args, {cwd: process.cwd()}); - - self.child.on('error', (err) => { - err = err.toString(); - self.logger.error('Blockchain error: ', err); - if (self.env === 'development' && err.indexOf('Failed to unlock') > 0) { - self.logger.error('\n' + __('Development blockchain has changed to use the --dev option.').yellow); - self.logger.error(__('You can reset your workspace to fix the problem with').yellow + ' embark reset'.cyan); - self.logger.error(__('Otherwise, you can change your data directory in blockchain.json (datadir)').yellow); - } - }); - - // TOCHECK I don't understand why stderr and stdout are reverted. - // This happens with Geth and Parity, so it does not seems a client problem - self.child.stdout.on('data', (data) => { - self.logger.info(`${self.client.name} error: ${data}`); - }); - - self.child.stderr.on('data', async (data) => { - data = data.toString(); - if (!self.readyCalled && self.client.isReady(data)) { - self.readyCalled = true; - // if (self.config.proxy) { - // await self.setupProxy(); - // } - self.readyCallback(); - } - self.logger.info(`${self.client.name}: ${data}`); - }); - - self.child.on('exit', (code) => { - let strCode; - if (code) { - strCode = 'with error code ' + code; - } else { - strCode = 'with no error code (manually killed?)'; - } - self.logger.error(self.client.name + ' exited ' + strCode); - if (self.onExitCallback) { - self.onExitCallback(); - } - }); - - self.child.on('uncaughtException', (err) => { - self.logger.error('Uncaught ' + self.client.name + ' exception', err); - if (self.onExitCallback) { - self.onExitCallback(); - } - }); - }); -}; - -Blockchain.prototype.readyCallback = function () { - if (this.onReadyCallback) { - this.onReadyCallback(); } - if (this.config.mineWhenNeeded && !this.isDev) { - this.miner = this.client.getMiner(); + + async setupProxy() { + // if (!this.proxyIpc) this.proxyIpc = new IPC({ipcRole: 'client'}); + + // const addresses = AccountParser.parseAccountsConfig(this.userConfig.accounts, false, dappPath(), this.logger); + + // let wsProxy; + // if (this.config.wsRPC) { + // wsProxy = new Proxy(this.proxyIpc).serve(this.config.wsHost, this.config.wsPort, true, this.config.wsOrigins, addresses, this.certOptions); + // } + + // [this.rpcProxy, this.wsProxy] = await Promise.all([new Proxy(this.proxyIpc).serve(this.config.rpcHost, this.config.rpcPort, false, null, addresses, this.certOptions), wsProxy]); } -}; -Blockchain.prototype.kill = function () { - this.shutdownProxy(); - if (this.child) { - this.child.kill(); + shutdownProxy() { + // if (!this.config.proxy) { + // return; + // } + + // if (this.rpcProxy) this.rpcProxy.close(); + // if (this.wsProxy) this.wsProxy.close(); } -}; -Blockchain.prototype.isClientInstalled = function (callback) { - let versionCmd = this.client.determineVersionCommand(); - this.runCommand(versionCmd, {}, (err, stdout, stderr) => { - if (err || !stdout || stderr.indexOf("not found") >= 0 || stdout.indexOf("not found") >= 0) { - return callback(__('Ethereum client bin not found:') + ' ' + this.client.getBinaryPath()); + runCommand(cmd, options, callback) { + this.logger.info(__("running: %s", cmd.underline).green); + if (this.config.silent) { + options.silent = true; } - const parsedVersion = this.client.parseVersion(stdout); - const supported = this.client.isSupportedVersion(parsedVersion); - if (supported === undefined) { - this.logger.warn((__('WARNING! Ethereum client version could not be determined or compared with version range') + ' ' + this.client.versSupported + __(', for best results please use a supported version'))); - } else if (!supported) { - this.logger.warn((__('WARNING! Ethereum client version unsupported, for best results please use a version in range') + ' ' + this.client.versSupported)); - } - callback(); - }); -}; + return exec(cmd, options, callback); + } -Blockchain.prototype.initDevChain = function (callback) { - const self = this; - const ACCOUNTS_ALREADY_PRESENT = 'accounts_already_present'; - // Init the dev chain - self.client.initDevChain(self.config.datadir, (err) => { - if (err) { - return callback(err); - } + run() { + var self = this; + this.logger.info("===============================================================================".magenta); + this.logger.info("===============================================================================".magenta); + this.logger.info(__("Embark Blockchain using %s", self.client.prettyName.underline).magenta); + this.logger.info("===============================================================================".magenta); + this.logger.info("===============================================================================".magenta); - const accountsToCreate = self.config.account && self.config.account.numAccounts; - if (!accountsToCreate) return callback(); - - // Create other accounts + let address = ''; async.waterfall([ - function listAccounts(next) { - self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, _stderr) => { - if (err || stdout === undefined || stdout.indexOf("Fatal") >= 0) { - console.log(__("no accounts found").green); - return next(); - } - // List current addresses - self.config.unlockAddressList = self.client.parseListAccountsCommandResultToAddressList(stdout); - // Count current addresses and remove the default account from the count (because password can be different) - let addressCount = self.config.unlockAddressList.length; - if (addressCount < accountsToCreate) { - next(null, accountsToCreate - addressCount); - } else { - next(ACCOUNTS_ALREADY_PRESENT); + function checkInstallation(next) { + self.isClientInstalled((err) => { + if (err) { + return next({message: err}); } + next(); }); }, - function newAccounts(accountsToCreate, next) { - var accountNumber = 0; - async.whilst( - function () { - return accountNumber < accountsToCreate; - }, - function (callback) { - accountNumber++; - self.runCommand(self.client.newAccountCommand(), {}, (err, stdout, _stderr) => { - if (err) { - return callback(err, accountNumber); - } - self.config.unlockAddressList.push(self.client.parseNewAccountCommandResultToAddress(stdout)); - callback(null, accountNumber); - }); - }, - function (err) { + function init(next) { + if (self.isDev) { + return self.initDevChain((err) => { next(err); - } - ); + }); + } + return self.initChainAndGetAddress((err, addr) => { + address = addr; + next(err); + }); + }, + function getMainCommand(next) { + self.client.mainCommand(address, function (cmd, args) { + next(null, cmd, args); + }, true); } - ], (err) => { - if (err && err !== ACCOUNTS_ALREADY_PRESENT) { - console.log(err); - return callback(err); + ], function (err, cmd, args) { + if (err) { + self.logger.error(err.message); + return; + } + args = compact(args); + + let full_cmd = cmd + " " + args.join(' '); + self.logger.info(__("running: %s", full_cmd.underline).green); + self.child = spawn(cmd, args, {cwd: process.cwd()}); + + self.child.on('error', (err) => { + err = err.toString(); + self.logger.error('Blockchain error: ', err); + if (self.env === 'development' && err.indexOf('Failed to unlock') > 0) { + self.logger.error('\n' + __('Development blockchain has changed to use the --dev option.').yellow); + self.logger.error(__('You can reset your workspace to fix the problem with').yellow + ' embark reset'.cyan); + self.logger.error(__('Otherwise, you can change your data directory in blockchain.json (datadir)').yellow); + } + }); + + // TOCHECK I don't understand why stderr and stdout are reverted. + // This happens with Geth and Parity, so it does not seems a client problem + self.child.stdout.on('data', (data) => { + self.logger.info(`${self.client.name} error: ${data}`); + }); + + self.child.stderr.on('data', async (data) => { + data = data.toString(); + if (!self.readyCalled && self.client.isReady(data)) { + self.readyCalled = true; + // if (self.config.proxy) { + // await self.setupProxy(); + // } + self.readyCallback(); + } + self.logger.info(`${self.client.name}: ${data}`); + }); + + self.child.on('exit', (code) => { + let strCode; + if (code) { + strCode = 'with error code ' + code; + } else { + strCode = 'with no error code (manually killed?)'; + } + self.logger.error(self.client.name + ' exited ' + strCode); + if (self.onExitCallback) { + self.onExitCallback(); + } + }); + + self.child.on('uncaughtException', (err) => { + self.logger.error('Uncaught ' + self.client.name + ' exception', err); + if (self.onExitCallback) { + self.onExitCallback(); + } + }); + }); + } + + readyCallback() { + if (this.onReadyCallback) { + this.onReadyCallback(); + } + if (this.config.mineWhenNeeded && !this.isDev) { + this.miner = this.client.getMiner(); + } + } + + kill() { + this.shutdownProxy(); + if (this.child) { + this.child.kill(); + } + } + + isClientInstalled(callback) { + let versionCmd = this.client.determineVersionCommand(); + this.runCommand(versionCmd, {}, (err, stdout, stderr) => { + if (err || !stdout || stderr.indexOf("not found") >= 0 || stdout.indexOf("not found") >= 0) { + return callback(__('Ethereum client bin not found:') + ' ' + this.client.getBinaryPath()); + } + const parsedVersion = this.client.parseVersion(stdout); + const supported = this.client.isSupportedVersion(parsedVersion); + if (supported === undefined) { + this.logger.warn((__('WARNING! Ethereum client version could not be determined or compared with version range') + ' ' + this.client.versSupported + __(', for best results please use a supported version'))); + } else if (!supported) { + this.logger.warn((__('WARNING! Ethereum client version unsupported, for best results please use a version in range') + ' ' + this.client.versSupported)); } callback(); }); - }); -}; + } -Blockchain.prototype.initChainAndGetAddress = function (callback) { - const self = this; - let address = null; - const ALREADY_INITIALIZED = 'already'; - - // ensure datadir exists, bypassing the interactive liabilities prompt. - self.datadir = self.config.datadir; - - async.waterfall([ - function makeDir(next) { - fs.mkdirp(self.datadir, (err, _result) => { - next(err); - }); - }, - function listAccounts(next) { - self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, _stderr) => { - if (err || stdout === undefined || stdout.indexOf("Fatal") >= 0) { - self.logger.info(__("no accounts found").green); - return next(); - } - let firstAccountFound = self.client.parseListAccountsCommandResultToAddress(stdout); - if (firstAccountFound === undefined || firstAccountFound === "") { - console.log(__("no accounts found").green); - return next(); - } - self.logger.info(__("already initialized").green); - address = firstAccountFound; - next(ALREADY_INITIALIZED); - }); - }, - function genesisBlock(next) { - //There's no genesis init with Parity. Custom network are set in the chain property at startup - if (!self.config.genesisBlock || self.client.name === constants.blockchain.clients.parity) { - return next(); + initDevChain(callback) { + const self = this; + const ACCOUNTS_ALREADY_PRESENT = 'accounts_already_present'; + // Init the dev chain + self.client.initDevChain(self.config.datadir, (err) => { + if (err) { + return callback(err); } - self.logger.info(__("initializing genesis block").green); - self.runCommand(self.client.initGenesisCommmand(), {}, (err, _stdout, _stderr) => { - next(err); - }); - }, - function newAccount(next) { - self.runCommand(self.client.newAccountCommand(), {}, (err, stdout, _stderr) => { - if (err) { - return next(err); + + const accountsToCreate = self.config.account && self.config.account.numAccounts; + if (!accountsToCreate) return callback(); + + // Create other accounts + async.waterfall([ + function listAccounts(next) { + self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, _stderr) => { + if (err || stdout === undefined || stdout.indexOf("Fatal") >= 0) { + console.log(__("no accounts found").green); + return next(); + } + // List current addresses + self.config.unlockAddressList = self.client.parseListAccountsCommandResultToAddressList(stdout); + // Count current addresses and remove the default account from the count (because password can be different) + let addressCount = self.config.unlockAddressList.length; + if (addressCount < accountsToCreate) { + next(null, accountsToCreate - addressCount); + } else { + next(ACCOUNTS_ALREADY_PRESENT); + } + }); + }, + function newAccounts(accountsToCreate, next) { + var accountNumber = 0; + async.whilst( + function () { + return accountNumber < accountsToCreate; + }, + function (callback) { + accountNumber++; + self.runCommand(self.client.newAccountCommand(), {}, (err, stdout, _stderr) => { + if (err) { + return callback(err, accountNumber); + } + self.config.unlockAddressList.push(self.client.parseNewAccountCommandResultToAddress(stdout)); + callback(null, accountNumber); + }); + }, + function (err) { + next(err); + } + ); } - address = self.client.parseNewAccountCommandResultToAddress(stdout); - next(); + ], (err) => { + if (err && err !== ACCOUNTS_ALREADY_PRESENT) { + console.log(err); + return callback(err); + } + callback(); }); - } - ], (err) => { - if (err === ALREADY_INITIALIZED) { - err = null; - } - callback(err, address); - }); -}; - -export function BlockchainClient(userConfig, options) { - if ((userConfig === {} || JSON.stringify(userConfig) === '{"enabled":true}') && options.env !== 'development') { - options.logger.info("===> " + __("warning: running default config on a non-development environment")); + }); } - // if client is not set in preferences, default is parity - if (!userConfig.client) userConfig.client = constants.blockchain.clients.parity; - // if clientName is set, it overrides preferences - if (options.clientName) userConfig.client = options.clientName; - // Choose correct client instance based on clientName - let clientClass; - switch (userConfig.client) { - case constants.blockchain.clients.parity: - clientClass = ParityClient; - break; - // case constants.blockchain.clients.parity: - // clientClass = ParityClient; - // break; - default: - console.error(__('Unknown client "%s". Please use one of the following: %s', userConfig.client, Object.keys(constants.blockchain.clients).join(', '))); - process.exit(1); + initChainAndGetAddress(callback) { + const self = this; + let address = null; + const ALREADY_INITIALIZED = 'already'; + + // ensure datadir exists, bypassing the interactive liabilities prompt. + self.datadir = self.config.datadir; + + async.waterfall([ + function makeDir(next) { + fs.mkdirp(self.datadir, (err, _result) => { + next(err); + }); + }, + function listAccounts(next) { + self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, _stderr) => { + if (err || stdout === undefined || stdout.indexOf("Fatal") >= 0) { + self.logger.info(__("no accounts found").green); + return next(); + } + let firstAccountFound = self.client.parseListAccountsCommandResultToAddress(stdout); + if (firstAccountFound === undefined || firstAccountFound === "") { + console.log(__("no accounts found").green); + return next(); + } + self.logger.info(__("already initialized").green); + address = firstAccountFound; + next(ALREADY_INITIALIZED); + }); + }, + function genesisBlock(next) { + //There's no genesis init with Parity. Custom network are set in the chain property at startup + if (!self.config.genesisBlock || self.client.name === constants.blockchain.clients.parity) { + return next(); + } + self.logger.info(__("initializing genesis block").green); + self.runCommand(self.client.initGenesisCommmand(), {}, (err, _stdout, _stderr) => { + next(err); + }); + }, + function newAccount(next) { + self.runCommand(self.client.newAccountCommand(), {}, (err, stdout, _stderr) => { + if (err) { + return next(err); + } + address = self.client.parseNewAccountCommandResultToAddress(stdout); + next(); + }); + } + ], (err) => { + if (err === ALREADY_INITIALIZED) { + err = null; + } + callback(err, address); + }); + } +} + +export class BlockchainClient extends Blockchain { + constructor(userConfig, options) { + if ((userConfig === {} || JSON.stringify(userConfig) === '{"enabled":true}') && options.env !== 'development') { + options.logger.info("===> " + __("warning: running default config on a non-development environment")); + } + // if client is not set in preferences, default is parity + if (!userConfig.client) userConfig.client = constants.blockchain.clients.parity; + // if clientName is set, it overrides preferences + if (options.clientName) userConfig.client = options.clientName; + // Choose correct client instance based on clientName + let clientClass; + switch (userConfig.client) { + case constants.blockchain.clients.parity: + clientClass = ParityClient; + break; + + // case constants.blockchain.clients.parity: + // clientClass = ParityClient; + // break; + default: + console.error(__('Unknown client "%s". Please use one of the following: %s', userConfig.client, Object.keys(constants.blockchain.clients).join(', '))); + process.exit(1); + } + userConfig.isDev = (userConfig.isDev || userConfig.default); + userConfig.env = options.env; + userConfig.onReadyCallback = options.onReadyCallback; + userConfig.onExitCallback = options.onExitCallback; + userConfig.logger = options.logger; + userConfig.certOptions = options.certOptions; + userConfig.isStandalone = options.isStandalone; + + super(userConfig, clientClass); } - userConfig.isDev = (userConfig.isDev || userConfig.default); - userConfig.env = options.env; - userConfig.onReadyCallback = options.onReadyCallback; - userConfig.onExitCallback = options.onExitCallback; - userConfig.logger = options.logger; - userConfig.certOptions = options.certOptions; - userConfig.isStandalone = options.isStandalone; - return new Blockchain(userConfig, clientClass); } diff --git a/packages/plugins/parity/src/blockchainProcess.js b/packages/plugins/parity/src/blockchainProcess.js index 75b82623c..897f37342 100644 --- a/packages/plugins/parity/src/blockchainProcess.js +++ b/packages/plugins/parity/src/blockchainProcess.js @@ -17,7 +17,7 @@ class BlockchainProcess extends ProcessWrapper { i18n.setOrDetectLocale(options.locale); this.blockchainConfig.silent = true; - this.blockchain = BlockchainClient( + this.blockchain = new BlockchainClient( this.blockchainConfig, { clientName: this.client, diff --git a/packages/plugins/parity/tsconfig.json b/packages/plugins/parity/tsconfig.json index 1ffac409c..a69fef8a7 100644 --- a/packages/plugins/parity/tsconfig.json +++ b/packages/plugins/parity/tsconfig.json @@ -1,5 +1,23 @@ { - "compilerOptions": { "baseUrl": ".", "paths": { "*": ["types/*"] } }, - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-parity.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + } + ] } diff --git a/packages/plugins/plugin-cmd/package.json b/packages/plugins/plugin-cmd/package.json index 5d056a3aa..ff8031403 100644 --- a/packages/plugins/plugin-cmd/package.json +++ b/packages/plugins/plugin-cmd/package.json @@ -16,15 +16,18 @@ "dist" ], "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/plugin-cmd/tsconfig.json b/packages/plugins/plugin-cmd/tsconfig.json new file mode 100644 index 000000000..6ed577384 --- /dev/null +++ b/packages/plugins/plugin-cmd/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-plugin-cmd.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/plugins/profiler/package.json b/packages/plugins/profiler/package.json index f102a27c5..578861674 100644 --- a/packages/plugins/profiler/package.json +++ b/packages/plugins/profiler/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/profiler/tsconfig.json b/packages/plugins/profiler/tsconfig.json new file mode 100644 index 000000000..2f6e7e52b --- /dev/null +++ b/packages/plugins/profiler/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-profiler.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/plugins/rpc-manager/package.json b/packages/plugins/rpc-manager/package.json index b9fadb16a..2560202c0 100644 --- a/packages/plugins/rpc-manager/package.json +++ b/packages/plugins/rpc-manager/package.json @@ -2,7 +2,6 @@ "name": "embark-rpc-manager", "version": "5.0.0-alpha.4", "description": "Embark RPC Manager", - "main": "./dist/lib/index.js", "repository": { "directory": "packages/plugins/embark-rpc-manager", "type": "git", @@ -23,21 +22,24 @@ "files": [ "dist/" ], + "main": "./dist/lib/index.js", + "types": "./dist/lib/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "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\"", - "qa": "npm-run-all lint typecheck _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf .nyc_output coverage dist embark-*.tgz package", "solo": "embark-solo", - "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register", - "typecheck": "tsc" + "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register" }, "eslintConfig": { "extends": "../../../.eslintrc.json" @@ -45,21 +47,24 @@ "dependencies": { "@babel/runtime-corejs3": "7.7.4", "@omisego/omg-js-util": "2.0.0-v0.2", + "@types/async": "2.0.50", "async": "2.6.1", "embark-core": "^5.0.0-alpha.4", "embark-i18n": "^5.0.0-alpha.2", + "embark-logger": "^5.0.0-alpha.4", "embark-utils": "^5.0.0-alpha.4", "web3": "1.2.1" }, "devDependencies": { - "@types/async": "2.0.50", "cross-env": "5.2.0", + "embark-solo": "^5.0.0-alpha.0", "eslint": "5.7.0", "mocha": "6.2.2", "npm-run-all": "4.1.5", + "nyc": "13.1.0", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/plugins/rpc-manager/src/lib/eth_accounts.ts b/packages/plugins/rpc-manager/src/lib/eth_accounts.ts index 551ba2394..6845003ba 100644 --- a/packages/plugins/rpc-manager/src/lib/eth_accounts.ts +++ b/packages/plugins/rpc-manager/src/lib/eth_accounts.ts @@ -1,7 +1,8 @@ -import { Callback, Embark, Events, Logger } /* supplied by @types/embark in packages/embark-typings */ from "embark"; -import Web3 from "web3"; +import { Callback, Embark, EmbarkEvents } from "embark-core"; const { blockchain: blockchainConstants } = require("embark-core/constants"); import { __ } from "embark-i18n"; +import { Logger } from "embark-logger"; +import Web3 from "web3"; import RpcModifier from "./rpcModifier"; const METHODS_TO_MODIFY = [ @@ -18,7 +19,7 @@ function arrayEqual(arrayA: string[], arrayB: string[]) { } export default class EthAccounts extends RpcModifier { - constructor(embark: Embark, rpcModifierEvents: Events) { + constructor(embark: Embark, rpcModifierEvents: EmbarkEvents) { super(embark, rpcModifierEvents); this.init(); diff --git a/packages/plugins/rpc-manager/src/lib/eth_sendTransaction.ts b/packages/plugins/rpc-manager/src/lib/eth_sendTransaction.ts index f2b129d43..402a503a5 100644 --- a/packages/plugins/rpc-manager/src/lib/eth_sendTransaction.ts +++ b/packages/plugins/rpc-manager/src/lib/eth_sendTransaction.ts @@ -1,6 +1,7 @@ import async from "async"; -import { Callback, Embark, Events, Logger } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Callback, Embark, EmbarkEvents } from "embark-core"; import { __ } from "embark-i18n"; +import { Logger } from "embark-logger"; import Web3 from "web3"; const { blockchain: blockchainConstants } = require("embark-core/constants"); import RpcModifier from "./rpcModifier"; @@ -8,7 +9,7 @@ import RpcModifier from "./rpcModifier"; export default class EthSendTransaction extends RpcModifier { private signTransactionQueue: any; private nonceCache: any = {}; - constructor(embark: Embark, rpcModifierEvents: Events) { + constructor(embark: Embark, rpcModifierEvents: EmbarkEvents) { super(embark, rpcModifierEvents); embark.registerActionForEvent("blockchain:proxy:request", this.ethSendTransactionRequest.bind(this)); diff --git a/packages/plugins/rpc-manager/src/lib/eth_signData.ts b/packages/plugins/rpc-manager/src/lib/eth_signData.ts index 1c36fe6de..3a380f809 100644 --- a/packages/plugins/rpc-manager/src/lib/eth_signData.ts +++ b/packages/plugins/rpc-manager/src/lib/eth_signData.ts @@ -1,10 +1,10 @@ -import { Callback, Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Callback, Embark, EmbarkEvents } from "embark-core"; import { __ } from "embark-i18n"; import Web3 from "web3"; import RpcModifier from "./rpcModifier"; export default class EthSignData extends RpcModifier { - constructor(embark: Embark, rpcModifierEvents: Events) { + constructor(embark: Embark, rpcModifierEvents: EmbarkEvents) { super(embark, rpcModifierEvents); this.embark.registerActionForEvent("blockchain:proxy:request", this.ethSignDataRequest.bind(this)); diff --git a/packages/plugins/rpc-manager/src/lib/eth_signTypedData.ts b/packages/plugins/rpc-manager/src/lib/eth_signTypedData.ts index 7f5746d14..ac2a989a5 100644 --- a/packages/plugins/rpc-manager/src/lib/eth_signTypedData.ts +++ b/packages/plugins/rpc-manager/src/lib/eth_signTypedData.ts @@ -1,11 +1,12 @@ import { sign, transaction } from "@omisego/omg-js-util"; -import { Callback, Embark, Events, Logger } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Callback, Embark, EmbarkEvents } from "embark-core"; import { __ } from "embark-i18n"; +import { Logger } from "embark-logger"; import Web3 from "web3"; import RpcModifier from "./rpcModifier"; export default class EthSignTypedData extends RpcModifier { - constructor(embark: Embark, rpcModifierEvents: Events) { + constructor(embark: Embark, rpcModifierEvents: EmbarkEvents) { super(embark, rpcModifierEvents); this.embark.registerActionForEvent("blockchain:proxy:request", this.ethSignTypedDataRequest.bind(this)); diff --git a/packages/plugins/rpc-manager/src/lib/eth_subscribe.ts b/packages/plugins/rpc-manager/src/lib/eth_subscribe.ts index 24b485dd2..c49b6d122 100644 --- a/packages/plugins/rpc-manager/src/lib/eth_subscribe.ts +++ b/packages/plugins/rpc-manager/src/lib/eth_subscribe.ts @@ -1,9 +1,9 @@ -import { Callback, Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Callback, Embark, EmbarkEvents } from "embark-core"; import { __ } from "embark-i18n"; import RpcModifier from "./rpcModifier"; export default class EthSubscribe extends RpcModifier { - constructor(embark: Embark, rpcModifierEvents: Events) { + constructor(embark: Embark, rpcModifierEvents: EmbarkEvents) { super(embark, rpcModifierEvents); embark.registerActionForEvent("blockchain:proxy:request", this.ethSubscribeRequest.bind(this)); diff --git a/packages/plugins/rpc-manager/src/lib/eth_unsubscribe.ts b/packages/plugins/rpc-manager/src/lib/eth_unsubscribe.ts index 35042e3a3..6c0b989ba 100644 --- a/packages/plugins/rpc-manager/src/lib/eth_unsubscribe.ts +++ b/packages/plugins/rpc-manager/src/lib/eth_unsubscribe.ts @@ -1,10 +1,10 @@ -import { Callback, Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Callback, Embark, EmbarkEvents } from "embark-core"; import { __ } from "embark-i18n"; import RpcModifier from "./rpcModifier"; export default class EthUnsubscribe extends RpcModifier { - constructor(embark: Embark, rpcModifierEvents: Events) { + constructor(embark: Embark, rpcModifierEvents: EmbarkEvents) { super(embark, rpcModifierEvents); embark.registerActionForEvent("blockchain:proxy:request", this.ethUnsubscribeRequest.bind(this)); diff --git a/packages/plugins/rpc-manager/src/lib/index.ts b/packages/plugins/rpc-manager/src/lib/index.ts index a9898bddf..49922d125 100644 --- a/packages/plugins/rpc-manager/src/lib/index.ts +++ b/packages/plugins/rpc-manager/src/lib/index.ts @@ -1,4 +1,5 @@ -import { Callback, Embark, Events } from "embark-core"; +import { Callback, Embark, EmbarkEvents } from "embark-core"; +import { Events } from "embark-core"; import { Logger } from 'embark-logger'; import Web3 from "web3"; import EthAccounts from "./eth_accounts"; @@ -14,15 +15,15 @@ export default class RpcManager { private modifiers: RpcModifier[] = []; private _web3: Web3 | null = null; - private rpcModifierEvents: Events; + private rpcModifierEvents: EmbarkEvents; private logger: Logger; - private events: Events; + private events: EmbarkEvents; public _accounts: any[] | null = null; public _nodeAccounts: any[] | null = null; constructor(private readonly embark: Embark) { this.events = embark.events; this.logger = embark.logger; - this.rpcModifierEvents = new Events(); + this.rpcModifierEvents = new Events() as EmbarkEvents; this.init(); } diff --git a/packages/plugins/rpc-manager/src/lib/personal_newAccount.ts b/packages/plugins/rpc-manager/src/lib/personal_newAccount.ts index 60d032035..eac13d55e 100644 --- a/packages/plugins/rpc-manager/src/lib/personal_newAccount.ts +++ b/packages/plugins/rpc-manager/src/lib/personal_newAccount.ts @@ -1,10 +1,10 @@ -import { Callback, Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Callback, Embark, EmbarkEvents } from "embark-core"; import Web3 from "web3"; const { blockchain: blockchainConstants } = require("embark-core/constants"); import { __ } from "embark-i18n"; import RpcModifier from "./rpcModifier"; export default class PersonalNewAccount extends RpcModifier { - constructor(embark: Embark, rpcModifierEvents: Events) { + constructor(embark: Embark, rpcModifierEvents: EmbarkEvents) { super(embark, rpcModifierEvents); embark.registerActionForEvent("blockchain:proxy:response", this.personalNewAccountResponse.bind(this)); diff --git a/packages/plugins/rpc-manager/src/lib/rpcModifier.ts b/packages/plugins/rpc-manager/src/lib/rpcModifier.ts index 83da7bd6d..ebff0bc24 100644 --- a/packages/plugins/rpc-manager/src/lib/rpcModifier.ts +++ b/packages/plugins/rpc-manager/src/lib/rpcModifier.ts @@ -1,14 +1,15 @@ -import { Embark, Events, Logger } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Embark, EmbarkEvents } /* supplied by @types/embark in packages/core/typings */ from "embark-core"; +import { Logger } from "embark-logger"; import { AccountParser, dappPath } from "embark-utils"; import Web3 from "web3"; export default class RpcModifier { - public events: Events; + public events: EmbarkEvents; public logger: Logger; private _web3: Web3 | null = null; private _accounts: any[] | null = null; protected _nodeAccounts: any[] | null = null; - constructor(readonly embark: Embark, readonly rpcModifierEvents: Events) { + constructor(readonly embark: Embark, readonly rpcModifierEvents: EmbarkEvents) { this.events = embark.events; this.logger = embark.logger; diff --git a/packages/plugins/rpc-manager/tsconfig.json b/packages/plugins/rpc-manager/tsconfig.json index 1bb65da9e..7fb155bea 100644 --- a/packages/plugins/rpc-manager/tsconfig.json +++ b/packages/plugins/rpc-manager/tsconfig.json @@ -1,4 +1,26 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-rpc-manager.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/lib/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/logger" + }, + { + "path": "../../core/utils" + } + ] } diff --git a/packages/plugins/scaffolding/package.json b/packages/plugins/scaffolding/package.json index 6f7822c93..84fd626b8 100644 --- a/packages/plugins/scaffolding/package.json +++ b/packages/plugins/scaffolding/package.json @@ -25,26 +25,27 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "npm-run-all lint:*", "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", - "qa": "npm-run-all lint typecheck _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "solo": "embark-solo" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", "ajv": "6.10.2", "core-js": "3.4.3", + "embark-core": "^5.0.0-alpha.3", "embark-i18n": "^5.0.0-alpha.2", "embark-logger": "^5.0.0-alpha.2", "embark-utils": "^5.0.0-alpha.2", @@ -58,8 +59,8 @@ "lodash.clonedeep": "4.5.0", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/plugins/scaffolding/src/contractLanguage/solidityBuilder/index.ts b/packages/plugins/scaffolding/src/contractLanguage/solidityBuilder/index.ts index 4073b42af..fc6acb0f6 100644 --- a/packages/plugins/scaffolding/src/contractLanguage/solidityBuilder/index.ts +++ b/packages/plugins/scaffolding/src/contractLanguage/solidityBuilder/index.ts @@ -1,4 +1,4 @@ -import { Embark } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Embark } from "embark-core"; import { __ } from "embark-i18n"; import { dappPath } from "embark-utils"; import Handlebars from "handlebars"; diff --git a/packages/plugins/scaffolding/src/framework/reactBuilder/index.ts b/packages/plugins/scaffolding/src/framework/reactBuilder/index.ts index 9bb4e8880..cedf4bbea 100644 --- a/packages/plugins/scaffolding/src/framework/reactBuilder/index.ts +++ b/packages/plugins/scaffolding/src/framework/reactBuilder/index.ts @@ -1,4 +1,4 @@ -import { Contract, Embark } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Contract, Embark } from "embark-core"; import { __ } from "embark-i18n"; import Handlebars from "handlebars"; import * as path from "path"; diff --git a/packages/plugins/scaffolding/src/index.ts b/packages/plugins/scaffolding/src/index.ts index 81ccdf89c..86f2c7198 100644 --- a/packages/plugins/scaffolding/src/index.ts +++ b/packages/plugins/scaffolding/src/index.ts @@ -1,4 +1,4 @@ -import { Contract, Embark } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Contract, Embark } from "embark-core"; import { CommandOptions, ContractLanguage, Framework } from "./commandOptions"; import { SolidityBuilder } from "./contractLanguage/solidityBuilder"; import { ReactBuilder } from "./framework/reactBuilder"; diff --git a/packages/plugins/scaffolding/tsconfig.json b/packages/plugins/scaffolding/tsconfig.json index 1dc6632e6..4414f29ec 100644 --- a/packages/plugins/scaffolding/tsconfig.json +++ b/packages/plugins/scaffolding/tsconfig.json @@ -1,5 +1,26 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-scaffolding.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/logger" + }, + { + "path": "../../core/utils" + } + ] } - diff --git a/packages/plugins/scaffolding/tslint.json b/packages/plugins/scaffolding/tslint.json index 1bdfa34f9..1f63906f0 100644 --- a/packages/plugins/scaffolding/tslint.json +++ b/packages/plugins/scaffolding/tslint.json @@ -1,4 +1,3 @@ { "extends": "../../../tslint.json" } - diff --git a/packages/plugins/snark/package.json b/packages/plugins/snark/package.json index 13d7fb700..16dc54dfe 100644 --- a/packages/plugins/snark/package.json +++ b/packages/plugins/snark/package.json @@ -28,19 +28,22 @@ "type": "git", "url": "https://github.com/embark-framework/embark.git" }, - "main": "dist/index.js", "files": [ "dist" ], + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/ test/", - "qa": "npm-run-all lint _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf coverage dist embark-*.tgz package", "solo": "embark-solo", "test": "jest" diff --git a/packages/plugins/snark/tsconfig.json b/packages/plugins/snark/tsconfig.json new file mode 100644 index 000000000..454deff83 --- /dev/null +++ b/packages/plugins/snark/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-snark.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/plugins/solc/package.json b/packages/plugins/solc/package.json index 501d6dc0c..9850dd2f2 100644 --- a/packages/plugins/solc/package.json +++ b/packages/plugins/solc/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/solc/tsconfig.json b/packages/plugins/solc/tsconfig.json new file mode 100644 index 000000000..3494b2b51 --- /dev/null +++ b/packages/plugins/solc/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-solc.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/plugins/solidity-tests/package.json b/packages/plugins/solidity-tests/package.json index 9ccbebfe5..1630dc8cb 100644 --- a/packages/plugins/solidity-tests/package.json +++ b/packages/plugins/solidity-tests/package.json @@ -2,7 +2,6 @@ "name": "embark-solidity-tests", "version": "5.0.0-alpha.4", "description": "Plugin to run Embark solidity tests", - "main": "dist/lib/index.js", "homepage": "https://github.com/embark-framework/embark/tree/master/packages/plugins/solidity-tests#readme", "repository": { "directory": "packages/plugins/solidity-tests", @@ -24,15 +23,19 @@ "files": [ "dist" ], + "main": "./dist/lib/index.js", + "types": "./dist/lib/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf .nyc_output dist embark-*.tgz package", "solo": "embark-solo", "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register" @@ -45,6 +48,7 @@ "@types/async": "3.0.3", "async": "3.1.0", "core-js": "3.4.3", + "embark-utils": "^5.0.0-alpha.2", "remix-tests": "0.1.20", "web3": "1.2.1", "yo-yoify": "4.3.0" diff --git a/packages/plugins/solidity-tests/tsconfig.json b/packages/plugins/solidity-tests/tsconfig.json new file mode 100644 index 000000000..d7e4a88e6 --- /dev/null +++ b/packages/plugins/solidity-tests/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-solidity-tests.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/lib/**/*" + ], + "references": [ + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/plugins/solidity/package.json b/packages/plugins/solidity/package.json index c1e9a764c..71e4042ef 100644 --- a/packages/plugins/solidity/package.json +++ b/packages/plugins/solidity/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/solidity/tsconfig.json b/packages/plugins/solidity/tsconfig.json new file mode 100644 index 000000000..fca49a8d2 --- /dev/null +++ b/packages/plugins/solidity/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-solidity.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/plugins/specialconfigs/package.json b/packages/plugins/specialconfigs/package.json index 69bbdeee7..2ec7a5432 100644 --- a/packages/plugins/specialconfigs/package.json +++ b/packages/plugins/specialconfigs/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/specialconfigs/tsconfig.json b/packages/plugins/specialconfigs/tsconfig.json new file mode 100644 index 000000000..728af9796 --- /dev/null +++ b/packages/plugins/specialconfigs/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-specialconfigs.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/i18n" + } + ] +} diff --git a/packages/plugins/swarm/package.json b/packages/plugins/swarm/package.json index d662c4e78..4249406c6 100644 --- a/packages/plugins/swarm/package.json +++ b/packages/plugins/swarm/package.json @@ -28,15 +28,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint process.js src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/swarm/tsconfig.json b/packages/plugins/swarm/tsconfig.json new file mode 100644 index 000000000..d8d312340 --- /dev/null +++ b/packages/plugins/swarm/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-swarm.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../embarkjs/embarkjs" + }, + { + "path": "../../embarkjs/swarm" + }, + { + "path": "../../stack/storage" + } + ] +} diff --git a/packages/plugins/transaction-logger/package.json b/packages/plugins/transaction-logger/package.json index 2993a4da4..c82d96aa7 100644 --- a/packages/plugins/transaction-logger/package.json +++ b/packages/plugins/transaction-logger/package.json @@ -25,15 +25,20 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", - "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "lint": "npm-run-all lint:*", + "lint:js": "eslint src/", + "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, @@ -42,6 +47,7 @@ }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", + "@types/web3": "1.0.12", "async": "2.6.1", "core-js": "3.4.3", "embark-core": "^5.0.0-alpha.4", @@ -55,7 +61,9 @@ "embark-solo": "^5.0.0-alpha.2", "eslint": "5.7.0", "npm-run-all": "4.1.5", - "rimraf": "3.0.0" + "rimraf": "3.0.0", + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/plugins/transaction-logger/src/index.js b/packages/plugins/transaction-logger/src/index.js index 23c6d6669..92cabab2a 100644 --- a/packages/plugins/transaction-logger/src/index.js +++ b/packages/plugins/transaction-logger/src/index.js @@ -3,8 +3,9 @@ import { __ } from 'embark-i18n'; const Web3 = require('web3'); const { blockchain: blockchainConstants } = require('embark-core/constants'); -import { dappPath, getAddressToContract, getTransactionParams, hexToNumber } from 'embark-utils'; - +import { dappPath, hexToNumber } from 'embark-utils'; +import { getAddressToContract, getTransactionParams } from './transactionUtils'; +export { getAddressToContract, getTransactionParams }; const Transaction = require('ethereumjs-tx'); const ethUtil = require('ethereumjs-util'); @@ -16,7 +17,7 @@ const LISTENED_METHODS = [ blockchainConstants.transactionMethods.eth_sendRawTransaction ]; -class TransactionLogger { +export default class TransactionLogger { constructor(embark, _options) { this.embark = embark; this.logger = embark.logger; @@ -269,5 +270,3 @@ class TransactionLogger { } } } - -module.exports = TransactionLogger; diff --git a/packages/core/utils/src/transactionUtils.ts b/packages/plugins/transaction-logger/src/transactionUtils.ts similarity index 93% rename from packages/core/utils/src/transactionUtils.ts rename to packages/plugins/transaction-logger/src/transactionUtils.ts index 5d1a7938c..8559a0765 100644 --- a/packages/core/utils/src/transactionUtils.ts +++ b/packages/plugins/transaction-logger/src/transactionUtils.ts @@ -1,6 +1,6 @@ -import { Contract } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Contract } from "embark-core"; +import { decodeParams, sha3 } from "embark-utils"; import { ABIDefinition } from "web3/eth/abi"; -import { decodeParams, sha3 } from "./web3Utils"; interface AddressToContract { name: string; diff --git a/packages/plugins/transaction-logger/tsconfig.json b/packages/plugins/transaction-logger/tsconfig.json new file mode 100644 index 000000000..c0b69288b --- /dev/null +++ b/packages/plugins/transaction-logger/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-transaction-logger.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/plugins/parity/tslint.json b/packages/plugins/transaction-logger/tslint.json similarity index 100% rename from packages/plugins/parity/tslint.json rename to packages/plugins/transaction-logger/tslint.json diff --git a/packages/plugins/transaction-tracker/package.json b/packages/plugins/transaction-tracker/package.json index c362b29e2..0076c585c 100644 --- a/packages/plugins/transaction-tracker/package.json +++ b/packages/plugins/transaction-tracker/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/transaction-tracker/tsconfig.json b/packages/plugins/transaction-tracker/tsconfig.json new file mode 100644 index 000000000..84ce757da --- /dev/null +++ b/packages/plugins/transaction-tracker/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-transaction-tracker.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/plugins/vyper/package.json b/packages/plugins/vyper/package.json index dd13df9ea..212138dc0 100644 --- a/packages/plugins/vyper/package.json +++ b/packages/plugins/vyper/package.json @@ -21,19 +21,22 @@ "type": "git", "url": "https://github.com/embark-framework/embark.git" }, - "main": "./dist/index.js", "files": [ "dist" ], + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/vyper/tsconfig.json b/packages/plugins/vyper/tsconfig.json new file mode 100644 index 000000000..9d8aba81c --- /dev/null +++ b/packages/plugins/vyper/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-vyper.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/i18n" + } + ] +} diff --git a/packages/plugins/web3/package.json b/packages/plugins/web3/package.json index e3a449936..c255a06cf 100644 --- a/packages/plugins/web3/package.json +++ b/packages/plugins/web3/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/web3/tsconfig.json b/packages/plugins/web3/tsconfig.json new file mode 100644 index 000000000..81e2cddc2 --- /dev/null +++ b/packages/plugins/web3/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-web3.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../embarkjs/web3" + } + ] +} diff --git a/packages/plugins/whisper-geth/package.json b/packages/plugins/whisper-geth/package.json index 8d06649f1..dbcdeed60 100644 --- a/packages/plugins/whisper-geth/package.json +++ b/packages/plugins/whisper-geth/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/whisper-geth/src/blockchain.js b/packages/plugins/whisper-geth/src/blockchain.js index 1e352cf5f..fe66cc3ba 100644 --- a/packages/plugins/whisper-geth/src/blockchain.js +++ b/packages/plugins/whisper-geth/src/blockchain.js @@ -13,289 +13,294 @@ const Logger = require("embark-logger"); // time between IPC connection attempts (in ms) const IPC_CONNECT_INTERVAL = 2000; -/*eslint complexity: ["error", 50]*/ -var Blockchain = function(userConfig, clientClass, communicationConfig) { - this.userConfig = userConfig; - this.env = userConfig.env || "development"; - this.isDev = userConfig.isDev; - this.onReadyCallback = userConfig.onReadyCallback || (() => {}); - this.onExitCallback = userConfig.onExitCallback; - this.logger = userConfig.logger || new Logger({logLevel: "debug", context: constants.contexts.blockchain}); // do not pass in events as we don't want any log events emitted - this.events = userConfig.events; - this.isStandalone = userConfig.isStandalone; - this.certOptions = userConfig.certOptions; +class Blockchain { + /*eslint complexity: ["error", 50]*/ + constructor(userConfig, clientClass, communicationConfig) { + this.userConfig = userConfig; + this.env = userConfig.env || "development"; + this.isDev = userConfig.isDev; + this.onReadyCallback = userConfig.onReadyCallback || (() => {}); + this.onExitCallback = userConfig.onExitCallback; + this.logger = userConfig.logger || new Logger({logLevel: "debug", context: constants.contexts.blockchain}); // do not pass in events as we don't want any log events emitted + this.events = userConfig.events; + this.isStandalone = userConfig.isStandalone; + this.certOptions = userConfig.certOptions; - let defaultWsApi = clientClass.DEFAULTS.WS_API; - if (this.isDev) defaultWsApi = clientClass.DEFAULTS.DEV_WS_API; + let defaultWsApi = clientClass.DEFAULTS.WS_API; + if (this.isDev) defaultWsApi = clientClass.DEFAULTS.DEV_WS_API; - this.config = { - silent: this.userConfig.silent, - client: this.userConfig.client, - ethereumClientBin: this.userConfig.ethereumClientBin || this.userConfig.client, - networkType: this.userConfig.networkType || clientClass.DEFAULTS.NETWORK_TYPE, - networkId: this.userConfig.networkId || clientClass.DEFAULTS.NETWORK_ID, - genesisBlock: this.userConfig.genesisBlock || false, - datadir: this.userConfig.datadir, - mineWhenNeeded: this.userConfig.mineWhenNeeded || false, - rpcHost: dockerHostSwap(this.userConfig.rpcHost) || defaultHost, - rpcPort: this.userConfig.rpcPort || 8545, - rpcCorsDomain: this.userConfig.rpcCorsDomain || false, - rpcApi: this.userConfig.rpcApi || clientClass.DEFAULTS.RPC_API, - port: this.userConfig.port || 30303, - nodiscover: this.userConfig.nodiscover || false, - mine: this.userConfig.mine || false, - account: {}, - whisper: (this.userConfig.whisper !== false), - maxpeers: ((this.userConfig.maxpeers === 0) ? 0 : (this.userConfig.maxpeers || 25)), - bootnodes: this.userConfig.bootnodes || "", - wsRPC: (this.userConfig.wsRPC !== false), - wsHost: dockerHostSwap(this.userConfig.wsHost) || defaultHost, - wsPort: this.userConfig.wsPort || 8546, - wsOrigins: this.userConfig.wsOrigins || false, - wsApi: this.userConfig.wsApi || defaultWsApi, - vmdebug: this.userConfig.vmdebug || false, - targetGasLimit: this.userConfig.targetGasLimit || false, - syncMode: this.userConfig.syncMode || this.userConfig.syncmode, - verbosity: this.userConfig.verbosity - }; + this.config = { + silent: this.userConfig.silent, + client: this.userConfig.client, + ethereumClientBin: this.userConfig.ethereumClientBin || this.userConfig.client, + networkType: this.userConfig.networkType || clientClass.DEFAULTS.NETWORK_TYPE, + networkId: this.userConfig.networkId || clientClass.DEFAULTS.NETWORK_ID, + genesisBlock: this.userConfig.genesisBlock || false, + datadir: this.userConfig.datadir, + mineWhenNeeded: this.userConfig.mineWhenNeeded || false, + rpcHost: dockerHostSwap(this.userConfig.rpcHost) || defaultHost, + rpcPort: this.userConfig.rpcPort || 8545, + rpcCorsDomain: this.userConfig.rpcCorsDomain || false, + rpcApi: this.userConfig.rpcApi || clientClass.DEFAULTS.RPC_API, + port: this.userConfig.port || 30303, + nodiscover: this.userConfig.nodiscover || false, + mine: this.userConfig.mine || false, + account: {}, + whisper: (this.userConfig.whisper !== false), + maxpeers: ((this.userConfig.maxpeers === 0) ? 0 : (this.userConfig.maxpeers || 25)), + bootnodes: this.userConfig.bootnodes || "", + wsRPC: (this.userConfig.wsRPC !== false), + wsHost: dockerHostSwap(this.userConfig.wsHost) || defaultHost, + wsPort: this.userConfig.wsPort || 8546, + wsOrigins: this.userConfig.wsOrigins || false, + wsApi: this.userConfig.wsApi || defaultWsApi, + vmdebug: this.userConfig.vmdebug || false, + targetGasLimit: this.userConfig.targetGasLimit || false, + syncMode: this.userConfig.syncMode || this.userConfig.syncmode, + verbosity: this.userConfig.verbosity + }; - this.devFunds = null; + this.devFunds = null; - if (this.userConfig.accounts) { - const nodeAccounts = this.userConfig.accounts.find((account) => account.nodeAccounts); - if (nodeAccounts) { - this.config.account = { - numAccounts: nodeAccounts.numAddresses || 1, - password: nodeAccounts.password, - balance: nodeAccounts.balance - }; - } - } - - if (this.userConfig.default || JSON.stringify(this.userConfig) === "{'client':'geth'}") { - if (this.env === "development") { - this.isDev = true; - } else { - this.config.genesisBlock = embarkPath("templates/boilerplate/config/privatenet/genesis.json"); - } - this.config.datadir = dappPath(".embark/development/datadir"); - this.config.wsOrigins = this.config.wsOrigins || "http://localhost:8000"; - this.config.rpcCorsDomain = this.config.rpcCorsDomain || "http://localhost:8000"; - this.config.targetGasLimit = 8000000; - } - this.config.account.devPassword = path.join(this.config.datadir, "devPassword"); - - const spaceMessage = "The path for %s in blockchain config contains spaces, please remove them"; - if (this.config.datadir && this.config.datadir.indexOf(" ") > 0) { - this.logger.error(__(spaceMessage, "datadir")); - process.exit(1); - } - if (this.config.account.password && this.config.account.password.indexOf(" ") > 0) { - this.logger.error(__(spaceMessage, "accounts.password")); - process.exit(1); - } - if (this.config.genesisBlock && this.config.genesisBlock.indexOf(" ") > 0) { - this.logger.error(__(spaceMessage, "genesisBlock")); - process.exit(1); - } - this.client = new clientClass({config: this.config, env: this.env, isDev: this.isDev, communicationConfig: communicationConfig}); - - if (this.isStandalone) { - this.initStandaloneProcess(); - } -}; - -/** - * Polls for a connection to an IPC server (generally this is set up - * in the Embark process). Once connected, any logs logged to the - * Logger will be shipped off to the IPC server. In the case of `embark - * run`, the BlockchainListener module is listening for these logs. - * - * @return {void} - */ -Blockchain.prototype.initStandaloneProcess = function() { - let logQueue = []; - - // on every log logged in logger (say that 3x fast), send the log - // to the IPC serve listening (only if we're connected of course) - this.logger.events.on("log", (logLevel, message) => { - if (this.ipc.connected) { - this.ipc.request("blockchain:log", {logLevel, message}); - } else { - logQueue.push({logLevel, message}); - } - }); - - this.ipc = new IPC({ipcRole: "client"}); - - // Wait for an IPC server to start (ie `embark run`) by polling `.connect()`. - // Do not kill this interval as the IPC server may restart (ie restart - // `embark run` without restarting `embark blockchain`) - setInterval(() => { - if (!this.ipc.connected) { - this.ipc.connect(() => { - if (this.ipc.connected) { - logQueue.forEach((message) => { - this.ipc.request("blockchain:log", message); - }); - logQueue = []; - this.ipc.client.on("process:blockchain:stop", () => { - this.kill(); - process.exit(0); - }); - } - }); - } - }, IPC_CONNECT_INTERVAL); -}; - -Blockchain.prototype.runCommand = function (cmd, options, callback) { - this.logger.info(__("running: %s", cmd.underline).green); - if (this.config.silent) { - options.silent = true; - } - return exec(cmd, options, callback); -}; - -Blockchain.prototype.run = function () { - var self = this; - this.logger.info("===============================================================================".magenta); - this.logger.info("===============================================================================".magenta); - this.logger.info(__("Embark Whisper using %s", self.client.prettyName.underline).magenta); - this.logger.info("===============================================================================".magenta); - this.logger.info("===============================================================================".magenta); - - if (self.client.name === constants.blockchain.clients.geth) this.checkPathLength(); - - let address = ""; - async.waterfall([ - function checkInstallation(next) { - self.isClientInstalled((err) => { - if (err) { - return next({ message: err }); - } - next(); - }); - }, - function getMainCommand(next) { - self.client.mainCommand(address, function (cmd, args) { - next(null, cmd, args); - }, true); - } - ], function(err, cmd, args) { - if (err) { - self.logger.error(err.message); - return; - } - args = compact(args); - - let full_cmd = cmd + " " + args.join(" "); - self.logger.info(__(">>>>>>>>>>>>>>>> running: %s", full_cmd.underline).green); - self.child = spawn(cmd, args, {cwd: process.cwd()}); - - self.child.on("error", (err) => { - err = err.toString(); - self.logger.error("Blockchain error: ", err); - if (self.env === "development" && err.indexOf("Failed to unlock") > 0) { - self.logger.error("\n" + __("Development blockchain has changed to use the --dev option.").yellow); - self.logger.error(__("You can reset your workspace to fix the problem with").yellow + " embark reset".cyan); - self.logger.error(__("Otherwise, you can change your data directory in blockchain.json (datadir)").yellow); + if (this.userConfig.accounts) { + const nodeAccounts = this.userConfig.accounts.find((account) => account.nodeAccounts); + if (nodeAccounts) { + this.config.account = { + numAccounts: nodeAccounts.numAddresses || 1, + password: nodeAccounts.password, + balance: nodeAccounts.balance + }; } - }); + } - // TOCHECK I don't understand why stderr and stdout are reverted. - // This happens with Geth and Parity, so it does not seems a client problem - self.child.stdout.on("data", (data) => { - self.logger.error(`${self.client.name} error: ${data}`); - }); - - self.child.stderr.on("data", async (data) => { - data = data.toString(); - if (!self.readyCalled && self.client.isReady(data)) { - self.readyCalled = true; - self.readyCallback(); - } - self.logger.info(`${self.client.name}: ${data}`); - }); - - self.child.on("exit", (code) => { - let strCode; - if (code) { - strCode = "with error code " + code; + if (this.userConfig.default || JSON.stringify(this.userConfig) === "{'client':'geth'}") { + if (this.env === "development") { + this.isDev = true; } else { - strCode = "with no error code (manually killed?)"; + this.config.genesisBlock = embarkPath("templates/boilerplate/config/privatenet/genesis.json"); } - self.logger.error(self.client.name + " exited " + strCode); - if (self.onExitCallback) { - self.onExitCallback(); + this.config.datadir = dappPath(".embark/development/datadir"); + this.config.wsOrigins = this.config.wsOrigins || "http://localhost:8000"; + this.config.rpcCorsDomain = this.config.rpcCorsDomain || "http://localhost:8000"; + this.config.targetGasLimit = 8000000; + } + this.config.account.devPassword = path.join(this.config.datadir, "devPassword"); + + const spaceMessage = "The path for %s in blockchain config contains spaces, please remove them"; + if (this.config.datadir && this.config.datadir.indexOf(" ") > 0) { + this.logger.error(__(spaceMessage, "datadir")); + process.exit(1); + } + if (this.config.account.password && this.config.account.password.indexOf(" ") > 0) { + this.logger.error(__(spaceMessage, "accounts.password")); + process.exit(1); + } + if (this.config.genesisBlock && this.config.genesisBlock.indexOf(" ") > 0) { + this.logger.error(__(spaceMessage, "genesisBlock")); + process.exit(1); + } + this.client = new clientClass({config: this.config, env: this.env, isDev: this.isDev, communicationConfig: communicationConfig}); + + if (this.isStandalone) { + this.initStandaloneProcess(); + } + } + + /** + * Polls for a connection to an IPC server (generally this is set up + * in the Embark process). Once connected, any logs logged to the + * Logger will be shipped off to the IPC server. In the case of `embark + * run`, the BlockchainListener module is listening for these logs. + * + * @return {void} + */ + initStandaloneProcess() { + let logQueue = []; + + // on every log logged in logger (say that 3x fast), send the log + // to the IPC serve listening (only if we're connected of course) + this.logger.events.on("log", (logLevel, message) => { + if (this.ipc.connected) { + this.ipc.request("blockchain:log", {logLevel, message}); + } else { + logQueue.push({logLevel, message}); } }); - self.child.on("uncaughtException", (err) => { - self.logger.error("Uncaught " + self.client.name + " exception", err); - if (self.onExitCallback) { - self.onExitCallback(); + this.ipc = new IPC({ipcRole: "client"}); + + // Wait for an IPC server to start (ie `embark run`) by polling `.connect()`. + // Do not kill this interval as the IPC server may restart (ie restart + // `embark run` without restarting `embark blockchain`) + setInterval(() => { + if (!this.ipc.connected) { + this.ipc.connect(() => { + if (this.ipc.connected) { + logQueue.forEach((message) => { + this.ipc.request("blockchain:log", message); + }); + logQueue = []; + this.ipc.client.on("process:blockchain:stop", () => { + this.kill(); + process.exit(0); + }); + } + }); } + }, IPC_CONNECT_INTERVAL); + } + + runCommand(cmd, options, callback) { + this.logger.info(__("running: %s", cmd.underline).green); + if (this.config.silent) { + options.silent = true; + } + return exec(cmd, options, callback); + } + + run() { + var self = this; + this.logger.info("===============================================================================".magenta); + this.logger.info("===============================================================================".magenta); + this.logger.info(__("Embark Whisper using %s", self.client.prettyName.underline).magenta); + this.logger.info("===============================================================================".magenta); + this.logger.info("===============================================================================".magenta); + + if (self.client.name === constants.blockchain.clients.geth) this.checkPathLength(); + + let address = ""; + async.waterfall([ + function checkInstallation(next) { + self.isClientInstalled((err) => { + if (err) { + return next({ message: err }); + } + next(); + }); + }, + function getMainCommand(next) { + self.client.mainCommand(address, function (cmd, args) { + next(null, cmd, args); + }, true); + } + ], function(err, cmd, args) { + if (err) { + self.logger.error(err.message); + return; + } + args = compact(args); + + let full_cmd = cmd + " " + args.join(" "); + self.logger.info(__(">>>>>>>>>>>>>>>> running: %s", full_cmd.underline).green); + self.child = spawn(cmd, args, {cwd: process.cwd()}); + + self.child.on("error", (err) => { + err = err.toString(); + self.logger.error("Blockchain error: ", err); + if (self.env === "development" && err.indexOf("Failed to unlock") > 0) { + self.logger.error("\n" + __("Development blockchain has changed to use the --dev option.").yellow); + self.logger.error(__("You can reset your workspace to fix the problem with").yellow + " embark reset".cyan); + self.logger.error(__("Otherwise, you can change your data directory in blockchain.json (datadir)").yellow); + } + }); + + // TOCHECK I don't understand why stderr and stdout are reverted. + // This happens with Geth and Parity, so it does not seems a client problem + self.child.stdout.on("data", (data) => { + self.logger.error(`${self.client.name} error: ${data}`); + }); + + self.child.stderr.on("data", async (data) => { + data = data.toString(); + if (!self.readyCalled && self.client.isReady(data)) { + self.readyCalled = true; + self.readyCallback(); + } + self.logger.info(`${self.client.name}: ${data}`); + }); + + self.child.on("exit", (code) => { + let strCode; + if (code) { + strCode = "with error code " + code; + } else { + strCode = "with no error code (manually killed?)"; + } + self.logger.error(self.client.name + " exited " + strCode); + if (self.onExitCallback) { + self.onExitCallback(); + } + }); + + self.child.on("uncaughtException", (err) => { + self.logger.error("Uncaught " + self.client.name + " exception", err); + if (self.onExitCallback) { + self.onExitCallback(); + } + }); }); - }); -}; - -Blockchain.prototype.readyCallback = function () { - if (this.onReadyCallback) { - this.onReadyCallback(); } -}; -Blockchain.prototype.kill = function () { - if (this.child) { - this.child.kill(); - } -}; - -Blockchain.prototype.checkPathLength = function () { - let _dappPath = dappPath(""); - if (_dappPath.length > 66) { - // this.logger.error is captured and sent to the console output regardless of silent setting - this.logger.error("===============================================================================".yellow); - this.logger.error("===========> ".yellow + __("WARNING! ÐApp path length is too long: ").yellow + _dappPath.yellow); - this.logger.error("===========> ".yellow + __("This is known to cause issues with starting geth, please consider reducing your ÐApp path\'s length to 66 characters or less.").yellow); - this.logger.error("===============================================================================".yellow); - } -}; - -Blockchain.prototype.isClientInstalled = function (callback) { - let versionCmd = this.client.determineVersionCommand(); - this.runCommand(versionCmd, {}, (err, stdout, stderr) => { - if (err || !stdout || stderr.indexOf("not found") >= 0 || stdout.indexOf("not found") >= 0) { - return callback(__("Ethereum client bin not found:") + " " + this.client.getBinaryPath()); + readyCallback() { + if (this.onReadyCallback) { + this.onReadyCallback(); } - const parsedVersion = this.client.parseVersion(stdout); - const supported = this.client.isSupportedVersion(parsedVersion); - if (supported === undefined) { - this.logger.warn((__("WARNING! Ethereum client version could not be determined or compared with version range") + " " + this.client.versSupported + __(", for best results please use a supported version"))); - } else if (!supported) { - this.logger.warn((__("WARNING! Ethereum client version unsupported, for best results please use a version in range") + " " + this.client.versSupported)); - } - callback(); - }); -}; - -export function BlockchainClient(userConfig, options, communicationConfig) { - if ((JSON.stringify(userConfig) === "{'enabled':true}") && options.env !== "development") { - options.logger.info("===> " + __("warning: running default config on a non-development environment")); } - // if client is not set in preferences, default is geth - if (!userConfig.client) userConfig.client = constants.blockchain.clients.geth; - // if clientName is set, it overrides preferences - if (options.clientName) userConfig.client = options.clientName; - userConfig.isDev = (userConfig.isDev || userConfig.default); - userConfig.env = options.env; - userConfig.onReadyCallback = options.onReadyCallback; - userConfig.onExitCallback = options.onExitCallback; - userConfig.logger = options.logger; - userConfig.certOptions = options.certOptions; - userConfig.isStandalone = options.isStandalone; - return new Blockchain(userConfig, WhisperGethClient, communicationConfig); + kill() { + if (this.child) { + this.child.kill(); + } + } + + checkPathLength() { + let _dappPath = dappPath(""); + if (_dappPath.length > 66) { + // this.logger.error is captured and sent to the console output regardless of silent setting + this.logger.error("===============================================================================".yellow); + this.logger.error("===========> ".yellow + __("WARNING! ÐApp path length is too long: ").yellow + _dappPath.yellow); + this.logger.error("===========> ".yellow + __("This is known to cause issues with starting geth, please consider reducing your ÐApp path\'s length to 66 characters or less.").yellow); + this.logger.error("===============================================================================".yellow); + } + } + + isClientInstalled(callback) { + let versionCmd = this.client.determineVersionCommand(); + this.runCommand(versionCmd, {}, (err, stdout, stderr) => { + if (err || !stdout || stderr.indexOf("not found") >= 0 || stdout.indexOf("not found") >= 0) { + return callback(__("Ethereum client bin not found:") + " " + this.client.getBinaryPath()); + } + const parsedVersion = this.client.parseVersion(stdout); + const supported = this.client.isSupportedVersion(parsedVersion); + if (supported === undefined) { + this.logger.warn((__("WARNING! Ethereum client version could not be determined or compared with version range") + " " + this.client.versSupported + __(", for best results please use a supported version"))); + } else if (!supported) { + this.logger.warn((__("WARNING! Ethereum client version unsupported, for best results please use a version in range") + " " + this.client.versSupported)); + } + callback(); + }); + } +} + +export class BlockchainClient extends Blockchain { + constructor(userConfig, options, communicationConfig) { + if ((JSON.stringify(userConfig) === "{'enabled':true}") && options.env !== "development") { + options.logger.info("===> " + __("warning: running default config on a non-development environment")); + } + // if client is not set in preferences, default is geth + if (!userConfig.client) userConfig.client = constants.blockchain.clients.geth; + // if clientName is set, it overrides preferences + if (options.clientName) userConfig.client = options.clientName; + + userConfig.isDev = (userConfig.isDev || userConfig.default); + userConfig.env = options.env; + userConfig.onReadyCallback = options.onReadyCallback; + userConfig.onExitCallback = options.onExitCallback; + userConfig.logger = options.logger; + userConfig.certOptions = options.certOptions; + userConfig.isStandalone = options.isStandalone; + + super(userConfig, WhisperGethClient, communicationConfig); + } } diff --git a/packages/plugins/whisper-geth/src/blockchainProcess.js b/packages/plugins/whisper-geth/src/blockchainProcess.js index 640bb8366..30fc64dcb 100644 --- a/packages/plugins/whisper-geth/src/blockchainProcess.js +++ b/packages/plugins/whisper-geth/src/blockchainProcess.js @@ -1,7 +1,7 @@ import * as i18n from "embark-i18n"; import { ProcessWrapper } from "embark-core"; const constants = require("embark-core/constants"); -import { BlockchainClient as blockchainClient } from "./blockchain"; +import { BlockchainClient } from "./blockchain"; let blockchainProcess; @@ -18,7 +18,7 @@ class BlockchainProcess extends ProcessWrapper { i18n.setOrDetectLocale(options.locale); this.blockchainConfig.silent = true; - this.blockchain = blockchainClient( + this.blockchain = new BlockchainClient( this.blockchainConfig, { clientName: this.client, diff --git a/packages/plugins/whisper-geth/tsconfig.json b/packages/plugins/whisper-geth/tsconfig.json new file mode 100644 index 000000000..513dfff42 --- /dev/null +++ b/packages/plugins/whisper-geth/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-whisper-geth.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../embarkjs/whisper" + } + ] +} diff --git a/packages/plugins/whisper-parity/package.json b/packages/plugins/whisper-parity/package.json index fe3212a67..e340da3c1 100644 --- a/packages/plugins/whisper-parity/package.json +++ b/packages/plugins/whisper-parity/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/plugins/whisper-parity/tsconfig.json b/packages/plugins/whisper-parity/tsconfig.json new file mode 100644 index 000000000..6961db734 --- /dev/null +++ b/packages/plugins/whisper-parity/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-whisper-parity.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../embarkjs/whisper" + } + ] +} diff --git a/packages/stack/api/package.json b/packages/stack/api/package.json index 999736898..11cc737ed 100644 --- a/packages/stack/api/package.json +++ b/packages/stack/api/package.json @@ -22,32 +22,39 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "files": [ "dist" ], "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "npm-run-all lint:*", "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", - "qa": "npm-run-all lint typecheck _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "solo": "embark-solo" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", + "@types/body-parser": "1.17.1", + "@types/cors": "2.8.6", + "@types/express": "4.17.1", + "@types/express-ws": "3.0.0", + "@types/helmet": "0.0.42", "body-parser": "1.19.0", "colors": "1.3.2", "core-js": "3.4.3", "cors": "2.8.5", + "embark-core": "^5.0.0-alpha.3", "embark-i18n": "^5.0.0-alpha.2", + "embark-ui": "^5.0.0-alpha.4", "embark-utils": "^5.0.0-alpha.4", "express": "4.17.1", "express-ws": "4.0.0", @@ -55,17 +62,11 @@ "helmet": "3.13.0" }, "devDependencies": { - "@types/body-parser": "1.17.1", - "@types/cors": "2.8.6", - "@types/express": "4.17.1", - "@types/express-ws": "3.0.0", - "@types/find-up": "4.0.0", - "@types/helmet": "0.0.42", "embark-solo": "^5.0.0-alpha.2", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/stack/api/src/index.ts b/packages/stack/api/src/index.ts index 2afc698ed..de11efca3 100644 --- a/packages/stack/api/src/index.ts +++ b/packages/stack/api/src/index.ts @@ -1,4 +1,4 @@ -import {Embark} /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import {Embark} from "embark-core"; import { __ } from "embark-i18n"; import {checkIsAvailable, dockerHostSwap, findNextPort} from "embark-utils"; diff --git a/packages/stack/api/src/server.ts b/packages/stack/api/src/server.ts index 73d0a9b93..ce516629c 100644 --- a/packages/stack/api/src/server.ts +++ b/packages/stack/api/src/server.ts @@ -1,9 +1,9 @@ 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 {Embark, EmbarkPlugins} from "embark-core"; import { __ } from "embark-i18n"; -import {embarkPath, findMonorepoPackageFromRootSync, isInsideMonorepoSync, monorepoRootPathSync} from "embark-utils"; +import {findMonorepoPackageFromRootSync, isInsideMonorepoSync, monorepoRootPathSync} from "embark-utils"; import express, {NextFunction, Request, Response} from "express"; import expressWs, { Application } from "express-ws"; import findUp from "find-up"; @@ -24,23 +24,23 @@ interface CallDescription { export default class Server { private isInsideMonorepo: boolean; private monorepoRootPath: string = ""; - private embarkUiBuildDir: string = embarkPath("node_modules/embark-ui/build"); + // in the monorepo and other deduped installs embark-ui may be in a higher-up node_modules + private embarkUiBuildDir: string = path.join(findUp.sync( + "node_modules/embark-ui", + {cwd: __dirname, type: "directory"} + ) as string, "build"); private expressInstance: expressWs.Instance; private isLogging: boolean = false; private server?: http.Server; private openSockets = new Set(); - constructor(private embark: Embark, private port: number, private hostname: string, private plugins: Plugins) { + constructor(private embark: Embark, private port: number, private hostname: string, private plugins: EmbarkPlugins) { this.isInsideMonorepo = isInsideMonorepoSync(); if (this.isInsideMonorepo) { this.monorepoRootPath = monorepoRootPathSync(); } - // in the monorepo and other deduped installs embark-ui may be in a higher-up node_modules - const foundEmbarkUi = findUp.sync("node_modules/embark-ui", {cwd: embarkPath(), type: "directory"}); - if (foundEmbarkUi) { - this.embarkUiBuildDir = path.join(foundEmbarkUi, "build"); - } + this.expressInstance = this.initApp(); } diff --git a/packages/stack/api/tsconfig.json b/packages/stack/api/tsconfig.json index 1bb65da9e..54d6d15e0 100644 --- a/packages/stack/api/tsconfig.json +++ b/packages/stack/api/tsconfig.json @@ -1,4 +1,23 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-api.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + } + ] } diff --git a/packages/stack/authenticator/package.json b/packages/stack/authenticator/package.json index 13ce5ab75..2056c93b7 100644 --- a/packages/stack/authenticator/package.json +++ b/packages/stack/authenticator/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/stack/authenticator/tsconfig.json b/packages/stack/authenticator/tsconfig.json new file mode 100644 index 000000000..e23c93862 --- /dev/null +++ b/packages/stack/authenticator/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-authenticator.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/stack/blockchain-client/package.json b/packages/stack/blockchain-client/package.json index bee3d30c3..3aa8121dd 100644 --- a/packages/stack/blockchain-client/package.json +++ b/packages/stack/blockchain-client/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/stack/blockchain-client/tsconfig.json b/packages/stack/blockchain-client/tsconfig.json new file mode 100644 index 000000000..988a48b66 --- /dev/null +++ b/packages/stack/blockchain-client/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-blockchain-client.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ] +} diff --git a/packages/stack/blockchain/package.json b/packages/stack/blockchain/package.json index d43918726..214356eff 100644 --- a/packages/stack/blockchain/package.json +++ b/packages/stack/blockchain/package.json @@ -25,15 +25,20 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", - "lint": "eslint src/", - "qa": "npm-run-all lint _build test", + "lint": "npm-run-all lint:*", + "lint:js": "eslint src/", + "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo", "test": "jest" @@ -59,7 +64,9 @@ "eslint": "5.7.0", "jest": "24.9.0", "npm-run-all": "4.1.5", - "rimraf": "3.0.0" + "rimraf": "3.0.0", + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/stack/blockchain/src/api.ts b/packages/stack/blockchain/src/api.ts index 1408c97f7..0fb072306 100644 --- a/packages/stack/blockchain/src/api.ts +++ b/packages/stack/blockchain/src/api.ts @@ -1,9 +1,9 @@ -import { Embark, Events } from "embark"; +import { Embark, EmbarkEvents } from "embark-core"; import { Logger } from 'embark-logger'; export default class BlockchainAPI { private embark: Embark; private logger: Logger; - private events: Events; + private events: EmbarkEvents; private apiPlugins: Map void>> = new Map(); private requestPlugins: Map any>> = new Map(); constructor(embark: Embark) { diff --git a/packages/stack/blockchain/src/index.js b/packages/stack/blockchain/src/index.js index c5336eba2..6fc6209c7 100644 --- a/packages/stack/blockchain/src/index.js +++ b/packages/stack/blockchain/src/index.js @@ -3,7 +3,7 @@ const { __ } = require('embark-i18n'); const constants = require('embark-core/constants'); import BlockchainAPI from "./api"; -class Blockchain { +export default class Blockchain { constructor(embark, options) { this.embark = embark; @@ -160,5 +160,3 @@ class Blockchain { }); } } - -module.exports = Blockchain; diff --git a/packages/stack/blockchain/tsconfig.json b/packages/stack/blockchain/tsconfig.json index 52d43eaaa..d30c62920 100644 --- a/packages/stack/blockchain/tsconfig.json +++ b/packages/stack/blockchain/tsconfig.json @@ -1,4 +1,29 @@ { - "extends": "../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-blockchain.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/logger" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../utils/testing" + } + ] } diff --git a/packages/stack/blockchain/tslint.json b/packages/stack/blockchain/tslint.json index 0946f2096..1f63906f0 100644 --- a/packages/stack/blockchain/tslint.json +++ b/packages/stack/blockchain/tslint.json @@ -1,3 +1,3 @@ { - "extends": "../../tslint.json" + "extends": "../../../tslint.json" } diff --git a/packages/stack/communication/package.json b/packages/stack/communication/package.json index b62365578..fc2347439 100644 --- a/packages/stack/communication/package.json +++ b/packages/stack/communication/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo", "test": "jest" diff --git a/packages/stack/communication/tsconfig.json b/packages/stack/communication/tsconfig.json new file mode 100644 index 000000000..076baf4c6 --- /dev/null +++ b/packages/stack/communication/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-communication.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../utils/testing" + } + ] +} diff --git a/packages/stack/compiler/package.json b/packages/stack/compiler/package.json index d1c2cbe2f..e5612ef4b 100644 --- a/packages/stack/compiler/package.json +++ b/packages/stack/compiler/package.json @@ -22,29 +22,30 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "files": [ "dist" ], "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "npm-run-all lint:*", "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", - "qa": "npm-run-all lint typecheck _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo", - "test": "jest", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "test": "jest" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", "core-js": "3.4.3", + "embark-core": "^5.0.0-alpha.3", "embark-i18n": "^5.0.0-alpha.2", "embark-utils": "^5.0.0-alpha.4" }, @@ -58,8 +59,8 @@ "jest": "24.9.0", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/stack/compiler/src/index.ts b/packages/stack/compiler/src/index.ts index 73889d21d..88e400f18 100644 --- a/packages/stack/compiler/src/index.ts +++ b/packages/stack/compiler/src/index.ts @@ -1,4 +1,4 @@ -import { Callback, CompilerPluginObject, Embark, Plugins /* supplied by @types/embark in packages/embark-typings */ } from "embark"; +import { Callback, CompilerPluginObject, Embark, EmbarkPlugins } from "embark-core"; import { __ } from "embark-i18n"; import * as os from "os"; import * as path from "path"; @@ -6,10 +6,10 @@ import { promisify } from "util"; const { File, Types, dappPath } = require("embark-utils"); -class Compiler { +export default class Compiler { private fs: any; private logger: any; - private plugins: Plugins; + private plugins: EmbarkPlugins; constructor(embark: Embark, options: any) { this.fs = embark.fs; @@ -132,5 +132,3 @@ class Compiler { }; } } - -module.exports = Compiler; diff --git a/packages/stack/compiler/tsconfig.json b/packages/stack/compiler/tsconfig.json index 1bb65da9e..9e383007c 100644 --- a/packages/stack/compiler/tsconfig.json +++ b/packages/stack/compiler/tsconfig.json @@ -1,4 +1,26 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-compiler.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../utils/testing" + } + ] } diff --git a/packages/stack/contracts-manager/package.json b/packages/stack/contracts-manager/package.json index a1908a378..c0b0ff2a4 100644 --- a/packages/stack/contracts-manager/package.json +++ b/packages/stack/contracts-manager/package.json @@ -25,22 +25,22 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "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\"", - "qa": "npm-run-all lint typecheck _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "solo": "embark-solo" }, "eslintConfig": { "extends": "../../../.eslintrc.json" @@ -61,8 +61,8 @@ "eslint": "5.7.0", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/stack/contracts-manager/src/contract.ts b/packages/stack/contracts-manager/src/contract.ts index ea00ae541..45d81d0fd 100644 --- a/packages/stack/contracts-manager/src/contract.ts +++ b/packages/stack/contracts-manager/src/contract.ts @@ -1,4 +1,4 @@ -import { ContractConfig } from "embark"; +import { ContractConfig } from "embark-core"; import { Logger } from 'embark-logger'; const { sha3 } = require("embark-utils"); import { ABIDefinition } from "web3/eth/abi"; diff --git a/packages/stack/contracts-manager/src/index.js b/packages/stack/contracts-manager/src/index.js index 14414623f..3c79a6524 100644 --- a/packages/stack/contracts-manager/src/index.js +++ b/packages/stack/contracts-manager/src/index.js @@ -5,7 +5,7 @@ const async = require('async'); const constants = require('embark-core/constants'); const {dappPath, proposeAlternative, toposort} = require('embark-utils'); -class ContractsManager { +export default class ContractsManager { constructor(embark, options) { this.embark = embark; this.logger = embark.logger; @@ -662,5 +662,3 @@ class ContractsManager { return data; } } - -module.exports = ContractsManager; diff --git a/packages/stack/contracts-manager/tsconfig.json b/packages/stack/contracts-manager/tsconfig.json index 1bb65da9e..0520d93f3 100644 --- a/packages/stack/contracts-manager/tsconfig.json +++ b/packages/stack/contracts-manager/tsconfig.json @@ -1,4 +1,26 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-contracts-manager.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/logger" + }, + { + "path": "../../core/utils" + } + ] } diff --git a/packages/stack/deployment/package.json b/packages/stack/deployment/package.json index 9a54de73c..7f9cdc03e 100644 --- a/packages/stack/deployment/package.json +++ b/packages/stack/deployment/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo", "test": "jest" diff --git a/packages/stack/deployment/tsconfig.json b/packages/stack/deployment/tsconfig.json new file mode 100644 index 000000000..2271c1bb9 --- /dev/null +++ b/packages/stack/deployment/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-deployment.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../utils/testing" + } + ] +} diff --git a/packages/stack/embarkjs/package.json b/packages/stack/embarkjs/package.json index 6cff6341f..b3c2abe54 100644 --- a/packages/stack/embarkjs/package.json +++ b/packages/stack/embarkjs/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/stack/embarkjs/tsconfig.json b/packages/stack/embarkjs/tsconfig.json new file mode 100644 index 000000000..fe0588b71 --- /dev/null +++ b/packages/stack/embarkjs/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-embarkjs.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + } + ] +} diff --git a/packages/stack/library-manager/package.json b/packages/stack/library-manager/package.json index 09886895c..b82fd7105 100644 --- a/packages/stack/library-manager/package.json +++ b/packages/stack/library-manager/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/stack/library-manager/tsconfig.json b/packages/stack/library-manager/tsconfig.json new file mode 100644 index 000000000..cdf876fbd --- /dev/null +++ b/packages/stack/library-manager/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-library-manager.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/stack/namesystem/package.json b/packages/stack/namesystem/package.json index 4b66070ff..0f525616e 100644 --- a/packages/stack/namesystem/package.json +++ b/packages/stack/namesystem/package.json @@ -26,15 +26,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/stack/namesystem/tsconfig.json b/packages/stack/namesystem/tsconfig.json new file mode 100644 index 000000000..a38dc1d0e --- /dev/null +++ b/packages/stack/namesystem/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-namesystem.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/i18n" + } + ] +} diff --git a/packages/stack/pipeline/package.json b/packages/stack/pipeline/package.json index fd6216c9c..060dfa887 100644 --- a/packages/stack/pipeline/package.json +++ b/packages/stack/pipeline/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/stack/pipeline/tsconfig.json b/packages/stack/pipeline/tsconfig.json new file mode 100644 index 000000000..fecd8c4e1 --- /dev/null +++ b/packages/stack/pipeline/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-pipeline.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/stack/process-logs-api-manager/package.json b/packages/stack/process-logs-api-manager/package.json index 584436b86..0bd2abb1d 100644 --- a/packages/stack/process-logs-api-manager/package.json +++ b/packages/stack/process-logs-api-manager/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/stack/process-logs-api-manager/tsconfig.json b/packages/stack/process-logs-api-manager/tsconfig.json new file mode 100644 index 000000000..9c2855604 --- /dev/null +++ b/packages/stack/process-logs-api-manager/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-process-logs-api-manager.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/stack/proxy/package.json b/packages/stack/proxy/package.json index e3143e8dd..43b5f6519 100644 --- a/packages/stack/proxy/package.json +++ b/packages/stack/proxy/package.json @@ -25,27 +25,30 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "npm-run-all lint:*", "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", - "qa": "npm-run-all lint typecheck _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", - "solo": "embark-solo", - "typecheck": "tsc", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "solo": "embark-solo" }, "eslintConfig": { "extends": "../../../.eslintrc.json" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", + "@types/cors": "2.8.6", + "@types/express": "4.17.1", + "@types/express-ws": "3.0.0", "core-js": "3.4.3", "cors": "2.8.5", "embark-core": "^5.0.0-alpha.4", @@ -58,15 +61,12 @@ "web3-providers-ws": "1.2.1" }, "devDependencies": { - "@types/cors": "2.8.6", - "@types/express": "4.17.1", - "@types/express-ws": "3.0.0", "embark-solo": "^5.0.0-alpha.2", "eslint": "5.7.0", "npm-run-all": "4.1.5", "rimraf": "3.0.0", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/stack/proxy/src/index.ts b/packages/stack/proxy/src/index.ts index e1769c564..44591a58d 100644 --- a/packages/stack/proxy/src/index.ts +++ b/packages/stack/proxy/src/index.ts @@ -1,14 +1,15 @@ -import { Embark, Events } /* supplied by @types/embark in packages/embark-typings */ from "embark"; +import { Embark, EmbarkEvents } from "embark-core"; import { __ } from "embark-i18n"; +import { Logger } from "embark-logger"; import { buildUrl, findNextPort } from "embark-utils"; -import { Logger } from 'embark-logger'; + import { Proxy } from "./proxy"; const constants = require("embark-core/constants"); export default class ProxyManager { private readonly logger: Logger; - private readonly events: Events; + private readonly events: EmbarkEvents; private wsProxy: any; private httpProxy: any; private plugins: any; diff --git a/packages/stack/proxy/tsconfig.json b/packages/stack/proxy/tsconfig.json index 1ffac409c..c62839ba0 100644 --- a/packages/stack/proxy/tsconfig.json +++ b/packages/stack/proxy/tsconfig.json @@ -1,5 +1,26 @@ { - "compilerOptions": { "baseUrl": ".", "paths": { "*": ["types/*"] } }, - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-proxy.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/logger" + }, + { + "path": "../../core/utils" + } + ] } diff --git a/packages/stack/storage/package.json b/packages/stack/storage/package.json index 1b7220a1e..3b50093b7 100644 --- a/packages/stack/storage/package.json +++ b/packages/stack/storage/package.json @@ -27,15 +27,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint processes.js src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/stack/storage/tsconfig.json b/packages/stack/storage/tsconfig.json new file mode 100644 index 000000000..6d1cdaf48 --- /dev/null +++ b/packages/stack/storage/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-storage.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/core" + }, + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/stack/test-runner/package.json b/packages/stack/test-runner/package.json index a10659a83..377b9d471 100644 --- a/packages/stack/test-runner/package.json +++ b/packages/stack/test-runner/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/lib/index.js", + "types": "./dist/lib/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf .nyc_output dist embark-*.tgz package", "solo": "embark-solo", "test": "nyc --reporter=html --reporter=json mocha \"dist/test/**/*.js\" --exit --no-timeouts --require source-map-support/register" @@ -49,6 +52,7 @@ "async": "2.6.1", "chalk": "2.4.2", "core-js": "3.4.3", + "deep-equal": "1.0.1", "embark-i18n": "^5.0.0-alpha.2", "embark-testing": "^5.0.0-alpha.4", "embark-utils": "^5.0.0-alpha.4", diff --git a/packages/stack/test-runner/tsconfig.json b/packages/stack/test-runner/tsconfig.json new file mode 100644 index 000000000..d3608dac8 --- /dev/null +++ b/packages/stack/test-runner/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-test-runner.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/lib/**/*" + ], + "references": [ + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + }, + { + "path": "../../utils/testing" + } + ] +} diff --git a/packages/stack/watcher/package.json b/packages/stack/watcher/package.json index 092b6891c..c515622a4 100644 --- a/packages/stack/watcher/package.json +++ b/packages/stack/watcher/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/stack/watcher/tsconfig.json b/packages/stack/watcher/tsconfig.json new file mode 100644 index 000000000..e941407e5 --- /dev/null +++ b/packages/stack/watcher/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-watcher.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/stack/webserver/package.json b/packages/stack/webserver/package.json index 10c756b89..737024860 100644 --- a/packages/stack/webserver/package.json +++ b/packages/stack/webserver/package.json @@ -25,15 +25,18 @@ "url": "https://github.com/embark-framework/embark.git" }, "main": "./dist/index.js", + "types": "./dist/index.d.ts", "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "ci": "npm run qa", "clean": "npm run reset", "lint": "eslint src/", - "qa": "npm-run-all lint _build", + "qa": "npm-run-all lint _typecheck _build", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo" }, diff --git a/packages/stack/webserver/tsconfig.json b/packages/stack/webserver/tsconfig.json new file mode 100644 index 000000000..66ff5944e --- /dev/null +++ b/packages/stack/webserver/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-webserver.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/**/*" + ], + "references": [ + { + "path": "../../core/i18n" + }, + { + "path": "../../core/utils" + } + ] +} diff --git a/packages/utils/collective/index.js b/packages/utils/collective/index.js index 0c72b514d..cb03ab8ea 100644 --- a/packages/utils/collective/index.js +++ b/packages/utils/collective/index.js @@ -3,14 +3,20 @@ const filterPackages = require('@lerna/filter-packages'); const {fork, spawn} = require('child_process'); const {sync: findUp} = require('find-up'); -const {readJsonSync} = require('fs-extra'); +const {existsSync, readJsonSync, writeJsonSync} = require('fs-extra'); const {sync: glob} = require('glob'); +const isEqual = require('lodash.isequal'); +const isPlainObject = require('lodash.isplainobject'); +const mergeWith = require('lodash.mergewith'); const minimist = require('minimist'); -const {dirname, join, normalize, relative} = require('path'); -const { Transform } = require('stream'); +const {basename, dirname, join, normalize, relative} = require('path'); +const sortKeys = require('sort-keys'); +const {Transform} = require('stream'); + +const EMBARK_COLLECTIVE = 'embark-collective'; module.exports = function (cliArgs = []) { - const {action, exclude, include, showPrivate} = processArgs(cliArgs); + const {action, exclude, include, showPrivate, solo} = processArgs(cliArgs); const allPackages = findAllMonorepoPackages(); const allPkgJsons = allPackages.map(path => readJsonSync(path)); @@ -20,7 +26,7 @@ module.exports = function (cliArgs = []) { {action, exclude, include, showPrivate} ); - const pkgJsonDict = makePkgJsonDict( + const {allPkgJsonDict, filteredPkgJsonDict} = makePkgJsonDict( allPackages, allPkgJsons, filteredPkgJsons @@ -28,10 +34,13 @@ module.exports = function (cliArgs = []) { switch (action) { case 'build:browser': - buildBrowser(cliArgs.slice(1), pkgJsonDict); + buildBrowser(cliArgs.slice(1), filteredPkgJsonDict); break; case 'build:node': - buildNode(cliArgs.slice(1), pkgJsonDict); + buildNode(cliArgs.slice(1), filteredPkgJsonDict); + break; + case 'typecheck': + typecheck(cliArgs.slice(1), filteredPkgJsonDict, allPkgJsonDict, solo); break; default: throw new Error(`no implementation for ${action} action`); @@ -46,8 +55,6 @@ function processArgs(cliArgs) { options = {}; } - const solo = !!process.env.EMBARK_SOLO; - const args = minimist(cliArgs); Object.keys(args).forEach(key => { @@ -71,8 +78,9 @@ function processArgs(cliArgs) { const {_: [action], ignore: exclude, [np]: noPrivate, scope: include} = args; const showPrivate = !noPrivate; + const solo = !!process.env.EMBARK_SOLO; - return {action, exclude, include, showPrivate}; + return {action, exclude, include, showPrivate, solo}; } let _monorepoRootPath = null; @@ -103,14 +111,13 @@ function findAllMonorepoPackages() { } function filterPkgJsons(pkgJsons, {action, exclude, include, showPrivate}) { - const embarkCollective = 'embark-collective'; return filterPackages( pkgJsons, include, exclude, showPrivate ).filter(pkgJson => ( - pkgJson && pkgJson[embarkCollective] && pkgJson[embarkCollective][action] && + pkgJson && pkgJson[EMBARK_COLLECTIVE] && pkgJson[EMBARK_COLLECTIVE][action] && !(pkgJson.scripts && pkgJson.scripts[action]) )); } @@ -119,15 +126,17 @@ function makePkgJsonDict(allPackages, allPkgJsons, filteredPkgJsons) { const allPkgJsonDict = {}; const filteredPkgJsonDict = {}; - allPkgJsons.forEach(({name}, index) => { - allPkgJsonDict[name] = allPackages[index]; + allPkgJsons.forEach((pkgJson, index) => { + const {name} = pkgJson; + pkgJson._path = allPackages[index]; + allPkgJsonDict[name] = pkgJson; }); filteredPkgJsons.forEach(({name}) => { filteredPkgJsonDict[name] = allPkgJsonDict[name]; }); - return filteredPkgJsonDict; + return {allPkgJsonDict, filteredPkgJsonDict}; } function labeler(label) { @@ -143,21 +152,18 @@ function labeler(label) { function build(babelEnv, outDir, cliArgs, pkgJsonDict) { const rootPath = monorepoRootPath(); - const babelCmd = process.platform === 'win32' ? 'babel.cmd': 'babel'; const babelBinPath = join(__dirname, 'node_modules', '.bin', babelCmd); const babelConfigPath = join(rootPath, 'babel.config.js'); const sources = Object.values(pkgJsonDict).map( - path => relative(rootPath, join(dirname(path), 'src')) + ({_path}) => relative(rootPath, join(dirname(_path), 'src')) ); if (!sources.length) { return; } - process.chdir(rootPath); - const subp = spawn(babelBinPath, [ ...sources, '--config-file', @@ -170,15 +176,19 @@ function build(babelEnv, outDir, cliArgs, pkgJsonDict) { '--source-maps', ...cliArgs ], { + cwd: rootPath, env: { ...process.env, - BABEL_ENV: babelEnv + BABEL_ENV: babelEnv, + FORCE_COLOR: '1' }, stdio: ['inherit', 'pipe', 'pipe'] }); subp.stdout.pipe(labeler(`build:${babelEnv}`)).pipe(process.stdout); subp.stderr.pipe(labeler(`build:${babelEnv}`)).pipe(process.stderr); + + subp.on('close', code => process.exit(code)); } function buildBrowser(cliArgs, pkgJsonDict) { @@ -189,6 +199,241 @@ function buildNode(cliArgs, pkgJsonDict) { build('node', 'dist', cliArgs, pkgJsonDict); } +function typecheck(cliArgs, filteredPkgJsonDict, allPkgJsonDict, solo) { + let doClean = cliArgs.indexOf('--clean'); + if (doClean > -1) { + cliArgs.splice(doClean, 1); + doClean = true; + } else { + doClean = false; + } + + const rootPath = monorepoRootPath(); + const rootTsConfigPath = join(rootPath, 'tsconfig.json'); + const baseTsConfigPath = join(rootPath, 'tsconfig.base.json'); + const collectiveTsConfigPath = join(rootPath, '.tsconfig.collective.json'); + const typecheckCmd = process.platform === 'win32' ? 'tsc.cmd': 'tsc'; + const typecheckBinPath = join(__dirname, 'node_modules', '.bin', typecheckCmd); + + const allPkgNames = new Set(Object.keys(allPkgJsonDict)); + const seen = {}; + + const collectiveTsConfig = { + files: [], + references: [] + }; + + Object.values(filteredPkgJsonDict).forEach(pkgJson => { + const packages = [pkgJson]; + for (const _pkgJson of packages) { + if (seen[_pkgJson.name]) continue; + seen[_pkgJson.name] = true; + const pkgTsConfig = { + compilerOptions: { + composite: true, + declarationDir: './dist', + tsBuildInfoFile: `./node_modules/.cache/tsc/tsconfig.${_pkgJson.name}.tsbuildinfo` + }, + extends: relative( + dirname(_pkgJson._path), + baseTsConfigPath + ).replace(/\\/g, '/'), + include: [] + }; + + pkgTsConfig.compilerOptions.rootDir = './src'; + if (basename(dirname(_pkgJson.main)) === 'lib' || + basename(dirname(dirname(_pkgJson.main))) === 'lib') { + pkgTsConfig.include.push('src/lib/**/*'); + } else { + pkgTsConfig.include.push('src/**/*'); + } + + let refs; + for (const pkgName of [...new Set([ + ...Object.keys(_pkgJson.dependencies), + ...Object.keys(_pkgJson.devDependencies) + ])].filter(n => n !== 'embark-solo')) { + if (allPkgNames.has(pkgName)) { + if (!refs) { + refs = true; + pkgTsConfig.references = []; + } + + const depPkgJson = allPkgJsonDict[pkgName]; + const depPkgJsonTsConfig = (depPkgJson[EMBARK_COLLECTIVE] && + depPkgJson[EMBARK_COLLECTIVE].typecheck); + + if (depPkgJsonTsConfig) { + pkgTsConfig.references.push({ + path: relative( + dirname(_pkgJson._path), + dirname(depPkgJson._path) + ).replace(/\\/g, '/') + }); + + if (!seen[pkgName]) { + packages.push(depPkgJson); + } + } + } + } + + if (pkgTsConfig.references) { + pkgTsConfig.references.sort(refPathSort); + } + + const _pkgJsonTsConfig = _pkgJson[EMBARK_COLLECTIVE].typecheck; + + if (isPlainObject(_pkgJsonTsConfig)) { + mergeWith(pkgTsConfig, _pkgJsonTsConfig, (_objValue, srcValue, key) => { + // cf. https://www.typescriptlang.org/docs/handbook/tsconfig-json.html + if (['exclude', 'files', 'include'].includes(key)) { + return srcValue; + } + return undefined; + }); + } + + const pkgTsConfigPath = join(dirname(_pkgJson._path), 'tsconfig.json'); + + if (!existsSync(pkgTsConfigPath) || + !isEqual(pkgTsConfig, readJsonSync(pkgTsConfigPath))) { + writeJsonSync( + pkgTsConfigPath, + sortKeys(pkgTsConfig, {deep: true}), + {spaces: 2} + ); + } + } + }); + + const rootTsConfig = { + files: [], + references: [] + }; + + Object.values(allPkgJsonDict).forEach(pkgJson => { + if (pkgJson[EMBARK_COLLECTIVE] && pkgJson[EMBARK_COLLECTIVE].typecheck) { + rootTsConfig.references.push({ + path: relative(rootPath, dirname(pkgJson._path)).replace(/\\/g, '/') + }); + } + }); + + rootTsConfig.references.sort(refPathSort); + + if (!existsSync(rootTsConfigPath) || + !isEqual(rootTsConfig, readJsonSync(rootTsConfigPath))) { + writeJsonSync( + rootTsConfigPath, + sortKeys(rootTsConfig, {deep: true}), + {spaces: 2} + ); + } + + if (solo) { + const packagePath = dirname(Object.values(filteredPkgJsonDict)[0]._path); + + const doSolo = () => { + const subp = spawn(typecheckBinPath, [ + '--build', + '--pretty', + ...cliArgs + ], { + cwd: packagePath, + stdio: 'inherit' + }); + + subp.on('close', code => process.exit(code)); + }; + + if (doClean) { + const subp = spawn(typecheckBinPath, [ + '--build', + '--clean' + ], { + cwd: packagePath, + stdio: 'inherit' + }); + + subp.on('close', code => { + if (code) process.exit(code); + doSolo(); + }); + } else { + doSolo(); + } + } else { + Object.values(filteredPkgJsonDict).forEach(pkgJson => { + if (pkgJson[EMBARK_COLLECTIVE] && pkgJson[EMBARK_COLLECTIVE].typecheck) { + collectiveTsConfig.references.push({ + path: relative(rootPath, dirname(pkgJson._path)).replace(/\\/g, '/') + }); + } + }); + + collectiveTsConfig.references.sort(refPathSort); + + if (!existsSync(collectiveTsConfigPath) || + !isEqual(collectiveTsConfig, readJsonSync(collectiveTsConfigPath))) { + writeJsonSync( + collectiveTsConfigPath, + sortKeys(collectiveTsConfig, {deep: true}), + {spaces: 2} + ); + } + + const doCollective = () => { + const subp = spawn(typecheckBinPath, [ + '--build', + collectiveTsConfigPath, + '--pretty', + ...cliArgs + ], { + cwd: rootPath, + stdio: ['inherit', 'pipe', 'pipe'] + }); + + subp.stdout.pipe(labeler('typecheck')).pipe(process.stdout); + subp.stderr.pipe(labeler('typecheck')).pipe(process.stderr); + + subp.on('close', code => process.exit(code)); + }; + + if (doClean) { + const subp = spawn(typecheckBinPath, [ + '--build', + collectiveTsConfigPath, + '--clean' + ], { + cwd: rootPath, + stdio: ['inherit', 'pipe', 'pipe'] + }); + + subp.stdout.pipe(labeler('typecheck')).pipe(process.stdout); + subp.stderr.pipe(labeler('typecheck')).pipe(process.stderr); + + subp.on('close', code => { + if (code) process.exit(code); + doCollective(); + }); + } else { + doCollective(); + } + } +} + +function refPathSort({path: pathA}, {path: pathB}) { + if (pathA < pathB) { + return -1; + } else if (pathA > pathB) { + return 1; + } else { + return 0; + } +} + const embarkInsidePkg = 'embark-inside-monorepo'; try { require.resolve(embarkInsidePkg, {paths: [__dirname]}); diff --git a/packages/utils/collective/package.json b/packages/utils/collective/package.json index cd6590162..2e4b0eca1 100644 --- a/packages/utils/collective/package.json +++ b/packages/utils/collective/package.json @@ -22,22 +22,23 @@ "build:node:watch": "node bin/collective build:node --verbose --watch", "build:watch": "run-p build:node:watch build:browser:watch", "// ci": "npm run qa", - "// clean": "node bin/collective reset", + "clean": "npm run reset", "// lint": "node bin/collective lint", "// lint:fix": "npm run lint -- --fix", "// qa": "run-s typecheck lint test build", - "// reset": "node bin/collective reset", + "// reset": "node bin/collective reset && npx rimraf embark-*.tgz package", + "reset": "npx rimraf embark-*.tgz package", "start": "npm run watch", "// start:fix": "npm run watch+fix", "// test": "node bin/collective test", - "// typecheck": "node bin/collective typecheck", + "typecheck": "node bin/collective typecheck", "watch": "run-p watch:*", "// watch+fix": "run-p watch:build watch:lint:fix watch:test watch:typecheck", "watch:build": "npm run build:watch", "// watch:lint": "npm run lint -- --watch", "// watch:lint:fix": "npm run lint -- --fix --watch", "// watch:test": "npm run test -- --watch", - "// watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" }, "devDependencies": { "@babel/cli": "7.7.4", @@ -60,8 +61,14 @@ "fs-extra": "8.1.0", "glob": "7.1.4", "lodash.clonedeep": "4.5.0", + "lodash.isequal": "4.5.0", + "lodash.isplainobject": "4.0.6", + "lodash.mergewith": "4.6.2", "minimist": "1.2.0", - "npm-run-all": "4.1.5" + "npm-run-all": "4.1.5", + "rimraf": "3.0.0", + "sort-keys": "4.0.0", + "typescript": "3.7.2" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/utils/inside-monorepo/package.json b/packages/utils/inside-monorepo/package.json index c7263be6a..1656e3005 100644 --- a/packages/utils/inside-monorepo/package.json +++ b/packages/utils/inside-monorepo/package.json @@ -6,7 +6,13 @@ "description": "If a package from the monorepo can resolve this package then the first package is inside the monorepo", "license": "MIT", "main": "index.js", - "scripts": {}, + "scripts": { + "clean": "npm run reset", + "reset": "npx rimraf embark-*.tgz package" + }, + "devDependencies": { + "rimraf": "3.0.0" + }, "engines": { "node": ">=10.17.0 <12.0.0", "npm": ">=6.11.3", diff --git a/packages/utils/solo/index.js b/packages/utils/solo/index.js index 28eddca4d..26922cf8a 100644 --- a/packages/utils/solo/index.js +++ b/packages/utils/solo/index.js @@ -25,6 +25,14 @@ module.exports = function (cliArgs) { ); const npmCmd = process.platform === 'win32' ? 'npm.cmd': 'npm'; - process.chdir(embarkCollectivePath); - spawn(npmCmd, ['run', '--', ...cliArgs], {stdio: 'inherit'}); + const subp = spawn(npmCmd, [ + 'run', + '--', + ...cliArgs + ], { + cwd: embarkCollectivePath, + stdio: 'inherit' + }); + + subp.on('close', code => process.exit(code)); }; diff --git a/packages/utils/solo/package.json b/packages/utils/solo/package.json index 754f375ed..902fb1da3 100644 --- a/packages/utils/solo/package.json +++ b/packages/utils/solo/package.json @@ -8,11 +8,15 @@ "bin": "./bin/solo", "main": "index.js", "files": [], - "scripts": {}, + "scripts": { + "clean": "npm run reset", + "reset": "npx rimraf embark-*.tgz package" + }, "devDependencies": { "embark-collective": "^5.0.0-alpha.2", "find-up": "4.1.0", - "fs-extra": "8.1.0" + "fs-extra": "8.1.0", + "rimraf": "3.0.0" }, "engines": { "node": ">=10.17.0 <12.0.0", diff --git a/packages/utils/testing/package.json b/packages/utils/testing/package.json index 89a4d82b0..393f4e1e2 100644 --- a/packages/utils/testing/package.json +++ b/packages/utils/testing/package.json @@ -4,6 +4,7 @@ "description": "Testing", "homepage": "https://github.com/embark-framework/embark/tree/master/packages/utils/testing#readme", "main": "dist/lib/index.js", + "types": "./dist/lib/index.d.ts", "repository": { "directory": "packages/utils/testing", "type": "git", @@ -25,28 +26,28 @@ "dist" ], "embark-collective": { - "build:node": true + "build:node": true, + "typecheck": true }, "scripts": { "_build": "npm run solo -- build", + "_typecheck": "npm run solo -- typecheck", "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\"", - "qa": "npm-run-all lint typecheck _build test", + "qa": "npm-run-all lint _typecheck _build test", "reset": "npx rimraf dist embark-*.tgz package", "solo": "embark-solo", - "typecheck": "tsc", - "test": "jest", - "watch": "run-p watch:*", - "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + "test": "jest" }, "eslintConfig": { "extends": "../../../.eslintrc.json" }, "dependencies": { "@babel/runtime-corejs3": "7.7.4", + "@types/async": "3.0.3", "async": "2.6.1", "core-js": "3.4.3", "refute": "1.0.2", @@ -54,7 +55,6 @@ }, "devDependencies": { "@babel/core": "7.7.4", - "@types/async": "3.0.3", "babel-jest": "24.9.0", "embark-solo": "^5.0.0-alpha.2", "eslint": "5.7.0", @@ -62,8 +62,8 @@ "lodash.clonedeep": "4.5.0", "npm-run-all": "4.1.5", "rimraf": "2.6.3", - "tslint": "5.16.0", - "typescript": "3.6.3" + "tslint": "5.20.1", + "typescript": "3.7.2" }, "jest": { "collectCoverage": true, diff --git a/packages/utils/testing/tsconfig.json b/packages/utils/testing/tsconfig.json index 1bb65da9e..0559c743a 100644 --- a/packages/utils/testing/tsconfig.json +++ b/packages/utils/testing/tsconfig.json @@ -1,4 +1,12 @@ { - "extends": "../../../tsconfig.json", - "include": ["src/**/*"] + "compilerOptions": { + "composite": true, + "declarationDir": "./dist", + "rootDir": "./src", + "tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-testing.tsbuildinfo" + }, + "extends": "../../../tsconfig.base.json", + "include": [ + "src/lib/**/*" + ] } diff --git a/scripts/monorun.js b/scripts/monorun.js index 3e4e0d07a..9020aa52d 100644 --- a/scripts/monorun.js +++ b/scripts/monorun.js @@ -46,5 +46,13 @@ if (cliArgs.includes('--scope')) { } const npxCmd = process.platform === 'win32' ? 'npx.cmd': 'npx'; -process.chdir(monorepoRootPath); -spawn(npxCmd, ['lerna', 'run', ...cliArgs], {stdio: 'inherit'}); +const subp = spawn(npxCmd, [ + 'lerna', + 'run', + ...cliArgs +], { + cwd: monorepoRootPath, + stdio: 'inherit' +}); + +subp.on('close', code => process.exit(code)); diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 000000000..f5e10fc7c --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "allowJs": true, + // "checkJs": true, + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "esModuleInterop": true, + "isolatedModules": true, + "moduleResolution": "Node", + "noImplicitAny": false, + "noImplicitThis": false, + "resolveJsonModule": true, + "strict": true, + "target": "ESNext" + } +} diff --git a/tsconfig.json b/tsconfig.json index bebff6eb9..d612c1d65 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,14 +1,197 @@ { - "compilerOptions": { - "allowJs": true, - "esModuleInterop": true, - "lib": ["ES2017", "dom"], - "module": "CommonJS", - "noEmit": true, - "noImplicitThis": false, - "noImplicitAny": false, - "strict": true, - "target": "ES2017", - "resolveJsonModule": true - } + "files": [], + "references": [ + { + "path": "packages/cockpit/api-client" + }, + { + "path": "packages/core/code-runner" + }, + { + "path": "packages/core/console" + }, + { + "path": "packages/core/core" + }, + { + "path": "packages/core/engine" + }, + { + "path": "packages/core/i18n" + }, + { + "path": "packages/core/logger" + }, + { + "path": "packages/core/reset" + }, + { + "path": "packages/core/utils" + }, + { + "path": "packages/embark" + }, + { + "path": "packages/embarkjs/embarkjs" + }, + { + "path": "packages/embarkjs/ens" + }, + { + "path": "packages/embarkjs/ipfs" + }, + { + "path": "packages/embarkjs/swarm" + }, + { + "path": "packages/embarkjs/web3" + }, + { + "path": "packages/embarkjs/whisper" + }, + { + "path": "packages/plugins/accounts-manager" + }, + { + "path": "packages/plugins/basic-pipeline" + }, + { + "path": "packages/plugins/coverage" + }, + { + "path": "packages/plugins/debugger" + }, + { + "path": "packages/plugins/deploy-tracker" + }, + { + "path": "packages/plugins/ens" + }, + { + "path": "packages/plugins/ethereum-blockchain-client" + }, + { + "path": "packages/plugins/ganache" + }, + { + "path": "packages/plugins/geth" + }, + { + "path": "packages/plugins/graph" + }, + { + "path": "packages/plugins/ipfs" + }, + { + "path": "packages/plugins/mocha-tests" + }, + { + "path": "packages/plugins/parity" + }, + { + "path": "packages/plugins/plugin-cmd" + }, + { + "path": "packages/plugins/profiler" + }, + { + "path": "packages/plugins/rpc-manager" + }, + { + "path": "packages/plugins/scaffolding" + }, + { + "path": "packages/plugins/snark" + }, + { + "path": "packages/plugins/solc" + }, + { + "path": "packages/plugins/solidity" + }, + { + "path": "packages/plugins/solidity-tests" + }, + { + "path": "packages/plugins/specialconfigs" + }, + { + "path": "packages/plugins/swarm" + }, + { + "path": "packages/plugins/transaction-logger" + }, + { + "path": "packages/plugins/transaction-tracker" + }, + { + "path": "packages/plugins/vyper" + }, + { + "path": "packages/plugins/web3" + }, + { + "path": "packages/plugins/whisper-geth" + }, + { + "path": "packages/plugins/whisper-parity" + }, + { + "path": "packages/stack/api" + }, + { + "path": "packages/stack/authenticator" + }, + { + "path": "packages/stack/blockchain" + }, + { + "path": "packages/stack/blockchain-client" + }, + { + "path": "packages/stack/communication" + }, + { + "path": "packages/stack/compiler" + }, + { + "path": "packages/stack/contracts-manager" + }, + { + "path": "packages/stack/deployment" + }, + { + "path": "packages/stack/embarkjs" + }, + { + "path": "packages/stack/library-manager" + }, + { + "path": "packages/stack/namesystem" + }, + { + "path": "packages/stack/pipeline" + }, + { + "path": "packages/stack/process-logs-api-manager" + }, + { + "path": "packages/stack/proxy" + }, + { + "path": "packages/stack/storage" + }, + { + "path": "packages/stack/test-runner" + }, + { + "path": "packages/stack/watcher" + }, + { + "path": "packages/stack/webserver" + }, + { + "path": "packages/utils/testing" + } + ] } diff --git a/yarn.lock b/yarn.lock index 02eefc457..d147abd8d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2404,15 +2404,15 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^13.0.0" -"@lerna/add@3.16.2": - version "3.16.2" - resolved "https://registry.yarnpkg.com/@lerna/add/-/add-3.16.2.tgz#90ecc1be7051cfcec75496ce122f656295bd6e94" - integrity sha512-RAAaF8aODPogj2Ge9Wj3uxPFIBGpog9M+HwSuq03ZnkkO831AmasCTJDqV+GEpl1U2DvnhZQEwHpWmTT0uUeEw== +"@lerna/add@3.19.0": + version "3.19.0" + resolved "https://registry.yarnpkg.com/@lerna/add/-/add-3.19.0.tgz#33b6251c669895f842c14f05961432d464166249" + integrity sha512-qzhxPyoczvvT1W0wwCK9I0iJ4B9WR+HzYsusmRuzM3mEhWjowhbuvKEl5BjGYuXc9AvEErM/S0Fm5K0RcuS39Q== dependencies: "@evocateur/pacote" "^9.6.3" - "@lerna/bootstrap" "3.16.2" - "@lerna/command" "3.16.0" - "@lerna/filter-options" "3.16.0" + "@lerna/bootstrap" "3.18.5" + "@lerna/command" "3.18.5" + "@lerna/filter-options" "3.18.4" "@lerna/npm-conf" "3.16.0" "@lerna/validation-error" "3.13.0" dedent "^0.7.0" @@ -2420,31 +2420,22 @@ p-map "^2.1.0" semver "^6.2.0" -"@lerna/batch-packages@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/batch-packages/-/batch-packages-3.16.0.tgz#1c16cb697e7d718177db744cbcbdac4e30253c8c" - integrity sha512-7AdMkANpubY/FKFI01im01tlx6ygOBJ/0JcixMUWoWP/7Ds3SWQF22ID6fbBr38jUWptYLDs2fagtTDL7YUPuA== +"@lerna/bootstrap@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/bootstrap/-/bootstrap-3.18.5.tgz#cc22a750d6b0402e136926e8b214148dfc2e1390" + integrity sha512-9vD/BfCz8YSF2Dx7sHaMVo6Cy33WjLEmoN1yrHgNkHjm7ykWbLHG5wru0f4Y4pvwa0s5Hf76rvT8aJWzGHk9IQ== dependencies: - "@lerna/package-graph" "3.16.0" - npmlog "^4.1.2" - -"@lerna/bootstrap@3.16.2": - version "3.16.2" - resolved "https://registry.yarnpkg.com/@lerna/bootstrap/-/bootstrap-3.16.2.tgz#be268d940221d3c3270656b9b791b492559ad9d8" - integrity sha512-I+gs7eh6rv9Vyd+CwqL7sftRfOOsSzCle8cv/CGlMN7/p7EAVhxEdAw8SYoHIKHzipXszuqqy1Y3opyleD0qdA== - dependencies: - "@lerna/batch-packages" "3.16.0" - "@lerna/command" "3.16.0" - "@lerna/filter-options" "3.16.0" - "@lerna/has-npm-version" "3.16.0" - "@lerna/npm-install" "3.16.0" - "@lerna/package-graph" "3.16.0" + "@lerna/command" "3.18.5" + "@lerna/filter-options" "3.18.4" + "@lerna/has-npm-version" "3.16.5" + "@lerna/npm-install" "3.16.5" + "@lerna/package-graph" "3.18.5" "@lerna/pulse-till-done" "3.13.0" - "@lerna/rimraf-dir" "3.14.2" + "@lerna/rimraf-dir" "3.16.5" "@lerna/run-lifecycle" "3.16.2" - "@lerna/run-parallel-batches" "3.16.0" - "@lerna/symlink-binary" "3.16.2" - "@lerna/symlink-dependencies" "3.16.2" + "@lerna/run-topologically" "3.18.5" + "@lerna/symlink-binary" "3.17.0" + "@lerna/symlink-dependencies" "3.17.0" "@lerna/validation-error" "3.13.0" dedent "^0.7.0" get-port "^4.2.0" @@ -2458,100 +2449,99 @@ read-package-tree "^5.1.6" semver "^6.2.0" -"@lerna/changed@3.16.4": - version "3.16.4" - resolved "https://registry.yarnpkg.com/@lerna/changed/-/changed-3.16.4.tgz#c3e727d01453513140eee32c94b695de577dc955" - integrity sha512-NCD7XkK744T23iW0wqKEgF4R9MYmReUbyHCZKopFnsNpQdqumc3SOIvQUAkKCP6hQJmYvxvOieoVgy/CVDpZ5g== +"@lerna/changed@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/changed/-/changed-3.18.5.tgz#ef2c460f5497b8b4cfac7e5165fe46d7181fcdf5" + integrity sha512-IXS7VZ5VDQUfCsgK56WYxd42luMBxL456cNUf1yBgQ1cy1U2FPVMitIdLN4AcP7bJizdPWeG8yDptf47jN/xVw== dependencies: - "@lerna/collect-updates" "3.16.0" - "@lerna/command" "3.16.0" - "@lerna/listable" "3.16.0" + "@lerna/collect-updates" "3.18.0" + "@lerna/command" "3.18.5" + "@lerna/listable" "3.18.5" "@lerna/output" "3.13.0" - "@lerna/version" "3.16.4" -"@lerna/check-working-tree@3.14.2": - version "3.14.2" - resolved "https://registry.yarnpkg.com/@lerna/check-working-tree/-/check-working-tree-3.14.2.tgz#5ce007722180a69643a8456766ed8a91fc7e9ae1" - integrity sha512-7safqxM/MYoAoxZxulUDtIJIbnBIgo0PB/FHytueG+9VaX7GMnDte2Bt1EKa0dz2sAyQdmQ3Q8ZXpf/6JDjaeg== +"@lerna/check-working-tree@3.16.5": + version "3.16.5" + resolved "https://registry.yarnpkg.com/@lerna/check-working-tree/-/check-working-tree-3.16.5.tgz#b4f8ae61bb4523561dfb9f8f8d874dd46bb44baa" + integrity sha512-xWjVBcuhvB8+UmCSb5tKVLB5OuzSpw96WEhS2uz6hkWVa/Euh1A0/HJwn2cemyK47wUrCQXtczBUiqnq9yX5VQ== dependencies: - "@lerna/collect-uncommitted" "3.14.2" - "@lerna/describe-ref" "3.14.2" + "@lerna/collect-uncommitted" "3.16.5" + "@lerna/describe-ref" "3.16.5" "@lerna/validation-error" "3.13.0" -"@lerna/child-process@3.14.2": - version "3.14.2" - resolved "https://registry.yarnpkg.com/@lerna/child-process/-/child-process-3.14.2.tgz#950240cba83f7dfe25247cfa6c9cebf30b7d94f6" - integrity sha512-xnq+W5yQb6RkwI0p16ZQnrn6HkloH/MWTw4lGE1nKsBLAUbmSU5oTE93W1nrG0X3IMF/xWc9UYvNdUGMWvZZ4w== +"@lerna/child-process@3.16.5": + version "3.16.5" + resolved "https://registry.yarnpkg.com/@lerna/child-process/-/child-process-3.16.5.tgz#38fa3c18064aa4ac0754ad80114776a7b36a69b2" + integrity sha512-vdcI7mzei9ERRV4oO8Y1LHBZ3A5+ampRKg1wq5nutLsUA4mEBN6H7JqjWOMY9xZemv6+kATm2ofjJ3lW5TszQg== dependencies: chalk "^2.3.1" execa "^1.0.0" strong-log-transformer "^2.0.0" -"@lerna/clean@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/clean/-/clean-3.16.0.tgz#1c134334cacea1b1dbeacdc580e8b9240db8efa1" - integrity sha512-5P9U5Y19WmYZr7UAMGXBpY7xCRdlR7zhHy8MAPDKVx70rFIBS6nWXn5n7Kntv74g7Lm1gJ2rsiH5tj1OPcRJgg== +"@lerna/clean@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/clean/-/clean-3.18.5.tgz#44b4a6db68ae369778f2921c85ec6961bdd86072" + integrity sha512-tHxOj9frTIhB/H2gtgMU3xpIc4IJEhXcUlReko6RJt8TTiDZGPDudCcgjg6i7n15v9jXMOc1y4F+y5/1089bfA== dependencies: - "@lerna/command" "3.16.0" - "@lerna/filter-options" "3.16.0" - "@lerna/prompt" "3.13.0" + "@lerna/command" "3.18.5" + "@lerna/filter-options" "3.18.4" + "@lerna/prompt" "3.18.5" "@lerna/pulse-till-done" "3.13.0" - "@lerna/rimraf-dir" "3.14.2" + "@lerna/rimraf-dir" "3.16.5" p-map "^2.1.0" p-map-series "^1.0.0" p-waterfall "^1.0.0" -"@lerna/cli@3.13.0": - version "3.13.0" - resolved "https://registry.yarnpkg.com/@lerna/cli/-/cli-3.13.0.tgz#3d7b357fdd7818423e9681a7b7f2abd106c8a266" - integrity sha512-HgFGlyCZbYaYrjOr3w/EsY18PdvtsTmDfpUQe8HwDjXlPeCCUgliZjXLOVBxSjiOvPeOSwvopwIHKWQmYbwywg== +"@lerna/cli@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/cli/-/cli-3.18.5.tgz#c90c461542fcd35b6d5b015a290fb0dbfb41d242" + integrity sha512-erkbxkj9jfc89vVs/jBLY/fM0I80oLmJkFUV3Q3wk9J3miYhP14zgVEBsPZY68IZlEjT6T3Xlq2xO1AVaatHsA== dependencies: "@lerna/global-options" "3.13.0" dedent "^0.7.0" npmlog "^4.1.2" - yargs "^12.0.1" + yargs "^14.2.2" -"@lerna/collect-uncommitted@3.14.2": - version "3.14.2" - resolved "https://registry.yarnpkg.com/@lerna/collect-uncommitted/-/collect-uncommitted-3.14.2.tgz#b5ed00d800bea26bb0d18404432b051eee8d030e" - integrity sha512-4EkQu4jIOdNL2BMzy/N0ydHB8+Z6syu6xiiKXOoFl0WoWU9H1jEJCX4TH7CmVxXL1+jcs8FIS2pfQz4oew99Eg== +"@lerna/collect-uncommitted@3.16.5": + version "3.16.5" + resolved "https://registry.yarnpkg.com/@lerna/collect-uncommitted/-/collect-uncommitted-3.16.5.tgz#a494d61aac31cdc7aec4bbe52c96550274132e63" + integrity sha512-ZgqnGwpDZiWyzIQVZtQaj9tRizsL4dUOhuOStWgTAw1EMe47cvAY2kL709DzxFhjr6JpJSjXV5rZEAeU3VE0Hg== dependencies: - "@lerna/child-process" "3.14.2" + "@lerna/child-process" "3.16.5" chalk "^2.3.1" figgy-pudding "^3.5.1" npmlog "^4.1.2" -"@lerna/collect-updates@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/collect-updates/-/collect-updates-3.16.0.tgz#6db3ce8a740a4e2b972c033a63bdfb77f2553d8c" - integrity sha512-HwAIl815X2TNlmcp28zCrSdXfoZWNP7GJPEqNWYk7xDJTYLqQ+SrmKUePjb3AMGBwYAraZSEJLbHdBpJ5+cHmQ== +"@lerna/collect-updates@3.18.0": + version "3.18.0" + resolved "https://registry.yarnpkg.com/@lerna/collect-updates/-/collect-updates-3.18.0.tgz#6086c64df3244993cc0a7f8fc0ddd6a0103008a6" + integrity sha512-LJMKgWsE/var1RSvpKDIxS8eJ7POADEc0HM3FQiTpEczhP6aZfv9x3wlDjaHpZm9MxJyQilqxZcasRANmRcNgw== dependencies: - "@lerna/child-process" "3.14.2" - "@lerna/describe-ref" "3.14.2" + "@lerna/child-process" "3.16.5" + "@lerna/describe-ref" "3.16.5" minimatch "^3.0.4" npmlog "^4.1.2" slash "^2.0.0" -"@lerna/command@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/command/-/command-3.16.0.tgz#ba3dba49cb5ce4d11b48269cf95becd86e30773f" - integrity sha512-u7tE4GC4/gfbPA9eQg+0ulnoJ+PMoMqomx033r/IxqZrHtmJR9+pF/37S0fsxJ2hX/RMFPC7c9Q/i8NEufSpdQ== +"@lerna/command@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/command/-/command-3.18.5.tgz#14c6d2454adbfd365f8027201523e6c289cd3cd9" + integrity sha512-36EnqR59yaTU4HrR1C9XDFti2jRx0BgpIUBeWn129LZZB8kAB3ov1/dJNa1KcNRKp91DncoKHLY99FZ6zTNpMQ== dependencies: - "@lerna/child-process" "3.14.2" - "@lerna/package-graph" "3.16.0" - "@lerna/project" "3.16.0" + "@lerna/child-process" "3.16.5" + "@lerna/package-graph" "3.18.5" + "@lerna/project" "3.18.0" "@lerna/validation-error" "3.13.0" "@lerna/write-log-file" "3.13.0" + clone-deep "^4.0.1" dedent "^0.7.0" execa "^1.0.0" is-ci "^2.0.0" - lodash "^4.17.14" npmlog "^4.1.2" -"@lerna/conventional-commits@3.16.4": - version "3.16.4" - resolved "https://registry.yarnpkg.com/@lerna/conventional-commits/-/conventional-commits-3.16.4.tgz#bf464f11b2f6534dad204db00430e1651b346a04" - integrity sha512-QSZJ0bC9n6FVaf+7KDIq5zMv8WnHXnwhyL5jG1Nyh3SgOg9q2uflqh7YsYB+G6FwaRfnPaKosh6obijpYg0llA== +"@lerna/conventional-commits@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/conventional-commits/-/conventional-commits-3.18.5.tgz#08efd2e5b45acfaf3f151a53a3ec7ecade58a7bc" + integrity sha512-qcvXIEJ3qSgalxXnQ7Yxp5H9Ta5TVyai6vEor6AAEHc20WiO7UIdbLDCxBtiiHMdGdpH85dTYlsoYUwsCJu3HQ== dependencies: "@lerna/validation-error" "3.13.0" conventional-changelog-angular "^5.0.3" @@ -2574,14 +2564,14 @@ fs-extra "^8.1.0" npmlog "^4.1.2" -"@lerna/create@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/create/-/create-3.16.0.tgz#4de841ec7d98b29bb19fb7d6ad982e65f7a150e8" - integrity sha512-OZApR1Iz7awutbmj4sAArwhqCyKgcrnw9rH0aWAUrkYWrD1w4TwkvAcYAsfx5GpQGbLQwoXhoyyPwPfZRRWz3Q== +"@lerna/create@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/create/-/create-3.18.5.tgz#11ac539f069248eaf7bc4c42e237784330f4fc47" + integrity sha512-cHpjocbpKmLopCuZFI7cKEM3E/QY8y+yC7VtZ4FQRSaLU8D8i2xXtXmYaP1GOlVNavji0iwoXjuNpnRMInIr2g== dependencies: "@evocateur/pacote" "^9.6.3" - "@lerna/child-process" "3.14.2" - "@lerna/command" "3.16.0" + "@lerna/child-process" "3.16.5" + "@lerna/command" "3.18.5" "@lerna/npm-conf" "3.16.0" "@lerna/validation-error" "3.13.0" camelcase "^5.0.0" @@ -2598,44 +2588,46 @@ validate-npm-package-name "^3.0.0" whatwg-url "^7.0.0" -"@lerna/describe-ref@3.14.2": - version "3.14.2" - resolved "https://registry.yarnpkg.com/@lerna/describe-ref/-/describe-ref-3.14.2.tgz#edc3c973f5ca9728d23358c4f4d3b55a21f65be5" - integrity sha512-qa5pzDRK2oBQXNjyRmRnN7E8a78NMYfQjjlRFB0KNHMsT6mCiL9+8kIS39sSE2NqT8p7xVNo2r2KAS8R/m3CoQ== +"@lerna/describe-ref@3.16.5": + version "3.16.5" + resolved "https://registry.yarnpkg.com/@lerna/describe-ref/-/describe-ref-3.16.5.tgz#a338c25aaed837d3dc70b8a72c447c5c66346ac0" + integrity sha512-c01+4gUF0saOOtDBzbLMFOTJDHTKbDFNErEY6q6i9QaXuzy9LNN62z+Hw4acAAZuJQhrVWncVathcmkkjvSVGw== dependencies: - "@lerna/child-process" "3.14.2" + "@lerna/child-process" "3.16.5" npmlog "^4.1.2" -"@lerna/diff@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/diff/-/diff-3.16.0.tgz#6d09a786f9f5b343a2fdc460eb0be08a05b420aa" - integrity sha512-QUpVs5TPl8vBIne10/vyjUxanQBQQp7Lk3iaB8MnCysKr0O+oy7trWeFVDPEkBTCD177By7yPGyW5Yey1nCBbA== +"@lerna/diff@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/diff/-/diff-3.18.5.tgz#e9e2cb882f84d5b84f0487c612137305f07accbc" + integrity sha512-u90lGs+B8DRA9Z/2xX4YaS3h9X6GbypmGV6ITzx9+1Ga12UWGTVlKaCXBgONMBjzJDzAQOK8qPTwLA57SeBLgA== dependencies: - "@lerna/child-process" "3.14.2" - "@lerna/command" "3.16.0" + "@lerna/child-process" "3.16.5" + "@lerna/command" "3.18.5" "@lerna/validation-error" "3.13.0" npmlog "^4.1.2" -"@lerna/exec@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/exec/-/exec-3.16.0.tgz#2b6c033cee46181b6eede0eb12aad5c2c0181e89" - integrity sha512-mH3O5NXf/O88jBaBBTUf+d56CUkxpg782s3Jxy7HWbVuSUULt3iMRPTh+zEXO5/555etsIVVDDyUR76meklrJA== +"@lerna/exec@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/exec/-/exec-3.18.5.tgz#50f1bd6b8f88f2ec02c0768b8b1d9024feb1a96a" + integrity sha512-Q1nz95MeAxctS9bF+aG8FkjixzqEjRpg6ujtnDW84J42GgxedkPtNcJ2o/MBqLd/mxAlr+fW3UZ6CPC/zgoyCg== dependencies: - "@lerna/child-process" "3.14.2" - "@lerna/command" "3.16.0" - "@lerna/filter-options" "3.16.0" - "@lerna/run-topologically" "3.16.0" + "@lerna/child-process" "3.16.5" + "@lerna/command" "3.18.5" + "@lerna/filter-options" "3.18.4" + "@lerna/run-topologically" "3.18.5" "@lerna/validation-error" "3.13.0" p-map "^2.1.0" -"@lerna/filter-options@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/filter-options/-/filter-options-3.16.0.tgz#b1660b4480c02a5c6efa4d0cd98b9afde4ed0bba" - integrity sha512-InIi1fF8+PxpCwir9bIy+pGxrdE6hvN0enIs1eNGCVS1TTE8osNgiZXa838bMQ1yaEccdcnVX6Z03BNKd56kNg== +"@lerna/filter-options@3.18.4": + version "3.18.4" + resolved "https://registry.yarnpkg.com/@lerna/filter-options/-/filter-options-3.18.4.tgz#f5476a7ee2169abed27ad433222e92103f56f9f1" + integrity sha512-4giVQD6tauRwweO/322LP2gfVDOVrt/xN4khkXyfkJDfcsZziFXq+668otD9KSLL8Ps+To4Fah3XbK0MoNuEvA== dependencies: - "@lerna/collect-updates" "3.16.0" - "@lerna/filter-packages" "3.16.0" + "@lerna/collect-updates" "3.18.0" + "@lerna/filter-packages" "3.18.0" dedent "^0.7.0" + figgy-pudding "^3.5.1" + npmlog "^4.1.2" "@lerna/filter-packages@3.16.0": version "3.16.0" @@ -2646,6 +2638,15 @@ multimatch "^3.0.0" npmlog "^4.1.2" +"@lerna/filter-packages@3.18.0": + version "3.18.0" + resolved "https://registry.yarnpkg.com/@lerna/filter-packages/-/filter-packages-3.18.0.tgz#6a7a376d285208db03a82958cfb8172e179b4e70" + integrity sha512-6/0pMM04bCHNATIOkouuYmPg6KH3VkPCIgTfQmdkPJTullERyEQfNUKikrefjxo1vHOoCACDpy65JYyKiAbdwQ== + dependencies: + "@lerna/validation-error" "3.13.0" + multimatch "^3.0.0" + npmlog "^4.1.2" + "@lerna/get-npm-exec-opts@3.13.0": version "3.13.0" resolved "https://registry.yarnpkg.com/@lerna/get-npm-exec-opts/-/get-npm-exec-opts-3.13.0.tgz#d1b552cb0088199fc3e7e126f914e39a08df9ea5" @@ -2662,12 +2663,12 @@ ssri "^6.0.1" tar "^4.4.8" -"@lerna/github-client@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/github-client/-/github-client-3.16.0.tgz#619874e461641d4f59ab1b3f1a7ba22dba88125d" - integrity sha512-IVJjcKjkYaUEPJsDyAblHGEFFNKCRyMagbIDm14L7Ab94ccN6i4TKOqAFEJn2SJHYvKKBdp3Zj2zNlASOMe3DA== +"@lerna/github-client@3.16.5": + version "3.16.5" + resolved "https://registry.yarnpkg.com/@lerna/github-client/-/github-client-3.16.5.tgz#2eb0235c3bf7a7e5d92d73e09b3761ab21f35c2e" + integrity sha512-rHQdn8Dv/CJrO3VouOP66zAcJzrHsm+wFuZ4uGAai2At2NkgKH+tpNhQy2H1PSC0Ezj9LxvdaHYrUzULqVK5Hw== dependencies: - "@lerna/child-process" "3.14.2" + "@lerna/child-process" "3.16.5" "@octokit/plugin-enterprise-rest" "^3.6.1" "@octokit/rest" "^16.28.4" git-url-parse "^11.1.2" @@ -2687,66 +2688,66 @@ resolved "https://registry.yarnpkg.com/@lerna/global-options/-/global-options-3.13.0.tgz#217662290db06ad9cf2c49d8e3100ee28eaebae1" integrity sha512-SlZvh1gVRRzYLVluz9fryY1nJpZ0FHDGB66U9tFfvnnxmueckRQxLopn3tXj3NU1kc3QANT2I5BsQkOqZ4TEFQ== -"@lerna/has-npm-version@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/has-npm-version/-/has-npm-version-3.16.0.tgz#55764a4ce792f0c8553cf996a17f554b9e843288" - integrity sha512-TIY036dA9J8OyTrZq9J+it2DVKifL65k7hK8HhkUPpitJkw6jwbMObA/8D40LOGgWNPweJWqmlrTbRSwsR7DrQ== +"@lerna/has-npm-version@3.16.5": + version "3.16.5" + resolved "https://registry.yarnpkg.com/@lerna/has-npm-version/-/has-npm-version-3.16.5.tgz#ab83956f211d8923ea6afe9b979b38cc73b15326" + integrity sha512-WL7LycR9bkftyqbYop5rEGJ9sRFIV55tSGmbN1HLrF9idwOCD7CLrT64t235t3t4O5gehDnwKI5h2U3oxTrF8Q== dependencies: - "@lerna/child-process" "3.14.2" + "@lerna/child-process" "3.16.5" semver "^6.2.0" -"@lerna/import@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/import/-/import-3.16.0.tgz#b57cb453f4acfc60f6541fcbba10674055cb179d" - integrity sha512-trsOmGHzw0rL/f8BLNvd+9PjoTkXq2Dt4/V2UCha254hMQaYutbxcYu8iKPxz9x86jSPlH7FpbTkkHXDsoY7Yg== +"@lerna/import@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/import/-/import-3.18.5.tgz#a9c7d8601870729851293c10abd18b3707f7ba5e" + integrity sha512-PH0WVLEgp+ORyNKbGGwUcrueW89K3Iuk/DDCz8mFyG2IG09l/jOF0vzckEyGyz6PO5CMcz4TI1al/qnp3FrahQ== dependencies: - "@lerna/child-process" "3.14.2" - "@lerna/command" "3.16.0" - "@lerna/prompt" "3.13.0" + "@lerna/child-process" "3.16.5" + "@lerna/command" "3.18.5" + "@lerna/prompt" "3.18.5" "@lerna/pulse-till-done" "3.13.0" "@lerna/validation-error" "3.13.0" dedent "^0.7.0" fs-extra "^8.1.0" p-map-series "^1.0.0" -"@lerna/init@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/init/-/init-3.16.0.tgz#31e0d66bbededee603338b487a42674a072b7a7d" - integrity sha512-Ybol/x5xMtBgokx4j7/Y3u0ZmNh0NiSWzBFVaOs2NOJKvuqrWimF67DKVz7yYtTYEjtaMdug64ohFF4jcT/iag== +"@lerna/init@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/init/-/init-3.18.5.tgz#86dd0b2b3290755a96975069b5cb007f775df9f5" + integrity sha512-oCwipWrha98EcJAHm8AGd2YFFLNI7AW9AWi0/LbClj1+XY9ah+uifXIgYGfTk63LbgophDd8936ZEpHMxBsbAg== dependencies: - "@lerna/child-process" "3.14.2" - "@lerna/command" "3.16.0" + "@lerna/child-process" "3.16.5" + "@lerna/command" "3.18.5" fs-extra "^8.1.0" p-map "^2.1.0" write-json-file "^3.2.0" -"@lerna/link@3.16.2": - version "3.16.2" - resolved "https://registry.yarnpkg.com/@lerna/link/-/link-3.16.2.tgz#6c3a5658f6448a64dddca93d9348ac756776f6f6" - integrity sha512-eCPg5Lo8HT525fIivNoYF3vWghO3UgEVFdbsiPmhzwI7IQyZro5HWYzLtywSAdEog5XZpd2Bbn0CsoHWBB3gww== +"@lerna/link@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/link/-/link-3.18.5.tgz#f24347e4f0b71d54575bd37cfa1794bc8ee91b18" + integrity sha512-xTN3vktJpkT7Nqc3QkZRtHO4bT5NvuLMtKNIBDkks0HpGxC9PRyyqwOoCoh1yOGbrWIuDezhfMg3Qow+6I69IQ== dependencies: - "@lerna/command" "3.16.0" - "@lerna/package-graph" "3.16.0" - "@lerna/symlink-dependencies" "3.16.2" + "@lerna/command" "3.18.5" + "@lerna/package-graph" "3.18.5" + "@lerna/symlink-dependencies" "3.17.0" p-map "^2.1.0" slash "^2.0.0" -"@lerna/list@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/list/-/list-3.16.0.tgz#883c00b2baf1e03c93e54391372f67a01b773c2f" - integrity sha512-TkvstoPsgKqqQ0KfRumpsdMXfRSEhdXqOLq519XyI5IRWYxhoqXqfi8gG37UoBPhBNoe64japn5OjphF3rOmQA== +"@lerna/list@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/list/-/list-3.18.5.tgz#58863f17c81e24e2c38018eb8619fc99d7cc5c82" + integrity sha512-qIeomm28C2OCM8TMjEe/chTnQf6XLN54wPVQ6kZy+axMYxANFNt/uhs6GZEmhem7GEVawzkyHSz5ZJPsfH3IFg== dependencies: - "@lerna/command" "3.16.0" - "@lerna/filter-options" "3.16.0" - "@lerna/listable" "3.16.0" + "@lerna/command" "3.18.5" + "@lerna/filter-options" "3.18.4" + "@lerna/listable" "3.18.5" "@lerna/output" "3.13.0" -"@lerna/listable@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/listable/-/listable-3.16.0.tgz#e6dc47a2d5a6295222663486f50e5cffc580f043" - integrity sha512-mtdAT2EEECqrJSDm/aXlOUFr1MRE4p6hppzY//Klp05CogQy6uGaKk+iKG5yyCLaOXFFZvG4HfO11CmoGSDWzw== +"@lerna/listable@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/listable/-/listable-3.18.5.tgz#e82798405b5ed8fc51843c8ef1e7a0e497388a1a" + integrity sha512-Sdr3pVyaEv5A7ZkGGYR7zN+tTl2iDcinryBPvtuv20VJrXBE8wYcOks1edBTcOWsPjCE/rMP4bo1pseyk3UTsg== dependencies: - "@lerna/query-graph" "3.16.0" + "@lerna/query-graph" "3.18.5" chalk "^2.3.1" columnify "^1.5.4" @@ -2768,23 +2769,23 @@ config-chain "^1.1.11" pify "^4.0.1" -"@lerna/npm-dist-tag@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/npm-dist-tag/-/npm-dist-tag-3.16.0.tgz#b2184cee5e1f291277396854820e1117a544b7ee" - integrity sha512-MQrBkqJJB9+eNphuj9w90QPMOs4NQXMuSRk9NqzeFunOmdDopPCV0Q7IThSxEuWnhJ2n3B7G0vWUP7tNMPdqIQ== +"@lerna/npm-dist-tag@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/npm-dist-tag/-/npm-dist-tag-3.18.5.tgz#9ef9abb7c104077b31f6fab22cc73b314d54ac55" + integrity sha512-xw0HDoIG6HreVsJND9/dGls1c+lf6vhu7yJoo56Sz5bvncTloYGLUppIfDHQr4ZvmPCK8rsh0euCVh2giPxzKQ== dependencies: "@evocateur/npm-registry-fetch" "^4.0.0" - "@lerna/otplease" "3.16.0" + "@lerna/otplease" "3.18.5" figgy-pudding "^3.5.1" npm-package-arg "^6.1.0" npmlog "^4.1.2" -"@lerna/npm-install@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/npm-install/-/npm-install-3.16.0.tgz#8ec76a7a13b183bde438fd46296bf7a0d6f86017" - integrity sha512-APUOIilZCzDzce92uLEwzt1r7AEMKT/hWA1ThGJL+PO9Rn8A95Km3o2XZAYG4W0hR+P4O2nSVuKbsjQtz8CjFQ== +"@lerna/npm-install@3.16.5": + version "3.16.5" + resolved "https://registry.yarnpkg.com/@lerna/npm-install/-/npm-install-3.16.5.tgz#d6bfdc16f81285da66515ae47924d6e278d637d3" + integrity sha512-hfiKk8Eku6rB9uApqsalHHTHY+mOrrHeWEs+gtg7+meQZMTS3kzv4oVp5cBZigndQr3knTLjwthT/FX4KvseFg== dependencies: - "@lerna/child-process" "3.14.2" + "@lerna/child-process" "3.16.5" "@lerna/get-npm-exec-opts" "3.13.0" fs-extra "^8.1.0" npm-package-arg "^6.1.0" @@ -2792,13 +2793,13 @@ signal-exit "^3.0.2" write-pkg "^3.1.0" -"@lerna/npm-publish@3.16.2": - version "3.16.2" - resolved "https://registry.yarnpkg.com/@lerna/npm-publish/-/npm-publish-3.16.2.tgz#a850b54739446c4aa766a0ceabfa9283bb0be676" - integrity sha512-tGMb9vfTxP57vUV5svkBQxd5Tzc+imZbu9ZYf8Mtwe0+HYfDjNiiHLIQw7G95w4YRdc5KsCE8sQ0uSj+f2soIg== +"@lerna/npm-publish@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/npm-publish/-/npm-publish-3.18.5.tgz#240e4039959fd9816b49c5b07421e11b5cb000af" + integrity sha512-3etLT9+2L8JAx5F8uf7qp6iAtOLSMj+ZYWY6oUgozPi/uLqU0/gsMsEXh3F0+YVW33q0M61RpduBoAlOOZnaTg== dependencies: "@evocateur/libnpmpublish" "^1.2.2" - "@lerna/otplease" "3.16.0" + "@lerna/otplease" "3.18.5" "@lerna/run-lifecycle" "3.16.2" figgy-pudding "^3.5.1" fs-extra "^8.1.0" @@ -2807,21 +2808,21 @@ pify "^4.0.1" read-package-json "^2.0.13" -"@lerna/npm-run-script@3.14.2": - version "3.14.2" - resolved "https://registry.yarnpkg.com/@lerna/npm-run-script/-/npm-run-script-3.14.2.tgz#8c518ea9d241a641273e77aad6f6fddc16779c3f" - integrity sha512-LbVFv+nvAoRTYLMrJlJ8RiakHXrLslL7Jp/m1R18vYrB8LYWA3ey+nz5Tel2OELzmjUiemAKZsD9h6i+Re5egg== +"@lerna/npm-run-script@3.16.5": + version "3.16.5" + resolved "https://registry.yarnpkg.com/@lerna/npm-run-script/-/npm-run-script-3.16.5.tgz#9c2ec82453a26c0b46edc0bb7c15816c821f5c15" + integrity sha512-1asRi+LjmVn3pMjEdpqKJZFT/3ZNpb+VVeJMwrJaV/3DivdNg7XlPK9LTrORuKU4PSvhdEZvJmSlxCKyDpiXsQ== dependencies: - "@lerna/child-process" "3.14.2" + "@lerna/child-process" "3.16.5" "@lerna/get-npm-exec-opts" "3.13.0" npmlog "^4.1.2" -"@lerna/otplease@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/otplease/-/otplease-3.16.0.tgz#de66aec4f3e835a465d7bea84b58a4ab6590a0fa" - integrity sha512-uqZ15wYOHC+/V0WnD2iTLXARjvx3vNrpiIeyIvVlDB7rWse9mL4egex/QSgZ+lDx1OID7l2kgvcUD9cFpbqB7Q== +"@lerna/otplease@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/otplease/-/otplease-3.18.5.tgz#b77b8e760b40abad9f7658d988f3ea77d4fd0231" + integrity sha512-S+SldXAbcXTEDhzdxYLU0ZBKuYyURP/ND2/dK6IpKgLxQYh/z4ScljPDMyKymmEvgiEJmBsPZAAPfmNPEzxjog== dependencies: - "@lerna/prompt" "3.13.0" + "@lerna/prompt" "3.18.5" figgy-pudding "^3.5.1" "@lerna/output@3.13.0": @@ -2845,10 +2846,10 @@ tar "^4.4.10" temp-write "^3.4.0" -"@lerna/package-graph@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/package-graph/-/package-graph-3.16.0.tgz#909c90fb41e02f2c19387342d2a5eefc36d56836" - integrity sha512-A2mum/gNbv7zCtAwJqoxzqv89As73OQNK2MgSX1SHWya46qoxO9a9Z2c5lOFQ8UFN5ZxqWMfFYXRCz7qzwmFXw== +"@lerna/package-graph@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/package-graph/-/package-graph-3.18.5.tgz#c740e2ea3578d059e551633e950690831b941f6b" + integrity sha512-8QDrR9T+dBegjeLr+n9WZTVxUYUhIUjUgZ0gvNxUBN8S1WB9r6H5Yk56/MVaB64tA3oGAN9IIxX6w0WvTfFudA== dependencies: "@lerna/prerelease-id-from-version" "3.16.0" "@lerna/validation-error" "3.13.0" @@ -2872,10 +2873,10 @@ dependencies: semver "^6.2.0" -"@lerna/project@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/project/-/project-3.16.0.tgz#2469a4e346e623fd922f38f5a12931dfb8f2a946" - integrity sha512-NrKcKK1EqXqhrGvslz6Q36+ZHuK3zlDhGdghRqnxDcHxMPT01NgLcmsnymmQ+gjMljuLRmvKYYCuHrknzX8VrA== +"@lerna/project@3.18.0": + version "3.18.0" + resolved "https://registry.yarnpkg.com/@lerna/project/-/project-3.18.0.tgz#56feee01daeb42c03cbdf0ed8a2a10cbce32f670" + integrity sha512-+LDwvdAp0BurOAWmeHE3uuticsq9hNxBI0+FMHiIai8jrygpJGahaQrBYWpwbshbQyVLeQgx3+YJdW2TbEdFWA== dependencies: "@lerna/package" "3.16.0" "@lerna/validation-error" "3.13.0" @@ -2890,41 +2891,41 @@ resolve-from "^4.0.0" write-json-file "^3.2.0" -"@lerna/prompt@3.13.0": - version "3.13.0" - resolved "https://registry.yarnpkg.com/@lerna/prompt/-/prompt-3.13.0.tgz#53571462bb3f5399cc1ca6d335a411fe093426a5" - integrity sha512-P+lWSFokdyvYpkwC3it9cE0IF2U5yy2mOUbGvvE4iDb9K7TyXGE+7lwtx2thtPvBAfIb7O13POMkv7df03HJeA== +"@lerna/prompt@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/prompt/-/prompt-3.18.5.tgz#628cd545f225887d060491ab95df899cfc5218a1" + integrity sha512-rkKj4nm1twSbBEb69+Em/2jAERK8htUuV8/xSjN0NPC+6UjzAwY52/x9n5cfmpa9lyKf/uItp7chCI7eDmNTKQ== dependencies: inquirer "^6.2.0" npmlog "^4.1.2" -"@lerna/publish@3.16.4": - version "3.16.4" - resolved "https://registry.yarnpkg.com/@lerna/publish/-/publish-3.16.4.tgz#4cd55d8be9943d9a68e316e930a90cda8590500e" - integrity sha512-XZY+gRuF7/v6PDQwl7lvZaGWs8CnX6WIPIu+OCcyFPSL/rdWegdN7HieKBHskgX798qRQc2GrveaY7bNoTKXAw== +"@lerna/publish@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/publish/-/publish-3.18.5.tgz#8cc708d83a4cb7ab1c4cc020a02e7ebc4b6b0b0e" + integrity sha512-ifYqLX6mvw95T8vYRlhT68UC7Al0flQvnf5uF9lDgdrgR5Bs+BTwzk3D+0ctdqMtfooekrV6pqfW0R3gtwRffQ== dependencies: "@evocateur/libnpmaccess" "^3.1.2" "@evocateur/npm-registry-fetch" "^4.0.0" "@evocateur/pacote" "^9.6.3" - "@lerna/check-working-tree" "3.14.2" - "@lerna/child-process" "3.14.2" - "@lerna/collect-updates" "3.16.0" - "@lerna/command" "3.16.0" - "@lerna/describe-ref" "3.14.2" + "@lerna/check-working-tree" "3.16.5" + "@lerna/child-process" "3.16.5" + "@lerna/collect-updates" "3.18.0" + "@lerna/command" "3.18.5" + "@lerna/describe-ref" "3.16.5" "@lerna/log-packed" "3.16.0" "@lerna/npm-conf" "3.16.0" - "@lerna/npm-dist-tag" "3.16.0" - "@lerna/npm-publish" "3.16.2" - "@lerna/otplease" "3.16.0" + "@lerna/npm-dist-tag" "3.18.5" + "@lerna/npm-publish" "3.18.5" + "@lerna/otplease" "3.18.5" "@lerna/output" "3.13.0" "@lerna/pack-directory" "3.16.4" "@lerna/prerelease-id-from-version" "3.16.0" - "@lerna/prompt" "3.13.0" + "@lerna/prompt" "3.18.5" "@lerna/pulse-till-done" "3.13.0" "@lerna/run-lifecycle" "3.16.2" - "@lerna/run-topologically" "3.16.0" + "@lerna/run-topologically" "3.18.5" "@lerna/validation-error" "3.13.0" - "@lerna/version" "3.16.4" + "@lerna/version" "3.18.5" figgy-pudding "^3.5.1" fs-extra "^8.1.0" npm-package-arg "^6.1.0" @@ -2941,12 +2942,12 @@ dependencies: npmlog "^4.1.2" -"@lerna/query-graph@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/query-graph/-/query-graph-3.16.0.tgz#e6a46ebcd9d5b03f018a06eca2b471735353953c" - integrity sha512-p0RO+xmHDO95ChJdWkcy9TNLysLkoDARXeRHzY5U54VCwl3Ot/2q8fMCVlA5UeGXDutEyyByl3URqEpcQCWI7Q== +"@lerna/query-graph@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/query-graph/-/query-graph-3.18.5.tgz#df4830bb5155273003bf35e8dda1c32d0927bd86" + integrity sha512-50Lf4uuMpMWvJ306be3oQDHrWV42nai9gbIVByPBYJuVW8dT8O8pA3EzitNYBUdLL9/qEVbrR0ry1HD7EXwtRA== dependencies: - "@lerna/package-graph" "3.16.0" + "@lerna/package-graph" "3.18.5" figgy-pudding "^3.5.1" "@lerna/resolve-symlink@3.16.0": @@ -2958,12 +2959,12 @@ npmlog "^4.1.2" read-cmd-shim "^1.0.1" -"@lerna/rimraf-dir@3.14.2": - version "3.14.2" - resolved "https://registry.yarnpkg.com/@lerna/rimraf-dir/-/rimraf-dir-3.14.2.tgz#103a49882abd85d42285d05cc76869b89f21ffd2" - integrity sha512-eFNkZsy44Bu9v1Hrj5Zk6omzg8O9h/7W6QYK1TTUHeyrjTEwytaNQlqF0lrTLmEvq55sviV42NC/8P3M2cvq8Q== +"@lerna/rimraf-dir@3.16.5": + version "3.16.5" + resolved "https://registry.yarnpkg.com/@lerna/rimraf-dir/-/rimraf-dir-3.16.5.tgz#04316ab5ffd2909657aaf388ea502cb8c2f20a09" + integrity sha512-bQlKmO0pXUsXoF8lOLknhyQjOZsCc0bosQDoX4lujBXSWxHVTg1VxURtWf2lUjz/ACsJVDfvHZbDm8kyBk5okA== dependencies: - "@lerna/child-process" "3.14.2" + "@lerna/child-process" "3.16.5" npmlog "^4.1.2" path-exists "^3.0.0" rimraf "^2.6.2" @@ -2978,55 +2979,47 @@ npm-lifecycle "^3.1.2" npmlog "^4.1.2" -"@lerna/run-parallel-batches@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/run-parallel-batches/-/run-parallel-batches-3.16.0.tgz#5ace7911a2dd31dfd1e53c61356034e27df0e1fb" - integrity sha512-2J/Nyv+MvogmQEfC7VcS21ifk7w0HVvzo2yOZRPvkCzGRu/rducxtB4RTcr58XCZ8h/Bt1aqQYKExu3c/3GXwg== +"@lerna/run-topologically@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/run-topologically/-/run-topologically-3.18.5.tgz#3cd639da20e967d7672cb88db0f756b92f2fdfc3" + integrity sha512-6N1I+6wf4hLOnPW+XDZqwufyIQ6gqoPfHZFkfWlvTQ+Ue7CuF8qIVQ1Eddw5HKQMkxqN10thKOFfq/9NQZ4NUg== dependencies: - p-map "^2.1.0" - p-map-series "^1.0.0" - -"@lerna/run-topologically@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/run-topologically/-/run-topologically-3.16.0.tgz#39e29cfc628bbc8e736d8e0d0e984997ac01bbf5" - integrity sha512-4Hlpv4zDtKWa5Z0tPkeu0sK+bxZEKgkNESMGmWrUCNfj7xwvAJurcraK8+a2Y0TFYwf0qjSLY/MzX+ZbJA3Cgw== - dependencies: - "@lerna/query-graph" "3.16.0" + "@lerna/query-graph" "3.18.5" figgy-pudding "^3.5.1" p-queue "^4.0.0" -"@lerna/run@3.16.0": - version "3.16.0" - resolved "https://registry.yarnpkg.com/@lerna/run/-/run-3.16.0.tgz#1ea568c6f303e47fa00b3403a457836d40738fd2" - integrity sha512-woTeLlB1OAAz4zzjdI6RyIxSGuxiUPHJZm89E1pDEPoWwtQV6HMdMgrsQd9ATsJ5Ez280HH4bF/LStAlqW8Ufg== +"@lerna/run@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/run/-/run-3.18.5.tgz#09ae809b16445d3621249c24596cf4ae8e250d5d" + integrity sha512-1S0dZccNJO8+gT5ztYE4rHTEnbXVwThHOfDnlVt2KDxl9cbnBALk3xprGLW7lSzJsxegS849hxrAPUh0UorMgw== dependencies: - "@lerna/command" "3.16.0" - "@lerna/filter-options" "3.16.0" - "@lerna/npm-run-script" "3.14.2" + "@lerna/command" "3.18.5" + "@lerna/filter-options" "3.18.4" + "@lerna/npm-run-script" "3.16.5" "@lerna/output" "3.13.0" - "@lerna/run-topologically" "3.16.0" + "@lerna/run-topologically" "3.18.5" "@lerna/timer" "3.13.0" "@lerna/validation-error" "3.13.0" p-map "^2.1.0" -"@lerna/symlink-binary@3.16.2": - version "3.16.2" - resolved "https://registry.yarnpkg.com/@lerna/symlink-binary/-/symlink-binary-3.16.2.tgz#f98a3d9da9e56f1d302dc0d5c2efeb951483ee66" - integrity sha512-kz9XVoFOGSF83gg4gBqH+mG6uxfJfTp8Uy+Cam40CvMiuzfODrGkjuBEFoM/uO2QOAwZvbQDYOBpKUa9ZxHS1Q== +"@lerna/symlink-binary@3.17.0": + version "3.17.0" + resolved "https://registry.yarnpkg.com/@lerna/symlink-binary/-/symlink-binary-3.17.0.tgz#8f8031b309863814883d3f009877f82e38aef45a" + integrity sha512-RLpy9UY6+3nT5J+5jkM5MZyMmjNHxZIZvXLV+Q3MXrf7Eaa1hNqyynyj4RO95fxbS+EZc4XVSk25DGFQbcRNSQ== dependencies: "@lerna/create-symlink" "3.16.2" "@lerna/package" "3.16.0" fs-extra "^8.1.0" p-map "^2.1.0" -"@lerna/symlink-dependencies@3.16.2": - version "3.16.2" - resolved "https://registry.yarnpkg.com/@lerna/symlink-dependencies/-/symlink-dependencies-3.16.2.tgz#91d9909d35897aebd76a03644a00cd03c4128240" - integrity sha512-wnZqGJQ+Jvr1I3inxrkffrFZfmQI7Ta8gySw/UWCy95QtZWF/f5yk8zVIocCAsjzD0wgb3jJE3CFJ9W5iwWk1A== +"@lerna/symlink-dependencies@3.17.0": + version "3.17.0" + resolved "https://registry.yarnpkg.com/@lerna/symlink-dependencies/-/symlink-dependencies-3.17.0.tgz#48d6360e985865a0e56cd8b51b308a526308784a" + integrity sha512-KmjU5YT1bpt6coOmdFueTJ7DFJL4H1w5eF8yAQ2zsGNTtZ+i5SGFBWpb9AQaw168dydc3s4eu0W0Sirda+F59Q== dependencies: "@lerna/create-symlink" "3.16.2" "@lerna/resolve-symlink" "3.16.0" - "@lerna/symlink-binary" "3.16.2" + "@lerna/symlink-binary" "3.17.0" fs-extra "^8.1.0" p-finally "^1.0.0" p-map "^2.1.0" @@ -3044,26 +3037,27 @@ dependencies: npmlog "^4.1.2" -"@lerna/version@3.16.4": - version "3.16.4" - resolved "https://registry.yarnpkg.com/@lerna/version/-/version-3.16.4.tgz#b5cc37f3ad98358d599c6196c30b6efc396d42bf" - integrity sha512-ikhbMeIn5ljCtWTlHDzO4YvTmpGTX1lWFFIZ79Vd1TNyOr+OUuKLo/+p06mCl2WEdZu0W2s5E9oxfAAQbyDxEg== +"@lerna/version@3.18.5": + version "3.18.5" + resolved "https://registry.yarnpkg.com/@lerna/version/-/version-3.18.5.tgz#0c4f0c2f8d23e9c95c2aa77ad9ce5c7ef025fac0" + integrity sha512-eSMxLIDuVxZIq0JZKNih50x1IZuMmViwF59uwOGMx0hHB84N3waE8HXOF9CJXDSjeP6sHB8tS+Y+X5fFpBop2Q== dependencies: - "@lerna/check-working-tree" "3.14.2" - "@lerna/child-process" "3.14.2" - "@lerna/collect-updates" "3.16.0" - "@lerna/command" "3.16.0" - "@lerna/conventional-commits" "3.16.4" - "@lerna/github-client" "3.16.0" + "@lerna/check-working-tree" "3.16.5" + "@lerna/child-process" "3.16.5" + "@lerna/collect-updates" "3.18.0" + "@lerna/command" "3.18.5" + "@lerna/conventional-commits" "3.18.5" + "@lerna/github-client" "3.16.5" "@lerna/gitlab-client" "3.15.0" "@lerna/output" "3.13.0" "@lerna/prerelease-id-from-version" "3.16.0" - "@lerna/prompt" "3.13.0" + "@lerna/prompt" "3.18.5" "@lerna/run-lifecycle" "3.16.2" - "@lerna/run-topologically" "3.16.0" + "@lerna/run-topologically" "3.18.5" "@lerna/validation-error" "3.13.0" chalk "^2.3.1" dedent "^0.7.0" + load-json-file "^5.3.0" minimatch "^3.0.4" npmlog "^4.1.2" p-map "^2.1.0" @@ -3073,6 +3067,7 @@ semver "^6.2.0" slash "^2.0.0" temp-write "^3.4.0" + write-json-file "^3.2.0" "@lerna/write-log-file@3.13.0": version "3.13.0" @@ -3833,6 +3828,11 @@ dependencies: "@types/express" "*" +"@types/deep-equal@1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@types/deep-equal/-/deep-equal-1.0.1.tgz#71cfabb247c22bcc16d536111f50c0ed12476b03" + integrity sha512-mMUu4nWHLBlHtxXY17Fg6+ucS/MnndyOWyOe7MmwkoMYxvfQU2ajtRaEvqSUv+aVkMqH/C0NCI8UoVfRNQ10yg== + "@types/eslint-visitor-keys@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" @@ -3869,13 +3869,6 @@ "@types/express-serve-static-core" "*" "@types/serve-static" "*" -"@types/find-up@4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@types/find-up/-/find-up-4.0.0.tgz#6b74a76670477a23f0793cfaf2dafc86df59723a" - integrity sha512-QlRNKeOPFWKisbNtKVOOGXw3AeLbkw8UmT/EyEGM6brfqpYffKBcch7f1y40NYN9O90aK2+K0xBMDJfOAsg2qg== - dependencies: - find-up "*" - "@types/follow-redirects@1.5.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@types/follow-redirects/-/follow-redirects-1.5.0.tgz#c50084d51be6655ca02ecd887f56e0e0aab192be" @@ -4087,9 +4080,9 @@ integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== "@types/underscore@*": - version "1.9.2" - resolved "https://registry.yarnpkg.com/@types/underscore/-/underscore-1.9.2.tgz#2c4f7743287218f5c2d9a83db3806672aa48530d" - integrity sha512-KgOKTAD+9X+qvZnB5S1+onqKc4E+PZ+T6CM/NA5ohRPLHJXb+yCJMVf8pWOnvuBuKFNUAJW8N97IA6lba6mZGg== + version "1.9.4" + resolved "https://registry.yarnpkg.com/@types/underscore/-/underscore-1.9.4.tgz#22d1a3e6b494608e430221ec085fa0b7ccee7f33" + integrity sha512-CjHWEMECc2/UxOZh0kpiz3lEyX2Px3rQS9HzD20lxMvx571ivOBQKeLnqEjxUY0BMgp6WJWo/pQLRBwMW5v4WQ== "@types/web3@1.0.12": version "1.0.12" @@ -7988,11 +7981,16 @@ diff-sequences@^24.9.0: resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.9.0.tgz#5715d6244e2aa65f48bba0bc972db0b0b11e95b5" integrity sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew== -diff@3.5.0, diff@^3.1.0, diff@^3.2.0, diff@^3.5.0: +diff@3.5.0, diff@^3.1.0, diff@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== +diff@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.1.tgz#0c667cb467ebbb5cea7f14f135cc2dba7780a8ff" + integrity sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q== + diffie-hellman@^5.0.0: version "5.0.3" resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" @@ -10013,14 +10011,6 @@ find-root@^1.0.0, find-root@^1.1.0: resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4" integrity sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng== -find-up@*, find-up@4.1.0, find-up@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== - dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" - find-up@2.1.0, find-up@^2.0.0, find-up@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" @@ -10035,6 +10025,14 @@ find-up@3.0.0, find-up@^3.0.0: dependencies: locate-path "^3.0.0" +find-up@4.1.0, find-up@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" + integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== + dependencies: + locate-path "^5.0.0" + path-exists "^4.0.0" + find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -13357,26 +13355,26 @@ left-pad@^1.3.0: resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.3.0.tgz#5b8a3a7765dfe001261dde915589e782f8c94d1e" integrity sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA== -lerna@3.16.4: - version "3.16.4" - resolved "https://registry.yarnpkg.com/lerna/-/lerna-3.16.4.tgz#158cb4f478b680f46f871d5891f531f3a2cb31ec" - integrity sha512-0HfwXIkqe72lBLZcNO9NMRfylh5Ng1l8tETgYQ260ZdHRbPuaLKE3Wqnd2YYRRkWfwPyEyZO8mZweBR+slVe1A== +lerna@3.19.0: + version "3.19.0" + resolved "https://registry.yarnpkg.com/lerna/-/lerna-3.19.0.tgz#6d53b613eca7da426ab1e97c01ce6fb39754da6c" + integrity sha512-YtMmwEqzWHQCh7Ynk7BvjrZri3EkSeVqTAcwZIqWlv9V/dCfvFPyRqp+2NIjPB5nj1FWXLRH6F05VT/qvzuuOA== dependencies: - "@lerna/add" "3.16.2" - "@lerna/bootstrap" "3.16.2" - "@lerna/changed" "3.16.4" - "@lerna/clean" "3.16.0" - "@lerna/cli" "3.13.0" - "@lerna/create" "3.16.0" - "@lerna/diff" "3.16.0" - "@lerna/exec" "3.16.0" - "@lerna/import" "3.16.0" - "@lerna/init" "3.16.0" - "@lerna/link" "3.16.2" - "@lerna/list" "3.16.0" - "@lerna/publish" "3.16.4" - "@lerna/run" "3.16.0" - "@lerna/version" "3.16.4" + "@lerna/add" "3.19.0" + "@lerna/bootstrap" "3.18.5" + "@lerna/changed" "3.18.5" + "@lerna/clean" "3.18.5" + "@lerna/cli" "3.18.5" + "@lerna/create" "3.18.5" + "@lerna/diff" "3.18.5" + "@lerna/exec" "3.18.5" + "@lerna/import" "3.18.5" + "@lerna/init" "3.18.5" + "@lerna/link" "3.18.5" + "@lerna/list" "3.18.5" + "@lerna/publish" "3.18.5" + "@lerna/run" "3.18.5" + "@lerna/version" "3.18.5" import-local "^2.0.0" npmlog "^4.1.2" @@ -13671,6 +13669,11 @@ lodash.get@^4.4.2: resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= +lodash.isequal@4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" + integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA= + lodash.isfunction@^3.0.9: version "3.0.9" resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz#06de25df4db327ac931981d1bdb067e5af68d051" @@ -13686,11 +13689,21 @@ lodash.isobject@^3.0.2: resolved "https://registry.yarnpkg.com/lodash.isobject/-/lodash.isobject-3.0.2.tgz#3c8fb8d5b5bf4bf90ae06e14f2a530a4ed935e1d" integrity sha1-PI+41bW/S/kK4G4U8qUwpO2TXh0= +lodash.isplainobject@4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" + integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs= + lodash.memoize@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= +lodash.mergewith@4.6.2: + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz#617121f89ac55f59047c7aec1ccd6654c6590f55" + integrity sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ== + lodash.set@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" @@ -19554,6 +19567,13 @@ solidity-parser-antlr@^0.4.4: resolved "https://registry.yarnpkg.com/solidity-parser-antlr/-/solidity-parser-antlr-0.4.11.tgz#af43e1f13b3b88309a875455f5d6e565b05ee5f1" integrity sha512-4jtxasNGmyC0midtjH/lTFPZYvTTUMy6agYcF+HoMnzW8+cqo3piFrINb4ZCzpPW+7tTVFCGa5ubP34zOzeuMg== +sort-keys@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-4.0.0.tgz#56dc5e256637bfe3fec8db0dc57c08b1a2be22d6" + integrity sha512-hlJLzrn/VN49uyNkZ8+9b+0q9DjmmYcYOnbMQtpkLrYpPwRApDPZfmqbUfJnAA3sb/nRib+nDot7Zi/1ER1fuA== + dependencies: + is-plain-obj "^2.0.0" + sort-keys@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad" @@ -20709,18 +20729,18 @@ tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== -tslint@5.16.0: - version "5.16.0" - resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.16.0.tgz#ae61f9c5a98d295b9a4f4553b1b1e831c1984d67" - integrity sha512-UxG2yNxJ5pgGwmMzPMYh/CCnCnh0HfPgtlVRDs1ykZklufFBL1ZoTlWFRz2NQjcoEiDoRp+JyT0lhBbbH/obyA== +tslint@5.20.1: + version "5.20.1" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.20.1.tgz#e401e8aeda0152bc44dd07e614034f3f80c67b7d" + integrity sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg== dependencies: "@babel/code-frame" "^7.0.0" builtin-modules "^1.1.1" chalk "^2.3.0" commander "^2.12.1" - diff "^3.2.0" + diff "^4.0.1" glob "^7.1.1" - js-yaml "^3.13.0" + js-yaml "^3.13.1" minimatch "^3.0.4" mkdirp "^0.5.1" resolve "^1.3.2" @@ -20857,10 +20877,10 @@ typescript-tuple@^2.2.1: dependencies: typescript-compare "^0.0.2" -typescript@3.6.3: - version "3.6.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.3.tgz#fea942fabb20f7e1ca7164ff626f1a9f3f70b4da" - integrity sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw== +typescript@3.7.2: + version "3.7.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb" + integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ== ua-parser-js@^0.7.18, ua-parser-js@^0.7.9: version "0.7.20" @@ -22819,6 +22839,14 @@ yargs-parser@^11.1.1: camelcase "^5.0.0" decamelize "^1.2.0" +yargs-parser@^15.0.0: + version "15.0.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-15.0.0.tgz#cdd7a97490ec836195f59f3f4dbe5ea9e8f75f08" + integrity sha512-xLTUnCMc4JhxrPEPUYD5IBR1mWCK/aT6+RJ/K29JY2y1vD+FhtgKK0AXRWvI262q3QSffAQuTouFIKUuHX89wQ== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + yargs-parser@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-2.4.1.tgz#85568de3cf150ff49fa51825f03a8c880ddcc5c4" @@ -22902,7 +22930,7 @@ yargs@13.3.0, yargs@^13.2.0, yargs@^13.3.0: y18n "^4.0.0" yargs-parser "^13.1.1" -yargs@^12.0.0, yargs@^12.0.1, yargs@^12.0.2, yargs@^12.0.5: +yargs@^12.0.0, yargs@^12.0.2, yargs@^12.0.5: version "12.0.5" resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13" integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw== @@ -22920,6 +22948,23 @@ yargs@^12.0.0, yargs@^12.0.1, yargs@^12.0.2, yargs@^12.0.5: y18n "^3.2.1 || ^4.0.0" yargs-parser "^11.1.1" +yargs@^14.2.2: + version "14.2.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-14.2.2.tgz#2769564379009ff8597cdd38fba09da9b493c4b5" + integrity sha512-/4ld+4VV5RnrynMhPZJ/ZpOCGSCeghMykZ3BhdFBDa9Wy/RH6uEGNWDJog+aUlq+9OM1CFTgtYRW5Is1Po9NOA== + dependencies: + cliui "^5.0.0" + decamelize "^1.2.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^15.0.0" + yargs@^4.7.1: version "4.8.1" resolved "https://registry.yarnpkg.com/yargs/-/yargs-4.8.1.tgz#c0c42924ca4aaa6b0e6da1739dfb216439f9ddc0"