Skip to content

Commit

Permalink
chore(recipe): Add composer-update-minor-only
Browse files Browse the repository at this point in the history
  • Loading branch information
philipsorst committed Jun 24, 2024
1 parent e21972c commit 77245f8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions recipe/bin/dev/composer-update-minor-only
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env php
<?php

$updatePackages = array_map(
fn($package) => sprintf("%s:%s", $package['name'], $package['latest']),
array_filter(
json_decode(shell_exec('composer outdated -m --format=json'), true, 512, JSON_THROW_ON_ERROR)['installed'],
fn(array $package): bool => $package['latest-status'] === 'semver-safe-update'
&& preg_match('/^v?\d+\.\d+\.\d+$/', $package['latest'])
)
);

if ($updatePackages) {
shell_exec('composer update ' . implode(' ', $updatePackages));
} else {
echo "No packages need to be updated.\n";
}

0 comments on commit 77245f8

Please sign in to comment.