@@ -15,7 +15,7 @@ private function show(): void
1515 {
1616 $ fullStatus = $ this ->check ();
1717
18- $ headers = ['Package ' , 'Type ' , 'Active ' , 'Valid ' , 'Linked ' , 'Version ' , 'Path ' ];
18+ $ headers = ['Package ' , 'Type ' , 'Enabled ' , 'Valid ' , 'Active ' , 'Version ' , 'Path ' ];
1919 $ rows = array_map (function ($ row ) {
2020 $ type = match ($ row ['type ' ]) {
2121 'local ' => '<fg=yellow>local</> ' ,
@@ -24,7 +24,7 @@ private function show(): void
2424 default => $ row ['type ' ],
2525 };
2626
27- $ version = $ this ->getInstalledVersion ($ row ['name ' ], $ row );
27+ $ version = $ this ->getInstalledVersion ($ row ['name ' ], $ row[ ' config ' ] );
2828 $ path = $ this ->getShortPath ($ row );
2929
3030 return [
@@ -83,14 +83,29 @@ private function getInstalledVersion(string $name, array $package): ?string
8383 }
8484
8585 $ lockData = json_decode (file_get_contents ($ composerLock ), true );
86+ if (json_last_error () !== JSON_ERROR_NONE ) {
87+ info ("Invalid composer.lock JSON for $ name " );
88+
89+ return null ;
90+ }
91+
8692 foreach ([$ lockData ['packages ' ] ?? [], $ lockData ['packages-dev ' ] ?? []] as $ packages ) {
8793 foreach ($ packages as $ pkg ) {
88- if ($ pkg ['name ' ] === $ packageName ) {
89- return $ pkg ['version ' ];
94+ if (( $ pkg ['name ' ] ?? '' ) === $ packageName ) {
95+ return $ pkg ['version ' ] ?? null ;
9096 }
9197 }
9298 }
9399
100+ // If not found in lock file but composer.json exists, assume dev-main
101+ $ path = $ package ['path ' ] ?? '' ;
102+ if ($ path && ! str_contains ($ path , 'disabled/ ' )) {
103+ $ composerJson = realpath (base_path ($ path )).'/composer.json ' ;
104+ if (file_exists ($ composerJson )) {
105+ return 'dev-main ' ;
106+ }
107+ }
108+
94109 return null ;
95110 }
96111
@@ -127,20 +142,21 @@ private function getPackageName(string $name, array $package): ?string
127142 $ isLocal = ($ package ['type ' ] ?? '' ) === 'local ' ;
128143 $ path = $ isLocal ? "packages/ $ name " : ($ package ['path ' ] ?? '' );
129144
130- if (! $ path || ! is_dir ($ path )) {
145+ if (! $ path || str_contains ($ path, ' disabled/ ' )) {
131146 return null ;
132147 }
133148
149+ if (str_starts_with ($ path , '../ ' )) {
150+ $ path = realpath (base_path ($ path ));
151+ }
152+
134153 $ composerJson = "$ path/composer.json " ;
135154 if (! file_exists ($ composerJson )) {
136155 return null ;
137156 }
138157
139158 $ data = json_decode (file_get_contents ($ composerJson ), true );
140- if (! isset ($ data ['name ' ])) {
141- return null ;
142- }
143159
144- return $ data ['name ' ];
160+ return $ data ['name ' ] ?? null ;
145161 }
146162}
0 commit comments