This repository was archived by the owner on Jan 10, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +60
-1
lines changed
Expand file tree Collapse file tree 6 files changed +60
-1
lines changed Original file line number Diff line number Diff line change @@ -53,13 +53,15 @@ This is the contents of the published config file:
5353return [
5454 'namespaces' => [
5555 'action' => 'Actions',
56- 'collection' => 'Collection',
56+ 'collection' => 'Collections',
57+ 'config' => 'config',
5758 'contract' => 'Contracts',
5859 'dto' => 'Dtos',
5960 'enum' => 'Enums',
6061 'interface' => 'Interfaces',
6162 'repository' => 'Repositories',
6263 'service' => 'Services',
64+ 'trait' => 'Traits',
6365 ],
6466];
6567```
@@ -71,6 +73,7 @@ The following commands are available.
7173```
7274php artisan make:action CreateUserAction
7375php artisan make:collection OrderCollection
76+ php artisan make:config config-file
7477php artisan make:contract CreatesUserContract
7578php artisan make:dto RestRequestObject
7679php artisan make:enum OrderStatusEnum
Original file line number Diff line number Diff line change 1212 'namespaces ' => [
1313 'action ' => 'Actions ' ,
1414 'collection ' => 'Collections ' ,
15+ 'config ' => 'config ' ,
1516 'contract ' => 'Contracts ' ,
1617 'dto ' => 'Dtos ' ,
1718 'enum ' => 'Enums ' ,
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Xammie \MakeCommands \Commands ;
4+
5+ use Illuminate \Console \GeneratorCommand ;
6+ use Illuminate \Support \Str ;
7+
8+ class ConfigMakeCommand extends GeneratorCommand
9+ {
10+ use GeneratorTrait;
11+
12+ protected $ name = 'make:config ' ;
13+
14+ protected $ description = 'Create a new config file ' ;
15+
16+ protected $ type = 'Config ' ;
17+
18+ protected function stubName (): string
19+ {
20+ return 'config ' ;
21+ }
22+
23+ protected function getPath ($ name )
24+ {
25+ $ name = Str::replaceFirst ($ this ->rootNamespace (), '' , $ name );
26+
27+ return str_replace ('\\' , '/ ' , base_path ($ name )) . '.php ' ;
28+ }
29+
30+ protected function alreadyExists ($ rawName ): bool
31+ {
32+ return $ this ->files ->exists ($ this ->getPath ($ this ->qualifyClass ($ rawName )));
33+ }
34+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ return [
4+ /*
5+ |--------------------------------------------------------------------------
6+ | {{ class }}
7+ |--------------------------------------------------------------------------
8+ |
9+ | {{ class }} description...
10+ |
11+ */
12+
13+ 'key' => env('KEY', 'value'),
14+ ];
Original file line number Diff line number Diff line change 66use Spatie \LaravelPackageTools \PackageServiceProvider ;
77use Xammie \MakeCommands \Commands \ActionMakeCommand ;
88use Xammie \MakeCommands \Commands \CollectionMakeCommand ;
9+ use Xammie \MakeCommands \Commands \ConfigMakeCommand ;
910use Xammie \MakeCommands \Commands \ContractMakeCommand ;
1011use Xammie \MakeCommands \Commands \DtoMakeCommand ;
1112use Xammie \MakeCommands \Commands \EnumMakeCommand ;
@@ -24,6 +25,7 @@ public function configurePackage(Package $package): void
2425 ->hasCommands ([
2526 ActionMakeCommand::class,
2627 CollectionMakeCommand::class,
28+ ConfigMakeCommand::class,
2729 ContractMakeCommand::class,
2830 DtoMakeCommand::class,
2931 EnumMakeCommand::class,
Original file line number Diff line number Diff line change 33use function Pest \Laravel \artisan ;
44use Xammie \MakeCommands \Commands \ActionMakeCommand ;
55use Xammie \MakeCommands \Commands \CollectionMakeCommand ;
6+ use Xammie \MakeCommands \Commands \ConfigMakeCommand ;
67use Xammie \MakeCommands \Commands \ContractMakeCommand ;
78use Xammie \MakeCommands \Commands \DtoMakeCommand ;
89use Xammie \MakeCommands \Commands \EnumMakeCommand ;
1920 artisan (CollectionMakeCommand::class, ['name ' => 'TestCollection ' ])->assertExitCode (0 );
2021});
2122
23+ it ('can make config ' , function () {
24+ artisan (ConfigMakeCommand::class, ['name ' => 'test-config ' ])->assertExitCode (0 );
25+ });
26+
2227it ('can make contract ' , function () {
2328 artisan (ContractMakeCommand::class, ['name ' => 'TestContract ' ])->assertExitCode (0 );
2429});
You can’t perform that action at this time.
0 commit comments