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