Created
October 8, 2012 16:27
-
-
Save schmunk42/3853414 to your computer and use it in GitHub Desktop.
Test-script to auto-generate packages.json from github API
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 | |
// get all repos from yiiext | |
$response = file_get_contents("https://api.github.com/orgs/yiiext/repos"); | |
$repos = json_decode($response); | |
#var_dump($repos); | |
// get versions/tags | |
$satis = array(); | |
foreach($repos AS $num => $repo) { | |
if ($num > 5) break; // TODO - just for debugging | |
$response = file_get_contents($repo->url.'/tags'); | |
$tags = json_decode($response); | |
#echo "REPO:"; | |
#var_dump($repo); | |
#echo "TAGS:"; | |
#var_dump($tags); | |
foreach($tags AS $tag){ | |
$versions[$tag->name] = array( | |
'name' => $repo->full_name, | |
'description' => $repo->description, | |
'version' => $tag->name, | |
'source' => array( | |
'url' => $repo->clone_url, | |
'type' => 'git', | |
'reference' => $tag->commit->sha, | |
), | |
'dist' => array( | |
'url' => $tag->zipball_url, | |
'type' => 'zip', | |
), | |
); | |
$packages[$repo->full_name] = $versions; | |
} | |
}; | |
$satis = new StdClass(); | |
$satis->packages = $packages; | |
$json = json_encode($satis); | |
file_put_contents ("packages.json" , $json); | |
echo "packages.json generated."; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment