Skip to content

Harden no-cache output cleanup#62

Open
samdark wants to merge 1 commit into
masterfrom
harden-output-directory-cleanup
Open

Harden no-cache output cleanup#62
samdark wants to merge 1 commit into
masterfrom
harden-output-directory-cleanup

Conversation

@samdark

@samdark samdark commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

  • replace shell-based output cleanup with Yii file helper cleanup
  • write a YiiPress build marker after successful builds
  • refuse --no-cache cleanup for non-empty output directories without that marker
  • delay destructive cleanup until after content configuration parses successfully

Tests

  • make test -- --filter BuildCommandTest
  • make psalm
  • make test

Copilot AI review requested due to automatic review settings June 13, 2026 08:44
@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 58 minutes and 17 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ 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: 7b381da9-73b6-40e3-9d32-597682b68710

📥 Commits

Reviewing files that changed from the base of the PR and between 315ad8d and 2bb27d3.

📒 Files selected for processing (3)
  • docs/commands.md
  • src/Console/BuildCommand.php
  • tests/Unit/Console/BuildCommandTest.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch harden-output-directory-cleanup

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 hardens build --no-cache output cleanup by switching away from shell-based deletion, adding a YiiPress build marker file, and preventing destructive cleanup unless the output directory is empty or explicitly marked as YiiPress-generated. It also delays cleanup until after content configuration parsing succeeds, and updates tests/docs accordingly.

Changes:

  • Replace rm -rf output cleanup with Yiisoft\Files\FileHelper::removeDirectory() and add safety checks before clearing.
  • Write a .yiipress-build marker after successful builds; refuse --no-cache cleanup for non-empty, unmarked output dirs.
  • Update unit tests and CLI documentation to cover/describe the new marker behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/Console/BuildCommand.php Implements safe output cleanup, adds build marker logic, and delays destructive actions until after parsing succeeds.
tests/Unit/Console/BuildCommandTest.php Adds assertions/tests for marker creation and for refusing to clear unmarked non-empty output directories.
docs/commands.md Updates --no-cache documentation to reflect the marker-based cleanup behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 107 to 109
private const int MAX_AUTO_WORKERS = 4;
private const string BUILD_MARKER = '.yiipress-build';

Comment on lines +836 to +838
if (!$noWrite) {
$this->writeBuildMarker($outputDir);
}
Comment on lines +1253 to +1258
private function isDirectoryEmpty(string $directory): bool
{
$iterator = new FilesystemIterator($directory, FilesystemIterator::SKIP_DOTS);

return !$iterator->valid();
}
Comment thread docs/commands.md
- `--output-dir`, `-o` — path to the output directory (default: `output`). Absolute or relative to project root.
- `--workers`, `-w` — number of parallel workers or `auto` (default: `auto`). Auto mode detects available CPU capacity inside the container, caps it at `4`, and still falls back to sequential work for small task sets.
- `--no-cache` — disable build cache and incremental builds. Forces a full rebuild, clearing the output directory. By default, rendered HTML is cached and a build manifest tracks source file hashes for incremental builds.
- `--no-cache` — disable build cache and incremental builds. Forces a full rebuild, clearing the output directory only when it is empty or contains YiiPress' build marker. By default, rendered HTML is cached and a build manifest tracks source file hashes for incremental builds.
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