2014-07-04 12:15:38 +04:00
|
|
|
#!/usr/bin/env php
|
2013-07-11 15:47:09 +04:00
|
|
|
<?php
|
2016-01-11 12:51:59 +07:00
|
|
|
/* (c) Anton Medvedev <anton@medv.io>
|
2013-07-11 15:47:09 +04:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2014-07-05 14:05:17 +04:00
|
|
|
$loaded = false;
|
2013-07-11 15:47:09 +04:00
|
|
|
|
2015-06-18 12:41:40 +02:00
|
|
|
foreach ([__DIR__ . '/../../../autoload.php', __DIR__ . '/../vendor/autoload.php'] as $file) {
|
2014-07-05 14:05:17 +04:00
|
|
|
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
|
|
|
|
);
|
|
|
|
}
|
2014-07-04 13:39:57 +04:00
|
|
|
|
2014-07-06 14:02:23 +04:00
|
|
|
// Recipe include path
|
2014-08-09 14:50:30 +04:00
|
|
|
set_include_path(__DIR__ . '/../' . PATH_SEPARATOR . get_include_path());
|
2014-07-06 14:02:23 +04:00
|
|
|
|
2014-11-29 22:11:11 +03:00
|
|
|
// Include function declarations
|
|
|
|
require_once 'src/functions.php';
|
|
|
|
|
2014-12-25 23:29:47 +03:00
|
|
|
// Deployer constants
|
|
|
|
define('DEPLOYER_BIN', __FILE__);
|
|
|
|
|
2014-07-07 17:44:06 +04:00
|
|
|
// Init Deployer
|
2015-02-05 17:19:37 +03:00
|
|
|
$console = new \Deployer\Console\Application('Deployer', 'master');
|
2014-11-29 22:11:11 +03:00
|
|
|
$input = new \Symfony\Component\Console\Input\ArgvInput();
|
2014-12-13 17:16:32 +03:00
|
|
|
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
|
2014-11-29 22:11:11 +03:00
|
|
|
$deployer = new \Deployer\Deployer($console, $input, $output);
|
|
|
|
|
|
|
|
// Require deploy.php script
|
|
|
|
$options = getopt('f::', ['file::']);
|
|
|
|
$userSpecifiedFile = null;
|
2014-07-07 17:44:06 +04:00
|
|
|
|
2014-11-29 22:11:11 +03:00
|
|
|
if (isset($options['f'])) {
|
2015-02-12 19:52:28 -05:00
|
|
|
$userSpecifiedFile = $options['f'];
|
2015-06-18 12:41:40 +02:00
|
|
|
} elseif (isset($options['file'])) {
|
2015-02-12 19:52:28 -05:00
|
|
|
$userSpecifiedFile = $options['file'];
|
2014-11-29 22:11:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($userSpecifiedFile)) {
|
|
|
|
$deployFile = getcwd() . '/deploy.php';
|
|
|
|
} else {
|
2015-02-12 19:52:28 -05:00
|
|
|
$deployFile = ($userSpecifiedFile[0] === '/' ? '' : getcwd() . '/') . $userSpecifiedFile;
|
2014-11-29 22:11:11 +03:00
|
|
|
}
|
2014-07-04 13:39:57 +04:00
|
|
|
|
2014-07-05 14:05:17 +04:00
|
|
|
if (is_file($deployFile) && is_readable($deployFile)) {
|
2014-07-04 13:39:57 +04:00
|
|
|
require $deployFile;
|
2014-07-07 17:44:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run Deployer
|
|
|
|
$deployer->run();
|