Add throwing file writer for build output#65
Conversation
|
Warning Review limit reached
More reviews will be available in 49 minutes and 45 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR introduces a small FileWriter helper in the build pipeline to consistently throw an exception when file writes fail, and replaces direct file_put_contents() calls across various build output writers (pages, support files, cache, manifest, and parallel worker results). This helps ensure build failures don’t silently produce incomplete or missing output.
Changes:
- Added
YiiPress\Build\FileWriter::write()and unit tests covering successful and failing writes. - Replaced multiple
file_put_contents()call sites in build output generation withFileWriter::write(). - Updated build command support-file generation (
robots.txt) to use the new helper.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/Build/FileWriter.php |
Adds centralized write helper that throws on failure. |
tests/Unit/Build/FileWriterTest.php |
Adds unit coverage for success/failure write behavior. |
src/Console/BuildCommand.php |
Uses FileWriter for robots.txt generation. |
src/Build/SearchIndexGenerator.php |
Uses FileWriter for search-index.json output. |
src/Build/ParallelTaskRunner.php |
Uses FileWriter for worker result files. |
src/Build/ParallelEntryWriter.php |
Uses FileWriter for generated entry HTML files. |
src/Build/RedirectPageWriter.php |
Uses FileWriter for redirect page HTML output. |
src/Build/NotFoundPageWriter.php |
Uses FileWriter for 404.html output. |
src/Build/TaxonomyPageWriter.php |
Uses FileWriter for taxonomy index/term pages. |
src/Build/DateArchiveWriter.php |
Uses FileWriter for archive index/year/month pages. |
src/Build/CollectionListingWriter.php |
Uses FileWriter for collection listing pages. |
src/Build/BuildManifest.php |
Uses FileWriter for writing the build manifest JSON. |
src/Build/BuildCache.php |
Uses FileWriter for writing cache entries. |
src/Build/AuthorPageWriter.php |
Uses FileWriter for author index/author pages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $robots = $robotsGenerator->generate($siteConfig); | ||
| if ($robots !== '') { | ||
| if (!$noWrite) { | ||
| FileWriter::write($outputDir . '/robots.txt', $robots); | ||
| } | ||
| $output->writeln(' robots.txt generated.'); | ||
| } |
| if (!$noWrite) { | ||
| file_put_contents($outputDir . '/search-index.json', $json); | ||
| FileWriter::write($outputDir . '/search-index.json', $json); | ||
| } |
| $count = $this->runSequential($chunk, $taskRunner); | ||
| file_put_contents($resultFile, (string) $count); | ||
| FileWriter::write($resultFile, (string) $count); | ||
| exit(0); |
Summary
Tests