diff --git a/src/node/eejs/index.js b/src/node/eejs/index.js index 1bf29634b..31ff2c1a5 100644 --- a/src/node/eejs/index.js +++ b/src/node/eejs/index.js @@ -76,6 +76,7 @@ exports.require = (name, args, mod) => { basedir = path.dirname(mod.filename); paths = mod.paths; } + paths.push(settings.root + '/plugin_packages') const ejspath = resolve.sync(name, {paths, basedir, extensions: ['.html', '.ejs']}); diff --git a/src/package.json b/src/package.json index 534f59161..472d83343 100644 --- a/src/package.json +++ b/src/package.json @@ -49,6 +49,7 @@ "jsdom": "^23.2.0", "jsonminify": "0.4.2", "languages4translatewiki": "0.1.3", + "live-plugin-manager": "^0.18.1", "lodash.clonedeep": "4.5.0", "log4js": "^6.9.1", "measured-core": "^2.0.0", @@ -56,7 +57,6 @@ "npm": "^6.14.18", "openapi-backend": "^5.10.5", "proxy-addr": "^2.0.7", - "live-plugin-manager": "^0.18.1", "rate-limiter-flexible": "^4.0.0", "rehype": "^13.0.1", "rehype-minify-whitespace": "^6.0.0", diff --git a/src/static/js/pluginfw/installer.js b/src/static/js/pluginfw/installer.js index 618e5ae50..b04964feb 100644 --- a/src/static/js/pluginfw/installer.js +++ b/src/static/js/pluginfw/installer.js @@ -37,16 +37,7 @@ const wrapTaskCb = (cb) => { exports.uninstall = async (pluginName, cb = null) => { cb = wrapTaskCb(cb); logger.info(`Uninstalling plugin ${pluginName}...`); - try { - // The --no-save flag prevents npm from creating package.json or package-lock.json. - // The --legacy-peer-deps flag is required to work around a bug in npm v7: - // https://github.com/npm/cli/issues/2199 - await runCmd(['npm', 'uninstall', '--no-save', '--legacy-peer-deps', pluginName]); - } catch (err) { - logger.error(`Failed to uninstall plugin ${pluginName}`); - cb(err || new Error(err)); - throw err; - } + await exports.manager.uninstall(pluginName); logger.info(`Successfully uninstalled plugin ${pluginName}`); await hooks.aCallAll('pluginUninstall', {pluginName}); await plugins.update(); @@ -56,16 +47,7 @@ exports.uninstall = async (pluginName, cb = null) => { exports.install = async (pluginName, cb = null) => { cb = wrapTaskCb(cb); logger.info(`Installing plugin ${pluginName}...`); - try { - // The --no-save flag prevents npm from creating package.json or package-lock.json. - // The --legacy-peer-deps flag is required to work around a bug in npm v7: - // https://github.com/npm/cli/issues/2199 - await runCmd(['npm', 'install', '--no-save', '--legacy-peer-deps', pluginName]); - } catch (err) { - logger.error(`Failed to install plugin ${pluginName}`); - cb(err || new Error(err)); - throw err; - } + await exports.manager.install(pluginName); logger.info(`Successfully installed plugin ${pluginName}`); await hooks.aCallAll('pluginInstall', {pluginName}); await plugins.update(); diff --git a/src/static/js/pluginfw/plugins.js b/src/static/js/pluginfw/plugins.js index e8b7cb326..d35d8c97a 100644 --- a/src/static/js/pluginfw/plugins.js +++ b/src/static/js/pluginfw/plugins.js @@ -84,6 +84,8 @@ exports.pathNormalization = (part, hookFnName, hookName) => { }; exports.update = async () => { + await manager.install('ep_bookmark') + await manager.install('ep_align') const packages = await exports.getPackages(); const parts = {}; // Key is full name. sortParts converts this into a topologically sorted array. const plugins = {}; @@ -107,6 +109,13 @@ exports.update = async () => { exports.getPackages = async () => { logger.info('Running npm to get a list of installed plugins...'); + let plugins = manager.list() + let newDependencies = {} + for (const plugin of plugins) { + plugin.realPath = await fs.realpath(plugin.location); + plugin.path = plugin.realPath; + newDependencies[plugin.name] = plugin + } // Notes: // * Do not pass `--prod` otherwise `npm ls` will fail if there is no `package.json`. // * The `--no-production` flag is required (or the `NODE_ENV` environment variable must be @@ -121,11 +130,12 @@ exports.getPackages = async () => { } info.realPath = await fs.realpath(info.path); })); - return dependencies; + let newList = Object.assign({}, dependencies, newDependencies) + console.log('blub', newList) + return newList; }; const loadPlugin = async (packages, pluginName, plugins, parts) => { - console.log('Plugins', manager.list()); const pluginPath = path.resolve(packages[pluginName].path, 'ep.json'); try { const data = await fs.readFile(pluginPath);