Created
January 10, 2012 18:21
-
-
Save kiang/1590354 to your computer and use it in GitHub Desktop.
another vendors shell that only export missing deps in vendors for symfony2
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
#!/usr/bin/env php | |
<?php | |
set_time_limit(0); | |
$rootDir = dirname(__DIR__); | |
$vendorDir = $rootDir . '/vendor'; | |
array_shift($argv); | |
if (!is_dir($vendorDir)) { | |
mkdir($vendorDir, 0777, true); | |
} | |
$deps = parse_ini_file($rootDir . '/deps', true, INI_SCANNER_RAW); | |
if (false === $deps) { | |
exit("The deps file is not valid ini syntax. Perhaps missing a trailing newline?\n"); | |
} | |
foreach ($deps as $name => $dep) { | |
$dep = array_map('trim', $dep); | |
// revision | |
$rev = isset($dep['version']) ? "/tags/{$dep['version']}" : '/branches/master'; | |
// install dir | |
$installDir = isset($dep['target']) ? $vendorDir . '/' . $dep['target'] : $vendorDir . '/' . $name; | |
if (file_exists($installDir)) { | |
echo "> Target dep exists: $name\n"; | |
} else { | |
echo "> Installing $name\n"; | |
// url | |
if (!isset($dep['git'])) { | |
exit(sprintf('The "git" value for the "%s" dependency must be set.', $name)); | |
} | |
$url = $dep['git']; | |
$githubPos = strpos($url, 'github.com'); | |
if(false === $githubPos) { | |
echo "> $name is not located in github.com\n"; | |
} else { | |
$url = 'https://' . substr($url, $githubPos) . $rev; | |
} | |
system(sprintf('svn export %s %s', escapeshellarg($url), escapeshellarg($installDir))); | |
} | |
} | |
// php on windows can't use the shebang line from system() | |
$interpreter = PHP_OS == 'WINNT' ? 'php.exe' : ''; | |
// Update the bootstrap files | |
system(sprintf('%s %s %s', $interpreter, escapeshellarg($rootDir . '/vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php'), escapeshellarg($rootDir))); | |
// Update assets | |
system(sprintf('%s %s assets:install %s', $interpreter, escapeshellarg($rootDir . '/app/console'), escapeshellarg($rootDir . '/web/'))); | |
// Remove the cache | |
system(sprintf('%s %s cache:clear --no-warmup', $interpreter, escapeshellarg($rootDir . '/app/console'))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment