• 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/ProdBuildCommand.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 RuntimeException;
17
use Symfony\Component\Console\Attribute\AsCommand;
18
use Symfony\Component\Console\Command\Command;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21
use Symfony\Component\Console\Style\SymfonyStyle;
22
use ValksorDev\Build\Provider\IoAwareInterface;
23

24
use function count;
25
use function implode;
26
use function sprintf;
27
use function ucfirst;
28

29
#[AsCommand(name: 'valksor-prod:build', description: 'Build all production assets using the new flag-based service system.')]
30
final class ProdBuildCommand extends AbstractCommand
31
{
32
    public function __invoke(
33
        InputInterface $input,
34
        OutputInterface $output,
35
    ): int {
UNCOV
36
        $io = new SymfonyStyle($input, $output);
×
37

UNCOV
38
        $io->title('Production Build');
×
39

40
        // Get services configuration from ParameterBag
UNCOV
41
        $servicesConfig = $this->parameterBag->get('valksor.build.services');
×
42

43
        // Run init phase first
UNCOV
44
        $this->runInit($io);
×
45

46
        // Get providers that should run in production (prod=true)
UNCOV
47
        $prodProviders = $this->providerRegistry->getProvidersByFlag($servicesConfig, 'prod');
×
48

49
        if (empty($prodProviders)) {
×
UNCOV
50
            $io->warning('No production services are enabled in configuration.');
×
51

UNCOV
52
            return Command::SUCCESS;
×
53
        }
54

55
        // Validate all configured providers exist
UNCOV
56
        $missingProviders = $this->providerRegistry->validateProviders($servicesConfig);
×
57

58
        if (!empty($missingProviders)) {
×
UNCOV
59
            $io->error(sprintf('Missing providers for: %s', implode(', ', $missingProviders)));
×
60

UNCOV
61
            return Command::FAILURE;
×
62
        }
63

64
        $stepCount = count($prodProviders);
×
UNCOV
65
        $currentStep = 1;
×
66

67
        $io->text(sprintf('Running %d production service(s)...', $stepCount));
×
UNCOV
68
        $io->newLine();
×
69

70
        foreach ($prodProviders as $name => $provider) {
×
UNCOV
71
            $io->section(sprintf('Step %d/%d: %s', $currentStep, $stepCount, ucfirst($name)));
×
72

73
            $config = $servicesConfig[$name] ?? [];
×
UNCOV
74
            $options = $config['options'] ?? [];
×
75

76
            // Force production environment for all providers
UNCOV
77
            $options['environment'] = 'prod';
×
78

79
            // Enable minification for importmap service in production builds
UNCOV
80
            if ('importmap' === $name) {
×
81
                $options['minify'] = true;
×
82
            }
83

84
            // Set IO for providers that need it
UNCOV
85
            if ($provider instanceof IoAwareInterface) {
×
UNCOV
86
                $provider->setIo($io);
×
87
            }
88

89
            try {
UNCOV
90
                $result = $provider->build($options);
×
91

UNCOV
92
                if (Command::SUCCESS !== $result) {
×
UNCOV
93
                    $io->error(sprintf('Service "%s" failed with exit code %d', $name, $result));
×
94

UNCOV
95
                    return Command::FAILURE;
×
96
                }
97

UNCOV
98
                $io->success(sprintf('✓ %s completed successfully', ucfirst($name)));
×
99
            } catch (Exception $e) {
×
UNCOV
100
                $io->error(sprintf('Service "%s" failed: %s', $name, $e->getMessage()));
×
101

UNCOV
102
                return Command::FAILURE;
×
103
            }
104

UNCOV
105
            $currentStep++;
×
106
        }
107

UNCOV
108
        $io->success('Production build completed successfully!');
×
109

UNCOV
110
        return Command::SUCCESS;
×
111
    }
112

113
    /**
114
     * Run a single provider with error handling.
115
     */
116
    protected function runProvider(
117
        string $name,
118
        $provider,
119
        array $options,
120
    ): void {
121
        try {
UNCOV
122
            $provider->init($options);
×
UNCOV
123
        } catch (Exception $e) {
×
124
            // In production, fail fast
UNCOV
125
            throw new RuntimeException("Provider '$name' failed: " . $e->getMessage(), 0, $e);
×
126
        }
127
    }
128
}
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