-
-
Notifications
You must be signed in to change notification settings - Fork 142
feat(console): add make:controller and make:model commands
#647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
brendt
merged 60 commits into
tempestphp:main
from
gturpin-dev:feat/console/make-commands
Nov 14, 2024
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
cc164f5
:sparkles: Add work from the other branch
gturpin-dev cfc7ad3
:art: Coding styles
gturpin-dev f30cefa
:rotating_light: Run phpstan
gturpin-dev a7aa94e
:rotating_light: Run Rector
gturpin-dev c4dee0a
:sparkles: Add the make:model command
gturpin-dev 030e2be
:art: Coding styles
gturpin-dev a3e8536
:pencil: Update phpdoc and code styles
gturpin-dev a6ef03c
:pencil: Update phpdoc and code styles
gturpin-dev ef7d478
:pencil: Update phpdoc and code styles
gturpin-dev 8654725
:pencil: Update phpdoc and code styles
gturpin-dev 9e33d9d
:pencil: Update phpdoc and code styles
gturpin-dev 084cf21
:pencil: Update phpdoc and code styles
gturpin-dev c5c7b20
:pencil: Update phpdoc and code styles
gturpin-dev 98f87e2
:pencil: Update phpdoc and code styles
gturpin-dev 8b2f05c
:pencil: Update phpdoc and code styles
gturpin-dev 5070533
:pencil: Update phpdoc and code styles
gturpin-dev af7ed2a
:pencil: Update phpdoc and code styles
gturpin-dev bc9f939
:pencil: Update phpdoc and code styles
gturpin-dev a31d41d
:sparkles: Refactor and add manipulations on the fly
gturpin-dev 5509af0
:bug: Fix generation aliasing old classname
gturpin-dev 1405419
:recycle: Refactor PublishesFiles to use the StubFileGenerator
gturpin-dev ef37a84
:recycle: Refactor make:controller command to work with new methods
gturpin-dev 1a6ca14
:recycle: Refactor namespace build for generation
gturpin-dev 9f8f804
:rotating_light: Run rector
gturpin-dev 030bef7
:rotating_light: Run phpstan
gturpin-dev a4ad57c
:art: Coding styles
gturpin-dev 1ef9f60
:fire: Remove unused exception
gturpin-dev 08a4783
:white_check_mark: Add tests for PathHelper::toClassName
gturpin-dev c23c9bf
:fire: make:model now only create a database model
gturpin-dev ea917b7
:fire: Removing pathPrefix and classSufix on make commands
gturpin-dev c69ce91
:art: Move make:controller command to tempest/http package
gturpin-dev d6dfb86
:art: Move make:model command to tempest/database package
gturpin-dev e074fa3
:recycle: Refactor HasGeneratorCommand to use Injected properties
gturpin-dev 9698266
:recycle: Rename HasGeneratorCommand trait to HasGeneratorConsoleInte…
gturpin-dev 0891b57
qa
brendt 4b0dc40
Update phpstan
brendt 3b7794e
:art: Fix coding styles
gturpin-dev 5df1b1f
:recycle: Refactor StubFile accessor to improve the API
gturpin-dev 9006d9c
:recycle::construction: Start refactoring StubFileGenerator to avoid …
gturpin-dev a6a071b
:bug: Fix StubFile issue
gturpin-dev 3d0408f
:art: Coding styles
gturpin-dev e4b9360
Merge branch 'main' into feat/console/make-commands
brendt 5a7c1b1
wip
brendt 62c254f
qa
brendt de86401
wip
brendt 9601ee9
Add some tests
brendt 39a42ae
:recycle: Replace DIRECTORY_SEPARATOR with slashes
gturpin-dev 9bb7ca1
:white_check_mark: Add tests
gturpin-dev a7f1ed7
:art: Coding styles
gturpin-dev 84b88a5
:white_check_mark: Add tests for PublishesFiles trait
gturpin-dev 398dc80
:white_check_mark: Add test for make:model command
gturpin-dev 8f6f985
:test_tube: Add failing test for PublishesFiles
gturpin-dev 9418d92
:bug: Fix the failing test
gturpin-dev 76e27b5
:recycle: Refactor the make:controller tests
gturpin-dev 854984e
Merge branch 'main' into feat/console/make-commands
gturpin-dev 2d6e512
:art: Coding styles
gturpin-dev 99f4821
:bug: Try fixing windows paths CI issue
gturpin-dev b39c42c
:art: Coding styles
gturpin-dev 7a7ab00
Merge branch 'main' into feat/console/make-commands
gturpin-dev 92b4b88
Merge branch 'main' into feat/console/make-commands
brendt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Tempest\Database\Commands; | ||
|
|
||
| use Tempest\Console\ConsoleArgument; | ||
| use Tempest\Console\ConsoleCommand; | ||
| use Tempest\Core\PublishesFiles; | ||
| use Tempest\Database\Stubs\DatabaseModelStub; | ||
| use Tempest\Generation\DataObjects\StubFile; | ||
| use Tempest\Generation\Exceptions\FileGenerationAbortedException; | ||
| use Tempest\Generation\Exceptions\FileGenerationFailedException; | ||
|
|
||
| final class MakeModelCommand | ||
| { | ||
| use PublishesFiles; | ||
|
|
||
| #[ConsoleCommand( | ||
| name: 'make:model', | ||
| description: 'Creates a new model class', | ||
| aliases: ['model:make', 'model:create', 'create:model'], | ||
| )] | ||
| public function __invoke( | ||
| #[ConsoleArgument( | ||
| help: 'The name of the model class to create', | ||
| )] | ||
| string $className, | ||
| ): void { | ||
| $suggestedPath = $this->getSuggestedPath($className); | ||
| $targetPath = $this->promptTargetPath($suggestedPath); | ||
| $shouldOverride = $this->askForOverride($targetPath); | ||
|
|
||
| try { | ||
|
|
||
| $this->stubFileGenerator->generateClassFile( | ||
| stubFile: StubFile::from(DatabaseModelStub::class), | ||
| targetPath: $targetPath, | ||
| shouldOverride: $shouldOverride, | ||
| ); | ||
|
|
||
| $this->console->success(sprintf('File successfully created at "%s".', $targetPath)); | ||
| } catch (FileGenerationAbortedException|FileGenerationFailedException $e) { | ||
| $this->console->error($e->getMessage()); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Tempest\Database\Stubs; | ||
|
|
||
| use Tempest\Database\DatabaseModel; | ||
| use Tempest\Database\IsDatabaseModel; | ||
| use Tempest\Validation\Rules\Length; | ||
|
|
||
| final class DatabaseModelStub implements DatabaseModel | ||
| { | ||
| use IsDatabaseModel; | ||
|
|
||
| public function __construct( | ||
| #[Length(min: 1, max: 120)] | ||
| public string $title | ||
| ) { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.