Skip to content

Commit 5b39513

Browse files
authored
Merge pull request #20 from KaririCode-Framework/develop
Develop
2 parents fba216a + e668fd9 commit 5b39513

File tree

6 files changed

+58
-7
lines changed

6 files changed

+58
-7
lines changed

bin/kcode

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ declare(strict_types=1);
6868
$devkit->addRunner(new \KaririCode\Devkit\Runner\PhpStanRunner($executor, $context));
6969
$devkit->addRunner(new \KaririCode\Devkit\Runner\CsFixerRunner($executor, $context));
7070
$devkit->addRunner(new \KaririCode\Devkit\Runner\RectorRunner($executor, $context));
71+
$devkit->addRunner(new \KaririCode\Devkit\Runner\RectorApplyRunner($executor, $context));
7172
$devkit->addRunner(new \KaririCode\Devkit\Runner\PsalmRunner($executor, $context));
7273
$devkit->addRunner(new \KaririCode\Devkit\Runner\ComposerAuditRunner($executor, $context));
7374
}

build/kcode.phar

1.19 KB
Binary file not shown.

composer.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
{
22
"name": "kariricode/devkit",
3-
"description": "Unified quality toolchain for KaririCode Framework — encapsulates PHPUnit, PHPStan, PHP-CS-Fixer, Rector, and Psalm in .kcode/",
3+
"description": "Zero-config PHP quality toolchain for KaririCode Framework. Bundles PHPUnit, PHPStan, PHP-CS-Fixer, Rector, and Psalm under a single `kcode` CLI — isolated in .kcode/ so it never pollutes production dependencies.",
44
"type": "library",
55
"license": "MIT",
66
"keywords": [
77
"kariricode",
88
"devkit",
99
"quality",
1010
"toolchain",
11+
"cli",
12+
"phar",
1113
"phpunit",
1214
"phpstan",
1315
"php-cs-fixer",
1416
"rector",
1517
"psalm",
1618
"static-analysis",
17-
"code-style"
19+
"code-style",
20+
"linting",
21+
"testing",
22+
"coverage",
23+
"developer-tools",
24+
"code-quality",
25+
"refactoring",
26+
"php84"
1827
],
1928
"homepage": "https://kariricode.org",
2029
"authors": [

src/Command/FormatCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public function execute(Devkit $devkit, array $arguments): int
5050
}
5151

5252
// Step 2: Rector apply (--no-dry-run overrides runner default)
53-
if ($devkit->isToolAvailable('rector')) {
53+
if ($devkit->isToolAvailable('rector-apply')) {
5454
$this->line("\033[1m▸ Running rector process…\033[0m");
55-
$result = $devkit->run('rector', ['--no-dry-run', ...$arguments]);
55+
$result = $devkit->run('rector-apply', $arguments);
5656
$this->line($result->output());
5757

5858
if ($result->success) {

src/Command/RectorCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ public function execute(Devkit $devkit, array $arguments): int
3636

3737
$passthrough = $this->passthrough($arguments, ['--fix', '--apply']);
3838

39-
// RectorRunner defaults to --dry-run for safety.
40-
// When applying, --no-dry-run overrides it (Rector: last flag wins).
39+
// RectorRunner defaults to --dry-run (preview only).
40+
// RectorApplyRunner runs without --dry-run (applies changes).
4141
$result = $apply
42-
? $devkit->run('rector', ['--no-dry-run', ...$passthrough])
42+
? $devkit->run('rector-apply', $passthrough)
4343
: $devkit->run('rector', $passthrough);
4444

4545
$this->line($result->output());

src/Runner/RectorApplyRunner.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace KaririCode\Devkit\Runner;
6+
7+
use Override;
8+
9+
/**
10+
* Runs Rector without --dry-run, applying all changes.
11+
*
12+
* Used by FormatCommand and RectorCommand (with --fix) to actually write
13+
* the changes to disk, as opposed to RectorRunner which only previews.
14+
*
15+
* @since 1.0.0
16+
*/
17+
final class RectorApplyRunner extends AbstractToolRunner
18+
{
19+
#[Override]
20+
public function toolName(): string
21+
{
22+
return 'rector-apply';
23+
}
24+
25+
#[Override]
26+
protected function vendorBin(): string
27+
{
28+
return 'vendor/bin/rector';
29+
}
30+
31+
#[Override]
32+
protected function defaultArguments(): array
33+
{
34+
return [
35+
'process',
36+
'--config',
37+
$this->context->configPath('rector.php'),
38+
'--ansi',
39+
];
40+
}
41+
}

0 commit comments

Comments
 (0)