forked from BeSimple/BeSimpleI18nRoutingBundle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Replaced vendors.sh by bin/vendors php script to install vendors to r…
…un unit tests
- Loading branch information
1 parent
2d9047f
commit 55ee41c
Showing
3 changed files
with
110 additions
and
38 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
/* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
*/ | ||
|
||
$rootDir = dirname(__DIR__); | ||
$vendorDir = $rootDir.'/vendor'; | ||
|
||
array_shift($argv); | ||
if (!isset($argv[0])) { | ||
exit(<<<EOF | ||
I18nRoutingBundle vendors script management. | ||
Specify a command to run: | ||
install: install vendors | ||
update [--reinstall]: update vendors | ||
EOF | ||
); | ||
} | ||
|
||
if (!in_array($command = array_shift($argv), array('install', 'update'))) { | ||
exit(sprintf("Command \"%s\" does not exist.\n", $command)); | ||
} | ||
|
||
if ('install' === $command && is_dir($vendorDir.'/symfony/.git')) { | ||
exit(<<<EOF | ||
Vendors already installed | ||
Try to run ./bin/vendors update or ./bin/vendors update --reinstall | ||
EOF | ||
); | ||
} elseif ('update' === $command && !is_dir($vendorDir.'/symfony/.git') && !in_array('--reinstall', $argv)) { | ||
exit(<<<EOF | ||
Vendors are not installed | ||
Try to run ./bin/vendors update --reinstall or ./bin/vendors install | ||
EOF | ||
); | ||
} | ||
|
||
if (!is_file($rootDir.'/deps')) { | ||
exit(<<<EOF | ||
The $rootDir files does not exists | ||
EOF | ||
); | ||
} | ||
|
||
if (!is_dir($vendorDir)) { | ||
mkdir($vendorDir, 0777, true); | ||
} | ||
|
||
$newversions = array(); | ||
$deps = parse_ini_file($rootDir.'/deps', true, INI_SCANNER_RAW); | ||
foreach ($deps as $name => $dep) { | ||
// revision | ||
if (isset($versions[$name])) { | ||
$rev = $versions[$name]; | ||
} else { | ||
$rev = isset($dep['version']) ? $dep['version'] : 'origin/HEAD'; | ||
} | ||
|
||
// install dir | ||
$installDir = isset($dep['target']) ? $vendorDir.'/'.$dep['target'] : $vendorDir.'/'.$name; | ||
if (in_array('--reinstall', $argv)) { | ||
if (PHP_OS == 'WINNT') { | ||
system(sprintf('rmdir /S /Q %s', escapeshellarg(realpath($installDir)))); | ||
} else { | ||
system(sprintf('rm -rf %s', escapeshellarg($installDir))); | ||
} | ||
} | ||
|
||
echo "> Installing/Updating $name\n"; | ||
|
||
// url | ||
if (!isset($dep['git'])) { | ||
exit(sprintf('The "git" value for the "%s" dependency must be set.', $name)); | ||
} | ||
$url = $dep['git']; | ||
|
||
if (!is_dir($installDir)) { | ||
system(sprintf('git clone %s %s', escapeshellarg($url), escapeshellarg($installDir))); | ||
} | ||
|
||
system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev))); | ||
|
||
if ('update' === $command) { | ||
ob_start(); | ||
system(sprintf('cd %s && git log -n 1 --format=%%H', escapeshellarg($installDir))); | ||
$newversions[] = trim($name.' '.ob_get_clean()); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[symfony] | ||
git=http://github.com/symfony/symfony.git | ||
|
||
[doctrine-common] | ||
git=http://github.com/doctrine/common.git | ||
|
||
[doctrine-dbal] | ||
git=http://github.com/doctrine/dbal.git |
This file was deleted.
Oops, something went wrong.