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

orchestral / dusk-updater / 13354956518

16 Feb 2025 12:24PM UTC coverage: 59.406% (+13.7%) from 45.745%
13354956518

push

github

web-flow
Use `orchestra/dusk-updater-api` (#15)

* Use `orchestra/dusk-updater-api`

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

---------

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

36 of 40 new or added lines in 5 files covered. (90.0%)

1 existing line in 1 file now uncovered.

60 of 101 relevant lines covered (59.41%)

1.68 hits per line

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

0.0
/src/DetectCommand.php
1
<?php
2

3
namespace Orchestra\DuskUpdater;
4

5
use Composer\Semver\Comparator;
6
use Orchestra\DuskUpdaterApi\ChromeVersionFinder;
7
use Orchestra\DuskUpdaterApi\OperatingSystem;
8
use Symfony\Component\Console\Attribute\AsCommand;
9
use Symfony\Component\Console\Input\ArrayInput;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Input\InputOption;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use Symfony\Component\Console\Style\SymfonyStyle;
14

15
/**
16
 * @copyright Originally created by Jonas Staudenmeir: https://github.com/staudenmeir/dusk-updater
17
 */
18
#[AsCommand(name: 'detect', description: 'Detect the installed Chrome/Chromium version.')]
19
class DetectCommand extends Command
20
{
21
    /** {@inheritDoc */
22
    #[\Override]
23
    protected function configure(): void
24
    {
25
        $this->setName('detect')
×
26
            ->setDescription('Detect the installed Chrome/Chromium version.')
×
27
            ->addOption('chrome-dir', null, InputOption::VALUE_OPTIONAL, 'Detect the installed Chrome/Chromium version, optionally in a custom path')
×
28
            ->addOption('auto-update', null, InputOption::VALUE_NONE, 'Auto update ChromeDriver binary if outdated');
×
29

30
        parent::configure();
×
31
    }
32

33
    /** {@inheritDoc */
34
    #[\Override]
35
    protected function execute(InputInterface $input, OutputInterface $output): int
36
    {
NEW
37
        $finder = new ChromeVersionFinder;
×
UNCOV
38
        $io = new SymfonyStyle($input, $output);
×
39

40
        $chromeDirectory = $input->getOption('chrome-dir');
×
41
        $driverDirectory = $input->getOption('install-dir');
×
42
        $autoUpdate = $input->getOption('auto-update');
×
43

44
        $currentOS = OperatingSystem::id();
×
45

NEW
46
        $chromeVersions = $finder->installedChromeVersion($currentOS, $chromeDirectory);
×
NEW
47
        $driverVersions = $finder->installedChromeDriverVersion($currentOS, (string) $driverDirectory);
×
48

49
        $updated = Comparator::equalTo(
×
50
            isset($driverVersions['semver']) ? $driverVersions['semver'] : '',
×
51
            isset($chromeVersions['semver']) ? $chromeVersions['semver'] : ''
×
52
        );
×
53

54
        $io->block(\sprintf('Running PHP %s on Platform [%s]', PHP_VERSION, $currentOS));
×
55

56
        $io->table(['Tool', 'Version'], [
×
57
            ['Chrome/Chromium', $chromeVersions['semver'] ?? '<fg=yellow>✖ N/A</>'],
×
58
            ['ChromeDriver', $driverVersions['semver'] ?? '<fg=yellow>✖ N/A</>'],
×
59
        ]);
×
60

61
        if (! $updated) {
×
62
            if (! $autoUpdate) {
×
63
                $io->caution('ChromeDriver is outdated!');
×
64
            }
65

66
            if ($autoUpdate || $io->confirm('Do you want to update ChromeDriver?')) {
×
67
                $this->updateChromeDriver($input, $output, $driverDirectory, $chromeVersions['major']);
×
68
            }
69
        }
70

71
        return self::SUCCESS;
×
72
    }
73

74
    /**
75
     * Update ChromeDriver.
76
     */
77
    protected function updateChromeDriver(InputInterface $input, OutputInterface $output, string $directory, int $version): int
78
    {
79
        /** @var \Symfony\Component\Console\Application $console */
80
        $console = $this->getApplication();
×
81

82
        $command = $console->find('update');
×
83

84
        $arguments = array_merge([
×
85
            'command' => 'update',
×
86
            'version' => $version,
×
87
            '--install-dir' => $directory,
×
88
        ], array_filter([
×
89
            '--proxy' => $input->getOption('proxy'),
×
90
            '--ssl-no-verify' => $input->getOption('ssl-no-verify'),
×
91
        ]));
×
92

93
        return $command->run(new ArrayInput($arguments), $output);
×
94
    }
95
}
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