Files
FOSSBilling/.ddev/post-start.sh
T
Belle Aerni c486b262d9 Small developer experience improvements (#2971)
* ddev enhancements

Introduced a new script that runs when the ddev container starts.
This script will automatically update the dependencies if they fall behind the lockfile and will rebuild NPM when needed too

* Fixes and improvements for DX

* Cleaner, better

* Changes based on copilot review

* Remove an old comment I somehow missed

* use npm ci instead
2025-10-14 11:06:33 -07:00

42 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# NPM vars
nodeModulesPath="node_modules"
packageLock="package-lock.json"
nodeBuildTimestamp="node_modules/package.stamp"
# Composer vars
composerVendorPath="src/vendor"
composerLock="composer.lock"
customVendorTimestamp="src/vendor/composer.stamp"
# Other vars
npmBuildNeeded=0
infoString="\033[1;33mINFO:\033[0m"
now=$(date +"%Y-%m-%d_%H:%M:%S")
echo -e "$infoString Automatically installing / updating dependencies and building the front-end. Please wait."
sleep 2
# If the NPM packages aren't installed or are outdated, install the locked versions
if [ ! -d "$nodeModulesPath" ] || [ ! -f "$nodeBuildTimestamp" ] || [ "$packageLock" -nt "$nodeBuildTimestamp" ]; then
npm ci --include=dev
npmBuildNeeded=1
elif [ ! -d "src/themes/admin_default/build" ]; then
npmBuildNeeded=1
fi
# If the composer packages aren't installed or are outdated, install the locked versions
if [ ! -d "$composerVendorPath" ] || [ ! -f "$customVendorTimestamp" ] || [ "$composerLock" -nt "$customVendorTimestamp" ]; then
composer install
echo "$now" > "$customVendorTimestamp"
fi
# If we changed NPM packages, then re-run the build automatically
if [ $npmBuildNeeded -eq 1 ]; then
npm run build
echo "$now" > "$nodeBuildTimestamp"
fi
echo -e "$infoString Done!"