From 04063d664b8ef478122afef2830dfb3accb38f46 Mon Sep 17 00:00:00 2001 From: JannikStreek Date: Wed, 21 Feb 2024 21:50:11 +0100 Subject: [PATCH] cleanup after workspace refactoring (#6174) * fix bin folder and workflows as far its possible cleanup of dockerfile changed paths of scripts add lock file fix working directory for workflows fix windows bin fix travis (is travis used anyway?) fix package refs remove pnpm-lock file in root as these conflicts with the docker volume setup optimize comments use install again refactor prod image call to run fix --workspace can only be used inside a workspace correct comment try fix pipeline try fix pipeline for upgrade-from-latest-release install all deps smaller adjustments save update dockerfile remove workspace command fix run test command start repair latest release workflow start repair latest release workflow start repair latest release workflow further repairs * remove test plugin from docker compose --- .github/workflows/backend-tests.yml | 27 +++---- .github/workflows/docker.yml | 2 +- .github/workflows/frontend-admin-tests.yml | 2 +- .github/workflows/frontend-tests.yml | 4 +- .github/workflows/load-test.yml | 6 +- .github/workflows/perform-type-check.yml | 1 - .github/workflows/rate-limit.yml | 2 +- .../workflows/upgrade-from-latest-release.yml | 67 +++++++++--------- .github/workflows/windows.yml | 8 +-- .gitignore | 3 +- .travis.yml | 14 ++-- Dockerfile | 29 ++------ bin | 1 - {src/bin => bin}/buildDebian.sh | 2 +- {src/bin => bin}/buildForWindows.sh | 2 +- {src/bin => bin}/checkAllPads.js | 6 +- {src/bin => bin}/checkPad.js | 6 +- {src/bin => bin}/cleanRun.sh | 6 +- .../bin => bin}/convertSettings.json.template | 0 {src/bin => bin}/createRelease.sh | 2 +- {src/bin => bin}/createUserSession.js | 4 +- {src/bin => bin}/deb-src/DEBIAN/control | 0 {src/bin => bin}/deb-src/DEBIAN/postinst | 0 {src/bin => bin}/deb-src/DEBIAN/preinst | 0 {src/bin => bin}/deb-src/DEBIAN/prerm | 0 .../deb-src/sysroot/etc/init/etherpad.conf | 2 +- {src/bin => bin}/debugRun.sh | 6 +- {src/bin => bin}/deleteAllGroupSessions.js | 4 +- {src/bin => bin}/deletePad.js | 4 +- {src/bin => bin}/doc/LICENSE | 0 {src/bin => bin}/doc/README.md | 0 {src/bin => bin}/doc/generate.js | 0 {src/bin => bin}/doc/html.js | 0 {src/bin => bin}/doc/json.js | 0 {src/bin => bin}/etherpad-healthcheck | 0 {src/bin => bin}/extractPadData.js | 6 +- {src/bin => bin}/fastRun.sh | 4 +- {src/bin => bin}/functions.sh | 0 {src/bin => bin}/importSqlFile.js | 2 +- {src/bin => bin}/installDeps.sh | 15 ++-- {src/bin => bin}/installOnWindows.bat | 4 +- {src/bin => bin}/migrateDirtyDBtoRealDB.js | 4 +- {src/bin => bin}/nsis/README.md | 0 {src/bin => bin}/nsis/brand.ico | Bin {src/bin => bin}/nsis/etherpad.nsi | 0 {src/bin => bin}/plugins/README.md | 0 {src/bin => bin}/plugins/checkPlugin.js | 24 +++---- {src/bin => bin}/plugins/getCorePlugins.sh | 2 +- {src/bin => bin}/plugins/lib/CONTRIBUTING.md | 0 {src/bin => bin}/plugins/lib/LICENSE | 0 {src/bin => bin}/plugins/lib/README.md | 0 .../bin => bin}/plugins/lib/backend-tests.yml | 4 +- {src/bin => bin}/plugins/lib/dependabot.yml | 0 {src/bin => bin}/plugins/lib/eslintrc.cjs | 0 .../plugins/lib/frontend-tests.yml | 4 +- {src/bin => bin}/plugins/lib/gitignore | 0 {src/bin => bin}/plugins/lib/npmpublish.yml | 0 {src/bin => bin}/plugins/listOfficialPlugins | 2 +- {src/bin => bin}/plugins/reTestAllPlugins.sh | 2 +- {src/bin => bin}/plugins/stalePlugins.js | 0 .../plugins/updateAllPluginsScript.sh | 2 +- {src/bin => bin}/plugins/updateCorePlugins.sh | 2 +- {src/bin => bin}/push-after-release.sh | 2 +- {src/bin => bin}/rebuildPad.js | 12 ++-- {src/bin => bin}/release.js | 6 +- {src/bin => bin}/repairPad.js | 8 +-- {src/bin => bin}/run.sh | 7 +- {src/bin => bin}/safeRun.sh | 4 +- {src/bin => bin}/updatePlugins.sh | 2 +- doc/docker.adoc | 2 +- docker-compose.yml | 10 ++- package.json | 4 +- pnpm-workspace.yaml | 2 + src/package.json | 2 +- src/tests/frontend/travis/runner.sh | 2 +- 75 files changed, 158 insertions(+), 192 deletions(-) delete mode 120000 bin rename {src/bin => bin}/buildDebian.sh (96%) rename {src/bin => bin}/buildForWindows.sh (98%) rename {src/bin => bin}/checkAllPads.js (79%) rename {src/bin => bin}/checkPad.js (75%) rename {src/bin => bin}/cleanRun.sh (89%) rename {src/bin => bin}/convertSettings.json.template (100%) rename {src/bin => bin}/createRelease.sh (99%) rename {src/bin => bin}/createUserSession.js (94%) rename {src/bin => bin}/deb-src/DEBIAN/control (100%) rename {src/bin => bin}/deb-src/DEBIAN/postinst (100%) rename {src/bin => bin}/deb-src/DEBIAN/preinst (100%) rename {src/bin => bin}/deb-src/DEBIAN/prerm (100%) rename {src/bin => bin}/deb-src/sysroot/etc/init/etherpad.conf (90%) rename {src/bin => bin}/debugRun.sh (87%) rename {src/bin => bin}/deleteAllGroupSessions.js (92%) rename {src/bin => bin}/deletePad.js (90%) rename {src/bin => bin}/doc/LICENSE (100%) rename {src/bin => bin}/doc/README.md (100%) rename {src/bin => bin}/doc/generate.js (100%) rename {src/bin => bin}/doc/html.js (100%) rename {src/bin => bin}/doc/json.js (100%) rename {src/bin => bin}/etherpad-healthcheck (100%) rename {src/bin => bin}/extractPadData.js (92%) rename {src/bin => bin}/fastRun.sh (91%) rename {src/bin => bin}/functions.sh (100%) rename {src/bin => bin}/importSqlFile.js (97%) rename {src/bin => bin}/installDeps.sh (82%) rename {src/bin => bin}/installOnWindows.bat (94%) rename {src/bin => bin}/migrateDirtyDBtoRealDB.js (94%) rename {src/bin => bin}/nsis/README.md (100%) rename {src/bin => bin}/nsis/brand.ico (100%) rename {src/bin => bin}/nsis/etherpad.nsi (100%) rename {src/bin => bin}/plugins/README.md (100%) rename {src/bin => bin}/plugins/checkPlugin.js (94%) rename {src/bin => bin}/plugins/getCorePlugins.sh (97%) rename {src/bin => bin}/plugins/lib/CONTRIBUTING.md (100%) rename {src/bin => bin}/plugins/lib/LICENSE (100%) rename {src/bin => bin}/plugins/lib/README.md (100%) rename {src/bin => bin}/plugins/lib/backend-tests.yml (97%) rename {src/bin => bin}/plugins/lib/dependabot.yml (100%) rename {src/bin => bin}/plugins/lib/eslintrc.cjs (100%) rename {src/bin => bin}/plugins/lib/frontend-tests.yml (98%) rename {src/bin => bin}/plugins/lib/gitignore (100%) rename {src/bin => bin}/plugins/lib/npmpublish.yml (100%) rename {src/bin => bin}/plugins/listOfficialPlugins (95%) rename {src/bin => bin}/plugins/reTestAllPlugins.sh (84%) rename {src/bin => bin}/plugins/stalePlugins.js (100%) rename {src/bin => bin}/plugins/updateAllPluginsScript.sh (93%) rename {src/bin => bin}/plugins/updateCorePlugins.sh (70%) rename {src/bin => bin}/push-after-release.sh (82%) rename {src/bin => bin}/rebuildPad.js (89%) rename {src/bin => bin}/release.js (97%) rename {src/bin => bin}/repairPad.js (87%) rename {src/bin => bin}/run.sh (88%) rename {src/bin => bin}/safeRun.sh (95%) rename {src/bin => bin}/updatePlugins.sh (92%) diff --git a/.github/workflows/backend-tests.yml b/.github/workflows/backend-tests.yml index 4f94a7271..2ff211380 100644 --- a/.github/workflows/backend-tests.yml +++ b/.github/workflows/backend-tests.yml @@ -53,10 +53,10 @@ jobs: sudo apt install -y --no-install-recommends libreoffice libreoffice-pdfimport - name: Install all dependencies and symlink for ep_etherpad-lite - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: Run the backend tests - run: cd src && pnpm test + run: pnpm test withpluginsLinux: # run on pushes to any branch @@ -102,10 +102,11 @@ jobs: sudo add-apt-repository -y ppa:libreoffice/ppa sudo apt update sudo apt install -y --no-install-recommends libreoffice libreoffice-pdfimport + - + name: Install all dependencies and symlink for ep_etherpad-lite + run: bin/installDeps.sh - name: Install Etherpad plugins - # 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 --workspace-root ep_align @@ -121,21 +122,9 @@ jobs: ep_spellcheck ep_subscript_and_superscript ep_table_of_contents - # Etherpad core dependencies must be installed after installing the - # plugin's dependencies, otherwise npm will try to hoist common - # dependencies by removing them from src/node_modules and installing them - # in the top-level node_modules. As of v6.14.10, npm's hoist logic appears - # to be buggy, because it sometimes removes dependencies from - # src/node_modules but fails to add them to the top-level node_modules. - # Even if npm correctly hoists the dependencies, the hoisting seems to - # confuse tools such as `npm outdated`, `npm update`, and some ESLint - # rules. - - - name: Install all dependencies and symlink for ep_etherpad-lite - run: src/bin/installDeps.sh - name: Run the backend tests - run: cd src && pnpm test + run: pnpm test withoutpluginsWindows: # run on pushes to any branch @@ -173,7 +162,7 @@ jobs: run: pnpm config set auto-install-peers false - name: Install all dependencies and symlink for ep_etherpad-lite - run: src/bin/installOnWindows.bat + run: bin/installOnWindows.bat - name: Fix up the settings.json run: | @@ -248,7 +237,7 @@ jobs: # rules. - name: Install all dependencies and symlink for ep_etherpad-lite - run: src/bin/installOnWindows.bat + run: bin/installOnWindows.bat - name: Fix up the settings.json run: | diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2edf31cee..7e728ec64 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -60,7 +60,7 @@ jobs: name: Test run: | docker run --rm -d -p 9001:9001 --name test ${{ env.TEST_TAG }} - ./src/bin/installDeps.sh + ./bin/installDeps.sh docker logs -f test & while true; do echo "Waiting for Docker container to start..." diff --git a/.github/workflows/frontend-admin-tests.yml b/.github/workflows/frontend-admin-tests.yml index 1477ba0b5..aa1c4e70a 100644 --- a/.github/workflows/frontend-admin-tests.yml +++ b/.github/workflows/frontend-admin-tests.yml @@ -67,7 +67,7 @@ jobs: # rules. - name: Install all dependencies and symlink for ep_etherpad-lite - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: Install etherpad plugins run: rm -Rf node_modules/ep_align/static/tests/* diff --git a/.github/workflows/frontend-tests.yml b/.github/workflows/frontend-tests.yml index c966df81d..a5498e1e8 100644 --- a/.github/workflows/frontend-tests.yml +++ b/.github/workflows/frontend-tests.yml @@ -46,7 +46,7 @@ jobs: run: pnpm config set auto-install-peers false - name: Install all dependencies and symlink for ep_etherpad-lite - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: export GIT_HASH to env id: environment @@ -142,7 +142,7 @@ jobs: # rules. - name: Install all dependencies and symlink for ep_etherpad-lite - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: export GIT_HASH to env id: environment diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index 1c47fcca4..d4f1a9b44 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -43,7 +43,7 @@ jobs: run: pnpm config set auto-install-peers false - name: Install all dependencies and symlink for ep_etherpad-lite - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: Install etherpad-load-test run: sudo npm install -g etherpad-load-test-socket-io @@ -117,7 +117,7 @@ jobs: # rules. - name: Install all dependencies and symlink for ep_etherpad-lite - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: Run load test run: src/tests/frontend/travis/runnerLoadTest.sh 25 50 @@ -158,7 +158,7 @@ jobs: run: pnpm config set auto-install-peers false - name: Install all dependencies and symlink for ep_etherpad-lite - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: Install etherpad-load-test run: sudo npm install -g etherpad-load-test-socket-io diff --git a/.github/workflows/perform-type-check.yml b/.github/workflows/perform-type-check.yml index 2e928ca24..81be2567d 100644 --- a/.github/workflows/perform-type-check.yml +++ b/.github/workflows/perform-type-check.yml @@ -41,7 +41,6 @@ jobs: - name: Install all dependencies and symlink for ep_etherpad-lite run: ./bin/installDeps.sh - working-directory: ./src - name: Perform type check working-directory: ./src run: npm run ts-check diff --git a/.github/workflows/rate-limit.yml b/.github/workflows/rate-limit.yml index 0309b4514..dab99fff3 100644 --- a/.github/workflows/rate-limit.yml +++ b/.github/workflows/rate-limit.yml @@ -57,7 +57,7 @@ jobs: docker run --rm --network ep_net --ip 172.23.42.3 --name anotherip -dt anotherip - name: install dependencies and create symlink for ep_etherpad-lite - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: run rate limit test run: | diff --git a/.github/workflows/upgrade-from-latest-release.yml b/.github/workflows/upgrade-from-latest-release.yml index fc1c171f6..2a97b8b27 100644 --- a/.github/workflows/upgrade-from-latest-release.yml +++ b/.github/workflows/upgrade-from-latest-release.yml @@ -29,30 +29,13 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - - uses: pnpm/action-setup@v3 - name: Install pnpm - with: - version: 8 - run_install: false - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Only install direct dependencies - run: pnpm config set auto-install-peers false - name: Install Etherpad plugins - # The --legacy-peer-deps flag is required to work around a bug in npm - # v7: https://github.com/npm/cli/issues/2199 + # Important: Installer for old master which does not have pnpm right now + # 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 --workspace root + npm install --no-save --legacy-peer-deps ep_align ep_author_hover ep_cursortrace @@ -66,21 +49,12 @@ jobs: ep_spellcheck ep_subscript_and_superscript ep_table_of_contents - # Etherpad core dependencies must be installed after installing the - # plugin's dependencies, otherwise npm will try to hoist common - # dependencies by removing them from src/node_modules and installing them - # in the top-level node_modules. As of v6.14.10, npm's hoist logic appears - # to be buggy, because it sometimes removes dependencies from - # src/node_modules but fails to add them to the top-level node_modules. - # Even if npm correctly hoists the dependencies, the hoisting seems to - # confuse tools such as `npm outdated`, `npm update`, and some ESLint - # rules. - name: Install all dependencies and symlink for ep_etherpad-lite run: src/bin/installDeps.sh - name: Run the backend tests - run: cd src && pnpm test + run: cd src && npm test # Because actions/checkout@v4 is called with "ref: master" and without # "fetch-depth: 0", the local clone does not have the ${GITHUB_SHA} # commit. Fetch ${GITHUB_REF} to get the ${GITHUB_SHA} commit. Note that a @@ -96,13 +70,36 @@ jobs: # For pull requests, ${GITHUB_SHA} is the automatically generated merge # commit that merges the PR's source branch to its destination branch. run: git checkout "${GITHUB_SHA}" + - uses: pnpm/action-setup@v3 + name: Install pnpm + with: + version: 8 + run_install: false + - name: Only install direct dependencies + run: pnpm config set auto-install-peers false + - + name: Install libreoffice + run: | + sudo add-apt-repository -y ppa:libreoffice/ppa + sudo apt update + sudo apt install -y --no-install-recommends libreoffice libreoffice-pdfimport + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install all dependencies and symlink for ep_etherpad-lite - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: Run the backend tests - working-directory: ./src - run: npm test + run: pnpm test - name: Install Cypress working-directory: ./src @@ -111,6 +108,6 @@ jobs: name: Run Etherpad & Test Frontend working-directory: ./src run: | - npm run dev & + pnpm run dev & curl --connect-timeout 10 --max-time 20 --retry 5 --retry-delay 10 --retry-max-time 60 --retry-connrefused http://127.0.0.1:9001/p/test ./node_modules/cypress/bin/cypress run --config-file tests/frontend/cypress/cypress.config.js diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index acd078363..d95cc68b6 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -50,7 +50,7 @@ jobs: - name: Install all dependencies and symlink for ep_etherpad-lite shell: msys2 {0} - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: Run the backend tests shell: msys2 {0} @@ -58,7 +58,7 @@ jobs: - name: Build the .zip shell: msys2 {0} - run: src/bin/buildForWindows.sh + run: bin/buildForWindows.sh - name: Archive production artifacts uses: actions/upload-artifact@v4 @@ -91,7 +91,7 @@ jobs: name: Create installer uses: joncloud/makensis-action@v4.1 with: - script-file: 'src/bin/nsis/etherpad.nsi' + script-file: 'bin/nsis/etherpad.nsi' - name: Archive production artifacts uses: actions/upload-artifact@v4 @@ -143,7 +143,7 @@ jobs: run: pnpm config set auto-install-peers false - name: Install all dependencies and symlink for ep_etherpad-lite run: .\bin\installOnWindows.bat - working-directory: etherpad/src + working-directory: etherpad - name: Run Etherpad working-directory: etherpad/src diff --git a/.gitignore b/.gitignore index 5364f4397..3f6377af0 100644 --- a/.gitignore +++ b/.gitignore @@ -22,5 +22,4 @@ out/ /src/bin/convertSettings.json /src/bin/etherpad-1.deb /src/bin/node.exe -plugin_packages -/pnpm-lock.yaml \ No newline at end of file +plugin_packages \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index f142e51b2..ca8c5380f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,7 +55,7 @@ jobs: - *set_loglevel_warn - *enable_admin_tests - "src/tests/frontend/travis/sauce_tunnel.sh" - - "src/bin/installDeps.sh" + - "bin/installDeps.sh" - "export GIT_HASH=$(git rev-parse --verify --short HEAD)" script: - "./src/tests/frontend/travis/runner.sh" @@ -63,7 +63,7 @@ jobs: install: - *install_libreoffice - *set_loglevel_warn - - "src/bin/installDeps.sh" + - "bin/installDeps.sh" - "cd src && pnpm install && cd -" script: - "cd src && pnpm test" @@ -77,7 +77,7 @@ jobs: - name: "Load test Etherpad without Plugins" install: - *set_loglevel_warn - - "src/bin/installDeps.sh" + - "bin/installDeps.sh" - "cd src && pnpm install && cd -" - "npm install -g etherpad-load-test" script: @@ -90,7 +90,7 @@ jobs: - *set_loglevel_warn - *enable_admin_tests - "src/tests/frontend/travis/sauce_tunnel.sh" - - "src/bin/installDeps.sh" + - "bin/installDeps.sh" - "rm src/tests/frontend/specs/*" - *install_plugins - "export GIT_HASH=$(git rev-parse --verify --short HEAD)" @@ -105,7 +105,7 @@ jobs: install: - *install_libreoffice - *set_loglevel_warn - - "src/bin/installDeps.sh" + - "bin/installDeps.sh" - *install_plugins - "cd src && pnpm install && cd -" script: @@ -120,7 +120,7 @@ jobs: - name: "Load test Etherpad with Plugins" install: - *set_loglevel_warn - - "src/bin/installDeps.sh" + - "bin/installDeps.sh" - *install_plugins - "cd src && npm install && cd -" - "npm install -g etherpad-load-test" @@ -135,7 +135,7 @@ jobs: - "docker run -p 8081:80 --rm --network ep_net --ip 172.23.42.1 -d nginx-latest" - "docker run --name etherpad-docker -p 9000:9001 --rm --network ep_net --ip 172.23.42.2 -e 'TRUST_PROXY=true' epl-debian-slim &" - "docker run --rm --network ep_net --ip 172.23.42.3 --name anotherip -dt anotherip" - - "./src/bin/installDeps.sh" + - "./bin/installDeps.sh" script: - "cd src/tests/ratelimit && bash testlimits.sh" diff --git a/Dockerfile b/Dockerfile index bb000449c..a39ce882e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,40 +88,25 @@ 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 ./package.json ./package.json -COPY --chown=etherpad:etherpad ./pnpm-workspace.yaml ./pnpm-workspace.yaml +COPY --chown=etherpad:etherpad ./bin ./bin +COPY --chown=etherpad:etherpad ./pnpm-workspace.yaml ./package.json ./ 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 --workspace-root ${ETHERPAD_PLUGINS}; } && \ - src/bin/installDeps.sh - +RUN bin/installDeps.sh && { [ -z "${ETHERPAD_PLUGINS}" ] || \ + pnpm install --workspace-root ${ETHERPAD_PLUGINS}; } + FROM build as production -# By default, Etherpad container is built and run in "production" mode. This is -# leaner (development dependencies are not installed) and runs faster (among -# other things, assets are minified & compressed). ENV NODE_ENV=production ENV ETHERPAD_PRODUCTION=true COPY --chown=etherpad:etherpad ./src ./src -# Plugins must be installed before installing Etherpad's dependencies, otherwise -# npm will try to hoist common dependencies by removing them from -# src/node_modules and installing them in the top-level node_modules. As of -# v6.14.10, npm's hoist logic appears to be buggy, because it sometimes removes -# dependencies from src/node_modules but fails to add them to the top-level -# node_modules. Even if npm correctly hoists the dependencies, the hoisting -# seems to confuse tools such as `npm outdated`, `npm update`, and some ESLint -# rules. -RUN { [ -z "${ETHERPAD_PLUGINS}" ] || \ +RUN bin/installDeps.sh && { [ -z "${ETHERPAD_PLUGINS}" ] || \ pnpm install --workspace-root ${ETHERPAD_PLUGINS}; } && \ - src/bin/installDeps.sh && \ rm -rf ~/.npm # Copy the configuration file. @@ -137,4 +122,4 @@ HEALTHCHECK --interval=5s --timeout=3s \ CMD curl --silent http://localhost:9001/health | grep -E "pass|ok|up" > /dev/null || exit 1 EXPOSE 9001 -CMD ["npm", "run", "prod", "--prefix", "./src"] +CMD ["pnpm", "run", "prod"] diff --git a/bin b/bin deleted file mode 120000 index 70feaa890..000000000 --- a/bin +++ /dev/null @@ -1 +0,0 @@ -src/bin \ No newline at end of file diff --git a/src/bin/buildDebian.sh b/bin/buildDebian.sh similarity index 96% rename from src/bin/buildDebian.sh rename to bin/buildDebian.sh index 241b3f751..f1f5675ec 100755 --- a/src/bin/buildDebian.sh +++ b/bin/buildDebian.sh @@ -14,7 +14,7 @@ rm -rf ${DIST} mkdir -p ${DIST}/ rm -rf ${SRC} -rsync -a src/bin/deb-src/ ${SRC}/ +rsync -a bin/deb-src/ ${SRC}/ mkdir -p ${SYSROOT}/opt/ rsync --exclude '.git' -a . ${SYSROOT}/opt/etherpad/ --delete diff --git a/src/bin/buildForWindows.sh b/bin/buildForWindows.sh similarity index 98% rename from src/bin/buildForWindows.sh rename to bin/buildForWindows.sh index ffba06eb6..e49a3da69 100755 --- a/src/bin/buildForWindows.sh +++ b/bin/buildForWindows.sh @@ -47,7 +47,7 @@ rm -rf node_modules || true rm -rf src/node_modules || true #log "do a normal unix install first..." -#$(try cd src && ./bin/installDeps.sh) +#$(try cd ./bin/installDeps.sh) log "copy the windows settings template..." try cp settings.json.template settings.json diff --git a/src/bin/checkAllPads.js b/bin/checkAllPads.js similarity index 79% rename from src/bin/checkAllPads.js rename to bin/checkAllPads.js index d2a5f837c..69514f358 100644 --- a/src/bin/checkAllPads.js +++ b/bin/checkAllPads.js @@ -7,12 +7,12 @@ // unhandled rejection into an uncaught exception, which does cause Node.js to exit. process.on('unhandledRejection', (err) => { throw err; }); -if (process.argv.length !== 2) throw new Error('Use: node src/bin/checkAllPads.js'); +if (process.argv.length !== 2) throw new Error('Use: node bin/checkAllPads.js'); (async () => { - const db = require('../node/db/DB'); + const db = require('./src/node/db/DB'); await db.init(); - const padManager = require('../node/db/PadManager'); + const padManager = require('./src/node/db/PadManager'); await Promise.all((await padManager.listAllPads()).padIDs.map(async (padId) => { const pad = await padManager.getPad(padId); try { diff --git a/src/bin/checkPad.js b/bin/checkPad.js similarity index 75% rename from src/bin/checkPad.js rename to bin/checkPad.js index 6aa4b3034..104486371 100644 --- a/src/bin/checkPad.js +++ b/bin/checkPad.js @@ -7,12 +7,12 @@ // unhandled rejection into an uncaught exception, which does cause Node.js to exit. process.on('unhandledRejection', (err) => { throw err; }); -if (process.argv.length !== 3) throw new Error('Use: node src/bin/checkPad.js $PADID'); +if (process.argv.length !== 3) throw new Error('Use: node bin/checkPad.js $PADID'); const padId = process.argv[2]; (async () => { - const db = require('../node/db/DB'); + const db = require('./src/node/db/DB'); await db.init(); - const padManager = require('../node/db/PadManager'); + const padManager = require('./src/node/db/PadManager'); if (!await padManager.doesPadExists(padId)) throw new Error('Pad does not exist'); const pad = await padManager.getPad(padId); await pad.check(); diff --git a/src/bin/cleanRun.sh b/bin/cleanRun.sh similarity index 89% rename from src/bin/cleanRun.sh rename to bin/cleanRun.sh index adac8c662..acff0d669 100755 --- a/src/bin/cleanRun.sh +++ b/bin/cleanRun.sh @@ -2,10 +2,10 @@ # Move to the Etherpad base directory. MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 -cd "${MY_DIR}/../.." || exit 1 +cd "${MY_DIR}/.." || exit 1 # Source constants and useful functions -. src/bin/functions.sh +. bin/functions.sh ignoreRoot=0 for ARG in "$@" @@ -31,7 +31,7 @@ fi rm -rf src/node_modules #Prepare the environment -src/bin/installDeps.sh "$@" || exit 1 +bin/installDeps.sh "$@" || exit 1 #Move to the node folder and start echo "Starting Etherpad..." diff --git a/src/bin/convertSettings.json.template b/bin/convertSettings.json.template similarity index 100% rename from src/bin/convertSettings.json.template rename to bin/convertSettings.json.template diff --git a/src/bin/createRelease.sh b/bin/createRelease.sh similarity index 99% rename from src/bin/createRelease.sh rename to bin/createRelease.sh index 14e3cd337..e3b0eb0d3 100755 --- a/src/bin/createRelease.sh +++ b/bin/createRelease.sh @@ -134,7 +134,7 @@ function create_builds { git clone $ETHER_WEB_REPO echo "Creating windows build..." cd etherpad-lite - src/bin/buildForWindows.sh + bin/buildForWindows.sh [[ $? != 0 ]] && echo "Aborting: Error creating build for windows" && exit 1 echo "Creating docs..." make docs diff --git a/src/bin/createUserSession.js b/bin/createUserSession.js similarity index 94% rename from src/bin/createUserSession.js rename to bin/createUserSession.js index 33dcac18e..58ab1bba5 100644 --- a/src/bin/createUserSession.js +++ b/bin/createUserSession.js @@ -12,13 +12,13 @@ process.on('unhandledRejection', (err) => { throw err; }); const fs = require('fs'); const path = require('path'); const querystring = require('querystring'); -const settings = require('../node/utils/Settings'); +const settings = require('./src/node/utils/Settings'); const supertest = require('supertest'); (async () => { const api = supertest(`http://${settings.ip}:${settings.port}`); - const filePath = path.join(__dirname, '../../APIKEY.txt'); + const filePath = path.join(__dirname, '../APIKEY.txt'); const apikey = fs.readFileSync(filePath, {encoding: 'utf-8'}); let res; diff --git a/src/bin/deb-src/DEBIAN/control b/bin/deb-src/DEBIAN/control similarity index 100% rename from src/bin/deb-src/DEBIAN/control rename to bin/deb-src/DEBIAN/control diff --git a/src/bin/deb-src/DEBIAN/postinst b/bin/deb-src/DEBIAN/postinst similarity index 100% rename from src/bin/deb-src/DEBIAN/postinst rename to bin/deb-src/DEBIAN/postinst diff --git a/src/bin/deb-src/DEBIAN/preinst b/bin/deb-src/DEBIAN/preinst similarity index 100% rename from src/bin/deb-src/DEBIAN/preinst rename to bin/deb-src/DEBIAN/preinst diff --git a/src/bin/deb-src/DEBIAN/prerm b/bin/deb-src/DEBIAN/prerm similarity index 100% rename from src/bin/deb-src/DEBIAN/prerm rename to bin/deb-src/DEBIAN/prerm diff --git a/src/bin/deb-src/sysroot/etc/init/etherpad.conf b/bin/deb-src/sysroot/etc/init/etherpad.conf similarity index 90% rename from src/bin/deb-src/sysroot/etc/init/etherpad.conf rename to bin/deb-src/sysroot/etc/init/etherpad.conf index 9a2fcf42f..ea8349d10 100644 --- a/src/bin/deb-src/sysroot/etc/init/etherpad.conf +++ b/bin/deb-src/sysroot/etc/init/etherpad.conf @@ -15,7 +15,7 @@ pre-start script chown $EPUSER $EPLOGS ||true chmod 0755 $EPLOGS ||true chown -R $EPUSER $EPHOME/var ||true - $EPHOME/src/bin/installDeps.sh >> $EPLOGS/error.log || { stop; exit 1; } + $EPHOME/bin/installDeps.sh >> $EPLOGS/error.log || { stop; exit 1; } end script script diff --git a/src/bin/debugRun.sh b/bin/debugRun.sh similarity index 87% rename from src/bin/debugRun.sh rename to bin/debugRun.sh index 1336e295a..2bfe969c9 100755 --- a/src/bin/debugRun.sh +++ b/bin/debugRun.sh @@ -2,13 +2,13 @@ # Move to the Etherpad base directory. MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 -cd "${MY_DIR}/../.." || exit 1 +cd "${MY_DIR}/.." || exit 1 # Source constants and useful functions -. src/bin/functions.sh +. bin/functions.sh # Prepare the environment -src/bin/installDeps.sh || exit 1 +bin/installDeps.sh || exit 1 echo "If you are new to debugging Node.js with Chrome DevTools, take a look at this page:" echo "https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27" diff --git a/src/bin/deleteAllGroupSessions.js b/bin/deleteAllGroupSessions.js similarity index 92% rename from src/bin/deleteAllGroupSessions.js rename to bin/deleteAllGroupSessions.js index c95bf1075..4b619265f 100644 --- a/src/bin/deleteAllGroupSessions.js +++ b/bin/deleteAllGroupSessions.js @@ -18,11 +18,11 @@ const supertest = require('supertest'); let deleteCount = 0; // get the API Key -const filePath = path.join(__dirname, '../../APIKEY.txt'); +const filePath = path.join(__dirname, '../APIKEY.txt'); console.log('Deleting all group sessions, please be patient.'); (async () => { - const settings = require('../tests/container/loadSettings').loadSettings(); + const settings = require('./src/tests/container/loadSettings').loadSettings(); const apikey = fs.readFileSync(filePath, {encoding: 'utf-8'}); const api = supertest(`http://${settings.ip}:${settings.port}`); diff --git a/src/bin/deletePad.js b/bin/deletePad.js similarity index 90% rename from src/bin/deletePad.js rename to bin/deletePad.js index 51ea99639..7823cbd8b 100644 --- a/src/bin/deletePad.js +++ b/bin/deletePad.js @@ -9,7 +9,7 @@ // unhandled rejection into an uncaught exception, which does cause Node.js to exit. process.on('unhandledRejection', (err) => { throw err; }); -const settings = require('../tests/container/loadSettings').loadSettings(); +const settings = require('./src/tests/container/loadSettings').loadSettings(); const path = require('path'); const fs = require('fs'); const supertest = require('supertest'); @@ -22,7 +22,7 @@ if (process.argv.length !== 3) throw new Error('Use: node deletePad.js $PADID'); const padId = process.argv[2]; // get the API Key -const filePath = path.join(__dirname, '../../APIKEY.txt'); +const filePath = path.join(__dirname, '../APIKEY.txt'); const apikey = fs.readFileSync(filePath, {encoding: 'utf-8'}); (async () => { diff --git a/src/bin/doc/LICENSE b/bin/doc/LICENSE similarity index 100% rename from src/bin/doc/LICENSE rename to bin/doc/LICENSE diff --git a/src/bin/doc/README.md b/bin/doc/README.md similarity index 100% rename from src/bin/doc/README.md rename to bin/doc/README.md diff --git a/src/bin/doc/generate.js b/bin/doc/generate.js similarity index 100% rename from src/bin/doc/generate.js rename to bin/doc/generate.js diff --git a/src/bin/doc/html.js b/bin/doc/html.js similarity index 100% rename from src/bin/doc/html.js rename to bin/doc/html.js diff --git a/src/bin/doc/json.js b/bin/doc/json.js similarity index 100% rename from src/bin/doc/json.js rename to bin/doc/json.js diff --git a/src/bin/etherpad-healthcheck b/bin/etherpad-healthcheck similarity index 100% rename from src/bin/etherpad-healthcheck rename to bin/etherpad-healthcheck diff --git a/src/bin/extractPadData.js b/bin/extractPadData.js similarity index 92% rename from src/bin/extractPadData.js rename to bin/extractPadData.js index b0d0212d7..51c3abcdc 100644 --- a/src/bin/extractPadData.js +++ b/bin/extractPadData.js @@ -19,13 +19,13 @@ const padId = process.argv[2]; (async () => { // initialize database - require('../node/utils/Settings'); - const db = require('../node/db/DB'); + require('./src/node/utils/Settings'); + const db = require('./src/node/db/DB'); await db.init(); // load extra modules const dirtyDB = require('dirty'); - const padManager = require('../node/db/PadManager'); + const padManager = require('./src/node/db/PadManager'); // initialize output database const dirty = dirtyDB(`${padId}.db`); diff --git a/src/bin/fastRun.sh b/bin/fastRun.sh similarity index 91% rename from src/bin/fastRun.sh rename to bin/fastRun.sh index 6b4996175..b18469edb 100755 --- a/src/bin/fastRun.sh +++ b/bin/fastRun.sh @@ -11,10 +11,10 @@ set -eu # Move to the Etherpad base directory. MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 -cd "${MY_DIR}/../.." || exit 1 +cd "${MY_DIR}/.." || exit 1 # Source constants and useful functions -. src/bin/functions.sh +. bin/functions.sh echo "Running directly, without checking/installing dependencies" diff --git a/src/bin/functions.sh b/bin/functions.sh similarity index 100% rename from src/bin/functions.sh rename to bin/functions.sh diff --git a/src/bin/importSqlFile.js b/bin/importSqlFile.js similarity index 97% rename from src/bin/importSqlFile.js rename to bin/importSqlFile.js index 148503e8d..145e19bf7 100644 --- a/src/bin/importSqlFile.js +++ b/bin/importSqlFile.js @@ -49,7 +49,7 @@ const unescape = (val) => { const fs = require('fs'); const log4js = require('log4js'); const readline = require('readline'); - const settings = require('../node/utils/Settings'); + const settings = require('./src/node/utils/Settings'); const ueberDB = require('ueberdb2'); const dbWrapperSettings = { diff --git a/src/bin/installDeps.sh b/bin/installDeps.sh similarity index 82% rename from src/bin/installDeps.sh rename to bin/installDeps.sh index 722dec0d0..af2b5e30a 100755 --- a/src/bin/installDeps.sh +++ b/bin/installDeps.sh @@ -3,10 +3,10 @@ # Move to the Etherpad base directory. MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 -cd "${MY_DIR}/../.." || exit 1 +cd "${MY_DIR}/.." || exit 1 # Source constants and useful functions -. src/bin/functions.sh +. bin/functions.sh is_cmd pnpm || npm install pnpm -g @@ -33,16 +33,13 @@ if [ ! -f "$settings" ]; then cp settings.json.template "$settings" || exit 1 fi - log "Installing dependencies..." -cd src - if [ -z "${ETHERPAD_PRODUCTION}" ]; then - log "Installing dev dependencies" - pnpm i || exit 1 + log "Installing dev dependencies with pnpm" + pnpm --recursive i || exit 1 else - log "Installing production dependencies" - pnpm i --production || exit 1 + log "Installing production dependencies with pnpm" + pnpm --recursive i --production || exit 1 fi # Remove all minified data to force node creating it new diff --git a/src/bin/installOnWindows.bat b/bin/installOnWindows.bat similarity index 94% rename from src/bin/installOnWindows.bat rename to bin/installOnWindows.bat index 56bd4c7de..bf8e6a321 100644 --- a/src/bin/installOnWindows.bat +++ b/bin/installOnWindows.bat @@ -1,7 +1,7 @@ @echo off :: Change directory to etherpad-lite root -cd /D "%~dp0\..\.." +cd /D "%~dp0\.." :: Is node installed? cmd /C node -e "" || ( echo "Please install node.js ( https://nodejs.org )" && exit /B 1 ) @@ -16,7 +16,7 @@ mklink /D "ep_etherpad-lite" "..\src" cd /D ..\src cmd /C pnpm i || exit /B 1 -cd /D "%~dp0\..\.." +cd /D "%~dp0\.." echo _ echo Clearing cache... diff --git a/src/bin/migrateDirtyDBtoRealDB.js b/bin/migrateDirtyDBtoRealDB.js similarity index 94% rename from src/bin/migrateDirtyDBtoRealDB.js rename to bin/migrateDirtyDBtoRealDB.js index 75f6cc677..37a95212a 100644 --- a/src/bin/migrateDirtyDBtoRealDB.js +++ b/bin/migrateDirtyDBtoRealDB.js @@ -14,7 +14,7 @@ process.on('unhandledRejection', (err) => { throw err; }); const dirtyDb = require('dirty'); const log4js = require('log4js'); - const settings = require('../node/utils/Settings'); + const settings = require('./src/node/utils/Settings'); const ueberDB = require('ueberdb2'); const util = require('util'); @@ -30,7 +30,7 @@ process.on('unhandledRejection', (err) => { throw err; }); await db.init(); console.log('Waiting for dirtyDB to parse its file.'); - const dirty = dirtyDb(`${__dirname}/../../var/dirty.db`); + const dirty = dirtyDb(`${__dirname}/../var/dirty.db`); const length = await new Promise((resolve) => { dirty.once('load', resolve); }); console.log(`Found ${length} records, processing now.`); diff --git a/src/bin/nsis/README.md b/bin/nsis/README.md similarity index 100% rename from src/bin/nsis/README.md rename to bin/nsis/README.md diff --git a/src/bin/nsis/brand.ico b/bin/nsis/brand.ico similarity index 100% rename from src/bin/nsis/brand.ico rename to bin/nsis/brand.ico diff --git a/src/bin/nsis/etherpad.nsi b/bin/nsis/etherpad.nsi similarity index 100% rename from src/bin/nsis/etherpad.nsi rename to bin/nsis/etherpad.nsi diff --git a/src/bin/plugins/README.md b/bin/plugins/README.md similarity index 100% rename from src/bin/plugins/README.md rename to bin/plugins/README.md diff --git a/src/bin/plugins/checkPlugin.js b/bin/plugins/checkPlugin.js similarity index 94% rename from src/bin/plugins/checkPlugin.js rename to bin/plugins/checkPlugin.js index 8f557c3c5..132097ef7 100755 --- a/src/bin/plugins/checkPlugin.js +++ b/bin/plugins/checkPlugin.js @@ -3,11 +3,11 @@ /* * Usage -- see README.md * - * Normal usage: node src/bin/plugins/checkPlugin.js ep_whatever - * Auto fix the things it can: node src/bin/plugins/checkPlugin.js ep_whatever autofix - * Auto fix and commit: node src/bin/plugins/checkPlugin.js ep_whatever autocommit + * Normal usage: node bin/plugins/checkPlugin.js ep_whatever + * Auto fix the things it can: node bin/plugins/checkPlugin.js ep_whatever autofix + * Auto fix and commit: node bin/plugins/checkPlugin.js ep_whatever autocommit * Auto fix, commit, push and publish to npm (highly dangerous): - * node src/bin/plugins/checkPlugin.js ep_whatever autopush + * node bin/plugins/checkPlugin.js ep_whatever autopush */ const process = require('process'); @@ -32,7 +32,7 @@ const logger = log4js.getLogger('checkPlugin'); if (!pluginName) throw new Error('no plugin name specified'); logger.info(`Checking the plugin: ${pluginName}`); - const epRootDir = await fsp.realpath(path.join(await fsp.realpath(__dirname), '../../..')); + const epRootDir = await fsp.realpath(path.join(await fsp.realpath(__dirname), '../..')); logger.info(`Etherpad root directory: ${epRootDir}`); process.chdir(epRootDir); const pluginPath = await fsp.realpath(`node_modules/${pluginName}`); @@ -159,9 +159,9 @@ const logger = log4js.getLogger('checkPlugin'); const workflows = ['backend-tests.yml', 'frontend-tests.yml', 'npmpublish.yml']; await Promise.all(workflows.map(async (fn) => { - await checkFile(`src/bin/plugins/lib/${fn}`, `.github/workflows/${fn}`); + await checkFile(`bin/plugins/lib/${fn}`, `.github/workflows/${fn}`); })); - await checkFile('src/bin/plugins/lib/dependabot.yml', '.github/dependabot.yml'); + await checkFile('bin/plugins/lib/dependabot.yml', '.github/dependabot.yml'); if (!files.includes('package.json')) { logger.warn('no package.json, please create'); @@ -214,7 +214,7 @@ const logger = log4js.getLogger('checkPlugin'); logger.error(`both ${from} and ${to} exist; delete ${from}`); } } else { - checkFile('src/bin/plugins/lib/eslintrc.cjs', '.eslintrc.cjs', false); + checkFile('bin/plugins/lib/eslintrc.cjs', '.eslintrc.cjs', false); } if (checkEntries(parsedPackageJSON, { @@ -251,7 +251,7 @@ const logger = log4js.getLogger('checkPlugin'); if (autoFix) { logger.info('Autofixing missing README.md file'); logger.info('please edit the README.md file further to include plugin specific details.'); - await fillTemplate('src/bin/plugins/lib/README.md', `${pluginPath}/README.md`); + await fillTemplate('bin/plugins/lib/README.md', `${pluginPath}/README.md`); } } @@ -260,7 +260,7 @@ const logger = log4js.getLogger('checkPlugin'); if (autoFix) { logger.info('Autofixing missing CONTRIBUTING.md file, please edit the CONTRIBUTING.md ' + 'file further to include plugin specific details.'); - await fillTemplate('src/bin/plugins/lib/CONTRIBUTING.md', `${pluginPath}/CONTRIBUTING.md`); + await fillTemplate('bin/plugins/lib/CONTRIBUTING.md', `${pluginPath}/CONTRIBUTING.md`); } } @@ -296,7 +296,7 @@ const logger = log4js.getLogger('checkPlugin'); logger.warn('LICENSE file not found, please create'); if (autoFix) { logger.info('Autofixing missing LICENSE file (Apache 2.0).'); - await fsp.copyFile('src/bin/plugins/lib/LICENSE', `${pluginPath}/LICENSE`); + await fsp.copyFile('bin/plugins/lib/LICENSE', `${pluginPath}/LICENSE`); } } @@ -306,7 +306,7 @@ const logger = log4js.getLogger('checkPlugin'); if (autoFix) { logger.info('Autofixing missing .gitignore file'); const gitignore = - await fsp.readFile('src/bin/plugins/lib/gitignore', {encoding: 'utf8', flag: 'r'}); + await fsp.readFile('bin/plugins/lib/gitignore', {encoding: 'utf8', flag: 'r'}); await fsp.writeFile(`${pluginPath}/.gitignore`, gitignore); } } else { diff --git a/src/bin/plugins/getCorePlugins.sh b/bin/plugins/getCorePlugins.sh similarity index 97% rename from src/bin/plugins/getCorePlugins.sh rename to bin/plugins/getCorePlugins.sh index 85552ab14..db0599e14 100755 --- a/src/bin/plugins/getCorePlugins.sh +++ b/bin/plugins/getCorePlugins.sh @@ -11,7 +11,7 @@ error () { log "ERROR: $@" >&2; } fatal () { error "$@"; exit 1; } mydir=$(cd "${0%/*}" && pwd -P) || exit 1 -cd "${mydir}/../../.." +cd "${mydir}/../.." pdir=$(cd .. && pwd -P) || exit 1 plugins=$("${mydir}/listOfficialPlugins") || exit 1 diff --git a/src/bin/plugins/lib/CONTRIBUTING.md b/bin/plugins/lib/CONTRIBUTING.md similarity index 100% rename from src/bin/plugins/lib/CONTRIBUTING.md rename to bin/plugins/lib/CONTRIBUTING.md diff --git a/src/bin/plugins/lib/LICENSE b/bin/plugins/lib/LICENSE similarity index 100% rename from src/bin/plugins/lib/LICENSE rename to bin/plugins/lib/LICENSE diff --git a/src/bin/plugins/lib/README.md b/bin/plugins/lib/README.md similarity index 100% rename from src/bin/plugins/lib/README.md rename to bin/plugins/lib/README.md diff --git a/src/bin/plugins/lib/backend-tests.yml b/bin/plugins/lib/backend-tests.yml similarity index 97% rename from src/bin/plugins/lib/backend-tests.yml rename to bin/plugins/lib/backend-tests.yml index 184eb26fc..e8304ea02 100644 --- a/src/bin/plugins/lib/backend-tests.yml +++ b/bin/plugins/lib/backend-tests.yml @@ -49,7 +49,7 @@ jobs: cache: 'npm' cache-dependency-path: | src/package-lock.json - src/bin/doc/package-lock.json + bin/doc/package-lock.json node_modules/${{ steps.plugin_name.outputs.plugin_name }}/package-lock.json - name: Install plugin dependencies @@ -69,7 +69,7 @@ jobs: # rules. - name: Install Etherpad core dependencies - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: Run the backend tests run: cd src && pnpm test diff --git a/src/bin/plugins/lib/dependabot.yml b/bin/plugins/lib/dependabot.yml similarity index 100% rename from src/bin/plugins/lib/dependabot.yml rename to bin/plugins/lib/dependabot.yml diff --git a/src/bin/plugins/lib/eslintrc.cjs b/bin/plugins/lib/eslintrc.cjs similarity index 100% rename from src/bin/plugins/lib/eslintrc.cjs rename to bin/plugins/lib/eslintrc.cjs diff --git a/src/bin/plugins/lib/frontend-tests.yml b/bin/plugins/lib/frontend-tests.yml similarity index 98% rename from src/bin/plugins/lib/frontend-tests.yml rename to bin/plugins/lib/frontend-tests.yml index 8491ec3d1..f4c6d34a3 100644 --- a/src/bin/plugins/lib/frontend-tests.yml +++ b/bin/plugins/lib/frontend-tests.yml @@ -38,7 +38,7 @@ jobs: cache: 'npm' cache-dependency-path: | src/package-lock.json - src/bin/doc/package-lock.json + bin/doc/package-lock.json - name: Check out the plugin uses: actions/checkout@v3 @@ -80,7 +80,7 @@ jobs: # rules. - name: Install Etherpad core dependencies - run: src/bin/installDeps.sh + run: bin/installDeps.sh - name: Create settings.json run: cp settings.json.template settings.json diff --git a/src/bin/plugins/lib/gitignore b/bin/plugins/lib/gitignore similarity index 100% rename from src/bin/plugins/lib/gitignore rename to bin/plugins/lib/gitignore diff --git a/src/bin/plugins/lib/npmpublish.yml b/bin/plugins/lib/npmpublish.yml similarity index 100% rename from src/bin/plugins/lib/npmpublish.yml rename to bin/plugins/lib/npmpublish.yml diff --git a/src/bin/plugins/listOfficialPlugins b/bin/plugins/listOfficialPlugins similarity index 95% rename from src/bin/plugins/listOfficialPlugins rename to bin/plugins/listOfficialPlugins index 322ad5d3b..61cd8b0ce 100755 --- a/src/bin/plugins/listOfficialPlugins +++ b/bin/plugins/listOfficialPlugins @@ -3,7 +3,7 @@ set -e newline=' ' mydir=$(cd "${0%/*}" && pwd -P) || exit 1 -cd "${mydir}/../../.." +cd "${mydir}/../.." pdir=$(cd .. && pwd -P) || exit 1 plugins= for p in "" "&page=2" "&page=3"; do diff --git a/src/bin/plugins/reTestAllPlugins.sh b/bin/plugins/reTestAllPlugins.sh similarity index 84% rename from src/bin/plugins/reTestAllPlugins.sh rename to bin/plugins/reTestAllPlugins.sh index abe1bca80..ccabd1bc6 100755 --- a/src/bin/plugins/reTestAllPlugins.sh +++ b/bin/plugins/reTestAllPlugins.sh @@ -4,7 +4,7 @@ do echo $dir if [[ $dir == *"ep_"* ]]; then if [[ $dir != "ep_etherpad-lite" ]]; then - # node src/bin/plugins/checkPlugin.js $dir autopush + # node bin/plugins/checkPlugin.js $dir autopush cd node_modules/$dir git commit -m "Automatic update: bump update to re-run latest Etherpad tests" --allow-empty git push origin master diff --git a/src/bin/plugins/stalePlugins.js b/bin/plugins/stalePlugins.js similarity index 100% rename from src/bin/plugins/stalePlugins.js rename to bin/plugins/stalePlugins.js diff --git a/src/bin/plugins/updateAllPluginsScript.sh b/bin/plugins/updateAllPluginsScript.sh similarity index 93% rename from src/bin/plugins/updateAllPluginsScript.sh rename to bin/plugins/updateAllPluginsScript.sh index 79be4bc47..3ee0118be 100755 --- a/src/bin/plugins/updateAllPluginsScript.sh +++ b/bin/plugins/updateAllPluginsScript.sh @@ -10,7 +10,7 @@ do # echo $0 if [[ $dir == *"ep_"* ]]; then if [[ $dir != "ep_etherpad-lite" ]]; then - node src/bin/plugins/checkPlugin.js $dir autopush + node bin/plugins/checkPlugin.js $dir autopush fi fi # echo $dir diff --git a/src/bin/plugins/updateCorePlugins.sh b/bin/plugins/updateCorePlugins.sh similarity index 70% rename from src/bin/plugins/updateCorePlugins.sh rename to bin/plugins/updateCorePlugins.sh index 3866b8444..51ef7724c 100755 --- a/src/bin/plugins/updateCorePlugins.sh +++ b/bin/plugins/updateCorePlugins.sh @@ -5,5 +5,5 @@ set -e for dir in node_modules/ep_*; do dir=${dir#node_modules/} [ "$dir" != ep_etherpad-lite ] || continue - node src/bin/plugins/checkPlugin.js "$dir" autopush + node bin/plugins/checkPlugin.js "$dir" autopush done diff --git a/src/bin/push-after-release.sh b/bin/push-after-release.sh similarity index 82% rename from src/bin/push-after-release.sh rename to bin/push-after-release.sh index 8781196fb..b426f630b 100755 --- a/src/bin/push-after-release.sh +++ b/bin/push-after-release.sh @@ -1,7 +1,7 @@ #!/bin/bash # Specify the path to your package.json file -PACKAGE_JSON_PATH="./src//package.json" +PACKAGE_JSON_PATH="./src/package.json" # Check if the file exists if [ ! -f "$PACKAGE_JSON_PATH" ]; then diff --git a/src/bin/rebuildPad.js b/bin/rebuildPad.js similarity index 89% rename from src/bin/rebuildPad.js rename to bin/rebuildPad.js index 73f530889..52194c9a3 100644 --- a/src/bin/rebuildPad.js +++ b/bin/rebuildPad.js @@ -10,7 +10,7 @@ process.on('unhandledRejection', (err) => { throw err; }); if (process.argv.length !== 4 && process.argv.length !== 5) { - throw new Error('Use: node src/bin/repairPad.js $PADID $REV [$NEWPADID]'); + throw new Error('Use: node bin/repairPad.js $PADID $REV [$NEWPADID]'); } const padId = process.argv[2]; @@ -18,11 +18,11 @@ const newRevHead = process.argv[3]; const newPadId = process.argv[4] || `${padId}-rebuilt`; (async () => { - const db = require('../node/db/DB'); + const db = require('./src/node/db/DB'); await db.init(); - const PadManager = require('../node/db/PadManager'); - const Pad = require('../node/db/Pad').Pad; + const PadManager = require('./src/node/db/PadManager'); + const Pad = require('./src/node/db/Pad').Pad; // Validate the newPadId if specified and that a pad with that ID does // not already exist to avoid overwriting it. if (!PadManager.isValidPadId(newPadId)) { @@ -43,8 +43,8 @@ const newPadId = process.argv[4] || `${padId}-rebuilt`; })); // Rebuild Pad from revisions up to and including the new revision head - const AuthorManager = require('../node/db/AuthorManager'); - const Changeset = require('../static/js/Changeset'); + const AuthorManager = require('./src/node/db/AuthorManager'); + const Changeset = require('./src/static/js/Changeset'); // Author attributes are derived from changesets, but there can also be // non-author attributes with specific mappings that changesets depend on // and, AFAICT, cannot be recreated any other way diff --git a/src/bin/release.js b/bin/release.js similarity index 97% rename from src/bin/release.js rename to bin/release.js index ee5f245e7..47a74a41f 100644 --- a/src/bin/release.js +++ b/bin/release.js @@ -20,11 +20,11 @@ log4js.configure({appenders: {console: {type: 'console'}}, Usage -node src/bin/release.js patch +node bin/release.js patch */ const usage = - 'node src/bin/release.js [patch/minor/major] -- example: "node src/bin/release.js patch"'; + 'node bin/release.js [patch/minor/major] -- example: "node bin/release.js patch"'; const release = process.argv[2]; @@ -33,7 +33,7 @@ if (!release) { throw new Error('No release type included'); } -const cwd = path.join(fs.realpathSync(__dirname), '../../'); +const cwd = path.join(fs.realpathSync(__dirname), '../'); process.chdir(cwd); // Run command capturing stdout. Trailing newlines are stripped (like the shell does). diff --git a/src/bin/repairPad.js b/bin/repairPad.js similarity index 87% rename from src/bin/repairPad.js rename to bin/repairPad.js index ed1d83659..bf346c8e7 100644 --- a/src/bin/repairPad.js +++ b/bin/repairPad.js @@ -10,7 +10,7 @@ process.on('unhandledRejection', (err) => { throw err; }); console.warn('WARNING: This script must not be used while etherpad is running!'); -if (process.argv.length !== 3) throw new Error('Use: node src/bin/repairPad.js $PADID'); +if (process.argv.length !== 3) throw new Error('Use: node ./src/bin/repairPad.js $PADID'); // get the padID const padId = process.argv[2]; @@ -19,12 +19,12 @@ let valueCount = 0; (async () => { // initialize database - require('../node/utils/Settings'); - const db = require('../node/db/DB'); + require('./src/node/utils/Settings'); + const db = require('./src/node/db/DB'); await db.init(); // get the pad - const padManager = require('../node/db/PadManager'); + const padManager = require('./src/node/db/PadManager'); const pad = await padManager.getPad(padId); // accumulate the required keys diff --git a/src/bin/run.sh b/bin/run.sh similarity index 88% rename from src/bin/run.sh rename to bin/run.sh index 0f11a1239..4f0b8f83a 100755 --- a/src/bin/run.sh +++ b/bin/run.sh @@ -2,10 +2,10 @@ # Move to the Etherpad base directory. MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 -cd "${MY_DIR}/../.." || exit 1 +cd "${MY_DIR}/.." || exit 1 # Source constants and useful functions -. src/bin/functions.sh +. bin/functions.sh ignoreRoot=0 for ARG in "$@"; do @@ -27,9 +27,10 @@ EOF fi # Prepare the environment -src/bin/installDeps.sh "$@" || exit 1 +bin/installDeps.sh "$@" || exit 1 # Move to the node folder and start log "Starting Etherpad..." +# cd src exec pnpm run dev "$@" diff --git a/src/bin/safeRun.sh b/bin/safeRun.sh similarity index 95% rename from src/bin/safeRun.sh rename to bin/safeRun.sh index d980b9300..72ac475be 100755 --- a/src/bin/safeRun.sh +++ b/bin/safeRun.sh @@ -25,7 +25,7 @@ LAST_EMAIL_SEND=0 # Move to the Etherpad base directory. MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 -cd "${MY_DIR}/../.." || exit 1 +cd "${MY_DIR}/.." || exit 1 # Check if a logfile parameter is set LOG="$1" @@ -40,7 +40,7 @@ while true; do [ -w "${LOG}" ] || fatal "Logfile '${LOG}' is not writeable" # Start the application - src/bin/run.sh "$@" >>${LOG} 2>>${LOG} + bin/run.sh "$@" >>${LOG} 2>>${LOG} TIME_FMT=$(date +%Y-%m-%dT%H:%M:%S%z) diff --git a/src/bin/updatePlugins.sh b/bin/updatePlugins.sh similarity index 92% rename from src/bin/updatePlugins.sh rename to bin/updatePlugins.sh index 586ba1623..55879e6bf 100755 --- a/src/bin/updatePlugins.sh +++ b/bin/updatePlugins.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e mydir=$(cd "${0%/*}" && pwd -P) || exit 1 -cd "${mydir}"/../.. +cd "${mydir}"/.. OUTDATED=$(npm outdated --depth=0 | awk '{print $1}' | grep '^ep_') || { echo "All plugins are up-to-date" exit 0 diff --git a/doc/docker.adoc b/doc/docker.adoc index ec5277f80..e26323337 100644 --- a/doc/docker.adoc +++ b/doc/docker.adoc @@ -30,7 +30,7 @@ docker compose up -d # will build and start the docker container on port 9001 wi Starting dev server: ``` -docker compose exec app bash -c "./src/bin/run.sh" +docker compose exec app bash -c "./bin/run.sh" ``` For production, please create your own docker compose file and change the `target` property in the build section to `production`. In addition, change the NODE_ENV in environment to production. For instance: diff --git a/docker-compose.yml b/docker-compose.yml index 189c23f91..4efb74da4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,10 +15,10 @@ services: tty: true stdin_open: true volumes: + # no volume mapping of node_modules as otherwise the build-time installed plugins will be overwritten with the mount + # the same applies to package.json and pnpm-lock.yaml in root dir as these would also get overwritten and build time installed plugins will be removed - ./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 + - ./bin:/opt/etherpad-lite/bin depends_on: - postgres environment: @@ -60,6 +60,4 @@ services: - postgres_data:/var/lib/postgresql/data/pgdata volumes: - postgres_data: - node_modules: - pnpm-store: \ No newline at end of file + postgres_data: \ No newline at end of file diff --git a/package.json b/package.json index 77ccdbc6f..891edbd5a 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "editor" ], "bin": { - "etherpad-healthcheck": "src/bin/etherpad-healthcheck", - "etherpad-lite": "src/bin/run" + "etherpad-healthcheck": "bin/etherpad-healthcheck", + "etherpad-lite": "bin/run" }, "scripts": { "lint": "pnpm --filter ep_etherpad-lite run lint", diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index e69de29bb..ced0baca4 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - src \ No newline at end of file diff --git a/src/package.json b/src/package.json index 784efd9f6..ba392899f 100644 --- a/src/package.json +++ b/src/package.json @@ -75,7 +75,7 @@ "wtfnode": "^0.9.1" }, "bin": { - "etherpad-healthcheck": "bin/etherpad-healthcheck", + "etherpad-healthcheck": "../bin/etherpad-healthcheck", "etherpad-lite": "node/server.ts" }, "devDependencies": { diff --git a/src/tests/frontend/travis/runner.sh b/src/tests/frontend/travis/runner.sh index 7796bc2ef..c2c2907e3 100755 --- a/src/tests/frontend/travis/runner.sh +++ b/src/tests/frontend/travis/runner.sh @@ -10,7 +10,7 @@ try() { "$@" || fatal "'$@' failed"; } MY_DIR=$(try cd "${0%/*}" && try pwd -P) || exit 1 try cd "${MY_DIR}/../../../.." -log "Assuming src/bin/installDeps.sh has already been run" +log "Assuming bin/installDeps.sh has already been run" (cd src && npm run dev --experimental-worker "${@}" & ep_pid=$!)