Brendonovich / prisma-client-rust

Type-safe database access for Rust
https://prisma.brendonovich.dev
Apache License 2.0
1.75k stars 106 forks source link

Publish on crates.io and use cargo local-install for locally installing the cli #307

Closed dlight closed 1 year ago

dlight commented 1 year ago

Right now it's recommended to include prisma as a workspace crate, and a cli binary is not provided in crates.io because cargo install is a global installation, instead of being per project.

But there is a tool called cargo local-install that installs tools locally for each project (similar to node's npx). You specify each package in Cargo.toml metadata alongside its version, like this:

[workspace.metadata.local-install]
prisma-client-rust-cli = "1.1"

A great benefit is that it builds a single time for each version of the binary and reuses it across many projects, creating a symlink in the bin directory at the root of your project (thus it makes sense to add this bin directory to .gitignore)

A limitation is that cargo local-install doesn't create the appropriate alias on ~/.cargo/config.toml, and it should be created manually. However, the alias is being created manually today too.

Brendonovich commented 1 year ago

cargo-local-install does actually look pretty cool, but as stated before I can't publish to crates.io. I see that they support using git dependencies but I don't want to commit to it just yet, I've got some ideas that may involve customising the generators themselves.