Skip to content

Commit 83fe930

Browse files
author
nejc
committed
feat: enhance setup command with Laravel version check and better developer guidance
- Add Laravel 12+ version compatibility check at setup start - Show clear error message with upgrade instructions for older Laravel versions - Enhanced success messages with detailed next steps for developers - Added comprehensive information about what each command does - Explained safety features and PR workflow - Better developer experience with clear guidance New setup flow: 1. Check Laravel version compatibility (requires 12.0+) 2. Guide through configuration with clear explanations 3. Show detailed next steps with command explanations 4. Explain safety features and PR workflow Benefits: - Prevents setup on incompatible Laravel versions - Clear upgrade path for older Laravel projects - Better developer understanding of the workflow - More informative and helpful setup experience
1 parent e45bee2 commit 83fe930

File tree

1 file changed

+64
-2
lines changed

1 file changed

+64
-2
lines changed

src/Console/Commands/UpstreamSetupCommand.php

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ public function handle(): int
2424
$this->displayLogo();
2525
$this->displayWelcomeMessage();
2626

27+
// Check Laravel version compatibility
28+
if (!$this->checkLaravelVersion()) {
29+
return self::FAILURE;
30+
}
31+
2732
$this->info('🚀 Laravel Updater Setup');
2833
$this->newLine();
2934

@@ -70,6 +75,37 @@ private function displayWelcomeMessage(): void
7075
$this->line('');
7176
}
7277

78+
private function checkLaravelVersion(): bool
79+
{
80+
$laravelVersion = app()->version();
81+
$versionNumber = (float) substr($laravelVersion, 0, 3);
82+
83+
if ($versionNumber < 12.0) {
84+
$this->error('❌ Laravel Version Incompatible');
85+
$this->newLine();
86+
$this->line('🚫 <error>Laravel Updater requires Laravel 12.0 or higher</error>');
87+
$this->line("📍 Your current version: <comment>$laravelVersion</comment>");
88+
$this->line('📍 Required version: <info>12.0+</info>');
89+
$this->newLine();
90+
$this->line('🔧 <comment>To update Laravel:</comment>');
91+
$this->line(' 1. Update your composer.json to require "laravel/framework": "^12.0"');
92+
$this->line(' 2. Run: <info>composer update laravel/framework</info>');
93+
$this->line(' 3. Update your application code for Laravel 12 compatibility');
94+
$this->line(' 4. Run this setup command again');
95+
$this->newLine();
96+
$this->line('📚 <comment>Laravel 12 Upgrade Guide:</comment>');
97+
$this->line(' • <info>https://laravel.com/docs/12.x/upgrade</info>');
98+
$this->newLine();
99+
100+
return false;
101+
}
102+
103+
$this->line("✅ Laravel version check passed: <info>$laravelVersion</info>");
104+
$this->newLine();
105+
106+
return true;
107+
}
108+
73109
private function setupPreset(string $preset): int
74110
{
75111
$config = config("upstream.presets.$preset");
@@ -123,7 +159,20 @@ private function setupPreset(string $preset): int
123159
$this->line("📍 Local Branch: $localBranch (your main project branch)");
124160

125161
$this->newLine();
126-
$this->line('💡 You can now run: <info>php artisan laravelplus:check</info>');
162+
$this->line('🚀 <comment>Next Steps:</comment>');
163+
$this->line(' 1. 💡 Run <info>php artisan laravelplus:check</info> to see what updates are available');
164+
$this->line(' 2. 💡 Run <info>php artisan laravelplus:update</info> to create a PR with upstream changes');
165+
$this->newLine();
166+
$this->line('🔍 <comment>What will happen when you run these commands:</comment>');
167+
$this->line(' • <info>laravelplus:check</info> - Shows detailed information about available updates');
168+
$this->line(' • <info>laravelplus:update</info> - Creates a new branch and PR with upstream changes');
169+
$this->line(' • PRs target your <info>' . $localBranch . '</info> branch for safe review');
170+
$this->line(' • You can review changes on GitHub before merging');
171+
$this->newLine();
172+
$this->line('🛡️ <comment>Safety Features:</comment>');
173+
$this->line(' • Always creates PRs by default (no direct merges)');
174+
$this->line(' • Dry-run mode available with <info>--dry-run</info> flag');
175+
$this->line(' • Comprehensive testing before applying changes');
127176

128177
return self::SUCCESS;
129178
}
@@ -175,7 +224,20 @@ private function setupCustom(): int
175224
$this->line("📍 Local Branch: $localBranch (your main project branch)");
176225

177226
$this->newLine();
178-
$this->line('💡 You can now run: <info>php artisan laravelplus:check</info>');
227+
$this->line('🚀 <comment>Next Steps:</comment>');
228+
$this->line(' 1. 💡 Run <info>php artisan laravelplus:check</info> to see what updates are available');
229+
$this->line(' 2. 💡 Run <info>php artisan laravelplus:update</info> to create a PR with upstream changes');
230+
$this->newLine();
231+
$this->line('🔍 <comment>What will happen when you run these commands:</comment>');
232+
$this->line(' • <info>laravelplus:check</info> - Shows detailed information about available updates');
233+
$this->line(' • <info>laravelplus:update</info> - Creates a new branch and PR with upstream changes');
234+
$this->line(' • PRs target your <info>' . $localBranch . '</info> branch for safe review');
235+
$this->line(' • You can review changes on GitHub before merging');
236+
$this->newLine();
237+
$this->line('🛡️ <comment>Safety Features:</comment>');
238+
$this->line(' • Always creates PRs by default (no direct merges)');
239+
$this->line(' • Dry-run mode available with <info>--dry-run</info> flag');
240+
$this->line(' • Comprehensive testing before applying changes');
179241

180242
return self::SUCCESS;
181243
}

0 commit comments

Comments
 (0)