1111use Cake \Log \Log ;
1212use Composer \Semver \Intervals ;
1313use Composer \Semver \VersionParser ;
14- use Packagist \Api \Client ;
14+ use GuzzleHttp \Client as HttpClient ;
15+ use Packagist \Api \Client as PackagistClient ;
1516use Packagist \Api \Result \Package \Version ;
1617use UnexpectedValueException ;
1718
@@ -47,7 +48,7 @@ class SyncPackagesCommand extends Command
4748 '5 ' => [0 , 1 , 2 , 3 ],
4849 ];
4950
50- private readonly Client $ client ;
51+ private readonly PackagistClient $ client ;
5152
5253 /**
5354 * The name of this command.
@@ -71,7 +72,7 @@ public static function defaultName(): string
7172 */
7273 public static function getDescription (): string
7374 {
74- return 'Command description here. ' ;
75+ return 'Sync all packages from packagist.org marked cakephp-plugin ' ;
7576 }
7677
7778 /**
@@ -81,7 +82,23 @@ public function __construct(
8182 ?CommandFactoryInterface $ factory = null ,
8283 ) {
8384 parent ::__construct ($ factory );
84- $ this ->client = new Client ();
85+ $ this ->client = new PackagistClient ($ this ->createPackagistHttpClient ());
86+ }
87+
88+ /**
89+ * @return \GuzzleHttp\Client
90+ */
91+ private function createPackagistHttpClient (): HttpClient
92+ {
93+ return new HttpClient ([
94+ 'headers ' => [
95+ 'User-Agent ' => env (
96+ 'PACKAGIST_USER_AGENT ' ,
97+ 'plugins.cakephp.org (https://plugins.cakephp.org; mailto=security@cakephp.org) ' ,
98+ ),
99+ ],
100+ 'version ' => 2.0 ,
101+ ]);
85102 }
86103
87104 /**
@@ -106,6 +123,7 @@ public function execute(Arguments $args, ConsoleIo $io): void
106123 $ failed = 0 ;
107124 $ i = 0 ;
108125
126+ /** @var \Cake\Command\Helper\ProgressHelper $progress */
109127 $ progress = $ io ->helper ('Progress ' );
110128 $ progress ->init (['total ' => $ total , 'width ' => 60 ]);
111129 $ io ->out ('' , 0 );
0 commit comments