Skip to content

Commit a224401

Browse files
committed
refactor(@embark/suggestions): move suggestions API into plugin
1 parent 61bf7d5 commit a224401

File tree

12 files changed

+128
-13
lines changed

12 files changed

+128
-13
lines changed

packages/core/console/src/lib/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { dappPath, escapeHtml, exit, jsonFunctionReplacer } from "embark-utils";
66
import stringify from "json-stringify-safe";
77
import { dirname } from "path";
88
import util from "util";
9-
import Suggestions from "./suggestions";
109

1110
type MatchFunction = (cmd: string) => boolean;
1211
interface HelpDescription {
@@ -26,7 +25,6 @@ export default class Console {
2625
private config: any;
2726
private history: string[];
2827
private cmdHistoryFile: string;
29-
private suggestions?: Suggestions;
3028
// private providerReady: boolean;
3129
private helpCmds: any;
3230

@@ -82,8 +80,6 @@ export default class Console {
8280
return;
8381
}
8482
this.registerApi();
85-
86-
this.suggestions = new Suggestions(embark, options);
8783
}
8884

8985
private get isEmbarkConsole() {

packages/embark/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"embark-i18n": "^5.1.0-nightly.0",
8585
"embark-logger": "^5.1.0-nightly.0",
8686
"embark-reset": "^5.1.0-nightly.0",
87+
"embark-suggestions": "^5.1.0-nightly.0",
8788
"embark-utils": "^5.1.0-nightly.0",
8889
"eth-ens-namehash": "2.0.8",
8990
"find-up": "2.1.0",

packages/embark/src/cmd/cmd_controller.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class EmbarkController {
176176
engine.registerModuleGroup("cockpit");
177177
engine.registerModulePackage('embark-deploy-tracker', { plugins: engine.plugins });
178178
engine.registerModulePackage("embark-debugger");
179+
engine.registerModulePackage('embark-suggestions');
179180

180181
// load custom plugins
181182
engine.loadDappPlugins();
@@ -391,6 +392,7 @@ class EmbarkController {
391392
}
392393
engine.registerModulePackage('embark-deploy-tracker', { plugins: engine.plugins });
393394
engine.registerModulePackage("embark-debugger");
395+
engine.registerModulePackage('embark-suggestions');
394396

395397
// load custom plugins
396398
engine.loadDappPlugins();

packages/embark/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
{
4343
"path": "../plugins/solidity"
4444
},
45+
{
46+
"path": "../plugins/suggestions"
47+
},
4548
{
4649
"path": "../plugins/transaction-logger"
4750
},
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# `embark-suggestions
2+
3+
> Suggestions plugin for Embark
4+
5+
Visit [embark.status.im](https://embark.status.im/) to get started with
6+
[Embark](https://github.com/embark-framework/embark).
7+
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"name": "embark-suggestions",
3+
"version": "5.1.0-nightly.0",
4+
"author": "Iuri Matias <[email protected]>",
5+
"contributors": [],
6+
"description": "Suggestions plugin for Embark",
7+
"homepage": "https://github.com/embark-framework/embark/tree/master/packages/plugins/suggestions#readme",
8+
"bugs": "https://github.com/embark-framework/embark/issues",
9+
"keywords": [],
10+
"files": [
11+
"dist"
12+
],
13+
"license": "MIT",
14+
"repository": {
15+
"directory": "packages/plugins/suggestions",
16+
"type": "git",
17+
"url": "https://github.com/embark-framework/embark.git"
18+
},
19+
"main": "./dist/index.js",
20+
"types": "./dist/index.d.ts",
21+
"embark-collective": {
22+
"build:node": true,
23+
"typecheck": true
24+
},
25+
"scripts": {
26+
"_build": "npm run solo -- build",
27+
"_typecheck": "npm run solo -- typecheck",
28+
"ci": "npm run qa",
29+
"clean": "npm run reset",
30+
"lint": "npm-run-all lint:*",
31+
"lint:ts": "tslint -c tslint.json \"src/**/*.ts\"",
32+
"qa": "npm-run-all lint _typecheck _build test",
33+
"reset": "npx rimraf dist embark-*.tgz package",
34+
"solo": "embark-solo",
35+
"test": "jest"
36+
},
37+
"dependencies": {
38+
"@babel/runtime-corejs3": "7.7.4",
39+
"core-js": "3.4.3",
40+
"embark-core": "^5.1.0-nightly.0",
41+
"embark-utils": "^5.1.0-nightly.0",
42+
"fs-extra": "8.1.0"
43+
},
44+
"devDependencies": {
45+
"@babel/core": "7.7.4",
46+
"babel-jest": "24.9.0",
47+
"embark-solo": "^5.1.0-nightly.0",
48+
"embark-testing": "^5.1.0-nightly.0",
49+
"eslint": "5.7.0",
50+
"npm-run-all": "4.1.5",
51+
"rimraf": "3.0.0",
52+
"tslint": "5.20.1",
53+
"typescript": "3.7.2"
54+
},
55+
"engines": {
56+
"node": ">=10.17.0 <12.0.0",
57+
"npm": ">=6.11.3",
58+
"yarn": ">=1.19.1"
59+
},
60+
"jest": {
61+
"collectCoverage": true,
62+
"testEnvironment": "node",
63+
"testMatch": [
64+
"**/test/**/*.js"
65+
],
66+
"transform": {
67+
"\\.(js|ts)$": [
68+
"babel-jest",
69+
{
70+
"rootMode": "upward"
71+
}
72+
]
73+
}
74+
}
75+
}
76+

packages/core/console/src/lib/suggestions.ts renamed to packages/plugins/suggestions/src/index.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { fuzzySearch } from "embark-utils";
33
import { readJsonSync } from "fs-extra";
44
import { join } from "path";
55

6-
const { suggestions: defaultSuggestions } = readJsonSync(join(__dirname, "../../suggestions.json"));
6+
const { suggestions: defaultSuggestions } = readJsonSync(join(__dirname, "../suggestions.json"));
77

88
interface ContractsManager {
99
[key: string]: any;
@@ -17,13 +17,6 @@ interface Suggestion {
1717

1818
type SuggestionsList = Suggestion[];
1919

20-
// =============================================
21-
// =============================================
22-
// TODO: this should be moved to its own module
23-
// it's a plugin not a core module
24-
// =============================================
25-
// =============================================
26-
2720
export default class Suggestions {
2821
private embark: Embark;
2922
private events: EmbarkEvents;
@@ -35,7 +28,6 @@ export default class Suggestions {
3528
this.embark = embark;
3629
this.events = embark.events;
3730
this.contracts = {};
38-
3931
this.registerApi();
4032
this.listenToEvents();
4133
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import assert from 'assert';
2+
3+
describe('plugins/suggestions', () => {
4+
5+
it('should run test', () => {
6+
assert.ok(true);
7+
});
8+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"declarationDir": "./dist",
5+
"rootDir": "./src",
6+
"tsBuildInfoFile": "./node_modules/.cache/tsc/tsconfig.embark-suggestions.tsbuildinfo"
7+
},
8+
"extends": "../../../tsconfig.base.json",
9+
"include": [
10+
"src/**/*"
11+
],
12+
"references": [
13+
{
14+
"path": "../../core/core"
15+
},
16+
{
17+
"path": "../../core/utils"
18+
},
19+
{
20+
"path": "../../utils/testing"
21+
}
22+
]
23+
}

0 commit comments

Comments
 (0)