mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
install-node: Upgrade Node.js to 18.14.0; manage Yarn with Corepack.
Corepack manages multiple per-project version of Yarn and PNPM, which means we have to maintain less installation code, and could help us switch away from Yarn 1 without making the system unusable for development of other Yarn 1 projects. https://nodejs.org/api/corepack.html The Unicode spaces in the timerender test resulted from an ICU upgrade: https://github.com/nodejs/node/pull/45068. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
70ac144d57
commit
ec58b6790d
@@ -390,7 +390,6 @@ if [ "$VIRTUALENV_NEEDED" = "yes" ]; then
|
||||
fi
|
||||
|
||||
"$ZULIP_PATH"/scripts/lib/install-node
|
||||
"$ZULIP_PATH"/scripts/lib/install-yarn
|
||||
|
||||
# Generate /etc/zulip/zulip.conf .
|
||||
mkdir -p /etc/zulip
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
version=18.12.1
|
||||
version=18.14.0
|
||||
arch="$(uname -m)"
|
||||
|
||||
case $arch in
|
||||
x86_64)
|
||||
tarball="node-v$version-linux-x64.tar.xz"
|
||||
sha256=4481a34bf32ddb9a9ff9540338539401320e8c3628af39929b4211ea3552a19e
|
||||
sha256=1ccec74b6240fce8754813e31fdbc93ad520df2e814729cea29efe9075e48350
|
||||
;;
|
||||
|
||||
aarch64)
|
||||
tarball="node-v$version-linux-arm64.tar.xz"
|
||||
sha256=3904869935b7ecc51130b4b86486d2356539a174d11c9181180cab649f32cd2a
|
||||
sha256=30ef375f0b8006759c0e08bee9d4b74915b95abfa924006c289d2d474a8b152e
|
||||
;;
|
||||
esac
|
||||
|
||||
check_version() {
|
||||
out="$(node --version)" && [ "$out" = "v$version" ]
|
||||
out="$(node --version)" && [ "$out" = "v$version" ] \
|
||||
&& [ /usr/local/bin/yarn -ef /srv/zulip-node/lib/node_modules/corepack/dist/yarn.js ]
|
||||
}
|
||||
|
||||
if ! check_version 2>/dev/null; then
|
||||
@@ -33,7 +34,11 @@ if ! check_version 2>/dev/null; then
|
||||
rm -rf /srv/zulip-node
|
||||
mkdir -p /srv/zulip-node
|
||||
tar -xJf "$tarball" --no-same-owner --strip-components=1 -C /srv/zulip-node
|
||||
ln -sf /srv/zulip-node/bin/{node,npm,npx} /usr/local/bin
|
||||
rm -rf /usr/local/nvm
|
||||
ln -sf /srv/zulip-node/bin/{corepack,node,npm,npx} /usr/local/bin
|
||||
COREPACK_DEFAULT_TO_LATEST=0 /usr/local/bin/corepack enable
|
||||
|
||||
# Clean up after previous versions of this script
|
||||
rm -rf /srv/zulip-yarn /usr/bin/yarn /usr/local/nvm
|
||||
|
||||
check_version
|
||||
fi
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
version=1.22.19
|
||||
sha256=732620bac8b1690d507274f025f3c6cfdc3627a84d9642e38a07452cc00e0f2e
|
||||
tarball="yarn-$version.tgz"
|
||||
|
||||
check_version() {
|
||||
# Reading the version of Yarn from its package.json is much faster
|
||||
# than running yarn --version.
|
||||
current_version="$(jq -r '.version' /srv/zulip-yarn/package.json)" \
|
||||
&& [ "$current_version" = "$version" ]
|
||||
}
|
||||
|
||||
if ! check_version; then
|
||||
tmpdir="$(mktemp -d)"
|
||||
trap 'rm -r "$tmpdir"' EXIT
|
||||
cd "$tmpdir"
|
||||
curl -fLO --retry 3 "https://registry.npmjs.org/yarn/-/$tarball"
|
||||
sha256sum -c <<<"$sha256 $tarball"
|
||||
rm -rf /srv/zulip-yarn
|
||||
mkdir /srv/zulip-yarn
|
||||
tar -xzf "$tarball" --no-same-owner --strip-components=1 -C /srv/zulip-yarn
|
||||
check_version
|
||||
fi
|
||||
@@ -11,8 +11,7 @@ ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__f
|
||||
ZULIP_SRV_PATH = "/srv"
|
||||
|
||||
NODE_MODULES_CACHE_PATH = os.path.join(ZULIP_SRV_PATH, "zulip-npm-cache")
|
||||
YARN_BIN = os.path.join(ZULIP_SRV_PATH, "zulip-yarn/bin/yarn")
|
||||
YARN_PACKAGE_JSON = os.path.join(ZULIP_SRV_PATH, "zulip-yarn/package.json")
|
||||
YARN_BIN = "/usr/local/bin/yarn"
|
||||
|
||||
DEFAULT_PRODUCTION = False
|
||||
|
||||
@@ -40,8 +39,6 @@ def generate_sha1sum_node_modules(
|
||||
# For backwards compatibility, we can't assume yarn.lock exists
|
||||
with open(YARN_LOCK_FILE_PATH) as f:
|
||||
data[YARN_LOCK_FILE_PATH] = f.read().strip()
|
||||
with open(YARN_PACKAGE_JSON) as f:
|
||||
data["yarn-package-version"] = json.load(f)["version"]
|
||||
data["node-version"] = subprocess.check_output(["node", "--version"], text=True).strip()
|
||||
data["yarn-args"] = get_yarn_args(production=production)
|
||||
|
||||
|
||||
@@ -29,11 +29,7 @@ VENV_DEPENDENCIES = [
|
||||
# Needed by python-xmlsec:
|
||||
"libxmlsec1-dev",
|
||||
"pkg-config",
|
||||
# This is technically a node dependency, but we add it here
|
||||
# because we don't have another place that we install apt packages
|
||||
# on upgrade of a production server, and it's not worth adding
|
||||
# another call to `apt install` for.
|
||||
"jq", # Used by scripts/lib/install-yarn to check yarn version
|
||||
"jq", # No longer used in production (clean me up later)
|
||||
"libsasl2-dev", # For building python-ldap from source
|
||||
]
|
||||
|
||||
|
||||
@@ -263,7 +263,6 @@ if not args.skip_downgrade_check:
|
||||
|
||||
# Make sure the right version of node is installed
|
||||
subprocess.check_call([os.path.join(deploy_path, "scripts", "lib", "install-node")])
|
||||
subprocess.check_call([os.path.join(deploy_path, "scripts", "lib", "install-yarn")])
|
||||
|
||||
# Generate any new secrets that were added in the new version required.
|
||||
# TODO: Do caching to only run this when it has changed.
|
||||
|
||||
Reference in New Issue
Block a user