Files
zulip/tools/build-help-center
Shubham Padia 7db29f29de help: Serve help center build without relative links for zulip.com.
We have a copy of help center with relative links disabled which is
reserved for root domains without an organisation on the root domain.
Ideally, we should have some logic to determine whether we are on such
a root domain or not. For practical short term purposes, since this
type of documentation is mainly useful for zulip.com, we add an
exception for zulip.com.
2025-09-03 09:28:15 -07:00

56 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
import argparse
import os
import subprocess
import sys
from email.utils import parseaddr
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from scripts.lib.setup_path import setup_path
setup_path()
os.environ["DJANGO_SETTINGS_MODULE"] = "zproject.settings"
import django
django.setup()
from django.conf import settings
parser = argparse.ArgumentParser()
parser.add_argument(
"--no-relative-links",
action="store_false",
dest="show_relative_links",
help="Disable relative links when using NavigationSteps component. Typically only set to true in case of the help center being hosted on zulip.com.",
)
parser.add_argument(
"--out-dir",
action="store",
dest="out_dir",
help="Output directory for the final build.",
)
args = parser.parse_args()
def run() -> None:
env = os.environ.copy()
env["SUPPORT_EMAIL"] = parseaddr(settings.ZULIP_ADMINISTRATOR)[1]
env["CORPORATE_ENABLED"] = str(settings.CORPORATE_ENABLED).lower()
env["SHOW_RELATIVE_LINKS"] = str(args.show_relative_links).lower()
build_command = ["/usr/local/bin/corepack", "pnpm", "build"]
if args.out_dir:
build_command += ["--outDir", args.out_dir]
subprocess.check_call(
build_command,
cwd="starlight_help",
env=env,
)
run()