Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

# Composer runs on the runner, not in a container, so the plugin installs
# in install-ssp get the PHP extensions above, npm and a git checkout the
# runner owns
# in scripts/local-deps.sh get the PHP extensions above and a git checkout
# the runner owns. The script skips npm in CI.
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@
"php -r \"copy('.env.example', '.env');\""
],
"post-install-cmd": [
"@install-ssp",
"@local-deps:install",
"if [ ! -e .env ]; then cp .env.dist .env; fi",
"if [ ! -e wp-cli.yml ]; then cp wp-cli.yml.dist wp-cli.yml; fi"
],
"post-update-cmd": [
"@update-ssp"
"@local-deps:update"
],
"install-ssp": "cd web/app/plugins/cbf-multisite && composer install && cd ../cbf-slides-importer && composer install && cd ../cbf-semantic-glossary && composer install && cd ../cbf-semantic-glossary-learndash && composer install && cd ../../../..",
"update-ssp": "cd web/app/plugins/cbf-multisite && composer update && cd ../cbf-slides-importer && composer update && cd ../cbf-semantic-glossary && composer update && cd ../cbf-semantic-glossary-learndash && composer update && cd ../../../..",
"local-deps:install": "bash scripts/local-deps.sh install",
"local-deps:update": "bash scripts/local-deps.sh update",
"lint": "phpcs --standard=phpcs.xml",
"lint:all": "@lint ./web/app/plugins/cbf-multisite ./web/app/plugins/cbf-slides-importer ./web/app/plugins/cbf-semantic-glossary ./web/app/plugins/cbf-semantic-glossary-learndash ./web/app/themes/cbf-academy ./web/app/themes/cbf-jobs",
"fix": "phpcbf --standard=phpcs.xml",
Expand Down
52 changes: 52 additions & 0 deletions scripts/local-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
#
# Install or update the Composer and npm dependencies of each in-repo plugin
# (web/app/plugins/cbf-*). Root Composer runs this after its own install or
# update; run it directly to refresh the plugins alone.
#
# Usage: scripts/local-deps.sh install|update
#
# Under `composer install --no-dev`, as on the servers, plugins get --no-dev
# too and npm is skipped. npm is also skipped in CI, which builds plugin assets
# in its own step.

set -euo pipefail

action=${1:-}
if [ "$action" != install ] && [ "$action" != update ]; then
echo "Usage: $0 install|update" >&2
exit 1
fi

cd "$(dirname "$0")/.."

# Composer sets this for its hook scripts: 0 under --no-dev, 1 otherwise
dev=${COMPOSER_DEV_MODE:-1}

composer_args=(--no-interaction)
if [ "$dev" = 0 ]; then
composer_args+=(--no-dev)
fi

run_npm=0
if [ "$dev" = 1 ] && [ -z "${CI:-}" ]; then
if command -v npm >/dev/null 2>&1; then
run_npm=1
else
echo "npm not found: skipping plugin npm dependencies" >&2
fi
fi

for dir in web/app/plugins/cbf-*/; do
name=$(basename "$dir")

if [ -f "$dir/composer.json" ]; then
echo "> $name: composer $action"
composer "$action" --working-dir="$dir" "${composer_args[@]}"
fi

if [ "$run_npm" = 1 ] && [ -f "$dir/package.json" ]; then
echo "> $name: npm $action"
npm "$action" --prefix "$dir" --no-audit --no-fund
fi
done
6 changes: 0 additions & 6 deletions web/app/plugins/cbf-multisite/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@
],
"phpcbf": [
"../../../../vendor/bin/phpcbf --standard=../../../../phpcs.xml -p ."
],
"post-install-cmd": [
"npm install || true"
],
"post-update-cmd": [
"npm update || true"
]
},
"extra": {
Expand Down
Loading