updated install to better work with symliks

This commit is contained in:
Andy Miller 2014-08-07 09:45:16 -06:00
parent cd24994bc7
commit 96481dd25b
2 changed files with 39 additions and 15 deletions

View File

@ -11,7 +11,8 @@ use \Symfony\Component\Yaml\Yaml;
class InstallCommand extends Command {
protected $configuration;
protected $config;
protected $local_config;
protected function configure() {
$this
@ -30,7 +31,7 @@ class InstallCommand extends Command {
{
$dependencies_file = USER_DIR . '/.dependencies';
$local_config_file = exec('eval echo ~/.grav/config');
// Create a red output option
$output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
@ -38,8 +39,16 @@ class InstallCommand extends Command {
$output->getFormatter()->setStyle('green', new OutputFormatterStyle('green'));
$output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
if (file_exists($local_config_file)) {
$this->local_config = Yaml::parse($local_config_file);
$output->writeln('');
$output->writeln('read local config from <cyan>' . $local_config_file . '</cyan>');
}
if (is_file($dependencies_file)) {
$this->configuration = Yaml::parse($dependencies_file);
$this->config = Yaml::parse($dependencies_file);
if (!$input->getOption('symlink')) {
$this->gitclone($output);
@ -64,7 +73,7 @@ class InstallCommand extends Command {
$output->writeln('');
exec('cd ' . ROOT_DIR);
foreach($this->configuration['git'] as $repo => $data) {
foreach($this->config['git'] as $repo => $data) {
if (!file_exists($data['path'])) {
exec('git clone -b ' . $data['branch'] . ' ' . $data['url'] . ' ' . $data['path']);
$output->writeln('<green>SUCCESS</green> cloned <magenta>' . $data['url'] . '</magenta> -> <cyan>' . $data['path'] . '</cyan>');
@ -85,16 +94,28 @@ class InstallCommand extends Command {
$output->writeln('===============');
$output->writeln('');
if (!$this->local_config) {
$output->writeln('<red>No local configuration available, aborting...</red>');
$output->writeln('');
exit;
}
exec('cd ' . ROOT_DIR);
foreach($this->configuration['links'] as $repo => $data) {
if (!file_exists($data['path'])) {
$from = ROOT_DIR . $data['src'];
$to = ROOT_DIR . $data['path'];
symlink ($from, $to);
$output->writeln('<green>SUCCESS</green> symlinked <magenta>' . $data['src'] . '</magenta> -> <cyan>' . $data['path'] . '</cyan>');
$output->writeln('');
foreach($this->config['links'] as $repo => $data) {
$from = $this->local_config[$data['scm'].'_repos'] . $data['src'];
$to = ROOT_DIR . $data['path'];
if (file_exists($from)) {
if (!file_exists($to)) {
symlink ($from, $to);
$output->writeln('<green>SUCCESS</green> symlinked <magenta>' . $data['src'] . '</magenta> -> <cyan>' . $data['path'] . '</cyan>');
$output->writeln('');
} else {
$output->writeln('<red>destination: ' . $to . ' already exists, skipping...</red>');
$output->writeln('');
}
} else {
$output->writeln('<red>' . $data['path'] . ' already exists, skipping...</red>');
$output->writeln('<red>source: ' . $from . ' does not exists, skipping...</red>');
$output->writeln('');
}

View File

@ -13,11 +13,14 @@ git:
branch: develop
links:
problems:
src: ../grav-plugin-problems
src: grav-plugin-problems
path: user/plugins/problems
scm: github
error:
src: ../grav-plugin-error
src: grav-plugin-error
path: user/plugins/error
scm: github
antimatter:
src: ../grav-theme-antimatter
src: grav-theme-antimatter
path: user/themes/antimatter
scm: github