Skip to content

Commit b698ce3

Browse files
mikagrichgithub-actions[bot]
authored andcommitted
Fix styling
1 parent 4684091 commit b698ce3

File tree

11 files changed

+299
-176
lines changed

11 files changed

+299
-176
lines changed

packages/core/src/Console/Commands/MooxInstaller.php

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@
1313
use Moox\Core\Console\Traits\SelectFilamentPanel;
1414
use Moox\Core\Services\PackageService;
1515

16-
use function Laravel\Prompts\select;
1716
use function Laravel\Prompts\multiselect;
18-
use function Laravel\Prompts\alert;
19-
use function Laravel\Prompts\info;
20-
use function Laravel\Prompts\warning;
21-
use function Laravel\Prompts\text;
22-
use function Laravel\Prompts\password;
23-
17+
use function Laravel\Prompts\select;
2418

2519
class MooxInstaller extends Command
2620
{
@@ -33,7 +27,9 @@ class MooxInstaller extends Command
3327
SelectFilamentPanel;
3428

3529
protected $signature = 'moox:install';
30+
3631
protected $description = 'Install Moox Packages or generate Filament Panels.';
32+
3733
protected array $selectedPanels = [];
3834

3935
public function __construct(protected PackageService $packageService)
@@ -51,18 +47,19 @@ public function handle(): void
5147
label: 'What would you like to do?',
5248
options: [
5349
'packages' => '📦 Install Moox Packages',
54-
'panels' => '🖼️ Generate Filament Panels',
50+
'panels' => '🖼️ Generate Filament Panels',
5551
]
5652
);
5753

5854
if (! $this->checkForFilament(silent: true)) {
5955
$this->error('❌ Filament installation is required or was aborted.');
56+
6057
return;
6158
}
6259

6360
match ($choice) {
6461
'packages' => $this->runPackageInstallFlow(),
65-
'panels' => $this->runPanelGenerationFlow(),
62+
'panels' => $this->runPanelGenerationFlow(),
6663
};
6764
}
6865

@@ -73,6 +70,7 @@ protected function isPanelGenerationMode(): bool
7370
return true;
7471
}
7572
}
73+
7674
return false;
7775
}
7876

@@ -81,6 +79,7 @@ protected function runPackageInstallFlow(): void
8179
$available = $this->getPackagesFromComposerRequire();
8280
if (empty($available)) {
8381
$this->warn('⚠️ No Moox packages found in composer.json require.');
82+
8483
return;
8584
}
8685

@@ -96,6 +95,7 @@ protected function runPackageInstallFlow(): void
9695

9796
if (empty($selection)) {
9897
$this->warn('⚠️ No selection made. Aborting.');
98+
9999
return;
100100
}
101101

@@ -104,7 +104,7 @@ protected function runPackageInstallFlow(): void
104104
$selectedPanelKey = $this->determinePanelForPackage(implode(', ', $selection));
105105
$this->ensurePanelForKey($selectedPanelKey, $selectedPanelKey, false);
106106

107-
$providerPath = $this->panelMap[$selectedPanelKey]['path'] . '/' . ucfirst($selectedPanelKey) . 'PanelProvider.php';
107+
$providerPath = $this->panelMap[$selectedPanelKey]['path'].'/'.ucfirst($selectedPanelKey).'PanelProvider.php';
108108

109109
$changedAny = false;
110110
foreach ($selection as $package) {
@@ -120,19 +120,20 @@ protected function runPackageInstallFlow(): void
120120
$this->callSilent('package:discover');
121121
$this->callSilent('filament:upgrade');
122122
}
123-
124-
$this->info('🎉 Selected packages have been installed successfully: ' . implode(', ', $selection));
123+
124+
$this->info('🎉 Selected packages have been installed successfully: '.implode(', ', $selection));
125125
}
126126

127127
protected function getPackagesFromComposerRequire(): array
128128
{
129129
$composerPath = base_path('composer.json');
130-
if (!file_exists($composerPath)) {
130+
if (! file_exists($composerPath)) {
131131
return [];
132132
}
133133

134134
$json = json_decode(file_get_contents($composerPath), true);
135135
$require = $json['require'] ?? [];
136+
136137
return array_values(array_filter(array_keys($require), function ($pkg) {
137138
return is_string($pkg) && str_starts_with($pkg, 'moox/');
138139
}));
@@ -144,7 +145,7 @@ protected function runPanelGenerationFlow(): void
144145

145146
$existingPanels = $this->getExistingPanelsWithLogin();
146147

147-
if (!empty($existingPanels)) {
148+
if (! empty($existingPanels)) {
148149
$this->info('➡️ You can still create additional panels.');
149150
$this->error('❌ A panel with login already exists:');
150151
foreach ($existingPanels as $panelClass) {
@@ -156,6 +157,7 @@ protected function runPanelGenerationFlow(): void
156157

157158
if (empty($this->selectedPanels)) {
158159
$this->warn('⚠️ No panel selection made. Operation aborted.');
160+
159161
return;
160162
}
161163

@@ -174,32 +176,32 @@ protected function runPanelGenerationFlow(): void
174176
$this->info('✅ Moox Panels installed successfully. Enjoy! 🎉');
175177
}
176178

177-
178179
protected function determinePanelForPackage(string $package): string
179180
{
180181
$providerClasses = $this->getProviderClassesFromBootstrap();
181182

182183
$panelOptions = [];
183184
foreach ($providerClasses as $index => $class) {
184185
$key = $this->mapProviderClassToPanelKey($class);
185-
if (!$key) {
186+
if (! $key) {
186187
continue;
187188
}
188-
$uniqueKey = $key . '_' . $index;
189-
$panelOptions[$uniqueKey] = $key . ' (' . $class . ')';
189+
$uniqueKey = $key.'_'.$index;
190+
$panelOptions[$uniqueKey] = $key.' ('.$class.')';
190191
}
191192

192193
$panelChoice = select(
193194
label: "Would you like to register the package '{$package}' into an existing panel or create a new panel?",
194195
options: [
195196
'existing' => 'Existing Panel',
196-
'new' => 'Create New Panel',
197+
'new' => 'Create New Panel',
197198
]
198199
);
199200

200201
if ($panelChoice === 'existing') {
201202
if (empty($panelOptions)) {
202203
$this->warn('⚠️ No existing panels found. Creating a new panel instead.');
204+
203205
return $this->selectNewPanel([]);
204206
}
205207

@@ -213,6 +215,7 @@ protected function determinePanelForPackage(string $package): string
213215
$existingKeys = array_values(array_filter(array_map(function ($class) {
214216
return $this->mapProviderClassToPanelKey($class);
215217
}, $providerClasses)));
218+
216219
return $this->selectNewPanel($existingKeys);
217220
}
218221
}
@@ -224,6 +227,7 @@ protected function selectNewPanel(array $existingPanels): string
224227

225228
if (empty($availablePanels)) {
226229
$this->warn('⚠️ No new panels available, using default.');
230+
227231
return reset($allPanels);
228232
}
229233

@@ -260,15 +264,15 @@ protected function warnIfPackagesAlreadyRegistered(array $packages): void
260264
$already = [];
261265
foreach ($packages as $pkg) {
262266
$panels = $this->findPanelsContainingPackage($pkg);
263-
if (!empty($panels)) {
267+
if (! empty($panels)) {
264268
$already[$pkg] = $panels;
265269
}
266270
}
267271

268-
if (!empty($already)) {
272+
if (! empty($already)) {
269273
$this->warn('⚠️ Selected packages are already registered in panels:');
270274
foreach ($already as $pkg => $panels) {
271-
$this->line('' . $pkg . '' . implode(', ', $panels));
275+
$this->line(''.$pkg.''.implode(', ', $panels));
272276
}
273277
}
274278
}
@@ -278,26 +282,28 @@ protected function findPanelsContainingPackage(string $package): array
278282
$panels = [];
279283
foreach ($this->panelMap as $key => $cfg) {
280284
$panelPath = $cfg['path'] ?? null;
281-
if (!$panelPath) {
285+
if (! $panelPath) {
282286
continue;
283287
}
284-
$composerJsonPath = base_path($panelPath . '/../../composer.json');
285-
if (!File::exists($composerJsonPath)) {
288+
$composerJsonPath = base_path($panelPath.'/../../composer.json');
289+
if (! File::exists($composerJsonPath)) {
286290
continue;
287291
}
288292
$composerJson = json_decode(File::get($composerJsonPath), true);
289293
if (isset($composerJson['require']) && array_key_exists($package, $composerJson['require'])) {
290294
$panels[] = $key;
291295
}
292296
}
297+
293298
return $panels;
294299
}
295300

296301
protected function updatePanelPackageComposerJson(string $panelKey, array $packages): void
297302
{
298-
$panelPath = base_path($this->panelMap[$panelKey]['path'] . '/../../composer.json');
299-
if (!file_exists($panelPath)) {
303+
$panelPath = base_path($this->panelMap[$panelKey]['path'].'/../../composer.json');
304+
if (! file_exists($panelPath)) {
300305
$this->warn("⚠️ Panel composer.json not found for {$panelKey}, skipping update.");
306+
301307
return;
302308
}
303309

@@ -307,7 +313,7 @@ protected function updatePanelPackageComposerJson(string $panelKey, array $packa
307313
}
308314

309315
file_put_contents($panelPath, json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
310-
$this->info("✅ Updated composer.json for panel '{$panelKey}' with package(s): " . implode(', ', $packages));
316+
$this->info("✅ Updated composer.json for panel '{$panelKey}' with package(s): ".implode(', ', $packages));
311317
}
312318

313319
protected function installPluginsFromGeneratedPanels(): void
@@ -316,6 +322,7 @@ protected function installPluginsFromGeneratedPanels(): void
316322

317323
if (empty($this->selectedPanels)) {
318324
$this->warn('⚠️ No panels selected. Skipping plugin installation.');
325+
319326
return;
320327
}
321328

@@ -324,35 +331,38 @@ protected function installPluginsFromGeneratedPanels(): void
324331
foreach ($this->selectedPanels as $i => $panelKey) {
325332
$panelInfo = $this->panelMap[$panelKey] ?? null;
326333

327-
if (!$panelInfo) {
334+
if (! $panelInfo) {
328335
$this->warn("⚠️ Unknown panel key '{$panelKey}'. Skipping plugin scan.");
336+
329337
continue;
330338
}
331339

332340
$panelClass = ($panelInfo['namespace'] ?? null)
333-
? $panelInfo['namespace'] . '\\' . ucfirst($panelKey) . 'PanelProvider'
341+
? $panelInfo['namespace'].'\\'.ucfirst($panelKey).'PanelProvider'
334342
: null;
335343

336-
if (!$panelClass || !class_exists($panelClass)) {
344+
if (! $panelClass || ! class_exists($panelClass)) {
337345
$this->warn("⚠️ Panel provider class '{$panelClass}' does not exist. Skipping plugin scan.");
346+
338347
continue;
339348
}
340349

341350
$this->newLine();
342351
$this->line(str_repeat('', 60));
343-
$this->info("🧩 [".($i+1)."/{$panelCount}] Processing panel: {$panelKey}");
352+
$this->info('🧩 ['.($i + 1)."/{$panelCount}] Processing panel: {$panelKey}");
344353
$this->line(str_repeat('', 60));
345354
$this->newLine();
346355

347356
$providerInstance = new $panelClass(app());
348357

349-
$panel = new \Filament\Panel();
358+
$panel = new \Filament\Panel;
350359
$configuredPanel = $providerInstance->panel($panel);
351360

352361
$plugins = $configuredPanel->getPlugins() ?? [];
353362

354363
if (empty($plugins)) {
355364
$this->info("ℹ️ No plugins found in panel '{$panelKey}'.");
365+
356366
continue;
357367
}
358368

@@ -373,15 +383,16 @@ protected function installPluginsFromGeneratedPanels(): void
373383

374384
if (empty($packagesToInstall)) {
375385
$this->info("ℹ️ No composer packages detected for panel '{$panelKey}'.");
386+
376387
continue;
377388
}
378389

379-
$this->info("📦 Detected plugin packages:");
390+
$this->info('📦 Detected plugin packages:');
380391
foreach ($packagesToInstall as $pkg) {
381392
$this->line("{$pkg}");
382393
}
383394

384-
$providerPath = $panelInfo['path'] . '/' . ucfirst($panelKey) . 'PanelProvider.php';
395+
$providerPath = $panelInfo['path'].'/'.ucfirst($panelKey).'PanelProvider.php';
385396

386397
// --- Pakete installieren ---
387398
foreach ($packagesToInstall as $pkg) {
@@ -405,16 +416,16 @@ protected function installPluginsFromGeneratedPanels(): void
405416

406417
$this->newLine(2);
407418
$this->line(str_repeat('', 60));
408-
$this->info("🎉 All selected panels processed successfully!");
409-
$this->info("✨ Moox Panels installed successfully. Enjoy!");
419+
$this->info('🎉 All selected panels processed successfully!');
420+
$this->info('✨ Moox Panels installed successfully. Enjoy!');
410421
$this->line(str_repeat('', 60));
411422
$this->newLine();
412423
}
413424

414425
protected function getProviderClassesFromBootstrap(): array
415426
{
416427
$bootstrapProvidersPath = base_path('bootstrap/providers.php');
417-
if (!file_exists($bootstrapProvidersPath)) {
428+
if (! file_exists($bootstrapProvidersPath)) {
418429
return [];
419430
}
420431

@@ -423,7 +434,7 @@ protected function getProviderClassesFromBootstrap(): array
423434
return [];
424435
}
425436

426-
if (!preg_match_all('/([\\\\A-Za-z0-9_]+)::class/', $content, $matches)) {
437+
if (! preg_match_all('/([\\\\A-Za-z0-9_]+)::class/', $content, $matches)) {
427438
return [];
428439
}
429440

@@ -434,6 +445,7 @@ protected function mapProviderClassToPanelKey(string $class): ?string
434445
{
435446
$classParts = explode('\\', $class);
436447
$name = end($classParts);
448+
437449
return strtolower(str_replace('PanelProvider', '', $name));
438450
}
439451
}

packages/core/src/Console/Commands/UpdatePanelDependencies.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,37 @@
44

55
use Illuminate\Console\Command;
66
use Moox\Core\Console\Traits\SelectFilamentPanel;
7+
78
use function Laravel\Prompts\select;
89

910
class UpdatePanelDependencies extends Command
1011
{
1112
use SelectFilamentPanel;
1213

1314
protected $signature = 'moox:update-panel-dependencies {panel? : The panel to update dependencies for}';
15+
1416
protected $description = 'Update composer dependencies for panel packages based on their plugins';
1517

1618
public function handle(): int
1719
{
1820
$panel = $this->argument('panel');
1921

20-
if (!$panel) {
22+
if (! $panel) {
2123
$availablePanels = array_keys($this->panelMap);
2224
$panel = select(
2325
label: '🛠️ Which panel do you want to update dependencies for?',
2426
options: $availablePanels
2527
);
2628
}
2729

28-
if (!isset($this->panelMap[$panel])) {
30+
if (! isset($this->panelMap[$panel])) {
2931
$this->error("❌ Panel '{$panel}' not found.");
32+
3033
return 1;
3134
}
3235

3336
$this->updatePanelDependencies($panel);
3437

3538
return 0;
3639
}
37-
}
40+
}

0 commit comments

Comments
 (0)