Added initial bun support.

This commit is contained in:
SamTV12345 2023-10-02 19:06:25 +02:00
parent b6ce8c7377
commit 8be2dffc37
9 changed files with 32 additions and 9619 deletions

View file

@ -18,19 +18,15 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [16, 18, 20]
node: [1.0.3, canary]
steps:
-
name: Checkout repository
uses: actions/checkout@v4
-
uses: actions/setup-node@v3
uses: oven-sh/setup-bun@v1
with:
node-version: ${{ matrix.node }}
cache: 'npm'
cache-dependency-path: |
src/package-lock.json
src/bin/doc/package-lock.json
bun-version: ${{ matrix.node }}
-
name: Install libreoffice
run: |
@ -42,7 +38,7 @@ jobs:
run: src/bin/installDeps.sh
-
name: Run the backend tests
run: cd src && npm test
run: cd src && bun test
withpluginsLinux:
# run on pushes to any branch
@ -55,19 +51,15 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [16, 18, 20]
node: [1.0.3, canary]
steps:
-
name: Checkout repository
uses: actions/checkout@v4
-
uses: actions/setup-node@v3
uses: oven-sh/setup-bun@v1
with:
node-version: ${{ matrix.node }}
cache: 'npm'
cache-dependency-path: |
src/package-lock.json
src/bin/doc/package-lock.json
bun-version: ${{ matrix.node }}
-
name: Install libreoffice
run: |
@ -76,10 +68,8 @@ jobs:
sudo apt install -y --no-install-recommends libreoffice libreoffice-pdfimport
-
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: >
npm install --no-save --legacy-peer-deps
bun install --no-save --legacy-peer-deps
ep_align
ep_author_hover
ep_cursortrace
@ -93,21 +83,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 && npm test
run: cd src && bun run test
withoutpluginsWindows:
# run on pushes to any branch
@ -122,13 +103,9 @@ jobs:
name: Checkout repository
uses: actions/checkout@v4
-
uses: actions/setup-node@v3
uses: oven-sh/setup-bun@v1
with:
node-version: 20
cache: 'npm'
cache-dependency-path: |
src/package-lock.json
src/bin/doc/package-lock.json
bun-version: latest
-
name: Install all dependencies and symlink for ep_etherpad-lite
run: src/bin/installOnWindows.bat
@ -139,7 +116,7 @@ jobs:
powershell -Command "(gc settings.json.holder) -replace '\"points\": 10', '\"points\": 1000' | Out-File -encoding ASCII settings.json"
-
name: Run the backend tests
run: cd src && npm test
run: cd src && bun run test
withpluginsWindows:
# run on pushes to any branch
@ -155,19 +132,13 @@ jobs:
name: Checkout repository
uses: actions/checkout@v4
-
uses: actions/setup-node@v3
uses: oven-sh/setup-bun@v1
with:
node-version: 20
cache: 'npm'
cache-dependency-path: |
src/package-lock.json
src/bin/doc/package-lock.json
bun-version: latest
-
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: >
npm install --no-save --legacy-peer-deps
bun install --no-save
ep_align
ep_author_hover
ep_cursortrace
@ -181,15 +152,6 @@ 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/installOnWindows.bat
@ -200,4 +162,4 @@ jobs:
powershell -Command "(gc settings.json.holder) -replace '\"points\": 10', '\"points\": 1000' | Out-File -encoding ASCII settings.json"
-
name: Run the backend tests
run: cd src && npm test
run: cd src && bun run test

2
.gitignore vendored
View file

@ -21,3 +21,5 @@ out/
/src/bin/convertSettings.json
/src/bin/etherpad-1.deb
/src/bin/node.exe
*.lockb binary diff=lockb

View file

@ -8,20 +8,17 @@ cd "${MY_DIR}/../.." || exit 1
# Source constants and useful functions
. src/bin/functions.sh
# Is node installed?
# Not checking io.js, default installation creates a symbolic link to node
is_cmd node || fatal "Please install node.js ( https://nodejs.org )"
# Is bun installed?
is_cmd bun || fatal "Please install bun ( https://bun.sh )"
# Is npm installed?
is_cmd npm || fatal "Please install npm ( https://npmjs.org )"
# Check npm version
require_minimal_version "npm" "$(get_program_version "npm")" \
"$REQUIRED_NPM_MAJOR" "$REQUIRED_NPM_MINOR"
#require_minimal_version "npm" "$(get_program_version "npm")" \
# "$REQUIRED_NPM_MAJOR" "$REQUIRED_NPM_MINOR"
# Check node version
require_minimal_version "nodejs" "$(get_program_version "node")" \
"$REQUIRED_NODE_MAJOR" "$REQUIRED_NODE_MINOR"
#require_minimal_version "nodejs" "$(get_program_version "node")" \
# "$REQUIRED_NODE_MAJOR" "$REQUIRED_NODE_MINOR"
# Get the name of the settings file
settings="settings.json"
@ -48,10 +45,10 @@ cd src
if [ -z "${ETHERPAD_PRODUCTION}" ]; then
log "Installing dev dependencies"
npm ci --no-optional --omit=optional --include=dev --lockfile-version 1 || exit 1
bun install --no-optional --omit=optional --include=dev --lockfile-version 1 || exit 1
else
log "Installing production dependencies"
npm ci --no-optional --omit=optional --omit=dev --lockfile-version 1 --production || exit 1
bun install --no-optional --omit=optional --omit=dev --lockfile-version 1 --production || exit 1
fi
# Remove all minified data to force node creating it new

View file

@ -14,7 +14,7 @@ cd /D node_modules
mklink /D "ep_etherpad-lite" "..\src"
cd /D "ep_etherpad-lite"
cmd /C npm ci || exit /B 1
cmd /C bun install --frozen-lockfile || exit /B 1
cd /D "%~dp0\..\.."

View file

@ -32,4 +32,4 @@ src/bin/installDeps.sh "$@" || exit 1
# Move to the node folder and start
log "Starting Etherpad..."
exec node src/node/server.js "$@"
exec bun run src/node/server.js "$@"

BIN
src/bun.lockb Executable file

Binary file not shown.

9549
src/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -93,6 +93,7 @@
"typescript": "^4.9.5"
},
"engines": {
"bun": ">=1.0.3",
"node": ">=16.20.1",
"npm": ">=6.14.0"
},

View file

@ -14,10 +14,10 @@ const logger = log4js.getLogger('plugins');
// Log the version of npm at startup.
(async () => {
try {
const version = await runCmd(['npm', '--version'], {stdio: [null, 'string']});
logger.info(`npm --version: ${version}`);
const version = await runCmd(['bun', '--version'], {stdio: [null, 'string']});
logger.info(`bun --version: ${version}`);
} catch (err) {
logger.error(`Failed to get npm version: ${err.stack || err}`);
logger.error(`Failed to get bun version: ${err.stack || err}`);
// This isn't a fatal error so don't re-throw.
}
})();