refactor(@embark/suggestions): move suggestions API into plugin

This commit is contained in:
Pascal Precht 2020-01-16 13:42:18 +01:00 committed by Pascal Precht
parent 61bf7d5b16
commit a2244019c9
12 changed files with 128 additions and 13 deletions

View File

@ -6,7 +6,6 @@ import { dappPath, escapeHtml, exit, jsonFunctionReplacer } from "embark-utils";
import stringify from "json-stringify-safe";
import { dirname } from "path";
import util from "util";
import Suggestions from "./suggestions";
type MatchFunction = (cmd: string) => boolean;
interface HelpDescription {
@ -26,7 +25,6 @@ export default class Console {
private config: any;
private history: string[];
private cmdHistoryFile: string;
private suggestions?: Suggestions;
// private providerReady: boolean;
private helpCmds: any;
@ -82,8 +80,6 @@ export default class Console {
return;
}
this.registerApi();
this.suggestions = new Suggestions(embark, options);
}
private get isEmbarkConsole() {

View File

@ -84,6 +84,7 @@
"embark-i18n": "^5.1.0-nightly.0",
"embark-logger": "^5.1.0-nightly.0",
"embark-reset": "^5.1.0-nightly.0",
"embark-suggestions": "^5.1.0-nightly.0",
"embark-utils": "^5.1.0-nightly.0",
"eth-ens-namehash": "2.0.8",
"find-up": "2.1.0",

View File

@ -176,6 +176,7 @@ class EmbarkController {
engine.registerModuleGroup("cockpit");
engine.registerModulePackage('embark-deploy-tracker', { plugins: engine.plugins });
engine.registerModulePackage("embark-debugger");
engine.registerModulePackage('embark-suggestions');
// load custom plugins
engine.loadDappPlugins();
@ -391,6 +392,7 @@ class EmbarkController {
}
engine.registerModulePackage('embark-deploy-tracker', { plugins: engine.plugins });
engine.registerModulePackage("embark-debugger");
engine.registerModulePackage('embark-suggestions');
// load custom plugins
engine.loadDappPlugins();

View File

@ -42,6 +42,9 @@
{
"path": "../plugins/solidity"
},
{
"path": "../plugins/suggestions"
},
{
"path": "../plugins/transaction-logger"
},

View File

@ -0,0 +1,7 @@
# `embark-suggestions
> Suggestions plugin for Embark
Visit [embark.status.im](https://embark.status.im/) to get started with
[Embark](https://github.com/embark-framework/embark).

View File

@ -0,0 +1,76 @@
{
"name": "embark-suggestions",
"version": "5.1.0-nightly.0",
"author": "Iuri Matias <iuri.matias@gmail.com>",
"contributors": [],
"description": "Suggestions plugin for Embark",
"homepage": "https://github.com/embark-framework/embark/tree/master/packages/plugins/suggestions#readme",
"bugs": "https://github.com/embark-framework/embark/issues",
"keywords": [],
"files": [
"dist"
],
"license": "MIT",
"repository": {
"directory": "packages/plugins/suggestions",
"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": "npm-run-all lint:*",
"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"
},
"dependencies": {
"@babel/runtime-corejs3": "7.7.4",
"core-js": "3.4.3",
"embark-core": "^5.1.0-nightly.0",
"embark-utils": "^5.1.0-nightly.0",
"fs-extra": "8.1.0"
},
"devDependencies": {
"@babel/core": "7.7.4",
"babel-jest": "24.9.0",
"embark-solo": "^5.1.0-nightly.0",
"embark-testing": "^5.1.0-nightly.0",
"eslint": "5.7.0",
"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"
},
"jest": {
"collectCoverage": true,
"testEnvironment": "node",
"testMatch": [
"**/test/**/*.js"
],
"transform": {
"\\.(js|ts)$": [
"babel-jest",
{
"rootMode": "upward"
}
]
}
}
}

View File

@ -3,7 +3,7 @@ import { fuzzySearch } from "embark-utils";
import { readJsonSync } from "fs-extra";
import { join } from "path";
const { suggestions: defaultSuggestions } = readJsonSync(join(__dirname, "../../suggestions.json"));
const { suggestions: defaultSuggestions } = readJsonSync(join(__dirname, "../suggestions.json"));
interface ContractsManager {
[key: string]: any;
@ -17,13 +17,6 @@ interface Suggestion {
type SuggestionsList = Suggestion[];
// =============================================
// =============================================
// TODO: this should be moved to its own module
// it's a plugin not a core module
// =============================================
// =============================================
export default class Suggestions {
private embark: Embark;
private events: EmbarkEvents;
@ -35,7 +28,6 @@ export default class Suggestions {
this.embark = embark;
this.events = embark.events;
this.contracts = {};
this.registerApi();
this.listenToEvents();
}

View File

@ -0,0 +1,8 @@
import assert from 'assert';
describe('plugins/suggestions', () => {
it('should run test', () => {
assert.ok(true);
});
});

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"composite": true,
"declarationDir": "./dist",
"rootDir": "./src",
"tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-suggestions.tsbuildinfo"
},
"extends": "../../../tsconfig.base.json",
"include": [
"src/**/*"
],
"references": [
{
"path": "../../core/core"
},
{
"path": "../../core/utils"
},
{
"path": "../../utils/testing"
}
]
}

View File

@ -0,0 +1,4 @@
{
"extends": "../../../tslint.json"
}

View File

@ -118,6 +118,9 @@
{
"path": "packages/plugins/specialconfigs"
},
{
"path": "packages/plugins/suggestions"
},
{
"path": "packages/plugins/swarm"
},