mirror of
https://github.com/zulip/zulip.git
synced 2026-06-21 21:32:29 +08:00
There’s no reason to monkey-patch something that we were already subclassing. Removing the PRODUCTION conditional causes us to generate staticfiles.json in the right place to begin with so we don’t need to move it later. It also allows Django to find staticfiles.json if running the dev server with PIPELINE_ENABLED. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
74 lines
2.3 KiB
Python
Executable File
74 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# Updates static files for production.
|
|
|
|
|
|
import os
|
|
import argparse
|
|
import sys
|
|
|
|
# We need settings so we can figure out where the prod-static directory is.
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
|
import scripts.lib.setup_path_on_import
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
|
|
from django.conf import settings
|
|
from scripts.lib.node_cache import setup_node_modules
|
|
from scripts.lib.zulip_tools import run
|
|
|
|
# check for the venv
|
|
from lib import sanity_check
|
|
sanity_check.check_venv(__file__)
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--prev-deploy', metavar='DIR',
|
|
help='a previous deploy from which to reuse files if possible')
|
|
parser.add_argument('--authors-not-required', action='store_true', default=False,
|
|
help='Authors files need not be updated')
|
|
args = parser.parse_args()
|
|
prev_deploy = args.prev_deploy
|
|
|
|
os.chdir(settings.DEPLOY_ROOT)
|
|
|
|
# Redirect child processes' output to a log file (most recent run only).
|
|
os.makedirs("var/log", exist_ok=True)
|
|
fp = open('var/log/update-prod-static.log', 'w')
|
|
|
|
# Install node packages
|
|
setup_node_modules(production=True, stdout=fp, stderr=fp)
|
|
|
|
# Build emoji
|
|
run(['./tools/setup/emoji/build_emoji'], stdout=fp, stderr=fp)
|
|
|
|
# Inline CSS in emails
|
|
run(['./tools/inline-email-css'], stdout=fp, stderr=fp)
|
|
|
|
# Copy over static files from the zulip_bots package
|
|
run(['./tools/setup/generate_zulip_bots_static_files.py'], stdout=fp, stderr=fp)
|
|
|
|
# Build pygment data
|
|
run(['./tools/setup/build_pygments_data'], stdout=fp, stderr=fp)
|
|
|
|
# Create webpack bundle
|
|
run(['./tools/webpack'], stdout=fp, stderr=fp)
|
|
|
|
# Generate /team page markdown for authors
|
|
authors_cmd = ['./tools/update-authors-json']
|
|
if os.environ.get("TRAVIS"):
|
|
authors_cmd.append("--use-fixture")
|
|
if args.authors_not_required:
|
|
authors_cmd.append("--not-required")
|
|
run(authors_cmd, stdout=fp, stderr=fp)
|
|
|
|
# Collect the files that we're going to serve; this creates prod-static/serve.
|
|
run(['./manage.py', 'collectstatic', '--no-default-ignore',
|
|
'--noinput', '-i', 'assets', '-i', 'js', '-i', 'styles', '-i', 'templates'],
|
|
stdout=fp, stderr=fp)
|
|
|
|
# Compile translation strings to generate `.mo` files.
|
|
run(['./manage.py', 'compilemessages'], stdout=fp, stderr=fp)
|
|
|
|
# Needed if PRODUCTION
|
|
os.makedirs('prod-static', exist_ok=True)
|
|
|
|
fp.close()
|