diff --git a/src/BuildProcess/CompressApplication.php b/src/BuildProcess/CompressApplication.php index 2c7dd4e8..8620650b 100644 --- a/src/BuildProcess/CompressApplication.php +++ b/src/BuildProcess/CompressApplication.php @@ -31,13 +31,14 @@ public function __invoke() if (PHP_OS == 'Darwin') { $this->compressApplicationOnMac(); + $this->ensureCompressedApplicationSizeIsWithinSizeLimits($this->getCompressedApplicationSizeInBytes()); return $this->ensureArchiveIsWithinSizeLimits($appSizeInBytes); } $archive = new ZipArchive(); - $archive->open($this->buildPath.'/app.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE); + $archive->open($this->getCompressedApplicationPath(), ZipArchive::CREATE | ZipArchive::OVERWRITE); foreach (BuiltApplicationFiles::get($this->appPath) as $file) { $relativePathName = str_replace('\\', '/', $file->getRelativePathname()); @@ -53,9 +54,31 @@ public function __invoke() $archive->close(); + $this->ensureCompressedApplicationSizeIsWithinSizeLimits($this->getCompressedApplicationSizeInBytes()); + $this->ensureArchiveIsWithinSizeLimits($appSizeInBytes); } + /** + * Get the full path of the compressed application (zip file). + * + * @return string + */ + protected function getCompressedApplicationPath() + { + return $this->buildPath.'/app.zip'; + } + + /** + * Get the size of the zip file in bytes. + * + * @return int + */ + protected function getCompressedApplicationSizeInBytes() + { + return filesize($this->getCompressedApplicationPath()); + } + /** * Utilize the "zip" utility to compress the application. * @@ -63,7 +86,7 @@ public function __invoke() */ protected function compressApplicationOnMac() { - (new Process(['zip', '-r', $this->buildPath.'/app.zip', '.'], $this->appPath))->mustRun(); + (new Process(['zip', '-r', $this->getCompressedApplicationPath(), '.'], $this->appPath))->mustRun(); } /** @@ -80,7 +103,7 @@ protected function getPermissions($file) } /** - * Ensure the application archive is within supported size limits. + * Ensure the uncompressed application archive is within supported size limits. * * @param float $bytes * @return void @@ -95,6 +118,22 @@ protected function ensureArchiveIsWithinSizeLimits($bytes) } } + /** + * Ensure the compressed application is within supported size limits. + * + * @param float $bytes + * @return void + */ + protected function ensureCompressedApplicationSizeIsWithinSizeLimits($bytes) + { + $size = ceil($bytes / 1048576); + + if ($size > 50) { + Helpers::line(); + Helpers::abort('Compressed application is greater than 50MB. Your compressed application is '.$size.'MB.'); + } + } + /** * Get the size of the given directory. * diff --git a/src/BuildProcess/ValidateManifest.php b/src/BuildProcess/ValidateManifest.php index 976de699..4745522d 100644 --- a/src/BuildProcess/ValidateManifest.php +++ b/src/BuildProcess/ValidateManifest.php @@ -32,7 +32,7 @@ protected function warnAboutDeprecations() Helpers::warn( '- The "separate-vendor" option is deprecated.' .' Please use Docker based deployments instead:' - .' https://docs.vapor.build/1.0/projects/environments.html#runtime' + .' https://docs.vapor.build/projects/environments#docker-runtimes' ); } @@ -45,14 +45,14 @@ protected function warnAboutDeprecations() ])) { Helpers::warn( 'The runtimes "php-7.3", "php-7.4", "php-7.4:al2", "php-7.4:imagick", and "php-8.0" are deprecated and will no longer be supported or receiving any updates.' - .' For a full list of supported runtimes, please see: https://docs.vapor.build/1.0/projects/environments.html#runtime' + .' For a full list of supported runtimes, please see: https://docs.vapor.build/projects/environments#runtime' ); } if (Manifest::runtime($this->environment) === 'php-8.0:al2') { Helpers::warn( 'The runtime "php-8.0:al2" is now deprecated and it is no longer possible to deploy new environments using this runtime. Support will be removed for existing runtimes on February 26, 2024.' - .' For a full list of supported runtimes, please see: https://docs.vapor.build/1.0/projects/environments.html#runtime' + .' For a full list of supported runtimes, please see: https://docs.vapor.build/projects/environments#runtime' ); } diff --git a/src/Solutions/EnvironmentVariableLimitReached.php b/src/Solutions/EnvironmentVariableLimitReached.php index f4d716cf..b5033461 100644 --- a/src/Solutions/EnvironmentVariableLimitReached.php +++ b/src/Solutions/EnvironmentVariableLimitReached.php @@ -44,7 +44,7 @@ public function applicable() public function all() { return [ - 'Use encrypted environment files in place of or in addition to environment variables: https://docs.vapor.build/1.0/projects/environments.html#encrypted-environment-files', + 'Use encrypted environment files in place of or in addition to environment variables: https://docs.vapor.build/projects/environments#encrypted-environment-files', ]; } } diff --git a/src/Solutions/FunctionExceedsMaximumAllowedSize.php b/src/Solutions/FunctionExceedsMaximumAllowedSize.php index 1dd4863b..ee78a436 100644 --- a/src/Solutions/FunctionExceedsMaximumAllowedSize.php +++ b/src/Solutions/FunctionExceedsMaximumAllowedSize.php @@ -49,7 +49,7 @@ public function all() .' Docker based deployments allow you to package and deploy applications up to 10GB in size.' .' When migrating an existing environment to a Docker runtime, please keep in mind that you won\'t be able to revert that environment to the default Vapor Lambda runtime later.' .' For that reason, you may want to create an environment for testing the Docker runtime first.' - .' https://docs.vapor.build/1.0/projects/environments.html#building-custom-docker-images', + .' https://docs.vapor.build/projects/environments#docker-runtimes', ]; } }