22
33namespace App \Commands ;
44
5- use App \Parser \DetectWalker ;
6- use Illuminate \Support \Facades \File ;
75use LaravelZero \Framework \Commands \Command ;
86
9- use function Laravel \Prompts \info ;
10-
117class ContextTypeScriptGeneratorCommand extends Command
128{
139 protected $ signature = 'generate-ts ' ;
@@ -19,9 +15,9 @@ public function handle(): void
1915 $ this ->line ('namespace AutocompleteParsingResult { ' );
2016
2117 $ classes = collect (glob (base_path ('app/Contexts/*.php ' )))
22- ->filter (fn ($ file ) => !str_contains ($ file , 'Abstract ' ));
18+ ->filter (fn ($ file ) => !str_contains ($ file , 'Abstract ' ));
2319
24- $ this ->line (" type Result = " . $ classes ->map (fn ($ file ) => pathinfo ($ file , PATHINFO_FILENAME ))->join (' | ' ) . '; ' );
20+ $ this ->line (' type Result = ' . $ classes ->map (fn ($ file ) => pathinfo ($ file , PATHINFO_FILENAME ))->join (' | ' ) . '; ' );
2521
2622 $ this ->newLine ();
2723
@@ -36,34 +32,32 @@ public function handle(): void
3632 $ reflection = new \ReflectionClass ($ inst );
3733
3834 $ this ->line ("type: ' {$ inst ->type ()}'; " );
39- $ this ->line (" parent: Result | null; " );
35+ $ this ->line (' parent: Result | null; ' );
4036
4137 if ($ reflection ->getProperty ('hasChildren ' )->getValue ($ inst )) {
42- $ this ->line (" children: Result[]; " );
38+ $ this ->line (' children: Result[]; ' );
4339 }
4440
4541 $ properties = collect ($ reflection ->getProperties (\ReflectionProperty::IS_PUBLIC ))
46- ->filter (fn ($ prop ) => !in_array ($ prop ->getName (), [
42+ ->filter (fn ($ prop ) => !in_array ($ prop ->getName (), [
4743 'children ' ,
4844 'autocompleting ' ,
4945 'freshObject ' ,
5046 'hasChildren ' ,
5147 'parent ' ,
52- 'label '
48+ 'label ' ,
5349 ]))
54- ->map (fn ($ prop ) => [
55- 'name ' => $ prop ->getName (),
56- 'type ' => str_replace ('App\Contexts \\' , '' , $ prop ->getType ()?->getName() ?? 'any ' ),
57- 'default ' => $ prop ->getValue ($ inst )
50+ ->map (fn ($ prop ) => [
51+ 'name ' => $ prop ->getName (),
52+ 'type ' => str_replace ('App\Contexts \\' , '' , $ prop ->getType ()?->getName() ?? 'any ' ),
53+ 'default ' => $ prop ->getValue ($ inst ),
5854 ])
5955 ->each (function ($ prop ) {
6056 $ addon = ($ prop ['default ' ] === null ) ? ' | null ' : '' ;
6157 $ this ->line ("{$ prop ['name ' ]}: {$ prop ['type ' ]}{$ addon }; " );
6258 });
6359
64-
65-
66- $ this ->line ("} " );
60+ $ this ->line ('} ' );
6761 $ this ->newLine ();
6862 });
6963
0 commit comments