fidry/makefile
Helpers for writing Makefiles with consistent conventions: built-in checks, convention validation, and a simple structure for targets like help/default/cs/test. Aims to make Makefiles clearer, safer, and more contributor-friendly across projects.
Start by installing the package via Composer: composer require --dev fidry/makefile. Then, create a test class (e.g., tests/MakefileTest.php) extending Fidry\Makefile\Test\BaseMakefileTestCase. Implement getMakefilePath() to point to your project’s Makefile, and getExpectedHelpOutput() to define the expected output of make help. To generate the expected output, run make help locally, capture the ANSI-colored output (e.g., make help | pbcopy), and paste it into the test. The test will then validate that future changes to the Makefile preserve conventions like ##-commented targets, correct ordering, and consistent formatting.
getExpectedHelpOutput() to enforce that all .PHONY targets have ## comments and appear in a specific order—critical for onboarding and CI gatekeeping.phpunit tests/MakefileTest.php) to block PRs that break Makefile conventions (e.g., undocumented targets, duplicate targets, or broken make help formatting).BaseMakefileTestCase to add custom checks using the exposed parsedRules (an array of Rule objects), e.g., enforce that test always depends on cs and phpunit.make help output, its parser can be reused for ad-hoc checks (e.g., disallow sudo in commands, require vendor: to depend on composer.lock in apps).\033[33m); copy-paste from actual terminal output to avoid mismatched escapes. Use make help 2>&1 | cat -v to see raw control characters.touch -c artifacts may confuse tests: The README’s vendor target uses touch -c, which creates timestamp files. Ensure tests run in an isolated temp directory or that your CI doesn’t have stale .phar/vendor artifacts causing false positives.How can I help you explore Laravel packages today?