fix
This commit is contained in:
@@ -114,7 +114,6 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getLatestRelease(pluginName:string):Promise<any>{
|
private async getLatestRelease(pluginName:string):Promise<any>{
|
||||||
if(pluginName === this.name) pluginName = "admin"
|
|
||||||
const response = await fetch(this.conf.resourceLocation + pluginName + '/releases')
|
const response = await fetch(this.conf.resourceLocation + pluginName + '/releases')
|
||||||
if (!response.ok) throw new Error(pluginName+": "+response.statusText)
|
if (!response.ok) throw new Error(pluginName+": "+response.statusText)
|
||||||
|
|
||||||
@@ -125,16 +124,12 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getLatestVersion(pluginName:string):Promise<SemVer>{
|
private async getLatestVersion(pluginName:string):Promise<SemVer>{
|
||||||
if(pluginName === this.name) pluginName = "admin"
|
|
||||||
|
|
||||||
const latest = await this.getLatestRelease(pluginName)
|
const latest = await this.getLatestRelease(pluginName)
|
||||||
const version = latest.tag_name
|
const version = latest.tag_name
|
||||||
return parse(version)!
|
return parse(version)!
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadPlugin(pluginName: string) {
|
async downloadPlugin(pluginName: string) {
|
||||||
if(pluginName === this.name) pluginName = "admin"
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let version = await this.getLatestVersion(pluginName)
|
let version = await this.getLatestVersion(pluginName)
|
||||||
logger.info(version)
|
logger.info(version)
|
||||||
@@ -166,7 +161,6 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
|
|||||||
}
|
}
|
||||||
|
|
||||||
extractPlugin(pluginName: string){
|
extractPlugin(pluginName: string){
|
||||||
if(pluginName === this.name) pluginName = "admin"
|
|
||||||
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)
|
||||||
//fs.createReadStream(archivePath).pipe(unzip.Extract({ path: outputPath }));
|
//fs.createReadStream(archivePath).pipe(unzip.Extract({ path: outputPath }));
|
||||||
@@ -182,8 +176,6 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async installPlugin(pluginName: string) {
|
public async installPlugin(pluginName: string) {
|
||||||
if(pluginName === this.name) pluginName = "admin"
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let version = await this.getLatestVersion(pluginName)
|
let version = await this.getLatestVersion(pluginName)
|
||||||
|
|
||||||
@@ -209,7 +201,6 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
|
|||||||
|
|
||||||
|
|
||||||
public async loadPlugin(pluginName:string) {
|
public async loadPlugin(pluginName:string) {
|
||||||
if(pluginName === this.name) pluginName = "admin"
|
|
||||||
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")
|
||||||
@@ -220,7 +211,6 @@ export default class PluginManager extends ConfigLoader<PluginManagerConfig&Plug
|
|||||||
}
|
}
|
||||||
|
|
||||||
public loadFrontend(pluginName:string){
|
public loadFrontend(pluginName:string){
|
||||||
if(pluginName === this.name) pluginName = "admin"
|
|
||||||
const pth = path.join("..", "..", this.conf.installDir, pluginName)
|
const pth = path.join("..", "..", this.conf.installDir, pluginName)
|
||||||
logger.info("Loading frontend plugin from fs", path.join(__dirname,pth,"FrontendPlugin.js"))
|
logger.info("Loading frontend plugin from fs", path.join(__dirname,pth,"FrontendPlugin.js"))
|
||||||
return fs.readFileSync(path.join(__dirname, pth,"FrontendPlugin.js")).toString()
|
return fs.readFileSync(path.join(__dirname, pth,"FrontendPlugin.js")).toString()
|
||||||
|
|||||||
Reference in New Issue
Block a user