• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

valksor / php-dev-build / 19705532601

26 Nov 2025 01:33PM UTC coverage: 30.503% (+2.6%) from 27.943%
19705532601

push

github

k0d3r1s
generic binary provider

131 of 243 new or added lines in 7 files covered. (53.91%)

135 existing lines in 7 files now uncovered.

783 of 2567 relevant lines covered (30.5%)

1.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Command/BinaryInstallCommand.php
1
<?php declare(strict_types = 1);
2

3
/*
4
 * This file is part of the Valksor package.
5
 *
6
 * (c) Davis Zalitis (k0d3r1s)
7
 * (c) SIA Valksor <packages@valksor.com>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12

13
namespace ValksorDev\Build\Command;
14

15
use Exception;
16
use Symfony\Component\Console\Attribute\AsCommand;
17
use Symfony\Component\Console\Command\Command;
18
use Symfony\Component\Console\Input\InputInterface;
19
use Symfony\Component\Console\Output\OutputInterface;
20
use Symfony\Component\Console\Style\SymfonyStyle;
21
use Symfony\Component\DependencyInjection\Attribute\Autowire;
22
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
23
use ValksorDev\Build\Binary\BinaryRegistry;
24
use ValksorDev\Build\Provider\ProviderRegistry;
25

26
use function count;
27
use function sprintf;
28

29
#[AsCommand(name: 'valksor:binaries:install', description: 'Install all required binaries.')]
30
final class BinaryInstallCommand extends AbstractCommand
31
{
32
    public function __construct(
33
        ParameterBagInterface $parameterParameterBag,
34
        private readonly BinaryRegistry $binaryRegistry,
35
        #[Autowire(
36
            param: 'valksor.build.services',
37
        )]
38
        private readonly array $servicesConfig,
39
        ProviderRegistry $providerRegistry,
40
    ) {
41
        parent::__construct($parameterParameterBag, $providerRegistry);
×
42
    }
43

44
    public function __invoke(
45
        InputInterface $input,
46
        OutputInterface $output,
47
    ): int {
48
        $io = new SymfonyStyle($input, $output);
×
49

50
        $io->title('Installing Required Binaries');
×
51

52
        // Get required binaries from services configuration
53
        $binaryService = $this->servicesConfig['binaries'] ?? [];
×
NEW
54
        $requiredBinaries = $binaryService['options']['required'];
×
55

56
        if (empty($requiredBinaries)) {
×
57
            $io->warning('No binaries required in configuration.');
×
58

59
            return Command::SUCCESS;
×
60
        }
61

62
        $projectRoot = $this->parameterBag->get('kernel.project_dir');
×
63
        $varDir = $projectRoot . '/var';
×
64

65
        $successCount = 0;
×
66
        $totalCount = count($requiredBinaries);
×
67

68
        foreach ($requiredBinaries as $binary) {
×
69
            $io->section(sprintf('Installing %s', $binary));
×
70

71
            if (!$this->binaryRegistry->has($binary)) {
×
72
                $io->warning(sprintf('Binary %s not found in registry, skipping...', $binary));
×
73

74
                continue;
×
75
            }
76

77
            try {
NEW
78
                $tag = $this->binaryRegistry->get($binary)->createManager($varDir, $binary)?->ensureLatest([$io, 'text']);
×
79
                $io->success(sprintf('✓ %s installed (%s)', $binary, $tag));
×
80
                $successCount++;
×
81
            } catch (Exception $e) {
×
82
                $io->error(sprintf('Failed to install %s: %s', $binary, $e->getMessage()));
×
83
            }
84
        }
85

86
        // Check for and install Generic NPM packages
NEW
87
        $genericProvider = $this->binaryRegistry->getGenericNpmProvider();
×
88

NEW
89
        if ($genericProvider && $genericProvider->getPackageCount() > 0) {
×
NEW
90
            $io->section('Installing Generic NPM Packages');
×
91

92
            try {
NEW
93
                $packageNames = $genericProvider->getPackages();
×
NEW
94
                $versions = $genericProvider->ensureAll([$io, 'text']);
×
95

NEW
96
                foreach ($packageNames as $i => $packageName) {
×
NEW
97
                    $io->success(sprintf('✓ %s installed (%s)', $packageName, $versions[$i] ?? 'unknown'));
×
98
                }
99

100
                // Sync packages to public/vendor
NEW
101
                $io->section('Syncing Packages to public/vendor');
×
102

NEW
103
                foreach ($genericProvider->syncToPublicVendor([$io, 'text']) as $packageName) {
×
NEW
104
                    $io->success(sprintf('✓ %s synced to public/vendor', $packageName));
×
105
                }
106

NEW
107
                $successCount += count($packageNames);
×
NEW
108
                $totalCount += count($packageNames);
×
NEW
109
            } catch (Exception $e) {
×
NEW
110
                $io->error(sprintf('Failed to install Generic NPM packages: %s', $e->getMessage()));
×
111
            }
112
        }
113

UNCOV
114
        $io->newLine();
×
115

116
        if ($successCount === $totalCount) {
×
117
            $io->success(sprintf('All %d binaries installed successfully!', $totalCount));
×
118

119
            return Command::SUCCESS;
×
120
        }
121
        $io->warning(sprintf('%d/%d binaries installed successfully.', $successCount, $totalCount));
×
122

123
        return Command::FAILURE;
×
124
    }
125
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc