Based on this It seems running composer update
can possibly lead to problems.
The alternative of running each one individually seems tedious
So, in favor of my learning python3 and in my experience with bash and nostalgia for one-liners, I bring the one-line function of update_flarum. Enjoy ?
To see what it's doing, place echo
in front of composer update
and php flarum
After entering the below function into the terminal (or placing in your ~/.bash_aliases
), you can then invoke it.
Usage: update_flarum /dir/to/flarum/
# Must have trailing slash (/
)
What it does:
- Checks for composer.json at the directory you specify
- python3 loads the json data from composer.json and prints out the key for each extension you have installed
- composer updates based on these values
- Clears the cache
update_flarum() { if [ ! -f "$1"composer.json ]; then echo "No composer.json at $1"; else ( cd "$1" && composer update $(python3 -c "import sys, json; [ print(key, end=' ') for key, value in json.load(sys.stdin)['require'].items()]" < composer.json) && php flarum cache:clear ); fi; }
update_flarum() {
if [ ! -f "$1"composer.json ]
then
echo "No composer.json at $1"
else
(
cd "$1" && \
composer update $(
python3 -c "
import sys, json; \
[ print(key, end=' ') for key, value in json.load(sys.stdin)['require'].items()]" \
< composer.json) && \
php flarum cache:clear
)
fi
}