From b4ac96d82351fa64d90c7eaadf7f842262254e65 Mon Sep 17 00:00:00 2001 From: JannikStreek Date: Mon, 19 Feb 2024 22:31:27 +0100 Subject: [PATCH] Refactor project structure and introduce workspaces (#6170) * prototype for structure change - working * move server.ts * Revert "move server.ts" This reverts commit 4cf2e61dc0f0f3f3dea37a8160a2d85e0213ac10. * adjusted package file * further cleanup * add workspace root flag * fix docker install * fix loadtest * fix run --- .github/workflows/backend-tests.yml | 4 +-- .github/workflows/load-test.yml | 2 +- Dockerfile | 8 +++--- docker-compose.yml | 1 + node_modules/ep_etherpad-lite | 1 - package.json | 38 +++++++++++++++++++++++++++++ pnpm-workspace.yaml | 0 src/bin/installDeps.sh | 5 ---- src/bin/run.sh | 2 +- 9 files changed, 48 insertions(+), 13 deletions(-) delete mode 120000 node_modules/ep_etherpad-lite create mode 100644 package.json create mode 100644 pnpm-workspace.yaml diff --git a/.github/workflows/backend-tests.yml b/.github/workflows/backend-tests.yml index 92c2161ad..4f94a7271 100644 --- a/.github/workflows/backend-tests.yml +++ b/.github/workflows/backend-tests.yml @@ -107,7 +107,7 @@ jobs: # The --legacy-peer-deps flag is required to work around a bug in npm v7: # https://github.com/npm/cli/issues/2199 run: > - pnpm install + pnpm install --workspace-root ep_align ep_author_hover ep_cursortrace @@ -223,7 +223,7 @@ jobs: # The --legacy-peer-deps flag is required to work around a bug in npm # v7: https://github.com/npm/cli/issues/2199 run: > - pnpm install + pnpm install --workspace-root ep_align ep_author_hover ep_cursortrace diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index e34919484..1c47fcca4 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -93,7 +93,7 @@ jobs: # The --legacy-peer-deps flag is required to work around a bug in npm v7: # https://github.com/npm/cli/issues/2199 run: > - pnpm install + pnpm install --workspace-root ep_align ep_author_hover ep_cursortrace diff --git a/Dockerfile b/Dockerfile index a50d6bca5..bb000449c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,15 +88,17 @@ COPY --chown=etherpad:etherpad ./.git/HEAD ./.git/HEAD COPY --chown=etherpad:etherpad ./.git/refs ./.git/refs COPY --chown=etherpad:etherpad ${SETTINGS} ./settings.json COPY --chown=etherpad:etherpad ./var ./var -COPY --chown=etherpad:etherpad ./node_modules ./node_modules +COPY --chown=etherpad:etherpad ./package.json ./package.json +COPY --chown=etherpad:etherpad ./pnpm-workspace.yaml ./pnpm-workspace.yaml FROM build as development COPY --chown=etherpad:etherpad ./src/package.json .npmrc ./src/pnpm-lock.yaml ./src/ + COPY --chown=etherpad:etherpad ./src/bin ./src/bin RUN { [ -z "${ETHERPAD_PLUGINS}" ] || \ - pnpm install --no-save --legacy-peer-deps ${ETHERPAD_PLUGINS}; } && \ + pnpm install --workspace-root ${ETHERPAD_PLUGINS}; } && \ src/bin/installDeps.sh FROM build as production @@ -118,7 +120,7 @@ COPY --chown=etherpad:etherpad ./src ./src # seems to confuse tools such as `npm outdated`, `npm update`, and some ESLint # rules. RUN { [ -z "${ETHERPAD_PLUGINS}" ] || \ - pnpm install --no-save --legacy-peer-deps ${ETHERPAD_PLUGINS}; } && \ + pnpm install --workspace-root ${ETHERPAD_PLUGINS}; } && \ src/bin/installDeps.sh && \ rm -rf ~/.npm diff --git a/docker-compose.yml b/docker-compose.yml index bb4ac85ee..189c23f91 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,7 @@ services: stdin_open: true volumes: - ./src:/opt/etherpad-lite/src + - ./package.json:/opt/etherpad-lite/package.json - node_modules:/opt/etherpad-lite/src/node_modules - pnpm-store:/home/etherpad/.local/share/pnpm/store/v3 depends_on: diff --git a/node_modules/ep_etherpad-lite b/node_modules/ep_etherpad-lite deleted file mode 120000 index 5cd551cf2..000000000 --- a/node_modules/ep_etherpad-lite +++ /dev/null @@ -1 +0,0 @@ -../src \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 000000000..77ccdbc6f --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "etherpad", + "description": "A free and open source realtime collaborative editor", + "homepage": "https://etherpad.org", + "keywords": [ + "etherpad", + "realtime", + "collaborative", + "editor" + ], + "bin": { + "etherpad-healthcheck": "src/bin/etherpad-healthcheck", + "etherpad-lite": "src/bin/run" + }, + "scripts": { + "lint": "pnpm --filter ep_etherpad-lite run lint", + "test": "pnpm --filter ep_etherpad-lite run test", + "test-container": "pnpm --filter ep_etherpad-lite run test-container", + "dev": "pnpm --filter ep_etherpad-lite run dev", + "prod": "pnpm --filter ep_etherpad-lite run prod", + "ts-check": "pnpm --filter ep_etherpad-lite run ts-check", + "ts-check:watch": "pnpm --filter ep_etherpad-lite run ts-check:watch" + }, + "dependencies": { + "ep_etherpad-lite": "workspace:./src" + }, + "engines": { + "node": ">=18.18.2", + "npm": ">=6.14.0", + "pnpm": ">=8.3.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/ether/etherpad-lite.git" + }, + "version": "1.9.7", + "license": "Apache-2.0" +} \ No newline at end of file diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/src/bin/installDeps.sh b/src/bin/installDeps.sh index dde000b7c..722dec0d0 100755 --- a/src/bin/installDeps.sh +++ b/src/bin/installDeps.sh @@ -35,11 +35,6 @@ fi log "Installing dependencies..." -(mkdir -p node_modules && -cd node_modules && -{ [ -d ep_etherpad-lite ] || ln -sf ../src ep_etherpad-lite; } && -cd ep_etherpad-lite) - cd src if [ -z "${ETHERPAD_PRODUCTION}" ]; then diff --git a/src/bin/run.sh b/src/bin/run.sh index 463e5936d..0f11a1239 100755 --- a/src/bin/run.sh +++ b/src/bin/run.sh @@ -32,4 +32,4 @@ src/bin/installDeps.sh "$@" || exit 1 # Move to the node folder and start log "Starting Etherpad..." -exec pnpm run dev --prefix ./src "$@" +exec pnpm run dev "$@"