Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $packages = [];
     foreach ((array) $this->argument('packages') as $package) {
         $path = $this->container->get('path.packages') . '/' . $package . '/composer.json';
         if (file_exists($path)) {
             $info = json_decode(file_get_contents($path), true);
         }
         if (isset($info['require']) && is_array($info['require'])) {
             $packages = array_merge($packages, $info['require']);
         }
     }
     $config = [];
     foreach (['path.temp', 'path.cache', 'path.vendor', 'path.artifact', 'path.packages', 'system.api'] as $key) {
         $config[$key] = $this->container->get($key);
     }
     $composer = new Composer($config, $output);
     $composer->install($packages, true, false, $this->option('prefer-source'));
 }
Example #2
0
 /**
  * @param  array $uninstall
  * @return bool
  */
 public function uninstall($uninstall)
 {
     foreach ((array) $uninstall as $name) {
         if (!($package = App::package($name))) {
             throw new \RuntimeException(__('Unable to find "%name%".', ['%name%' => $name]));
         }
         $this->disable($package);
         $this->getScripts($package)->uninstall();
         App::config('system')->remove('packages.' . $package->get('module'));
         if ($this->composer->isInstalled($package->getName())) {
             $this->composer->uninstall($package->getName());
         } else {
             if (!($path = $package->get('path'))) {
                 throw new \RuntimeException(__('Package path is missing.'));
             }
             $this->output->writeln(__("Removing package folder."));
             App::file()->delete($path);
             @rmdir(dirname($path));
         }
     }
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $this->container->path();
     $vers = $this->container->version();
     $filter = '/' . implode('|', $this->excludes) . '/i';
     $packages = ['pagekit/blog' => '*', 'pagekit/theme-one' => '*'];
     $config = [];
     foreach (['path.temp', 'path.cache', 'path.vendor', 'path.artifact', 'path.packages', 'system.api'] as $key) {
         $config[$key] = $this->container->get($key);
     }
     $composer = new Composer($config, $output);
     $composer->install($packages);
     $this->line(sprintf('Starting: webpack'));
     exec('webpack -p');
     $this->line(sprintf('Building Package.'));
     $finder = Finder::create()->files()->in($path)->ignoreVCS(true)->filter(function ($file) use($filter) {
         return !preg_match($filter, $file->getRelativePathname());
     });
     $zip = new \ZipArchive();
     if (true !== $zip->open($zipFile = "{$path}/pagekit-{$vers}.zip", \ZipArchive::CREATE | \ZipArchive::OVERWRITE)) {
         $this->abort("Can't open ZIP extension in '{$zipFile}'");
     }
     foreach ($finder as $file) {
         $zip->addFile($file->getPathname(), $file->getRelativePathname());
     }
     $zip->addFile("{$path}/.bowerrc", '.bowerrc');
     $zip->addFile("{$path}/.htaccess", '.htaccess');
     $zip->addEmptyDir('tmp/');
     $zip->addEmptyDir('tmp/cache');
     $zip->addEmptyDir('tmp/temp');
     $zip->addEmptyDir('tmp/logs');
     $zip->addEmptyDir('tmp/sessions');
     $zip->addEmptyDir('tmp/packages');
     $zip->close();
     $name = basename($zipFile);
     $size = filesize($zipFile) / 1024 / 1024;
     $this->line(sprintf('Build: %s (%.2f MB)', $name, $size));
 }