mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
Fixes #2665. Regenerated by tabbott with `lint --fix` after a rebase and change in parameters. Note from tabbott: In a few cases, this converts technical debt in the form of unsorted imports into different technical debt in the form of our largest files having very long, ugly import sequences at the start. I expect this change will increase pressure for us to split those files, which isn't a bad thing. Signed-off-by: Anders Kaseorg <anders@zulip.com>
68 lines
1.7 KiB
Python
Executable File
68 lines
1.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# Updates static files for production.
|
|
import argparse
|
|
import os
|
|
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__), '..'))
|
|
from scripts.lib.setup_path import setup_path
|
|
|
|
setup_path()
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
|
|
from django.conf import settings
|
|
|
|
# check for the venv
|
|
from lib import sanity_check
|
|
from scripts.lib.node_cache import setup_node_modules
|
|
from scripts.lib.zulip_tools import run
|
|
|
|
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')
|
|
args = parser.parse_args()
|
|
prev_deploy = args.prev_deploy
|
|
|
|
os.chdir(settings.DEPLOY_ROOT)
|
|
|
|
# Install node packages
|
|
setup_node_modules(production=True)
|
|
|
|
# Build emoji
|
|
run(['./tools/setup/emoji/build_emoji'])
|
|
|
|
# Inline CSS in emails
|
|
run(['./scripts/setup/inline_email_css.py'])
|
|
|
|
# Copy over static files from the zulip_bots package
|
|
run(['./tools/setup/generate_zulip_bots_static_files.py'])
|
|
|
|
# Build pygment data
|
|
run(['./tools/setup/build_pygments_data'])
|
|
|
|
# Create webpack bundle
|
|
run(['./tools/webpack', '--quiet'])
|
|
|
|
# Collect the files that we're going to serve; this creates prod-static/serve.
|
|
run([
|
|
'./manage.py', 'collectstatic', '--no-default-ignore',
|
|
'-v0',
|
|
'--noinput',
|
|
'-i', 'assets',
|
|
'-i', 'emoji-styles',
|
|
'-i', 'html',
|
|
'-i', 'js',
|
|
'-i', 'styles',
|
|
'-i', 'templates',
|
|
])
|
|
|
|
# Compile translation strings to generate `.mo` files.
|
|
run(['./manage.py', 'compilemessages', '-v0'])
|
|
|
|
# Needed if PRODUCTION
|
|
os.makedirs('prod-static', exist_ok=True)
|