cleanup
This commit is contained in:
+27
-22
@@ -4,28 +4,13 @@ import { FolderStatus } from "upgiter/js/src/Types";
|
|||||||
import { Plugin } from "./Plugin";
|
import { Plugin } from "./Plugin";
|
||||||
import { FrontworkAdmin } from "./Admin";
|
import { FrontworkAdmin } from "./Admin";
|
||||||
|
|
||||||
export type PluginLoaderIfc = {
|
class PluginLoader {
|
||||||
PluginLoader: {
|
|
||||||
installPlugin: (name:string, force:boolean) => Promise<FolderStatus>
|
|
||||||
startPlugin: (name:string) => Promise<boolean>
|
|
||||||
updatePlugin: (name:string) => Promise<boolean>
|
|
||||||
setPluginVersion: (name:string, tag:string) => Promise<FolderStatus>
|
|
||||||
getLoadedPluginNames: () => Promise<String[]>
|
|
||||||
selfUpdate: (force:boolean) => Promise<FolderStatus>
|
|
||||||
destroy: () => Promise<void>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class PluginLoader
|
|
||||||
implements RPCExporter<PluginLoaderIfc, "PluginLoader">{
|
|
||||||
|
|
||||||
name = "PluginLoader" as "PluginLoader";
|
|
||||||
private runningPlugins: Plugin[]
|
private runningPlugins: Plugin[]
|
||||||
private pluginUpdaters:{[name in string]:Git.Updater} = {}
|
private pluginUpdaters:{[name in string]:Git.Updater} = {}
|
||||||
|
|
||||||
constructor(private admin:FrontworkAdmin){}
|
constructor(private admin:FrontworkAdmin){}
|
||||||
|
|
||||||
private async selfUpdate(force:boolean = false){
|
async selfUpdate(force:boolean = false){
|
||||||
const updater = new Git.Updater({
|
const updater = new Git.Updater({
|
||||||
schema: 'https',
|
schema: 'https',
|
||||||
localPath: './dist',
|
localPath: './dist',
|
||||||
@@ -39,7 +24,7 @@ implements RPCExporter<PluginLoaderIfc, "PluginLoader">{
|
|||||||
//logger.warn("Cloning fb-dist/admin into ./dist ..."+(force?" USING FORCE!":""))
|
//logger.warn("Cloning fb-dist/admin into ./dist ..."+(force?" USING FORCE!":""))
|
||||||
status = await updater.cloneRepo(force)
|
status = await updater.cloneRepo(force)
|
||||||
|
|
||||||
//this.destroy()
|
this.destroy()
|
||||||
const installer = eval("require")("./Installer").installAdmin
|
const installer = eval("require")("./Installer").installAdmin
|
||||||
installer(this.getPlugins())
|
installer(this.getPlugins())
|
||||||
}
|
}
|
||||||
@@ -55,7 +40,6 @@ implements RPCExporter<PluginLoaderIfc, "PluginLoader">{
|
|||||||
remotePath: 'frontwork-distribution',
|
remotePath: 'frontwork-distribution',
|
||||||
repoName: name
|
repoName: name
|
||||||
})
|
})
|
||||||
//new GitUpdater("./plugins/"+name)
|
|
||||||
const status = await this.pluginUpdaters[name].cloneRepo(force)
|
const status = await this.pluginUpdaters[name].cloneRepo(force)
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
@@ -79,8 +63,8 @@ implements RPCExporter<PluginLoaderIfc, "PluginLoader">{
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let str = "../plugins/"+name+"/Plugin"
|
let evalstr = "../plugins/"+name+"/Plugin"
|
||||||
const pluginClass = await eval('require')(str)
|
const pluginClass = await eval('require')(evalstr)
|
||||||
const pluginObj = new pluginClass.default(this)
|
const pluginObj = new pluginClass.default(this)
|
||||||
try{
|
try{
|
||||||
if(pluginObj.start)
|
if(pluginObj.start)
|
||||||
@@ -142,10 +126,31 @@ implements RPCExporter<PluginLoaderIfc, "PluginLoader">{
|
|||||||
return [...this.runningPlugins]
|
return [...this.runningPlugins]
|
||||||
}
|
}
|
||||||
|
|
||||||
private async destroy(){
|
async destroy(){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type PluginLoaderIfc = {
|
||||||
|
PluginLoader: {
|
||||||
|
installPlugin: (name:string, force:boolean) => Promise<FolderStatus>
|
||||||
|
startPlugin: (name:string) => Promise<boolean>
|
||||||
|
updatePlugin: (name:string) => Promise<boolean>
|
||||||
|
setPluginVersion: (name:string, tag:string) => Promise<FolderStatus>
|
||||||
|
getLoadedPluginNames: () => Promise<String[]>
|
||||||
|
selfUpdate: (force:boolean) => Promise<FolderStatus>
|
||||||
|
destroy: () => Promise<void>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RPCPluginLoader
|
||||||
|
extends PluginLoader
|
||||||
|
implements RPCExporter<PluginLoaderIfc, "PluginLoader">{
|
||||||
|
|
||||||
|
name = "PluginLoader" as "PluginLoader";
|
||||||
|
|
||||||
exportRPCs(){
|
exportRPCs(){
|
||||||
return [{
|
return [{
|
||||||
name: "installPlugin" as "installPlugin",
|
name: "installPlugin" as "installPlugin",
|
||||||
|
|||||||
Reference in New Issue
Block a user