Files
deployer/bin/deployer
macintoshplus 9df133fa08 dev
2015-09-02 08:00:51 +02:00

83 lines
2.5 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
set_time_limit(0);
require_once __DIR__.'/../vendor/autoload.php';
//require_once __DIR__.'/AppKernel.php';
//use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Application;
use Mactronique\Deployer\DeployerApp;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
use Mactronique\Deployer\Command;
use Mactronique\Deployer\Config\Configuration;
use Mactronique\Deployer\Config\ProjectConfiguration;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Config\Definition\Processor;
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('DEPLOYER_ENV') ?: 'dev');
$debug = getenv('DEPLOYER_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
if ($debug) {
Debug::enable();
}
// Configuration
$configPath = __DIR__.'/../config/app.yml';
if (file_exists($configPath)) {
$config = Yaml::parse(file_get_contents($configPath));
} else {
$config = [];
}
$projectPath = __DIR__.'/../config/projects.yml';
if (file_exists($projectPath)) {
$project = Yaml::parse(file_get_contents($projectPath));
} else {
$project = [];
}
$processor = new Processor();
$configuration = new Configuration();
try {
$processedConfiguration = $processor->processConfiguration(
$configuration,
[$config]);
} catch (\Exception $e) {
echo sprintf("In app configuration : %s\n", $e->getMessage());
exit(1);
}
$projectConfiguration = new ProjectConfiguration();
try {
$processedProjectConfiguration = $processor->processConfiguration(
$projectConfiguration,
[$project]);
$processedConfiguration['projects'] = $processedProjectConfiguration;
} catch (\Exception $e) {
echo sprintf("In project configuration : %s\n", $e->getMessage());
exit(1);
}
//$kernel = new AppKernel($env, $debug);
$application = new DeployerApp('Deployer', '0.0.1');
$application->setConfig($processedConfiguration);
$application->setConfigPath($configPath);
$application->setProjectConfigPath($projectPath);
$application->add(new Command\InitCommand());
$application->add(new Command\DeployCommand());
$application->add(new Command\UpdateCommand());
$application->add(new Command\ManagerAddCommand());
$application->add(new Command\ManagerRemoveCommand());
$application->add(new Command\ManagerListCommand());
$application->run($input);