mirror of https://github.com/embarklabs/embark.git
refactor(@embark/console-listener): remove embark-listener and put in console-listener
This commit is contained in:
parent
5f8653de02
commit
8f358c29aa
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
engine-strict = true
|
||||
package-lock = false
|
||||
save-exact = true
|
||||
scripts-prepend-node-path = true
|
|
@ -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
|
|
@ -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).
|
|
@ -1,71 +0,0 @@
|
|||
{
|
||||
"name": "embark-listener",
|
||||
"version": "4.1.0-beta.5",
|
||||
"author": "Iuri Matias <iuri.matias@gmail.com>",
|
||||
"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/**"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -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;
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["src/**/*"]
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"extends": "../../tslint.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",
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue