Skip to content

Commit 9c820f8

Browse files
feat(dev): add WP-CLI testing script
Add development script to run WP-CLI commands in Docker containers with configurable WordPress and PHP versions for testing CLI functionality.
1 parent 6bbb568 commit 9c820f8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

bin/run-wpcli

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# Usage: bin/run-wpcli [WORDPRESS_VERSION] [PHP_VERSION] [COMMAND]
4+
# Example: bin/run-wpcli 67 82 "tiny optimize --attachments=123,456"
5+
# Example: bin/run-wpcli 67 82 "tiny optimize"
6+
7+
8+
CONFIG_FILE="config/wp-version.conf"
9+
WORDPRESS_VERSION_ENV="${1:-$WORDPRESS_VERSION}"
10+
PHP_VERSION_ENV="${2:-$PHP_VERSION}"
11+
12+
WORDPRESS_PORT="80${WORDPRESS_VERSION_ENV}"
13+
WP_IMAGE_KEY="${WORDPRESS_VERSION_ENV}_${PHP_VERSION_ENV}"
14+
WP_IMAGE=$(grep "^${WP_IMAGE_KEY}=" "$CONFIG_FILE" | cut -d'=' -f2)
15+
16+
COMMAND=${3:-"tiny --help"}
17+
18+
export WP_IMAGE
19+
export COMPOSE_PROJECT_NAME="tinify_${WORDPRESS_VERSION_ENV}_${PHP_VERSION_ENV}"
20+
export WORDPRESS_PORT
21+
22+
docker compose -f config/docker-compose.yml run --rm wpcli wp $COMMAND

0 commit comments

Comments
 (0)