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

valksor / php-dev-build / 19202038340

09 Nov 2025 02:25AM UTC coverage: 17.283% (-0.9%) from 18.191%
19202038340

push

github

k0d3r1s
update documentation

383 of 2216 relevant lines covered (17.28%)

0.92 hits per line

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

0.0
/Provider/ImportmapProvider.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\Provider;
14

15
use Symfony\Component\Console\Command\Command;
16
use Symfony\Component\Console\Style\SymfonyStyle;
17
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
18
use ValksorDev\Build\Service\ProcessManager;
19
use ValksorDev\Build\Util\ConsoleCommandBuilder;
20

21
use function array_filter;
22
use function is_dir;
23
use function rtrim;
24
use function scandir;
25

26
use const SCANDIR_SORT_ASCENDING;
27

28
/**
29
 * Provider for Importmap service.
30
 */
31
final class ImportmapProvider implements ProviderInterface, IoAwareInterface
32
{
33
    private ?SymfonyStyle $io = null;
34

35
    public function __construct(
36
        private readonly ParameterBagInterface $parameterBag,
37
        private readonly ConsoleCommandBuilder $commandBuilder,
38
        private readonly ProcessManager $processManager,
39
    ) {
40
    }
×
41

42
    public function build(
43
        array $options,
44
    ): int {
45
        // Check if we should force minification in production
46
        $isProductionEnvironment = ($options['environment'] ?? 'dev') === 'prod';
×
47
        $shouldMinify = $isProductionEnvironment || ($options['minify'] ?? false);
×
48

49
        // Get available apps from the project
50
        $projectDir = $this->parameterBag->get('kernel.project_dir');
×
51
        $appsDir = $projectDir . '/' . $this->parameterBag->get('valksor.project.apps_dir');
×
52

53
        if (is_dir($appsDir) && rtrim($projectDir, '/') !== rtrim($appsDir, '/')) {
×
54
            $apps = array_filter(scandir($appsDir, SCANDIR_SORT_ASCENDING), static function ($item) use ($appsDir) {
×
55
                $appPath = $appsDir . '/' . $item;
×
56

57
                return '.' !== $item && '..' !== $item && is_dir($appPath);
×
58
            });
×
59

60
            foreach ($apps as $app) {
×
61
                $arguments = $this->commandBuilder->buildArguments('valksor:importmap', [
×
62
                    'app' => $app,
×
63
                    'minify' => $shouldMinify,
×
64
                ]);
×
65

66
                $exitCode = $this->processManager->executeProcess($arguments, false, 'Importmap build for app ' . $app);
×
67

68
                if (Command::SUCCESS !== $exitCode) {
×
69
                    return Command::FAILURE;
×
70
                }
71
            }
72
        } else {
73
            // Fallback to running without app ID if no apps directory
74
            $arguments = $this->commandBuilder->buildArguments('valksor:importmap', [
×
75
                'minify' => $shouldMinify,
×
76
            ]);
×
77

78
            return $this->processManager->executeProcess($arguments, false, 'Importmap build');
×
79
        }
80

81
        return Command::SUCCESS;
×
82
    }
83

84
    public function getDependencies(): array
85
    {
86
        return ['binaries']; // Ensure binaries run first
×
87
    }
88

89
    public function getName(): string
90
    {
91
        return 'importmap';
×
92
    }
93

94
    public function getServiceOrder(): int
95
    {
96
        return 25; // Run after binaries and tailwind, before hot_reload
×
97
    }
98

99
    public function init(
100
        array $options,
101
    ): void {
102
        // Importmap doesn't need initialization
103
    }
×
104

105
    public function setIo(
106
        SymfonyStyle $io,
107
    ): void {
108
        $this->io = $io;
×
109
    }
110

111
    public function watch(
112
        array $options,
113
    ): int {
114
        $arguments = $this->commandBuilder->buildArguments('valksor:importmap', [
×
115
            'watch' => true,
×
116
        ]);
×
117
        $isInteractive = $options['interactive'] ?? true;
×
118

119
        return $this->processManager->executeProcess($arguments, $isInteractive, 'Importmap service');
×
120
    }
121
}
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