zulip/scripts/lib/node_cache.py
Shubham Padia d7889221db
Some checks are pending
Code scanning / CodeQL (push) Waiting to run
Zulip production suite / Ubuntu 22.04 production build (push) Waiting to run
Zulip production suite / ${{ matrix.name }} (zulip/ci:bookworm, --test-custom-db, Debian 12 production install with custom db name and user, bookworm) (push) Blocked by required conditions
Zulip production suite / ${{ matrix.name }} (zulip/ci:jammy, , Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga, jammy) (push) Blocked by required conditions
Zulip production suite / ${{ matrix.name }} (zulip/ci:noble, , Ubuntu 24.04 production install, noble) (push) Blocked by required conditions
Zulip production suite / ${{ matrix.name }} (zulip/ci:bookworm-7.0, 7.0 Version Upgrade, bookworm) (push) Blocked by required conditions
Zulip production suite / ${{ matrix.name }} (zulip/ci:bookworm-8.0, 8.0 Version Upgrade, bookworm) (push) Blocked by required conditions
Zulip production suite / ${{ matrix.name }} (zulip/ci:jammy-6.0, 6.0 Version Upgrade, jammy) (push) Blocked by required conditions
Zulip production suite / ${{ matrix.name }} (zulip/ci:noble-9.0, 9.0 Version Upgrade, noble) (push) Blocked by required conditions
Zulip CI / ${{ matrix.name }} (zulip/ci:bookworm, true, false, Debian 12 (Python 3.11, backend + documentation), bookworm) (push) Waiting to run
Zulip CI / ${{ matrix.name }} (zulip/ci:jammy, false, true, Ubuntu 22.04 (Python 3.10, backend + frontend), jammy) (push) Waiting to run
Zulip CI / ${{ matrix.name }} (zulip/ci:noble, false, false, Ubuntu 24.04 (Python 3.12, backend), noble) (push) Waiting to run
node_cache: Run pnpm install if node_modules not present in help-beta.
We need this check when switching between branches without `help-beta`
package. `node_modules` will be removed when working on a non `help-beta`
branch, but if `node_modules/.pnpm/lock.yaml` has not been updated by that
branch, we will end up in a situation where we might not have `node_modules`
even when we run the provision command.

We might not need this check when the `help-beta` initial folder
has been merged for a week or two, where almost all active PRs
would have been rebased upon main, making switching branches an ease.
2024-08-02 18:18:01 -07:00

40 lines
1.1 KiB
Python

import os
from scripts.lib.zulip_tools import run
DEFAULT_PRODUCTION = False
def setup_node_modules(production: bool = DEFAULT_PRODUCTION) -> None:
if os.path.islink("node_modules"):
os.unlink("node_modules")
skip = False
try:
with open("node_modules/.pnpm/lock.yaml") as a, open("pnpm-lock.yaml") as b:
if a.read() == b.read():
skip = True
except FileNotFoundError:
pass
# We need this check when switching between branches without `help-beta`
# package. `node_modules` will be removed when working on a non `help-beta`
# branch, but if `node_modules/.pnpm/lock.yaml` has not been updated by that
# branch, we will end up in a situation where we might not have `node_modules`
# even when we run the provision command.
if not os.path.exists("help-beta/node_modules"):
skip = False
if not skip:
run(
[
"/usr/local/bin/corepack",
"pnpm",
"install",
"--frozen-lockfile",
"--prefer-offline",
*(["--prod"] if production else []),
]
)