Anton Medvedev 8022c978b2 Update dep
Now all installs from composer will see `master` version of Deployer. And users who uses `deployer.phar` will see actual version (build script will replace `master` string with build tag).
2015-02-05 17:19:37 +03:00

71 lines
2.0 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
/* (c) Anton Medvedev <anton@elfet.ru>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$loaded = false;
foreach (array(__DIR__ . '/../../../autoload.php', __DIR__ . '/../vendor/autoload.php') as $file) {
if (file_exists($file)) {
require $file;
$loaded = true;
break;
}
}
if (!$loaded) {
die(
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
'wget http://getcomposer.org/composer.phar' . PHP_EOL .
'php composer.phar install' . PHP_EOL
);
}
// Recipe include path
set_include_path(__DIR__ . '/../' . PATH_SEPARATOR . get_include_path());
// Include function declarations
require_once 'src/functions.php';
// Deployer constants
define('DEPLOYER_BIN', __FILE__);
// Init Deployer
$console = new \Deployer\Console\Application('Deployer', 'master');
$input = new \Symfony\Component\Console\Input\ArgvInput();
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
$deployer = new \Deployer\Deployer($console, $input, $output);
// Require deploy.php script
$options = getopt('f::', ['file::']);
$userSpecifiedFile = null;
if (isset($options['f'])) {
$userSpecifiedFile = $options['f'];
} else if (isset($options['file'])) {
$userSpecifiedFile = $options['file'];
}
if (empty($userSpecifiedFile)) {
$deployFile = getcwd() . '/deploy.php';
} else {
$deployFile = ($userSpecifiedFile[0] === '/' ? '' : getcwd() . '/') . $userSpecifiedFile;
}
if (is_file($deployFile) && is_readable($deployFile)) {
require $deployFile;
}
// Self-update command
$selfUpdate = new \KevinGH\Amend\Command('self-update');
$selfUpdate->setDescription('Updates deployer.phar to the latest version');
$selfUpdate->setManifestUri('http://deployer.org/manifest.json');
$console->add($selfUpdate);
$console->getHelperSet()->set(new \KevinGH\Amend\Helper());
// Run Deployer
$deployer->run();