mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-04 22:27:10 -04:00
Added querying and removing plugins.
This commit is contained in:
parent
d9a0ecba53
commit
9a072bf36d
6 changed files with 64 additions and 17 deletions
17
bin/commonPlugins.ts
Normal file
17
bin/commonPlugins.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import {PackageData} from "ep_etherpad-lite/node/types/PackageInfo";
|
||||||
|
import {writeFileSync} from "fs";
|
||||||
|
import {installedPluginsPath} from "ep_etherpad-lite/static/js/pluginfw/installer";
|
||||||
|
const pluginsModule = require('ep_etherpad-lite/static/js/pluginfw/plugins');
|
||||||
|
|
||||||
|
export const persistInstalledPlugins = async () => {
|
||||||
|
const plugins:PackageData[] = []
|
||||||
|
const installedPlugins = {plugins: plugins};
|
||||||
|
for (const pkg of Object.values(await pluginsModule.getPackages()) as PackageData[]) {
|
||||||
|
installedPlugins.plugins.push({
|
||||||
|
name: pkg.name,
|
||||||
|
version: pkg.version,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
installedPlugins.plugins = [...new Set(installedPlugins.plugins)];
|
||||||
|
writeFileSync(installedPluginsPath, JSON.stringify(installedPlugins));
|
||||||
|
};
|
|
@ -1,10 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import {writeFileSync} from 'fs'
|
|
||||||
import {linkInstaller, installedPluginsPath} from "ep_etherpad-lite/static/js/pluginfw/installer";
|
import {linkInstaller, installedPluginsPath} from "ep_etherpad-lite/static/js/pluginfw/installer";
|
||||||
import {PackageData} from "ep_etherpad-lite/node/types/PackageInfo";
|
import {persistInstalledPlugins} from "./commonPlugins";
|
||||||
|
|
||||||
const pluginsModule = require('ep_etherpad-lite/static/js/pluginfw/plugins');
|
|
||||||
if (process.argv.length === 2) {
|
if (process.argv.length === 2) {
|
||||||
console.error('Expected at least one argument!');
|
console.error('Expected at least one argument!');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -23,18 +21,7 @@ if (args.indexOf('--path') !== -1) {
|
||||||
registryPlugins = args;
|
registryPlugins = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
const persistInstalledPlugins = async () => {
|
|
||||||
const plugins:PackageData[] = []
|
|
||||||
const installedPlugins = {plugins: plugins};
|
|
||||||
for (const pkg of Object.values(await pluginsModule.getPackages()) as PackageData[]) {
|
|
||||||
installedPlugins.plugins.push({
|
|
||||||
name: pkg.name,
|
|
||||||
version: pkg.version,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
installedPlugins.plugins = [...new Set(installedPlugins.plugins)];
|
|
||||||
writeFileSync(installedPluginsPath, JSON.stringify(installedPlugins));
|
|
||||||
};
|
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
for (const plugin of registryPlugins) {
|
for (const plugin of registryPlugins) {
|
||||||
|
|
18
bin/listPlugins.ts
Normal file
18
bin/listPlugins.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import {linkInstaller, pluginInstallPath} from "ep_etherpad-lite/static/js/pluginfw/installer";
|
||||||
|
import {readdirSync} from "node:fs";
|
||||||
|
import {availablePlugins} from 'ep_etherpad-lite/static/js/pluginfw/installer'
|
||||||
|
import {persistInstalledPlugins} from "./commonPlugins";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const walk = async () => {
|
||||||
|
const plugins = await linkInstaller.listPlugins()
|
||||||
|
|
||||||
|
const pluginNames = plugins.join(" ")
|
||||||
|
|
||||||
|
console.log("Installed plugins are:", pluginNames)
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await walk();
|
||||||
|
})();
|
|
@ -32,7 +32,9 @@
|
||||||
"rebuildPad": "node --import tsx rebuildPad.ts",
|
"rebuildPad": "node --import tsx rebuildPad.ts",
|
||||||
"stalePlugins": "node --import tsx ./plugins/stalePlugins.ts",
|
"stalePlugins": "node --import tsx ./plugins/stalePlugins.ts",
|
||||||
"checkPlugin": "node --import tsx ./plugins/checkPlugin.ts",
|
"checkPlugin": "node --import tsx ./plugins/checkPlugin.ts",
|
||||||
"install-plugins": "node --import tsx ./installPlugins.ts"
|
"install-plugins": "node --import tsx ./installPlugins.ts",
|
||||||
|
"remove-plugins": "node --import tsx ./removePlugins.ts",
|
||||||
|
"list-plugins": "node --import tsx ./listPlugins.ts"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
|
|
21
bin/removePlugins.ts
Normal file
21
bin/removePlugins.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import {linkInstaller} from "ep_etherpad-lite/static/js/pluginfw/installer";
|
||||||
|
import {persistInstalledPlugins} from "./commonPlugins";
|
||||||
|
if (process.argv.length === 2) {
|
||||||
|
console.error('Expected at least one argument!');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let pluginsToRemove = process.argv.slice(2);
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
for (const plugin of pluginsToRemove) {
|
||||||
|
console.log(`Removing plugin from etherpad: ${plugin}`)
|
||||||
|
await linkInstaller.uninstallPlugin(plugin);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await run();
|
||||||
|
await persistInstalledPlugins();
|
||||||
|
})();
|
|
@ -24,7 +24,9 @@
|
||||||
"test-ui:ui": "pnpm --filter ep_etherpad-lite run test-ui:ui",
|
"test-ui:ui": "pnpm --filter ep_etherpad-lite run test-ui:ui",
|
||||||
"test-admin": "pnpm --filter ep_etherpad-lite run test-admin",
|
"test-admin": "pnpm --filter ep_etherpad-lite run test-admin",
|
||||||
"test-admin:ui": "pnpm --filter ep_etherpad-lite run test-admin:ui",
|
"test-admin:ui": "pnpm --filter ep_etherpad-lite run test-admin:ui",
|
||||||
"install-plugins": "pnpm --filter bin run install-plugins"
|
"install-plugins": "pnpm --filter bin run install-plugins",
|
||||||
|
"remove-plugins": "pnpm --filter bin run remove-plugins",
|
||||||
|
"list-plugins": "pnpm --filter bin run list-plugins"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ep_etherpad-lite": "workspace:./src"
|
"ep_etherpad-lite": "workspace:./src"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue