This commit is contained in:
peter
2019-08-04 00:57:23 +02:00
parent 6601b4bf2f
commit 6aae2146e9
14 changed files with 90 additions and 171 deletions
+40
View File
@@ -889,6 +889,11 @@
"integrity": "sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==",
"dev": true
},
"adm-zip": {
"version": "0.4.13",
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.13.tgz",
"integrity": "sha512-fERNJX8sOXfel6qCBCMPvZLzENBEhZTzKqg6vrOW5pvoEaQuJhRU4ndTAh6lHOxn1I6jnz2NHra56ZODM751uw=="
},
"after": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz",
@@ -1758,6 +1763,11 @@
}
}
},
"buffer-crc32": {
"version": "0.2.13",
"resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
"integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI="
},
"buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
@@ -3023,6 +3033,14 @@
}
}
},
"easy-unzip": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/easy-unzip/-/easy-unzip-1.1.0.tgz",
"integrity": "sha512-Nxsq0eh1Tn22UFPrqDM+VNdkAdZFoAjN8NTOOPzGXxqXoNxB5jCYu9/s3uOM6BFeshF/oTI/LYmOlLp0h5QKiA==",
"requires": {
"yauzl": "^2.10.0"
}
},
"ecc-jsbn": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
@@ -3575,6 +3593,14 @@
"bser": "^2.0.0"
}
},
"fd-slicer": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
"integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=",
"requires": {
"pend": "~1.2.0"
}
},
"figgy-pudding": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.1.tgz",
@@ -7641,6 +7667,11 @@
"sha.js": "^2.4.8"
}
},
"pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA="
},
"performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
@@ -11463,6 +11494,15 @@
"decamelize": "^1.2.0"
}
},
"yauzl": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
"integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=",
"requires": {
"buffer-crc32": "~0.2.3",
"fd-slicer": "~1.1.0"
}
},
"yeast": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",
+4 -2
View File
@@ -8,8 +8,8 @@
"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-dashboard": "cd src/frontend/dashboard; npm i; npm run build; cp -r dist/* ../../../static",
"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",
"build-widget": "rollup -c src/frontend/widget/rollup.config.js; mkdir -p plugins/admin; cp FrontendPlugin.js plugins/admin",
"clean": "rm -rf lib static plugins kfs dist widget .rpt2_cache *.js *.ts; rm -rf src/frontend/dashboard/dist",
"update-frontblock": "rm -rf node_modules/frontblock*; npm install"
},
"repository": {
@@ -23,11 +23,13 @@
"@angular/core": "^5.2.2",
"@types/node": "^11.13.10",
"@uirouter/angularjs": "^1.0.5",
"adm-zip": "^0.4.13",
"angular": "^1.7.8",
"bip39": "^3.0.2",
"bitcoinjs-lib": "^5.0.4",
"bsert": "0.0.10",
"bsock": "^0.1.9",
"easy-unzip": "^1.1.0",
"express": "^4.16.4",
"frontblock-generic": "latest",
"hdkey": "^1.1.1",
+13 -1
View File
@@ -20,6 +20,8 @@ export default class PluginManagerPlugin extends PluginManager implements Plugin
constructor(){
super()
this.loadedPlugins[this.name] = {backend: this, frontend: this.loadFrontend(this.name)}
}
exportRPCs(): import("frontblock-generic/Plugin").socketioRPC[] {
@@ -75,12 +77,22 @@ export default class PluginManagerPlugin extends PluginManager implements Plugin
visibility: "private",
rpc: async(conf) => { return this.updateConfig(conf) },
type: 'call'
},{
name: "extractPlugin",
visibility: "private",
rpc: async(conf) => { return this.extractPlugin(conf) },
type: 'call'
},{
name: "downloadPlugin",
visibility: "private",
rpc: async(conf) => { return this.downloadPlugin(conf) },
type: 'call'
}
]
}
async start(): Promise<void> {
await this.loadPlugin("admin")
}
stop(): void {
+31 -28
View File
@@ -5,8 +5,11 @@ import fetch = require('node-fetch');
import fs = require('fs');
import path = require('path')
import unzip = require('unzip')
import easyunzip = require('easy-unzip')
import { Plugin, ConfigLoader } from 'frontblock-generic/Plugin';
import { SemVer, parse } from "semver";
import { once } from 'events';
Logger.configure({
appenders:
@@ -20,6 +23,7 @@ Logger.configure({
}
})
const logger = Logger.getLogger("PluginManager")
const AdmZip = require('adm-zip');
type PluginVersion = {
installed?: SemVer,
@@ -55,16 +59,11 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
logger.info('Initializing manager')
try {
fs.access(this.cacheDir, err => {
if (err && err.code === 'ENOENT') {
fs.mkdirSync(this.cacheDir, {recursive: true})
logger.info('Manager installed to ' + this.conf.installDir)
} else {
logger.info('Manager already installed at ' + this.conf.installDir)
}
})
fs.accessSync(this.cacheDir)
logger.info('Manager already installed at ' + this.conf.installDir)
} catch (error) {
logger.error(error)
fs.mkdirSync(this.cacheDir, {recursive: true})
logger.info('Manager installed to ' + this.cacheDir)
}
}
@@ -79,12 +78,12 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
]
}
public async getInstalledPlugins(): Promise<string[]> {
public getInstalledPlugins():string[] {
try {
const installed = await fs.promises.readdir(this.conf.installDir)
const installed = fs.readdirSync(this.conf.installDir)
return installed.filter( entry => entry[0] != '.')
} catch (error) {
logger.error(error)
logger.error("getInstalledPlugins", error)
throw error
}
}
@@ -104,17 +103,18 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
file.on('error', err => {throw new Error(err)})
const response = await fetch(url)
if (!response.ok) throw new Error(response.statusText)
await response.body.pipe(file)
response.body.pipe(file)
await once(file, 'finish');
} catch (error) {
logger.error(error)
logger.error("downloadFile", error)
await fs.promises.unlink(dest)
}
}
private async getLatestRelease(pluginName:string):Promise<any>{
logger.info("Downloading Plugin", pluginName)
logger.info("Downloading Plugin", pluginName, "from", this.conf.resourceLocation + pluginName + '/releases')
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)
@@ -130,23 +130,20 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
return parse(version)!
}
private async downloadPlugin(pluginName: string) {
async downloadPlugin(pluginName: string) {
try {
let version = await this.getLatestVersion(pluginName)
if(this.conf[pluginName] != null && version == this.conf[pluginName]!["installed"]){
return
}
const latest = await this.getLatestRelease(pluginName)
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
if (!version || ! archiveURL || !checksumURL) throw new Error('Malformed response')
await fs.access(path.join(this.cacheDir, pluginName), err => {
if (err && err.code === 'ENOENT') {
fs.mkdirSync(path.join(this.cacheDir, pluginName), {recursive: true})
}
})
fs.mkdirSync(path.join(this.cacheDir, pluginName), {recursive: true})
await this.downloadFile(archiveURL, path.join(this.cacheDir, pluginName, 'plugin.zip'))
await this.downloadFile(checksumURL, path.join(this.cacheDir, pluginName, 'md5sum.txt'))
@@ -159,15 +156,18 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
} catch (error) {
logger.error(error)
logger.error("downloadPlugin", error)
}
}
private async extractPlugin(pluginName: string){
extractPlugin(pluginName: string){
if(pluginName === this.name) pluginName = "admin"
const archivePath = path.join(this.cacheDir, pluginName, "plugin.zip")
const outputPath = path.join(this.conf.installDir,pluginName)
await fs.createReadStream(archivePath).pipe(unzip.Extract({ path: outputPath }));
//fs.createReadStream(archivePath).pipe(unzip.Extract({ path: outputPath }));
var zip = new AdmZip(archivePath);
fs.mkdirSync(outputPath, {recursive: true})
zip.extractAllTo(outputPath, true);
if(this.conf[pluginName] == null){
this.conf[pluginName] = {}
@@ -177,16 +177,18 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
}
public async installPlugin(pluginName: string) {
if(pluginName === this.name) pluginName = "admin"
try {
let version = await this.getLatestVersion(pluginName)
if(this.conf[pluginName] != null || version != this.conf[pluginName]!["installed"]){
if(this.conf[pluginName] == null || version != this.conf[pluginName]!["installed"]){
await this.downloadPlugin(pluginName)
await this.extractPlugin(pluginName)
this.extractPlugin(pluginName)
}
await this.loadPlugin(pluginName)
} catch (error) {
logger.error(error)
logger.error("installPlugin", error)
}
}
@@ -213,6 +215,7 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
}
public loadFrontend(pluginName:string){
if(pluginName === this.name) pluginName = "admin"
const pth = path.join("..", "..", this.conf.installDir, pluginName)
logger.info("Loading frontend plugin from fs", path.join(__dirname,pth,"FrontendPlugin.js"))
return fs.readFileSync(path.join(__dirname, pth,"FrontendPlugin.js"))
-124
View File
@@ -1,124 +0,0 @@
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.

Before

Width:  |  Height:  |  Size: 5.3 KiB

-1
View File
@@ -1 +0,0 @@
<!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>
@@ -1 +0,0 @@
!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
+2 -2
View File
@@ -1,12 +1,12 @@
import { Component, OnInit } from '@angular/core';
declare const fb
@Component({
selector: 'APICLIENT', //!!!!
selector: 'PLUGINMANAGER', //!!!!
template: `
<div class="card">
<div class="card-block">
<div class="card-title">
APICLIENT ${Object.keys(fb.ApiClient).join("<br>")}
PLUGINMANAGER <br> ${Object.keys(fb.PluginManager).join("<br>")}
</div>
<div class="card-text">
Hello World <exclamations></exclamations>