Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feat/composer-cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Oct 17, 2023
2 parents 09bcc05 + c4a7823 commit b4b017e
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Box Requirements Checker
========================

> Using PHP PHP_VERSION
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
> PHP is not using any php.ini file.

> Checking Box requirements:
✘ The application requires a version matching "^10".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Box Requirements Checker
========================

> Using PHP PHP_VERSION
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
> PHP is not using any php.ini file.

> Checking Box requirements:
✘ The application requires a version matching "^10".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Box Requirements Checker
========================

> Using PHP PHP_VERSION
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
> PHP is not using any php.ini file.

> Checking Box requirements:
✔ The application requires the extension "phar".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Box Requirements Checker
========================

> Using PHP PHP_VERSION
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
> PHP is not using any php.ini file.

> Checking Box requirements:
✔ The application requires a version matching ">=5.3".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Box Requirements Checker
========================

> Using PHP PHP_VERSION
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
> PHP is not using any php.ini file.

> Checking Box requirements:
✔ The application requires a version matching ">=5.3".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Box Requirements Checker
========================

> Using PHP PHP_VERSION
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
> PHP is not using any php.ini file.

> No requirements found.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Box Requirements Checker
========================

> Using PHP PHP_VERSION
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
> PHP is not using any php.ini file.

> No requirements found.

Expand Down
26 changes: 20 additions & 6 deletions src/Composer/ComposerOrchestrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function dumpAutoload(
return;
}

$autoloadFile = $this->retrieveAutoloadFile();
$autoloadFile = $this->getVendorDir().'/autoload.php';

$autoloadContents = AutoloadDumper::generateAutoloadStatements(
$symbolsRegistry,
Expand All @@ -148,6 +148,25 @@ public function dumpAutoload(
$this->fileSystem->dumpFile($autoloadFile, $autoloadContents);
}

public function getVendorDir(): string
{
$vendorDirProcess = $this->processFactory->getVendorDirProcess();

$this->logger->info($vendorDirProcess->getCommandLine());

$vendorDirProcess->run();

if (false === $vendorDirProcess->isSuccessful()) {
throw new RuntimeException(
'Could not retrieve the vendor dir.',
0,
new ProcessFailedException($vendorDirProcess),
);
}

return trim($vendorDirProcess->getOutput());
}

private function dumpAutoloader(bool $noDev): void
{
$dumpAutoloadProcess = $this->processFactory->getDumpAutoloaderProcess($noDev);
Expand Down Expand Up @@ -181,9 +200,4 @@ private function dumpAutoloader(bool $noDev): void
);
}
}

private function retrieveAutoloadFile(): string
{
return $this->getVendorDir().'/autoload.php';
}
}
20 changes: 13 additions & 7 deletions src/Composer/ComposerProcessFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public function __construct(

public function getVersionProcess(): Process
{
// Never use ANSI support here as we want to parse the raw output.
return $this->createProcess(
[
$this->composerExecutable,
'--version',
// Never use ANSI support here as we want to parse the raw output.
'--no-ansi',
],
// Ensure that even if this command gets executed within the app with --quiet it still
Expand Down Expand Up @@ -83,12 +83,18 @@ public function getDumpAutoloaderProcess(bool $noDev): Process

public function getVendorDirProcess(): Process
{
return $this->createProcess([
$this->composerExecutable,
'config',
'vendor-dir',
'--no-ansi',
]);
return $this->createProcess(
[
$this->composerExecutable,
'config',
'vendor-dir',
// Never use ANSI support here as we want to parse the raw output.
'--no-ansi',
],
// Ensure that even if this command gets executed within the app with --quiet it still
// works.
['SHELL_VERBOSITY' => 0],
);
}

private function createProcess(array $command, array $environmentVariables = []): Process
Expand Down

0 comments on commit b4b017e

Please sign in to comment.