fix null apiclient and add plugin config in admin
This commit is contained in:
Generated
+820
-291
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -4,13 +4,13 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"tsc": "tsc",
|
"tsc": "tsc",
|
||||||
"start": "npm run build; node dist/FrontblockAdmin.js",
|
"start": "npm run build; node lib/FrontblockAdmin.js",
|
||||||
"build": "npm run clean; npm run build-backend",
|
"build": "npm run clean; npm run build-backend",
|
||||||
"build-backend": "tsc; npm run webpack",
|
"build-backend": "tsc; npm run webpack",
|
||||||
"build-frontend": "npm run build-dashboard",
|
"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/* ../../../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 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",
|
||||||
"webpack": "webpack --config src/backend/webpack.prod.js --progress --colors"
|
"webpack": "webpack --config src/backend/webpack.prod.js --progress --colors"
|
||||||
},
|
},
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
"bsock": "^0.1.9",
|
"bsock": "^0.1.9",
|
||||||
"child-process-promise": "^2.2.1",
|
"child-process-promise": "^2.2.1",
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
"frontblock": "^0.9.9",
|
"frontblock": "^0.14.0",
|
||||||
"frontblock-generic": "^0.28.4",
|
"frontblock-generic": "^0.29.0",
|
||||||
"git-cherrypicker": "0.0.3",
|
"git-cherrypicker": "0.0.3",
|
||||||
"git-describe": "^4.0.4",
|
"git-describe": "^4.0.4",
|
||||||
"http": "0.0.0",
|
"http": "0.0.0",
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
import * as Logger from 'log4js'
|
import * as Logger from 'log4js'
|
||||||
import { ConfigLoader, Plugin } from 'frontblock-generic/Plugin';
|
import * as Knex from 'knex'
|
||||||
|
import { FrontblockApiClient } from 'frontblock';
|
||||||
import { socketioRPC, rpcHooker, ExtendedRpcInfo } from 'frontblock-generic/RPC';
|
import { socketioRPC, rpcHooker, ExtendedRpcInfo } from 'frontblock-generic/RPC';
|
||||||
import { ErrorResponse, SuccessResponse, SubscriptionResponse } from 'frontblock-generic/Types';
|
import { ApiClientBase } from 'frontblock-generic/Admin';
|
||||||
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 { promises as fs } from "fs"
|
import { promises as fs } from "fs"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
import { UpdateManager } from './UpdateManger';
|
import { UpdateManager } from './UpdateManger';
|
||||||
|
import { FrontblockApiConf, FrontblockApi } from 'frontblock-generic/Api';
|
||||||
var exec = require('child-process-promise').exec;
|
var exec = require('child-process-promise').exec;
|
||||||
|
|
||||||
Logger.configure({
|
Logger.configure({
|
||||||
@@ -36,22 +38,13 @@ export type AdminConf = { httpPort: number}
|
|||||||
*
|
*
|
||||||
* The list of available plugins is published via the frontblock API and downloaded via gitea-releases
|
* The list of available plugins is published via the frontblock API and downloaded via gitea-releases
|
||||||
*/
|
*/
|
||||||
export class FrontblockAdmin extends ConfigLoader<AdminConf> implements Plugin<AdminConf>{
|
export class FrontblockAdmin extends ApiClientBase<AdminConf>{
|
||||||
exportRPCs(): socketioRPC[] {
|
|
||||||
throw new Error("Method not implemented.");
|
|
||||||
}
|
|
||||||
start(): void | Promise<void> {
|
|
||||||
throw new Error("Method not implemented.");
|
|
||||||
}
|
|
||||||
stop(): void | Promise<void> {
|
|
||||||
throw new Error("Method not implemented.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private express
|
private express
|
||||||
private httpServer
|
private httpServer
|
||||||
private io = bsock.createServer()
|
private io = bsock.createServer()
|
||||||
private wsServer = http.createServer()
|
private wsServer = http.createServer()
|
||||||
private updateManager:UpdateManager = new UpdateManager()
|
private updateManager:UpdateManager = new UpdateManager(this)
|
||||||
|
|
||||||
constructor(){
|
constructor(){
|
||||||
super("FrontblockAdmin")
|
super("FrontblockAdmin")
|
||||||
@@ -59,8 +52,27 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf> implements Plugin<A
|
|||||||
this.initialize()
|
this.initialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultConfig(): AdminConf {
|
getDefaultConfig(): { apiConf: FrontblockApiConf; } & AdminConf & { dbConf:Knex.Config; } {
|
||||||
return {httpPort: 8080}
|
return {
|
||||||
|
httpPort: 8080,
|
||||||
|
apiConf: {
|
||||||
|
apiHost: "api.testnet.frontblock.me",
|
||||||
|
apiKey: "",
|
||||||
|
apiPort: 10001,
|
||||||
|
tls: false
|
||||||
|
},
|
||||||
|
dbConf: {
|
||||||
|
client: 'sqlite3',
|
||||||
|
connection: {
|
||||||
|
filename: "./data/ApiClient.sqlite"
|
||||||
|
},
|
||||||
|
useNullAsDefault: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected makeApiClient(conf: FrontblockApiConf): FrontblockApi {
|
||||||
|
return new FrontblockApiClient(conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async initialize(){
|
private async initialize(){
|
||||||
@@ -84,6 +96,7 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf> implements Plugin<A
|
|||||||
|
|
||||||
const rpcInfos:ExtendedRpcInfo[] = [
|
const rpcInfos:ExtendedRpcInfo[] = [
|
||||||
...rpcHooker(socket, "Admin", adminRPCs, false),
|
...rpcHooker(socket, "Admin", adminRPCs, false),
|
||||||
|
...rpcHooker(socket, "ApiClient", this.exportRPCs()),
|
||||||
...rpcHooker(socket, "UpdateManager", this.updateManager.exportRPCs()),
|
...rpcHooker(socket, "UpdateManager", this.updateManager.exportRPCs()),
|
||||||
...this.updateManager.getLoadedPlugins().flatMap(plugin => rpcHooker(socket, plugin.name, plugin.exportRPCs()))
|
...this.updateManager.getLoadedPlugins().flatMap(plugin => rpcHooker(socket, plugin.name, plugin.exportRPCs()))
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { GitUpdater, RepoFolderStatus } from "./GitUpdater";
|
|||||||
import { FrontblockCherryPicker } from "git-cherrypicker";
|
import { FrontblockCherryPicker } from "git-cherrypicker";
|
||||||
import * as Logger from 'log4js'
|
import * as Logger from 'log4js'
|
||||||
import { mkdirSync } from "fs";
|
import { mkdirSync } from "fs";
|
||||||
|
import { FrontblockAdmin } from "./FrontblockAdmin";
|
||||||
var exec = require('child-process-promise').exec;
|
var exec = require('child-process-promise').exec;
|
||||||
|
|
||||||
Logger.configure({
|
Logger.configure({
|
||||||
@@ -20,13 +21,17 @@ Logger.configure({
|
|||||||
const logger = Logger.getLogger("admin/updatemanager")
|
const logger = Logger.getLogger("admin/updatemanager")
|
||||||
|
|
||||||
|
|
||||||
export class UpdateManager implements Plugin{
|
export class UpdateManager extends Plugin<void>{
|
||||||
name: string = "UpdateManager"
|
name: string = "UpdateManager"
|
||||||
private loadedPlugins:{[name in string]:Plugin} = {}
|
private loadedPlugins:{[name in string]:Plugin<any>} = {}
|
||||||
private dashboardUpdater:GitUpdater
|
private dashboardUpdater:GitUpdater
|
||||||
private adminUpdater:GitUpdater
|
private adminUpdater:GitUpdater
|
||||||
private pluginUpdaters:{[name in string]:GitUpdater} = {}
|
private pluginUpdaters:{[name in string]:GitUpdater} = {}
|
||||||
|
|
||||||
|
constructor(admin:FrontblockAdmin){
|
||||||
|
super(admin, "UpdateManager")
|
||||||
|
}
|
||||||
|
|
||||||
getDefaultConfig(): void {
|
getDefaultConfig(): void {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -163,21 +168,11 @@ export class UpdateManager implements Plugin{
|
|||||||
return await this.pluginUpdaters[pluginName].checkoutTag(tag)
|
return await this.pluginUpdaters[pluginName].checkoutTag(tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
getLoadedPlugins():Plugin[]{
|
getLoadedPlugins():Plugin<any>[]{
|
||||||
return Object.values(this.loadedPlugins)
|
return Object.values(this.loadedPlugins)
|
||||||
}
|
}
|
||||||
|
|
||||||
getLoadedPluginNames():string[]{
|
getLoadedPluginNames():string[]{
|
||||||
return Object.keys(this.loadedPlugins)
|
return Object.keys(this.loadedPlugins)
|
||||||
}
|
}
|
||||||
|
|
||||||
start(): void | Promise<void> {
|
|
||||||
throw new Error("Method not implemented (on purpose)");
|
|
||||||
}
|
|
||||||
|
|
||||||
stop(): void | Promise<void> {
|
|
||||||
throw new Error("Method not implemented (on purpose)");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user