mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
provision: Use a more efficient approach for getting yarn version.
Since yarn has a package.json conveniently available, we can parse that with jq, saving the expensive operation of starting up yarn. This saves ~300ms in a no-op provision.
This commit is contained in:
@@ -163,7 +163,7 @@ fi
|
||||
|
||||
apt-get -y dist-upgrade "${APT_OPTIONS[@]}"
|
||||
if ! apt-get install -y \
|
||||
puppet git curl wget \
|
||||
puppet git curl wget jq \
|
||||
python python3 python-six python3-six crudini \
|
||||
"${ADDITIONAL_PACKAGES[@]}"; then
|
||||
set +x
|
||||
|
||||
@@ -6,7 +6,7 @@ ZULIP_SRV="/srv"
|
||||
if [ "$TRAVIS" ] ; then
|
||||
ZULIP_SRV="/home/travis"
|
||||
fi
|
||||
YARN_BIN="$ZULIP_SRV/zulip-yarn/bin/yarn"
|
||||
YARN_PACKAGE_JSON="$ZULIP_SRV/zulip-yarn/package.json"
|
||||
node_version=8.11.1
|
||||
yarn_version=1.7.0
|
||||
|
||||
@@ -20,7 +20,12 @@ if node_wrapper_path="$(command -v node)"; then
|
||||
current_node_version="$(node --version)"
|
||||
fi
|
||||
|
||||
if [ "$($YARN_BIN --version 2>/dev/null)" = "$yarn_version" ] && [ "$current_node_version" = "v$node_version" ] && [ -L "$node_wrapper_path" ]; then
|
||||
current_yarn_version="none"
|
||||
if [ -e "$YARN_PACKAGE_JSON" ]; then
|
||||
current_yarn_version=$(jq -r '.version' "$YARN_PACKAGE_JSON")
|
||||
fi
|
||||
|
||||
if [ "$current_yarn_version" = "$yarn_version" ] && [ "$current_node_version" = "v$node_version" ] && [ -L "$node_wrapper_path" ]; then
|
||||
echo "Node version $node_version and yarn version $yarn_version are already installed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -37,6 +37,12 @@ VENV_DEPENDENCIES = [
|
||||
"libxslt1-dev", # Used for installing talon
|
||||
"libpq-dev", # Needed by psycopg2
|
||||
"libssl-dev", # Needed to build pycurl and other libraries
|
||||
|
||||
# This is technically a node dependency, but we add it here
|
||||
# because we don't have another place that we install apt packages
|
||||
# on upgrade of a production server, and it's not worth adding
|
||||
# another call to `apt install` for.
|
||||
"jq", # Used by scripts/lib/install-node to check yarn version
|
||||
]
|
||||
|
||||
codename = parse_lsb_release()["DISTRIB_CODENAME"]
|
||||
|
||||
Reference in New Issue
Block a user