mirror of
https://github.com/bitinflow/bunny-cli.git
synced 2026-03-13 13:45:54 +00:00
Improve caching, performance and add dry-run
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Bunny\Filesystem\CompareOptions;
|
||||
use App\Bunny\Filesystem\EdgeStorage;
|
||||
use App\Bunny\Filesystem\Exceptions\FilesystemException;
|
||||
use App\Bunny\Filesystem\FileCompare;
|
||||
use App\Bunny\Filesystem\LocalStorage;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
@@ -16,7 +18,11 @@ class DeployCommand extends Command
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'deploy
|
||||
{--dir=dist : Root directory to upload}';
|
||||
{--dir=dist : Root directory to upload}
|
||||
{--no-sha256-cache : Skips .well-known/bunny.sha256 and queries the storage endpoints recursively instead}
|
||||
{--no-sha256-generation : Skips .well-known/bunny.sha256 generation}
|
||||
{--sha256-name=.well-known/bunny.sha256 : Change filename of .well-known/bunny.sha256}
|
||||
{--dry-run : Outputs the operations but will not execute anything}';
|
||||
|
||||
/**
|
||||
* The description of the command.
|
||||
@@ -34,9 +40,11 @@ class DeployCommand extends Command
|
||||
{
|
||||
$start = microtime(true);
|
||||
|
||||
$edgeStorage = new EdgeStorage();
|
||||
$localStorage = new LocalStorage();
|
||||
$fileCompare = new FileCompare($localStorage, $edgeStorage, $this);
|
||||
$fileCompare = new FileCompare(
|
||||
app(LocalStorage::class),
|
||||
app(EdgeStorage::class),
|
||||
$this
|
||||
);
|
||||
|
||||
$localPath = realpath($path = $this->option('dir') ?? 'dist');
|
||||
|
||||
@@ -47,7 +55,23 @@ class DeployCommand extends Command
|
||||
|
||||
$edgePath = sprintf('/%s', config('bunny.storage.username'));
|
||||
|
||||
$fileCompare->compare($localPath, $edgePath, $start);
|
||||
if ($this->option('dry-run')) {
|
||||
$this->warn('⚠ Dry run is activated. The operations are displayed but not executed.');
|
||||
}
|
||||
|
||||
try {
|
||||
$fileCompare->compare($localPath, $edgePath, [
|
||||
CompareOptions::START => $start,
|
||||
CompareOptions::NO_SHA256_CACHE => $this->option('no-sha256-cache'),
|
||||
CompareOptions::NO_SHA256_GENERATION => $this->option('no-sha256-generation'),
|
||||
CompareOptions::SHA256_NAME => $this->option('sha256-name'),
|
||||
CompareOptions::DRY_RUN => $this->option('dry-run'),
|
||||
]);
|
||||
} catch (FilesystemException $exception) {
|
||||
$this->error($exception->getMessage());
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user