Created
July 14, 2015 11:31
-
-
Save SvenRtbg/2cf56388ac996870f380 to your computer and use it in GitHub Desktop.
Satis abandon flag afterburner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* $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"; | |
exit(1); | |
} | |
if (!file_exists($argv[1])) { | |
echo 'file does not exist: "'. $argv[1] ."\"\n"; | |
exit(2); | |
} | |
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)); | |
exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
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