make work

This commit is contained in:
peter
2019-08-27 19:25:17 +02:00
parent 19e011d518
commit fb86ed1978
7 changed files with 2740 additions and 14 deletions
+1 -5
View File
@@ -3,8 +3,7 @@
import * as Logger from 'log4js'
import * as Knex from 'knex'
import { FrontblockApiClient, FrontblockApiConf } from 'frontblock';
import { socketioRPC, rpcHooker, ExtendedRpcInfo } from 'frontblock-generic/RPC';
import { ApiClientBase, AdminBase } from 'frontblock-generic/Admin';
import { AdminBase } from 'frontblock-generic/Admin';
import express = require('express');
import http = require('http');
import bsock = require('bsock');
@@ -173,9 +172,6 @@ export class FrontblockAdmin extends AdminBase<AdminConf>{
}
}
new FrontblockAdmin()
process.on( 'SIGINT', function() {
logger.info( "Gracefully shutting down from SIGINT (Ctrl-C)" );
// some other closing procedures go here
+25
View File
@@ -0,0 +1,25 @@
import * as Logger from 'log4js'
var exec = require('child-process-promise').exec;
Logger.configure({
appenders:
{
"admin": { type: 'stdout' },
//app: { type: 'file', filename: 'application.log' }
},
categories:
{
default: { appenders: [ 'admin' ], level: 'debug' }
}
})
const logger = Logger.getLogger("admin")
logger.info("Checking npm dependencies...")
exec("npm i --prefix ./plugins knex@0.19.2 sqlite3@4.1.0").then(process => {
logger.debug(process.stdout)
const admin = require("./FrontblockAdmin").FrontblockAdmin
new admin()
})
+12 -2
View File
@@ -41,7 +41,7 @@ export class UpdateManager extends Plugin{
exportRPCs(): socketioRPC[] {
return [{
name: 'installPlugin',
func: async (name:string, force = false) => { },
func: async (name:string, force = false) => {return await this.installPlugin(name, force)},
type: 'call',
visibility: 'private'
},{
@@ -86,19 +86,29 @@ export class UpdateManager extends Plugin{
logger.info(res.stdout)
*/
/*
const extensions = [
new NPMExtension("sqlite3", "./plugins", "4.1.0"),
new NPMExtension("frontblock", "./plugins", "latest")
]
*/
const extensions:NPMExtension[] = []
await Promise.all(extensions.map(e => e.install()))
const status = await Promise.all(extensions.map(e => e.status()))
console.log(status)
}
async installPlugin(name: string, force:boolean = false):Promise<RepoFolderStatus>{
logger.warn("Cloning fb-dist/"+name+".git into ./plugins/"+name+" ..."+(force?" USING FORCE!":""))
this.pluginUpdaters[name] = new GitUpdater("./plugins/"+name)
const status = await this.pluginUpdaters[name].cloneRepo("https://gitea.frontblock.me/fb-dist/"+name.toLowerCase()+".git", force)
return status
}
async updateAdmin(force:boolean = false){
this.adminUpdater = new GitUpdater("./dist")
let status = await this.adminUpdater.getStatus()
+16 -2
View File
@@ -19,15 +19,29 @@ module.exports = [{
__dirname: false,
Buffer: true,
},
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: [".ts", ".tsx", ".js"]
},
module: {
rules: [
{ test: /\.ts?$/, loader: "ts-loader" }
]
},
externals:{
sqlite3: 'sqlite3',
knex: "../plugins/node_modules/knex"
},
optimization: {
minimize: false
},
entry: path.resolve(__dirname, '../../lib/FrontblockAdmin.js'),
entry: path.resolve(__dirname, 'Main.ts'),
output: {
path: path.resolve(__dirname, '../../dist'),
filename: 'FrontblockAdmin.js',
libraryTarget: 'commonjs',
}
}]