mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Improve plugins docker build and fixed plugin loading when dependencies are specified (#6164)
* Install pnpm only local - not global * Install plugins during docker build with live-plugin-manager * Migrated installer to ts. * Added missing workspace script. * Fixed docker build. * Fix Dockerfile * Fixed installer not being yet initialized. * Ported installer to correct install path. * Fixed pnpm installation. * Fixed docker build. * Fixed plugin loading. * Fixed plugins not being able to be loaded. * Fix plugin installation instructions in README * Fixed startup. * Fixed folder not present. * Added unlinking dependencies. * Added deleting dependencies. * Fixed listing plugins. --------- Co-authored-by: SamTV12345 <40429738+samtv12345@users.noreply.github.com>
This commit is contained in:
parent
f9e3416d78
commit
fe106f0afc
16 changed files with 413 additions and 66 deletions
|
@ -26,6 +26,7 @@ const hooks = require('../../static/js/pluginfw/hooks.js');
|
|||
const path = require('path');
|
||||
const resolve = require('resolve');
|
||||
const settings = require('../utils/Settings');
|
||||
import {pluginInstallPath} from '../../static/js/pluginfw/installer'
|
||||
|
||||
const templateCache = new Map();
|
||||
|
||||
|
@ -82,7 +83,13 @@ exports.require = (name:string, args:{
|
|||
basedir = path.dirname(mod.filename);
|
||||
paths = mod.paths;
|
||||
}
|
||||
paths.push(settings.root + '/plugin_packages')
|
||||
|
||||
/**
|
||||
* Add the plugin install path to the paths array
|
||||
*/
|
||||
if (!paths.includes(pluginInstallPath)) {
|
||||
paths.push(pluginInstallPath)
|
||||
}
|
||||
|
||||
const ejspath = resolve.sync(name, {paths, basedir, extensions: ['.html', '.ejs']});
|
||||
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
import {ArgsExpressType} from "../../types/ArgsExpressType";
|
||||
import {Socket} from "node:net";
|
||||
import {ErrorCaused} from "../../types/ErrorCaused";
|
||||
import {QueryType} from "../../types/QueryType";
|
||||
import {PluginType} from "../../types/Plugin";
|
||||
|
||||
const eejs = require('../../eejs');
|
||||
const settings = require('../../utils/Settings');
|
||||
const installer = require('../../../static/js/pluginfw/installer');
|
||||
import {getAvailablePlugins, install, search, uninstall} from "../../../static/js/pluginfw/installer";
|
||||
import {PackageData} from "../../types/PackageInfo";
|
||||
|
||||
const pluginDefs = require('../../../static/js/pluginfw/plugin_defs');
|
||||
const plugins = require('../../../static/js/pluginfw/plugins');
|
||||
const semver = require('semver');
|
||||
import semver from 'semver';
|
||||
|
||||
|
||||
exports.socketio = (hookName:string, args:ArgsExpressType, cb:Function) => {
|
||||
|
@ -32,7 +29,7 @@ exports.socketio = (hookName:string, args:ArgsExpressType, cb:Function) => {
|
|||
socket.on('checkUpdates', async () => {
|
||||
// Check plugins for updates
|
||||
try {
|
||||
const results = await installer.getAvailablePlugins(/* maxCacheAge:*/ 60 * 10);
|
||||
const results = await getAvailablePlugins(/* maxCacheAge:*/ 60 * 10);
|
||||
|
||||
const updatable = Object.keys(pluginDefs.plugins).filter((plugin) => {
|
||||
if (!results[plugin]) return false;
|
||||
|
@ -54,7 +51,7 @@ exports.socketio = (hookName:string, args:ArgsExpressType, cb:Function) => {
|
|||
|
||||
socket.on('getAvailable', async (query:string) => {
|
||||
try {
|
||||
const results = await installer.getAvailablePlugins(/* maxCacheAge:*/ false);
|
||||
const results = await getAvailablePlugins(/* maxCacheAge:*/ false);
|
||||
socket.emit('results:available', results);
|
||||
} catch (er) {
|
||||
console.error(er);
|
||||
|
@ -64,7 +61,7 @@ exports.socketio = (hookName:string, args:ArgsExpressType, cb:Function) => {
|
|||
|
||||
socket.on('search', async (query: QueryType) => {
|
||||
try {
|
||||
const results = await installer.search(query.searchTerm, /* maxCacheAge:*/ 60 * 10);
|
||||
const results = await search(query.searchTerm, /* maxCacheAge:*/ 60 * 10);
|
||||
let res = Object.keys(results)
|
||||
.map((pluginName) => results[pluginName])
|
||||
.filter((plugin) => !pluginDefs.plugins[plugin.name]);
|
||||
|
@ -79,7 +76,7 @@ exports.socketio = (hookName:string, args:ArgsExpressType, cb:Function) => {
|
|||
});
|
||||
|
||||
socket.on('install', (pluginName: string) => {
|
||||
installer.install(pluginName, (err: ErrorCaused) => {
|
||||
install(pluginName, (err: ErrorCaused) => {
|
||||
if (err) console.warn(err.stack || err.toString());
|
||||
|
||||
socket.emit('finished:install', {
|
||||
|
@ -91,7 +88,7 @@ exports.socketio = (hookName:string, args:ArgsExpressType, cb:Function) => {
|
|||
});
|
||||
|
||||
socket.on('uninstall', (pluginName:string) => {
|
||||
installer.uninstall(pluginName, (err:ErrorCaused) => {
|
||||
uninstall(pluginName, (err:ErrorCaused) => {
|
||||
if (err) console.warn(err.stack || err.toString());
|
||||
|
||||
socket.emit('finished:uninstall', {plugin: pluginName, error: err ? err.message : null});
|
||||
|
@ -108,7 +105,7 @@ exports.socketio = (hookName:string, args:ArgsExpressType, cb:Function) => {
|
|||
* @param {String} dir The directory of the plugin
|
||||
* @return {Object[]}
|
||||
*/
|
||||
const sortPluginList = (plugins:PluginType[], property:string, /* ASC?*/dir:string): object[] => plugins.sort((a, b) => {
|
||||
const sortPluginList = (plugins:PackageData[], property:string, /* ASC?*/dir:string): PackageData[] => plugins.sort((a, b) => {
|
||||
// @ts-ignore
|
||||
if (a[property] < b[property]) {
|
||||
return dir ? -1 : 1;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/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.
|
||||
* Static file Requests are answered directly from this module, Socket.IO messages are passed
|
||||
|
@ -26,10 +24,10 @@
|
|||
|
||||
import {PluginType} from "./types/Plugin";
|
||||
import {ErrorCaused} from "./types/ErrorCaused";
|
||||
import {PromiseHooks} from "node:v8";
|
||||
|
||||
import log4js from 'log4js';
|
||||
|
||||
import {checkForMigration} from "../static/js/pluginfw/installer";
|
||||
|
||||
const settings = require('./utils/Settings');
|
||||
|
||||
let wtfnode: any;
|
||||
|
@ -53,7 +51,6 @@ const express = require('./hooks/express');
|
|||
const hooks = require('../static/js/pluginfw/hooks');
|
||||
const pluginDefs = require('../static/js/pluginfw/plugin_defs');
|
||||
const plugins = require('../static/js/pluginfw/plugins');
|
||||
const installer = require('../static/js/pluginfw/installer');
|
||||
const {Gate} = require('./utils/promises');
|
||||
const stats = require('./stats')
|
||||
|
||||
|
@ -147,7 +144,7 @@ exports.start = async () => {
|
|||
}
|
||||
|
||||
await db.init();
|
||||
await installer.checkForMigration();
|
||||
await checkForMigration();
|
||||
await plugins.update();
|
||||
const installedPlugins = (Object.values(pluginDefs.plugins) as PluginType[])
|
||||
.filter((plugin) => plugin.package.name !== 'ep_etherpad-lite')
|
||||
|
|
20
src/node/types/PackageInfo.ts
Normal file
20
src/node/types/PackageInfo.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
export type PackageInfo = {
|
||||
from: string,
|
||||
name: string,
|
||||
version: string,
|
||||
resolved: string,
|
||||
description: string,
|
||||
license: string,
|
||||
author: {
|
||||
name: string
|
||||
},
|
||||
homepage: string,
|
||||
repository: string,
|
||||
path: string
|
||||
}
|
||||
|
||||
|
||||
export type PackageData = {
|
||||
version: string,
|
||||
name: string
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue