protected function unzip($zip, $path) { // build the temporary folder path $tmp = $this->tmp(preg_replace('!.zip$!', '', $zip)); // extract the zip file util::unzip($zip, $tmp); // get the list of directories within our tmp folder $dirs = glob($tmp . '/*'); // get the source directory from the tmp folder if (isset($dirs[0]) && is_dir($dirs[0])) { $source = $dirs[0]; } else { throw new RuntimeException('The source directory could not be found'); } // create the folder if it does not exist yet if (!is_dir($path)) { mkdir($path); } // extract the content of the directory to the final path foreach ((array) array_diff(scandir($source), ['.', '..']) as $name) { if (!rename($source . '/' . $name, $path . '/' . $name)) { throw new RuntimeException($name . ' could not be copied'); } } // remove the zip file util::remove($zip); // remove the temporary folder util::remove($tmp); }
protected function execute(InputInterface $input, OutputInterface $output) { if ($this->isInstalled() === false) { throw new RuntimeException('There seems to be no valid Kirby installation in this folder!'); } $output->writeln('<info>Updating Kirby...</info>'); $output->writeln(''); // check if the panel is installed at all $hasPanel = is_dir($this->dir() . '/panel'); // start updating the core $output->writeln('Updating the core...'); // remove the old folder util::remove($this->dir() . '/kirby'); // update the core $this->install(['repo' => 'getkirby/kirby', 'branch' => $input->getOption('dev') ? 'develop' : 'master', 'path' => $this->dir() . '/kirby', 'output' => $output]); // still has the old toolkit submodule if (is_dir($this->dir() . '/kirby/toolkit')) { // start updating the toolkit $output->writeln('Updating the toolkit...'); // remove the toolkit folder first util::remove($this->dir() . '/kirby/toolkit'); // update the toolkit $this->install(['repo' => 'getkirby/toolkit', 'branch' => $input->getOption('dev') ? 'develop' : 'master', 'path' => $this->dir() . '/kirby/toolkit', 'output' => $output]); } if ($hasPanel) { // start updating the panel $output->writeln('Updating the panel...'); // remove the old panel folder first util::remove($this->dir() . '/panel'); // update the panel $this->install(['repo' => 'getkirby/panel', 'branch' => $input->getOption('dev') ? 'develop' : 'master', 'path' => $this->dir() . '/panel', 'output' => $output]); } $output->writeln('<comment>Kirby has been updated to: ' . $this->version() . '!</comment>'); $output->writeln(''); }
protected function dev($input, $output, $kit) { $path = $input->getArgument('path'); $this->install(['repo' => 'getkirby/' . $kit, 'branch' => 'master', 'path' => $path, 'output' => $output]); util::remove(realpath($path) . '/panel'); util::remove(realpath($path) . '/kirby'); $output->writeln('Installing the core developer preview...'); $this->install(['repo' => 'getkirby/kirby', 'branch' => 'develop', 'path' => $path . '/kirby', 'output' => $output]); $output->writeln('Installing the panel developer preview...'); $this->install(['repo' => 'getkirby/panel', 'branch' => 'develop', 'path' => $path . '/panel', 'output' => $output]); $output->writeln('<comment>The developer preview has been installed!</comment>'); $output->writeln(''); }