From 4470a3947bf4f9f06b03c2f1d4ffde059d0230f0 Mon Sep 17 00:00:00 2001 From: Harshit Bansal Date: Tue, 7 Mar 2017 22:37:59 +0530 Subject: [PATCH] provision: Download emoji-data during provisioning. Add code to download iamcal's emoji_pretty.json (emoji-data/emoji.json) during provisioning. --- .gitignore | 1 + tools/lib/provision.py | 1 + tools/setup/emoji/download-emoji-data | 23 +++++++++++++++++++++++ tools/update-prod-static | 4 ++++ 4 files changed, 29 insertions(+) create mode 100755 tools/setup/emoji/download-emoji-data diff --git a/.gitignore b/.gitignore index b855ea515a..4d6bcefbf1 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ static/js/bundle.js static/generated/emoji static/generated/github-contributors.json static/locale/language_options.json +static/third/emoji-data /node_modules /staticfiles.json npm-debug.log diff --git a/tools/lib/provision.py b/tools/lib/provision.py index 04e5cd1ab8..98d104393f 100755 --- a/tools/lib/provision.py +++ b/tools/lib/provision.py @@ -217,6 +217,7 @@ def main(options): if not os.path.isdir(EMOJI_CACHE_PATH): run(["sudo", "mkdir", EMOJI_CACHE_PATH]) run(["sudo", "chown", "%s:%s" % (user_id, user_id), EMOJI_CACHE_PATH]) + run(["tools/setup/emoji/download-emoji-data"]) run(["tools/setup/emoji/build_emoji"]) run(["scripts/setup/generate_secrets.py", "--development"]) run(["tools/update-authors-json", "--use-fixture"]) diff --git a/tools/setup/emoji/download-emoji-data b/tools/setup/emoji/download-emoji-data new file mode 100755 index 0000000000..93e901449e --- /dev/null +++ b/tools/setup/emoji/download-emoji-data @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e +set -x + +OUTPUT_PATH=static/third/emoji-data +COMMIT_FILE_PATH=$OUTPUT_PATH/commit +COMMIT=b588e200268d6c3c1d20d5ecdfe4634a68a6f947 # Change this to upgrade + +mkdir -p "$OUTPUT_PATH" + +if [ -e "$COMMIT_FILE_PATH" ] +then + CURRENT_COMMIT=`cat $COMMIT_FILE_PATH` +else + CURRENT_COMMIT=00 +fi + +if [ "$CURRENT_COMMIT" == "$COMMIT" ]; then + echo "Already at latest version of emoji.json" +else + echo "$COMMIT" > "$COMMIT_FILE_PATH" + wget "https://raw.githubusercontent.com/iamcal/emoji-data/$COMMIT/emoji_pretty.json" -O "$OUTPUT_PATH/emoji.json" +fi diff --git a/tools/update-prod-static b/tools/update-prod-static index 706ec09786..f5d2c2803e 100755 --- a/tools/update-prod-static +++ b/tools/update-prod-static @@ -37,6 +37,10 @@ fp = open('var/log/update-prod-static.log', 'w') # Install node packages setup_node_modules(npm_args=['--production'], stdout=fp, stderr=fp) +# Download emoji data +subprocess.check_call(['./tools/setup/emoji/download-emoji-data'], + stdout=fp, stderr=fp) + # Build emoji subprocess.check_call(['./tools/setup/emoji/build_emoji'], stdout=fp, stderr=fp)