Skip to content

feat(react-email): Remove existing out directory when running email export #1373

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 3 commits into from
Mar 18, 2024

Conversation

bennyburrito
Copy link
Contributor

add in code to delete the PathToWhereEmailMarkupShouldBeDumped , out by default, if it already exists to make sure the directory only displays current and correct files when exporting to remove the chance of duplications and errors.

add in code to delete the PathToWhereEmailMarkupShouldBeDumped , out by default, if it already exists to make sure the directory only displays current and correct files when exporting to remove the chance of duplications and errors.
Copy link

vercel bot commented Mar 18, 2024

@bennyburrito is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Mar 18, 2024

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

Name Status Preview Comments Updated (UTC)
react-email-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 18, 2024 5:42pm

@gabrielmfern gabrielmfern added Package: react-email This is the CLI we generally use as just `email` on the temrinal. Type: Bug Confirmed bug labels Mar 18, 2024
@gabrielmfern
Copy link
Collaborator

Could you also run pnpm format on the root of the project?

@bennyburrito
Copy link
Contributor Author

@gabrielmfern how would I go about doing that? Sorry, not really done this before :)

@gabrielmfern
Copy link
Collaborator

gabrielmfern commented Mar 18, 2024

@bennyburrito You will have to clone your fork, that you've created to make these changes — through GitHub I assume — and then checkout into the new patch-1 branch that it has created.
Once there, if you already have pnpm installed, you just need to run pnpm install to then run the pnpm format.
This is equivalent to running npm run format but running with pnpm instead, which is the package manager we use.

@gabrielmfern gabrielmfern changed the title feat(react-email): Update export.ts to include code to delete existing out directory if already exists before building a new one feat(react-email): Remove existing out directory when running email export Mar 18, 2024
@bennyburrito
Copy link
Contributor Author

I have done that and refactored the code. when running pnpm install and pnpm format, all appears to be working correctly and no errors thrown.

@gabrielmfern
Copy link
Collaborator

@bennyburrito pnpm format will change the code to make it look the same across the codebase. Don't forget to commit the changes that it makes!

@bennyburrito
Copy link
Contributor Author

Thanks for the heads up. All committed.

Copy link
Collaborator

@gabrielmfern gabrielmfern 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 good to go! Thank you so much for contributing.

@gabrielmfern gabrielmfern merged commit 7c54713 into resend:canary Mar 18, 2024
@bennyburrito bennyburrito deleted the patch-1 branch March 18, 2024 17:46
@bennyburrito
Copy link
Contributor Author

Just happy to help in some way :) FYI it is a great project that we are looking at including for our new email system at work so keep up the good work.

bukinoshita pushed a commit that referenced this pull request Mar 18, 2024
@kdoroszewicz
Copy link

This change unfortunately broke my workflow. I'm exporting both .html and .txt versions of emails to the same out folder which now gets cleared before each command runs, removing what's been generated by the prior export.

@bennyburrito
Copy link
Contributor Author

bennyburrito commented Apr 10, 2024

This change unfortunately broke my workflow. I'm exporting both .html and .txt versions of emails to the same out folder which now gets cleared before each command runs, removing what's been generated by the prior export.

Hi @kdoroszewicz, we had a similar issue with ours and also needed a text version. The solution I came up with was to add a script that generates a TXT version based on the HTML version that is created in the out directory and saves the TXT version into the out directory as well. We liked this solution as it means the TXT version is automatically kept up to date as it is generated from the HTML. This means you don't have to remember to change the TXT version if you change copy in the HTML version.

We used npm html-to-text to do this and now we have no issues with it. https://www.npmjs.com/package/html-to-text

It would be good if the built-in export script could create a TXT version as well as a HTML version when the out directory is created.

@kdoroszewicz
Copy link

This change unfortunately broke my workflow. I'm exporting both .html and .txt versions of emails to the same out folder which now gets cleared before each command runs, removing what's been generated by the prior export.

Hi @kdoroszewicz, we had a similar issue with ours and my solution was to add a script to the export script that autogenerates a TXT version based on the HTML version that is created. We used npm html-to-text to do this and now we have no issues with it. https://www.npmjs.com/package/html-to-text

I'm relaying on '--plaintext' flag available in react-email CLI - no extra package required. The CLI just doesn't handle generating both versions at once so this change destroys the output of the previous command.

@bennyburrito
Copy link
Contributor Author

This change unfortunately broke my workflow. I'm exporting both .html and .txt versions of emails to the same out folder which now gets cleared before each command runs, removing what's been generated by the prior export.

Hi @kdoroszewicz, we had a similar issue with ours and my solution was to add a script to the export script that autogenerates a TXT version based on the HTML version that is created. We used npm html-to-text to do this and now we have no issues with it. https://www.npmjs.com/package/html-to-text

I'm relaying on '--plaintext' flag available in react-email CLI - no extra package required. The CLI just doesn't handle generating both versions at once so this change destroys the output of the previous command.

It would be good if they could look at that and the flag could be applied once the directory has been made so it can handle both versions at once.

@foosbar
Copy link

foosbar commented Apr 23, 2024

@bennyburrito - agreed it would be nice to output multiple formats at once.

As a workaround, I updated my script:
"export": "email export --outDir out/html; email export --plainText --outDir out/txt"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: react-email This is the CLI we generally use as just `email` on the temrinal. Type: Bug Confirmed bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants