|
5 | 5 | use Sheaf\Cli\Services\PackageInitializationService; |
6 | 6 | use Sheaf\Cli\Support\InitializationConfig; |
7 | 7 | use Illuminate\Console\Command; |
| 8 | +use Sheaf\Cli\Services\ComponentHttpClient; |
8 | 9 |
|
9 | 10 | use function Laravel\Prompts\confirm; |
10 | 11 | use function Laravel\Prompts\text; |
@@ -64,6 +65,7 @@ public function handle() |
64 | 65 | if ($result) { |
65 | 66 | $this->displaySuccess($configuration); |
66 | 67 | $this->displayNextStep($configuration); |
| 68 | + $this->subscribeToNewsletter(); |
67 | 69 | return Command::SUCCESS; |
68 | 70 | } |
69 | 71 |
|
@@ -206,6 +208,31 @@ protected function validateCssFileName(?string $input): ?string |
206 | 208 | return null; |
207 | 209 | } |
208 | 210 |
|
| 211 | + /** |
| 212 | + * Ask user to subscribe to the news letter |
| 213 | + */ |
| 214 | + protected function subscribeToNewsletter() |
| 215 | + { |
| 216 | + |
| 217 | + $email = text( |
| 218 | + label: 'Get notified when we release new components', |
| 219 | + placeholder: 'your.email@example.com', |
| 220 | + hint: 'No spam, just useful updates', |
| 221 | + validate: fn($input) => $input && !filter_var($input, FILTER_VALIDATE_EMAIL) |
| 222 | + ? 'Please enter a valid email address' |
| 223 | + : null |
| 224 | + ); |
| 225 | + |
| 226 | + if (empty($email)) { |
| 227 | + return; |
| 228 | + } |
| 229 | + try { |
| 230 | + new ComponentHttpClient()->subscribeUserToNewsletter($email); |
| 231 | + $this->info("✓ Thanks for subscribing! We'll keep you updated with new components and features."); |
| 232 | + } catch (\Throwable $th) { |
| 233 | + $this->warn("We couldn't subscribe your email right now, but you can always subscribe later at https://sheafui.dev"); |
| 234 | + } |
| 235 | + } |
209 | 236 |
|
210 | 237 | /** |
211 | 238 | * Display the Sheaf package banner |
|
0 commit comments