예제 #1
0
 *
 *
 *
 */
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/** @var Application $console */
$console->register('packagist:process-package')->setDefinition(array(new InputArgument('name', InputArgument::REQUIRED, 'name of the package'), new InputArgument('dir', InputArgument::REQUIRED, 'Directory to put the signature files into')))->setDescription('find all packages with this exact name and create signatures')->setCode(function (InputInterface $input, OutputInterface $output) use($config) {
    $name = $input->getArgument('name');
    $dir = $input->getArgument('dir');
    $client = new Packagist\Api\Client();
    $SignatureClient = new \Cotya\SignatureChainer\Client($config['userAgent'], $config['githubApiToken']);
    $storage = new \Cotya\SignatureChainer\Storage($dir . '/signatures');
    $packages = $client->get($name);
    $numberOfVersions = count($packages->getVersions());
    $output->writeln("found {$numberOfVersions} versions for {$packages->getName()}");
    foreach ($packages->getVersions() as $version) {
        /** @var \Packagist\Api\Result\Package\Version $version */
        if (!is_numeric(mb_substr($version->getVersionNormalized(), 0, 1, 'utf-8')) || mb_stripos($version->getVersionNormalized(), '-dev') !== false) {
            $output->writeln('jump over version: ' . $version->getVersionNormalized());
            continue;
        }
        $dist = $version->getDist();
        if (!$dist || !$dist->getUrl()) {
            $output->writeln('no Dist url found ');
            var_dump($dist);
            continue;
        }
예제 #2
0
        $csvFileHandle = fopen($outputFile, 'w');
    } else {
        $csvFileHandle = fopen(__DIR__ . '/packages.csv', 'w');
    }
    foreach ($packages['packages'] as $packageName => $versionList) {
        foreach ($versionList as $version => $package) {
            if (!isset($package['dist']['url'])) {
                continue;
            }
            if (!is_numeric(mb_substr($package['version'], 0, 1, 'utf-8')) || mb_stripos($package['version'], '-dev') !== false) {
                continue;
            }
            $url = $package['dist']['url'];
            $entry = [$packageName, $package['version'], $url];
            fputcsv($csvFileHandle, $entry);
        }
    }
    $output->writeln('command finished');
});
$console->register('validate-package')->setDefinition(array(new InputArgument('dir', InputArgument::REQUIRED, 'Directory name'), new InputArgument('name', InputArgument::REQUIRED, 'package name'), new InputArgument('version', InputArgument::REQUIRED, 'package version')))->setDescription('Displays the files in the given directory')->setCode(function (InputInterface $input, OutputInterface $output) use($config) {
    $dir = $input->getArgument('dir');
    $name = $input->getArgument('name');
    $version = $input->getArgument('version');
    $client = new \Cotya\SignatureChainer\Client($config['userAgent'], $config['githubApiToken']);
    $storage = new \Cotya\SignatureChainer\Storage($dir . '/signatures');
    $signatures = $storage->getSignaturesForPackageByNameAndVersion($name, $version);
    $client->downloadPackageWithValidation($signatures[0]);
    $output->writeln('command finished');
});
require __DIR__ . '/console/packagist.php';
$console->run();