<commit_before>#!/usr/bin/env bash

# =========================== CHECK FORCE FLAG =================================
if [ "$1" == "--force" ]; then
  FORCE=true
fi


# =========================== CURRENT VERSION INFO =============================
echo "--> Getting version numbers"

CURR_VERSION=$(curl -s https://gcollazo.github.io/mongodbapp/ | grep -o '<div class="current-version">v.*' | grep -o '[0-9]*\.[0-9]*\.[0-9]*-build\.[0-9]*')

CURR_MONGO=$(echo $CURR_VERSION | grep -o '^[0-9]*\.[0-9]*\.[0-9]*')
CURR_BUILD=$(echo $CURR_VERSION | grep -o '[0-9]*$')

echo " -- Current mongodb.app version: $CURR_MONGO"


# =========================== LATEST VERSION INFO ==============================
# Get latest mongodb Production Relase version
VERSION=$(curl -s https://www.mongodb.com/download-center | grep -o 'Current Stable Release (.*)</span>' | grep -o '[0-9]*\.[0-9]*\.[0-9]*')
echo " -- Latest mongodb version: $VERSION"


# =========================== COMPARE VERSIONS =================================
if [ "$FORCE" != true ] && [ "$CURR_MONGO" == "$VERSION" ]; then
  echo " -- No need to update :)"
  echo "==> Done!"
  exit 0
fi


# =========================== DOWNLOAD =========================================
echo '--> Download'
DOWNLOAD_URL="http://downloads.mongodb.org/osx/mongodb-osx-ssl-x86_64-$VERSION.tgz"

# Download latest mongodb for mac
echo " -- Downloading: $DOWNLOAD_URL"
curl -o /tmp/mongodb.tgz $DOWNLOAD_URL

# Clean old mongodb dir
echo " -- Cleaning directory $(pwd)/Vendor/mongodb"
rm -rf $(pwd)/Vendor/mongodb

# Create dir
echo " -- Creating directory $(pwd)/Vendor/mongodb"
mkdir -p $(pwd)/Vendor/mongodb

# Extract
echo " -- Unzipping..."
tar xvzf /tmp/mongodb.tgz -C /tmp

# move files
echo " -- Moving files to $(pwd)/Vendor/mongodb/"
mv /tmp/mongodb-osx-x86_64-*/* Vendor/mongodb

# cleanup
echo " -- Removing /tmp/mongodb.tgz"
rm /tmp/mongodb.tgz<commit_msg>Fix update script to handle new website design<commit_after>#!/usr/bin/env bash

# =========================== CHECK FORCE FLAG =================================
if [ "$1" == "--force" ]; then
  FORCE=true
fi


# =========================== CURRENT VERSION INFO =============================
echo "--> Getting version numbers"

CURR_VERSION=$(curl -s https://gcollazo.github.io/mongodbapp/ | grep -o '<div class="current-version">v.*' | grep -o '[0-9]*\.[0-9]*\.[0-9]*-build\.[0-9]*')

CURR_MONGO=$(echo $CURR_VERSION | grep -o '^[0-9]*\.[0-9]*\.[0-9]*')
CURR_BUILD=$(echo $CURR_VERSION | grep -o '[0-9]*$')

echo " -- Current mongodb.app version: $CURR_MONGO"


# =========================== LATEST VERSION INFO ==============================
# Get latest mongodb Production Relase version
VERSION=$(curl -s https://www.mongodb.com/download-center/v2/community | \
  grep -o '<option value="1" selected>.* (current release)</option>' | \
  grep -o '[0-9]*\.[0-9]*\.[0-9]*')
echo " -- Latest mongodb version: $VERSION"


# =========================== COMPARE VERSIONS =================================
if [ "$FORCE" != true ] && [ "$CURR_MONGO" == "$VERSION" ]; then
  echo " -- No need to update :)"
  echo "==> Done!"
  exit 0
fi


# =========================== DOWNLOAD =========================================
echo '--> Download'
DOWNLOAD_URL="https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-$VERSION.tgz"

# Download latest mongodb for mac
echo " -- Downloading: $DOWNLOAD_URL"
curl -o /tmp/mongodb.tgz $DOWNLOAD_URL

# Clean old mongodb dir
echo " -- Cleaning directory $(pwd)/Vendor/mongodb"
rm -rf $(pwd)/Vendor/mongodb

# Create dir
echo " -- Creating directory $(pwd)/Vendor/mongodb"
mkdir -p $(pwd)/Vendor/mongodb

# Extract
echo " -- Unzipping..."
tar xvzf /tmp/mongodb.tgz -C /tmp

# move files
echo " -- Moving files to $(pwd)/Vendor/mongodb/"
mv /tmp/mongodb-osx-x86_64-*/* Vendor/mongodb

# cleanup
echo " -- Removing /tmp/mongodb.tgz"
rm /tmp/mongodb.tgz
{'fraction_non_alphanumeric': 0.3222565687789799, 'fraction_numerical': 0.017001545595054096, 'mean_word_length': 4.268656716417911, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 14, 'https://': 5, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2513429', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1289, 'n_words': 301}