Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Satis abandon flag afterburner
* $argc[0] - name of script
* $argc[1] - filename to work on
if ($argc != 2) {
echo "need at least one parameter: json file to work on\n";
if (!file_exists($argv[1])) {
echo 'file does not exist: "'. $argv[1] ."\"\n";
echo "Processing file '$argv[1]'\n";
$packagesJson = file_get_contents($argv[1]);
$packages = json_decode($packagesJson, true);
foreach ($packages['packages'] as $packageName => $package) {
if (isset($package['dev-master']['abandoned'])) {
echo "Abandoned dev-master version of '$packageName' detected.\n";
foreach ($package as $version => $versionInfo) {
if (!isset($versionInfo["abandoned"])) {
$packages['packages'][$packageName][$version]['abandoned'] = $package['dev-master']['abandoned'];
echo "Inherit to version '$version'\n";
file_put_contents($argv[1], json_encode($packages));
echo "Create timestamp file"
touch timestamp
# this allows the later step to only work on newly created files instead of all existing files.
echo "Running Satis"
php satis/bin/satis build satis.json web/
# your usual execution of Satis
echo "Set abandoned flag of dev-master versions to all versions"
find web/include/ -maxdepth 1 -name "*.json" -newer timestamp -exec php inherit-abandon-flag.php {} \;
# Run the above script for all new json files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment