Esempio n. 1
0
 function run($from, $to)
 {
     $this->logAction('copy', $to);
     $rsDir = $this->getResourceDir();
     // do copy
     Helper::copy($rsDir . DIRECTORY_SEPARATOR . $from, $to);
 }
Esempio n. 2
0
 /**
  * create directories operation
  *
  * @param array|string directory path
  */
 function run($dirs)
 {
     foreach ((array) $dirs as $dir) {
         $this->logAction('create', $dir);
         Helper::mktree($dir);
     }
 }
Esempio n. 3
0
 /**
  * write yaml to file
  *
  * @param string $path
  * @param mixed $data
  */
 function run($path, $data)
 {
     if (extension_loaded('yaml')) {
         $this->logAction('yaml', $path);
         Helper::put($path, yaml_emit($data));
     } else {
         $this->getLogger()->error('yaml extension not found.');
     }
 }
Esempio n. 4
0
 function run($repoUri, $target)
 {
     if (file_exists($target)) {
         $this->logAction('hg:pull', $repoUri);
         Helper::system('hg', '-R', $target, 'pull', '-u');
     } else {
         $this->logAction('hg:clone', $repoUri);
         Helper::system('hg', 'clone', $repoUri, $target);
     }
 }
Esempio n. 5
0
 function execute()
 {
     $logger = $this->getLogger();
     $path = Path::get_home_flavor_path();
     $logger->info("Creating {$path} ...");
     Helper::mktree($path);
     $logger->info("Creating flavors/...");
     Helper::mktree('flavors');
     $logger->info("Done");
 }
Esempio n. 6
0
 /**
  * render code template to file
  *
  * $this->render('template.php.twig','target.php', array( 
  *    ...
  * ));
  *
  * @param string $templateFile template file path (related from ResourceDir)
  * @param string $target       path to target file.
  */
 function run($templateFile, $target, $args = array())
 {
     $rsDir = $this->getResourceDir();
     $loader = new Twig_Loader_Filesystem(array($rsDir));
     $twig = new Twig_Environment($loader, array());
     // XXX: register some built-in template for php doc or code.
     $template = $twig->loadTemplate($templateFile);
     $output = $template->render($args);
     $this->logAction('render', $target);
     Helper::put($target, $output);
 }
Esempio n. 7
0
 function run($repoUri, $target)
 {
     if (file_exists($target)) {
         $this->logAction('git:pull', $repoUri);
         Helper::system('git', '--git-dir', $target . DIRECTORY_SEPARATOR . '.git', 'remote', 'update', '--prune');
         Helper::system('git', '--git-dir', $target . DIRECTORY_SEPARATOR . '.git', 'pull', '--all');
     } else {
         $this->logAction('git:clone', $repoUri);
         Helper::system('git', 'clone', $repoUri, $target);
     }
 }
Esempio n. 8
0
 /**
  * Recursive directory copy operation
  *
  * @param string $from related path from Resource Dir
  * @param string $to related path of target
  */
 public function run($from, $to)
 {
     $resDir = $this->getResourceDir();
     $from = realpath($from) ?: $resDir . DIRECTORY_SEPARATOR . $from;
     // $from = realpath($from) ?: $from;
     $to = realpath($to) ?: $to;
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($from), RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $path) {
         $target = $to . substr($path, strlen($from));
         if ($path->isDir()) {
             $this->logAction('copy', Helper::short_path($target));
             Helper::mktree($target);
         } else {
             $this->logAction('copy', Helper::short_path($target));
             Helper::copy($path, $target);
         }
     }
 }
Esempio n. 9
0
 function installFlavor($flavor)
 {
     if (isset($this->installed[$flavor->getName()])) {
         return;
     }
     $logger = $this->getLogger();
     $homePath = Path::get_home_flavor_path();
     Helper::mktree($homePath);
     $logger->info("Installing " . $flavor->getName() . "...");
     Helper::copy_dir($flavor->__toString(), $homePath . DIRECTORY_SEPARATOR . $flavor->getName(), function ($target) use($logger) {
         $logger->info("Installing " . $target, 1);
     });
     // get dependencies
     $generator = $flavor->getGenerator();
     $depGenerators = $generator->getDependencies();
     foreach ($depGenerators as $depGenerator) {
         $this->installFlavor($depGenerator->getFlavor());
     }
 }
Esempio n. 10
0
 /**
  * file create operation
  *
  * @param string $file target file path
  * @param string $content file content
  */
 function run($file, $content)
 {
     $this->logAction('create', $file);
     Helper::put($file, $content);
 }
Esempio n. 11
0
 static function copy($from, $to, $force = false)
 {
     Helper::mkdir_for_file($to);
     copy($from, $to);
 }
Esempio n. 12
0
 /**
  * write json file
  *
  * @param string $file path to file
  * @param mixed  structural data
  */
 function run($file, $data)
 {
     $this->logAction('create', $file);
     Helper::put($file, json_encode($data));
 }