Skip to content

Commit 4051423

Browse files
committed
feat: add erag:update-manifest console command
1 parent 69bc2a4 commit 4051423

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

src/Commands/PWACommand.php

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,15 @@
88

99
class PWACommand extends Command
1010
{
11+
protected $signature = 'erag:update-manifest';
12+
13+
protected $description = 'Update the manifest.json file for the PWA.';
14+
1115
public function __construct(protected PWAService $pwaService)
1216
{
1317
parent::__construct();
1418
}
1519

16-
/**
17-
* The name and signature of the console command.
18-
*
19-
* @var string
20-
*/
21-
protected $signature = 'erag:update-manifest';
22-
23-
/**
24-
* The console command description.
25-
*
26-
* @var string
27-
*/
28-
protected $description = 'Update the manifest.json file for the PWA.';
29-
30-
/**
31-
* Execute the console command.
32-
*/
3320
public function handle(): void
3421
{
3522
try {
@@ -49,24 +36,22 @@ public function handle(): void
4936
],
5037
];
5138

52-
// Load custom manifest from config, fallback to default
5339
$manifest = Config::get('pwa.manifest', $defaultManifest);
5440

5541
if (empty($manifest['icons'])) {
56-
$this->error('Manifest is missing icons. Aborting operation.');
57-
42+
$this->error('⚠️ Manifest is missing icons. Operation aborted.');
5843
return;
5944
}
6045

61-
if ($this->pwaService->createOrUpdate($manifest)) {
62-
$this->info('Manifest JSON updated successfully ✔');
63-
}
64-
65-
$this->info('Failed to write the manifest file.');
46+
$updated = $this->pwaService->createOrUpdate($manifest);
6647

67-
} catch (\Exception $e) {
68-
// Catch any errors and display an error message
69-
$this->error('An error occurred while updating the manifest: '.$e->getMessage());
48+
if ($updated) {
49+
$this->info('✅ Manifest JSON updated successfully.');
50+
} else {
51+
$this->warn('⚠️ Manifest file was not updated.');
52+
}
53+
} catch (\Throwable $e) {
54+
$this->error('❌ An error occurred while updating the manifest: '.$e->getMessage());
7055
}
7156
}
7257
}

0 commit comments

Comments
 (0)