etherpad-lite/bin/installer.ps1
John McLear 7d537f3deb
Require Node.js >= 25 (engines, installers, Dockerfile, snap, CI, docs) (#7749)
* docs: bump documented Node.js minimum to 25

Etherpad is moving its supported Node.js floor to >= 25 (CI matrix is
already pinned to 25 across all workflows on the node25-corepack-pnpm11
work). Sync the user-facing documentation so the install instructions,
requirements section, and plugin metadata example all reflect the new
minimum instead of Node 22 / 12.17.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore: require Node.js >= 25 (engines, installers, Dockerfile, snap, CI)

#7747 added Node 25 *support* but left the floor at Node 22. This
commit completes the cutover so the runtime requirement matches the
documentation bumped in the previous commit.

- package.json: engines.node ">=22.13.0" → ">=25.0.0"
- bin/functions.sh, bin/installer.sh, bin/installer.ps1: REQUIRED_NODE
  bumped to 25 (controls the error message users see when they invoke
  the installer or pnpm scripts on an older Node)
- Dockerfile: base image node:22-alpine → node:25-alpine (×2). Corepack
  comment updated: Node 25 no longer ships corepack at all, so we
  install it from npm rather than refreshing a stale signing-key list
- snap/snapcraft.yaml: pinned NODE_VERSION 22.22.2 → 25.9.0 and the
  surrounding design notes rewritten to reflect Node 25 instead of 22
- .github/workflows/*.yml: matrix dropped from [22, 24, 25] to just
  [25] (anything older now fails engines anyway). Stale comments in
  build-and-deploy-docs.yml referencing vite 8's 22.12 floor cleaned up
- bin/plugins/lib/npmpublish.yml: setup-node 22 → 25 so the plugin
  template propagated to every ether/* plugin matches the new minimum

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(docker): install pnpm directly on Node 25 (no corepack)

node:25-alpine doesn't ship corepack but does pre-install yarn at
/usr/local/bin/yarn, so `npm install -g corepack@latest` fails with
EEXIST trying to register its yarn shim. Per #7747, end-users install
pnpm via plain `npm install -g pnpm` on Node 25 — use the same flow in
the Dockerfile (and remove the unused yarn binary so it doesn't sit on
PATH inside the image). Drops COREPACK_HOME and the related
issue-7687 cache-sharing tweak since there's no corepack shim to share.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 10:04:24 +01:00

155 lines
6.2 KiB
PowerShell

# Etherpad one-line installer for Windows (PowerShell).
#
# Usage:
# irm https://raw.githubusercontent.com/ether/etherpad-lite/master/bin/installer.ps1 | iex
#
# Optional environment variables:
# $env:ETHERPAD_DIR Directory to install into (default: .\etherpad-lite)
# $env:ETHERPAD_BRANCH Branch / tag to clone (default: master)
# $env:ETHERPAD_REPO Repo URL (default: https://github.com/ether/etherpad.git)
# $env:ETHERPAD_RUN If "1", start Etherpad after install
# $env:NO_COLOR If set, disables coloured output
#Requires -Version 5.1
$ErrorActionPreference = 'Stop'
# ---------- pretty output ----------
$useColor = -not $env:NO_COLOR
function Write-Step([string]$msg) {
if ($useColor) { Write-Host "==> $msg" -ForegroundColor Green }
else { Write-Host "==> $msg" }
}
function Write-Warn([string]$msg) {
if ($useColor) { Write-Host "==> $msg" -ForegroundColor Yellow }
else { Write-Host "==> $msg" }
}
function Write-Fatal([string]$msg) {
if ($useColor) { Write-Host "==> $msg" -ForegroundColor Red }
else { Write-Host "==> $msg" }
exit 1
}
function Test-Cmd([string]$name) {
return [bool](Get-Command $name -ErrorAction SilentlyContinue)
}
# ---------- defaults ----------
$EtherpadDir = if ($env:ETHERPAD_DIR) { $env:ETHERPAD_DIR } else { 'etherpad-lite' }
$EtherpadBranch = if ($env:ETHERPAD_BRANCH) { $env:ETHERPAD_BRANCH } else { 'master' }
$EtherpadRepo = if ($env:ETHERPAD_REPO) { $env:ETHERPAD_REPO } else { 'https://github.com/ether/etherpad.git' }
$RequiredNodeMajor = 25
Write-Step 'Etherpad installer'
# ---------- prerequisite checks ----------
if (-not (Test-Cmd git)) {
Write-Fatal 'git is required but not installed. See https://git-scm.com/download/win'
}
if (-not (Test-Cmd node)) {
Write-Fatal "Node.js is required (>= $RequiredNodeMajor). Install it from https://nodejs.org"
}
$nodeMajor = [int](node -p 'process.versions.node.split(".")[0]')
if ($nodeMajor -lt $RequiredNodeMajor) {
$nodeVer = (node --version)
Write-Fatal "Node.js >= $RequiredNodeMajor required. You have $nodeVer."
}
if (-not (Test-Cmd pnpm)) {
Write-Step 'Installing pnpm globally'
if (-not (Test-Cmd npm)) {
Write-Fatal "npm not found. Install Node.js >= $RequiredNodeMajor."
}
npm install -g pnpm
if ($LASTEXITCODE -ne 0) {
Write-Fatal 'Failed to install pnpm. Install it manually: https://pnpm.io/installation'
}
if (-not (Test-Cmd pnpm)) {
Write-Fatal 'pnpm install reported success but pnpm is still not on PATH. Open a new shell and re-run.'
}
}
# ---------- clone ----------
if (Test-Path $EtherpadDir) {
if (Test-Path (Join-Path $EtherpadDir '.git')) {
Write-Warn "$EtherpadDir already exists; updating to $EtherpadBranch."
Push-Location $EtherpadDir
try {
# Verify the existing checkout points at the expected remote.
$existingRemote = (git remote get-url origin 2>$null)
if ($existingRemote -and $existingRemote -ne $EtherpadRepo) {
Write-Fatal "$EtherpadDir is checked out from '$existingRemote', expected '$EtherpadRepo'. Refusing to overwrite."
}
# Refuse to clobber meaningful local changes. pnpm-lock.yaml is
# excluded because `pnpm i` rewrites it during installation,
# which would otherwise make every re-run of the installer fail.
$statusLines = (git status --porcelain) -split "`n" |
Where-Object { $_ -and ($_ -notmatch '\bpnpm-lock\.yaml$') }
if ($statusLines) {
$statusLines | ForEach-Object { Write-Host $_ }
Write-Fatal "$EtherpadDir has uncommitted changes. Commit/stash them or remove the directory."
}
git fetch --tags --prune origin
if ($LASTEXITCODE -ne 0) { Write-Fatal "git fetch failed in $EtherpadDir" }
# Discard any pnpm-lock.yaml changes from a prior pnpm install
# so the subsequent checkout doesn't refuse to overwrite.
git checkout -- pnpm-lock.yaml 2>$null
# Switch to the requested branch / tag and fast-forward to it.
git show-ref --verify --quiet "refs/remotes/origin/$EtherpadBranch"
$isBranch = ($LASTEXITCODE -eq 0)
git show-ref --verify --quiet "refs/tags/$EtherpadBranch"
$isTag = ($LASTEXITCODE -eq 0)
if ($isBranch) {
git checkout -B $EtherpadBranch "origin/$EtherpadBranch"
if ($LASTEXITCODE -ne 0) { Write-Fatal "git checkout $EtherpadBranch failed" }
} elseif ($isTag) {
git checkout --detach "refs/tags/$EtherpadBranch"
if ($LASTEXITCODE -ne 0) { Write-Fatal "git checkout tag $EtherpadBranch failed" }
} else {
Write-Fatal "Branch or tag '$EtherpadBranch' not found on origin."
}
$installedRev = (git rev-parse --short HEAD)
Write-Step "Updated $EtherpadDir to $EtherpadBranch @ $installedRev"
} finally {
Pop-Location
}
} else {
Write-Fatal "$EtherpadDir exists and is not a git checkout. Aborting."
}
} else {
Write-Step "Cloning Etherpad ($EtherpadBranch) into $EtherpadDir"
git clone --depth 1 --branch $EtherpadBranch $EtherpadRepo $EtherpadDir
if ($LASTEXITCODE -ne 0) { Write-Fatal 'git clone failed.' }
}
Push-Location $EtherpadDir
# ---------- install + build ----------
Write-Step 'Installing dependencies (pnpm i)'
pnpm i
if ($LASTEXITCODE -ne 0) { Pop-Location; Write-Fatal 'pnpm i failed.' }
Write-Step 'Building Etherpad (pnpm run build:etherpad)'
pnpm run build:etherpad
if ($LASTEXITCODE -ne 0) { Pop-Location; Write-Fatal 'pnpm run build:etherpad failed.' }
# ---------- done ----------
Write-Host ''
if ($useColor) { Write-Host "🎉 Etherpad is installed in $EtherpadDir" -ForegroundColor Green }
else { Write-Host "Etherpad is installed in $EtherpadDir" }
Write-Host 'To start Etherpad:'
Write-Host " cd $EtherpadDir; pnpm run prod"
Write-Host 'Then open http://localhost:9001 in your browser.'
Write-Host ''
if ($env:ETHERPAD_RUN -eq '1') {
Write-Step 'Starting Etherpad on http://localhost:9001'
pnpm run prod
}