anchor icon indicating copy to clipboard operation
anchor copied to clipboard

Add Anchor hooks

Open losman0s opened this issue 3 years ago • 8 comments

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.toml which triggers automatically after build, so that I can stick to using the simple and beautiful anchor build with no particular option.

I can make a companion PR to the book if this PR seems useful to you.

losman0s avatar Apr 15 '22 12:04 losman0s

this is definitely something that would be nice to have and we have a more general issue to add hooks https://github.com/project-serum/anchor/issues/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: pre-build, post-build, pre-test, post-test, pre-deploy, post-deploy

paul-schaaf avatar Apr 20 '22 00:04 paul-schaaf

@paul-schaaf I can do it all, nw. Just want to make sure I get it, you want a separate hooks entry in Anchor.toml, separate from scripts and throwing error for unsupported hooks? Or the current approach with "reserved" script names is fine?

losman0s avatar Apr 20 '22 01:04 losman0s

you want a separate hooks entry in Anchor.toml, separate from scripts and throwing error for unsupported hooks?

yes

paul-schaaf avatar Apr 20 '22 21:04 paul-schaaf

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. Current behaviour is that unsupported entries to the [hooks] map are simply ignored (I'm guessing discarded during toml deserialization), which does not shock me more than that. Lmk what you think.

losman0s avatar Apr 21 '22 07:04 losman0s

Needs an entry in CHANGELOG.md

tomlinton avatar May 18 '22 02:05 tomlinton

@armaniferrante Could you help with this?

losman0s avatar Jun 07 '22 04:06 losman0s

yeh, i feel unqualified to review this. Not sure what hooks are or what they're used for yet 🤷

Henry-E avatar Dec 06 '22 17:12 Henry-E

@acheroncrypto can you review this one please?

Aursen avatar Nov 08 '23 22:11 Aursen