From 8b28e007842efefccf852a55f783761f86dc6090 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 4 Feb 2021 18:43:27 -0500 Subject: [PATCH] restructure: Prefix `bin/` and `tests/` with `src/` This is a follow-up to commit 2ea8ea12754c92ea06f22428f1e86341dcf00d99. --- .github/workflows/backend-tests.yml | 8 ++-- .github/workflows/dockerfile.yml | 2 +- .github/workflows/frontend-tests.yml | 14 +++---- .github/workflows/load-test.yml | 8 ++-- .github/workflows/rate-limit.yml | 8 ++-- .gitignore | 8 ++-- .travis.yml | 38 +++++++++---------- Dockerfile | 2 +- Makefile | 6 +-- README.md | 27 +++++++++---- doc/documentation.md | 2 +- src/bin/buildDebian.sh | 2 +- src/bin/buildForWindows.sh | 5 +-- src/bin/checkAllPads.js | 2 +- src/bin/checkPad.js | 2 +- src/bin/checkPadDeltas.js | 2 +- src/bin/cleanRun.sh | 14 +++---- src/bin/createRelease.sh | 2 +- .../deb-src/sysroot/etc/init/etherpad.conf | 2 +- src/bin/debugRun.sh | 9 +++-- src/bin/doc/README.md | 4 +- src/bin/fastRun.sh | 13 +++---- src/bin/installDeps.sh | 7 ++-- src/bin/migrateDirtyDBtoRealDB.js | 2 +- src/bin/plugins/README.md | 10 ++--- src/bin/plugins/checkPlugin.js | 31 ++++++++------- src/bin/plugins/lib/CONTRIBUTING.md | 4 +- src/bin/plugins/lib/backend-tests.yml | 6 +-- src/bin/plugins/lib/npmpublish.yml | 2 +- src/bin/plugins/lib/travis.yml | 14 +++---- src/bin/plugins/reTestAllPlugins.sh | 2 +- src/bin/plugins/updateAllPluginsScript.sh | 2 +- src/bin/plugins/updateCorePlugins.sh | 2 +- src/bin/rebuildPad.js | 2 +- src/bin/release.js | 5 ++- src/bin/repairPad.js | 2 +- src/bin/run.sh | 9 +++-- src/bin/safeRun.sh | 7 ++-- src/node/hooks/express/tests.js | 2 +- src/node/server.js | 2 +- src/package.json | 4 +- src/static/js/pluginfw/hooks.js | 6 ++- .../backend/specs/api/characterEncoding.js | 4 +- src/tests/backend/specs/api/importexport.js | 2 +- .../backend/specs/api/importexportGetPost.js | 12 +++--- src/tests/backend/specs/api/pad.js | 2 +- src/tests/frontend/travis/runner.sh | 9 ++--- src/tests/frontend/travis/runnerBackend.sh | 9 ++--- src/tests/frontend/travis/runnerLoadTest.sh | 9 ++--- src/tests/ratelimit/Dockerfile.anotherip | 2 +- src/tests/ratelimit/Dockerfile.nginx | 2 +- 51 files changed, 182 insertions(+), 170 deletions(-) diff --git a/.github/workflows/backend-tests.yml b/.github/workflows/backend-tests.yml index 8c9c45f2..a6a0d013 100644 --- a/.github/workflows/backend-tests.yml +++ b/.github/workflows/backend-tests.yml @@ -24,11 +24,11 @@ jobs: sudo apt install -y --no-install-recommends libreoffice libreoffice-pdfimport - name: Install all dependencies and symlink for ep_etherpad-lite - run: bin/installDeps.sh + run: src/bin/installDeps.sh # configures some settings and runs npm run test - name: Run the backend tests - run: tests/frontend/travis/runnerBackend.sh + run: src/tests/frontend/travis/runnerBackend.sh withplugins: # run on pushes to any branch @@ -73,8 +73,8 @@ jobs: # 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: bin/installDeps.sh + run: src/bin/installDeps.sh # configures some settings and runs npm run test - name: Run the backend tests - run: tests/frontend/travis/runnerBackend.sh + run: src/tests/frontend/travis/runnerBackend.sh diff --git a/.github/workflows/dockerfile.yml b/.github/workflows/dockerfile.yml index 8f6d5c3b..5f838470 100644 --- a/.github/workflows/dockerfile.yml +++ b/.github/workflows/dockerfile.yml @@ -21,6 +21,6 @@ jobs: run: | docker build -t etherpad:test . docker run -d -p 9001:9001 etherpad:test - ./bin/installDeps.sh + ./src/bin/installDeps.sh sleep 3 # delay for startup? cd src && npm run test-container diff --git a/.github/workflows/frontend-tests.yml b/.github/workflows/frontend-tests.yml index 0052cafe..f8a0e76b 100644 --- a/.github/workflows/frontend-tests.yml +++ b/.github/workflows/frontend-tests.yml @@ -17,10 +17,10 @@ jobs: SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} TRAVIS_JOB_NUMBER: ${{ github.run_id }}-${{ github.run_number }}-${{ github.job }} - run: tests/frontend/travis/sauce_tunnel.sh + run: src/tests/frontend/travis/sauce_tunnel.sh - name: Install all dependencies and symlink for ep_etherpad-lite - run: bin/installDeps.sh + run: src/bin/installDeps.sh - name: export GIT_HASH to env id: environment @@ -37,7 +37,7 @@ jobs: TRAVIS_JOB_NUMBER: ${{ github.run_id }}-${{ github.run_number }}-${{ github.job }} GIT_HASH: ${{ steps.environment.outputs.sha_short }} run: | - tests/frontend/travis/runner.sh + src/tests/frontend/travis/runner.sh withplugins: name: with plugins @@ -53,7 +53,7 @@ jobs: SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} TRAVIS_JOB_NUMBER: ${{ github.run_id }}-${{ github.run_number }}-${{ github.job }} - run: tests/frontend/travis/sauce_tunnel.sh + run: src/tests/frontend/travis/sauce_tunnel.sh - name: Install Etherpad plugins run: > @@ -79,7 +79,7 @@ jobs: # 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: bin/installDeps.sh + run: src/bin/installDeps.sh - name: export GIT_HASH to env id: environment @@ -90,7 +90,7 @@ jobs: # XXX we should probably run all tests, because plugins could effect their results - name: Remove standard frontend test files, so only plugin tests are run - run: rm tests/frontend/specs/* + run: rm src/tests/frontend/specs/* - name: Run the frontend tests shell: bash @@ -100,4 +100,4 @@ jobs: TRAVIS_JOB_NUMBER: ${{ github.run_id }}-${{ github.run_number }}-${{ github.job }} GIT_HASH: ${{ steps.environment.outputs.sha_short }} run: | - tests/frontend/travis/runner.sh + src/tests/frontend/travis/runner.sh diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml index ab0fb3bd..056930ec 100644 --- a/.github/workflows/load-test.yml +++ b/.github/workflows/load-test.yml @@ -18,13 +18,13 @@ jobs: uses: actions/checkout@v2 - name: Install all dependencies and symlink for ep_etherpad-lite - run: bin/installDeps.sh + run: src/bin/installDeps.sh - name: Install etherpad-load-test run: sudo npm install -g etherpad-load-test - name: Run load test - run: tests/frontend/travis/runnerLoadTest.sh + run: src/tests/frontend/travis/runnerLoadTest.sh withplugins: # run on pushes to any branch @@ -66,8 +66,8 @@ jobs: # 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: bin/installDeps.sh + run: src/bin/installDeps.sh # configures some settings and runs npm run test - name: Run load test - run: tests/frontend/travis/runnerLoadTest.sh + run: src/tests/frontend/travis/runnerLoadTest.sh diff --git a/.github/workflows/rate-limit.yml b/.github/workflows/rate-limit.yml index 4bdfc219..66755811 100644 --- a/.github/workflows/rate-limit.yml +++ b/.github/workflows/rate-limit.yml @@ -22,8 +22,8 @@ jobs: - name: build docker image run: | docker build -f Dockerfile -t epl-debian-slim . - docker build -f tests/ratelimit/Dockerfile.nginx -t nginx-latest . - docker build -f tests/ratelimit/Dockerfile.anotherip -t anotherip . + docker build -f src/tests/ratelimit/Dockerfile.nginx -t nginx-latest . + docker build -f src/tests/ratelimit/Dockerfile.anotherip -t anotherip . - name: run docker images run: | docker run --name etherpad-docker -p 9000:9001 --rm --network ep_net --ip 172.23.42.2 -e 'TRUST_PROXY=true' epl-debian-slim & @@ -31,9 +31,9 @@ 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: bin/installDeps.sh + run: src/bin/installDeps.sh - name: run rate limit test run: | - cd tests/ratelimit + cd src/tests/ratelimit ./testlimits.sh diff --git a/.gitignore b/.gitignore index c75e5a61..6dca890d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,11 +3,8 @@ node_modules !settings.json.template APIKEY.txt SESSIONKEY.txt -bin/abiword.exe -bin/node.exe etherpad-lite-win.zip var/dirty.db -bin/convertSettings.json *~ *.patch npm-debug.log @@ -15,9 +12,12 @@ npm-debug.log .ep_initialized *.crt *.key -bin/etherpad-1.deb credentials.json out/ .nyc_output ./package-lock.json .idea +/src/bin/abiword.exe +/src/bin/convertSettings.json +/src/bin/etherpad-1.deb +/src/bin/node.exe diff --git a/.travis.yml b/.travis.yml index 3f8ad1cf..f6cf4dba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,19 +46,19 @@ jobs: name: "Test the Frontend without Plugins" install: - *set_loglevel_warn - - "tests/frontend/travis/sauce_tunnel.sh" - - "bin/installDeps.sh" + - "src/tests/frontend/travis/sauce_tunnel.sh" + - "src/bin/installDeps.sh" - "export GIT_HASH=$(git rev-parse --verify --short HEAD)" script: - - "./tests/frontend/travis/runner.sh" + - "./src/tests/frontend/travis/runner.sh" - name: "Run the Backend tests without Plugins" install: - *install_libreoffice - *set_loglevel_warn - - "bin/installDeps.sh" + - "src/bin/installDeps.sh" - "cd src && npm install && cd -" script: - - "tests/frontend/travis/runnerBackend.sh" + - "src/tests/frontend/travis/runnerBackend.sh" - name: "Test the Dockerfile" install: - "cd src && npm install && cd -" @@ -69,24 +69,24 @@ jobs: - name: "Load test Etherpad without Plugins" install: - *set_loglevel_warn - - "bin/installDeps.sh" + - "src/bin/installDeps.sh" - "cd src && npm install && cd -" - "npm install -g etherpad-load-test" script: - - "tests/frontend/travis/runnerLoadTest.sh" + - "src/tests/frontend/travis/runnerLoadTest.sh" # we can only frontend tests from the ether/ organization and not from forks. # To request tests to be run ask a maintainer to fork your repo to ether/ - if: fork = false name: "Test the Frontend Plugins only" install: - *set_loglevel_warn - - "tests/frontend/travis/sauce_tunnel.sh" - - "bin/installDeps.sh" - - "rm tests/frontend/specs/*" + - "src/tests/frontend/travis/sauce_tunnel.sh" + - "src/bin/installDeps.sh" + - "rm src/tests/frontend/specs/*" - *install_plugins - "export GIT_HASH=$(git rev-parse --verify --short HEAD)" script: - - "./tests/frontend/travis/runner.sh" + - "./src/tests/frontend/travis/runner.sh" - name: "Lint test package-lock.json" install: - "npm install lockfile-lint" @@ -96,11 +96,11 @@ jobs: install: - *install_libreoffice - *set_loglevel_warn - - "bin/installDeps.sh" + - "src/bin/installDeps.sh" - *install_plugins - "cd src && npm install && cd -" script: - - "tests/frontend/travis/runnerBackend.sh" + - "src/tests/frontend/travis/runnerBackend.sh" - name: "Test the Dockerfile" install: - "cd src && npm install && cd -" @@ -111,24 +111,24 @@ jobs: - name: "Load test Etherpad with Plugins" install: - *set_loglevel_warn - - "bin/installDeps.sh" + - "src/bin/installDeps.sh" - *install_plugins - "cd src && npm install && cd -" - "npm install -g etherpad-load-test" script: - - "tests/frontend/travis/runnerLoadTest.sh" + - "src/tests/frontend/travis/runnerLoadTest.sh" - name: "Test rate limit" install: - "docker network create --subnet=172.23.42.0/16 ep_net" - "docker build -f Dockerfile -t epl-debian-slim ." - - "docker build -f tests/ratelimit/Dockerfile.nginx -t nginx-latest ." - - "docker build -f tests/ratelimit/Dockerfile.anotherip -t anotherip ." + - "docker build -f src/tests/ratelimit/Dockerfile.nginx -t nginx-latest ." + - "docker build -f src/tests/ratelimit/Dockerfile.anotherip -t anotherip ." - "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" - - "./bin/installDeps.sh" + - "./src/bin/installDeps.sh" script: - - "cd tests/ratelimit && bash testlimits.sh" + - "cd src/tests/ratelimit && bash testlimits.sh" notifications: irc: diff --git a/Dockerfile b/Dockerfile index aa6091a5..e16e5817 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,7 @@ WORKDIR /opt/etherpad-lite COPY --chown=etherpad:0 ./ ./ # install node dependencies for Etherpad -RUN bin/installDeps.sh && \ +RUN src/bin/installDeps.sh && \ rm -rf ~/.npm/_cacache # Install the plugins, if ETHERPAD_PLUGINS is not empty. diff --git a/Makefile b/Makefile index 0c99d9ff..bc79166b 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,8 @@ UNAME := $(shell uname -s) ensure_marked_is_installed: set -eu; \ hash npm; \ - if [ $(shell npm list --prefix bin/doc >/dev/null 2>/dev/null; echo $$?) -ne "0" ]; then \ - npm ci --prefix=bin/doc; \ + if [ $(shell npm list --prefix src/bin/doc >/dev/null 2>/dev/null; echo $$?) -ne "0" ]; then \ + npm ci --prefix=src/bin/doc; \ fi docs: ensure_marked_is_installed $(outdoc_files) $(docassets) @@ -21,7 +21,7 @@ out/doc/assets/%: doc/assets/% out/doc/%.html: doc/%.md mkdir -p $(@D) - node bin/doc/generate.js --format=html --template=doc/template.html $< > $@ + node src/bin/doc/generate.js --format=html --template=doc/template.html $< > $@ ifeq ($(UNAME),Darwin) sed -i '' 's/__VERSION__/${VERSION}/' $@ else diff --git a/README.md b/README.md index 5a66ddd7..3f1e6fb0 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,9 @@ Etherpad is a real-time collaborative editor [scalable to thousands of simultane ``` curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt install -y nodejs -git clone --branch master https://github.com/ether/etherpad-lite.git && cd etherpad-lite && bin/run.sh +git clone --branch master https://github.com/ether/etherpad-lite.git && +cd etherpad-lite && +src/bin/run.sh ``` ### Manual install @@ -31,9 +33,10 @@ You'll need git and [node.js](https://nodejs.org) installed (minimum required No 1. Move to a folder where you want to install Etherpad. Clone the git repository: `git clone --branch master git://github.com/ether/etherpad-lite.git` 2. Change into the new directory containing the cloned source code: `cd etherpad-lite` -3. run `bin/run.sh` and open in your browser. +3. run `src/bin/run.sh` and open in your browser. -To update to the latest released version, execute `git pull origin`. The next start with `bin/run.sh` will update the dependencies. +To update to the latest released version, execute `git pull origin`. The next +start with `src/bin/run.sh` will update the dependencies. [Next steps](#next-steps). @@ -53,11 +56,13 @@ You'll need [node.js](https://nodejs.org) and (optionally, though recommended) g 1. Grab the source, either - download - or `git clone --branch master https://github.com/ether/etherpad-lite.git` -2. With a "Run as administrator" command prompt execute `bin\installOnWindows.bat` +2. With a "Run as administrator" command prompt execute + `src\bin\installOnWindows.bat` Now, run `start.bat` and open in your browser. -Update to the latest version with `git pull origin`, then run `bin\installOnWindows.bat`, again. +Update to the latest version with `git pull origin`, then run +`src\bin\installOnWindows.bat`, again. If cloning to a subdirectory within another project, you may need to do the following: @@ -73,7 +78,9 @@ Find [here](doc/docker.md) information on running Etherpad in a container. ## Tweak the settings You can modify the settings in `settings.json`. -If you need to handle multiple settings files, you can pass the path to a settings file to `bin/run.sh` using the `-s|--settings` option: this allows you to run multiple Etherpad instances from the same installation. +If you need to handle multiple settings files, you can pass the path to a +settings file to `src/bin/run.sh` using the `-s|--settings` option: this allows +you to run multiple Etherpad instances from the same installation. Similarly, `--credentials` can be used to give a settings override file, `--apikey` to give a different APIKEY.txt file and `--sessionkey` to give a non-default SESSIONKEY.txt. **Each configuration parameter can also be set via an environment variable**, using the syntax `"${ENV_VAR}"` or `"${ENV_VAR:default_value}"`. For details, refer to `settings.json.template`. Once you have access to your `/admin` section settings can be modified through the web browser. @@ -115,9 +122,13 @@ Documentation can be found in `doc/`. # Development ## Things you should know -You can debug Etherpad using `bin/debugRun.sh`. -You can run Etherpad quickly launching `bin/fastRun.sh`. It's convenient for developers and advanced users. Be aware that it will skip the dependencies update, so remember to run `bin/installDeps.sh` after installing a new dependency or upgrading version. +You can debug Etherpad using `src/bin/debugRun.sh`. + +You can run Etherpad quickly launching `src/bin/fastRun.sh`. It's convenient for +developers and advanced users. Be aware that it will skip the dependencies +update, so remember to run `src/bin/installDeps.sh` after installing a new +dependency or upgrading version. If you want to find out how Etherpad's `Easysync` works (the library that makes it really realtime), start with this [PDF](https://github.com/ether/etherpad-lite/raw/master/doc/easysync/easysync-full-description.pdf) (complex, but worth reading). diff --git a/doc/documentation.md b/doc/documentation.md index 307c38af..bc18fbc0 100644 --- a/doc/documentation.md +++ b/doc/documentation.md @@ -11,5 +11,5 @@ heading. Every `.html` file is generated based on the corresponding `.md` file in the `doc/api/` folder in the source tree. The -documentation is generated using the `bin/doc/generate.js` program. +documentation is generated using the `src/bin/doc/generate.js` program. The HTML template is located at `doc/template.html`. diff --git a/src/bin/buildDebian.sh b/src/bin/buildDebian.sh index f1f5675e..241b3f75 100755 --- a/src/bin/buildDebian.sh +++ b/src/bin/buildDebian.sh @@ -14,7 +14,7 @@ rm -rf ${DIST} mkdir -p ${DIST}/ rm -rf ${SRC} -rsync -a bin/deb-src/ ${SRC}/ +rsync -a src/bin/deb-src/ ${SRC}/ mkdir -p ${SYSROOT}/opt/ rsync --exclude '.git' -a . ${SYSROOT}/opt/etherpad/ --delete diff --git a/src/bin/buildForWindows.sh b/src/bin/buildForWindows.sh index 818522ad..d62ef810 100755 --- a/src/bin/buildForWindows.sh +++ b/src/bin/buildForWindows.sh @@ -32,7 +32,7 @@ rm -f etherpad-lite-win.zip export NODE_ENV=production log "do a normal unix install first..." -bin/installDeps.sh || exit 1 +src/bin/installDeps.sh || exit 1 log "copy the windows settings template..." cp settings.json.template settings.json @@ -43,8 +43,7 @@ rm -rf node_modules mv node_modules_resolved node_modules log "download windows node..." -cd bin -wget "https://nodejs.org/dist/latest-erbium/win-x86/node.exe" -O ../node.exe +wget "https://nodejs.org/dist/latest-erbium/win-x86/node.exe" -O node.exe log "remove git history to reduce folder size" rm -rf .git/objects diff --git a/src/bin/checkAllPads.js b/src/bin/checkAllPads.js index fe1719b8..d15e5ec5 100644 --- a/src/bin/checkAllPads.js +++ b/src/bin/checkAllPads.js @@ -7,7 +7,7 @@ // 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 bin/checkAllPads.js'); +if (process.argv.length !== 2) throw new Error('Use: node src/bin/checkAllPads.js'); (async () => { // initialize the database diff --git a/src/bin/checkPad.js b/src/bin/checkPad.js index becca3a4..5b17fa31 100644 --- a/src/bin/checkPad.js +++ b/src/bin/checkPad.js @@ -7,7 +7,7 @@ // 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 bin/checkPad.js $PADID'); +if (process.argv.length !== 3) throw new Error('Use: node src/bin/checkPad.js $PADID'); // get the padID const padId = process.argv[2]; diff --git a/src/bin/checkPadDeltas.js b/src/bin/checkPadDeltas.js index 043187ce..852c6833 100644 --- a/src/bin/checkPadDeltas.js +++ b/src/bin/checkPadDeltas.js @@ -7,7 +7,7 @@ // 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 bin/checkPadDeltas.js $PADID'); +if (process.argv.length !== 3) throw new Error('Use: node src/bin/checkPadDeltas.js $PADID'); // get the padID const padId = process.argv[2]; diff --git a/src/bin/cleanRun.sh b/src/bin/cleanRun.sh index 36dd1e38..e8f4bd0d 100755 --- a/src/bin/cleanRun.sh +++ b/src/bin/cleanRun.sh @@ -1,15 +1,11 @@ #!/bin/sh -# Move to the folder where ep-lite is installed -cd "$(dirname "$0")"/.. +# Move to the Etherpad base directory. +MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 +cd "${MY_DIR}/../.." || exit 1 # Source constants and useful functions -. bin/functions.sh - -#Was this script started in the bin folder? if yes move out -if [ -d "../bin" ]; then - cd "../" -fi +. src/bin/functions.sh ignoreRoot=0 for ARG in "$@" @@ -35,7 +31,7 @@ fi rm -rf src/node_modules #Prepare the environment -bin/installDeps.sh "$@" || exit 1 +src/bin/installDeps.sh "$@" || exit 1 #Move to the node folder and start echo "Started Etherpad..." diff --git a/src/bin/createRelease.sh b/src/bin/createRelease.sh index 6768702f..531a2150 100755 --- a/src/bin/createRelease.sh +++ b/src/bin/createRelease.sh @@ -134,7 +134,7 @@ function create_builds { git clone $ETHER_WEB_REPO echo "Creating windows build..." cd etherpad-lite - bin/buildForWindows.sh + src/bin/buildForWindows.sh [[ $? != 0 ]] && echo "Aborting: Error creating build for windows" && exit 1 echo "Creating docs..." make docs diff --git a/src/bin/deb-src/sysroot/etc/init/etherpad.conf b/src/bin/deb-src/sysroot/etc/init/etherpad.conf index cd6f4541..aab40bca 100644 --- a/src/bin/deb-src/sysroot/etc/init/etherpad.conf +++ b/src/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/bin/installDeps.sh >> $EPLOGS/error.log || { stop; exit 1; } + $EPHOME/src/bin/installDeps.sh >> $EPLOGS/error.log || { stop; exit 1; } end script script diff --git a/src/bin/debugRun.sh b/src/bin/debugRun.sh index e04db88d..f418f4f6 100755 --- a/src/bin/debugRun.sh +++ b/src/bin/debugRun.sh @@ -1,13 +1,14 @@ #!/bin/sh -# Move to the folder where ep-lite is installed -cd "$(dirname "$0")"/.. +# Move to the Etherpad base directory. +MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 +cd "${MY_DIR}/../.." || exit 1 # Source constants and useful functions -. bin/functions.sh +. src/bin/functions.sh # Prepare the environment -bin/installDeps.sh || exit 1 +src/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/doc/README.md b/src/bin/doc/README.md index 4646c200..19a137fd 100644 --- a/src/bin/doc/README.md +++ b/src/bin/doc/README.md @@ -72,5 +72,5 @@ Each type of heading has a description block. Run the following from the etherpad-lite root directory: ```sh -$ node bin/doc/generate doc/index.md --format=html --template=doc/template.html > out.html -``` \ No newline at end of file +$ node src/bin/doc/generate doc/index.md --format=html --template=doc/template.html > out.html +``` diff --git a/src/bin/fastRun.sh b/src/bin/fastRun.sh index 63524e79..a782cafc 100755 --- a/src/bin/fastRun.sh +++ b/src/bin/fastRun.sh @@ -9,17 +9,14 @@ set -eu -# source: https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself#246128 -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +# Move to the Etherpad base directory. +MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 +cd "${MY_DIR}/../.." || exit 1 # Source constants and useful functions -. ${DIR}/../bin/functions.sh +. src/bin/functions.sh echo "Running directly, without checking/installing dependencies" -# move to the base Etherpad directory. This will be necessary until Etherpad -# learns to run from arbitrary CWDs. -cd "${DIR}/.." - # run Etherpad main class -node $(compute_node_args) "${DIR}/../node_modules/ep_etherpad-lite/node/server.js" "$@" +node $(compute_node_args) "node_modules/ep_etherpad-lite/node/server.js" "$@" diff --git a/src/bin/installDeps.sh b/src/bin/installDeps.sh index be3f1fd8..6ea555db 100755 --- a/src/bin/installDeps.sh +++ b/src/bin/installDeps.sh @@ -1,10 +1,11 @@ #!/bin/sh -# Move to the folder where ep-lite is installed -cd "$(dirname "$0")"/.. +# Move to the Etherpad base directory. +MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 +cd "${MY_DIR}/../.." || exit 1 # Source constants and useful functions -. bin/functions.sh +. src/bin/functions.sh # Is node installed? # Not checking io.js, default installation creates a symbolic link to node diff --git a/src/bin/migrateDirtyDBtoRealDB.js b/src/bin/migrateDirtyDBtoRealDB.js index fbeb0eb4..75f6cc67 100644 --- a/src/bin/migrateDirtyDBtoRealDB.js +++ b/src/bin/migrateDirtyDBtoRealDB.js @@ -10,7 +10,7 @@ process.on('unhandledRejection', (err) => { throw err; }); // file before using this script, just to be safe. // It might be necessary to run the script using more memory: - // `node --max-old-space-size=4096 bin/migrateDirtyDBtoRealDB.js` + // `node --max-old-space-size=4096 src/bin/migrateDirtyDBtoRealDB.js` const dirtyDb = require('dirty'); const log4js = require('log4js'); diff --git a/src/bin/plugins/README.md b/src/bin/plugins/README.md index 5bb4786c..b1406582 100755 --- a/src/bin/plugins/README.md +++ b/src/bin/plugins/README.md @@ -6,25 +6,25 @@ This code will check your plugin for known usual issues and some suggestions for improvements. No changes will be made to your project. ``` -node bin/plugins/checkPlugin.js $PLUGIN_NAME$ +node src/bin/plugins/checkPlugin.js $PLUGIN_NAME$ ``` # Basic Example: ``` -node bin/plugins/checkPlugin.js ep_webrtc +node src/bin/plugins/checkPlugin.js ep_webrtc ``` ## Autofixing - will autofix any issues it can ``` -node bin/plugins/checkPlugin.js ep_whatever autofix +node src/bin/plugins/checkPlugin.js ep_whatever autofix ``` ## Autocommitting, push, npm minor patch and npm publish (highly dangerous) ``` -node bin/plugins/checkPlugin.js ep_whatever autocommit +node src/bin/plugins/checkPlugin.js ep_whatever autocommit ``` # All the plugins @@ -41,7 +41,7 @@ cd .. for dir in node_modules/ep_*; do dir=${dir#node_modules/} [ "$dir" != ep_etherpad-lite ] || continue - node bin/plugins/checkPlugin.js "$dir" autocommit + node src/bin/plugins/checkPlugin.js "$dir" autocommit done ``` diff --git a/src/bin/plugins/checkPlugin.js b/src/bin/plugins/checkPlugin.js index 5bf35dd0..6d1144bf 100755 --- a/src/bin/plugins/checkPlugin.js +++ b/src/bin/plugins/checkPlugin.js @@ -3,10 +3,10 @@ /* * Usage -- see README.md * - * Normal usage: node bin/plugins/checkPlugin.js ep_whatever - * Auto fix the things it can: node bin/plugins/checkPlugin.js ep_whatever autofix + * 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 commit, push and publish to npm (highly dangerous): - * node bin/plugins/checkPlugin.js ep_whatever autocommit + * node src/bin/plugins/checkPlugin.js ep_whatever autocommit */ // As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an @@ -118,7 +118,7 @@ fs.readdir(pluginPath, (err, rootFiles) => { console.log('create one and set npm secret to auto publish to npm on commit'); if (autoFix) { const npmpublish = - fs.readFileSync('bin/plugins/lib/npmpublish.yml', {encoding: 'utf8', flag: 'r'}); + fs.readFileSync('src/bin/plugins/lib/npmpublish.yml', {encoding: 'utf8', flag: 'r'}); fs.mkdirSync(`${pluginPath}/.github/workflows`, {recursive: true}); fs.writeFileSync(path, npmpublish); console.log("If you haven't already, setup autopublish for this plugin https://github.com/ether/etherpad-lite/wiki/Plugins:-Automatically-publishing-to-npm-on-commit-to-Github-Repo"); @@ -134,14 +134,14 @@ fs.readdir(pluginPath, (err, rootFiles) => { currVersionFile.substr(existingConfigLocation + 17, existingConfigLocation.length)); const reqVersionFile = - fs.readFileSync('bin/plugins/lib/npmpublish.yml', {encoding: 'utf8', flag: 'r'}); + fs.readFileSync('src/bin/plugins/lib/npmpublish.yml', {encoding: 'utf8', flag: 'r'}); const reqConfigLocation = reqVersionFile.indexOf('##ETHERPAD_NPM_V='); const reqValue = parseInt(reqVersionFile.substr(reqConfigLocation + 17, reqConfigLocation.length)); if (!existingValue || (reqValue > existingValue)) { const npmpublish = - fs.readFileSync('bin/plugins/lib/npmpublish.yml', {encoding: 'utf8', flag: 'r'}); + fs.readFileSync('src/bin/plugins/lib/npmpublish.yml', {encoding: 'utf8', flag: 'r'}); fs.mkdirSync(`${pluginPath}/.github/workflows`, {recursive: true}); fs.writeFileSync(path, npmpublish); } @@ -158,7 +158,7 @@ fs.readdir(pluginPath, (err, rootFiles) => { console.log('create one and set npm secret to auto publish to npm on commit'); if (autoFix) { const backendTests = - fs.readFileSync('bin/plugins/lib/backend-tests.yml', {encoding: 'utf8', flag: 'r'}); + fs.readFileSync('src/bin/plugins/lib/backend-tests.yml', {encoding: 'utf8', flag: 'r'}); fs.mkdirSync(`${pluginPath}/.github/workflows`, {recursive: true}); fs.writeFileSync(path, backendTests); } @@ -171,14 +171,14 @@ fs.readdir(pluginPath, (err, rootFiles) => { currVersionFile.substr(existingConfigLocation + 17, existingConfigLocation.length)); const reqVersionFile = - fs.readFileSync('bin/plugins/lib/backend-tests.yml', {encoding: 'utf8', flag: 'r'}); + fs.readFileSync('src/bin/plugins/lib/backend-tests.yml', {encoding: 'utf8', flag: 'r'}); const reqConfigLocation = reqVersionFile.indexOf('##ETHERPAD_NPM_V='); const reqValue = parseInt(reqVersionFile.substr(reqConfigLocation + 17, reqConfigLocation.length)); if (!existingValue || (reqValue > existingValue)) { const backendTests = - fs.readFileSync('bin/plugins/lib/backend-tests.yml', {encoding: 'utf8', flag: 'r'}); + fs.readFileSync('src/bin/plugins/lib/backend-tests.yml', {encoding: 'utf8', flag: 'r'}); fs.mkdirSync(`${pluginPath}/.github/workflows`, {recursive: true}); fs.writeFileSync(path, backendTests); } @@ -283,7 +283,7 @@ fs.readdir(pluginPath, (err, rootFiles) => { if (autoFix) { console.log('Autofixing missing README.md file'); console.log('please edit the README.md file further to include plugin specific details.'); - let readme = fs.readFileSync('bin/plugins/lib/README.md', {encoding: 'utf8', flag: 'r'}); + let readme = fs.readFileSync('src/bin/plugins/lib/README.md', {encoding: 'utf8', flag: 'r'}); readme = readme.replace(/\[plugin_name\]/g, pluginName); if (repository) { const org = repository.split('/')[3]; @@ -303,7 +303,7 @@ fs.readdir(pluginPath, (err, rootFiles) => { console.log('Autofixing missing CONTRIBUTING.md file, please edit the CONTRIBUTING.md ' + 'file further to include plugin specific details.'); let contributing = - fs.readFileSync('bin/plugins/lib/CONTRIBUTING.md', {encoding: 'utf8', flag: 'r'}); + fs.readFileSync('src/bin/plugins/lib/CONTRIBUTING.md', {encoding: 'utf8', flag: 'r'}); contributing = contributing.replace(/\[plugin_name\]/g, pluginName); fs.writeFileSync(`${pluginPath}/CONTRIBUTING.md`, contributing); } @@ -325,14 +325,16 @@ fs.readdir(pluginPath, (err, rootFiles) => { console.warn('LICENSE.md file not found, please create'); if (autoFix) { console.log('Autofixing missing LICENSE.md file, including Apache 2 license.'); - let license = fs.readFileSync('bin/plugins/lib/LICENSE.md', {encoding: 'utf8', flag: 'r'}); + let license = + fs.readFileSync('src/bin/plugins/lib/LICENSE.md', {encoding: 'utf8', flag: 'r'}); license = license.replace('[yyyy]', new Date().getFullYear()); license = license.replace('[name of copyright owner]', execSync('git config user.name')); fs.writeFileSync(`${pluginPath}/LICENSE.md`, license); } } - let travisConfig = fs.readFileSync('bin/plugins/lib/travis.yml', {encoding: 'utf8', flag: 'r'}); + let travisConfig = + fs.readFileSync('src/bin/plugins/lib/travis.yml', {encoding: 'utf8', flag: 'r'}); travisConfig = travisConfig.replace(/\[plugin_name\]/g, pluginName); if (files.indexOf('.travis.yml') === -1) { @@ -371,7 +373,8 @@ fs.readdir(pluginPath, (err, rootFiles) => { "ensure files aren't incorrectly commited to a repository."); if (autoFix) { console.log('Autofixing missing .gitignore file'); - const gitignore = fs.readFileSync('bin/plugins/lib/gitignore', {encoding: 'utf8', flag: 'r'}); + const gitignore = + fs.readFileSync('src/bin/plugins/lib/gitignore', {encoding: 'utf8', flag: 'r'}); fs.writeFileSync(`${pluginPath}/.gitignore`, gitignore); } } else { diff --git a/src/bin/plugins/lib/CONTRIBUTING.md b/src/bin/plugins/lib/CONTRIBUTING.md index 724e02ac..347437b2 100644 --- a/src/bin/plugins/lib/CONTRIBUTING.md +++ b/src/bin/plugins/lib/CONTRIBUTING.md @@ -113,7 +113,9 @@ Documentation should be kept up-to-date. This means, whenever you add a new API You can build the docs e.g. produce html, using `make docs`. At some point in the future we will provide an online documentation. The current documentation in the github wiki should always reflect the state of `master` (!), since there are no docs in master, yet. ## Testing -Front-end tests are found in the `tests/frontend/` folder in the repository. Run them by pointing your browser to `/tests/frontend`. + +Front-end tests are found in the `src/tests/frontend/` folder in the repository. +Run them by pointing your browser to `/tests/frontend`. Back-end tests can be run from the `src` directory, via `npm test`. diff --git a/src/bin/plugins/lib/backend-tests.yml b/src/bin/plugins/lib/backend-tests.yml index 324cc4ba..f1d3a4af 100644 --- a/src/bin/plugins/lib/backend-tests.yml +++ b/src/bin/plugins/lib/backend-tests.yml @@ -30,7 +30,7 @@ jobs: repository: ether/etherpad-lite - name: Install all dependencies and symlink for ep_etherpad-lite - run: bin/installDeps.sh + run: src/bin/installDeps.sh # clone this repository into node_modules/ep_plugin-name - name: Checkout plugin repository @@ -45,7 +45,7 @@ jobs: # configures some settings and runs npm run test - name: Run the backend tests - run: tests/frontend/travis/runnerBackend.sh + run: src/tests/frontend/travis/runnerBackend.sh ##ETHERPAD_NPM_V=1 -## NPM configuration automatically created using bin/plugins/updateAllPluginsScript.sh +## NPM configuration automatically created using src/bin/plugins/updateAllPluginsScript.sh diff --git a/src/bin/plugins/lib/npmpublish.yml b/src/bin/plugins/lib/npmpublish.yml index 2e0cf240..4a930144 100644 --- a/src/bin/plugins/lib/npmpublish.yml +++ b/src/bin/plugins/lib/npmpublish.yml @@ -80,4 +80,4 @@ jobs: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} ##ETHERPAD_NPM_V=2 -## NPM configuration automatically created using bin/plugins/updateAllPluginsScript.sh +## NPM configuration automatically created using src/bin/plugins/updateAllPluginsScript.sh diff --git a/src/bin/plugins/lib/travis.yml b/src/bin/plugins/lib/travis.yml index 099d7e44..1cf10316 100644 --- a/src/bin/plugins/lib/travis.yml +++ b/src/bin/plugins/lib/travis.yml @@ -12,7 +12,7 @@ install: - "export GIT_HASH=$(git rev-parse --verify --short HEAD)" #script: -# - "tests/frontend/travis/runner.sh" +# - "src/tests/frontend/travis/runner.sh" env: global: @@ -40,14 +40,14 @@ jobs: - "cd etherpad" - "mkdir -p node_modules" - "mv ../[plugin_name] node_modules" - - "bin/installDeps.sh" + - "src/bin/installDeps.sh" - "export GIT_HASH=$(git rev-parse --verify --short HEAD)" - "cd src && npm install && cd -" script: - - "tests/frontend/travis/runnerBackend.sh" + - "src/tests/frontend/travis/runnerBackend.sh" - name: "Test the Frontend" before_script: - - "tests/frontend/travis/sauce_tunnel.sh" + - "src/tests/frontend/travis/sauce_tunnel.sh" install: - "npm install" - "mkdir [plugin_name]" @@ -56,10 +56,10 @@ jobs: - "cd etherpad" - "mkdir -p node_modules" - "mv ../[plugin_name] node_modules" - - "bin/installDeps.sh" + - "src/bin/installDeps.sh" - "export GIT_HASH=$(git rev-parse --verify --short HEAD)" script: - - "tests/frontend/travis/runner.sh" + - "src/tests/frontend/travis/runner.sh" notifications: irc: @@ -67,4 +67,4 @@ notifications: - "irc.freenode.org#etherpad-lite-dev" ##ETHERPAD_TRAVIS_V=9 -## Travis configuration automatically created using bin/plugins/updateAllPluginsScript.sh +## Travis configuration automatically created using src/bin/plugins/updateAllPluginsScript.sh diff --git a/src/bin/plugins/reTestAllPlugins.sh b/src/bin/plugins/reTestAllPlugins.sh index 319d378d..58628bdb 100755 --- a/src/bin/plugins/reTestAllPlugins.sh +++ b/src/bin/plugins/reTestAllPlugins.sh @@ -4,7 +4,7 @@ do echo $dir if [[ $dir == *"ep_"* ]]; then if [[ $dir != "ep_etherpad-lite" ]]; then - # node bin/plugins/checkPlugin.js $dir autofix autocommit autoupdate + # node src/bin/plugins/checkPlugin.js $dir autofix autocommit autoupdate 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/updateAllPluginsScript.sh b/src/bin/plugins/updateAllPluginsScript.sh index 763724fc..bf5280ee 100755 --- a/src/bin/plugins/updateAllPluginsScript.sh +++ b/src/bin/plugins/updateAllPluginsScript.sh @@ -10,7 +10,7 @@ do # echo $0 if [[ $dir == *"ep_"* ]]; then if [[ $dir != "ep_etherpad-lite" ]]; then - node bin/plugins/checkPlugin.js $dir autofix autocommit autoupdate + node src/bin/plugins/checkPlugin.js $dir autofix autocommit autoupdate fi fi # echo $dir diff --git a/src/bin/plugins/updateCorePlugins.sh b/src/bin/plugins/updateCorePlugins.sh index bf4e6b6d..402a080e 100755 --- a/src/bin/plugins/updateCorePlugins.sh +++ b/src/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 bin/plugins/checkPlugin.js "$dir" autofix autocommit autoupdate + node src/bin/plugins/checkPlugin.js "$dir" autofix autocommit autoupdate done diff --git a/src/bin/rebuildPad.js b/src/bin/rebuildPad.js index bda611f7..73f53088 100644 --- a/src/bin/rebuildPad.js +++ b/src/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 bin/repairPad.js $PADID $REV [$NEWPADID]'); + throw new Error('Use: node src/bin/repairPad.js $PADID $REV [$NEWPADID]'); } const padId = process.argv[2]; diff --git a/src/bin/release.js b/src/bin/release.js index b12513d6..21f1ddbc 100644 --- a/src/bin/release.js +++ b/src/bin/release.js @@ -12,10 +12,11 @@ const semver = require('semver'); Usage -node bin/release.js patch +node src/bin/release.js patch */ -const usage = 'node bin/release.js [patch/minor/major] -- example: "node bin/release.js patch"'; +const usage = + 'node src/bin/release.js [patch/minor/major] -- example: "node src/bin/release.js patch"'; const release = process.argv[2]; diff --git a/src/bin/repairPad.js b/src/bin/repairPad.js index 9aa20051..7983fc88 100644 --- a/src/bin/repairPad.js +++ b/src/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 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]; diff --git a/src/bin/run.sh b/src/bin/run.sh index c1035990..1a2aa36a 100755 --- a/src/bin/run.sh +++ b/src/bin/run.sh @@ -1,10 +1,11 @@ #!/bin/sh -# Move to the folder where ep-lite is installed -cd "$(dirname "$0")"/.. +# Move to the Etherpad base directory. +MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 +cd "${MY_DIR}/../.." || exit 1 # Source constants and useful functions -. bin/functions.sh +. src/bin/functions.sh ignoreRoot=0 for ARG in "$@"; do @@ -26,7 +27,7 @@ EOF fi # Prepare the environment -bin/installDeps.sh "$@" || exit 1 +src/bin/installDeps.sh "$@" || exit 1 # Move to the node folder and start log "Starting Etherpad..." diff --git a/src/bin/safeRun.sh b/src/bin/safeRun.sh index 6d43e303..d9efa241 100755 --- a/src/bin/safeRun.sh +++ b/src/bin/safeRun.sh @@ -23,8 +23,9 @@ fatal() { error "$@"; exit 1; } LAST_EMAIL_SEND=0 -# Move to the folder where ep-lite is installed -cd "$(dirname "$0")"/.. +# Move to the Etherpad base directory. +MY_DIR=$(try cd "${0%/*}" && try pwd -P) || exit 1 +try cd "${MY_DIR}/../.." # Check if a logfile parameter is set LOG="$1" @@ -39,7 +40,7 @@ while true; do [ -w "${LOG}" ] || fatal "Logfile '${LOG}' is not writeable" # Start the application - bin/run.sh "$@" >>${LOG} 2>>${LOG} + src/bin/run.sh "$@" >>${LOG} 2>>${LOG} TIME_FMT=$(date +%Y-%m-%dT%H:%M:%S%z) diff --git a/src/node/hooks/express/tests.js b/src/node/hooks/express/tests.js index 641ca819..de868ba3 100644 --- a/src/node/hooks/express/tests.js +++ b/src/node/hooks/express/tests.js @@ -91,4 +91,4 @@ exports.getPluginTests = async (callback) => { return Promise.all(promises).then(() => pluginSpecs); }; -exports.getCoreTests = () => readdir('tests/frontend/specs'); +exports.getCoreTests = () => readdir('src/tests/frontend/specs'); diff --git a/src/node/server.js b/src/node/server.js index affca7e1..48697571 100755 --- a/src/node/server.js +++ b/src/node/server.js @@ -3,7 +3,7 @@ 'use strict'; /** - * This module is started with bin/run.sh. It sets up a Express HTTP and a Socket.IO Server. + * This module is started with src/bin/run.sh. It sets up a Express HTTP and a Socket.IO Server. * Static file Requests are answered directly from this module, Socket.IO messages are passed * to MessageHandler and minfied requests are passed to minified. */ diff --git a/src/package.json b/src/package.json index bf61feaf..42e22975 100644 --- a/src/package.json +++ b/src/package.json @@ -217,8 +217,8 @@ }, "scripts": { "lint": "eslint .", - "test": "mocha --timeout 120000 --recursive ../tests/backend/specs ../node_modules/ep_*/static/tests/backend/specs", - "test-container": "mocha --timeout 5000 ../tests/container/specs/api" + "test": "mocha --timeout 120000 --recursive tests/backend/specs ../node_modules/ep_*/static/tests/backend/specs", + "test-container": "mocha --timeout 5000 tests/container/specs/api" }, "version": "1.8.7", "license": "Apache-2.0" diff --git a/src/static/js/pluginfw/hooks.js b/src/static/js/pluginfw/hooks.js index 72da6302..89f4267b 100644 --- a/src/static/js/pluginfw/hooks.js +++ b/src/static/js/pluginfw/hooks.js @@ -72,7 +72,8 @@ const flatten1 = (array) => array.reduce((a, b) => a.concat(b), []); // there will be an unhandled promise rejection depending on whether the the subsequent attempt is a // duplicate (same value or error) or different, respectively. // -// See the tests in tests/backend/specs/hooks.js for examples of supported and prohibited behaviors. +// See the tests in src/tests/backend/specs/hooks.js for examples of supported and prohibited +// behaviors. // const callHookFnSync = (hook, context) => { checkDeprecation(hook); @@ -226,7 +227,8 @@ exports.callAll = (hookName, context) => { // effect except either an error message is logged or an Error object is thrown depending on whether // the the subsequent attempt is a duplicate (same value or error) or different, respectively. // -// See the tests in tests/backend/specs/hooks.js for examples of supported and prohibited behaviors. +// See the tests in src/tests/backend/specs/hooks.js for examples of supported and prohibited +// behaviors. // const callHookFnAsync = async (hook, context) => { checkDeprecation(hook); diff --git a/src/tests/backend/specs/api/characterEncoding.js b/src/tests/backend/specs/api/characterEncoding.js index 9c1e294e..211885a2 100644 --- a/src/tests/backend/specs/api/characterEncoding.js +++ b/src/tests/backend/specs/api/characterEncoding.js @@ -1,7 +1,7 @@ 'use strict'; /* - * This file is copied & modified from /tests/backend/specs/api/pad.js + * This file is copied & modified from /src/tests/backend/specs/api/pad.js * * TODO: maybe unify those two files and merge in a single one. */ @@ -60,7 +60,7 @@ describe(__filename, function () { describe('setHTML', function () { it('Sets the HTML of a Pad attempting to weird utf8 encoded content', function (done) { - fs.readFile('../tests/backend/specs/api/emojis.html', 'utf8', (err, html) => { + fs.readFile('tests/backend/specs/api/emojis.html', 'utf8', (err, html) => { api.post(endPoint('setHTML')) .send({ padID: testPadId, diff --git a/src/tests/backend/specs/api/importexport.js b/src/tests/backend/specs/api/importexport.js index 4cdb5b8f..1c93c11c 100644 --- a/src/tests/backend/specs/api/importexport.js +++ b/src/tests/backend/specs/api/importexport.js @@ -1,7 +1,7 @@ 'use strict'; /* * ACHTUNG: there is a copied & modified version of this file in - * /tests/container/spacs/api/pad.js + * /src/tests/container/spacs/api/pad.js * * TODO: unify those two files, and merge in a single one. */ diff --git a/src/tests/backend/specs/api/importexportGetPost.js b/src/tests/backend/specs/api/importexportGetPost.js index 0a27f70a..ce03c576 100644 --- a/src/tests/backend/specs/api/importexportGetPost.js +++ b/src/tests/backend/specs/api/importexportGetPost.js @@ -12,12 +12,12 @@ const superagent = require('superagent'); const padManager = require('../../../../node/db/PadManager'); const plugins = require('../../../../static/js/pluginfw/plugin_defs'); -const padText = fs.readFileSync('../tests/backend/specs/api/test.txt'); -const etherpadDoc = fs.readFileSync('../tests/backend/specs/api/test.etherpad'); -const wordDoc = fs.readFileSync('../tests/backend/specs/api/test.doc'); -const wordXDoc = fs.readFileSync('../tests/backend/specs/api/test.docx'); -const odtDoc = fs.readFileSync('../tests/backend/specs/api/test.odt'); -const pdfDoc = fs.readFileSync('../tests/backend/specs/api/test.pdf'); +const padText = fs.readFileSync(`${__dirname}/test.txt`); +const etherpadDoc = fs.readFileSync(`${__dirname}/test.etherpad`); +const wordDoc = fs.readFileSync(`${__dirname}/test.doc`); +const wordXDoc = fs.readFileSync(`${__dirname}/test.docx`); +const odtDoc = fs.readFileSync(`${__dirname}/test.odt`); +const pdfDoc = fs.readFileSync(`${__dirname}/test.pdf`); let agent; const apiKey = common.apiKey; diff --git a/src/tests/backend/specs/api/pad.js b/src/tests/backend/specs/api/pad.js index d0280f78..92467cb1 100644 --- a/src/tests/backend/specs/api/pad.js +++ b/src/tests/backend/specs/api/pad.js @@ -1,6 +1,6 @@ /* * ACHTUNG: there is a copied & modified version of this file in - * /tests/container/specs/api/pad.js + * /src/tests/container/specs/api/pad.js * * TODO: unify those two files, and merge in a single one. */ diff --git a/src/tests/frontend/travis/runner.sh b/src/tests/frontend/travis/runner.sh index da28ec1e..b19c2873 100755 --- a/src/tests/frontend/travis/runner.sh +++ b/src/tests/frontend/travis/runner.sh @@ -9,12 +9,11 @@ try() { "$@" || fatal "'$@' failed"; } [ -n "${SAUCE_USERNAME}" ] || fatal "SAUCE_USERNAME is unset - exiting" [ -n "${SAUCE_ACCESS_KEY}" ] || fatal "SAUCE_ACCESS_KEY is unset - exiting" -MY_DIR=$(try cd "${0%/*}" && try pwd) || exit 1 +# Move to the Etherpad base directory. +MY_DIR=$(try cd "${0%/*}" && try pwd -P) || exit 1 +try cd "${MY_DIR}/../../../.." -# reliably move to the etherpad base folder before running it -try cd "${MY_DIR}/../../../" - -log "Assuming bin/installDeps.sh has already been run" +log "Assuming src/bin/installDeps.sh has already been run" node node_modules/ep_etherpad-lite/node/server.js --experimental-worker "${@}" & ep_pid=$! diff --git a/src/tests/frontend/travis/runnerBackend.sh b/src/tests/frontend/travis/runnerBackend.sh index f829d038..3bf2da1f 100755 --- a/src/tests/frontend/travis/runnerBackend.sh +++ b/src/tests/frontend/travis/runnerBackend.sh @@ -6,10 +6,9 @@ error() { log "ERROR: $@" >&2; } fatal() { error "$@"; exit 1; } try() { "$@" || fatal "'$@' failed"; } -MY_DIR=$(try cd "${0%/*}" && try pwd) || fatal "failed to find script directory" - -# reliably move to the etherpad base folder before running it -try cd "${MY_DIR}/../../../" +# Move to the Etherpad base directory. +MY_DIR=$(try cd "${0%/*}" && try pwd -P) || exit 1 +try cd "${MY_DIR}/../../../.." try sed -e ' s!"soffice":[^,]*!"soffice": "/usr/bin/soffice"! @@ -20,7 +19,7 @@ s!"points":[^,]*!"points": 1000! s!"loglevel":[^,]*!"loglevel": "WARN"! ' settings.json.template >settings.json -log "Assuming bin/installDeps.sh has already been run" +log "Assuming src/bin/installDeps.sh has already been run" node node_modules/ep_etherpad-lite/node/server.js "${@}" & ep_pid=$! diff --git a/src/tests/frontend/travis/runnerLoadTest.sh b/src/tests/frontend/travis/runnerLoadTest.sh index 50ffcbb4..3e9d7d40 100755 --- a/src/tests/frontend/travis/runnerLoadTest.sh +++ b/src/tests/frontend/travis/runnerLoadTest.sh @@ -6,10 +6,9 @@ error() { log "ERROR: $@" >&2; } fatal() { error "$@"; exit 1; } try() { "$@" || fatal "'$@' failed"; } -MY_DIR=$(try cd "${0%/*}" && try pwd) || exit 1 - -# reliably move to the etherpad base folder before running it -try cd "${MY_DIR}/../../../" +# Move to the Etherpad base directory. +MY_DIR=$(try cd "${0%/*}" && try pwd -P) || exit 1 +try cd "${MY_DIR}/../../../.." try sed -e ' s!"loadTest":[^,]*!"loadTest": true! @@ -17,7 +16,7 @@ s!"loadTest":[^,]*!"loadTest": true! s!"points":[^,]*!"points": 1000! ' settings.json.template >settings.json -log "Assuming bin/installDeps.sh has already been run" +log "Assuming src/bin/installDeps.sh has already been run" node node_modules/ep_etherpad-lite/node/server.js "${@}" >/dev/null & ep_pid=$! diff --git a/src/tests/ratelimit/Dockerfile.anotherip b/src/tests/ratelimit/Dockerfile.anotherip index 5b9d1d21..57f02f62 100644 --- a/src/tests/ratelimit/Dockerfile.anotherip +++ b/src/tests/ratelimit/Dockerfile.anotherip @@ -1,4 +1,4 @@ FROM node:alpine3.12 WORKDIR /tmp RUN npm i etherpad-cli-client -COPY ./tests/ratelimit/send_changesets.js /tmp/send_changesets.js +COPY ./src/tests/ratelimit/send_changesets.js /tmp/send_changesets.js diff --git a/src/tests/ratelimit/Dockerfile.nginx b/src/tests/ratelimit/Dockerfile.nginx index ba8dd358..c2a1dae4 100644 --- a/src/tests/ratelimit/Dockerfile.nginx +++ b/src/tests/ratelimit/Dockerfile.nginx @@ -1,2 +1,2 @@ FROM nginx -COPY ./tests/ratelimit/nginx.conf /etc/nginx/nginx.conf +COPY ./src/tests/ratelimit/nginx.conf /etc/nginx/nginx.conf