-
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 support for JS code generation for flix #1222
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.
I think the generate flag type needs to be fcl
, not js
since this is specifically for fcl and there could be other js libs.
Can you also link to a larger issue (probably on flixkit) which shows what the expected output is and describes the use case please?
internal/super/flix.go
Outdated
|
||
func isSaved(fr *flixResult) string { | ||
if fr.save != "" { | ||
return fmt.Sprintf("Generated code saved to %s", fr.save) |
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.
Use the logger instead of fmt
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.
the isSaved method returns a string. It's a convenience method for String()
and Oneliner()
methods. it's not a log out statement specifically.
Can you also create a CLI issue as well please and link it? Thanks. |
added #1232 and referenced it in the PR description |
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.
@bthaile I'm getting unknown flag: --generate
when running go run cmd/flow/main.go flix multiply.template.json --generate fcl-js --output multiply.template.js --network testnet
.
I'm also wondering if commands like generate
should be as flags --generate
. Those are for things like args. generate
feels like a command say flow flix generate...
or flow flix execute...
. Now that we are getting lots of flix items it feel like they should be subcommands otherwise you can run flow flix --bindings --execute --generate
and what is it supposed to do?
+1 on this point. In my opinion, these are distinct commands without significant functionality overlap, so they should probably be namespaced accordingly instead of distinguishing using flags. |
generate should be a subcommand of flix, not a flag. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1222 +/- ##
==========================================
- Coverage 38.65% 38.07% -0.59%
==========================================
Files 38 38
Lines 1948 1983 +35
==========================================
+ Hits 753 755 +2
- Misses 1107 1140 +33
Partials 88 88
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Updated description and PR. It makes more sense to break out verbs than add flags. |
@bjartek removed local --save flag and using global save flag. Added more structure to json output. |
Cool @bthaile can you make an issue to remember to update the docs with this new syntax? We'll also need to add the bindings stuff to the docs. |
good call, Added docs issue. I can write it up when this PR gets merged up and released. |
@bthaile There isn't much to test here but as a best practice does it make sense to at least add a test file maybe mocking the library was called so that its in place for whoever touches the code next? Apologies I should have added that when I originally put in the execute code originally. I don't think it matters that much right now since most of the logic is in the flixkit library, but if you are feeling like it wouldn't hurt. |
I don't think it's needed at this time. I could add tests when adding flix generate. |
Sounds good fine with that. Is this ready for me to manually test it again? |
One thing i was thinking about here is that the usecase we talked about in the developer office hours yesterday.
|
True @bjartek would be nice if it could grab a whole directory |
Not sure if it belongs in rhis issue bur a flix.json file that had lots of options could work. Let say you want to upload to a service, generate 3 different clients and maybe put those generated files somewhere. Describing all that with flags will be very complex. |
very simple for a developer to write a script (bash, nodejs, ...) to generate package files per flix. no need to add that complexity to flow-cli. |
closes: #1232
Depends on flixkit PR onflow/flixkit-go#12
js templates will be on going iterative process in flixkit-go repo.
Description
to follow the same pattern as transactions and account, using ...
command help when running
./flow flix
// Note for the future
There will be a new verb
generate
that will generate FLIX, so I'm reserving that word.To Test
execute
commandbindings
commanddownload this file to test local js generation,
https://github.com/onflow/flow-interaction-template-service/blob/master/templates/test/multiply.template.json
flow flix bindings multiply.template.json
script example
For contributor use:
master
branchFiles changed
in the Github PR explorer