@@ -15,6 +15,7 @@ private function link(): void
1515 $ this ->createSymlinks ();
1616 $ this ->updateComposerJson ();
1717 $ this ->createLinkedComposerJson ();
18+ $ this ->removeDeployComposerJson ();
1819 }
1920
2021 private function prepare (): void
@@ -148,12 +149,14 @@ private function composerRemovePackages(): void
148149 foreach ($ composerJson ['repositories ' ] ?? [] as $ key => $ repo ) {
149150 if ($ repo ['type ' ] === 'path ' && str_starts_with ($ repo ['url ' ], $ packagesBaseName .'/ ' )) {
150151 $ package = basename ($ repo ['url ' ]);
152+ $ packageName = $ this ->getPackageName ($ package , $ configuredPackages [$ package ] ?? []);
151153
152- if (! isset ($ configuredPackages [$ package ]) || ! ($ configuredPackages [$ package ]['active ' ] ?? false )) {
154+ if (! isset ($ configuredPackages [$ package ]) ||
155+ ! ($ configuredPackages [$ package ]['active ' ] ?? false )) {
153156 $ removedPackages [] = [
154157 'key ' => $ key ,
155158 'package ' => $ package ,
156- 'name ' => " moox/ $ package" ,
159+ 'name ' => $ packageName ?? $ package ,
157160 ];
158161 }
159162 }
@@ -206,24 +209,25 @@ private function updateComposerJson(): void
206209 $ removedRepos = [];
207210 $ removedRequires = [];
208211
209- // First, remove inactive packages
210212 foreach ($ repositories as $ key => $ repo ) {
211213 if (($ repo ['type ' ] ?? '' ) === 'path ' ) {
212214 $ name = basename ($ repo ['url ' ]);
213215 $ package = $ this ->packages [$ name ] ?? null ;
214216
215217 if (! $ package || ! ($ package ['active ' ] ?? false )) {
216218 unset($ repositories [$ key ]);
217- unset($ require ["moox/ $ name " ]);
218- unset($ requireDev ["moox/ $ name " ]);
219- $ removedRepos [] = $ name ;
220- $ removedRequires [] = "moox/ $ name " ;
221- $ updated = true ;
219+ $ packageName = $ this ->getPackageName ($ name , $ package ?? []);
220+ if ($ packageName ) {
221+ unset($ require [$ packageName ]);
222+ unset($ requireDev [$ packageName ]);
223+ $ removedRepos [] = $ name ;
224+ $ removedRequires [] = $ packageName ;
225+ $ updated = true ;
226+ }
222227 }
223228 }
224229 }
225230
226- // Then add or update active packages
227231 foreach ($ this ->packages as $ name => $ package ) {
228232 if (! ($ package ['active ' ] ?? false )) {
229233 continue ;
@@ -270,7 +274,6 @@ private function updateComposerJson(): void
270274 $ updated = true ;
271275 }
272276
273- // Remove from the other section if it exists
274277 if ($ isDev && isset ($ require [$ packageName ])) {
275278 unset($ require [$ packageName ]);
276279 $ updated = true ;
@@ -279,7 +282,6 @@ private function updateComposerJson(): void
279282 $ updated = true ;
280283 }
281284
282- // Add to the correct section if not present
283285 if ($ isDev && ! isset ($ requireDev [$ packageName ])) {
284286 $ requireDev [$ packageName ] = '* ' ;
285287 $ addedRequires [] = $ packageName .' (dev) ' ;
@@ -383,4 +385,13 @@ private function createLinkedComposerJson(): void
383385
384386 info ('Created composer.json-linked with local package repositories ' );
385387 }
388+
389+ private function removeDeployComposerJson (): void
390+ {
391+ $ deployPath = dirname ($ this ->composerJsonPath ).'/composer.json-deploy ' ;
392+ if (file_exists ($ deployPath )) {
393+ unlink ($ deployPath );
394+ info ('Removed composer.json-deploy ' );
395+ }
396+ }
386397}
0 commit comments