diff --git a/src/Console/FetchDataFromOzu.php b/src/Console/FetchDataFromOzu.php index 1d8fe92..9144640 100644 --- a/src/Console/FetchDataFromOzu.php +++ b/src/Console/FetchDataFromOzu.php @@ -12,7 +12,7 @@ class FetchDataFromOzu extends Command { - protected $signature = 'ozu:fetch-ozu-data'; + protected $signature = 'ozu:fetch-ozu-data {--force : Do not ask for confirmation} {--withoutAssets : Do not download assets}'; protected $aliases = ['ozu:fetch-data', 'ozu:pull']; @@ -26,14 +26,16 @@ class FetchDataFromOzu extends Command public function handle(Client $ozuClient): int { - - $this->warn('⚠️ This action will erase your local database and assets.'); - - if (!confirm( - 'Are you sure you want to continue? This cannot be undone.', - default: false, - )) { - return self::SUCCESS; + $this->newLine(2); + $this->warn('⚠️ This action will erase your local database and assets.'); + + if (!$this->option('force')) { + if (!confirm( + 'Are you sure you want to continue? This cannot be undone.', + default: false, + )) { + return self::SUCCESS; + } } $this->initializePaths($ozuClient); @@ -46,12 +48,14 @@ public function handle(Client $ozuClient): int return self::FAILURE; } - if (!$this->downloadAssets($ozuClient)) { - return self::FAILURE; - } + if (!$this->option('withoutAssets')) { + if (!$this->downloadAssets($ozuClient)) { + return self::FAILURE; + } - if (!$this->extractAssets()) { - return self::FAILURE; + if (!$this->extractAssets()) { + return self::FAILURE; + } } $this->cleanTemporaryFiles(); diff --git a/src/OzuServiceProvider.php b/src/OzuServiceProvider.php index 807fffc..9f323e9 100644 --- a/src/OzuServiceProvider.php +++ b/src/OzuServiceProvider.php @@ -50,16 +50,16 @@ public function register() $this->app->bind(Paginator::class, StaticPaginator::class); $this->app->bind(LengthAwarePaginator::class, StaticLengthAwarePaginator::class); $this->app->bind(Thumbnail::class, function ($app) { - if (!$app->environment('production') || !config('ozu-client.cdn_url')) { + if (!config('ozu-client.cdn_url')) { + // if no CDN URL is set, use the local storage return $app->make(LocalThumbnail::class); } - // Have to rely on the URL to determine the CDN provider for now, - // because we are limited to 10 params for the deployment script :/ if (str(config('ozu-client.cdn_url'))->contains('kxcdn.com')) { return $app->make(KeyCdnThumbnail::class); } + // ImageKit CDN also serves as a fallback return $app->make(ImageKitThumbnail::class); }); } diff --git a/src/Support/Thumbnails/LocalThumbnail.php b/src/Support/Thumbnails/LocalThumbnail.php index cb6d8f6..7dc9edf 100644 --- a/src/Support/Thumbnails/LocalThumbnail.php +++ b/src/Support/Thumbnails/LocalThumbnail.php @@ -5,7 +5,7 @@ use Illuminate\Contracts\Filesystem\FileNotFoundException; use Illuminate\Filesystem\FilesystemManager; use Illuminate\Support\Str; -use Intervention\Image\Drivers\Imagick\Driver; +use Intervention\Image\Drivers\Gd\Driver; use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\ImageManager;