mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 14:47:12 -04:00
Fixed plugins not being able to be loaded.
This commit is contained in:
parent
0ce10f0e39
commit
a1286cd103
3 changed files with 36 additions and 5 deletions
|
@ -29,6 +29,14 @@ fi
|
||||||
# Prepare the environment
|
# Prepare the environment
|
||||||
bin/installDeps.sh "$@" || exit 1
|
bin/installDeps.sh "$@" || exit 1
|
||||||
|
|
||||||
|
## Create the admin ui
|
||||||
|
if [ -z "$NODE_ENV" ] || [ "$NODE_ENV" = "development" ]; then
|
||||||
|
log "Creating the admin UI..."
|
||||||
|
(cd ../admin && pnpm run build)
|
||||||
|
else
|
||||||
|
log "Cannot create the admin UI in production mode"
|
||||||
|
fi
|
||||||
|
|
||||||
# Move to the node folder and start
|
# Move to the node folder and start
|
||||||
log "Starting Etherpad..."
|
log "Starting Etherpad..."
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module is started with src/bin/run.sh. It sets up a Express HTTP and a Socket.IO Server.
|
* This module is started with src/bin/run.sh. It sets up a Express HTTP and a Socket.IO Server.
|
||||||
* Static file Requests are answered directly from this module, Socket.IO messages are passed
|
* Static file Requests are answered directly from this module, Socket.IO messages are passed
|
||||||
|
@ -26,8 +24,6 @@
|
||||||
|
|
||||||
import {PluginType} from "./types/Plugin";
|
import {PluginType} from "./types/Plugin";
|
||||||
import {ErrorCaused} from "./types/ErrorCaused";
|
import {ErrorCaused} from "./types/ErrorCaused";
|
||||||
import {PromiseHooks} from "node:v8";
|
|
||||||
|
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
|
|
||||||
import {checkForMigration} from "../static/js/pluginfw/installer";
|
import {checkForMigration} from "../static/js/pluginfw/installer";
|
||||||
|
|
|
@ -22,7 +22,13 @@ const logger = log4js.getLogger('plugins');
|
||||||
export const pluginInstallPath = path.join(settings.root, 'src','plugin_packages');
|
export const pluginInstallPath = path.join(settings.root, 'src','plugin_packages');
|
||||||
|
|
||||||
export const manager = new PluginManager({
|
export const manager = new PluginManager({
|
||||||
pluginsPath: pluginInstallPath
|
pluginsPath: pluginInstallPath,
|
||||||
|
hostRequire: require,
|
||||||
|
requireCoreModules: true,
|
||||||
|
sandbox: {
|
||||||
|
env: process.env,
|
||||||
|
global: global
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const installedPluginsPath = path.join(settings.root, 'var/installed_plugins.json');
|
export const installedPluginsPath = path.join(settings.root, 'var/installed_plugins.json');
|
||||||
|
@ -77,6 +83,27 @@ const migratePluginsFromNodeModules = async () => {
|
||||||
|
|
||||||
export const checkForMigration = async () => {
|
export const checkForMigration = async () => {
|
||||||
logger.info('check installed plugins for migration');
|
logger.info('check installed plugins for migration');
|
||||||
|
const files = await fs.readdir(pluginInstallPath);
|
||||||
|
|
||||||
|
const node_modules = path.join(findEtherpadRoot(),'src', 'node_modules');
|
||||||
|
/*
|
||||||
|
* Check if the plugin is already installed in node_modules
|
||||||
|
* If not, create a symlink to node_modules
|
||||||
|
* This is necessary as
|
||||||
|
* 1. Live Plugin Manager does not support loading plugins from the directory so that node can access them normally
|
||||||
|
* 2. Plugins can't be directly installed to node_modules otherwise upgrading Etherpad will remove them
|
||||||
|
*/
|
||||||
|
for (let file of files){
|
||||||
|
const moduleName = path.basename(file);
|
||||||
|
try {
|
||||||
|
await fs.access(path.join(node_modules, moduleName), fs.constants.F_OK);
|
||||||
|
logger.debug(`plugin ${moduleName} already exists in node_modules`);
|
||||||
|
} catch (err) {
|
||||||
|
// Create symlink to node_modules
|
||||||
|
logger.debug(`create symlink for ${file} to ${path.join(node_modules,moduleName)}`)
|
||||||
|
await fs.symlink(path.join(pluginInstallPath,file), path.join(node_modules,moduleName), 'dir')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fs.access(installedPluginsPath, fs.constants.F_OK);
|
await fs.access(installedPluginsPath, fs.constants.F_OK);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue