Skip to content

Instantly share code, notes, and snippets.

@scribu
Created December 24, 2013 01:05
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save scribu/8107318 to your computer and use it in GitHub Desktop.
Save scribu/8107318 to your computer and use it in GitHub Desktop.
Set up the package index for WP-CLI
#!/usr/bin/env bash
if [ -z "$INSTALL_DIR" ]; then
INSTALL_DIR=$HOME/.wp-cli
fi
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR"
if [ ! -x composer.phar ]; then
echo "Installing Composer in $INSTALL_DIR"
echo "-------------------"
curl -sS https://getcomposer.org/installer | $WP_CLI_PHP
if [ $? -gt 0 ]; then
exit 1
fi
fi
if [ ! -f composer.json ]; then
echo "Creating composer.json file in $INSTALL_DIR"
$COMPOSER init --stability dev --no-interaction
$COMPOSER config bin-dir bin
$COMPOSER config vendor-dir vendor
fi
echo "Ensuring the package index is available in composer.json"
$COMPOSER config repositories.wp-cli composer http://wp-cli.org/package-index/
if [ ! -f config.yml ]; then
echo "Creating config.yml file in $INSTALL_DIR"
echo "require:\n - vendor/autoload.php" > config.yml
else
echo "WARNING: Make sure you have vendor/autoload.php inside config.yml"
fi
echo "Setup completed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment