This commit is contained in:
Alex P 2022-05-05 15:50:21 +03:00
parent 00cfa973e6
commit df6e784d29
14 changed files with 369 additions and 0 deletions

42
.ddev/commands/web/orchestrate Executable file
View file

@ -0,0 +1,42 @@
#!/bin/bash
set -x
## Description: Set up the development environment
## Usage: orchestrate
## Example: "ddev orchestrate"
mkdir -p "${DDEV_DOCROOT}"
pushd "${DDEV_DOCROOT}"
PLUGIN_FOLDER="${DDEV_DOCROOT}/wp-content/plugins/${PLUGIN_NAME:-$DDEV_PROJECT}"
VALID_ARGS=$(getopt -o fp: --long force,plugin: -- "$@")
if [[ $? -ne 0 ]]; then
exit 1;
fi
eval set -- "$VALID_ARGS"
while [ : ]; do
case "$1" in
-f | --force)
echo "Removing WordPress installation"
shift
export RECREATE_ENV=1;
popd
find "${DDEV_DOCROOT}" -mindepth 1 ! -regex "^${PLUGIN_FOLDER}\(/.*\)?" -delete
pushd "${DDEV_DOCROOT}"
;;
-p | --plugin)
echo "Processing 'plugin' option. Input argument is '$2'"
shift 2
;;
--) shift;
break
;;
esac
done
# Execute all fragments from orchestrate.d
if [ -d "${0}.d" ]; then
for FN in ${0}.d/*.sh ; do
echo $FN
source "${FN}"
done
fi

View file

@ -0,0 +1,6 @@
#!/bin/bash
if ! wp core download; then
echo 'WordPress is already installed.'
exit
fi

View file

@ -0,0 +1,6 @@
#!/bin/bash
cat << 'EOF' > ".gitignore"
# ignores everything in the docroot (docroot in config.yaml), this path may not be included in the standard .ddev/.gitignore.
*
EOF

View file

@ -0,0 +1,22 @@
#!/bin/bash
# Create wp-config.php
# the PHP snippet avoids some notices during CLI calls
# https://make.wordpress.org/cli/handbook/guides/common-issues/#php-notice-undefined-index-on-_server-superglobal
printf '
if ( defined( "WP_CLI" ) && WP_CLI && ! isset( $_SERVER["HTTP_HOST"] ) ) {
$_SERVER["HTTP_HOST"] = "%s";
}
' "${DDEV_HOSTNAME}" | wp config create \
--dbname=db \
--dbuser=db \
--dbpass=db \
--dbhost=db \
--force \
--extra-php
wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_DISPLAY true --raw
wp config set WP_DEBUG_LOG true --raw
wp config set WP_SITEURL '(isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] ? "https://" : "http://") . $_SERVER["HTTP_HOST"]' --raw
wp config set WP_HOME '(isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] ? "https://" : "http://") . $_SERVER["HTTP_HOST"]' --raw

View file

@ -0,0 +1,15 @@
#!/bin/bash
if [ ! -z "${RECREATE_ENV}" ]; then
echo "Deleting database before creating a new one"
wp db clean --yes
fi
wp core install \
--title="${WP_TITLE}" \
--admin_user="${ADMIN_USER}" \
--admin_password="${ADMIN_PASS}" \
--url="${DDEV_PRIMARY_URL}" \
--admin_email="${ADMIN_EMAIL}" \
--skip-email

View file

@ -0,0 +1,4 @@
#!/bin/bash
wp plugin is-installed akismet && wp plugin uninstall akismet
wp plugin is-installed hello && wp plugin uninstall hello

View file

@ -0,0 +1,6 @@
#!/bin/bash
popd
composer install
yarn run build:dev

View file

@ -0,0 +1,5 @@
#!/bin/bash
pushd "${DDEV_DOCROOT}"
wp plugin activate "${PLUGIN_NAME:-$DDEV_PROJECT}"

View file

@ -0,0 +1,3 @@
#!/bin/bash
wp plugin install woocommerce --version="${WC_VERSION}" --activate

View file

@ -0,0 +1,9 @@
#!/bin/bash
# Needed for generating the .htaccess file
echo "apache_modules:
- mod_rewrite
" > wp-cli.yml
wp rewrite structure '/%postname%'
wp rewrite flush --hard

View file

@ -0,0 +1,3 @@
#!/bin/bash
wp theme install storefront --activate