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

fix(init): don't add two dev_dependencies sections #1296

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

chadoh
Copy link
Contributor

@chadoh chadoh commented Apr 26, 2024

When initializing a new project with soroban contract init, we need to
clean up the Cargo.toml of example projects a little. We need to make
sure soroban-sdk is always inherited from the workspace, and we need
to make sure there's no profile section.

We had a couple issues with the old logic.

  1. It was adding a dev_dependencies section, with an underscore, which
    is deprecated. If the Cargo.toml already had a dev-dependencies
    section, it would add a second dev_dependencies, which cargo would
    complain about.
  2. The new setting would only set { workspace = true }, even if the
    old one included other details like features = ['testutils'].

This adds a new crate, cargo_toml, which allows us to parse and
manipulate Cargo.toml files in a more sophisticated way, which allows us
to make sure we get the dev-dependencies section even if it's called
dev_dependencies. It also makes it straightforward to add the correct
inherited dependency.

Known limitations

The format of the new Cargo.toml is a little unconventional:

[package]
name = "soroban-account-contract"
edition = "2021"
version = "0.0.0"
publish = false
[dependencies.soroban-sdk]
workspace = true
[dev-dependencies.ed25519-dalek]
version = "1.0.1"

[dev-dependencies.rand]
version = "0.7.3"

[dev-dependencies.soroban-sdk]
features = ["testutils"]
workspace = true

@chadoh chadoh changed the title fix(init): don't add two dev_dependencies fix(init): don't add two dev_dependencies sections Apr 26, 2024
@willemneal willemneal enabled auto-merge (squash) April 27, 2024 14:43
@willemneal
Copy link
Member

Looks good to me. Love a crate that makes everything smoother.

Copy link
Member

@willemneal willemneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use some tests, but this seems straight forward enough not to warrant one before the merge. Perhaps we can add more tests for the init in a future PR.

@chadoh chadoh force-pushed the fix/init/dev-dependencies branch 2 times, most recently from 40b27fa to 3fcee5f Compare April 30, 2024 14:57
When initializing a new project with `soroban contract init`, we need to
clean up the `Cargo.toml` of example projects a little. We need to make
sure `soroban-sdk` is always inherited from the workspace, and we need
to make sure there's no `profile` section.

We had a couple issues with the old logic.

1. It was adding a `dev_dependencies` section, with an underscore, which
   is deprecated. If the Cargo.toml already had a `dev-dependencies`
   section, it would add a second `dev_dependencies`, which cargo would
   complain about.
2. The new setting would only set `{ workspace = true }`, even if the
   old one included other details like `features = ['testutils']`.

This adds a new crate, `cargo_toml`, which allows us to parse and
manipulate Cargo.toml files in a more sophisticated way, which allows us
to make sure we get the `dev-dependencies` section even if it's called
`dev_dependencies`. It also makes it straightforward to add the correct
inherited dependency.
@willemneal willemneal merged commit af78d8d into stellar:main Apr 30, 2024
17 checks passed
@chadoh chadoh deleted the fix/init/dev-dependencies branch April 30, 2024 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants