-
Notifications
You must be signed in to change notification settings - Fork 2
/
dev
executable file
·77 lines (64 loc) · 2.19 KB
/
dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
# Reset
Reset="\033[0m"; # Text Reset
# Regular Colors
Black="\033[0;30m"; # Black
Red="\033[0;31m"; # Red
Green="\033[0;32m"; # Green
Yellow="\033[0;33m"; # Yellow
Blue="\033[0;34m"; # Blue
Purple="\033[0;35m"; # Purple
Cyan="\033[0;36m"; # Cyan
White="\033[0;37m"; # White
cmd=${1};
allArgs=${@};
allArgsExceptFirst=${@:2};
secondArg=${2};
valid=false;
# If no command provided, list commands
if [[ -z "${cmd}" ]]; then
valid=true;
printf "${Green}The following commands are available:\n${Yellow}";
printf " ./dev up\n";
printf " ./dev down\n";
printf " ./dev test\n";
printf " ./dev phpstan [args]\n";
printf " ./dev phpunit [args]\n";
printf " ./dev craft [args]\n";
printf " ./dev composer [args]\n";
printf " ./dev login [args]${Reset}\n";
fi
if [[ "${cmd}" = "up" ]]; then
valid=true;
docker-compose -f docker-compose.yml -p craft-static up -d;
docker exec -it --user root --workdir /app php-craft-static bash -c "cd /app && composer install";
fi
if [[ "${cmd}" = "down" ]]; then
valid=true;
docker-compose -f docker-compose.yml -p craft-static down;
fi
if [[ "${cmd}" = "phpstan" ]] || [[ "${cmd}" = "test" ]]; then
valid=true;
docker exec -it --user root --workdir /app php-craft-static bash -c "chmod +x /app/vendor/bin/phpstan && /app/vendor/bin/phpstan analyse src ${allArgsExceptFirst}"
fi
if [[ "${cmd}" = "phpunit" ]] || [[ "${cmd}" = "test" ]]; then
valid=true;
docker exec -it --user root --workdir /app php-craft-static bash -c "chmod +x /app/vendor/bin/phpunit && /app/vendor/bin/phpunit --configuration /app/phpunit.xml ${allArgsExceptFirst}"
fi
if [[ "${cmd}" = "craft" ]]; then
valid=true;
docker exec -it --user root --workdir /app/testenvironment/public php-craft-static bash -c "php index.php ${allArgsExceptFirst}";
fi
if [[ "${cmd}" = "composer" ]]; then
valid=true;
docker exec -it --user root --workdir /app php-craft-static bash -c "${allArgs}";
fi
if [[ "${cmd}" = "login" ]]; then
valid=true;
docker exec -it --user root ${secondArg}-craft-static bash;
fi
if [[ "${valid}" != "true" ]]; then
printf "${Red}Specified command not found${Reset}\n";
exit 1;
fi
exit 0;