88use Symfony \Component \Process \Process ;
99use ZipArchive ;
1010
11+ use function Laravel \Prompts \confirm ;
12+
1113class FetchDataFromOzu extends Command
1214{
1315 protected $ signature = 'ozu:fetch-ozu-data ' ;
1416
17+ protected $ aliases = ['ozu:fetch-data ' , 'ozu:pull ' ];
18+
1519 protected $ description = 'Gets Ozu’s CMS data and replaces your local database and assets with it. ' ;
1620
1721 private string $ databaseDumpPath ;
@@ -23,13 +27,16 @@ class FetchDataFromOzu extends Command
2327 public function handle (Client $ ozuClient ): int
2428 {
2529
26- $ this ->warn ('/! \\ This action will erase your local database and assets. ' );
30+ $ this ->warn ('⚠️ This action will erase your local database and assets. ' );
2731
28- if (!$ this ->confirm ('Are you sure you want to continue? This cannot be undone. ' )) {
32+ if (!confirm (
33+ 'Are you sure you want to continue? This cannot be undone. ' ,
34+ default: false ,
35+ )) {
2936 return self ::SUCCESS ;
3037 }
3138
32- $ this ->initializePaths ();
39+ $ this ->initializePaths ($ ozuClient );
3340
3441 if (!$ this ->downloadDatabase ($ ozuClient )) {
3542 return self ::FAILURE ;
@@ -53,11 +60,12 @@ public function handle(Client $ozuClient): int
5360 return self ::SUCCESS ;
5461 }
5562
56- private function initializePaths (): void
63+ private function initializePaths (Client $ ozuClient ): void
5764 {
65+ $ websiteKey = config ('ozu-client.website_key ' ) ?? $ ozuClient ->getWebsiteKey ();
5866 $ this ->databaseDumpPath = storage_path ('app/tmp/ozu.sql ' );
5967 $ this ->assetsZipPath = storage_path ('app/tmp/ozu-assets.zip ' );
60- $ this ->assetsExtractPath = storage_path ('app/public/data/ ' .config ( ' ozu-client.website_key ' ) .'/ ' );
68+ $ this ->assetsExtractPath = storage_path ('app/public/data/ ' .$ websiteKey .'/ ' );
6169 }
6270
6371 private function downloadDatabase (Client $ ozuClient ): bool
0 commit comments