Skip to content

Commit

Permalink
Merge pull request #5 from WorldBrain/feature/plugins
Browse files Browse the repository at this point in the history
Implement minimal plugin system
  • Loading branch information
ShishKabab authored Apr 12, 2020
2 parents 2519921 + 357de8c commit adcfea8
Show file tree
Hide file tree
Showing 25 changed files with 5,717 additions and 487 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ yarn-error.log*
*.swp

private
lib
3 changes: 3 additions & 0 deletions demos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Demos

- https://github.com/WorldBrain/storex-hub-demo-memex-gist-sharer
238 changes: 0 additions & 238 deletions demos/memex-gist-sharer/main.ts

This file was deleted.

17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"main": "lib/main.js",
"scripts": {
"start": "ts-node ts/main.ts",
"storex-hub": "ts-node/main.ts",
"memex-gist-sharer": "ts-node demos/memex-gist-sharer/main.ts",
"prepare": "tsc",
"prepare:watch": "npm run prepare -- -w",
"test": "mocha --require ts-node/register \"ts/**/*.test.ts\"",
Expand All @@ -25,6 +23,7 @@
"@worldbrain/storex-pattern-modules": "^0.4.0",
"bcrypt": "^4.0.1",
"crypto-random-string": "^3.2.0",
"fast-glob": "^3.2.2",
"gist-client": "^1.1.1",
"fake-indexeddb": "^2.0.4",
"koa": "^2.11.0",
Expand All @@ -33,38 +32,44 @@
"koa-session": "^5.12.3",
"koa-socket-2": "^1.2.0",
"lodash": "^4.17.10",
"prompt-sync": "^4.2.0",
"sqlite3": "^4.1.1",
"socket.io-client": "^2.3.0",
"typed-emitter": "^0.2.0",
"supertest": "^4.0.2",
"tempy": "^0.5.0",
"uuid": "^3.4.0"
"uuid": "^3.4.0",
"yargs": "^15.3.1"
},
"devDependencies": {
"@types/bcrypt": "^3.0.0",
"@types/chai": "^4.0.6",
"@types/events": "^1.2.0",
"@types/expect": "^1.20.4",
"@types/koa": "^2.11.0",
"@types/koa-bodyparser": "^4.3.0",
"@types/koa-router": "^7.4.0",
"@types/lodash": "^4.14.149",
"@types/minimist": "1.2.0",
"@types/mocha": "^2.2.44",
"@types/node": "^10.12.11",
"@types/socket.io": "^2.1.4",
"@types/socket.io-client": "^1.4.32",
"@types/supertest": "^2.0.8",
"@types/uuid": "^3.4.7",
"@types/yargs": "^11.0.0",
"chai": "^4.1.2",
"del": "^5.1.0",
"expect": "^23.5.0",
"expect": "^25.3.0",
"fake-fs": "^0.5.0",
"mocha": "^4.0.1",
"nyc": "^13.3.0",
"sinon": "^4.1.2",
"source-map-support": "0.5.16",
"storex-hub-plugin-internal-selftest": "^0.0.1",
"ts-node": "^7.0.1",
"typescript": "^3.7.5"
"typescript": "^3.7.5",
"@types/prompt-sync": "^4.1.0",
"@worldbrain/storex-hub-interfaces": "^0.1.1"
},
"resolutions": {
"**/graphql": "^14.0.0"
Expand Down
3 changes: 2 additions & 1 deletion ts/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export interface ApplicationApiOptions {
callbacks?: AllStorexHubCallbacks_v0
}
export class Application {
private storage: Promise<Storage>
public storage: Promise<Storage>

private remoteSessions: { [identifier: string]: AllStorexHubCallbacks_v0 } = {}
private appEvents: { [identifier: string]: EventEmitter } = {}
private events = new EventEmitter() as TypedEmitter<{
Expand Down
Empty file added ts/constants.ts
Empty file.
17 changes: 17 additions & 0 deletions ts/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { main } from "./main"
import expect from "expect"

describe('Main entry point', () => {
it('should correctly discover plugins', async () => {
const { application, pluginManager } = await main({
runtimeConfig: { discoverPlugins: 'true' },
confirmPluginInstall: async () => 'install',
withoutServer: true,
})
expect(pluginManager.loadedPlugins).toEqual({
'io.worldbrain.storex-hub.internal.self-test': expect.objectContaining({
running: true
})
})
})
})
Loading

0 comments on commit adcfea8

Please sign in to comment.