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

if [ $# -lt 1 ]; then
    echo "usage: $0 <slug> [replace-text-domain] [dev-url]"
    exit 1
fi

DEFAULT_SLUG="sage"
DEFAULT_PUBLIC_PATH="/app/themes/sage"
DEFAULT_DEV_URL="example.dev"

SLUG=$1
REPLACE_TEXT_DOMAIN=${2-false}
DEV_URL=${3-${SLUG}.wordpress.dev}
PUBLIC_PATH="/wp-content/themes/${SLUG}"

# portable in-place argument for both GNU sed and Mac OSX sed
if [[ $(uname -s) == 'Darwin' ]]; then
    ioption=('-i' '')
else
    ioption=('-i')
fi

# !!! WARNING !!! #
# SLUG is not sanitized! if it contains control characters
# passed to sed this script will exploded spectacularly.
# Check your input first if there are errors

echo "Updating public path..."
FILE="./resources/assets/config-local.json"
cat > $FILE <<EOF
{
  "publicPath": "${PUBLIC_PATH}",
  "devUrl": "http://${DEV_URL}"
}
EOF

if [ ${REPLACE_TEXT_DOMAIN} = "true" ]; then
    echo "Searching for files containing ${DEFAULT_SLUG}..."
    pattern="s/'${DEFAULT_SLUG}'/'${SLUG}'/g"
    git grep -lw "'${DEFAULT_SLUG}'" -- './*.php' ':!/app/lib/' | xargs sed "${ioption[@]}" $pattern

    echo "Updating style.css header..."
    sed "${ioption[@]}" -e "s/\s$DEFAULT_SLUG/ $SLUG/g" ./resources/style.css
fi
<commit_msg>Remove the ability to replace the themes text domain<commit_after>#!/usr/bin/env bash

if [ $# -lt 1 ]; then
    echo "usage: $0 <slug> [replace-text-domain] [dev-url]"
    exit 1
fi

SLUG=$1
REPLACE_TEXT_DOMAIN=${2-false}
DEV_URL=${3-${SLUG}.wordpress.dev}
FILE="./resources/assets/config-local.json"

echo "Creating config-local.json..."
cat > $FILE <<EOF
{
  "publicPath": "/wp-content/themes/${SLUG}",
  "devUrl": "http://${DEV_URL}"
}
EOF
{'fraction_non_alphanumeric': 0.19880239520958085, 'fraction_numerical': 0.00718562874251497, 'mean_word_length': 4.002994011976048, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7353607', 'n_tokens_mistral': 643, 'n_tokens_neox': 620, 'n_words': 151}