Example #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('package');
     Util\TmpDir::set($input->getOption('tmp-dir'));
     /* TODO Rework this to use the Info package command */
     $cb = function (Interfaces\Package $package) use($helper, $output) {
         $helper->showInfo($output, $package);
     };
     $path = rtrim($input->getArgument('path'), '/\\');
     /* Getting package unpacked first, then use the path*/
     $package = $this->getHelper('package')->convey($input, $output, $path);
     $release = Release::factory($package->getRootDir(), $cb, $input->getOption('no-convert'), $input->getOption('binary'));
     if ($input->getOption('binary')) {
         list($optionsValue, $force_opts) = $this->buildOptions($package, $input, $output);
         $build = \Pickle\Package\Command\Build::factory($package, $optionsValue);
         try {
             $build->prepare();
             $build->createTempDir($package->getUniqueNameForFs());
             $build->configure($force_opts);
             $build->make();
             $this->saveBuildLogs($input, $build);
         } catch (\Exception $e) {
             if ($input->getOption('pack-logs')) {
                 $release->packLog($build);
             } else {
                 $this->saveBuildLogs($input, $build);
             }
             $output->writeln('The following error(s) happened: ' . $e->getMessage());
         }
         $args = array('build' => $build);
         try {
             $release->create($args);
             if ($input->getOption('pack-logs')) {
                 $release->packLog();
             }
         } catch (Exception $e) {
             if ($input->getOption('pack-logs')) {
                 $release->packLog();
             }
             $build->cleanup();
             throw new \Exception($e->getMessage());
         }
     } else {
         /* imply --source */
         try {
             $release->create();
             if ($input->getOption('pack-logs')) {
                 $release->packLog();
             }
         } catch (Exception $e) {
             if ($input->getOption('pack-logs')) {
                 $release->packLog();
             }
             throw new \Exception($e->getMessage());
         }
     }
 }
Example #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     Util\TmpDir::set($input->getOption('tmp-dir'));
     $helper = $this->getHelper('package');
     $cb = function (\Pickle\Base\Interfaces\Package $package) use($helper, $output) {
         $output->writeln('<info>Successfully converted ' . $package->getPrettyName() . '</info>');
         $helper->showInfo($output, $package);
     };
     $convert = Convert::factory($input->getArgument('path'), $cb);
     $convert->process();
 }
Example #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = rtrim($input->getArgument('path'), '/\\');
     $helper = $this->getHelper('package');
     Util\TmpDir::set($input->getOption('tmp-dir'));
     $cb = function (Interfaces\Package $package) use($helper, $output) {
         /* TODO Rework this to use the Info package command */
         $helper->showInfo($output, $package);
         $output->writeln(trim($package->getDescription()));
     };
     $validate = Validate::factory($path, $cb);
     $validate->process();
 }
Example #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     Util\TmpDir::set($input->getOption('tmp-dir'));
     $helper = $this->getHelper('package');
     $cb = function (Interfaces\Package\Info $info) use($helper, $output) {
         /* TODO The part of the helper showing package info plus the
            concrete info class implementation should be
            reworked. The concrete Info class should provide
            information for this callback, whereby the output
            format and how it is shown should be controleld by
            the helper. */
         $helper->showInfo($output, $info->getPackage());
         $output->writeln(['', trim($info->getPackage()->getDescription()), '']);
         $output->writeln('<info>Configure options</info>');
         $helper->showOptions($output, $info->getPackage());
     };
     $path = rtrim($input->getArgument('path'), DIRECTORY_SEPARATOR);
     $package = $helper->convey($input, $output, $path);
     $info = Info::factory($package, $cb);
     $info->show();
 }
Example #5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = rtrim($input->getArgument('path'), '/\\');
     Util\TmpDir::set($input->getOption('tmp-dir'));
     /* if windows, try bin install by default */
     if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
         $sourceRequested = $input->getOption('source');
         if (!$sourceRequested) {
             $this->binaryInstallWindows($path, $input, $output);
             return 0;
         }
     }
     $package = $this->getHelper('package')->convey($input, $output, $path);
     /* TODO Info package command should be used here. */
     $this->getHelper('package')->showInfo($output, $package);
     list($optionsValue, $force_opts) = $this->buildOptions($package, $input, $output);
     if ($input->getOption('dry-run')) {
         return 0;
     }
     $this->sourceInstall($package, $input, $output, $optionsValue, $force_opts);
     return 0;
 }
Example #6
0
 private function download($url)
 {
     $output = $this->output;
     $progress = $this->progress;
     $ctx = stream_context_create(array(), array('notification' => function ($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax) use($output, $progress) {
         switch ($notificationCode) {
             case STREAM_NOTIFY_FILE_SIZE_IS:
                 $progress->start($output, $bytesMax);
                 break;
             case STREAM_NOTIFY_PROGRESS:
                 $progress->setCurrent($bytesTransferred);
                 break;
         }
     }));
     $output->writeln("downloading {$url} ");
     $fileContents = file_get_contents($url, false, $ctx);
     $progress->finish();
     if (!$fileContents) {
         throw new \Exception('Cannot fetch <' . $url . '>');
     }
     $tmpdir = Util\TmpDir::get();
     $path = $tmpdir . DIRECTORY_SEPARATOR . basename($url);
     if (!file_put_contents($path, $fileContents)) {
         throw new \Exception('Cannot save temporary file <' . $path . '>');
     }
     return $path;
 }
Example #7
0
 public function deliver($target = '', $no_convert = false)
 {
     $target = $target ? realpath($target) : Util\TmpDir::get() . DIRECTORY_SEPARATOR . $this->command->getName();
     return $this->command->execute($target, $no_convert);
 }