phpPackages.php-cs-fixer: add updateScript (#496857)

This commit is contained in:
Pol Dellaiera
2026-04-10 17:36:28 +00:00
committed by GitHub
2 changed files with 32 additions and 0 deletions
@@ -22,6 +22,8 @@ php.buildComposerProject2 (finalAttrs: {
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
passthru.updateScript = ./update.sh;
meta = {
changelog = "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/tag/v${finalAttrs.version}";
description = "Tool to automatically fix PHP coding standards issues";
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq php82.packages.composer nix-update coreutils
set -eou pipefail
PACKAGE_NAME="phpPackages.php-cs-fixer"
PACKAGE_VERSION=$(nix eval --raw -f. $PACKAGE_NAME.version)
PACKAGE_DIR="$(dirname "${BASH_SOURCE[0]}")"
# Get latest version from git
GIT_VERSION="$(curl --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/releases/latest" | jq '.tag_name' --raw-output)"
NEW_VERSION="${GIT_VERSION#v}"
# Fail if package and git version are the same
if [[ "$PACKAGE_VERSION" == "$NEW_VERSION" ]]; then
echo "${PACKAGE_NAME} is up-to-date: ${PACKAGE_VERSION}"
exit 0
fi
# Generate composer.lock file
TMPDIR=$(mktemp -d)
trap 'rm -rf -- "${TMPDIR}"' EXIT
git clone --depth 1 --branch "${GIT_VERSION}" https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git "${TMPDIR}/php-cs-fixer"
rm -f "${TMPDIR}/php-cs-fixer/composer.lock"
composer -d "${TMPDIR}/php-cs-fixer" update --no-scripts
cp "${TMPDIR}/php-cs-fixer/composer.lock" "${PACKAGE_DIR}/composer.lock"
# update package.nix version, hash and vendorHash
nix-update $PACKAGE_NAME --version="${NEW_VERSION}"