diff --git a/resources/build/build.php b/resources/build/build.php new file mode 100644 index 0000000..5ec23ac --- /dev/null +++ b/resources/build/build.php @@ -0,0 +1,120 @@ +" --catch ERR_ALL="btw_license_error" "*.php"', + LICENSE_FILE, + PROJECT_ID, + PROJECT_KEY +); +system($sgCommand); + +echo 'Creating the release archive...' . PHP_EOL . PHP_EOL; + +// Initialize archive object +$zip = new ZipArchive(); +$zip->open(sprintf('%s/blue-twilight_%s.zip', dirname($appRoot), $argv[1]), ZipArchive::CREATE | ZipArchive::OVERWRITE); + +/** @var SplFileInfo[] $files */ +$files = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($appRoot), + RecursiveIteratorIterator::LEAVES_ONLY +); + +foreach ($files as $name => $file) +{ + // Skip directories (they will be added automatically) and unnecessary files + if (!$file->isDir()) + { + // Get real and relative path for current file + $filePath = $file->getRealPath(); + $relativePath = substr($filePath, strlen($appRoot) + 1); + + // See if the file matches any of ignore patterns + $includeFile = true; + if ( + strlen($relativePath) < strlen('vendor') || + substr($relativePath, 0, strlen('vendor')) != 'vendor' + ) + { + array_walk($ignoredFiles, function ($value) use ($relativePath, &$includeFile) + { + $includeFile &= !(preg_match('/^' . preg_quote($value, '/') . '$/', $relativePath)); + }); + } + + // Add to the archive + if ($includeFile) + { + $zip->addFile($filePath, sprintf('blue-twilight_%s/%s', $argv[1], $relativePath)); + } + } +} + +$zip->close(); + +echo PHP_EOL . PHP_EOL; +echo 'All done!'; +echo PHP_EOL . PHP_EOL; +exit(); + +?>