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",
|
||||
"scripts": {
|
||||
"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-backend": "tsc; npm run webpack",
|
||||
"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-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",
|
||||
"webpack": "webpack --config src/backend/webpack.prod.js --progress --colors"
|
||||
},
|
||||
@@ -25,8 +25,8 @@
|
||||
"bsock": "^0.1.9",
|
||||
"child-process-promise": "^2.2.1",
|
||||
"express": "^4.16.4",
|
||||
"frontblock": "^0.9.9",
|
||||
"frontblock-generic": "^0.28.4",
|
||||
"frontblock": "^0.14.0",
|
||||
"frontblock-generic": "^0.29.0",
|
||||
"git-cherrypicker": "0.0.3",
|
||||
"git-describe": "^4.0.4",
|
||||
"http": "0.0.0",
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
'use strict'
|
||||
|
||||
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 { ErrorResponse, SuccessResponse, SubscriptionResponse } from 'frontblock-generic/Types';
|
||||
import { ApiClientBase } from 'frontblock-generic/Admin';
|
||||
import express = require('express');
|
||||
import http = require('http');
|
||||
import bsock = require('bsock');
|
||||
import { promises as fs } from "fs"
|
||||
import * as path from "path"
|
||||
import { UpdateManager } from './UpdateManger';
|
||||
import { FrontblockApiConf, FrontblockApi } from 'frontblock-generic/Api';
|
||||
var exec = require('child-process-promise').exec;
|
||||
|
||||
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
|
||||
*/
|
||||
export class FrontblockAdmin extends ConfigLoader<AdminConf> implements Plugin<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.");
|
||||
}
|
||||
|
||||
export class FrontblockAdmin extends ApiClientBase<AdminConf>{
|
||||
|
||||
private express
|
||||
private httpServer
|
||||
private io = bsock.createServer()
|
||||
private wsServer = http.createServer()
|
||||
private updateManager:UpdateManager = new UpdateManager()
|
||||
private updateManager:UpdateManager = new UpdateManager(this)
|
||||
|
||||
constructor(){
|
||||
super("FrontblockAdmin")
|
||||
@@ -59,8 +52,27 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf> implements Plugin<A
|
||||
this.initialize()
|
||||
}
|
||||
|
||||
getDefaultConfig(): AdminConf {
|
||||
return {httpPort: 8080}
|
||||
getDefaultConfig(): { apiConf: FrontblockApiConf; } & AdminConf & { dbConf:Knex.Config; } {
|
||||
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(){
|
||||
@@ -84,6 +96,7 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf> implements Plugin<A
|
||||
|
||||
const rpcInfos:ExtendedRpcInfo[] = [
|
||||
...rpcHooker(socket, "Admin", adminRPCs, false),
|
||||
...rpcHooker(socket, "ApiClient", this.exportRPCs()),
|
||||
...rpcHooker(socket, "UpdateManager", this.updateManager.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 * as Logger from 'log4js'
|
||||
import { mkdirSync } from "fs";
|
||||
import { FrontblockAdmin } from "./FrontblockAdmin";
|
||||
var exec = require('child-process-promise').exec;
|
||||
|
||||
Logger.configure({
|
||||
@@ -20,13 +21,17 @@ Logger.configure({
|
||||
const logger = Logger.getLogger("admin/updatemanager")
|
||||
|
||||
|
||||
export class UpdateManager implements Plugin{
|
||||
export class UpdateManager extends Plugin<void>{
|
||||
name: string = "UpdateManager"
|
||||
private loadedPlugins:{[name in string]:Plugin} = {}
|
||||
private loadedPlugins:{[name in string]:Plugin<any>} = {}
|
||||
private dashboardUpdater:GitUpdater
|
||||
private adminUpdater:GitUpdater
|
||||
private pluginUpdaters:{[name in string]:GitUpdater} = {}
|
||||
|
||||
constructor(admin:FrontblockAdmin){
|
||||
super(admin, "UpdateManager")
|
||||
}
|
||||
|
||||
getDefaultConfig(): void {
|
||||
return
|
||||
}
|
||||
@@ -163,21 +168,11 @@ export class UpdateManager implements Plugin{
|
||||
return await this.pluginUpdaters[pluginName].checkoutTag(tag)
|
||||
}
|
||||
|
||||
getLoadedPlugins():Plugin[]{
|
||||
getLoadedPlugins():Plugin<any>[]{
|
||||
return Object.values(this.loadedPlugins)
|
||||
}
|
||||
|
||||
getLoadedPluginNames():string[]{
|
||||
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