wordpress.org/environments/plugin-directory/bin/after-start.sh
Dion Hulse bc3041fa9f Plugin Directory: Introduce a local development option for the plugin directory.
This also provides an environment in which we can run integration & unit tests in.

Merges https://github.com/WordPress/wordpress.org/pull/555


git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14720 74240141-8908-4e6f-9713-ba540dce6ec7
2026-03-16 05:00:45 +00:00

59 lines
2.9 KiB
Bash
Executable file

#!/bin/bash
#
# Runs after wp-env start. Sets up permalinks, creates pages, and imports plugins.
#
CONFIG="--config plugin-directory/.wp-env.json"
WP="npx wp-env $CONFIG run cli --"
# Install CLI tools needed by the plugin directory (svn, unzip, etc.).
# Both containers have passwordless sudo for the host user.
WPENV="npx wp-env $CONFIG run"
# wordpress container (Debian).
echo "Installing CLI tools..."
$WPENV wordpress sudo bash -c \
'command -v svn > /dev/null || (apt-get -qy update && apt-get -qy install subversion unzip zip) > /dev/null 2>&1'
# cli container (Alpine).
$WPENV cli sudo sh -c \
'command -v svn > /dev/null || apk add --no-cache -q subversion unzip zip coreutils > /dev/null 2>&1'
# Set up permalinks.
$WP wp rewrite structure '/%postname%/' --hard
# Create pages that exist on wordpress.org/plugins (if they don't already exist).
echo "Creating pages..."
# Parent: /developers/
$WP wp post create --post_type=page --post_status=publish --post_title='Developer Information' --post_name='developers' --porcelain > /dev/null 2>&1 && echo " Created page: /developers/" || true
DEVELOPERS_ID=$($WP wp post list --post_type=page --name=developers --field=ID 2>/dev/null)
if [ -n "$DEVELOPERS_ID" ]; then
# Children of /developers/
$WP wp post create --post_type=page --post_status=publish --post_title='Add your Plugin' --post_name='add' --post_parent=$DEVELOPERS_ID --porcelain > /dev/null 2>&1 && echo " Created page: /developers/add/" || true
$WP wp post create --post_type=page --post_status=publish --post_title='Readme Validator' --post_content='[readme-validator]' --post_name='readme-validator' --post_parent=$DEVELOPERS_ID --porcelain > /dev/null 2>&1 && echo " Created page: /developers/readme-validator/" || true
$WP wp post create --post_type=page --post_status=publish --post_title='Block Plugin Checker' --post_content='[block-validator]' --post_name='block-plugin-validator' --post_parent=$DEVELOPERS_ID --porcelain > /dev/null 2>&1 && echo " Created page: /developers/block-plugin-validator/" || true
$WP wp post create --post_type=page --post_status=publish --post_title='Release Management' --post_content='[release-confirmation]' --post_name='releases' --post_parent=$DEVELOPERS_ID --porcelain > /dev/null 2>&1 && echo " Created page: /developers/releases/" || true
fi
# Create stub database tables that exist outside WordPress on production.
$WP wp db import wp-content/env-bin/database-tables.sql
# Create browse section terms with proper display names.
echo "Creating browse sections..."
declare -A SECTIONS=(
[featured]="Featured"
[popular]="Popular"
[beta]="Beta"
[blocks]="Block-Enabled"
[new]="New"
[updated]="Recently Updated"
[favorites]="Favorites"
)
for SLUG in "${!SECTIONS[@]}"; do
NAME="${SECTIONS[$SLUG]}"
$WP wp term create plugin_section "$NAME" --slug="$SLUG" > /dev/null 2>&1 && echo " Created section: $NAME ($SLUG)" || true
done
# Import plugins from wordpress.org.
$WP wp eval-file wp-content/env-bin/import-plugins.php