Conversation
|
this is definitely something that would be nice to have and we have a more general issue to add hooks #219 Id like to accept a PR that adds support for all the hooks. Would you be interested in doing the other hooks too? Or just adding the hooks setting and then I add the other hooks? let me know! the following hooks would be a good start: |
|
@paul-schaaf I can do it all, nw. Just want to make sure I get it, you want a separate |
yes |
a0a7b08 to
b5c22f1
Compare
|
Ok I did not exactly add an error when providing an invalid hook, as it is not immediately apparent to me how to do that cleanly. |
b5c22f1 to
4a2734b
Compare
cli/src/config.rs
Outdated
| provider: Provider, | ||
| workspace: Option<WorkspaceConfig>, | ||
| scripts: Option<ScriptsConfig>, | ||
| hooks: Option<HooksConfig>, |
There was a problem hiding this comment.
you can make this a Hashmap/BTreeMap and then fail during conversion from _Config to Config (which happens in Config's FromStr implementation) if you encounter an unknown hook
There was a problem hiding this comment.
@paul-schaaf I actually started with this and switched to a struct since we know in advance the hooks we're supporting, compared to scripts which is arbitrary. I can switch to Hashmap/BTreeMap if you feel rejecting invalid ones is more valuable though, yes.
There was a problem hiding this comment.
I feel like it's not too ugly implementation-wise and provides a better UX.
and just to be clear what I mean is: Hashmap/BTreeMap in _Config and Option<HooksConfig> in Config
There was a problem hiding this comment.
Ok got it. WIll give that a go tmr. Eager to get that merged 😄
There was a problem hiding this comment.
Alright, providing unsupported hooks now results in an error:
thread 'main' panicked at 'Error reading hooks. Hooks ["WRONG"] are not part of valid hooks ["pre_build", "post_build", "pre_test", "post_test", "pre_deploy", "post_deploy"].', cli/src/config.rs:336:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtraceLmk if you have any other remarks.
There was a problem hiding this comment.
@paul-schaaf bump, in case this fell through the cracks
|
Needs an entry in CHANGELOG.md |
1b538c2 to
6fc994a
Compare
|
@armaniferrante Could you help with this? |
|
yeh, i feel unqualified to review this. Not sure what hooks are or what they're used for yet 🤷 |
|
@acheroncrypto can you review this one please? |
|
Due to this becoming stale and conflicts, I'm going to close in favor of #3862 |
Problem
I have to repeatedly copy pasta the IDL json/types like an idiot while developing my programs.
Proposed solution
Recognize a special "post_build" script from
Anchor.tomlwhich triggers automatically after build, so that I can stick to using the simple and beautifulanchor buildwith no particular option.I can make a companion PR to the book if this PR seems useful to you.