fix(init): example contracts: keep cdylib, exclude Cargo.lock #1337
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.
This removes the
cargo_toml
dependency that I just added in #1296, opting for a simpler regex-based find-and-replace for the soroban-sdk dependency changes. Previous to #1296, we usedtoml_edit
for all of these modifications, but did so in a way that ignored and overwrote important fields likesoroban-sdk.features
.The
toml_edit
approach for editing thedependencies
anddev_dependencies
sections was quite verbose, and insufficient to what we needed, as the tests added in #1296 and this PR illustrate. Since we know what is in all thesoroban-examples
projects (for now), I thought maybe the regex approach was sufficient, for the time being. This could prove to be too brittle in the future, though, if one of the examples changes its format to not put allsoroban-sdk
settings on the same line.The
cargo_toml
approach seemed like it should have been superior to both of these approaches, but it was changing more than it should have. For example, here's the startingCargo.toml
for theauth
contract, prior to being modified byinit
:With
cargo_toml
, the above was being changed to this:Yikes! Where'd all that
lib
stuff come from?? That's not whereedition
goes! It already includesedition
in the[package]
section, why did it add it there, too?? And why on EARTH would it changelib.crate-type = ["cdylib"]
tolib.crate-type = ["rlib"]
?? Bad news! This means such crates won't even be considered Soroban contracts anymore! Wowee.