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

feat: split to create a library #62

Merged
merged 1 commit into from
Sep 28, 2024
Merged

feat: split to create a library #62

merged 1 commit into from
Sep 28, 2024

Conversation

jayvdb
Copy link
Contributor

@jayvdb jayvdb commented Sep 11, 2024

Not the cleanest split; happy to revise.
And also happy for this to not be published until it goes through a few more revisions to clean it up to produce a sensible API. (e.g. MainError probably doesnt belong in the lib)

@jayvdb
Copy link
Contributor Author

jayvdb commented Sep 20, 2024

@KSXGitHub , do you feel this might be possible ?

@jayvdb
Copy link
Contributor Author

jayvdb commented Sep 20, 2024

fwiw, I have developed a few other pnpm invocation wrappers which I would like to find a open source home for. See simonbuchan/pnpm-extra#2 for one of them.

@KSXGitHub
Copy link
Contributor

do you feel this might be possible ?

Technically possible. I have created plenty of Rust projects (not related to pnpm) that is both a library crate and a binary crate. All you have to do is to define both [lib] and [[bin]] in Cargo.toml.

@jayvdb
Copy link
Contributor Author

jayvdb commented Sep 21, 2024

All you have to do is to define both [lib] and [[bin]] in Cargo.toml

I believe this isnt necessary unless there are attributes needed to describe them.

i.e.
having both src/lib.rs and src/main.rs is sufficient...?

cargo run and cargo build do the appropriate things afaics

src/utils.rs Outdated Show resolved Hide resolved
@jayvdb jayvdb force-pushed the create-lib branch 2 times, most recently from 318eee9 to 935f9b2 Compare September 21, 2024 09:16
@zkochan
Copy link
Member

zkochan commented Sep 23, 2024

Why is a lib needed? Maintaining a library along with the CLI creates more work for us.

@jayvdb
Copy link
Contributor Author

jayvdb commented Sep 23, 2024

See earlier comment #62 (comment)

I would like to use pn in my Rust project.

@KSXGitHub KSXGitHub changed the title Split to create a library feat: split to create a library Sep 26, 2024
@jayvdb
Copy link
Contributor Author

jayvdb commented Sep 26, 2024

Thanks for approving.
I should add that I am happy to use git = ".." in my deps, so no need to do a release, and also I am expecting that the lib is very unstable.

It would be a good idea to follow this up with adding a header to the lib.rs to indicate that it is unstable, e.g. https://github.com/simonbuchan/pnpm-extra/blob/main/src/lib.rs , and maybe even hide it from the rust docs , e.g. https://github.com/Electron100/butane/blob/master/butane_cli/src/lib.rs

@zkochan zkochan merged commit ca84e29 into pnpm:main Sep 28, 2024
5 checks passed
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.

3 participants