Skip to content

Commit f2a9811

Browse files
Merge branch 'feature/installer' of https://github.com/mooxphp/moox into feature/installer
2 parents 6d23b46 + 2373352 commit f2a9811

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

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

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use function Moox\Prompts\select;
1919
use function Moox\Prompts\text;
2020
use function Moox\Prompts\warning;
21+
2122
class MooxInstallCommand extends Command
2223
{
2324
use Art, CheckForFilament, SelectFilamentPanel;
@@ -51,7 +52,6 @@ public function handle(): int
5152
}
5253

5354
info('✅ Found '.count($this->mooxProviders).' Moox package(s)');
54-
5555

5656
// Step 3: Collect all assets from all packages
5757
$assets = $this->collectPackageAssets();
@@ -65,7 +65,6 @@ public function handle(): int
6565
// Step 4: Install assets in batches (includes plugins)
6666
$this->installAssets($assets);
6767

68-
6968
info('✅ Installation completed successfully!');
7069

7170
return self::SUCCESS;
@@ -124,6 +123,7 @@ protected function collectPackageAssets(): array
124123
warning("⚠️ Failed to collect assets for {$packageName}: {$e->getMessage()}");
125124
}
126125
}
126+
127127
return $assets;
128128
}
129129

@@ -137,17 +137,17 @@ protected function installAssets(array $assets): void
137137
$groupedAssets = [];
138138
foreach ($assets as $packageName => $packageAssets) {
139139
$provider = $packageAssets['provider'] ?? null;
140-
140+
141141
foreach ($packageAssets as $type => $data) {
142142
// Skip 'provider' key
143143
if ($type === 'provider') {
144144
continue;
145145
}
146-
146+
147147
if (! isset($groupedAssets[$type])) {
148148
$groupedAssets[$type] = [];
149149
}
150-
150+
151151
$groupedAssets[$type][] = [
152152
'package' => $packageName,
153153
'data' => $data,
@@ -253,6 +253,7 @@ protected function installAssetType(string $type, array $assets): void
253253
// Plugins have their own multiselect in installPlugins, skip item-level selection here
254254
if ($type === 'plugins') {
255255
call_user_func($installer, $type, $allData, $assets);
256+
256257
return;
257258
}
258259

@@ -282,19 +283,20 @@ protected function installAssetType(string $type, array $assets): void
282283

283284
if (empty($selectedItems)) {
284285
note("⏩ No {$type} selected, skipping");
286+
285287
return;
286288
}
287289

288290
// Show what will be installed
289-
info("📦 Installing ".count($selectedItems)." {$label} item(s)...");
291+
info('📦 Installing '.count($selectedItems)." {$label} item(s)...");
290292

291293
// Filter assets to only include selected items
292294
$filteredAssets = [];
293295
foreach ($assets as $asset) {
294296
$packageName = $asset['package'];
295297
$data = $asset['data'] ?? [];
296298
$filteredData = array_intersect($data, $selectedItems);
297-
299+
298300
if (! empty($filteredData)) {
299301
$filteredAssets[] = [
300302
'package' => $packageName,
@@ -338,17 +340,17 @@ protected function installMigrations(string $type, array $migrations, array $ass
338340
});
339341

340342
if (! $published) {
341-
note("⏩ Migrations were skipped or failed");
343+
note('⏩ Migrations were skipped or failed');
342344
}
343345
}
344346

345347
protected function installConfigs(string $type, array $configs, array $assets): void
346348
{
347349
try {
348350
$published = $this->publishAndInstallAssets($type, $assets);
349-
351+
350352
if (! $published) {
351-
note("⏩ No configs were published (all already exist or no publish tags found)");
353+
note('⏩ No configs were published (all already exist or no publish tags found)');
352354
}
353355
} catch (\Exception $e) {
354356
warning("⚠️ Configs installation failed: {$e->getMessage()}");
@@ -359,9 +361,9 @@ protected function installTranslations(string $type, array $translations, array
359361
{
360362
try {
361363
$published = $this->publishAndInstallAssets($type, $assets);
362-
364+
363365
if (! $published) {
364-
note("⏩ No translations were published (all already exist or no publish tags found)");
366+
note('⏩ No translations were published (all already exist or no publish tags found)');
365367
}
366368
} catch (\Exception $e) {
367369
warning("⚠️ Translations installation failed: {$e->getMessage()}");
@@ -373,7 +375,7 @@ protected function installPlugins(string $type, array $plugins, array $assets):
373375
// Plugins need special handling with panel selection
374376
// The $plugins array already contains the plugin class names from mooxInfo
375377
// We just need to map them to their packages for display
376-
378+
377379
$allPlugins = [];
378380
$packagePluginMap = [];
379381

@@ -392,6 +394,7 @@ protected function installPlugins(string $type, array $plugins, array $assets):
392394

393395
if (empty($allPlugins)) {
394396
warning('⚠️ No plugins found');
397+
395398
return;
396399
}
397400

@@ -400,22 +403,22 @@ protected function installPlugins(string $type, array $plugins, array $assets):
400403
while (true) {
401404
// Clear terminal to reset state after Artisan calls
402405
clear();
403-
406+
404407
$panelPath = $this->selectOrCreatePanel();
405408
if (! $panelPath) {
406409
break;
407410
}
408-
411+
409412
info('✅ Selected Panel: '.basename($panelPath, '.php'));
410-
413+
411414
// Build display options for the plugins
412415
$pluginChoices = [];
413416
foreach ($allPlugins as $plugin) {
414417
$displayName = basename(str_replace('\\', '/', $plugin));
415418
$package = $packagePluginMap[$plugin] ?? 'unknown';
416419
$pluginChoices["{$displayName} ({$package})"] = $plugin;
417420
}
418-
421+
419422
// Multiselect which plugins to install in this panel
420423
$selectedLabels = multiselect(
421424
label: 'Select plugins to install in this panel:',
@@ -424,18 +427,18 @@ protected function installPlugins(string $type, array $plugins, array $assets):
424427
scroll: min(10, count($pluginChoices)),
425428
required: false
426429
);
427-
430+
428431
if (empty($selectedLabels)) {
429432
note('⏩ No plugins selected for this panel');
430433
} else {
431434
$selectedPlugins = array_map(
432435
fn ($label) => $pluginChoices[$label],
433436
$selectedLabels
434437
);
435-
438+
436439
$this->installResolvedPlugins($selectedPlugins, $panelPath);
437440
}
438-
441+
439442
if (! confirm(label: 'Install plugins in another panel?', default: false)) {
440443
break;
441444
}
@@ -477,10 +480,10 @@ protected function publishAndInstallAssets(string $type, array $assets, ?callabl
477480
if ($this->publishPackageAssets($packageName, $type)) {
478481
$published = true;
479482
$publishedPackages[] = $packageName;
480-
note(" ✅ Published");
483+
note(' ✅ Published');
481484
} else {
482485
$failedPackages[] = $packageName;
483-
note(" ⚠️ No publish tag found");
486+
note(' ⚠️ No publish tag found');
484487
}
485488
}
486489

@@ -502,7 +505,7 @@ protected function publishAndInstallAssets(string $type, array $assets, ?callabl
502505
if ($afterPublish && $published) {
503506
$afterPublish();
504507
}
505-
508+
506509
return $published || ! empty($skippedPackages);
507510
}
508511

@@ -552,7 +555,7 @@ protected function checkMigrationsPublished(string $packageName, array $migratio
552555
protected function installSeeders(string $type, array $seeders, array $assets): void
553556
{
554557
// Ask for confirmation
555-
558+
556559
if (! confirm(label: 'Run seeders for all packages?', default: false)) {
557560
note("⏩ Skipped {$type}");
558561

@@ -602,7 +605,6 @@ protected function installSeeders(string $type, array $seeders, array $assets):
602605
}
603606
}
604607

605-
606608
protected function scanMooxProviders(): void
607609
{
608610
// Get all installed packages from composer.json
@@ -648,7 +650,7 @@ protected function scanMooxProviders(): void
648650
}
649651
}
650652
}
651-
note("✅ Found ".count($this->mooxProviders)." Moox providers");
653+
note('✅ Found '.count($this->mooxProviders).' Moox providers');
652654
}
653655

654656
protected function getProviderClassFromPackage(string $packageName): ?string

packages/jobs/src/JobsServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Moox\Jobs;
44

5-
use Override;
65
use Moox\Core\MooxServiceProvider;
7-
use Moox\Jobs\Commands\UpdateCommand;
86
use Moox\Jobs\Commands\InstallCommand;
7+
use Moox\Jobs\Commands\UpdateCommand;
8+
use Override;
99
use Spatie\LaravelPackageTools\Package;
1010

1111
class JobsServiceProvider extends MooxServiceProvider

0 commit comments

Comments
 (0)