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

valksor / php-dev-build / 19113736544

05 Nov 2025 11:28AM UTC coverage: 18.191% (+0.06%) from 18.133%
19113736544

push

github

k0d3r1s
code cleanup

5 of 27 new or added lines in 7 files covered. (18.52%)

1 existing line in 1 file now uncovered.

372 of 2045 relevant lines covered (18.19%)

0.97 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

20
use function array_filter;
21
use function is_dir;
22
use function scandir;
23

24
use const SCANDIR_SORT_ASCENDING;
25

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

33
    public function __construct(
34
        private readonly ParameterBagInterface $parameterBag,
35
    ) {
36
    }
×
37

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

45
        // Get available apps from the project
46
        $projectDir = $this->parameterBag->get('kernel.project_dir');
×
47
        $appsDir = $projectDir . '/' . $this->parameterBag->get('valksor.project.apps_dir');
×
48

49
        if (is_dir($appsDir)) {
×
NEW
50
            $apps = array_filter(scandir($appsDir, SCANDIR_SORT_ASCENDING), static function ($item) use ($appsDir) {
×
51
                $appPath = $appsDir . '/' . $item;
×
52

53
                return '.' !== $item && '..' !== $item && is_dir($appPath);
×
54
            });
×
55

56
            foreach ($apps as $app) {
×
57
                $arguments = ['valksor:importmap', '--id', $app];
×
58

59
                // Add minification automatically in production or if explicitly requested
60
                if ($shouldMinify) {
×
61
                    $arguments[] = '--minify';
×
62
                }
63

64
                $exitCode = ProcessManager::executeProcess($arguments, false, 'Importmap build for app ' . $app);
×
65

66
                if (Command::SUCCESS !== $exitCode) {
×
67
                    return Command::FAILURE;
×
68
                }
69
            }
70
        } else {
71
            // Fallback to running without app ID if no apps directory
72
            $arguments = ['valksor:importmap'];
×
73

74
            // Add minification automatically in production or if explicitly requested
75
            if ($shouldMinify) {
×
76
                $arguments[] = '--minify';
×
77
            }
78

79
            return ProcessManager::executeProcess($arguments, false, 'Importmap build');
×
80
        }
81

82
        return Command::SUCCESS;
×
83
    }
84

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

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

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

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

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

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

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