From 6601b4bf2fbc0287d80356980648e3d7b2acb0b8 Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 3 Aug 2019 22:40:15 +0200 Subject: [PATCH] fix --- package.json | 2 +- src/backend/FrontblockAdmin.ts | 2 +- src/backend/PluginManager/Plugin.ts | 5 +- src/backend/PluginManager/PluginManager.ts | 64 ++++++--- src/backend/webpack.prod.js | 2 +- src/frontend/static/3rdpartylicenses.txt | 124 ++++++++++++++++++ src/frontend/static/favicon.ico | Bin 0 -> 5430 bytes src/frontend/static/index.html | 1 + .../inline.31e1fb380eb7cf3d75b1.bundle.js | 1 + .../main.5bc66c61683fd03d83d2.bundle.js | 1 + .../polyfills.f153256f53043f1cd40e.bundle.js | 1 + .../scripts.ca93a3bb56d9ffaa600d.bundle.js | 1 + .../styles.0af82fb2e23d79ae864c.bundle.css | 8 ++ .../vendor.8f5c7e43140df47ce94c.bundle.js | 1 + 14 files changed, 188 insertions(+), 25 deletions(-) create mode 100644 src/frontend/static/3rdpartylicenses.txt create mode 100644 src/frontend/static/favicon.ico create mode 100644 src/frontend/static/index.html create mode 100644 src/frontend/static/inline.31e1fb380eb7cf3d75b1.bundle.js create mode 100644 src/frontend/static/main.5bc66c61683fd03d83d2.bundle.js create mode 100644 src/frontend/static/polyfills.f153256f53043f1cd40e.bundle.js create mode 100644 src/frontend/static/scripts.ca93a3bb56d9ffaa600d.bundle.js create mode 100644 src/frontend/static/styles.0af82fb2e23d79ae864c.bundle.css create mode 100644 src/frontend/static/vendor.8f5c7e43140df47ce94c.bundle.js diff --git a/package.json b/package.json index 65a188f..b97eb38 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "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-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", "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" diff --git a/src/backend/FrontblockAdmin.ts b/src/backend/FrontblockAdmin.ts index 541e56d..990fef4 100644 --- a/src/backend/FrontblockAdmin.ts +++ b/src/backend/FrontblockAdmin.ts @@ -3,7 +3,7 @@ import * as Logger from 'log4js' import { Plugin, socketioRPC, ConfigLoader } from 'frontblock-generic/Plugin'; import { ErrorResponse, SuccessResponse } from 'frontblock-generic/Types'; -import { PluginManagerPlugin } from './PluginManager/Plugin' +import { default as PluginManagerPlugin } from './PluginManager/Plugin' import express = require('express'); import http = require('http'); import bsock = require('bsock'); diff --git a/src/backend/PluginManager/Plugin.ts b/src/backend/PluginManager/Plugin.ts index 5830f1d..88f7b22 100644 --- a/src/backend/PluginManager/Plugin.ts +++ b/src/backend/PluginManager/Plugin.ts @@ -17,12 +17,9 @@ const logger = Logger.getLogger("PluginManager/Plugin") export default class PluginManagerPlugin extends PluginManager implements Plugin{ - name: string; constructor(){ super() - - this.installPlugin(this.name) } exportRPCs(): import("frontblock-generic/Plugin").socketioRPC[] { @@ -83,7 +80,7 @@ export default class PluginManagerPlugin extends PluginManager implements Plugin } async start(): Promise { - await this.installPlugin("admin") //self-update + await this.loadPlugin("admin") } stop(): void { diff --git a/src/backend/PluginManager/PluginManager.ts b/src/backend/PluginManager/PluginManager.ts index c8a2ec4..b7d8108 100644 --- a/src/backend/PluginManager/PluginManager.ts +++ b/src/backend/PluginManager/PluginManager.ts @@ -6,7 +6,7 @@ import fs = require('fs'); import path = require('path') import unzip = require('unzip') import { Plugin, ConfigLoader } from 'frontblock-generic/Plugin'; -import { SemVer } from "semver"; +import { SemVer, parse } from "semver"; Logger.configure({ appenders: @@ -24,7 +24,6 @@ const logger = Logger.getLogger("PluginManager") type PluginVersion = { installed?: SemVer, cached?: SemVer, - loaded?: SemVer } export type PluginVersioning = { [pluginName in string]?: PluginVersion | string @@ -45,9 +44,6 @@ export default class PluginManager extends ConfigLoader {throw new Error(err)}) const response = await fetch(url) if (!response.ok) throw new Error(response.statusText) - response.body.pipe(file) + await response.body.pipe(file) } catch (error) { logger.error(error) await fs.promises.unlink(dest) } } + private async getLatestRelease(pluginName:string):Promise{ + 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{ + const latest = await this.getLatestRelease(pluginName) + const version = latest.tag_name + return parse(version)! + } + private async downloadPlugin(pluginName: string) { try { - 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) + let version = await this.getLatestVersion(pluginName) - const releases = await response.json() - if (!releases || !releases.length) throw new Error('Empty response') - - const latest = releases[0] - const version = latest.tag_name + 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') @@ -141,6 +151,13 @@ export default class PluginManager extends ConfigLoader}`90e12m8T*36WoeDLA&SD_hw{H^wM!cl_RWcVA!I+x87ee975; z@4kD^=bYPn&pmG@(+JZ`rqQEKxW<}RzhW}I!|ulN=fmjVi@x{p$cC`)5$a!)X&U+blKNvN5tg=uLvuLnuqRM;Yc*swiexs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FGkXwcNv8GBcZI#@Y2m{RNF_w8(Z%^A*!bS*!}s6sh*NnURytky humW;*g7R+&|Ledvc-Dashboard \ No newline at end of file diff --git a/src/frontend/static/inline.31e1fb380eb7cf3d75b1.bundle.js b/src/frontend/static/inline.31e1fb380eb7cf3d75b1.bundle.js new file mode 100644 index 0000000..6e4ec34 --- /dev/null +++ b/src/frontend/static/inline.31e1fb380eb7cf3d75b1.bundle.js @@ -0,0 +1 @@ +!function(r){var n=window.webpackJsonp;window.webpackJsonp=function(e,u,c){for(var f,i,p,a=0,l=[];a\n
\n \n
\n\n
\n
\n \n
\n
\n\n'},Jnfr:function(e,t){function n(e){return Promise.resolve().then(function(){throw new Error("Cannot find module '"+e+"'.")})}n.keys=function(){return[]},n.resolve=n,e.exports=n,n.id="Jnfr"},Zhnu:function(e,t){e.exports=""},gs3p:function(e,t){e.exports='
\n
\n
\n'},okgc:function(e,t){e.exports=""},x35b:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n("WT6e"),r=n("4PVY"),i=n("OE0E"),c=n("ItHS"),a=this&&this.__decorate||function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c},s=function(){function e(){}return e=a([Object(o.Component)({selector:"app-root",template:n("5xMp"),styles:[n("okgc")]})],e)}(),l=n("Xjw4"),u=n("7DMc"),f=n("WPXp"),p=this&&this.__decorate||function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c},d=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},h=function(){function e(){}return e.prototype.getWidgetConfigs=function(){return fb.PluginManager.getLoadedPluginNames()},e=p([Object(o.Injectable)(),d("design:paramtypes",[])],e)}(),y=this&&this.__decorate||function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c},m=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},g=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function c(e){try{s(o.next(e))}catch(e){i(e)}}function a(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){e.done?r(e.value):new n(function(t){t(e.value)}).then(c,a)}s((o=o.apply(e,t||[])).next())})},b=this&&this.__generator||function(e,t){var n,o,r,i,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,o&&(r=o[2&i[0]?"return":i[0]?"throw":"next"])&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[0,r.value]),i[0]){case 0:case 1:r=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,o=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]=0;a--)(r=e[a])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c},w=function(){function e(){}return e=S([Object(o.NgModule)({imports:[l.CommonModule],declarations:[v],providers:[h],exports:[v]})],e)}(),j=this&&this.__decorate||function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c};function O(e){return e.createCompiler()}var R=function(){function e(){}return e=j([Object(o.NgModule)({declarations:[s],imports:[i.BrowserModule,c.HttpClientModule,w],providers:[{provide:o.COMPILER_OPTIONS,useValue:{},multi:!0},{provide:o.CompilerFactory,useClass:r.JitCompilerFactory,deps:[o.COMPILER_OPTIONS]},{provide:o.Compiler,useFactory:O,deps:[o.CompilerFactory]}],bootstrap:[s]})],e)}();Object(o.enableProdMode)(),Object(r.platformBrowserDynamic)().bootstrapModule(R).catch(function(e){return console.log(e)})}},[0]); \ No newline at end of file diff --git a/src/frontend/static/polyfills.f153256f53043f1cd40e.bundle.js b/src/frontend/static/polyfills.f153256f53043f1cd40e.bundle.js new file mode 100644 index 0000000..a225c65 --- /dev/null +++ b/src/frontend/static/polyfills.f153256f53043f1cd40e.bundle.js @@ -0,0 +1 @@ +webpackJsonp([0],{"/whu":function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},"0Rih":function(e,t,n){"use strict";var r=n("OzIq"),o=n("Ds5P"),i=n("R3AP"),a=n("A16L"),c=n("1aA0"),u=n("vmSO"),s=n("9GpA"),l=n("UKM+"),f=n("zgIt"),p=n("qkyc"),h=n("yYvK"),v=n("kic5");e.exports=function(e,t,n,d,y,g){var k=r[e],_=k,m=y?"set":"add",b=_&&_.prototype,w={},T=function(e){var t=b[e];i(b,e,"delete"==e?function(e){return!(g&&!l(e))&&t.call(this,0===e?0:e)}:"has"==e?function(e){return!(g&&!l(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return g&&!l(e)?void 0:t.call(this,0===e?0:e)}:"add"==e?function(e){return t.call(this,0===e?0:e),this}:function(e,n){return t.call(this,0===e?0:e,n),this})};if("function"==typeof _&&(g||b.forEach&&!f(function(){(new _).entries().next()}))){var O=new _,E=O[m](g?{}:-0,1)!=O,S=f(function(){O.has(1)}),x=p(function(e){new _(e)}),D=!g&&f(function(){for(var e=new _,t=5;t--;)e[m](t,t);return!e.has(-0)});x||((_=t(function(t,n){s(t,_,e);var r=v(new k,t,_);return void 0!=n&&u(n,y,r[m],r),r})).prototype=b,b.constructor=_),(S||D)&&(T("delete"),T("has"),y&&T("get")),(D||E)&&T(m),g&&b.clear&&delete b.clear}else _=d.getConstructor(t,e,y,m),a(_.prototype,n),c.NEED=!0;return h(_,e),w[e]=_,o(o.G+o.W+o.F*(_!=k),w),g||d.setStrong(_,e,y),_}},1:function(e,t,n){e.exports=n("XS25")},"1aA0":function(e,t,n){var r=n("ulTY")("meta"),o=n("UKM+"),i=n("WBcL"),a=n("lDLk").f,c=0,u=Object.isExtensible||function(){return!0},s=!n("zgIt")(function(){return u(Object.preventExtensions({}))}),l=function(e){a(e,r,{value:{i:"O"+ ++c,w:{}}})},f=e.exports={KEY:r,NEED:!1,fastKey:function(e,t){if(!o(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!i(e,r)){if(!u(e))return"F";if(!t)return"E";l(e)}return e[r].i},getWeak:function(e,t){if(!i(e,r)){if(!u(e))return!0;if(!t)return!1;l(e)}return e[r].w},onFreeze:function(e){return s&&f.NEED&&u(e)&&!i(e,r)&&l(e),e}}},"2p1q":function(e,t,n){var r=n("lDLk"),o=n("fU25");e.exports=n("bUqO")?function(e,t,n){return r.f(e,t,o(1,n))}:function(e,t,n){return e[t]=n,e}},"3q4u":function(e,t,n){var r=n("wCso"),o=n("DIVP"),i=r.key,a=r.map,c=r.store;r.exp({deleteMetadata:function(e,t){var n=arguments.length<3?void 0:i(arguments[2]),r=a(o(t),n,!1);if(void 0===r||!r.delete(e))return!1;if(r.size)return!0;var u=c.get(t);return u.delete(n),!!u.size||c.delete(t)}})},"73qY":function(e,t,n){e.exports=n("VWgF")("native-function-to-string",Function.toString)},"7gX0":function(e,t){var n=e.exports={version:"2.6.9"};"number"==typeof __e&&(__e=n)},"7ylX":function(e,t,n){var r=n("DIVP"),o=n("twxM"),i=n("QKXm"),a=n("mZON")("IE_PROTO"),c=function(){},u=function(){var e,t=n("jhxf")("iframe"),r=i.length;for(t.style.display="none",n("d075").appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("