Skip to content

Commit cfaa662

Browse files
Merge branch 'main' into filament-user-can-access-panel-change
2 parents 6d7bf82 + b7cf090 commit cfaa662

File tree

9 files changed

+759
-604
lines changed

9 files changed

+759
-604
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@ VITE_APP_NAME="${APP_NAME}"
6565

6666
DEBUGBAR_ENABLED=true
6767

68+
DEFAULT_USER_NAME="John Doe"
6869
DEFAULT_USER_EMAIL="[email protected]"
6970
DEFAULT_USER_PASSWORD="password"

Skeletorfile.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
3+
use Filament\Support\Colors\Color;
4+
use NiftyCo\Skeletor\Skeletor;
5+
6+
return function (Skeletor $skeletor) {
7+
$skeletor->intro('Welcome to Larament setup! Let\'s get started.');
8+
9+
$applicationName = $skeletor->text('What is the application name?', 'Laravel', required: true);
10+
11+
$applicationDescription = $skeletor->text('What is the application description?', 'A cool Laravel application');
12+
13+
$timezone = $skeletor->search(
14+
'Which timezone would you like to use?',
15+
fn (string $query) => collect(timezone_identifiers_list())
16+
->filter(fn (string $timezone) => str_contains(strtolower($timezone), strtolower($query)))
17+
->values()
18+
->all()
19+
);
20+
21+
$adminPanelColor = $skeletor->select('What color would you like to use for the FilamentPHP admin panel?',
22+
collect(Color::all())
23+
->keys()
24+
->map(fn (string $color) => ucfirst($color))
25+
->flatten()
26+
->values()
27+
->toArray()
28+
);
29+
30+
$skeletor->intro('Let\'s setup the default user that will be created.');
31+
32+
$name = $skeletor->text('What is the demo username?', 'John Doe', required: true);
33+
34+
$email = $skeletor->text('What is the demo email?', '[email protected]', required: true);
35+
36+
$password = $skeletor->password('What is the demo password?', 'password', required: true);
37+
38+
if ($applicationName) {
39+
$skeletor->pregReplaceInFile('/^APP_NAME=(.*)$/m', 'APP_NAME="'.$applicationName.'"', '.env');
40+
}
41+
42+
if ($applicationDescription) {
43+
$skeletor->pregReplaceInFile(
44+
'/"description":\s*".*?"/',
45+
'"description": "'.addslashes($applicationDescription).'"',
46+
'composer.json'
47+
);
48+
}
49+
50+
if ($name) {
51+
$skeletor->pregReplaceInFile('/^DEFAULT_USER_NAME=(".*?"|[^"\s]*|)$/m', 'DEFAULT_USER_NAME="'.$name.'"', '.env');
52+
}
53+
54+
if ($email) {
55+
$skeletor->pregReplaceInFile('/^DEFAULT_USER_EMAIL=(".*?"|[^"\s]*|)$/m', 'DEFAULT_USER_EMAIL="'.$email.'"', '.env');
56+
}
57+
58+
if ($password) {
59+
$skeletor->pregReplaceInFile('/^DEFAULT_USER_PASSWORD=(".*?"|[^"\s]*|)$/m', 'DEFAULT_USER_PASSWORD="'.$password.'"', '.env');
60+
}
61+
62+
if ($timezone) {
63+
$skeletor->pregReplaceInFile('/^APP_TIMEZONE=(".*?"|[^"\s]*|)$/m', 'APP_TIMEZONE="'.$timezone.'"', '.env');
64+
}
65+
66+
if ($adminPanelColor) {
67+
$skeletor->pregReplaceInFile(
68+
"/'primary'\s*=>\s*Color::[A-Za-z0-9]+/",
69+
"'primary' => Color::".$adminPanelColor,
70+
'app/Providers/Filament/AdminPanelProvider.php'
71+
);
72+
}
73+
74+
if ($skeletor->exists('README.md')) {
75+
$skeletor->removeFile('README.md');
76+
}
77+
78+
if ($skeletor->exists('resources/images/larament.png')) {
79+
$skeletor->removeFile('resources/images/larament.png');
80+
}
81+
82+
if ($skeletor->exists('resources/images/pest-php.png')) {
83+
$skeletor->removeFile('resources/images/pest-php.png');
84+
}
85+
86+
if ($skeletor->exists('resources/images/user-global-search.jpg')) {
87+
$skeletor->removeFile('resources/images/user-global-search.jpg');
88+
}
89+
90+
if ($skeletor->exists('resources/images/global-search-keybinding.jpg')) {
91+
$skeletor->removeFile('resources/images/global-search-keybinding.jpg');
92+
}
93+
94+
$skeletor->outro('Setup completed! Enjoy your new Laravel and FilamentPHP application.');
95+
};

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"timokoerber/laravel-one-time-operations": "^1.4"
2323
},
2424
"require-dev": {
25+
"aniftyco/skeletor": "^0.1.0",
2526
"barryvdh/laravel-debugbar": "^3.13",
2627
"fakerphp/faker": "^1.23",
2728
"larastan/larastan": "^2.0",
@@ -66,6 +67,7 @@
6667
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
6768
],
6869
"post-create-project-cmd": [
70+
"NiftyCo\\Skeletor\\Runner::execute",
6971
"@php artisan key:generate --ansi",
7072
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
7173
"@php artisan migrate --graceful --ansi",

0 commit comments

Comments
 (0)