Skip to content

Develop#16

Merged
walmir-silva merged 6 commits intomainfrom
develop
Mar 2, 2026
Merged

Develop#16
walmir-silva merged 6 commits intomainfrom
develop

Conversation

@walmir-silva
Copy link
Contributor

No description provided.

…resolution

Binary resolution now uses three live tiers:
  Tier-1: {project}/.kcode/vendor/bin/{tool} (installed by kcode init)
  Tier-2: {project}/vendor/bin/{tool}         (project-local fallback)
  Tier-3: global PATH                          (system-wide fallback)

Removes unreachable Phar::running() check that was dead code since
tool binaries are never bundled inside kcode.phar.
Generates a self-contained Composer manifest at .kcode/composer.json
with dev-tool dependencies (phpunit, phpstan, php-cs-fixer, rector, psalm).

Version constraints come from devkit.php → 'tools' key; falls back to
KaririCode-certified defaults. Short-names (e.g. 'phpunit') are resolved
to full Composer package names via an internal map.

The generated .kcode/composer.json is then consumed by kcode init which
runs 'composer install --working-dir=.kcode/' to populate .kcode/vendor/bin/.
Extracts Composer binary resolution from Devkit into a dedicated readonly
class, honouring Single Responsibility Principle (ARFA 1.3 S1).

Resolution order:
  1. COMPOSER_BINARY env var (explicit override)
  2. PATH via 'command -v composer'
  3. Known global paths (/usr/local/bin/composer, /usr/bin/composer)
  4. User-level Composer PHAR (~/.composer/composer)
  5. Literal 'composer' fallback

Always returns a single executable path — never a shell fragment —
so proc_open array invocation is always safe (type-safety standard S14).
…sioning

Adds installTools() which runs 'composer install --working-dir=.kcode/'
to install dev tools into .kcode/vendor/bin/ after config generation.

Changes:
- Injects ComposerResolver via constructor default arg (DIP — S5)
- Variable names follow naming policy: $context, $devkitDirectory,
  $composerManifestPath (ARFA naming standard — S16)
- Removes resolveComposer() private method (extracted to ComposerResolver)
- proc_open uses STDIN/STDOUT/STDERR constants with \ namespace prefix
- @SInCE 1.0.0 added to all new public methods
InitCommand now receives MigrationDetector via constructor injection,
matching the existing MigrateCommand pattern (DIP — ARFA 1.3 S5).

Also extends the init flow with a Phase 2: installs dev tools via
Devkit::installTools() after config generation. Use --skip-install
to generate configs only (useful in CI / offline environments).

bin/kcode wiring updated to pass new MigrationDetector() to InitCommand.
KcodeComposerGeneratorTest (5 cases): toolName, outputPath, default versions,
user version overrides, config section, output newline.

bin/build-phar.php: restored to lean build strategy — bundles only src/
and an inline PSR-4 autoloader. Tools install dynamically via kcode init,
avoiding prohibitively slow Phar::compressFiles(GZ) on large vendor trees
(documented pitfall #12 in devkit KI).
@walmir-silva walmir-silva merged commit c42ff94 into main Mar 2, 2026
3 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant