-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add generate templates command #1242
Conversation
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.
@jribbink can check the go code
Co-authored-by: Greg Santos <[email protected]>
Co-authored-by: Jordan Ribbink <[email protected]>
Co-authored-by: Jordan Ribbink <[email protected]>
Co-authored-by: Bjarte S. Karlsen <[email protected]>
Co-authored-by: Jordan Ribbink <[email protected]>
Co-authored-by: Bjarte S. Karlsen <[email protected]>
Co-authored-by: Bjarte S. Karlsen <[email protected]>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1242 +/- ##
==========================================
+ Coverage 40.30% 41.19% +0.89%
==========================================
Files 38 39 +1
Lines 2007 2068 +61
==========================================
+ Hits 809 852 +43
- Misses 1109 1123 +14
- Partials 89 93 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
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.
lgtm
Co-authored-by: Jordan Ribbink <[email protected]>
Co-authored-by: Jordan Ribbink <[email protected]>
Co-authored-by: Jordan Ribbink <[email protected]>
internal/super/generate.go
Outdated
|
||
filenameWithBasePath := filepath.Join(basePath, filename) | ||
|
||
if _, err := os.Stat(filenameWithBasePath); err == nil { |
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.
flow-cli has the --save
-s
flag to save the output of a command to a file, do we need to have this logic here or can we just return the output and rely on that logic?
also state has a ReaderWriter that is used to save files and that is used elsewhere instead of os functions.
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.
Hmm yeah I guess that means that you always have to provide --save
. I was hoping to just always generate them to the correct folders unless specified otherwise. But it makes sense to keep the same pattern. Just really verbose now. Writing flow generate contract woohoo --save cadence/contracts/whoohoo.cdc
is so long that I'd almost rather just write the cadence instead of use this command. Makes me want to kill this PR.
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.
Imo just skip the pattern/flag here. I think think it's pretty obvious that this will be saving a file and using a flag for this is just redundant & a command like this is for ease of use so should be as shorthand as possible. I think the only purpose --save
potentially has in this is as an override to the output path.
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.
I'm fully in support for super short aliases here as well (i.e. flow g c FooBar
)
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.
Feel free to not use --save. But using ReaderWriter is recommended. I think it also creates required directories.
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.
Yeah ReaderWriter is no problem. Good catch. Will change that @bjartek
Also I think it would be cool if Additionally, there won't be any confusion about imports not being resolved when these contracts are referenced since they are automatically in the flow.json |
Totally agree on this. Would it be possible to optionally have it added to deployment section? One pattern i use in flow.json is that my accounts are named on the form of network-role So emulator-find, testnet-find, mainnet-find. |
So here's what I think is a good route based on what you all said. Tell me if you agree @bjartek @jribbink :
Thoughts? |
That works. It is always podsible to expand later. |
@jribbink @bjartek I updated the PR to have the "g" alias and to save the contract to |
Ammend the code in ReaderWriter then? |
@bjartek yep working on that next |
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.
LGTM
Closes #1233
For contributor use:
master
branchFiles changed
in the Github PR explorer