generated from Monogramm/wp-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
manage.sh
executable file
·124 lines (103 loc) · 3.52 KB
/
manage.sh
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
set -e
. .env
###########################################################
# Functions
log() {
echo "[${0}] [$(date +%Y-%m-%dT%H:%M:%S)] $*"
}
prepare_release() {
NEW_VERSION=${1}
if [ -z "${NEW_VERSION}" ] ; then
log 'Missing release version!'
return 1;
fi
log 'TODO Updating app version...'
sed -i \
-e "s|\"version\": \".*\"|\"version\": \"${NEW_VERSION}\"|g" \
./.gitmoji-changelogrc
log 'Updating plugin version...'
sed -i \
-e "s|version = '.*'|version = '${NEW_VERSION}'|g" \
./includes/"class-${WP_PLUGIN}.php"
sed -i \
-e "s|Version: .*|Version: ${NEW_VERSION}|g" \
-e "s| __FILE__, '.*' | __FILE__, '${NEW_VERSION}' |g" \
./"${WP_PLUGIN}.php"
# Generate Changelog for version
log "Generating Changelog for version '${NEW_VERSION}'..."
npm install
npm run gitmoji-changelog
# TODO Add and commit to git with message `:bookmark: Release X.Y.Z`
./bin/generate-plugin-zip.sh "${WP_PLUGIN}"
}
usage() {
echo "usage: ./manage.sh COMMAND [ARGUMENTS]
Commands:
local-install Install local env for WP tests and lint
local-test Execute tests in local env
local-lint Execute lint in local env
local-i18n Update i18n locales
local-clean Minify and clean source code
local-prep-release Prepare app release
start Start dev / test env (docker)
stop Stop dev / test env
test Start test env and verify plugin install correctly
logs Follow logs of dev / test env
reset Reset all data of dev / test env
sut Execute commands in test container
phpcbf Execute PHP Code Beautifier and Fixer in test container
wp Execute WP-CLI in WordPress container
"
}
###########################################################
# Runtime
case "${1}" in
# Local env
local-install)
composer install
npm install
./bin/install-wp-tests.sh "${@:2}";;
local-test)
./vendor/bin/phpunit
WP_MULTISITE=1 ./vendor/bin/phpunit;;
local-lint)
./vendor/bin/phpcs --warning-severity=0
npx eslint .;;
local-i18n) npm run i18n;;
local-clean)
npm run start
./vendor/bin/phpcbf;;
local-prep-release)
npm run start
prepare_release "${@:2}";;
# DEV env
start) docker-compose up -d "${@:2}";;
stop) docker-compose down "${@:2}";;
test) set -e
docker-compose build
docker-compose down -v
docker-compose up -d
docker-compose ps
docker-compose logs -f sut
docker-compose ps
docker-compose logs wordpress
docker-compose ps sut | grep -q 'Exit 0'
docker-compose exec -T --user www-data wordpress wp core install --url="http://localhost" --title="WordPress-CI" --admin_user=admin --admin_password=password [email protected]
docker-compose exec -T --user www-data wordpress wp plugin activate wp-plugin-advanced-leaflet
docker-compose down -v
set +e;;
logs) docker-compose logs -f "${@:2}";;
reset) docker-compose down -v;;
sut) docker-compose run -T sut "${@:2}";;
phpcbf) docker-compose run -T sut ./vendor/bin/phpcbf;;
wp) docker-compose exec -T --user www-data wordpress wp "${@:2}";;
i18n) npm install
npm run i18n;;
build) build;;
prepare-release) build
prepare_release "${@:2}";;
# Help
*) usage;;
esac
exit 0