foundry-rs / compilers

Utilities for working with native solc and compiling projects.
Apache License 2.0
73 stars 41 forks source link

feat(`forge build`): prettify compiled contract JSON artifacts #210

Open gnapoli23 opened 5 days ago

gnapoli23 commented 5 days ago

Component

Forge

Describe the feature you would like

It would be easier to read JSON artifacts by having them compiled in a pretty way, maybe using a setting in the foundry.toml file allowing you to specify tabs and spaces for the output. Using an external tool to do so it's only a temporary workaround, 'cause the contract would be always compiled in a non-pretty form if you make some changes and have the need of rebuilding it.

Additional context

No response

zerosnacks commented 5 days ago

Hi @gnapoli23 thanks for your suggestion

I think this is relevant to the foundry/compilers repo, moving it there

https://github.com/foundry-rs/compilers/blob/afa7569e6511fccb60a49e82474211d0b8a79522/crates/compilers/src/artifact_output/mod.rs#L129

A downside would be that pretty formatted artifacts have a larger filesize and it could be a breaking change if users are currently parsing by line as we expect in some other cases of JSON output

gnapoli23 commented 5 days ago

Would be worth considering it as an optional feature which can be enabled on demand? Eg in foundry.toml:

...
[output.fmt]
pretty = true
tabs = 2