Removed the build script as this is stored in Deploy

This commit is contained in:
Andy Heathershaw 2016-11-06 17:45:23 +00:00
parent 24d9c318cb
commit 3580fb9b62

View File

@ -1,115 +0,0 @@
<?php
define('PROJECT_ID', 'blue-twilight');
define('PROJECT_KEY', 's7Ebes37ChACHeC8A8AzAXUswestuZ8v');
define('LICENSE_FILE', 'blue-twilight.lic');
echo 'Blue Twilight Packaging Script' . PHP_EOL;
echo '(c) Andy Heathershaw 2016' . PHP_EOL;
echo '------------------------------' . PHP_EOL . PHP_EOL;
if ($argc != 3)
{
echo sprintf('Usage: %s [version_number] [output_directory]', $argv[0]) . PHP_EOL . PHP_EOL;
exit(1);
}
echo 'Checking current folder...' . PHP_EOL . PHP_EOL;
$appRoot = dirname(dirname(__DIR__));
if (getcwd() != $appRoot)
{
echo sprintf('The build script must be run in the application root - %s', $appRoot) . PHP_EOL;
exit();
}
echo 'Updating app.version config value...' . PHP_EOL . PHP_EOL;
$appConfigFile = sprintf('%s/config/app.php', $appRoot);
file_put_contents($appConfigFile, str_replace('**DEV**', $argv[1], file_get_contents($appConfigFile)));
echo 'Downloading Composer...' . PHP_EOL . PHP_EOL;
copy('https://getcomposer.org/installer', 'composer-setup.php');
if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('https://composer.github.io/installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); exit; } echo PHP_EOL;
system('php composer-setup.php');
unlink('composer-setup.php');
echo 'Installing dependencies using Composer...' . PHP_EOL . PHP_EOL;
system('./composer.phar install');
echo PHP_EOL;
echo 'Removing environment-related files...' . PHP_EOL . PHP_EOL;
@unlink(sprintf('%s/.env', $appRoot));
system(sprintf('rm -rf %s/storage/app/*', $appRoot));
system(sprintf('rm -rf %s/storage/framework/cache/*.log', $appRoot));
system(sprintf('rm -rf %s/storage/framework/sessions/*.log', $appRoot));
system(sprintf('rm -rf %s/storage/framework/views/*.log', $appRoot));
system(sprintf('rm -rf %s/storage/logs/*.log', $appRoot));
echo 'Removing build files...' . PHP_EOL . PHP_EOL;
// Remove development-related files
system(sprintf('rm -rf %s/.idea', $appRoot));
system(sprintf('rm -rf %s/resources/build', $appRoot));
system(sprintf('rm -rf %s/tests', $appRoot));
@unlink(sprintf('%s/composer.phar', $appRoot));
@unlink(sprintf('%s/server.php', $appRoot));
// Can't use Artisan once encoded
@unlink(sprintf('%s/artisan', $appRoot));
// We don't use Gulp or PHPUnit (yet, maybe one day!)
@unlink(sprintf('%s/gulpfile.js', $appRoot));
@unlink(sprintf('%s/package.json', $appRoot));
@unlink(sprintf('%s/phpunit.xml', $appRoot));
// The Readme.md is currently Laravel's, not our own, so get rid
@unlink(sprintf('%s/readme.md', $appRoot));
echo 'Licensing and encoding the application using Source Guardian...' . PHP_EOL . PHP_EOL;
$sgCommand = sprintf(
'/usr/local/sourceguardian/bin/sourceguardian --phpversion "5.6" --phpversion "7.0" --external "%s" --projid "%s" --projkey "%s" ' .
'--stop-on-error --strict-errors --deprec-errors -x "*.blade.php" -x "vendor/*.php" -x "public/raw/*.php" ' .
'-x public/license-required.php -x public/loader-required.php -x "storage/*" -r -b- ' .
'-p @./public/raw/sg-license-error.php -j "<?php btw_loader_error(); ?>" --catch ERR_ALL="btw_license_error" "*.php"',
LICENSE_FILE,
PROJECT_ID,
PROJECT_KEY
);
system($sgCommand);
echo 'Creating the release archive...' . PHP_EOL . PHP_EOL;
$rootPath = dirname(dirname(__DIR__));
// Initialize archive object
$zip = new ZipArchive();
$zip->open(sprintf('%s/blue-twilight_%s.zip', $argv[1], $argv[0]), ZipArchive::CREATE | ZipArchive::OVERWRITE);
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file)
{
// Skip directories (they will be added automatically)
if (!$file->isDir())
{
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
// Add current file to archive
$zip->addFile($filePath, $relativePath);
}
}
$zip->close();
echo PHP_EOL . PHP_EOL;
echo 'All done!';
echo PHP_EOL . PHP_EOL;
exit();
?>