Skip to content

Commit

Permalink
Support loading composer dependencies from extensions cloned before t…
Browse files Browse the repository at this point in the history
…he action

The action currently loads composer dependencies from every `composer.json`
file found in a subdirectory of `extensions/` or `skins/`. However, since those
directories are only available after this action performs the initial clone of
MediaWiki, any dependencies that the extension clones before running this
action will have been cloned into a separate location. Specifically, they are
expected to be cloned into the same directory as the MediaWiki installation,
with their `composer.json` files parallel to that of MediaWiki itself.
​
Search for all such files, excluding the one from MediaWiki itself, and add
them to the generated `composer.local.json`.
​
SEL-1138
  • Loading branch information
DanielWTQ authored Oct 13, 2024
1 parent 5679099 commit dfea56b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,25 @@ if [ -n "${EXTRA_INCLUDE_FILE}" ]; then
echo "require_once \"$INCLUDE_PATH\";" >> LocalSettings.php
fi

# Include everything from `extensions` and `skins` directories
# To support loading the composer.json of any dependency extensions that were
# cloned before MediaWiki was, we need to find those - they should be installed
# in the same directory that mediawiki was, i.e. one directory up from here;
# we cannot just use the composer-merge-plugin handling with a glob like
# `../*/composer.json` since that will recursively load itself and cause
# problems. Instead we want to
# - find all composer.json files that are in directories at the same level
# as the current directory
# - exclude the composer.json file that is in the current directory
# - format each of those entries, and add them to the list
EXTRACOMPOSER=$(ls ../*/composer.json 2>/dev/null | grep --invert $(basename $(pwd)/) | xargs -t -I% echo \"%\",)
cat <<EOT > composer.local.json
{
"require": {},
"extra": {
"merge-plugin": {
"merge-dev": true,
"include": [
$EXTRACOMPOSER
"extensions/*/composer.json",
"skins/*/composer.json"
]
Expand Down

0 comments on commit dfea56b

Please sign in to comment.