help prs, why do i get ENOENT on second downloadFile in downloadPlugin?

This commit is contained in:
Daniel Hübleitner
2019-08-01 16:56:53 +02:00
parent ea346fe0cb
commit 4edf6c1a7f
5 changed files with 388 additions and 74 deletions
+9 -59
View File
@@ -3,46 +3,26 @@
import * as Logger from 'log4js'
import { Plugin, socketioRPC } from 'frontblock-generic/Plugin';
import { ErrorResponse, SuccessResponse } from 'frontblock-generic/Types';
import { PluginManager } from './PluginManager'
import express = require('express');
import http = require('http');
import fs = require('fs');
import bsock = require('bsock');
import fetch = require("node-fetch");
const kfs = require("key-file-storage").default('kfs')
type pluginEntry =
{
pluginName:string
}
const pluginList:pluginEntry[] =
[
//{ pluginName: 'apiclient' },
//{ pluginName: 'paymentmanager' },
//{ pluginName: 'wallet' },
{ pluginName: 'htmlsupplier' }
]
type releaseEntry =
{
tagName: string,
staticZipURL: URL,
checksumFileURL: URL
}
Logger.configure({
appenders:
{
"admin": { type: 'stdout' },
"frontblock-admin": { type: 'stdout' },
//app: { type: 'file', filename: 'application.log' }
},
categories:
{
default: { appenders: [ 'admin' ], level: 'debug' }
default: { appenders: [ 'frontblock-admin' ], level: 'debug' }
}
})
const logger = Logger.getLogger("admin")
const logger = Logger.getLogger("frontblock-admin")
type hookRPC =
{
@@ -80,58 +60,28 @@ export type rpcInfo =
* The list of available plugins is published via the frontblock API and downloaded via gitea-releases
*/
export class FrontblockAdmin{
private plugins: Plugin[]
private plugins: Plugin[] = []
private hookToUids:{[hookName:string]:string[]} = {}
private express
private httpServer
private io = bsock.createServer()
private wsServer = http.createServer()
private pm: PluginManager
constructor(){
if(!('admin.conf' in kfs)){
logger.info('Generating ./kfs/admin.conf')
kfs['admin.conf'] = { httpPort: 8080 }
}
this.pm = new PluginManager()
this.initialize()
}
private async initialize(){
const wat = await this.fetchReleaseList('htmlsupplier')
logger.debug(wat)
//await this.downloadPlugins()
//this.plugins.forEach(plugin => plugin.start())
//this.startWebsocket()
//this.startWebserver()
}
private async fetchReleaseList(pluginName:string): Promise<releaseEntry[]>{
const res = await fetch('https://gitea.frontblock.me/api/v1/repos/fb-vendor/' + pluginName + '/releases')
const json = await res.json();
const releaseList:releaseEntry[] = []
json.forEach((release) => {
const tagName = release.tag_name
const staticZipURL = release.assets.filter(asset => asset.name === pluginName + '.zip')[0].browser_download_url
const checksumFileURL = release.assets.filter(asset => asset.name === 'md5sum.txt')[0].browser_download_url
releaseList.push({tagName,staticZipURL,checksumFileURL})
})
return releaseList
}
private async downloadPlugin(release:releaseEntry) {
}
private async verifyPlugin(release:releaseEntry) {
}
private async extractPlugin(release:releaseEntry) {
}
private async installPlugin(release:releaseEntry) {
}
private initApis(socket){
//Declare own functions
const rpcInfos:rpcInfo[] = [
@@ -234,7 +184,7 @@ export class FrontblockAdmin{
private restartWebserver(port:number){
this.stopWebserver()
kfs.FrontblockAdmin = { httpPort: port }
kfs['admin.conf'] = { httpPort: port }
this.startWebserver()
}