Skip to content

chore: write output to disk when testing codemod #1259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 27, 2025

Conversation

paoloricciuti
Copy link
Contributor

I'm working on fixing the codemod and while doing so I found pretty hard working with it because you are going off the diff in the console (also since whitespace counts you can't even copy the new output if it's meant to change).

This is a small chore that makes everything easier to reason and work with: when we test something we also write the _actual transform to disk so that you can open it with your editor of choice, look at the diff and even copy paste the result once you are satisfied with it.

Obviously it's git-ignored so we don't flood the repo, it's just for debugging purpose.

@Copilot Copilot AI review requested due to automatic review settings July 24, 2025 14:38
Copy link

vercel bot commented Jul 24, 2025

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

Name Status Preview Comments Updated (UTC)
valibot ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2025 2:44pm

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 24, 2025
Copy link

@Copilot 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 adds development tooling to improve the debugging experience when working on the zod-to-valibot codemod by writing transformed output to disk during testing.

  • Adds file system write operation to save actual transform output as _actual.ts files during test execution
  • Updates .gitignore to exclude the generated _actual.ts files from version control

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
codemod/zod-to-valibot/src/utils.ts Adds fs.writeFileSync call to save transform output to disk for debugging
codemod/zod-to-valibot/.gitignore Excludes generated _actual.ts files from git tracking
Comments suppressed due to low confidence (1)

codemod/zod-to-valibot/src/utils.ts:69

  • The writeFileSync operation could fail due to file system permissions or disk space issues, but there's no error handling. Consider wrapping this in a try-catch block to prevent test failures when the debugging file cannot be written.
      fs.writeFileSync(path.join(testPath, '_actual.ts'), output?.trim() ?? '');

@dosubot dosubot bot added the tooling Tooling for devs label Jul 24, 2025
@fabian-hiller
Copy link
Owner

Great idea!

@fabian-hiller fabian-hiller self-assigned this Jul 27, 2025
@fabian-hiller
Copy link
Owner

Feel free to reach out to me on Discord if you want to chat with me directly when working on the codemod!

@fabian-hiller fabian-hiller merged commit c39d0c4 into fabian-hiller:main Jul 27, 2025
2 checks passed
@paoloricciuti
Copy link
Contributor Author

Feel free to reach out to me on Discord if you want to chat with me directly when working on the codemod!

Just sent you a friend request, I also commented back on the bsky thread but discord will be faster 🤟🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XS This PR changes 0-9 lines, ignoring generated files. tooling Tooling for devs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants