Skip to content

Add throwing file writer for build output#65

Open
samdark wants to merge 1 commit into
masterfrom
add-throwing-file-writer
Open

Add throwing file writer for build output#65
samdark wants to merge 1 commit into
masterfrom
add-throwing-file-writer

Conversation

@samdark

@samdark samdark commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

  • add a small FileWriter helper that throws when file writes fail
  • use it for generated build pages, search index, robots.txt, cache, manifest, and parallel worker result files
  • add unit coverage for successful and failed writes

Tests

  • make test -- --filter FileWriterTest
  • make psalm
  • make test

Copilot AI review requested due to automatic review settings June 13, 2026 08:52
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@samdark, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c229746b-7e5d-4733-978b-ea2437204f87

📥 Commits

Reviewing files that changed from the base of the PR and between 315ad8d and 652e29a.

📒 Files selected for processing (14)
  • src/Build/AuthorPageWriter.php
  • src/Build/BuildCache.php
  • src/Build/BuildManifest.php
  • src/Build/CollectionListingWriter.php
  • src/Build/DateArchiveWriter.php
  • src/Build/FileWriter.php
  • src/Build/NotFoundPageWriter.php
  • src/Build/ParallelEntryWriter.php
  • src/Build/ParallelTaskRunner.php
  • src/Build/RedirectPageWriter.php
  • src/Build/SearchIndexGenerator.php
  • src/Build/TaxonomyPageWriter.php
  • src/Console/BuildCommand.php
  • tests/Unit/Build/FileWriterTest.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-throwing-file-writer

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with FileWriter::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.

Comment on lines +776 to 782
$robots = $robotsGenerator->generate($siteConfig);
if ($robots !== '') {
if (!$noWrite) {
FileWriter::write($outputDir . '/robots.txt', $robots);
}
$output->writeln(' robots.txt generated.');
}
Comment on lines 66 to 68
if (!$noWrite) {
file_put_contents($outputDir . '/search-index.json', $json);
FileWriter::write($outputDir . '/search-index.json', $json);
}
Comment on lines 64 to 66
$count = $this->runSequential($chunk, $taskRunner);
file_put_contents($resultFile, (string) $count);
FileWriter::write($resultFile, (string) $count);
exit(0);
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.

2 participants