2424class PackageJsonSynchronizer
2525{
2626 private $ rootDir ;
27- private $ vendorDirname ;
27+ private $ vendorDir ;
2828
29- public function __construct (string $ rootDir , string $ vendorDirname )
29+ public function __construct (string $ rootDir , string $ vendorDir = ' vendor ' )
3030 {
3131 $ this ->rootDir = $ rootDir ;
32- $ this ->vendorDirname = $ vendorDirname ;
32+ $ this ->vendorDir = $ vendorDir ;
3333 }
3434
3535 public function shouldSynchronize (): bool
@@ -42,7 +42,14 @@ public function synchronize(array $phpPackages): bool
4242 // Remove all links and add again only the existing packages
4343 $ didAddLink = $ this ->removePackageJsonLinks ((new JsonFile ($ this ->rootDir .'/package.json ' ))->read ());
4444
45- foreach ($ phpPackages as $ phpPackage ) {
45+ foreach ($ phpPackages as $ k => $ phpPackage ) {
46+ if (\is_string ($ phpPackage )) {
47+ // support for smooth upgrades from older flex versions
48+ $ phpPackages [$ k ] = $ phpPackage = [
49+ 'name ' => $ phpPackage ,
50+ 'keywords ' => ['symfony-ux ' ],
51+ ];
52+ }
4653 $ didAddLink = $ this ->addPackageJsonLink ($ phpPackage ) || $ didAddLink ;
4754 }
4855
@@ -194,7 +201,7 @@ public function registerPeerDependencies(array $phpPackages)
194201
195202 private function resolvePackageJson (array $ phpPackage ): ?JsonFile
196203 {
197- $ packageDir = $ this ->rootDir .'/ ' .$ this ->vendorDirname .'/ ' .$ phpPackage ['name ' ];
204+ $ packageDir = $ this ->rootDir .'/ ' .$ this ->vendorDir .'/ ' .$ phpPackage ['name ' ];
198205
199206 if (!\in_array ('symfony-ux ' , $ phpPackage ['keywords ' ] ?? [], true )) {
200207 return null ;
0 commit comments