fix(init): don't add two dev_dependencies
sections
#1296
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When initializing a new project with
soroban contract init
, we need toclean up the
Cargo.toml
of example projects a little. We need to makesure
soroban-sdk
is always inherited from the workspace, and we needto make sure there's no
profile
section.We had a couple issues with the old logic.
dev_dependencies
section, with an underscore, whichis deprecated. If the Cargo.toml already had a
dev-dependencies
section, it would add a second
dev_dependencies
, which cargo wouldcomplain about.
{ workspace = true }
, even if theold one included other details like
features = ['testutils']
.This adds a new crate,
cargo_toml
, which allows us to parse andmanipulate Cargo.toml files in a more sophisticated way, which allows us
to make sure we get the
dev-dependencies
section even if it's calleddev_dependencies
. It also makes it straightforward to add the correctinherited dependency.
Known limitations
The format of the new
Cargo.toml
is a little unconventional: