mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-04 22:27:10 -04:00
Added listing and removing plugins via cli
This commit is contained in:
parent
9a072bf36d
commit
8f15dbf777
5 changed files with 107 additions and 88 deletions
|
@ -1,46 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
import {linkInstaller, installedPluginsPath} 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 args = process.argv.slice(2)
|
|
||||||
|
|
||||||
let registryPlugins: string[] = [];
|
|
||||||
let localPlugins: string[] = [];
|
|
||||||
|
|
||||||
if (args.indexOf('--path') !== -1) {
|
|
||||||
const indexToSplit = args.indexOf('--path');
|
|
||||||
registryPlugins = args.slice(0, indexToSplit);
|
|
||||||
localPlugins = args.slice(indexToSplit + 1);
|
|
||||||
} else {
|
|
||||||
registryPlugins = args;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function run() {
|
|
||||||
for (const plugin of registryPlugins) {
|
|
||||||
console.log(`Installing plugin from registry: ${plugin}`)
|
|
||||||
if (plugin.includes('@')) {
|
|
||||||
const [name, version] = plugin.split('@');
|
|
||||||
await linkInstaller.installPlugin(name, version);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
await linkInstaller.installPlugin(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const plugin of localPlugins) {
|
|
||||||
console.log(`Installing plugin from path: ${plugin}`);
|
|
||||||
await linkInstaller.installFromPath(plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
await run();
|
|
||||||
await persistInstalledPlugins();
|
|
||||||
})();
|
|
|
@ -1,18 +0,0 @@
|
||||||
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,9 +32,7 @@
|
||||||
"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",
|
"plugins": "node --import tsx ./plugins.ts"
|
||||||
"remove-plugins": "node --import tsx ./removePlugins.ts",
|
|
||||||
"list-plugins": "node --import tsx ./listPlugins.ts"
|
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
|
|
106
bin/plugins.ts
Normal file
106
bin/plugins.ts
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import {linkInstaller} from "ep_etherpad-lite/static/js/pluginfw/installer";
|
||||||
|
import {persistInstalledPlugins} from "./commonPlugins";
|
||||||
|
import fs from "node:fs";
|
||||||
|
const settings = require('ep_etherpad-lite/node/utils/Settings');
|
||||||
|
|
||||||
|
if (process.argv.length === 2) {
|
||||||
|
console.error('Expected at least one argument!');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let args = process.argv.slice(2)
|
||||||
|
|
||||||
|
// 3d arg is ls, install or rm
|
||||||
|
let action = args[0];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const install = ()=> {
|
||||||
|
|
||||||
|
let registryPlugins: string[] = [];
|
||||||
|
let localPlugins: string[] = [];
|
||||||
|
|
||||||
|
if (args.indexOf('--path') !== -1) {
|
||||||
|
const indexToSplit = args.indexOf('--path');
|
||||||
|
registryPlugins = args.slice(1, indexToSplit);
|
||||||
|
localPlugins = args.slice(indexToSplit + 1);
|
||||||
|
} else {
|
||||||
|
registryPlugins = args;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
for (const plugin of registryPlugins) {
|
||||||
|
console.log(`Installing plugin from registry: ${plugin}`)
|
||||||
|
if (plugin.includes('@')) {
|
||||||
|
const [name, version] = plugin.split('@');
|
||||||
|
await linkInstaller.installPlugin(name, version);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
await linkInstaller.installPlugin(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const plugin of localPlugins) {
|
||||||
|
console.log(`Installing plugin from path: ${plugin}`);
|
||||||
|
await linkInstaller.installFromPath(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await run();
|
||||||
|
await persistInstalledPlugins();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
const list = ()=>{
|
||||||
|
const walk = async () => {
|
||||||
|
const plugins = fs.readFileSync(settings.root+"/var/installed_plugins.json", "utf-8")
|
||||||
|
const pluginNames = JSON.parse(plugins).plugins.map((plugin: any) => plugin.name).join(", ")
|
||||||
|
|
||||||
|
console.log("Installed plugins are:", pluginNames)
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await walk();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
const remove = (plugins: string[])=>{
|
||||||
|
const walk = async () => {
|
||||||
|
for (const plugin of plugins) {
|
||||||
|
console.log(`Uninstalling plugin: ${plugin}`)
|
||||||
|
await linkInstaller.uninstallPlugin(plugin);
|
||||||
|
}
|
||||||
|
await persistInstalledPlugins();
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await walk();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
|
case "install":
|
||||||
|
install();
|
||||||
|
break;
|
||||||
|
case "i":
|
||||||
|
install();
|
||||||
|
break;
|
||||||
|
case "ls":
|
||||||
|
list();
|
||||||
|
break;
|
||||||
|
case "list":
|
||||||
|
list();
|
||||||
|
break;
|
||||||
|
case "rm":
|
||||||
|
remove(args.slice(1));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.error('Expected at least one argument!');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
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();
|
|
||||||
})();
|
|
Loading…
Add table
Add a link
Reference in a new issue