Skip to content

Commit 5847f6f

Browse files
committed
Make some final adjustments based on testing.
1 parent b1648b0 commit 5847f6f

File tree

5 files changed

+60
-17
lines changed

5 files changed

+60
-17
lines changed

codesniffer-run

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ Usage:
1818
n - Suppress warnings during the sniff run.
1919
x - Always exit zero regardless of sniff results.
2020
21+
Environment:
22+
CODESNIFFER_RUN_STANDARD - If set, overrides the name of the Coding
23+
Standard to use. The standard is assumed
24+
to be "installed" already.
25+
(Default: Loadsys)
26+
2127
EOT
2228

2329
exit ${1:-0} # Exit with code 0 unless an arg is passed to the method.
@@ -32,7 +38,8 @@ REPORT_DIR="${TMP_DIR}/code-sniffs"
3238
FULL_REPORT_FILE="${REPORT_DIR}/report-full.txt"
3339
SUMMARY_REPORT_FILE="${REPORT_DIR}/report-summary.txt"
3440

35-
CODE_STANDARD="vendor/cakephp/cakephp-codesniffer/CakePHP,vendor/loadsys/loadsys_codesniffer/Loadsys"
41+
CODE_STANDARD=${CODESNIFFER_RUN_STANDARD:-Loadsys}
42+
CODE_STANDARDS=("vendor/cakephp/cakephp-codesniffer" "vendor/loadsys/loadsys_codesniffer")
3643
SNIFF_FOLDERS=("./src" "./plugins" "./tests" "./config" "./webroot")
3744
SNIFF_FAIL_CAUSES_SCRIPT_FAIL=0 # 0 = true. Script will exit with phpcs's return code.
3845

@@ -66,7 +73,27 @@ while getopts ":fhnx" opt; do
6673
done
6774

6875

76+
# Make sure phpcs has the sniffs configured.
77+
INSTALLED_ALREADY=$( bin/phpcs --config-show | grep installed_paths )
78+
INSTALLED_ALREADY=${INSTALLED_ALREADY#installed_paths: }
79+
#echo "old = $INSTALLED_ALREADY"
80+
81+
for STANDARD in "${CODE_STANDARDS[@]}"; do
82+
if [[ ! $INSTALLED_ALREADY == *"$STANDARD"* ]]; then
83+
TO_INSTALL="${TO_INSTALL-},${STANDARD}"
84+
fi
85+
done
86+
87+
TO_INSTALL=${TO_INSTALL#,}
88+
#echo "new = $TO_INSTALL"
89+
if [ -n "$TO_INSTALL" ] && [ "$TO_INSTALL" != "$INSTALLED_ALREADY" ]; then
90+
echo "## Adding required coding standards installed paths."
91+
bin/phpcs --config-set installed_paths $TO_INSTALL > /dev/null
92+
fi
93+
94+
6995
# Run the sniffs.
96+
echo "## Executing code sniffer:"
7097
bin/phpcs -ps $SUPPRESS_WARNINGS \
7198
--extensions=php \
7299
--standard="$CODE_STANDARD" \

coverage-report

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ fi
2727
COVERAGE_PATH="tmp/coverage/html"
2828

2929

30-
# Launch the coverage in a browser if requested and we're on the host.
31-
if command -v 'open' >/dev/null 2>&1; then
30+
# Launch the coverage in a browser if we're on the host.
31+
if command -v 'open' >/dev/null 2>&1 && command -v 'vagrant' >/dev/null 2>&1; then
3232
bin/vagrant-exec "bin/phpunit --coverage-html="$COVERAGE_PATH""
3333
open "${COVERAGE_PATH}/index.html"
3434
else

db-login

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ eval $( bin/db-credentials )
3939
if [ -n "${DB_PORT}" ]; then
4040
PORT_CLAUSE="--port=${DB_PORT}"
4141
else
42-
PORT_CLAUSE=""
43-
fi
4442

4543
# Define the primary command line.
46-
CMD="mysql --host=${DB_HOST} ${PORT_CLAUSE} --database=${DB_DATABASE} --user=${DB_USERNAME}"
44+
CMD="mysql --host=${DB_HOST} ${PORT_CLAUSE-} --database=${DB_DATABASE} --user=${DB_USERNAME}"
4745

4846
# Handle all the different ways to provide (or not provide) a password.
4947
if [[ $DB_PASSWORD =~ " |'" ]]; then

db-sample-data

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,35 @@ WEBROOT_PATH="webroot/"
4343

4444
# Internal var setup.
4545
eval $( bin/db-credentials ) # Yuck, but nothing else works!
46-
DATE=$(date +%Y-%m-%d)
4746
OPTIONS="--skip-add-drop-table --no-create-info"
48-
TMP_PATH="tmp/"
49-
DESTINATION_NAME="${DB_NAME}_sample_data_${DATE}"
50-
51-
# Generate the dump, compress it and move it into place.
52-
cd "${TMP_PATH}"
53-
mysqldump --host="${DB_HOST}" --user="${DB_USER}" -p${DB_PASS} ${OPTIONS} ${DB_NAME} $TABLES > "${DESTINATION_NAME}.sql"
54-
zip -rq9 "${WEBROOT_PATH}${DESTINATION_NAME}.zip" "${DESTINATION_NAME}.sql"
55-
rm -f "${DESTINATION_NAME}.sql"
47+
TMP_PATH="tmp"
48+
DESTINATION_NAME="${DB_DATABASE}_sample_data_$(date +%Y-%m-%d)"
49+
50+
51+
# Generate the dump command.
52+
if [ -n "$DB_PORT" ]; then
53+
PORT_CLAUSE="--port=$DB_PORT"
54+
fi
55+
CMD="mysqldump --host=${DB_HOST} ${PORT_CLAUSE} --user=${DB_USERNAME} ${OPTIONS} ${DB_DATABASE} $TABLES"
56+
57+
58+
# Run the dump command.
59+
# Handle all the different ways to provide (or not provide) a password.
60+
pushd "${TMP_PATH}" >/dev/null
61+
if [[ $DB_PASSWORD =~ " |'" ]]; then
62+
$CMD -p"${DB_PASSWORD}" > "${DESTINATION_NAME}.sql"
63+
elif [ -n "${DB_PASSWORD}" ]; then
64+
$CMD -p$DB_PASSWORD > "${DESTINATION_NAME}.sql"
65+
else
66+
$CMD > "${DESTINATION_NAME}.sql"
67+
fi
68+
popd >/dev/null
69+
70+
71+
# Zip the file and remove the original .sql.
72+
zip -rq9 "${WEBROOT_PATH}${DESTINATION_NAME}.zip" "${TMP_PATH}/${DESTINATION_NAME}.sql"
73+
rm -f "${TMP_PATH}/${DESTINATION_NAME}.sql"
74+
5675

5776
# Prompt to download the file, then delete it.
5877
echo "## Download URL: ${PUBLIC_URL}/${DESTINATION_NAME}.zip"

migrations

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ if [ "$1" = '-h' ]; then
2222
fi
2323

2424
bin/cache-clear
25-
bin/cake Migrations.migration migrate
26-
bin/cache-clear
25+
bin/cake migrations migrate

0 commit comments

Comments
 (0)