Example #1
0
 /**
  * execute
  *
  * @return  void
  */
 public function execute()
 {
     $this->exec("php -r \"readfile('https://getcomposer.org/installer');\" | php");
     rename('composer.phar', BUILD_ROOT . '/composer.phar');
     $this->exec(sprintf('php %s/composer.phar install', BUILD_ROOT));
     $this->out('>> Remove composer.phar');
     unlink(sprintf('%s/composer.phar', BUILD_ROOT));
     $this->out('>> Writing .gitignore');
     file_put_contents(BUILD_ROOT . '/.gitignore', $this->gitignore);
     include BUILD_ROOT . '/vendor/autoload.php';
     $dir = new \Windwalker\Filesystem\Path\PathLocator(BUILD_ROOT);
     $zip = new ZipArchive();
     @unlink(BUILD_ROOT . '/../rad.zip');
     $zip->open(BUILD_ROOT . '/../rad.zip', ZIPARCHIVE::CREATE);
     foreach ($dir->getFiles(true) as $file) {
         $file = str_replace(BUILD_ROOT . DIRECTORY_SEPARATOR, '', $file->getPathname());
         if (strpos($file, '.') === 0 && $file != '.gitignore') {
             continue;
         }
         $this->out('Zip file: ' . $file);
         $zip->addFile($file);
     }
     $zip->close();
     $this->out('Zip success to: ' . realpath(BUILD_ROOT . '/../rad.zip'));
 }
Example #2
0
 /**
  * execute
  *
  * @return  void
  */
 public function execute()
 {
     // Prepare zip name.
     $zipFile = BUILD_ROOT . '/../windwalker-rad-%s.zip';
     $version = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : null;
     if (!$version) {
         $this->out('Please enter a version.');
         $this->out('[Usage] php build.php <version>');
         exit;
     }
     // Remove unnecessary files and folders.
     $this->removeFiles();
     // Prepare load composer
     $this->exec("php -r \"readfile('https://getcomposer.org/installer');\" | php");
     rename('composer.phar', BUILD_ROOT . '/composer.phar');
     $this->exec(sprintf('php %s/composer.phar install', BUILD_ROOT));
     $this->out('>> Remove composer.phar');
     unlink(sprintf('%s/composer.phar', BUILD_ROOT));
     // Include dependency to do more things.
     include BUILD_ROOT . '/vendor/autoload.php';
     $zipFile = new \SplFileInfo(\Windwalker\Filesystem\Path::clean(sprintf($zipFile, $version)));
     $dir = new \Windwalker\Filesystem\Path\PathLocator(BUILD_ROOT);
     // Start ZIP archive
     $zip = new ZipArchive();
     @unlink($zipFile->getPathname());
     $zip->open($zipFile->getPathname(), ZIPARCHIVE::CREATE);
     foreach ($dir->getFiles(true) as $file) {
         $file = str_replace(BUILD_ROOT . DIRECTORY_SEPARATOR, '', $file->getPathname());
         if (strpos($file, '.') === 0) {
             continue;
         }
         $this->out('[Zip file] ' . $file);
         $zip->addFile(str_replace('\\', '/', $file));
     }
     $zip->close();
     $this->out('Zip success to: ' . realpath($zipFile->getPathname()));
 }