2016-10-06 12:48:04 +01:00
|
|
|
<?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;
|
|
|
|
|
2016-10-06 16:37:35 +01:00
|
|
|
if ($argc != 3)
|
|
|
|
{
|
|
|
|
echo sprintf('Usage: %s [version_number] [output_directory]', $argv[0]) . PHP_EOL . PHP_EOL;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2016-10-06 12:48:04 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2016-10-20 09:18:29 +01:00
|
|
|
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)));
|
|
|
|
|
2016-10-06 12:48:04 +01:00
|
|
|
echo 'Downloading Composer...' . PHP_EOL . PHP_EOL;
|
|
|
|
|
|
|
|
copy('https://getcomposer.org/installer', 'composer-setup.php');
|
|
|
|
if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { 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
|
2016-10-27 13:04:37 +01:00
|
|
|
system(sprintf('rm -rf %s/.idea', $appRoot));
|
2016-10-06 12:48:04 +01:00
|
|
|
system(sprintf('rm -rf %s/resources/build', $appRoot));
|
|
|
|
system(sprintf('rm -rf %s/tests', $appRoot));
|
2016-10-06 15:07:30 +01:00
|
|
|
@unlink(sprintf('%s/composer.phar', $appRoot));
|
2016-10-06 12:48:04 +01:00
|
|
|
@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(
|
2016-10-06 13:25:50 +01:00
|
|
|
'/usr/local/sourceguardian/bin/sourceguardian --phpversion "5.6" --phpversion "7.0" --external "%s" --projid "%s" --projkey "%s" ' .
|
2016-10-06 12:48:04 +01:00
|
|
|
'--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);
|
2016-10-06 16:37:35 +01:00
|
|
|
|
|
|
|
echo 'Creating the release archive...' . PHP_EOL . PHP_EOL;
|
2016-10-27 12:50:46 +01:00
|
|
|
system('git add --force vendor/');
|
2016-10-06 16:37:35 +01:00
|
|
|
system('git stash');
|
|
|
|
system(sprintf('git archive --format zip --output %1$s/blue-twilight_%2$s.zip --prefix=blue-twilight_%2$s/ "stash@{0}"', $argv[2], $argv[1]));
|
|
|
|
system('git stash pop');
|
|
|
|
|
2016-10-06 12:48:04 +01:00
|
|
|
echo PHP_EOL . PHP_EOL;
|
|
|
|
echo 'All done!';
|
2016-10-06 16:37:35 +01:00
|
|
|
echo PHP_EOL . PHP_EOL;
|
2016-10-06 12:48:04 +01:00
|
|
|
exit();
|
|
|
|
|
|
|
|
?>
|