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

eliashaeussler / version-bumper / 24529462145

16 Apr 2026 07:22PM UTC coverage: 88.084% (+0.09%) from 87.996%
24529462145

push

github

web-flow
Merge pull request #125 from eliashaeussler/feature/actions

[FEATURE] Introduce actions

242 of 289 new or added lines in 20 files covered. (83.74%)

2 existing lines in 2 files now uncovered.

1094 of 1242 relevant lines covered (88.08%)

4.98 hits per line

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

93.1
/src/Version/Action/PackageLockAction.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "eliashaeussler/version-bumper".
7
 *
8
 * Copyright (C) 2024-2026 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\VersionBumper\Version\Action;
25

26
use EliasHaeussler\VersionBumper\Config;
27
use EliasHaeussler\VersionBumper\Result;
28
use Symfony\Component\Console;
29
use Symfony\Component\Process;
30

31
use function dirname;
32
use function implode;
33
use function is_file;
34
use function iterator_to_array;
35

36
/**
37
 * PackageLockAction.
38
 *
39
 * @author Elias Häußler <elias@haeussler.dev>
40
 * @license GPL-3.0-or-later
41
 */
42
final readonly class PackageLockAction implements Action
43
{
44
    public function execute(
3✔
45
        string $rootPath,
46
        Config\FileToModify $sourceFile,
47
        Console\Output\OutputInterface $output,
48
    ): Result\ActionExecutionResult {
49
        $npmPrefix = dirname($sourceFile->fullPath($rootPath));
3✔
50
        $lockFilename = $npmPrefix.'/package-lock.json';
3✔
51
        $resultOutput = new Console\Output\BufferedOutput();
3✔
52

53
        // Early return if lock file does not exist
54
        if (!is_file($lockFilename)) {
3✔
55
            return Result\ActionExecutionResult::skipped($this);
1✔
56
        }
57

58
        $process = new Process\Process([
2✔
59
            'npm',
2✔
60
            'install',
2✔
61
            '--prefix',
2✔
62
            $npmPrefix,
2✔
63
            '--package-lock-only',
2✔
64
        ]);
2✔
65

66
        $exitCode = $process->run();
2✔
67

68
        if ($process->isSuccessful()) {
2✔
69
            return Result\ActionExecutionResult::success($this, [
1✔
70
                new Result\VersionBumpResult(
1✔
71
                    new Config\FileToModify($lockFilename),
1✔
72
                    [
1✔
73
                        Result\WriteOperation::regenerated(),
1✔
74
                    ],
1✔
75
                ),
1✔
76
            ]);
1✔
77
        }
78

79
        // Merge stdout and stderr
80
        $resultOutput->writeln(
1✔
81
            implode('', iterator_to_array($process)),
1✔
82
        );
1✔
83

84
        return new Result\ActionExecutionResult($this, $exitCode, [], $resultOutput->fetch());
1✔
85
    }
86

NEW
87
    public static function getIdentifier(): string
×
88
    {
NEW
89
        return 'package-lock';
×
90
    }
91
}
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