Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output size of application before compression #186

Merged
merged 3 commits into from
Jun 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/BuildProcess/CompressApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Laravel\VaporCli\BuiltApplicationFiles;
use Laravel\VaporCli\Helpers;
use Laravel\VaporCli\Manifest;
use Laravel\VaporCli\Path;
use Symfony\Component\Process\Process;
use ZipArchive;

Expand All @@ -23,12 +24,15 @@ public function __invoke()
return;
}

Helpers::step('<options=bold>Compressing Application</>');
$appSizeInBytes = $this->getDirectorySize(Path::app());
$appSizeInMegabytes = round($appSizeInBytes / 1048576, 2);

Helpers::step('<options=bold>Compressing Application</> ('.$appSizeInMegabytes.'MB)');

if (PHP_OS == 'Darwin') {
$this->compressApplicationOnMac();

return $this->ensureArchiveIsWithinSizeLimits();
return $this->ensureArchiveIsWithinSizeLimits($appSizeInBytes);
}

$archive = new ZipArchive();
Expand All @@ -49,7 +53,7 @@ public function __invoke()

$archive->close();

$this->ensureArchiveIsWithinSizeLimits();
$this->ensureArchiveIsWithinSizeLimits($appSizeInBytes);
}

/**
Expand Down Expand Up @@ -78,11 +82,12 @@ protected function getPermissions($file)
/**
* Ensure the application archive is within supported size limits.
*
* @param float $bytes
* @return void
*/
protected function ensureArchiveIsWithinSizeLimits()
protected function ensureArchiveIsWithinSizeLimits($bytes)
{
$size = ceil($this->getDirectorySize($this->buildPath.'/app') / 1048576);
$size = ceil($bytes / 1048576);

if ($size > 250) {
Helpers::line();
Expand Down