From a2f5e1ce5683fe411322a69e96e08c5dae3a7ae3 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Sun, 6 Aug 2023 23:49:47 +0100 Subject: [PATCH] wip --- .../forms/src/Commands/MakeFieldCommand.php | 11 +++-- .../forms/src/Commands/MakeFormCommand.php | 13 +++--- .../Commands/MakeLayoutComponentCommand.php | 11 +++-- .../src/Commands/MakeEntryCommand.php | 11 +++-- .../Commands/MakeLayoutComponentCommand.php | 11 +++-- .../panels/src/Commands/MakePageCommand.php | 43 +++++++++---------- .../panels/src/Commands/MakePanelCommand.php | 11 +++-- .../Commands/MakeRelationManagerCommand.php | 33 +++++++------- .../src/Commands/MakeResourceCommand.php | 11 +++-- .../panels/src/Commands/MakeUserCommand.php | 4 +- .../src/Commands/MakeSettingsPageCommand.php | 22 +++++----- .../tables/src/Commands/MakeColumnCommand.php | 11 +++-- .../tables/src/Commands/MakeTableCommand.php | 22 +++++----- .../src/Commands/MakeWidgetCommand.php | 10 +++-- 14 files changed, 104 insertions(+), 120 deletions(-) diff --git a/packages/forms/src/Commands/MakeFieldCommand.php b/packages/forms/src/Commands/MakeFieldCommand.php index 24b9150a61..e4b0427bed 100644 --- a/packages/forms/src/Commands/MakeFieldCommand.php +++ b/packages/forms/src/Commands/MakeFieldCommand.php @@ -17,12 +17,11 @@ class MakeFieldCommand extends Command public function handle(): int { - $field = (string) str($this->argument('name') ?? - text( - label: 'What is the field name?', - placeholder: 'Name (e.g. `RangeSlider`)', - required: true - )) + $field = (string) str($this->argument('name') ?? text( + label: 'What is the field name?', + placeholder: 'RangeSlider', + required: true, + )) ->trim('/') ->trim('\\') ->trim(' ') diff --git a/packages/forms/src/Commands/MakeFormCommand.php b/packages/forms/src/Commands/MakeFormCommand.php index bf93eb0d0e..941af03117 100644 --- a/packages/forms/src/Commands/MakeFormCommand.php +++ b/packages/forms/src/Commands/MakeFormCommand.php @@ -24,12 +24,11 @@ class MakeFormCommand extends Command public function handle(): int { - $component = (string) str($this->argument('name') ?? - text( - label: 'What is the form name?', - placeholder: 'Name (e.g. `Products/CreateProduct`)', - required: true - )) + $component = (string) str($this->argument('name') ?? text( + label: 'What is the form name?', + placeholder: 'Products/CreateProduct', + required: true, + )) ->trim('/') ->trim('\\') ->trim(' ') @@ -49,7 +48,7 @@ class MakeFormCommand extends Command $model = (string) str($this->argument('model') ?? text( label: 'What is the model name?', - placeholder: 'Model (e.g. `Product`)', + placeholder: 'Product', required: $this->option('edit') ))->replace('/', '\\'); $modelClass = (string) str($model)->afterLast('\\'); diff --git a/packages/forms/src/Commands/MakeLayoutComponentCommand.php b/packages/forms/src/Commands/MakeLayoutComponentCommand.php index 07ff4f4616..d8d6d826c3 100644 --- a/packages/forms/src/Commands/MakeLayoutComponentCommand.php +++ b/packages/forms/src/Commands/MakeLayoutComponentCommand.php @@ -17,12 +17,11 @@ class MakeLayoutComponentCommand extends Command public function handle(): int { - $component = (string) str($this->argument('name') ?? - text( - label: 'What is the layout name?', - placeholder: 'Name (e.g. `Wizard`)', - required: true - )) + $component = (string) str($this->argument('name') ?? text( + label: 'What is the layout name?', + placeholder: 'Wizard', + required: true, + )) ->trim('/') ->trim('\\') ->trim(' ') diff --git a/packages/infolists/src/Commands/MakeEntryCommand.php b/packages/infolists/src/Commands/MakeEntryCommand.php index 1f1c33e469..08bd69cb13 100644 --- a/packages/infolists/src/Commands/MakeEntryCommand.php +++ b/packages/infolists/src/Commands/MakeEntryCommand.php @@ -17,12 +17,11 @@ class MakeEntryCommand extends Command public function handle(): int { - $entry = (string) str($this->argument('name') ?? - text( - label: 'What is the infolist name?', - placeholder: 'Name (e.g. `StatusSwitcher`)', - required: true - )) + $entry = (string) str($this->argument('name') ?? text( + label: 'What is the infolist name?', + placeholder: 'StatusSwitcher', + required: true, + )) ->trim('/') ->trim('\\') ->trim(' ') diff --git a/packages/infolists/src/Commands/MakeLayoutComponentCommand.php b/packages/infolists/src/Commands/MakeLayoutComponentCommand.php index 98a1c84355..88f1461d1a 100644 --- a/packages/infolists/src/Commands/MakeLayoutComponentCommand.php +++ b/packages/infolists/src/Commands/MakeLayoutComponentCommand.php @@ -17,12 +17,11 @@ class MakeLayoutComponentCommand extends Command public function handle(): int { - $component = (string) str($this->argument('name') ?? - text( - label: 'What is the layout name?', - placeholder: 'Name (e.g. `Wizard`)', - required: true - )) + $component = (string) str($this->argument('name') ?? text( + label: 'What is the layout name?', + placeholder: 'Wizard', + required: true, + )) ->trim('/') ->trim('\\') ->trim(' ') diff --git a/packages/panels/src/Commands/MakePageCommand.php b/packages/panels/src/Commands/MakePageCommand.php index f45ef7f488..0ec7bbe671 100644 --- a/packages/panels/src/Commands/MakePageCommand.php +++ b/packages/panels/src/Commands/MakePageCommand.php @@ -26,9 +26,9 @@ class MakePageCommand extends Command $this->argument('name') ?? text( label: 'What is the page name?', - placeholder: 'Settings Page', - required: true - ) + placeholder: 'EditSettings', + required: true, + ), ) ->trim('/') ->trim('\\') @@ -43,13 +43,12 @@ class MakePageCommand extends Command $resourceClass = null; $resourcePage = null; - $resourceInput = $this->option('resource') ?? - text( - label: 'Make Page For Resource?', - placeholder: '(Optional) Resource (e.g. `UserResource`)', - ); + $resourceInput = $this->option('resource') ?? text( + label: 'Would you like to create the page inside a resource?', + placeholder: '[Optional] UserResource', + ); - if ($resourceInput !== null) { + if (filled($resourceInput)) { $resource = (string) str($resourceInput) ->studly() ->trim('/') @@ -64,20 +63,18 @@ class MakePageCommand extends Command $resourceClass = (string) str($resource) ->afterLast('\\'); - $resourcePage = $this->option('type') ?? - - select( - label: 'Which type of page would you like to create?', - options: [ - 'custom' => 'Custom', - 'ListRecords' => 'List', - 'CreateRecord' => 'Create', - 'EditRecord' => 'Edit', - 'ViewRecord' => 'View', - 'ManageRecords' => 'Manage', - ], - default: 'custom' - ); + $resourcePage = $this->option('type') ?? select( + label: 'Which type of page would you like to create?', + options: [ + 'custom' => 'Custom', + 'ListRecords' => 'List', + 'CreateRecord' => 'Create', + 'EditRecord' => 'Edit', + 'ViewRecord' => 'View', + 'ManageRecords' => 'Manage', + ], + default: 'custom' + ); } $panel = $this->option('panel'); diff --git a/packages/panels/src/Commands/MakePanelCommand.php b/packages/panels/src/Commands/MakePanelCommand.php index 5aa88cb997..bbdb9a21da 100644 --- a/packages/panels/src/Commands/MakePanelCommand.php +++ b/packages/panels/src/Commands/MakePanelCommand.php @@ -17,12 +17,11 @@ class MakePanelCommand extends Command public function handle(): int { - $id = Str::lcfirst($this->argument('id') ?? - text( - label: 'What is the ID?', - placeholder: 'ID (e.g. `app`)', - required: true - )); + $id = Str::lcfirst($this->argument('id') ?? text( + label: 'What is the ID?', + placeholder: 'app', + required: true, + )); $class = (string) str($id) ->studly() diff --git a/packages/panels/src/Commands/MakeRelationManagerCommand.php b/packages/panels/src/Commands/MakeRelationManagerCommand.php index 1481a4c52a..df9f916b01 100644 --- a/packages/panels/src/Commands/MakeRelationManagerCommand.php +++ b/packages/panels/src/Commands/MakeRelationManagerCommand.php @@ -23,12 +23,11 @@ class MakeRelationManagerCommand extends Command public function handle(): int { $resource = (string) str( - $this->argument('resource') ?? - text( - label: 'What is the Resource name?', - placeholder: 'Resource (e.g. `DepartmentResource`)', - required: true - ) + $this->argument('resource') ?? text( + label: 'What is the resource you would like to create this in?', + placeholder: 'DepartmentResource', + required: true, + ), ) ->studly() ->trim('/') @@ -40,23 +39,21 @@ class MakeRelationManagerCommand extends Command $resource .= 'Resource'; } - $relationship = (string) str($this->argument('relationship') ?? - text( - label: 'What is the Relationship?', - placeholder: 'Relationship (e.g. `members`)', - required: true - )) + $relationship = (string) str($this->argument('relationship') ?? text( + label: 'What is the relationship?', + placeholder: 'members', + required: true, + )) ->trim(' '); $managerClass = (string) str($relationship) ->studly() ->append('RelationManager'); - $recordTitleAttribute = (string) str($this->argument('recordTitleAttribute') ?? - text( - label: 'What is the Title attribute?', - placeholder: 'Title attribute (e.g. `name`)', - required: true - )) + $recordTitleAttribute = (string) str($this->argument('recordTitleAttribute') ?? text( + label: 'What is the title attribute?', + placeholder: 'name', + required: true, + )) ->trim(' '); $panel = $this->option('panel'); diff --git a/packages/panels/src/Commands/MakeResourceCommand.php b/packages/panels/src/Commands/MakeResourceCommand.php index cc804d5b68..d0abc15e58 100644 --- a/packages/panels/src/Commands/MakeResourceCommand.php +++ b/packages/panels/src/Commands/MakeResourceCommand.php @@ -28,12 +28,11 @@ class MakeResourceCommand extends Command public function handle(): int { - $model = (string) str($this->argument('name') ?? - text( - label: 'Model name?', - placeholder: 'Model (e.g. `BlogPost`)', - required: true - )) + $model = (string) str($this->argument('name') ?? text( + label: 'What is the model name?', + placeholder: 'BlogPost', + required: true, + )) ->studly() ->beforeLast('Resource') ->trim('/') diff --git a/packages/panels/src/Commands/MakeUserCommand.php b/packages/panels/src/Commands/MakeUserCommand.php index ccfc4f60fc..baeeb8d15f 100644 --- a/packages/panels/src/Commands/MakeUserCommand.php +++ b/packages/panels/src/Commands/MakeUserCommand.php @@ -34,7 +34,7 @@ class MakeUserCommand extends Command return [ 'name' => $this->options['name'] ?? text( label: 'Name', - required: true + required: true, ), 'email' => $this->options['email'] ?? text( @@ -49,7 +49,7 @@ class MakeUserCommand extends Command 'password' => Hash::make($this->options['password'] ?? password( label: 'Password', - required: true + required: true, )), ]; } diff --git a/packages/spatie-laravel-settings-plugin/src/Commands/MakeSettingsPageCommand.php b/packages/spatie-laravel-settings-plugin/src/Commands/MakeSettingsPageCommand.php index b576acef21..26f6c916ed 100644 --- a/packages/spatie-laravel-settings-plugin/src/Commands/MakeSettingsPageCommand.php +++ b/packages/spatie-laravel-settings-plugin/src/Commands/MakeSettingsPageCommand.php @@ -16,12 +16,11 @@ class MakeSettingsPageCommand extends Command public function handle(): int { - $page = (string) str($this->argument('name') ?? - text( - label: 'What is the page name?', - placeholder: 'Page name (e.g. `ManageFooter`)', - required: true - )) + $page = (string) str($this->argument('name') ?? text( + label: 'What is the page name?', + placeholder: 'ManageFooter', + required: true, + )) ->trim('/') ->trim('\\') ->trim(' ') @@ -31,12 +30,11 @@ class MakeSettingsPageCommand extends Command (string) str($page)->beforeLast('\\') : ''; - $settingsClass = (string) str($this->argument('settingsClass') ?? - text( - label: 'What is the settings name?', - placeholder: 'Settings class (e.g. `FooterSettings`)', - required: true - )) + $settingsClass = (string) str($this->argument('settingsClass') ?? text( + label: 'What is the settings name?', + placeholder: 'FooterSettings', + required: true, + )) ->trim('/') ->trim('\\') ->trim(' '); diff --git a/packages/tables/src/Commands/MakeColumnCommand.php b/packages/tables/src/Commands/MakeColumnCommand.php index b8dbb2f945..38cb56f4cd 100644 --- a/packages/tables/src/Commands/MakeColumnCommand.php +++ b/packages/tables/src/Commands/MakeColumnCommand.php @@ -17,12 +17,11 @@ class MakeColumnCommand extends Command public function handle(): int { - $column = (string) str($this->argument('name') ?? - text( - label: 'What is the column name?', - placeholder: 'Name (e.g. `StatusSwitcher`)', - required: true - )) + $column = (string) str($this->argument('name') ?? text( + label: 'What is the column name?', + placeholder: 'StatusSwitcher', + required: true, + )) ->trim('/') ->trim('\\') ->trim(' ') diff --git a/packages/tables/src/Commands/MakeTableCommand.php b/packages/tables/src/Commands/MakeTableCommand.php index 1c3c8e17f4..d6c49975ea 100644 --- a/packages/tables/src/Commands/MakeTableCommand.php +++ b/packages/tables/src/Commands/MakeTableCommand.php @@ -23,12 +23,11 @@ class MakeTableCommand extends Command public function handle(): int { - $component = (string) str($this->argument('name') ?? - text( - label: 'What is the table name?', - placeholder: 'Products/ListProducts`)', - required: true - )) + $component = (string) str($this->argument('name') ?? text( + label: 'What is the table name?', + placeholder: 'Products/ListProducts', + required: true, + )) ->trim('/') ->trim('\\') ->trim(' ') @@ -45,12 +44,11 @@ class MakeTableCommand extends Command ->map(fn ($segment) => Str::lower(Str::kebab($segment))) ->implode('.'); - $model = (string) str($this->argument('model') ?? - text( - label: 'What is the model name?', - placeholder: 'Model (e.g. `Product`)', - required: true - )) + $model = (string) str($this->argument('model') ?? text( + label: 'What is the model name?', + placeholder: 'Product', + required: true, + )) ->replace('/', '\\'); $modelClass = (string) str($model)->afterLast('\\'); diff --git a/packages/widgets/src/Commands/MakeWidgetCommand.php b/packages/widgets/src/Commands/MakeWidgetCommand.php index 50f15392c2..e31132a755 100644 --- a/packages/widgets/src/Commands/MakeWidgetCommand.php +++ b/packages/widgets/src/Commands/MakeWidgetCommand.php @@ -23,7 +23,8 @@ class MakeWidgetCommand extends Command public function handle(): int { $widget = (string) str($this->argument('name') ?? text( - label: 'Name (e.g. `BlogPostsChart`)', + label: 'What is the widget name?', + placeholder: 'BlogPostsChart', required: true, )) ->trim('/') @@ -40,10 +41,11 @@ class MakeWidgetCommand extends Command if (class_exists(Resource::class)) { $resourceInput = $this->option('resource') ?? text( - label: '(Optional) Resource (e.g. `BlogPostResource`)', + label: 'Would you like to create the page inside a resource?', + placeholder: '[Optional] BlogPostResource', ); - if ($resourceInput !== null) { + if (filled($resourceInput)) { $resource = (string) str($resourceInput) ->studly() ->trim('/') @@ -154,7 +156,7 @@ class MakeWidgetCommand extends Command if ($this->option('chart')) { $chart = select( - label: 'Chart type', + label: 'Which type of chart would you like to create?', options: [ 'Bar chart', 'Bubble chart',