fix
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
"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; pwd; cp -r lib/PluginManager/* .",
|
"build-backend": "tsc; webpack --display-error-details --config src/backend/webpack.prod.js --progress --colors; pwd; cp -r lib/PluginManager/* .",
|
||||||
"build-frontend": "npm run build-dashboard; npm run build-widget",
|
"build-frontend": "npm run build-dashboard; npm run build-widget",
|
||||||
"build-dashboard": "cd src/frontend/dashboard; npm i; npm run build; cp -r dist ../../../static",
|
"build-dashboard": "cd src/frontend/dashboard; npm i; npm run build; cp -r dist/* ../../../static",
|
||||||
"build-widget": "rollup -c src/frontend/widget/rollup.config.js",
|
"build-widget": "rollup -c src/frontend/widget/rollup.config.js",
|
||||||
"clean": "rm -rf lib static dist widget .rpt2_cache *.js *.ts; rm -rf src/frontend/dashboard/dist",
|
"clean": "rm -rf lib static dist widget .rpt2_cache *.js *.ts; rm -rf src/frontend/dashboard/dist",
|
||||||
"update-frontblock": "rm -rf node_modules/frontblock*; npm install"
|
"update-frontblock": "rm -rf node_modules/frontblock*; npm install"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import * as Logger from 'log4js'
|
import * as Logger from 'log4js'
|
||||||
import { Plugin, socketioRPC, ConfigLoader } from 'frontblock-generic/Plugin';
|
import { Plugin, socketioRPC, ConfigLoader } from 'frontblock-generic/Plugin';
|
||||||
import { ErrorResponse, SuccessResponse } from 'frontblock-generic/Types';
|
import { ErrorResponse, SuccessResponse } from 'frontblock-generic/Types';
|
||||||
import { PluginManagerPlugin } from './PluginManager/Plugin'
|
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');
|
||||||
|
|||||||
@@ -17,12 +17,9 @@ const logger = Logger.getLogger("PluginManager/Plugin")
|
|||||||
|
|
||||||
|
|
||||||
export default class PluginManagerPlugin extends PluginManager implements Plugin{
|
export default class PluginManagerPlugin extends PluginManager implements Plugin{
|
||||||
name: string;
|
|
||||||
|
|
||||||
constructor(){
|
constructor(){
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this.installPlugin(this.name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exportRPCs(): import("frontblock-generic/Plugin").socketioRPC[] {
|
exportRPCs(): import("frontblock-generic/Plugin").socketioRPC[] {
|
||||||
@@ -83,7 +80,7 @@ export default class PluginManagerPlugin extends PluginManager implements Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
async start(): Promise<void> {
|
async start(): Promise<void> {
|
||||||
await this.installPlugin("admin") //self-update
|
await this.loadPlugin("admin")
|
||||||
}
|
}
|
||||||
|
|
||||||
stop(): void {
|
stop(): void {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import fs = require('fs');
|
|||||||
import path = require('path')
|
import path = require('path')
|
||||||
import unzip = require('unzip')
|
import unzip = require('unzip')
|
||||||
import { Plugin, ConfigLoader } from 'frontblock-generic/Plugin';
|
import { Plugin, ConfigLoader } from 'frontblock-generic/Plugin';
|
||||||
import { SemVer } from "semver";
|
import { SemVer, parse } from "semver";
|
||||||
|
|
||||||
Logger.configure({
|
Logger.configure({
|
||||||
appenders:
|
appenders:
|
||||||
@@ -24,7 +24,6 @@ const logger = Logger.getLogger("PluginManager")
|
|||||||
type PluginVersion = {
|
type PluginVersion = {
|
||||||
installed?: SemVer,
|
installed?: SemVer,
|
||||||
cached?: SemVer,
|
cached?: SemVer,
|
||||||
loaded?: SemVer
|
|
||||||
}
|
}
|
||||||
export type PluginVersioning = {
|
export type PluginVersioning = {
|
||||||
[pluginName in string]?: PluginVersion | string
|
[pluginName in string]?: PluginVersion | string
|
||||||
@@ -45,9 +44,6 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
|
|||||||
super("PluginManager")
|
super("PluginManager")
|
||||||
this.cacheDir = path.join(this.conf.installDir, '.cache')
|
this.cacheDir = path.join(this.conf.installDir, '.cache')
|
||||||
this.initialize()
|
this.initialize()
|
||||||
|
|
||||||
//this.installPlugin("ApiClient")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultConfig(): PluginManagerConfig&PluginVersioning{
|
getDefaultConfig(): PluginManagerConfig&PluginVersioning{
|
||||||
@@ -108,26 +104,40 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
|
|||||||
file.on('error', err => {throw new Error(err)})
|
file.on('error', err => {throw new Error(err)})
|
||||||
const response = await fetch(url)
|
const response = await fetch(url)
|
||||||
if (!response.ok) throw new Error(response.statusText)
|
if (!response.ok) throw new Error(response.statusText)
|
||||||
response.body.pipe(file)
|
await response.body.pipe(file)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error)
|
logger.error(error)
|
||||||
await fs.promises.unlink(dest)
|
await fs.promises.unlink(dest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async getLatestRelease(pluginName:string):Promise<any>{
|
||||||
|
logger.info("Downloading Plugin", pluginName)
|
||||||
|
if(pluginName === this.name) pluginName = "admin"
|
||||||
|
logger.error(this.conf.resourceLocation + pluginName + '/releases')
|
||||||
|
const response = await fetch(this.conf.resourceLocation + pluginName + '/releases')
|
||||||
|
if (!response.ok) throw new Error(pluginName+": "+response.statusText)
|
||||||
|
|
||||||
|
const releases = await response.json()
|
||||||
|
if (!releases || !releases.length) throw new Error('Empty response')
|
||||||
|
|
||||||
|
return releases[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getLatestVersion(pluginName:string):Promise<SemVer>{
|
||||||
|
const latest = await this.getLatestRelease(pluginName)
|
||||||
|
const version = latest.tag_name
|
||||||
|
return parse(version)!
|
||||||
|
}
|
||||||
|
|
||||||
private async downloadPlugin(pluginName: string) {
|
private async downloadPlugin(pluginName: string) {
|
||||||
try {
|
try {
|
||||||
logger.info("Downloading Plugin", pluginName)
|
let version = await this.getLatestVersion(pluginName)
|
||||||
if(pluginName === this.name) pluginName = "admin"
|
|
||||||
logger.error(this.conf.resourceLocation + pluginName + '/releases')
|
|
||||||
const response = await fetch(this.conf.resourceLocation + pluginName + '/releases')
|
|
||||||
if (!response.ok) throw new Error(pluginName+": "+response.statusText)
|
|
||||||
|
|
||||||
const releases = await response.json()
|
if(this.conf[pluginName] != null && version == this.conf[pluginName]!["installed"]){
|
||||||
if (!releases || !releases.length) throw new Error('Empty response')
|
return
|
||||||
|
}
|
||||||
const latest = releases[0]
|
const latest = await this.getLatestRelease(pluginName)
|
||||||
const version = latest.tag_name
|
|
||||||
const archiveURL = latest.assets.filter(asset => asset.name === 'plugin.zip')[0].browser_download_url
|
const archiveURL = latest.assets.filter(asset => asset.name === 'plugin.zip')[0].browser_download_url
|
||||||
const checksumURL = latest.assets.filter(asset => asset.name === 'md5sum.txt')[0].browser_download_url
|
const checksumURL = latest.assets.filter(asset => asset.name === 'md5sum.txt')[0].browser_download_url
|
||||||
if (!version || ! archiveURL || !checksumURL) throw new Error('Malformed response')
|
if (!version || ! archiveURL || !checksumURL) throw new Error('Malformed response')
|
||||||
@@ -141,6 +151,13 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
|
|||||||
await this.downloadFile(archiveURL, path.join(this.cacheDir, pluginName, 'plugin.zip'))
|
await this.downloadFile(archiveURL, path.join(this.cacheDir, pluginName, 'plugin.zip'))
|
||||||
await this.downloadFile(checksumURL, path.join(this.cacheDir, pluginName, 'md5sum.txt'))
|
await this.downloadFile(checksumURL, path.join(this.cacheDir, pluginName, 'md5sum.txt'))
|
||||||
|
|
||||||
|
if(this.conf[pluginName] == null){
|
||||||
|
this.conf[pluginName] = {}
|
||||||
|
}
|
||||||
|
this.conf[pluginName]!["cached"] = version
|
||||||
|
this.updateConfig(this.conf)
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error)
|
logger.error(error)
|
||||||
}
|
}
|
||||||
@@ -151,12 +168,22 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
|
|||||||
const archivePath = path.join(this.cacheDir, pluginName, "plugin.zip")
|
const archivePath = path.join(this.cacheDir, pluginName, "plugin.zip")
|
||||||
const outputPath = path.join(this.conf.installDir,pluginName)
|
const outputPath = path.join(this.conf.installDir,pluginName)
|
||||||
await fs.createReadStream(archivePath).pipe(unzip.Extract({ path: outputPath }));
|
await fs.createReadStream(archivePath).pipe(unzip.Extract({ path: outputPath }));
|
||||||
|
|
||||||
|
if(this.conf[pluginName] == null){
|
||||||
|
this.conf[pluginName] = {}
|
||||||
|
}
|
||||||
|
this.conf[pluginName]!["installed"] = this.conf[pluginName]!["cached"]
|
||||||
|
this.updateConfig(this.conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async installPlugin(pluginName: string) {
|
public async installPlugin(pluginName: string) {
|
||||||
try {
|
try {
|
||||||
await this.downloadPlugin(pluginName)
|
let version = await this.getLatestVersion(pluginName)
|
||||||
await this.extractPlugin(pluginName)
|
|
||||||
|
if(this.conf[pluginName] != null || version != this.conf[pluginName]!["installed"]){
|
||||||
|
await this.downloadPlugin(pluginName)
|
||||||
|
await this.extractPlugin(pluginName)
|
||||||
|
}
|
||||||
await this.loadPlugin(pluginName)
|
await this.loadPlugin(pluginName)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error)
|
logger.error(error)
|
||||||
@@ -179,6 +206,7 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
|
|||||||
const pth = path.join("..", "..", this.conf.installDir, pluginName)
|
const pth = path.join("..", "..", this.conf.installDir, pluginName)
|
||||||
logger.info("Loading plugin from fs", pth+"/Plugin")
|
logger.info("Loading plugin from fs", pth+"/Plugin")
|
||||||
const clazz = await import(pth+"/Plugin")
|
const clazz = await import(pth+"/Plugin")
|
||||||
|
logger.warn(clazz)
|
||||||
let obj:Plugin = new clazz.default()
|
let obj:Plugin = new clazz.default()
|
||||||
await obj.start()
|
await obj.start()
|
||||||
this.loadedPlugins[pluginName] = {backend: obj, frontend: this.loadFrontend(pluginName)}
|
this.loadedPlugins[pluginName] = {backend: obj, frontend: this.loadFrontend(pluginName)}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const path = require('path');
|
|||||||
mode: 'production',
|
mode: 'production',
|
||||||
entry: path.resolve(__dirname, '../../lib/FrontblockLib.js'),
|
entry: path.resolve(__dirname, '../../lib/FrontblockLib.js'),
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, '../../../static'),
|
path: path.resolve(__dirname, '../../static'),
|
||||||
filename: 'FrontblockLib.js',
|
filename: 'FrontblockLib.js',
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
core-js@2.6.9
|
||||||
|
MIT
|
||||||
|
Copyright (c) 2014-2019 Denis Pushkarev
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
webpack@3.11.0
|
||||||
|
MIT
|
||||||
|
Copyright JS Foundation and other contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
zone.js@0.8.29
|
||||||
|
MIT
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2016-2018 Google, Inc.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
@angular/core@5.2.11
|
||||||
|
MIT
|
||||||
|
MIT
|
||||||
|
|
||||||
|
@types/systemjs@0.20.6
|
||||||
|
MIT
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
||||||
|
@angular/common@5.2.11
|
||||||
|
MIT
|
||||||
|
MIT
|
||||||
|
|
||||||
|
@angular/forms@5.2.11
|
||||||
|
MIT
|
||||||
|
MIT
|
||||||
|
|
||||||
|
@angular/animations@5.2.11
|
||||||
|
MIT
|
||||||
|
MIT
|
||||||
|
|
||||||
|
@angular/platform-browser@5.2.11
|
||||||
|
MIT
|
||||||
|
MIT
|
||||||
|
|
||||||
|
@angular/platform-browser-dynamic@5.2.11
|
||||||
|
MIT
|
||||||
|
MIT
|
||||||
|
|
||||||
|
@clr/ui@0.11.34
|
||||||
|
MIT
|
||||||
|
MIT
|
||||||
|
|
||||||
|
@angular/compiler@5.2.11
|
||||||
|
MIT
|
||||||
|
MIT
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Dashboard</title><base href="/"><script src="FrontblockLib.js"></script><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><link href="styles.0af82fb2e23d79ae864c.bundle.css" rel="stylesheet"/></head><body><app-root></app-root><script type="text/javascript" src="inline.31e1fb380eb7cf3d75b1.bundle.js"></script><script type="text/javascript" src="polyfills.f153256f53043f1cd40e.bundle.js"></script><script type="text/javascript" src="scripts.ca93a3bb56d9ffaa600d.bundle.js"></script><script type="text/javascript" src="vendor.8f5c7e43140df47ce94c.bundle.js"></script><script type="text/javascript" src="main.5bc66c61683fd03d83d2.bundle.js"></script></body></html>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
!function(r){var n=window.webpackJsonp;window.webpackJsonp=function(e,u,c){for(var f,i,p,a=0,l=[];a<e.length;a++)i=e[a],o[i]&&l.push(o[i][0]),o[i]=0;for(f in u)Object.prototype.hasOwnProperty.call(u,f)&&(r[f]=u[f]);for(n&&n(e,u,c);l.length;)l.shift()();if(c)for(a=0;a<c.length;a++)p=t(t.s=c[a]);return p};var e={},o={4:0};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=r,t.c=e,t.d=function(r,n,e){t.o(r,n)||Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:e})},t.n=function(r){var n=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(n,"a",n),n},t.o=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)},t.p="",t.oe=function(r){throw console.error(r),r}}([]);
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user