Skip to content
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

Make rustywind available as library #95

Closed
bram209 opened this issue Mar 4, 2024 · 12 comments
Closed

Make rustywind available as library #95

bram209 opened this issue Mar 4, 2024 · 12 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@bram209
Copy link
Contributor

bram209 commented Mar 4, 2024

I maintain a formatter for the rust leptos framework and would like to use rustywind as a library (mainly this function: https://github.com/avencera/rustywind/blob/fe487da5ceecd5c0d2377796b063d53addf799e4/src/sorter.rs#L34C11-L34C67)

Would you be willing to add a lib.rs next to the main.rs, so that your binary imports from the library instead? This way I can include tailwind class sorting seamlessly in my project (without having to go through the hassle of spawning a new process that calls the CLI).

@praveenperera
Copy link
Member

@bram209 this has been a plan of mine, I just have not had the time to do it. But its separated out decently, if you wanted to try and move it to a lib.rs, I will publish it as a library to crates.

@praveenperera praveenperera added good first issue Good for newcomers help wanted Extra attention is needed labels Mar 6, 2024
@Rolv-Apneseth
Copy link
Contributor

Hi, I could take this on if no one else wants to (I would love to have leptosfmt sort classes using rustywind) . What exactly needs to go into the lib.rs and what other changes would be required (documentation or anything else)?

Also, can the Cli struct be put in lib.rs, and if not, any tips on how to keep all the cli functionality in main.rs? The Cli struct looks quite intertwined with options.rs, and then that is required by sorter.rs

@praveenperera
Copy link
Member

@Rolv-Apneseth the process would be to change it to a cargo workspace with two packages, rustywind and rustywind-lib.

The rustywind package would be the CLI and would be small containing the clap dependency and calling functions, in the lib package. If you get it started create a PR and allow me to make changes to it, I'll help out. Thanks.

@Rolv-Apneseth
Copy link
Contributor

Cool, thanks, I'll do that

@bram209
Copy link
Contributor Author

bram209 commented Apr 4, 2024

@Rolv-Apneseth I already started doing this a while back, but didn't have time to wrap it up.
You can check it here (for reference): https://github.com/bram209/rustywind/tree/multiple-crates

@praveenperera I decided to split it in three different crates rustywind_core (lib), rustywind_vite (lib) and rustywind_cli (binary), rationale being that most library users won't need the utilities that rustywind_vite provides.

Things that still need to be done:

  • cleanup dependencies
  • fix ci/cd workflows (should be a few small changes only)
  • add workflow that publishes the library (rustywind_core) to crates.io

but feel free to start from scratch or organize things differently of course : )

@Rolv-Apneseth
Copy link
Contributor

Oh nice. Yeah idm either way, up to @praveenperera but very useful as a reference regardless, thanks.

Both of these tools are great, thank you both.

@praveenperera
Copy link
Member

Splitting it into 3 crates is a good idea. @Rolv-Apneseth it probably makes sense to continue from @bram209's branch.

@dbgordon09
Copy link

Hi, I could take this on if no one else wants to (I would love to have leptosfmt sort classes using rustywind) . What exactly needs to go into the lib.rs and what other changes would be required (documentation or anything else)?

Also, can the Cli struct be put in lib.rs, and if not, any tips on how to keep all the cli functionality in main.rs? The Cli struct looks quite intertwined with options.rs, and then that is required by sorter.rs

This exactly what I was hoping to achieve as well! 🎉Let me know how it goes! I would be happy to help out if need be :)

@Rolv-Apneseth
Copy link
Contributor

Sure yeah, if you have any thoughts on that PR that would be appreciated

@rathod-sahaab
Copy link

rathod-sahaab commented Apr 12, 2024

Thanks @bram209 and @Rolv-Apneseth would be great to use this with dioxus too!

@Rolv-Apneseth
Copy link
Contributor

This can be closed I guess? @praveenperera

Libraries linked in this comment for anyone that wasn't following the PR

@praveenperera
Copy link
Member

Closed by #100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants