<commit_before>#!/bin/bash
set -e

OPTIONS_DIR=/app/src/.localdev

if mkdir "$OPTIONS_DIR" 2>/dev/null; then
    cat > "$OPTIONS_DIR/help.txt" <<EOF
This directory allows you to set options by creating small files in here.
Valid option files:

- norefresh: If exists, don't keep refreshing composer/bower/npm.
- watch: If exists, use 'gulp watch' to refresh files. Might have performance concerns.
- nogulp: Rarely used, but sets up in case you want to run gulp on your own machine.
EOF
fi

composer_rerun() {
    pushd /app/src
    composer install --no-scripts
    composer install --no-autoloader
    popd
}


if [[ ! -f "$OPTIONS_DIR/norefresh" && -d /app/.git ]]; then
    # Take the git hash and the hashes of the important files.
    # If any change, re-run composer/bower.

    HASHES=$(md5sum composer.json composer.lock)
    VENDORHASHES=/app/src/vendor/.hashes
    if [[ ! -f "$VENDORHASHES" || "$(cat $VENDORHASHES)" != "$HASHES" ]]; then
        echo "Overwriting vendor folder $(du -sh vendor)"
        if [ ! -d /app/src/vendor ]; then
            mkdir /app/src/vendor
        else
            rm -rf /app/src/vendor/*
        fi
        cp -r vendor/* /app/src/vendor
        composer_rerun
        echo "$HASHES" > "$VENDORHASHES"
    else
        echo "No changes detected...skipping composer."
    fi

    HASHES=$(md5sum package.json bower.json)
    REFRESH=$(cat hashes.install || echo "bork")
    if [[ "$HASHES" != "$REFRESH" ]]; then
        bower install --allow-root
        npm install
    fi
fi

# If we get here, we got a vendor folder but no autoloads.
if [ ! -f /app/src/vendor/composer/autoload_real.php ]; then
    composer_rerun
fi

# Unfortunately, gulpfile does not work properly as a symlink.
# Copy it in when it's time to use it.
if [ -f /app/src/gulpfile.js ]; then
    rm -f gulpfile.js
    cp /app/src/gulpfile.js .
fi

if [ -f $OPTIONS_DIR/watch ]; then
    apache2-foreground &
    BROWSERSYNC_TARGET=localhost gulp watch
else
    if [ ! -f $OPTIONS_DIR/nogulp ]; then
        gulp
    fi
    apache2-foreground
fi<commit_msg>Update start.sh to create a reverse node_modules<commit_after>#!/bin/bash
set -e

OPTIONS_DIR=/app/src/.localdev

if mkdir "$OPTIONS_DIR" 2>/dev/null; then
    cat > "$OPTIONS_DIR/help.txt" <<EOF
This directory allows you to set options by creating small files in here.
Valid option files:

- norefresh: If exists, don't keep refreshing composer/bower/npm.
- watch: If exists, use 'gulp watch' to refresh files. Might have performance concerns.
- nogulp: Rarely used, but sets up in case you want to run gulp on your own machine.
EOF
fi

composer_rerun() {
    pushd /app/src
    composer install --no-scripts
    composer install --no-autoloader
    popd
}


if [[ ! -f "$OPTIONS_DIR/norefresh" && -d /app/.git ]]; then
    # Take the git hash and the hashes of the important files.
    # If any change, re-run composer/bower.

    HASHES=$(md5sum composer.json composer.lock)
    VENDORHASHES=/app/src/vendor/.hashes
    if [[ ! -f "$VENDORHASHES" || "$(cat $VENDORHASHES)" != "$HASHES" ]]; then
        echo "Overwriting vendor folder $(du -sh vendor)"
        if [ ! -d /app/src/vendor ]; then
            mkdir /app/src/vendor
        else
            rm -rf /app/src/vendor/*
        fi
        cp -r vendor/* /app/src/vendor
        composer_rerun
        echo "$HASHES" > "$VENDORHASHES"
    else
        echo "No changes detected...skipping composer."
    fi

    HASHES=$(md5sum package.json bower.json)
    REFRESH=$(cat hashes.install || echo "bork")
    if [[ "$HASHES" != "$REFRESH" ]]; then
        bower install --allow-root
        npm install
    fi
fi

# If we get here, we got a vendor folder but no autoloads.
if [ ! -f /app/src/vendor/composer/autoload_real.php ]; then
    composer_rerun
fi

# It seems like webpack resolves via the symlink and then can't find node_modules.
# We can simply symlink them in reverse. (this works on windows!)
if [ ! -d /app/src/node_modules ]; then
    echo "!! Making node_modules symlink"
    ln -s $PWD/node_modules /app/src/node_modules
fi

# Unfortunately, gulpfile does not work properly as a symlink.
# Copy it in when it's time to use it.
if [ -f /app/src/gulpfile.js ]; then
    rm -f gulpfile.js
    cp /app/src/gulpfile.js .
fi

if [ -f $OPTIONS_DIR/watch ]; then
    apache2-foreground &
    BROWSERSYNC_TARGET=localhost gulp watch
else
    if [ ! -f $OPTIONS_DIR/nogulp ]; then
        gulp
    fi
    apache2-foreground
fi
{'fraction_non_alphanumeric': 0.11541909457642313, 'fraction_numerical': 0.0022411474675033617, 'mean_word_length': 2.5962933118452862, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '5490432', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1517, 'n_words': 490}