Small changes to the plugin loading system
This commit is contained in:
@@ -7,6 +7,7 @@ otdebug.txt
|
||||
*/.DS_Store
|
||||
*/*/.DS_Store
|
||||
*/*/*/.DS_Store
|
||||
**/.DS_Store
|
||||
TEMP/
|
||||
.vscode/
|
||||
plugins/*
|
||||
|
||||
@@ -80,7 +80,7 @@ export class ODPlugin extends ODManagerData {
|
||||
this.crashed = false
|
||||
}
|
||||
|
||||
//Get the startfile location relative to the ./plugins/ directory
|
||||
/**Get the startfile location relative to the `./plugins/` directory. (`./dist/plugins/`) when compiled) */
|
||||
getStartFile(){
|
||||
const newFile = this.data.startFile.replace(/\.ts$/,".js")
|
||||
return nodepath.join(this.dir,newFile)
|
||||
@@ -113,6 +113,7 @@ export class ODPlugin extends ODManagerData {
|
||||
}else return true
|
||||
}
|
||||
|
||||
/**Check if a npm dependency exists. */
|
||||
#checkDependency(id:string){
|
||||
try{
|
||||
require.resolve(id)
|
||||
@@ -122,6 +123,7 @@ export class ODPlugin extends ODManagerData {
|
||||
}
|
||||
}
|
||||
|
||||
/**Get a list of all missing npm dependencies that are required for this plugin. */
|
||||
dependenciesInstalled(){
|
||||
const missing: string[] = []
|
||||
this.data.npmDependencies.forEach((d) => {
|
||||
@@ -132,6 +134,7 @@ export class ODPlugin extends ODManagerData {
|
||||
|
||||
return missing
|
||||
}
|
||||
/**Get a list of all missing plugins that are required for this plugin. */
|
||||
pluginsInstalled(manager:ODPluginManager){
|
||||
const missing: string[] = []
|
||||
this.data.requiredPlugins.forEach((p) => {
|
||||
@@ -143,6 +146,18 @@ export class ODPlugin extends ODManagerData {
|
||||
|
||||
return missing
|
||||
}
|
||||
/**Get a list of all enabled incompatible plugins that interfere with this plugin. */
|
||||
pluginsIncompatible(manager:ODPluginManager){
|
||||
const incompatible: string[] = []
|
||||
this.data.incompatiblePlugins.forEach((p) => {
|
||||
const plugin = manager.get(p)
|
||||
if (plugin && plugin.enabled){
|
||||
incompatible.push(p)
|
||||
}
|
||||
})
|
||||
|
||||
return incompatible
|
||||
}
|
||||
}
|
||||
|
||||
export class ODPluginClassManager extends ODManager<ODManagerData> {
|
||||
|
||||
@@ -91,22 +91,20 @@ export const loadAllPlugins = async () => {
|
||||
const missingDependencies: {id:string,missing:string}[] = []
|
||||
const missingPlugins: {id:string,missing:string}[] = []
|
||||
|
||||
//go trough all plugins for errors
|
||||
sortedPlugins.forEach((plugin) => {
|
||||
//go through all plugins for errors
|
||||
sortedPlugins.filter((plugin) => plugin.enabled).forEach((plugin) => {
|
||||
const from = plugin.id.value
|
||||
plugin.data.incompatiblePlugins.forEach((to) => {
|
||||
//deny incompatibility if it already exists
|
||||
if (incompatibilities.find((p) => (p.from == from && p.to == to) || (p.to == from && p.from == to))) return
|
||||
|
||||
//check for existence of both plugins => add to list
|
||||
if (openticket.plugins.exists(to)) incompatibilities.push({from,to})
|
||||
})
|
||||
plugin.dependenciesInstalled().forEach((missing) => missingDependencies.push({id:from,missing}))
|
||||
plugin.pluginsIncompatible(openticket.plugins).forEach((incompatible) => incompatibilities.push({from,to:incompatible}))
|
||||
plugin.pluginsInstalled(openticket.plugins).forEach((missing) => missingPlugins.push({id:from,missing}))
|
||||
})
|
||||
|
||||
//handle all incompatibilities
|
||||
const alreadyLoggedCompatPlugins: string[] = []
|
||||
incompatibilities.forEach((match) => {
|
||||
if (alreadyLoggedCompatPlugins.includes(match.from) || alreadyLoggedCompatPlugins.includes(match.to)) return
|
||||
else alreadyLoggedCompatPlugins.push(match.from,match.to)
|
||||
|
||||
const fromPlugin = openticket.plugins.get(match.from)
|
||||
if (fromPlugin && !fromPlugin.crashed){
|
||||
fromPlugin.crashed = true
|
||||
|
||||
@@ -737,8 +737,10 @@ const main = async () => {
|
||||
if (openticket.defaults.getDefault("startScreenRendering")){
|
||||
await openticket.startscreen.renderAllComponents()
|
||||
if (openticket.languages.getLanguageMetadata(false)?.automated){
|
||||
console.log("===================")
|
||||
openticket.log("You are currently using a language which has been translated by Google Translate!","warning")
|
||||
openticket.log("Please help us improve the translation by contributing to our project!","warning")
|
||||
console.log("===================")
|
||||
}
|
||||
|
||||
await openticket.events.get("afterStartScreensRendered").emit([openticket.startscreen])
|
||||
|
||||
Reference in New Issue
Block a user