Esempio n. 1
0
File: Phar.php Progetto: pago/pantr
 public static function create($phar, $src = 'src')
 {
     pantr::writeAction('phar', $phar);
     $p = new Phar($phar);
     $p->startBuffering();
     if (is_callable($src)) {
         $src($p);
     } else {
         $p->addDirectories($src);
         $p->setDefaultStub();
     }
     $p->stopBuffering();
 }
Esempio n. 2
0
 public function upload($files, $dest, $in = null)
 {
     $this->run(function ($ftp) use($files, $dest, $in) {
         // do the actual upload
         $ftp->mkdir($dest);
         $ftp->cd($dest);
         pantr::writeAction('ftp', 'upload');
         $action = new FTPDeployAction($ftp);
         $action->upload($files, $in);
         // erase message in line above
         pantr::write("");
         pantr::writeAction('ftp', 'upload done');
     });
     return $this;
 }
Esempio n. 3
0
 public function run($verbose = false, $taskName = 'test:unit')
 {
     $suite = $this->getTestSuite();
     if ($verbose) {
         $result = \PHPUnit_TextUI_TestRunner::run($suite, $this->arguments);
     } else {
         // execute the test
         ob_start();
         $listener = new AssertionTestListener();
         $runner = new TestRunner($listener);
         $result = $runner->doRun($suite, $this->arguments);
         ob_end_clean();
         $assertions = $listener->numAssertions;
         if ($result->wasSuccessful()) {
             pantr::writeAction($taskName, $this->formatTestResult($result, $assertions));
             return Task::SUCCESS;
         } else {
             pantr::writeAction($taskName, $this->formatTestResult($result, $assertions), pantr::WARNING);
             return Task::FAILED;
         }
     }
 }
Esempio n. 4
0
File: Pirum.php Progetto: pago/pantr
 public function add($pearPackage)
 {
     pantr::writeAction('pirum', 'Adding ' . $pearPackage . ' to ' . $this->channel);
     $this->exec('add', $this->channel, $pearPackage);
 }
Esempio n. 5
0
File: pantr.php Progetto: pago/pantr
 public static function sh($cmd, $interactive = false)
 {
     $verbose = true;
     pantr::writeAction('exec ', $cmd);
     if (false === $interactive) {
         ob_start();
     }
     passthru($cmd . ' 2>&1', $return);
     if (false === $interactive) {
         $content = ob_get_clean();
         if ($return > 0) {
             throw new \Exception(sprintf('Problem executing command %s', $verbose ? "\n" . $content : ''));
         }
     } else {
         if ($return > 0) {
             throw new \Exception('Problem executing command');
         }
     }
     if (false === $interactive) {
         return $content;
     }
 }
Esempio n. 6
0
 public function sync($silent = true)
 {
     $pkgs = $this->repo->listAllPackages();
     pantr::writeAction('sync', 'PEAR repository');
     foreach ($this->channels as $channel => $packages) {
         // discover channel if it is new
         if (!isset($pkgs[$channel])) {
             if ($silent) {
                 pantr::beginSilent('add', 'channel ' . $channel);
             }
             $this->repo->discoverChannel($channel);
             if ($silent) {
                 pantr::endSilent();
             }
             $pkgs[$channel] = array();
         }
         // now check if all packages from this channel are installed
         foreach ($packages as $pkg => $version) {
             if (!in_array($pkg, $pkgs[$channel])) {
                 // $channel/$pkg[-$version]
                 if ($silent) {
                     pantr::beginSilent('install', 'package ' . $pkg);
                 }
                 try {
                     $this->repo->install($channel . '/' . $pkg . ($version != '' ? '-' . $version : ''));
                 } catch (\Exception $ex) {
                     pantr::writeln($ex, pantr::WARNING);
                 }
                 if ($silent) {
                     pantr::endSilent();
                 }
                 $pkgs[$channel][] = $pkg;
             }
         }
         // check if packages are installed that are not specified
         foreach ($pkgs[$channel] as $pkg) {
             if (!isset($packages[$pkg])) {
                 if ($silent) {
                     pantr::beginSilent('delete', 'package ' . $pkg);
                 }
                 $this->repo->uninstall($channel . '/' . $pkg);
                 if ($silent) {
                     pantr::endSilent();
                 }
             }
         }
     }
     // delete unknown channels
     foreach ($pkgs as $channel => $packs) {
         if (!isset($this->channels[$channel])) {
             pantr::writeln($channel);
             foreach ($packs as $pkg) {
                 if ($silent) {
                     pantr::beginSilent('delete', 'package ' . $pkg);
                 }
                 $this->repo->uninstall($channel . '/' . $pkg);
                 if ($silent) {
                     pantr::endSilent();
                 }
             }
             if ($silent) {
                 pantr::beginSilent('delete', 'channel ' . $channel);
             }
             $this->repo->deleteChannel($channel);
             if ($silent) {
                 pantr::endSilent();
             }
         }
     }
 }
Esempio n. 7
0
File: load.php Progetto: pago/pantr
use pantr\pantr;
// try to load pearfarm
$tryLoad = function () {
    foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
        $dir = $path . DIRECTORY_SEPARATOR . 'pearfarm/src/Pearfarm';
        if (file_exists($dir)) {
            $classes = array('ITask', 'PackageSpec', 'Task' . DIRECTORY_SEPARATOR . 'Push');
            foreach ($classes as $class) {
                require_once $dir . DIRECTORY_SEPARATOR . $class . '.php';
            }
        }
    }
};
$tryLoad();
if (!class_exists('Pearfarm_PackageSpec')) {
    // try to install it now
    pantr::silent(function () {
        $repo = pantr::getRepository();
        if (!$repo->hasChannel('pearfarm')) {
            $repo->discoverChannel('pearfarm.pearfarm.org');
        }
        $repo->install('pearfarm/pearfarm');
        $tryLoad();
    });
    if (!class_exists('Pearfarm_PackageSpec')) {
        throw new \Exception('Pearfarm is not installed!');
    } else {
        pantr::writeAction('install', 'Pearfarm');
    }
}
Esempio n. 8
0
/** 
 * Output a formatted message to the user explaining
 * the current task. $action is the performed task (i.e. "move", "build", "create")
 * and $desc is the more detailed description ("to some other directory",
 * "the PEAR channel", "a PEAR package")
 *
 * It will also log the action with a Zend_Log::NOTICE priority.
 *
 * @return Output
 */
function writeAction($action, $desc, $style = 'PARAMETER')
{
    pantr::writeAction($action, $desc, $style);
}
Esempio n. 9
0
File: Spec.php Progetto: pago/pantr
 public static function run($testsDirectory, $arguments = array())
 {
     if (is_string($testsDirectory)) {
         $tests = \pantr\file\fileset('*Spec.php')->in($testsDirectory);
     } else {
         $tests = $testsDirectory;
     }
     foreach ($tests as $test) {
         require_once $test;
     }
     $isVerbose = isset($arguments['verbose']) && $arguments['verbose'];
     $taskName = isset($arguments['taskname']) ? $arguments['taskname'] : null;
     if (!$isVerbose && !is_null($taskName)) {
         ob_start();
     }
     $result = TextUI\TestRunner::run(self::getTestSuite(), $arguments);
     if (!$isVerbose && !is_null($taskName)) {
         $content = ob_get_contents();
         ob_end_clean();
         if ($result->wasSuccessful()) {
             pantr::writeAction($taskName, $content);
         } else {
             pantr::writeAction($taskName, $content, pantr::WARNING);
         }
     }
     if ($result->wasSuccessful()) {
         return Task::SUCCESS;
     } else {
         return Task::FAILED;
     }
 }
Esempio n. 10
0
            $task = $tasks[$taskName];
            if ($task->getName() == 'help') {
                $task->desc('Display detailed information for a task');
            }
            $task->printHelp();
        }
    } else {
        // show summary of all tasks
        pantr::writeln('Usage:', pantr::SECTION)->write('pantr [options]')->write(' <task> ', pantr::PARAMETER)->writeln('[args]');
        Application::printOptions();
        pantr::out()->nl()->writeln('Available tasks:', pantr::SECTION);
        $showGlobalTasks = isset($req['global-tasks']);
        $tasks = pantr::getDefinedTasks();
        $names = array_keys($tasks);
        sort($names);
        foreach ($names as $key) {
            $task = $tasks[$key];
            $taskName = $task->getName();
            $isGlobalTask = $task->isGlobal();
            $showTask = $task->isHidden() == false && $showGlobalTasks == $isGlobalTask;
            if ($showTask) {
                if ($task->getName() != $key) {
                    pantr::writeAction($key, 'Alias for [' . $task->getName() . '|INFO]');
                } else {
                    pantr::writeAction($key, $task->getDescription());
                }
            }
        }
        pantr::out()->nl()->writeln('Help', pantr::SECTION)->write('See ')->write('pantr help ', pantr::COMMENT)->write('<task> ', pantr::PARAMETER)->writeln(' for help with a specific task.');
    }
});