|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Git Artifact is a PHP CLI tool that packages code artifacts from a source repository and pushes them to a destination repository. It's designed for deployment workflows where built artifacts need to be deployed to a separate repository. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Code Quality and Linting |
| 12 | +- `composer lint` - Run code quality checks (PHPCS, PHPStan, Rector dry-run) |
| 13 | +- `composer lint-fix` - Fix code quality issues (Rector, PHPCBF) |
| 14 | + |
| 15 | +### Testing |
| 16 | +- `composer test` - Run PHPUnit tests without coverage |
| 17 | +- `composer test-coverage` - Run PHPUnit tests with coverage |
| 18 | + |
| 19 | +### Building |
| 20 | +- `composer build` - Build standalone PHAR executable using Box |
| 21 | + |
| 22 | +## Architecture |
| 23 | + |
| 24 | +### Core Components |
| 25 | +- **ArtifactCommand** (`src/Commands/ArtifactCommand.php`) - Main CLI command that orchestrates the artifact creation process |
| 26 | +- **ArtifactGitRepository** (`src/Git/ArtifactGitRepository.php`) - Extended Git repository class with artifact-specific operations |
| 27 | +- **Traits** (`src/Traits/`) - Reusable functionality: |
| 28 | + - `TokenTrait` - Handle token replacement in branch names and commit messages |
| 29 | + - `LoggerTrait` - Logging functionality |
| 30 | + - `FilesystemTrait` - File system operations |
| 31 | + |
| 32 | +### Application Entry Points |
| 33 | +- `git-artifact` - Main executable script with autoloader discovery |
| 34 | +- `src/app.php` - Application bootstrap using Symfony Console |
| 35 | + |
| 36 | +### Deployment Modes |
| 37 | +The tool supports two deployment modes: |
| 38 | +1. **force-push** (default) - Pushes to same branch, overwrites destination history |
| 39 | +2. **branch** - Creates new branches in destination based on source tags |
| 40 | + |
| 41 | +### Token System |
| 42 | +Supports dynamic token replacement in branch names and commit messages: |
| 43 | +- `[timestamp:FORMAT]` - Current timestamp with PHP date format |
| 44 | +- `[branch]` - Current branch name |
| 45 | +- `[safebranch]` - Branch name with non-alphanumeric chars replaced |
| 46 | +- `[tags:DELIMITER]` - Tags from latest commit |
| 47 | + |
| 48 | +## Testing Structure |
| 49 | + |
| 50 | +### Functional Tests (`tests/Functional/`) |
| 51 | +Integration tests that verify end-to-end functionality: |
| 52 | +- `BranchModeTest.php` - Tests branch mode deployment |
| 53 | +- `ForcePushModeTest.php` - Tests force-push mode deployment |
| 54 | +- `GeneralTest.php` - General functionality tests |
| 55 | +- `TagTest.php` - Token replacement and tagging tests |
| 56 | + |
| 57 | +### Unit Tests (`tests/Unit/`) |
| 58 | +- Component-level tests for individual classes |
| 59 | +- Follow PHPUnit conventions with strict typing |
| 60 | + |
| 61 | +### Test Fixtures Naming Convention |
| 62 | +- `f*` - Files with counter suffix |
| 63 | +- `i` - Ignored files |
| 64 | +- `c` - Committed files |
| 65 | +- `u` - Uncommitted files |
| 66 | +- `d` - Deleted files |
| 67 | +- `d_` - Directories |
| 68 | +- `sub_` - Sub-directories/files for wildcard testing |
| 69 | +- `f*_l` - Symlinks |
| 70 | + |
| 71 | +## Code Standards |
| 72 | + |
| 73 | +- Follows Drupal coding standards via PHPCS |
| 74 | +- Uses PHPStan level 9 for static analysis |
| 75 | +- Rector for automated code modernization to PHP 8.2+ |
| 76 | +- PSR-4 autoloading: `DrevOps\GitArtifact\` namespace maps to `src/` |
| 77 | + |
| 78 | +## Key Dependencies |
| 79 | + |
| 80 | +- `symfony/console` - CLI framework |
| 81 | +- `czproject/git-php` - Git operations |
| 82 | +- `symfony/filesystem` & `symfony/finder` - File operations |
| 83 | +- `monolog/monolog` - Logging |
| 84 | + |
| 85 | +## Single Test Execution |
| 86 | + |
| 87 | +Run specific test classes: |
| 88 | +```bash |
| 89 | +./vendor/bin/phpunit tests/Unit/TokenTest.php |
| 90 | +./vendor/bin/phpunit tests/Functional/BranchModeTest.php |
| 91 | +``` |
| 92 | + |
| 93 | +Run specific test methods: |
| 94 | +```bash |
| 95 | +./vendor/bin/phpunit --filter testTokenReplacement tests/Unit/TokenTest.php |
| 96 | +``` |
0 commit comments