<commit_before>#!/bin/bash

WHITE='\033[0;37m'
CYAN='\033[0;36m'
CLEAR='\033[0m'

function title ()
{
    printf "\n\n${WHITE}$1${CLEAR}\n------------------------------------------------------------\n"
}

function appendToJson()
{
    # Delete last two lines }
    sed -i '' -e '$ d' $1 
    sed -i '' -e '$ d' $1 

    # Append closing brace, but with a closing comma
    echo "    }," >> $1

    # Append provided content
    echo "    $2" >> $1
    
    # Append }
    echo "}" >> $1
}

printf "${CYAN}\n"
read -p "This script is meant to be run in directory of a brand-new Laravel app. Cool? " -n 1 -r
printf "${CLEAR}\n"
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
    printf "\nOK, quitting.\n"
    exit 1
fi

printf "${CYAN}\n"
read -p "Will this app be public on GitHub? " -n 1 -r
printf "${CLEAR}\n"
PUBLIC=$REPLY

title "Removing files..."
rm -f .styleci.yml
rm -f docker-compose.yml

title "Adding Composer dependencies..."
composer require tightenco/tlint
composer require squizlabs/php_codesniffer friendsofphp/php-cs-fixer barryvdh/laravel-debugbar --dev

title "Adding files to .gitignore..."
echo ".php_cs.cache" >> .gitignore

title "Downloading dotfiles from GitHub..."
wget -O .php_cs.xml.dist https://raw.githubusercontent.com/tighten/configs/main/.phpcs.xml.dist
wget -O .php_cs.dist https://raw.githubusercontent.com/tighten/configs/main/.php_cs.dist
wget -O .stylelintrc https://raw.githubusercontent.com/tighten/configs/main/.stylelintrc
wget -O README.md https://raw.githubusercontent.com/tighten/configs/main/templates/app-README.md

title "Moving branch to main if needed..."
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$BRANCH" == "master" ]]; then
    git checkout -b main
    git branch -d master
fi

title 'Appending Prettier config to package.json...'
read -d '' prettier << EOF
    "prettier": {
        "singleQuote": true,
        "trailingComma": "es5",<commit_msg>Move tlint to dev dependencies<commit_after>#!/bin/bash

WHITE='\033[0;37m'
CYAN='\033[0;36m'
CLEAR='\033[0m'

function title ()
{
    printf "\n\n${WHITE}$1${CLEAR}\n------------------------------------------------------------\n"
}

function appendToJson()
{
    # Delete last two lines }
    sed -i '' -e '$ d' $1 
    sed -i '' -e '$ d' $1 

    # Append closing brace, but with a closing comma
    echo "    }," >> $1

    # Append provided content
    echo "    $2" >> $1
    
    # Append }
    echo "}" >> $1
}

printf "${CYAN}\n"
read -p "This script is meant to be run in directory of a brand-new Laravel app. Cool? " -n 1 -r
printf "${CLEAR}\n"
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
    printf "\nOK, quitting.\n"
    exit 1
fi

printf "${CYAN}\n"
read -p "Will this app be public on GitHub? " -n 1 -r
printf "${CLEAR}\n"
PUBLIC=$REPLY

title "Removing files..."
rm -f .styleci.yml
rm -f docker-compose.yml

title "Adding Composer dependencies..."
composer require tightenco/tlint squizlabs/php_codesniffer friendsofphp/php-cs-fixer barryvdh/laravel-debugbar --dev

title "Adding files to .gitignore..."
echo ".php_cs.cache" >> .gitignore

title "Downloading dotfiles from GitHub..."
wget -O .php_cs.xml.dist https://raw.githubusercontent.com/tighten/configs/main/.phpcs.xml.dist
wget -O .php_cs.dist https://raw.githubusercontent.com/tighten/configs/main/.php_cs.dist
wget -O .stylelintrc https://raw.githubusercontent.com/tighten/configs/main/.stylelintrc
wget -O README.md https://raw.githubusercontent.com/tighten/configs/main/templates/app-README.md

title "Moving branch to main if needed..."
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$BRANCH" == "master" ]]; then
    git checkout -b main
    git branch -d master
fi

title 'Appending Prettier config to package.json...'
read -d '' prettier << EOF
    "prettier": {
        "singleQuote": true,
        "trailingComma": "es5",
{'fraction_non_alphanumeric': 0.18786279683377308, 'fraction_numerical': 0.01424802110817942, 'mean_word_length': 2.7423494570582427, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6249906', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1345, 'n_words': 369}