From 8f358c29aa980c4d1aef73e4b8fbec030bf6fd17 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 19 Aug 2019 14:47:32 -0400 Subject: [PATCH] refactor(@embark/console-listener): remove embark-listener and put in console-listener --- packages/embark-console-listener/src/index.js | 7 ++ packages/embark-listener/.npmrc | 4 -- packages/embark-listener/CHANGELOG.md | 40 ----------- packages/embark-listener/README.md | 6 -- packages/embark-listener/package.json | 71 ------------------- packages/embark-listener/src/index.js | 39 ---------- packages/embark-listener/tsconfig.json | 4 -- packages/embark-listener/tslint.json | 3 - packages/embark/package.json | 1 - packages/embark/src/cmd/cmd_controller.js | 3 - packages/embark/src/lib/core/engine.js | 7 +- 11 files changed, 8 insertions(+), 177 deletions(-) delete mode 100644 packages/embark-listener/.npmrc delete mode 100644 packages/embark-listener/CHANGELOG.md delete mode 100644 packages/embark-listener/README.md delete mode 100644 packages/embark-listener/package.json delete mode 100644 packages/embark-listener/src/index.js delete mode 100644 packages/embark-listener/tsconfig.json delete mode 100644 packages/embark-listener/tslint.json diff --git a/packages/embark-console-listener/src/index.js b/packages/embark-console-listener/src/index.js index ec844160a..1e35c2bfe 100644 --- a/packages/embark-console-listener/src/index.js +++ b/packages/embark-console-listener/src/index.js @@ -1,6 +1,9 @@ const async = require('async'); import { __ } from 'embark-i18n'; import { dappPath, getAddressToContract, getTransactionParams, hexToNumber } from 'embark-utils'; +const ProcessLogsApi = require('embark-process-logs-api'); + +const EMBARK_PROCESS_NAME = 'embark'; class ConsoleListener { constructor(embark, options) { @@ -14,6 +17,7 @@ class ConsoleListener { this.contractsDeployed = false; this.outputDone = false; this.logFile = dappPath(".embark", "contractLogs.json"); + this.processLogsApi = new ProcessLogsApi({embark: this.embark, processName: EMBARK_PROCESS_NAME, silent: false}); if (this.ipc.ipcRole === 'server') { this._listenForLogRequests(); @@ -21,6 +25,9 @@ class ConsoleListener { this._registerAPI(); this.events.on("contracts:log", this._saveLog.bind(this)); + this.events.on("log", (logLevel, message) => { + this.processLogsApi.logHandler.handleLog({logLevel, message}, true); + }); this.events.on('outputDone', () => { this.outputDone = true; }); diff --git a/packages/embark-listener/.npmrc b/packages/embark-listener/.npmrc deleted file mode 100644 index e031d3432..000000000 --- a/packages/embark-listener/.npmrc +++ /dev/null @@ -1,4 +0,0 @@ -engine-strict = true -package-lock = false -save-exact = true -scripts-prepend-node-path = true diff --git a/packages/embark-listener/CHANGELOG.md b/packages/embark-listener/CHANGELOG.md deleted file mode 100644 index 69231d4e3..000000000 --- a/packages/embark-listener/CHANGELOG.md +++ /dev/null @@ -1,40 +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. - -# [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) - -**Note:** Version bump only for package embark-listener - - - - - -# [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) - -**Note:** Version bump only for package embark-listener - - - - - -# [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 embark-listener - - - - - -# [4.1.0-beta.2](https://github.com/embark-framework/embark/compare/v4.1.0-beta.1...v4.1.0-beta.2) (2019-05-22) - -**Note:** Version bump only for package embark-listener - - - - - -# [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) - -**Note:** Version bump only for package embark-listener diff --git a/packages/embark-listener/README.md b/packages/embark-listener/README.md deleted file mode 100644 index 4440a3d54..000000000 --- a/packages/embark-listener/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# `embark-listener` - -> Log listening for Embark - -Visit [embark.status.im](https://embark.status.im/) to get started with -[Embark](https://github.com/embark-framework/embark). diff --git a/packages/embark-listener/package.json b/packages/embark-listener/package.json deleted file mode 100644 index 238ae61bb..000000000 --- a/packages/embark-listener/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "embark-listener", - "version": "4.1.0-beta.5", - "author": "Iuri Matias ", - "contributors": [], - "description": "Log listening for Embark", - "homepage": "https://github.com/embark-framework/embark/tree/master/packages/embark-listener#readme", - "bugs": "https://github.com/embark-framework/embark/issues", - "keywords": [ - "blockchain", - "dapps", - "ethereum", - "ipfs", - "serverless", - "solc", - "solidity" - ], - "files": [ - "dist" - ], - "license": "MIT", - "repository": { - "directory": "packages/embark-listener", - "type": "git", - "url": "https://github.com/embark-framework/embark.git" - }, - "main": "./dist/index.js", - "scripts": { - "build": "cross-env BABEL_ENV=node babel src --extensions \".js\" --out-dir dist --root-mode upward --source-maps", - "ci": "npm run qa", - "clean": "npm run reset", - "lint": "npm-run-all lint:*", - "lint:js": "eslint src/", - "// lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", - "package": "npm pack", - "// qa": "npm-run-all lint typecheck build package", - "qa": "npm-run-all lint build package", - "reset": "npx rimraf .nyc_output coverage dist embark-*.tgz package", - "start": "npm run watch", - "// 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:build": "npm run build -- --verbose --watch", - "// watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" - }, - "eslintConfig": { - "extends": "../../.eslintrc.json" - }, - "dependencies": { - "embark-process-logs-api": "^4.1.0-beta.5" - }, - "devDependencies": { - "eslint": "5.7.0", - "mocha": "6.2.0", - "npm-run-all": "4.1.5", - "nyc": "13.1.0", - "rimraf": "2.6.3" - }, - "engines": { - "node": ">=8.12.0 <12.0.0", - "npm": ">=6.4.1", - "yarn": ">=1.12.3" - }, - "nyc": { - "exclude": [ - "**/node_modules/**", - "coverage/**", - "dist/test/**" - ] - } -} diff --git a/packages/embark-listener/src/index.js b/packages/embark-listener/src/index.js deleted file mode 100644 index 839151c3d..000000000 --- a/packages/embark-listener/src/index.js +++ /dev/null @@ -1,39 +0,0 @@ -const ProcessLogsApi = require('embark-process-logs-api'); - -const EMBARK_PROCESS_NAME = 'embark'; - -// TODO: looks unnecessary, should be moved to a common module together with embark-process-logs-api - -/** - * EmbarkListener has two functions: - * 1. Register API endpoints (HTTP GET and WS) to retrieve embark logs. - * 2. Listen to log events in Embark and ensure they are processed - * through the LogHandler. - */ -class EmbarkListener { - - /** - * @param {Plugin} embark EmbarkListener module plugin object - */ - constructor(embark) { - this.embark = embark; - this.events = embark.events; - this.logger = embark.logger; - this.processLogsApi = new ProcessLogsApi({embark: this.embark, processName: EMBARK_PROCESS_NAME, silent: false}); - - this._listenToEmbarkLogs(); - } - - /** - * Listens to log events emitted by the Embark application and ensures - * they are processed through the LogHandler. - * - * @return {void} - */ - _listenToEmbarkLogs() { - this.events.on("log", (logLevel, message) => { - this.processLogsApi.logHandler.handleLog({logLevel, message}, true); - }); - } -} -module.exports = EmbarkListener; diff --git a/packages/embark-listener/tsconfig.json b/packages/embark-listener/tsconfig.json deleted file mode 100644 index 52d43eaaa..000000000 --- a/packages/embark-listener/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["src/**/*"] -} diff --git a/packages/embark-listener/tslint.json b/packages/embark-listener/tslint.json deleted file mode 100644 index 0946f2096..000000000 --- a/packages/embark-listener/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../tslint.json" -} diff --git a/packages/embark/package.json b/packages/embark/package.json index e64685ab0..94081ac1f 100644 --- a/packages/embark/package.json +++ b/packages/embark/package.json @@ -111,7 +111,6 @@ "embark-i18n": "^4.1.0-beta.3", "embark-ipfs": "^4.1.0-beta.5", "embark-library-manager": "^4.1.0-beta.5", - "embark-listener": "^4.1.0-beta.5", "embark-logger": "^4.1.0-beta.5", "embark-pipeline": "^4.1.0-beta.5", "embark-plugin-cmd": "^4.1.0-beta.5", diff --git a/packages/embark/src/cmd/cmd_controller.js b/packages/embark/src/cmd/cmd_controller.js index b9ca057d5..f207e03b5 100644 --- a/packages/embark/src/cmd/cmd_controller.js +++ b/packages/embark/src/cmd/cmd_controller.js @@ -145,9 +145,6 @@ class EmbarkController { async.waterfall([ function initEngine(callback) { engine.init({}, () => { - // TODO: we can hook up this module to the action engine:start instead - // TODO: embark-listener & embark-process-logs-api can probably be merged - // engine.startService("embarkListener"); if (!options.useDashboard) { engine.logger.info('========================'.bold.green); engine.logger.info((__('Welcome to Embark') + ' ' + engine.version).yellow.bold); diff --git a/packages/embark/src/lib/core/engine.js b/packages/embark/src/lib/core/engine.js index 254d992ad..eef2c92fa 100644 --- a/packages/embark/src/lib/core/engine.js +++ b/packages/embark/src/lib/core/engine.js @@ -147,7 +147,6 @@ class Engine { logger: this.logger, config: this.config }); - this.registerModulePackage('embark-listener'); // TODO: we shouldn't need useDashboard @@ -201,6 +200,7 @@ class Engine { // this.registerModule('web3', { plugins: this.plugins }); this.registerModulePackage('embark-web3', {plugins: this.plugins}); this.registerModulePackage('embark-specialconfigs', {plugins: this.plugins}); + this.registerModulePackage('embark-console-listener', {ipc: this.ipc}); } storageComponent() { @@ -243,7 +243,6 @@ class Engine { "coreProcess": this.coreProcessService, "processApi": this.processApiService, "blockchainListener": this.blockchainListenerService, - "embarkListener": this.embarkListenerService, "blockchain": this.blockchainComponents }; @@ -258,10 +257,6 @@ class Engine { return service.apply(this, [options]); } - embarkListenerService(_options){ - this.registerModulePackage('embark-listener'); - } - blockchainListenerService(_options){ this.registerModulePackage('embark-blockchain-listener', { ipc: this.ipc