@@ -129,6 +129,7 @@ public function init(string $name): void
129129 'init ' ,
130130 '--no-interaction ' ,
131131 sprintf ('--name=%s ' , $ name ),
132+ '--require=php:^8.2 ' ,
132133 );
133134
134135 $ this ->allowPlugins ('php-http/discovery ' );
@@ -163,20 +164,14 @@ public function denyPlugins(string ...$plugins): void
163164 */
164165 public function autoload (array $ autoloads ): void
165166 {
167+ $ composer = json_decode (file_get_contents ($ this ->workdir .'/composer.json ' ), true , 512 , \JSON_THROW_ON_ERROR );
166168 foreach ($ autoloads as $ type => $ autoload ) {
167169 match ($ type ) {
168- 'psr4 ' => $ this ->pipe (
169- $ this ->subcommand ('cat ' , 'composer.json ' ),
170- $ this ->subcommand ('jq ' , '--indent ' , '4 ' , sprintf ('.autoload."psr-4" |= . + %s ' , json_encode ($ autoload , \JSON_THROW_ON_ERROR ))),
171- $ this ->subcommand ('tee ' , 'composer.json ' ),
172- ),
173- 'file ' => $ this ->pipe (
174- $ this ->subcommand ('cat ' , 'composer.json ' ),
175- $ this ->subcommand ('jq ' , '--indent ' , '4 ' , sprintf ('.autoload."file" |= . + %s ' , json_encode ($ autoload , \JSON_THROW_ON_ERROR ))),
176- $ this ->subcommand ('tee ' , 'composer.json ' ),
177- )
170+ 'psr4 ' => $ composer ['autoload ' ]['psr-4 ' ] = $ autoload ,
171+ 'file ' => $ composer ['autoload ' ]['file ' ] = $ autoload ,
178172 };
179173 }
174+ file_put_contents ($ this ->workdir .'/composer.json ' , json_encode ($ composer , \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES ));
180175 }
181176
182177 public function install (): void
0 commit comments