-
Notifications
You must be signed in to change notification settings - Fork 2
Sync Cargo.toml dependencies when generating code
#70
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 5fdbdfd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
8e32350 to
15517a1
Compare
| export const DEFAULT_DEPENDENCY_VERSIONS: CargoDependencies = { | ||
| 'anchor-lang': '~0.31', | ||
| borsh: '^0.10', | ||
| kaigan: '0.2.6', | ||
| 'num-derive': '^0.4', | ||
| 'num-traits': '^0.2', | ||
| serde: '^1.0', | ||
| 'serde-big-array': '^0.5', | ||
| serde_with: '^3.0', | ||
| 'solana-account': '~2.2', | ||
| 'solana-account-info': '~2.3', | ||
| 'solana-client': '~2.2', | ||
| 'solana-cpi': '~2.2', | ||
| 'solana-decode-error': '~2.3', | ||
| 'solana-instruction': '~2.3', | ||
| 'solana-program-error': '~2.2', | ||
| 'solana-pubkey': '~2.3', | ||
| 'solana-sdk': '~2.3', | ||
| thiserror: '^1.0', | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section requires extra attention when reviewing. It defines the default version requirements for the generated code. Note that if the user uses stricter or newer versions for some of these, they will not be updated.
Cargo.toml when generating code
Cargo.toml when generating codeCargo.toml dependencies when generating code
52967b6 to
45f11ba
Compare
0de4fce to
cfc7371
Compare
cfc7371 to
5fdbdfd
Compare

This PR adds 2 new options to the renderer which enable the
Cargo.tomlof the generated client to be created and/or updated such that its dependencies match what the generated code expect.These options are:
syncCargoToml: Whether or not we should update the existingCargo.tomlif some of its dependencies are falling behind or create a newCargo.tomlif missing (default:false). Note that this requires the existingcrateFolderoption to be provided for this to work as, otherwise, we won't know where to look for theCargo.toml. A warning message is logged if this is not the case.dependencyVersions: ARecord<string, CargoDependency>such that keys are the name of external dependencies — e.g.solana-pubkey— and the values are the version ranges we want to support — e.g.^3.0— or the equivalent dependency object — e.g.{ version: "^3.0" }. The renderer offer default values for all external dependencies it relies on but this option may be used to override some of these values or add new ones.Additionally, even when the
syncCargoTomloption isfalse, if thecrateFolderis provided and there is an existingCargo.toml, the renderer will go through its dependencies and check if any are missing or out of date for the generated code. A warning message will be logged if that's the case.Note, when bumping the Rust renderer to the next major version (v2), we can make sure the required path is not the path to the generated folder but the crate folder instead. That way, we can make the
syncCargoTomloption default totrue. This would meancrateFolderwould be replaced bygeneratedFolderand would default tosrc/generated.