This commit is contained in:
peter
2019-08-18 05:01:32 +02:00
parent e71555af1a
commit b33f900806
6 changed files with 132 additions and 20 deletions
+99 -10
View File
@@ -637,6 +637,14 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.19.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.19.tgz",
"integrity": "sha512-tLRDU1hmcWamtgRT2iVRdraAQVGFQGgtcqracSo9XyMN1VeZLSVGb8RJJxVqab7UGbijoUijGPVFMjmqzyZIUw==" "integrity": "sha512-tLRDU1hmcWamtgRT2iVRdraAQVGFQGgtcqracSo9XyMN1VeZLSVGb8RJJxVqab7UGbijoUijGPVFMjmqzyZIUw=="
}, },
"@types/node-fetch": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.0.tgz",
"integrity": "sha512-TLFRywthBgL68auWj+ziWu+vnmmcHCDFC/sqCOQf1xTz4hRq8cu79z8CtHU9lncExGBsB8fXA4TiLDLt6xvMzw==",
"requires": {
"@types/node": "*"
}
},
"@types/q": { "@types/q": {
"version": "1.5.2", "version": "1.5.2",
"resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.2.tgz", "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.2.tgz",
@@ -3908,7 +3916,7 @@
"bitcoinjs-lib": "^5.0.4", "bitcoinjs-lib": "^5.0.4",
"bsock": "^0.1.9", "bsock": "^0.1.9",
"express": "^4.16.4", "express": "^4.16.4",
"frontblock-generic": "^0.22.0", "frontblock-generic": "^0.23.0",
"hdkey": "^1.1.1", "hdkey": "^1.1.1",
"key-file-storage": "^2.2.1", "key-file-storage": "^2.2.1",
"log4js": "^4.3.1", "log4js": "^4.3.1",
@@ -3918,12 +3926,12 @@
"rxjs": "^6.5.2", "rxjs": "^6.5.2",
"rxjs-compat": "^6.5.2", "rxjs-compat": "^6.5.2",
"uuid": "^3.3.2" "uuid": "^3.3.2"
}
}, },
"dependencies": {
"frontblock-generic": { "frontblock-generic": {
"version": "0.22.0", "version": "0.23.0",
"resolved": "https://registry.npmjs.org/frontblock-generic/-/frontblock-generic-0.22.0.tgz", "resolved": "https://registry.npmjs.org/frontblock-generic/-/frontblock-generic-0.23.0.tgz",
"integrity": "sha512-hhojVEeQYt1wakBTBTZAKuCNqvw4CxI9+WuWb7Ark2gaJJMD2+q/FxkrE+VAPDv82Uy7AT3Pn39DkMbyF52hCg==", "integrity": "sha512-5KukScUCAsomGP9xMp6gQjA5xKBMfctTSQhIoaoxEkXpXoX9F2pjlYIkfP11NYNSsk2gVf3xg7VIhhSzhizy/A==",
"requires": { "requires": {
"@types/node": "^12.7.1", "@types/node": "^12.7.1",
"bsock": "^0.1.9", "bsock": "^0.1.9",
@@ -3935,11 +3943,39 @@
}, },
"dependencies": { "dependencies": {
"@types/node": { "@types/node": {
"version": "12.7.1", "version": "12.7.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.2.tgz",
"integrity": "sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw==" "integrity": "sha512-dyYO+f6ihZEtNPDcWNR1fkoTDf3zAK3lAABDze3mz6POyIercH0lEUawUFXlG8xaQZmm1yEBON/4TsYv/laDYg=="
} }
} }
}
}
},
"frontblock-generic": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/frontblock-generic/-/frontblock-generic-0.23.0.tgz",
"integrity": "sha512-5KukScUCAsomGP9xMp6gQjA5xKBMfctTSQhIoaoxEkXpXoX9F2pjlYIkfP11NYNSsk2gVf3xg7VIhhSzhizy/A==",
"requires": {
"@types/node": "^12.7.1",
"bsock": "^0.1.9",
"http": "0.0.0",
"key-file-storage": "^2.2.4",
"log4js": "^4.2.0",
"minimist": "^1.2.0",
"uuid": "^3.3.2"
},
"dependencies": {
"@types/node": {
"version": "12.7.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.2.tgz",
"integrity": "sha512-dyYO+f6ihZEtNPDcWNR1fkoTDf3zAK3lAABDze3mz6POyIercH0lEUawUFXlG8xaQZmm1yEBON/4TsYv/laDYg=="
}
}
},
"fs": {
"version": "0.0.1-security",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
"integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ="
}, },
"fs-extra": { "fs-extra": {
"version": "8.1.0", "version": "8.1.0",
@@ -4631,6 +4667,18 @@
"assert-plus": "^1.0.0" "assert-plus": "^1.0.0"
} }
}, },
"git-cherrypicker": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/git-cherrypicker/-/git-cherrypicker-0.0.3.tgz",
"integrity": "sha512-zvKaHO33rp05u68IrWz6toYZBWlzrZEccf2fbtJOqZ+hLKSQ9BLffYZ7FtkOd53gmuMW8DhhnhEBp7fdL9H2Ew==",
"requires": {
"@types/node-fetch": "^2.5.0",
"fs": "0.0.1-security",
"node-fetch": "^2.6.0",
"path": "^0.12.7",
"simple-git": "^1.124.0"
}
},
"glob": { "glob": {
"version": "7.1.4", "version": "7.1.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
@@ -7678,6 +7726,25 @@
"integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=",
"dev": true "dev": true
}, },
"path": {
"version": "0.12.7",
"resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
"integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=",
"requires": {
"process": "^0.11.1",
"util": "^0.10.3"
},
"dependencies": {
"util": {
"version": "0.10.4",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
"integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
"requires": {
"inherits": "2.0.3"
}
}
}
},
"path-browserify": { "path-browserify": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz",
@@ -8450,8 +8517,7 @@
"process": { "process": {
"version": "0.11.10", "version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI="
"dev": true
}, },
"process-nextick-args": { "process-nextick-args": {
"version": "2.0.1", "version": "2.0.1",
@@ -9627,6 +9693,29 @@
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
"dev": true "dev": true
}, },
"simple-git": {
"version": "1.124.0",
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-1.124.0.tgz",
"integrity": "sha512-ks9mBoO4ODQy/xGLC8Cc+YDvj/hho/IKgPhi6h5LI/sA+YUdHc3v0DEoHzM29VmulubpGCxMJUSFmyXNsjNMEA==",
"requires": {
"debug": "^4.0.1"
},
"dependencies": {
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
"ms": "^2.1.1"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"simple-swizzle": { "simple-swizzle": {
"version": "0.2.2", "version": "0.2.2",
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
+5 -3
View File
@@ -6,9 +6,9 @@
"tsc": "tsc", "tsc": "tsc",
"start": "npm run build; node lib/FrontblockAdmin.js", "start": "npm run build; node lib/FrontblockAdmin.js",
"build": "npm run clean; npm run build-backend; npm run build-frontend", "build": "npm run clean; npm run build-backend; npm run build-frontend",
"build-backend": "tsc; webpack --display-error-details --config src/backend/webpack.prod.js --progress --colors; cp -r lib/PluginManager/* .", "build-backend": "tsc; webpack --display-error-details --config src/backend/webpack.prod.js --progress --colors;",
"build-frontend": "npm run build-dashboard; npm run build-widget", "build-frontend": "npm run build-dashboard",
"build-dashboard": "git submodule init && git submodule update --merge; cd src/frontend/dashboard; npm i && npm run build; cp -r dist/dashboard ../../../static", "build-dashboard": "git submodule init && git submodule update --merge; cd src/frontend/dashboard; npm i && npm run build; cp -r dist/* ../../../static",
"build-widget": "rollup -c src/frontend/widget/rollup.config.js; mkdir -p plugins/PluginManager; cp FrontendPlugin.js plugins/PluginManager", "build-widget": "rollup -c src/frontend/widget/rollup.config.js; mkdir -p plugins/PluginManager; cp FrontendPlugin.js plugins/PluginManager",
"clean": "rm -rf lib static plugins data conf dist widget .rpt2_cache *.js *.ts src/frontend/dashboard/dist", "clean": "rm -rf lib static plugins data conf dist widget .rpt2_cache *.js *.ts src/frontend/dashboard/dist",
"update-frontblock": "rm -rf node_modules/frontblock*; npm install", "update-frontblock": "rm -rf node_modules/frontblock*; npm install",
@@ -41,6 +41,7 @@
"express": "^4.16.4", "express": "^4.16.4",
"frontblock": "^0.9.9", "frontblock": "^0.9.9",
"frontblock-generic": "latest", "frontblock-generic": "latest",
"git-cherrypicker": "0.0.3",
"hdkey": "^1.1.1", "hdkey": "^1.1.1",
"http": "0.0.0", "http": "0.0.0",
"key-file-storage": "^2.2.4", "key-file-storage": "^2.2.4",
@@ -48,6 +49,7 @@
"memfs": "^2.15.5", "memfs": "^2.15.5",
"minimist": "^1.2.0", "minimist": "^1.2.0",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.0",
"path": "^0.12.7",
"rollup": "^0.55.1", "rollup": "^0.55.1",
"rollup-plugin-node-externals": "^2.0.0", "rollup-plugin-node-externals": "^2.0.0",
"rxjs": "^6.5.2", "rxjs": "^6.5.2",
+26 -4
View File
@@ -3,10 +3,12 @@
import * as Logger from 'log4js' import * as Logger from 'log4js'
import { socketioRPC, ConfigLoader } from 'frontblock-generic/Plugin'; import { socketioRPC, ConfigLoader } from 'frontblock-generic/Plugin';
import { ErrorResponse, SuccessResponse } from 'frontblock-generic/Types'; import { ErrorResponse, SuccessResponse } from 'frontblock-generic/Types';
import { default as PluginManagerPlugin } from './PluginManager/Plugin'
import express = require('express'); import express = require('express');
import http = require('http'); import http = require('http');
import bsock = require('bsock'); import bsock = require('bsock');
import { FrontblockCherryPicker } from "git-cherrypicker"
import { basename } from "path"
import { promises as fs } from "fs"
const kfs = require("key-file-storage").default('kfs') const kfs = require("key-file-storage").default('kfs')
@@ -67,11 +69,10 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
private httpServer private httpServer
private io = bsock.createServer() private io = bsock.createServer()
private wsServer = http.createServer() private wsServer = http.createServer()
private pm: PluginManagerPlugin private pm
constructor(){ constructor(){
super("FrontblockAdmin") super("FrontblockAdmin")
this.pm = new PluginManagerPlugin()
this.initialize() this.initialize()
} }
@@ -81,6 +82,13 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
} }
private async initialize(){ private async initialize(){
await fs.mkdir("plugins/PluginManager", {recursive: true})
await (new FrontblockCherryPicker("fb-dist/pluginmanager", "master", "Plugin.js")).write("plugins/PluginManager/Plugin.js")
await (new FrontblockCherryPicker("fb-dist/pluginmanager", "master", "FrontendPlugin.js")).write("plugins/PluginManager/FrontendPlugin.js")
let str = "../plugins/PluginManager/Plugin"
const PM = await import(str)
this.pm = new PM.default()
this.startWebsocket() this.startWebsocket()
this.startWebserver() this.startWebserver()
} }
@@ -104,11 +112,20 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
type:'call', type:'call',
fn: () => { return rpcInfos } fn: () => { return rpcInfos }
} }
},{
owner: 'Admin',
name: 'installPluginManager',
args: '',
info: {
type: 'call',
fn: () => {}
}
} }
] ]
//translate RPCs to socket-bound function metadata //translate RPCs to socket-bound function metadata
const loadedPlugins = this.pm.getLoadedPlugins() const loadedPlugins = this.pm.getLoadedPlugins()
for(const name in loadedPlugins){ for(const name in loadedPlugins){
loadedPlugins[name].backend.exportRPCs().forEach(rpc => { loadedPlugins[name].backend.exportRPCs().forEach(rpc => {
@@ -117,6 +134,7 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
}) })
} }
//Hook up all the functions //Hook up all the functions
for(const api of rpcInfos){ for(const api of rpcInfos){
switch(api.info.type){ switch(api.info.type){
@@ -174,6 +192,10 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
}) })
} }
private installPluginManager(){
}
private startWebserver(){ private startWebserver(){
if(this.httpServer != null || this.express != null){ if(this.httpServer != null || this.express != null){
logger.warn("Webserver is already running") logger.warn("Webserver is already running")
@@ -204,7 +226,7 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
/** /**
* redirect all the other traffic to the single * redirect all the other traffic to the single
* side app to the main entry point from where * page app to the main entry point from where
* a webpacked and rolled up index.html is serverd * a webpacked and rolled up index.html is serverd
* and angular takes over routing * and angular takes over routing
*/ */
+1 -2
View File
@@ -1,5 +1,4 @@
import { parseSubResponse, parseResponse } from "frontblock-generic/Types"; import { parseSubResponse, parseResponse } from "frontblock-generic/Types";
import PluginManager from "./PluginManager/PluginManager";
var bsock = require('bsock') var bsock = require('bsock')
/** /**
@@ -78,7 +77,7 @@ export class FrontblockConfigLib{
window['fb'] = new FrontblockConfigLib() window['fb'] = new FrontblockConfigLib()
declare const fb:{PluginManager:PluginManager} declare const fb:{PluginManager:any}
window['setup'] = async() => { window['setup'] = async() => {
await Promise.all([ await Promise.all([
fb.PluginManager.installPlugin("ApiClient"), fb.PluginManager.installPlugin("ApiClient"),