这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@mrclrchtr
Copy link
Contributor

Replace fs.cpSync with PnP-compatible recursive copy function to fix file copying from ZIP archives in Yarn PnP environments.

  • Add copyRecursivePnP() function using fs.readFile/writeFile operations
  • Replace all fs.cpSync calls in generateClientBundle()
  • Maintain createRequire() for package root resolution
  • Fix ENOENT errors when accessing /dist/clients/core in PnP

Fixes #2237, #2183

Replace fs.cpSync with PnP-compatible recursive copy function to fix file
copying from ZIP archives in Yarn PnP environments.

- Add copyRecursivePnP() function using fs.readFile/writeFile operations
- Replace all fs.cpSync calls in generateClientBundle()
- Maintain createRequire() for package root resolution
- Fix ENOENT errors when accessing /dist/clients/core in PnP

Fixes hey-api#2237, hey-api#2183
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel
Copy link

vercel bot commented Aug 6, 2025

@mrclrchtr is attempting to deploy a commit to the Hey API Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link

changeset-bot bot commented Aug 6, 2025

🦋 Changeset detected

Latest commit: 42566ef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mrclrchtr
Copy link
Contributor Author

I created a local npm registry setup with Verdaccio and could reproduce the error.

After this fix the error was gone. Unfortunately I don't know exactly, if there are some side effects.

copyRecursivePnP(path.join(src, file), path.join(dest, file));
}
} else {
const content = fs.readFileSync(src);

Check failure

Code scanning / CodeQL

Potential file system race condition High

The file may have changed since it
was checked
.
@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 6, 2025

Open in StackBlitz

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/nuxt@2401
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/openapi-ts@2401
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/vite-plugin@2401

commit: 42566ef

@codecov
Copy link

codecov bot commented Aug 6, 2025

Codecov Report

❌ Patch coverage is 20.00000% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 22.46%. Comparing base (1f9ec97) to head (42566ef).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
packages/openapi-ts/src/generate/client.ts 20.00% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2401      +/-   ##
==========================================
- Coverage   22.46%   22.46%   -0.01%     
==========================================
  Files         324      324              
  Lines       31956    31971      +15     
  Branches     1234     1234              
==========================================
+ Hits         7179     7181       +2     
- Misses      24768    24781      +13     
  Partials        9        9              
Flag Coverage Δ
unittests 22.46% <20.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vercel
Copy link

vercel bot commented Aug 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hey-api-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 7:28pm

Copy link
Member

@mrlubos mrlubos left a comment

Choose a reason for hiding this comment

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

This is wild. How long did it take you to debug? Tests are passing so I guess it works. Let's release it and find out 🤠 is there any test we could add that would be failing without these changes?

@mrlubos mrlubos merged commit 197ed86 into hey-api:main Aug 6, 2025
15 of 17 checks passed
@github-actions github-actions bot mentioned this pull request Aug 6, 2025
@mrclrchtr
Copy link
Contributor Author

I'll be honest, I wouldn't have figured that out without AI. But it really didn't do badly on that topic.

I think a test would be very difficult to set up... you would have to do the test with yarn PnP somehow... I don't know how to do that.

@mrlubos
Copy link
Member

mrlubos commented Aug 6, 2025

Hey, as long as it works 👯

@mrlubos mrlubos mentioned this pull request Aug 10, 2025
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.

[@hey-api/openapi-ts] Code generation error with PnP

2 participants