mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-01 00:18:14 +01:00
Fix plugin scan to not include subdirs, update external plugin path env variable to DEV_PLUGINS_PATH to support a folder of dev plugins
This commit is contained in:
parent
5f680d7277
commit
7557f3e2b9
2
index.js
2
index.js
@ -14,7 +14,7 @@ if (isDev) {
|
|||||||
if (devEnv.AllowIframe) process.env.ALLOW_IFRAME = '1'
|
if (devEnv.AllowIframe) process.env.ALLOW_IFRAME = '1'
|
||||||
if (devEnv.BackupPath) process.env.BACKUP_PATH = devEnv.BackupPath
|
if (devEnv.BackupPath) process.env.BACKUP_PATH = devEnv.BackupPath
|
||||||
if (devEnv.AllowPlugins) process.env.ALLOW_PLUGINS = '1'
|
if (devEnv.AllowPlugins) process.env.ALLOW_PLUGINS = '1'
|
||||||
if (devEnv.ExternalPluginPath) process.env.EXTERNAL_PLUGIN_PATH = devEnv.ExternalPluginPath
|
if (devEnv.DevPluginsPath) process.env.DEV_PLUGINS_PATH = devEnv.DevPluginsPath
|
||||||
process.env.SOURCE = 'local'
|
process.env.SOURCE = 'local'
|
||||||
process.env.ROUTER_BASE_PATH = devEnv.RouterBasePath || ''
|
process.env.ROUTER_BASE_PATH = devEnv.RouterBasePath || ''
|
||||||
}
|
}
|
||||||
|
@ -146,31 +146,20 @@ class PluginManager {
|
|||||||
/**
|
/**
|
||||||
* Get all plugins from the /metadata/plugins directory
|
* Get all plugins from the /metadata/plugins directory
|
||||||
*/
|
*/
|
||||||
async getPluginsFromFileSystem() {
|
async getPluginsFromDirPath(pluginsPath) {
|
||||||
await fsExtra.ensureDir(this.pluginMetadataPath)
|
|
||||||
|
|
||||||
// Get all directories in the plugins directory
|
// Get all directories in the plugins directory
|
||||||
const pluginDirs = await fsExtra.readdir(this.pluginMetadataPath, { withFileTypes: true, recursive: true }).then((files) => files.filter((file) => file.isDirectory()))
|
const pluginDirs = await fsExtra.readdir(pluginsPath, { withFileTypes: true }).then((files) => files.filter((file) => file.isDirectory()))
|
||||||
|
|
||||||
const pluginsFound = []
|
const pluginsFound = []
|
||||||
for (const pluginDir of pluginDirs) {
|
for (const pluginDir of pluginDirs) {
|
||||||
Logger.debug(`[PluginManager] Checking if directory "${pluginDir.name}" is a plugin`)
|
Logger.debug(`[PluginManager] Checking if directory "${pluginDir.name}" is a plugin`)
|
||||||
const plugin = await this.loadPlugin(pluginDir.name, Path.join(this.pluginMetadataPath, pluginDir.name))
|
const plugin = await this.loadPlugin(pluginDir.name, Path.join(pluginsPath, pluginDir.name))
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
Logger.debug(`[PluginManager] Found plugin "${plugin.manifest.name}"`)
|
Logger.debug(`[PluginManager] Found plugin "${plugin.manifest.name}"`)
|
||||||
pluginsFound.push(plugin)
|
pluginsFound.push(plugin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (process.env.EXTERNAL_PLUGIN_PATH) {
|
|
||||||
const pluginName = Path.basename(process.env.EXTERNAL_PLUGIN_PATH)
|
|
||||||
const plugin = await this.loadPlugin(pluginName, process.env.EXTERNAL_PLUGIN_PATH)
|
|
||||||
if (plugin) {
|
|
||||||
Logger.debug(`[PluginManager] Found external plugin "${plugin.manifest.name}"`)
|
|
||||||
pluginsFound.push(plugin)
|
|
||||||
} else {
|
|
||||||
Logger.error(`[PluginManager] External plugin not found or invalid`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pluginsFound
|
return pluginsFound
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +167,18 @@ class PluginManager {
|
|||||||
* Load plugins from the /metadata/plugins directory and update the database
|
* Load plugins from the /metadata/plugins directory and update the database
|
||||||
*/
|
*/
|
||||||
async loadPlugins() {
|
async loadPlugins() {
|
||||||
const pluginsFound = await this.getPluginsFromFileSystem()
|
await fsExtra.ensureDir(this.pluginMetadataPath)
|
||||||
|
|
||||||
|
const pluginsFound = await this.getPluginsFromDirPath(this.pluginMetadataPath)
|
||||||
|
|
||||||
|
if (process.env.DEV_PLUGINS_PATH) {
|
||||||
|
const devPluginsFound = await this.getPluginsFromDirPath(process.env.DEV_PLUGINS_PATH)
|
||||||
|
if (!devPluginsFound.length) {
|
||||||
|
Logger.warn(`[PluginManager] No plugins found in DEV_PLUGINS_PATH: ${process.env.DEV_PLUGINS_PATH}`)
|
||||||
|
} else {
|
||||||
|
pluginsFound.push(...devPluginsFound)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const existingPlugins = await Database.pluginModel.findAll()
|
const existingPlugins = await Database.pluginModel.findAll()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user