This commit is contained in:
macintoshplus
2015-09-02 08:00:51 +02:00
parent 431155ac80
commit 9df133fa08
6 changed files with 97 additions and 37 deletions

View File

@@ -17,6 +17,7 @@ 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;
@@ -37,16 +38,39 @@ if (file_exists($configPath)) {
$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();
$processedConfiguration = $processor->processConfiguration(
$configuration,
[$config]);
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());

View File

@@ -28,6 +28,22 @@ class SvnAdapter implements CvsAdapter
}
public function ls($url)
{
$command = $this->getCommand('svn ls', $url);
$this->run($command);
}
protected function run($command)
{
$proc = new ProcessExecutor();
$output = null;
$proc->execute($command, $output);
dump($output);
return $output;
}
protected function getCommand($cmd, $url, $path = null)
{
$command = sprintf('%s %s%s %s', $cmd, '--non-interactive ', $this->getCredentialString(), ProcessExecutor::escape($url));

View File

@@ -32,11 +32,7 @@ class ManagerListCommand extends Command
->setName('manager:list')
->setDescription('List all project into manager')
->setHelp('Help for my command !!!!')
->addArgument(
'url',
InputArgument::REQUIRED,
'url to deloyer config file'
)
->addOption('update', 'u', InputOption::VALUE_NONE, 'Update the list of project from SVN main repository')
;
}
@@ -51,10 +47,10 @@ class ManagerListCommand extends Command
$output->writeln('<question> </question>');
$output->writeln('');
$path = rtrim(rtrim($input->getArgument('path'), '/'), '\\').DIRECTORY_SEPARATOR;
$output->writeln($path);
$update = $this->getOption('update');
}
}

View File

@@ -14,29 +14,12 @@ class Configuration implements ConfigurationInterface
$rootNode
->children()
->booleanNode('enable-email')
->booleanNode('enable_email')
->defaultFalse()
->end()
->scalarNode('svn-path')
->scalarNode('svn_path')
->defaultValue(null)
->end()
->scalarNode('svn-user')
->defaultValue(null)
->end()
->scalarNode('svn-pass')
->defaultValue(null)
->end()
->arrayNode('projects')
->useAttributeAsKey('name')
->prototype('array')
->children()
->scalarNode('url')->isRequired()->end()
->booleanNode('enable')
->defaultTrue()
->end()
->end()
->end()
->end()
->end();
return $treeBuilder;

View File

@@ -10,6 +10,8 @@ class DeployerApp extends Application
protected $configPath;
protected $projectPath;
public function setConfig(array $config)
{
$this->config = $config;
@@ -45,4 +47,28 @@ class DeployerApp extends Application
return $this;
}
/**
* Gets the value of projectPath.
*
* @return mixed
*/
public function getProjectPath()
{
return $this->projectPath;
}
/**
* Sets the value of projectPath.
*
* @param mixed $projectPath the project path
*
* @return self
*/
public function setProjectPath($projectPath)
{
$this->projectPath = $projectPath;
return $this;
}
}

View File

@@ -1,25 +1,26 @@
<?php
namespace Mactronique\Deployer\Manager;
use Mactronique\Deployer\Adapter\CvsAdapter;
class ProjectManager
{
private $projects;
private $cachePath;
private $cache;
/**
* Array contains all system of Control of Version for Sources
*/
private $system;
public function __construct(array $projects)
public function __construct(array $projects, $cachePath)
{
$this->$projects = $projects;
}
public function add($name, $url)
{
$this->cachePath = $cachePath;
}
public function getList()
@@ -27,7 +28,7 @@ class ProjectManager
}
public function remove($name)
public function getInfos($projectName)
{
}
@@ -37,8 +38,22 @@ class ProjectManager
$this->system[$system->getName()] = $system;
}
private function save()
private function saveCache()
{
}
private function loadCache()
{
if (!file_exists($this->cachePath)) {
return [];
}
$content = file_get_contents($projectPath);
if (empty($content)) {
return [];
}
return unserialize($content);
}
}