mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 06:03:34 +01:00
fix github plugin installation (#6584)
This commit is contained in:
parent
1393f338e0
commit
f8225b3e2a
4 changed files with 32 additions and 17 deletions
19
Dockerfile
19
Dockerfile
|
@ -49,6 +49,14 @@ ARG ETHERPAD_PLUGINS=
|
|||
# ETHERPAD_LOCAL_PLUGINS="../ep_my_plugin ../ep_another_plugin"
|
||||
ARG ETHERPAD_LOCAL_PLUGINS=
|
||||
|
||||
# github plugins to install while building the container. By default no plugins are
|
||||
# installed.
|
||||
# If given a value, it has to be a space-separated, quoted list of plugin names.
|
||||
#
|
||||
# EXAMPLE:
|
||||
# ETHERPAD_GITHUB_PLUGINS="ether/ep_plugin"
|
||||
ARG ETHERPAD_GITHUB_PLUGINS=
|
||||
|
||||
# Control whether abiword will be installed, enabling exports to DOC/PDF/ODT formats.
|
||||
# By default, it is not installed.
|
||||
# If given any value, abiword will be installed.
|
||||
|
@ -114,13 +122,13 @@ COPY --chown=etherpad:etherpad ./pnpm-workspace.yaml ./package.json ./
|
|||
|
||||
FROM build AS development
|
||||
|
||||
COPY --chown=etherpad:etherpad ./src/package.json .npmrc ./src/
|
||||
COPY --chown=etherpad:etherpad ./src/ ./src/
|
||||
COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/ templates/admin./src/templates/admin
|
||||
COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/static/oidc ./src/static/oidc
|
||||
|
||||
RUN bin/installDeps.sh && \
|
||||
if [ ! -z "${ETHERPAD_PLUGINS}" ] || [ ! -z "${ETHERPAD_LOCAL_PLUGINS}" ]; then \
|
||||
pnpm run plugins i ${ETHERPAD_PLUGINS} ${ETHERPAD_LOCAL_PLUGINS:+--path ${ETHERPAD_LOCAL_PLUGINS}}; \
|
||||
if [ ! -z "${ETHERPAD_PLUGINS}" ] || [ ! -z "${ETHERPAD_LOCAL_PLUGINS}" ] || [ ! -z "${ETHERPAD_GITHUB_PLUGINS}" ]; then \
|
||||
pnpm run plugins i ${ETHERPAD_PLUGINS} ${ETHERPAD_LOCAL_PLUGINS:+--path ${ETHERPAD_LOCAL_PLUGINS}} ${ETHERPAD_GITHUB_PLUGINS:+--github ${ETHERPAD_GITHUB_PLUGINS}}; \
|
||||
fi
|
||||
|
||||
|
||||
|
@ -134,11 +142,10 @@ COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/template
|
|||
COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/static/oidc ./src/static/oidc
|
||||
|
||||
RUN bin/installDeps.sh && rm -rf ~/.npm && rm -rf ~/.local && rm -rf ~/.cache && \
|
||||
if [ ! -z "${ETHERPAD_PLUGINS}" ] || [ ! -z "${ETHERPAD_LOCAL_PLUGINS}" ]; then \
|
||||
pnpm run plugins i ${ETHERPAD_PLUGINS} ${ETHERPAD_LOCAL_PLUGINS:+--path ${ETHERPAD_LOCAL_PLUGINS}}; \
|
||||
if [ ! -z "${ETHERPAD_PLUGINS}" ] || [ ! -z "${ETHERPAD_LOCAL_PLUGINS}" ] || [ ! -z "${ETHERPAD_GITHUB_PLUGINS}" ]; then \
|
||||
pnpm run plugins i ${ETHERPAD_PLUGINS} ${ETHERPAD_LOCAL_PLUGINS:+--path ${ETHERPAD_LOCAL_PLUGINS}} ${ETHERPAD_GITHUB_PLUGINS:+--github ${ETHERPAD_GITHUB_PLUGINS}}; \
|
||||
fi
|
||||
|
||||
|
||||
# Copy the configuration file.
|
||||
COPY --chown=etherpad:etherpad ${SETTINGS} "${EP_DIR}"/settings.json
|
||||
|
||||
|
|
|
@ -23,17 +23,13 @@ const possibleActions = [
|
|||
]
|
||||
|
||||
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;
|
||||
}
|
||||
const argsAsString: string = args.join(" ");
|
||||
const regexRegistryPlugins = /(?<=i\s)(.*?)(?=--github|--path|$)/;
|
||||
const regexLocalPlugins = /(?<=--path\s)(.*?)(?=--github|$)/;
|
||||
const regexGithubPlugins = /(?<=--github\s)(.*?)(?=--path|$)/;
|
||||
const registryPlugins = argsAsString.match(regexRegistryPlugins)?.[0]?.split(" ")?.filter(s => s) || [];
|
||||
const localPlugins = argsAsString.match(regexLocalPlugins)?.[0]?.split(" ")?.filter(s => s) || [];
|
||||
const githubPlugins = argsAsString.match(regexGithubPlugins)?.[0]?.split(" ")?.filter(s => s) || [];
|
||||
|
||||
async function run() {
|
||||
for (const plugin of registryPlugins) {
|
||||
|
@ -53,6 +49,11 @@ const install = ()=> {
|
|||
console.log(`Installing plugin from path: ${plugin}`);
|
||||
await linkInstaller.installFromPath(plugin);
|
||||
}
|
||||
|
||||
for (const plugin of githubPlugins) {
|
||||
console.log(`Installing plugin from github: ${plugin}`);
|
||||
await linkInstaller.installFromGitHub(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
(async () => {
|
||||
|
|
|
@ -9,6 +9,7 @@ services:
|
|||
build:
|
||||
context: .
|
||||
args:
|
||||
# Attention: installed plugins in the node_modules folder get overwritten during volume mount in dev
|
||||
ETHERPAD_PLUGINS:
|
||||
# change from development to production if needed
|
||||
target: development
|
||||
|
|
|
@ -44,6 +44,12 @@ export class LinkInstaller {
|
|||
await this.checkLinkedDependencies(installedPlugin)
|
||||
}
|
||||
|
||||
public async installFromGitHub(repository: string) {
|
||||
const installedPlugin = await this.livePluginManager.installFromGithub(repository)
|
||||
this.linkDependency(installedPlugin.name)
|
||||
await this.checkLinkedDependencies(installedPlugin)
|
||||
}
|
||||
|
||||
public async installPlugin(pluginName: string, version?: string) {
|
||||
if (version) {
|
||||
const installedPlugin = await this.livePluginManager.install(pluginName, version);
|
||||
|
|
Loading…
Reference in a new issue