Files
zulip/scripts/lib/node_cache.py
Shubham Padia 3e60b16ac1 starlight_help: Move help-beta over to starlight_help.
We are starting the cutover process and starlight_help is the directory
we have agreed on to place our new help center project. We do not want
to use `starlight_help` as the URL for the project, but this commit
changes the url from `help-beta` to `starlight_help` temporarily since
we can only change URL once we get rid of the current help center
project. That will be done in a future commit.
2025-08-08 11:59:29 -07:00

40 lines
1.2 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 `starlight_help`
# package. `node_modules` will be removed when working on a non `starlight_help`
# 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("starlight_help/node_modules"):
skip = False
if not skip:
run(
[
"/usr/local/bin/corepack",
"pnpm",
"install",
"--frozen-lockfile",
"--prefer-offline",
*(["--prod"] if production else []),
],
)