mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
Live plugin manager (#6018)
* Added plugin live view. * Implemented PoC for managing plugins with live-plugin-manager * Add migration for plugins installed in node_modules and load plugins on start * Create installed_plugins.json even if no plugin is installed * Reload plugins and hooks after all (un)installs are done * Add installed_plugins.json to gitignore * Only write plugins to json file in Dockerfile * Install live-plugin-manager * Also persist plugin version * Do not call hooks during migration of plugins * Fix install of plugins in Dockerfile * Revert Dockerfile changes * Fixed package-lock.json --------- Co-authored-by: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Co-authored-by: Hossein M <marzban98@gmail.com>
This commit is contained in:
parent
6a2ffe6aaf
commit
9c14a4f7db
8 changed files with 357 additions and 77 deletions
|
@ -8,6 +8,8 @@ const runCmd = require('../../../node/utils/run_cmd');
|
|||
const tsort = require('./tsort');
|
||||
const pluginUtils = require('./shared');
|
||||
const defs = require('./plugin_defs');
|
||||
const {manager} = require('./installer');
|
||||
const settings = require("../../../node/utils/Settings");
|
||||
|
||||
const logger = log4js.getLogger('plugins');
|
||||
|
||||
|
@ -105,22 +107,26 @@ exports.update = async () => {
|
|||
};
|
||||
|
||||
exports.getPackages = async () => {
|
||||
logger.info('Running npm to get a list of installed plugins...');
|
||||
// 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
|
||||
// unset or set to `development`) because otherwise `npm ls` will not mention any packages
|
||||
// that are not included in `package.json` (which is expected to not exist).
|
||||
const cmd = ['npm', 'ls', '--long', '--json', '--depth=0', '--no-production'];
|
||||
const {dependencies = {}} = JSON.parse(await runCmd(cmd, {stdio: [null, 'string']}));
|
||||
await Promise.all(Object.entries(dependencies).map(async ([pkg, info]) => {
|
||||
if (!pkg.startsWith(exports.prefix)) {
|
||||
delete dependencies[pkg];
|
||||
return;
|
||||
let plugins = manager.list()
|
||||
let newDependencies = {}
|
||||
|
||||
for (const plugin of plugins) {
|
||||
if (!plugin.name.startsWith(exports.prefix)) {
|
||||
continue;
|
||||
}
|
||||
info.realPath = await fs.realpath(info.path);
|
||||
}));
|
||||
return dependencies;
|
||||
plugin.realPath = await fs.realpath(plugin.location);
|
||||
plugin.path = plugin.realPath;
|
||||
newDependencies[plugin.name] = plugin
|
||||
}
|
||||
|
||||
newDependencies['ep_etherpad-lite'] = {
|
||||
name: 'ep_etherpad-lite',
|
||||
version: settings.getEpVersion(),
|
||||
path: path.join(settings.root, 'node_modules/ep_etherpad-lite'),
|
||||
realPath: path.join(settings.root, 'src'),
|
||||
}
|
||||
|
||||
return newDependencies;
|
||||
};
|
||||
|
||||
const loadPlugin = async (packages, pluginName, plugins, parts) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue