Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/kcode
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ declare(strict_types=1);
$devkit->addRunner(new \KaririCode\Devkit\Runner\PhpStanRunner($executor, $context));
$devkit->addRunner(new \KaririCode\Devkit\Runner\CsFixerRunner($executor, $context));
$devkit->addRunner(new \KaririCode\Devkit\Runner\RectorRunner($executor, $context));
$devkit->addRunner(new \KaririCode\Devkit\Runner\RectorApplyRunner($executor, $context));
$devkit->addRunner(new \KaririCode\Devkit\Runner\PsalmRunner($executor, $context));
$devkit->addRunner(new \KaririCode\Devkit\Runner\ComposerAuditRunner($executor, $context));
}
Expand Down
Binary file modified build/kcode.phar
Binary file not shown.
13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
{
"name": "kariricode/devkit",
"description": "Unified quality toolchain for KaririCode Framework — encapsulates PHPUnit, PHPStan, PHP-CS-Fixer, Rector, and Psalm in .kcode/",
"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.",
"type": "library",
"license": "MIT",
"keywords": [
"kariricode",
"devkit",
"quality",
"toolchain",
"cli",
"phar",
"phpunit",
"phpstan",
"php-cs-fixer",
"rector",
"psalm",
"static-analysis",
"code-style"
"code-style",
"linting",
"testing",
"coverage",
"developer-tools",
"code-quality",
"refactoring",
"php84"
],
"homepage": "https://kariricode.org",
"authors": [
Expand Down
4 changes: 2 additions & 2 deletions src/Command/FormatCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public function execute(Devkit $devkit, array $arguments): int
}

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

if ($result->success) {
Expand Down
6 changes: 3 additions & 3 deletions src/Command/RectorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public function execute(Devkit $devkit, array $arguments): int

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

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

$this->line($result->output());
Expand Down
41 changes: 41 additions & 0 deletions src/Runner/RectorApplyRunner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace KaririCode\Devkit\Runner;

use Override;

/**
* Runs Rector without --dry-run, applying all changes.
*
* Used by FormatCommand and RectorCommand (with --fix) to actually write
* the changes to disk, as opposed to RectorRunner which only previews.
*
* @since 1.0.0
*/
final class RectorApplyRunner extends AbstractToolRunner
{
#[Override]
public function toolName(): string
{
return 'rector-apply';
}

#[Override]
protected function vendorBin(): string
{
return 'vendor/bin/rector';
}

#[Override]
protected function defaultArguments(): array
{
return [
'process',
'--config',
$this->context->configPath('rector.php'),
'--ansi',
];
}
}