Skip to content

Conversation

@ovflowd
Copy link
Member

@ovflowd ovflowd commented Nov 3, 2025

This PR removes the removal of files during also the crazy copy of files, deferring the out/ folder cleanup to docclean as it probably should. The original intent of the rm command was to ensure files that do not exist on source anymore and are irrelevant will be removed, but this isn't really an issue and eventually the legacy generator will go away.

Simplifed to a simple copyFile call too.

@ovflowd ovflowd requested a review from a team as a code owner November 3, 2025 22:55
Copilot AI review requested due to automatic review settings November 3, 2025 22:55
@vercel
Copy link

vercel bot commented Nov 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
api-docs-tooling Ready Ready Preview Nov 5, 2025 10:53pm

@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 96.66667% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.40%. Comparing base (179ca04) to head (8d4d289).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/generators/legacy-html/utils/safeCopy.mjs 82.60% 4 Missing ⚠️
...tors/legacy-html/utils/__tests__/safeCopy.test.mjs 99.20% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #482      +/-   ##
==========================================
+ Coverage   73.86%   74.40%   +0.54%     
==========================================
  Files         109      110       +1     
  Lines       10356    10480     +124     
  Branches      686      706      +20     
==========================================
+ Hits         7649     7798     +149     
+ Misses       2704     2679      -25     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

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 refactors the safeCopy utility to use Node.js's native fs.copyFile instead of manual readFile/writeFile operations, improving efficiency and handling of concurrent operations. Additionally, it removes the aggressive cleanup step (rm) that was previously deleting the entire assets directory before copying.

Key Changes

  • Replaced readFile/writeFile with native copyFile API for better performance and atomicity
  • Removed the rm call that was deleting the entire assets directory before copying
  • Added comprehensive test coverage for the safeCopy function

Reviewed Changes

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

File Description
src/generators/legacy-html/utils/safeCopy.mjs Refactored to use copyFile instead of manual read/write operations; updated documentation
src/generators/legacy-html/utils/tests/safeCopy.test.mjs Added comprehensive test suite covering various scenarios
src/generators/legacy-html/index.mjs Removed aggressive rm call that deleted the entire assets directory

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

This comment was marked as resolved.

@avivkeller
Copy link
Member

Whoops! I thought the bot would just make a commit, not open a whole different PR.

@ovflowd
Copy link
Member Author

ovflowd commented Nov 4, 2025

cc @aduh95 / @avivkeller / @flakey5 can y'all test if y'all see any issues with this one?

I tried:

-j
-j 32
-j 64
-j 128
-j 256

Didn't find any errors.

@avivkeller
Copy link
Member

Let's give it a try :-). If it fails in the PR (for @aduh95), we can fall back to #483

@aduh95 aduh95 self-requested a review November 5, 2025 13:21
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

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

I'm no longer getting errors! Left a suggestion

@ovflowd
Copy link
Member Author

ovflowd commented Nov 5, 2025

@avivkeller PR is failing

Co-authored-by: Antoine du Hamel <[email protected]>
@avivkeller

This comment was marked as resolved.

@ovflowd

This comment was marked as off-topic.

@avivkeller

This comment was marked as off-topic.

@avivkeller

This comment was marked as off-topic.

@ovflowd

This comment was marked as off-topic.

@avivkeller
Copy link
Member

@nodejs/web-infra for reviews

*/
export async function safeCopy(srcDir, targetDir) {
const files = await readdir(srcDir);
try {
Copy link
Member Author

Choose a reason for hiding this comment

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

Uhm, why we have a try with a catch doing this? I'd rather simplify this :)

Just do one await copyFile with the readdir and stats and call it a day.

Also, copyFile call with a srcDir and targetDir is wrong. copyFile !== cp

Copy link
Member

Choose a reason for hiding this comment

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

I was following the try/catch in #482 (comment)

Just do one await copyFile with the readdir and stats and call it a day.

By this you mean revert to the state of the PR at the time of @aduh95's approval (without his suggestion)? Or perhaps I'm not understanding?

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.

4 participants