Skip to content

Commit 0a0ac9d

Browse files
committed
wp
1 parent b6b20e1 commit 0a0ac9d

File tree

98 files changed

+19825
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+19825
-415
lines changed

.env

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PHP_IMAGE=dralec/php-cli-alpine
2+
PHP_DEBUG_IMAGE=dralec/php-cli-alpine-debug

bin/colors.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
# COLORS
4+
#Black 0;30 Dark Gray 1;30
5+
#Red 0;31 Light Red 1;31
6+
#Green 0;32 Light Green 1;32
7+
#Brown/Orange 0;33 Yellow 1;33
8+
#Blue 0;34 Light Blue 1;34
9+
#Purple 0;35 Light Purple 1;35
10+
#Cyan 0;36 Light Cyan 1;36
11+
#Light Gray 0;37 White 1;37
12+
13+
LIGHT_GRAY='\033[0;37m'
14+
DARK_GRAY='\033[0;30m'
15+
YELLOW='\033[0;33m'
16+
GREEN='\033[0;32m'
17+
RED='\033[0;31m'
18+
NC='\033[0m'

bin/functions.sh

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
3+
header () {
4+
printf "${LIGHT_GRAY}${1}${NC}\n"
5+
}
6+
7+
info () {
8+
printf "\n${GREEN}${1}${NC}\n\n"
9+
}
10+
11+
error () {
12+
printf "\n${RED}${1}${NC}\n\n"
13+
}
14+
15+
comment () {
16+
printf "\n${YELLOW}${1}${NC}\n\n"
17+
}
18+
19+
no-exec () {
20+
comment "No-Exec..."
21+
}
22+
23+
enabled () {
24+
echo " enabled."
25+
}
26+
disabled () {
27+
echo " disabled."
28+
}
29+
30+
help_message () {
31+
if [[ ${HELP} == 1 ]]
32+
then
33+
echo "Options:"
34+
echo " --help - show this message"
35+
[[ $OPTION_NO_RESTART ]] && echo " --no-restart - do not restart container(may cause 'No coverage driver')"
36+
[[ $OPTION_ANALYZE ]] && echo " --analyze - enable analysis"
37+
[[ $OPTION_COVERAGE ]] && echo " --coverage - enable code coverage"
38+
[[ $OPTION_ALL ]] && echo " --all - enable analysis and code coverage"
39+
[[ $OPTION_BEAUTY ]] && echo " --beautify - enable code beautifier"
40+
[[ $OPTION_BEAUTY ]] && echo " --beauty - same as above"
41+
[[ $OPTION_PROPAGATE ]] && echo " --propagate - propagate unrecognized options to underlying script"
42+
if [[ ${PROPAGATE} == 0 ]]
43+
then
44+
exit 0
45+
fi
46+
fi
47+
}
48+
49+
options_enabled () {
50+
printf "Analysis"
51+
if [[ ${ANALYZE} == 1 ]]
52+
then
53+
enabled
54+
else
55+
disabled
56+
fi
57+
printf "Coverage"
58+
if [[ ${COVERAGE} == 1 ]]
59+
then
60+
enabled
61+
else
62+
disabled
63+
fi
64+
printf "Beautifier"
65+
if [[ ${BEAUTY} == 1 ]]
66+
then
67+
enabled
68+
else
69+
disabled
70+
fi
71+
printf "Container restart"
72+
if [[ ${RESTART_CONTAINER} == 1 ]]
73+
then
74+
enabled
75+
else
76+
disabled
77+
fi
78+
79+
}
80+

bin/imports.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
script_dir="$(dirname "$0")"
3+
if [[ ${script_dir} != './bin' ]]
4+
then
5+
cd ${script_dir}
6+
fi
7+
8+
. colors.sh "$@"
9+
. settings.sh "$@"
10+
. functions.sh "$@"

bin/phpcbf

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
script_dir="$(dirname "$0")"
3+
cd ${script_dir}
4+
5+
. imports.sh
6+
7+
OPTION_PROPAGATE=1
8+
9+
help_message
10+
11+
info "PHP Code Sniffer Beautifier..."
12+
if [[ ${EXEC} == 1 ]]
13+
then
14+
if [[ ${BEAUTY} == 1 ]]
15+
then
16+
if [[ -z "$@" ]]
17+
then
18+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app phpcbf
19+
else
20+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app phpcbf "$@"
21+
fi
22+
else
23+
comment "use --beautify option to run"
24+
fi
25+
else
26+
no-exec
27+
fi

bin/phpcs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
script_dir="$(dirname "$0")"
3+
cd ${script_dir}
4+
5+
. imports.sh
6+
7+
OPTION_PROPAGATE=1
8+
9+
help_message
10+
11+
info "PHP Code Sniffer..."
12+
if [[ ${EXEC} == 1 ]]
13+
then
14+
if [[ -z "$@" ]]
15+
then
16+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app phpcs
17+
else
18+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app phpcs "$@"
19+
fi
20+
else
21+
no-exec
22+
fi

bin/phpmetrics

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
script_dir="$(dirname "$0")"
4+
cd ${script_dir}
5+
6+
. imports.sh
7+
8+
OPTION_PROPAGATE=1
9+
10+
help_message
11+
12+
13+
info "PhpMetrics..."
14+
if [[ ${EXEC} == 1 ]]
15+
then
16+
if [[ -z "$@" ]]
17+
then
18+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app phpmetrics --report-html="${PHPMETRICS_OUTPUT_DIR}" .
19+
else
20+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app phpmetrics "$@"
21+
fi
22+
else
23+
no-exec
24+
fi
25+

bin/phpstan

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
script_dir="$(dirname "$0")"
3+
cd ${script_dir}
4+
5+
. imports.sh
6+
7+
OPTION_PROPAGATE=1
8+
9+
help_message
10+
11+
12+
info "PHPStan..."
13+
if [[ ${EXEC} == 1 ]]
14+
then
15+
if [[ -z "$@" ]]
16+
then
17+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app phpstan analyze ${SOURCE_DIR} --level=${PHPSTAN_LEVEL}
18+
else
19+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app phpstan "$@"
20+
fi
21+
else
22+
no-exec
23+
fi

bin/phpunit

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
script_dir="$(dirname "$0")"
3+
cd ${script_dir}
4+
5+
. imports.sh
6+
7+
OPTION_PROPAGATE=1
8+
9+
help_message
10+
11+
info "PhpUnit..."
12+
if [[ ${EXEC} == 1 ]]
13+
then
14+
if [[ ${COVERAGE} == 1 ]]
15+
then
16+
comment "Running tests with coverage..."
17+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app phpunit --coverage-html ${PHPUNIT_COVERAGE_HTML_REPORT} --coverage-text \
18+
--coverage-clover ${PHPUNIT_COVERAGE_CLOVER_REPORT}
19+
else
20+
if [[ -z "$@" ]]
21+
then
22+
comment "Running tests..."
23+
fi
24+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app phpunit "$@"
25+
fi
26+
else
27+
no-exec
28+
fi
29+
30+

bin/psalm

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
script_dir="$(dirname "$0")"
3+
cd ${script_dir}
4+
5+
. imports.sh
6+
7+
OPTION_PROPAGATE=1
8+
9+
help_message
10+
11+
12+
if [[ -e ${PSALM_CONFIG} ]]
13+
then
14+
comment "Psalm config found..."
15+
else
16+
comment "Creating psalm config..."
17+
if [[ ${EXEC} == 1 ]]
18+
then
19+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app psalm --init ${SOURCE_DIR} ${PSALM_LEVEL}
20+
else
21+
no-exec
22+
fi
23+
fi
24+
25+
info "Psalm..."
26+
if [[ ${EXEC} == 1 ]]
27+
then
28+
if [[ -z "$@" ]]
29+
then
30+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app psalm
31+
else
32+
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app psalm "$@"
33+
fi
34+
else
35+
no-exec
36+
fi
37+

bin/restart-container.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
script_dir="$(dirname "$0")"
3+
cd ${script_dir}
4+
5+
. imports.sh
6+
7+
comment "Restarting container..."
8+
if [[ ${EXEC} == 0 ]]
9+
then
10+
no-exec
11+
else
12+
docker-compose down && docker-compose -f ${DOCKER_COMPOSE_FILE} up -d
13+
fi
14+

bin/settings.sh

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env bash
2+
COVERAGE=0
3+
PROPAGATE=0
4+
ANALYZE=0
5+
BEAUTY=0
6+
EXEC=1
7+
HELP=0
8+
RESTART_CONTAINER=1
9+
10+
#echo "$@" # for debug
11+
for arg
12+
do
13+
case "$arg" in
14+
--propagate)
15+
PROPAGATE=1
16+
;;
17+
esac
18+
done
19+
20+
for arg
21+
do
22+
case "$arg" in
23+
--help)
24+
HELP=1
25+
if [[ ${PROPAGATE} == 1 ]]
26+
then
27+
params+=("$arg")
28+
fi
29+
;;
30+
--no-exec)
31+
EXEC=0
32+
;;
33+
--no-restart)
34+
RESTART_CONTAINER=0
35+
;;
36+
--analyze)
37+
ANALYZE=1
38+
;;
39+
--coverage)
40+
COVERAGE=1
41+
;;
42+
--propagate)
43+
PROPAGATE=1
44+
;;
45+
--beauty)
46+
BEAUTY=1
47+
;;
48+
--beautify)
49+
BEAUTY=1
50+
;;
51+
--all)
52+
ANALYZE=1
53+
COVERAGE=1
54+
BEAUTY=1
55+
;;
56+
*)
57+
if [[ ${PROPAGATE} == 1 ]]
58+
then
59+
params+=("$arg")
60+
else
61+
echo "settings.sh: Unknown argument/option ${arg}"
62+
exit 0
63+
fi
64+
;;
65+
esac
66+
done
67+
set -- "${params[@]}" # overwrites the original positional params
68+
#echo "$@" # for debug
69+
70+
SOURCE_DIR="src"
71+
PHPSTAN_LEVEL=7
72+
PSALM_CONFIG="./../psalm.xml"
73+
PSALM_LEVEL=3
74+
PHPMETRICS_OUTPUT_DIR="./tests/phpmetrics"
75+
PHPUNIT_COVERAGE_HTML_REPORT="./tests/coverage/html"
76+
PHPUNIT_COVERAGE_CLOVER_REPORT="./tests/coverage/clover.xml"
77+
78+
if [[ ${COVERAGE} == 1 ]]
79+
then
80+
DOCKER_COMPOSE_FILE="./../docker-compose-xdebug.yml"
81+
else
82+
DOCKER_COMPOSE_FILE="./../docker-compose.yml"
83+
fi
84+

0 commit comments

Comments
 (0)