Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DiagnoseCommand.php

function DiagnoseCommand::checkComposerAudit

Return value

string|true

1 call to DiagnoseCommand::checkComposerAudit()
DiagnoseCommand::execute in vendor/composer/composer/src/Composer/Command/DiagnoseCommand.php
Executes the current command.

File

vendor/composer/composer/src/Composer/Command/DiagnoseCommand.php, line 569

Class

DiagnoseCommand
@author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Command

Code

private function checkComposerAudit(Config $config) {
    $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
    if ($result !== true) {
        return $result;
    }
    $auditor = new Auditor();
    $repoSet = new RepositorySet();
    $installedJson = new JsonFile(__DIR__ . '/../../../vendor/composer/installed.json');
    if (!$installedJson->exists()) {
        return '<warning>Could not find Composer\'s installed.json, this must be a non-standard Composer installation.</>';
    }
    $localRepo = new FilesystemRepository($installedJson);
    $version = Composer::getVersion();
    $packages = $localRepo->getCanonicalPackages();
    if ($version !== '@package_version@') {
        $versionParser = new VersionParser();
        $normalizedVersion = $versionParser->normalize($version);
        $rootPkg = new RootPackage('composer/composer', $normalizedVersion, $version);
        $packages[] = $rootPkg;
    }
    $repoSet->addRepository(new ComposerRepository([
        'type' => 'composer',
        'url' => 'https://packagist.org',
    ], new NullIO(), $config, $this->httpDownloader));
    try {
        $io = new BufferIO();
        $result = $auditor->audit($io, $repoSet, $packages, Auditor::FORMAT_TABLE, true, [], Auditor::ABANDONED_IGNORE);
    } catch (\Throwable $e) {
        return '<warning>Failed performing audit: ' . $e->getMessage() . '</>';
    }
    if ($result > 0) {
        return '<error>Audit found some issues:</>' . PHP_EOL . $io->getOutput();
    }
    return true;
}
RSS feed
Powered by Drupal