예제 #1
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::bootstrapProcessWire($output);
     $modules = explode(",", $input->getArgument('modules'));
     foreach ($modules as $module) {
         // if module doesn't exist, download the module
         if (!$this->checkIfModuleExists($module)) {
             $output->writeln("<comment>Cannot find '{$module}' locally, trying to download...</comment>");
             $this->passOnToModuleDownloadCommand($module, $output, $input);
         }
         // check whether module is already installed
         if (\ProcessWire\wire('modules')->isInstalled($module)) {
             $output->writeln("<info>Module `{$module}` is already installed.</info>");
             exit(1);
         }
         // install module
         if (\ProcessWire\wire('modules')->getModule($module, array('noPermissionCheck' => true, 'noInit' => true))) {
             $output->writeln("<info>Module `{$module}` installed successfully.</info>");
         } else {
             $output->writeln("<error>Module `{$module}` does not exist.</error>");
         }
     }
 }
예제 #2
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::bootstrapProcessWire($output);
     $this->fs = new Filesystem();
     $this->output = $output;
     $modules = explode(",", $input->getArgument('modules'));
     if (!ini_get('allow_url_fopen')) {
         // check if we have the rights to download files from other domains
         // using copy or file_get_contents
         $this->output->writeln('The php config `allow_url_fopen` is disabled on the server. Enable it then try again.');
     } elseif (!is_writable(wire('config')->paths->siteModules)) {
         // check if module directory is writeable
         $this->output->writeln('Make sure your /site/modules directory is writeable by PHP.');
     } else {
         $github = $input->getOption('github');
         $branch = $input->getOption('branch');
         if (!empty($github)) {
             $branch = !empty($branch) ? $input->getOption('branch') : 'master';
             $github = 'https://github.com/' . $input->getOption('github') . '/archive/' . $branch . '.zip';
         }
         foreach ($modules as $module) {
             $this->output->writeln("\n<bg=yellow;options=bold> - Module '{$module}': </bg=yellow;options=bold>\n");
             if ($this->checkIfModuleExists($module)) {
                 $this->output->writeln(" <error> Module '{$module}' already exists! </error>\n");
             } else {
                 // reset PW modules cache
                 wire('modules')->resetCache();
                 if (isset($github)) {
                     $this->downloadModule($module, $github);
                 } else {
                     $this->downloadModuleIfExists($module);
                 }
             }
         }
         wire('modules')->resetCache();
     }
 }
예제 #3
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::bootstrapProcessWire($output);
     if (!\ProcessWire\wire('config')->moduleServiceKey) {
         throw new \RuntimeException('No module service key was found.');
     }
     if ($input->getArgument('modules') && !$input->getOption('check')) {
         // upgrade specific modules
         $modules = explode(",", $input->getArgument('modules'));
         if ($modules) {
             $this->upgradeModules($modules, $output);
         }
     } else {
         \ProcessWire\wire('modules')->resetCache();
         if ($moduleVersions = parent::getModuleVersions(true, $output)) {
             $output->writeln("<info>An upgrade is available for:</info>");
             foreach ($moduleVersions as $name => $info) {
                 $output->writeln("  - {$name}: {$info['local']} -> {$info['remote']}");
             }
         } else {
             $output->writeln("<info>Your modules are up-to-date.</info>");
         }
     }
 }
예제 #4
0
 /**
  * @return string
  */
 protected function getModuleDirectory()
 {
     $modDir = getcwd() . parent::getModuleDirectory();
     return $modDir;
 }