24
24
class PackageJsonSynchronizer
25
25
{
26
26
private $ rootDir ;
27
- private $ vendorDirname ;
27
+ private $ vendorDir ;
28
28
29
- public function __construct (string $ rootDir , string $ vendorDirname )
29
+ public function __construct (string $ rootDir , string $ vendorDir = ' vendor ' )
30
30
{
31
31
$ this ->rootDir = $ rootDir ;
32
- $ this ->vendorDirname = $ vendorDirname ;
32
+ $ this ->vendorDir = $ vendorDir ;
33
33
}
34
34
35
35
public function shouldSynchronize (): bool
@@ -42,7 +42,14 @@ public function synchronize(array $phpPackages): bool
42
42
// Remove all links and add again only the existing packages
43
43
$ didAddLink = $ this ->removePackageJsonLinks ((new JsonFile ($ this ->rootDir .'/package.json ' ))->read ());
44
44
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
+ }
46
53
$ didAddLink = $ this ->addPackageJsonLink ($ phpPackage ) || $ didAddLink ;
47
54
}
48
55
@@ -194,7 +201,7 @@ public function registerPeerDependencies(array $phpPackages)
194
201
195
202
private function resolvePackageJson (array $ phpPackage ): ?JsonFile
196
203
{
197
- $ packageDir = $ this ->rootDir .'/ ' .$ this ->vendorDirname .'/ ' .$ phpPackage ['name ' ];
204
+ $ packageDir = $ this ->rootDir .'/ ' .$ this ->vendorDir .'/ ' .$ phpPackage ['name ' ];
198
205
199
206
if (!\in_array ('symfony-ux ' , $ phpPackage ['keywords ' ] ?? [], true )) {
200
207
return null ;
0 commit comments