stolt/lean-package-validator
CLI tool to validate a project or micro-package for “leanness” by ensuring common repo artifacts are excluded from release archives. Also creates, updates, and reformats .gitattributes export-ignore entries for lean distribution packages.
export-ignore rules, which are directly applicable to Laravel projects (e.g., .env, node_modules, vendor/).post-release, pre-publish)..idea/, .phpunit.result.cache).composer validate-gitattributes)..gitattributes in monorepos (e.g., Laravel + Vue/React).phpunit, php-cs-fixer) to ensure dev artifacts are excluded..gitattributes rules may conflict with the package’s defaults (mitigated by --glob-pattern or .lpv files).vendor/ in releases).--dry-run and --diff to preview changes.--validate-git-archive creates temporary archives, which could slow down CI pipelines for large repos..lpv files..env, storage/logs) or all dev artifacts?--keep-glob-pattern for specific files)?.lpv files or override presets via CLI flags?storage/framework/cache/ in releases.--validate-git-archive?git-archive-all) used in Laravel workflows?composer.json scripts (e.g., post-release).phpunit (exclude .phpunit.result.cache).laravel-mix/vite (exclude node_modules/).php-cs-fixer (exclude .php-cs-fixer.php)..lpv files.composer.json as a dev dependency:
"require-dev": {
"stolt/lean-package-validator": "^3.3"
}
"scripts": {
"validate-gitattributes": "lean-package-validator validate --preset=PHP"
}
--dry-run:
composer validate-gitattributes -- --dry-run
.github/workflows/lean-validation.yml):
- name: Validate lean package
run: composer validate-gitattributes
--keep-glob-pattern for critical files (e.g., storage/logs/).bootstrap/cache/) may need .lpv customizations.export-ignore; no conflicts with other Git tools (e.g., git-lfs).composer validate-gitattributes in post-release scripts to catch issues before publishing.composer install) to fail fast.composer install
composer validate-gitattributes
phpunit
--report-stale-export-ignores..lpv Files: Store project-specific patterns in version control.--keep-glob-pattern '{storage/logs/}') without modifying code..lpv files or update presets..gitattributes (use --diff to debug).--validate-git-archive or skip in CI).--dry-run for previewing changes.--tree to inspect source/dist structures.storage/framework/ from validation.".gitattributes, .lpv files, and Composer scripts.--validate-git-archive results or run in parallel with other checks.vendor/) from validation..lpv files or use directory-specific configs.| Failure Scenario | Impact | Mitigation |
|---|---|---|
Missing .gitattributes |
Build fails in CI. | Use --create or automate .gitattributes generation. |
Stale export-ignore rules |
Dev artifacts leak into releases. | Run --report-stale-export-ignores regularly. |
| Overly strict validation | Blocks legitimate files. | Use --keep-glob-pattern or adjust presets. |
CI timeout due to --validate-git-archive |
Flaky builds. | Cache results or skip in non-critical pipelines. |
Custom .gitattributes conflicts |
Validation fails. | Merge rules manually or use --overwrite cautiously. |
composer.json and run locally.--dry-run.How can I help you explore Laravel packages today?