• 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/TailwindProvider.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 Tailwind CSS service.
30
 */
31
final class TailwindProvider 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
        // In production mode, build all apps
46
        // Get available apps from the project
47
        $projectDir = $this->parameterBag->get('kernel.project_dir');
×
48
        $appsDir = $projectDir . '/' . $this->parameterBag->get('valksor.project.apps_dir');
×
49

50
        // Check if we should force minification in production
51
        $isProductionEnvironment = ($options['environment'] ?? 'dev') === 'prod';
×
52
        $shouldMinify = $isProductionEnvironment || ($options['minify'] ?? false);
×
53

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

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

61
            foreach ($apps as $app) {
×
62
                $process = $this->commandBuilder->build('valksor:tailwind', [
×
63
                    'app' => $app,
×
64
                    'minify' => $shouldMinify,
×
65
                ]);
×
66
                $process->run();
×
67

68
                if (!$process->isSuccessful()) {
×
69
                    // Log error output for debugging
70
                    $this->io?->error('Tailwind provider failed for app ' . $app . ': ' . $process->getErrorOutput());
×
71

72
                    return Command::FAILURE;
×
73
                }
74
            }
75
        } else {
76
            // Fallback to running without app ID if no apps directory
77
            $process = $this->commandBuilder->build('valksor:tailwind', [
×
78
                'minify' => $shouldMinify,
×
79
            ]);
×
80
            $process->run();
×
81

82
            return $process->isSuccessful() ? Command::SUCCESS : Command::FAILURE;
×
83
        }
84

85
        return Command::SUCCESS;
×
86
    }
87

88
    public function getDependencies(): array
89
    {
90
        return ['binaries']; // Ensure binaries run first
×
91
    }
92

93
    public function getName(): string
94
    {
95
        return 'tailwind';
×
96
    }
97

98
    public function getServiceOrder(): int
99
    {
100
        return 20; // Run after binaries (10) but before others
×
101
    }
102

103
    public function init(
104
        array $options,
105
    ): void {
106
        // Tailwind doesn't need initialization
107
    }
×
108

109
    public function setIo(
110
        SymfonyStyle $io,
111
    ): void {
112
        $this->io = $io;
×
113
    }
114

115
    public function watch(
116
        array $options,
117
    ): int {
118
        $arguments = $this->commandBuilder->buildArguments('valksor:tailwind', [
×
119
            'watch' => true,
×
120
        ]);
×
121
        $isInteractive = $options['interactive'] ?? true;
×
122

123
        return $this->processManager->executeProcess($arguments, $isInteractive, 'Tailwind service');
×
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