Skip to content
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

Refactor NodeJS codegen #4360

Merged
merged 7 commits into from
Feb 16, 2023
Merged

Refactor NodeJS codegen #4360

merged 7 commits into from
Feb 16, 2023

Conversation

dolanor
Copy link
Contributor

@dolanor dolanor commented Jan 11, 2023

Goal

  • remove extraneous template commands (use }} instead of -}} as we already have {{- in general)
  • remove template files if too simple (simple range)

@dolanor dolanor marked this pull request as draft January 11, 2023 10:42
@dolanor dolanor linked an issue Jan 11, 2023 that may be closed by this pull request
@dolanor dolanor linked an issue Jan 11, 2023 that may be closed by this pull request
@TomChv TomChv force-pushed the nodejs-refacto-codegen branch 2 times, most recently from b31e278 to d7cd479 Compare January 19, 2023 02:04
@TomChv TomChv marked this pull request as ready for review January 19, 2023 17:47
@slumbering
Copy link
Contributor

@dolanor @TomChv Do we have any friction between this PR and this one ?

@TomChv
Copy link
Member

TomChv commented Jan 23, 2023

Do we have any friction between this PR and this one ?

Not at all :D

@dolanor
Copy link
Contributor Author

dolanor commented Jan 26, 2023

I'll check this one tomorrow!

@slumbering
Copy link
Contributor

Is this PR still relevant (cc @dolanor @TomChv ) ?

@TomChv
Copy link
Member

TomChv commented Feb 8, 2023

Is this PR still relevant (cc @dolanor @TomChv ) ?

Of course! I'll rebase it and I'm waiting for Tanguy's review

@slumbering
Copy link
Contributor

cc @dolanor ☝️

Copy link
Contributor Author

@dolanor dolanor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work, I think you really streamlined it better.
There are a few -}} that can be avoided I think.

I would need a new version of the client generated code part of the PR to make sure that we don't have regression now that we removed most of codegen unit test.
Can you run a go run ./cmd/client-gen/ --lang nodejs -o ./sdk/nodejs/api/client.gen.ts and commit it with this PR so we see if we didn't break anything during the refactor?

@slumbering
Copy link
Contributor

@dolanor as you're the author of this PR, do you think it could be possible for you to make those changes above in order to ship this PR ?

@dolanor
Copy link
Contributor Author

dolanor commented Feb 16, 2023

I'm gonna rebase this and fix conflicts.

dolanor and others added 2 commits February 16, 2023 16:45
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
VSCode has an extension for Go template but it only parses files with *.go.tpml
or *.gtpl extension. To enable this capabilities, we rename *.ts.tpml to
*.ts.gtpl.

Simplify types.ts.tpml by merging external template
in it. This removes type, type_field_comment and object_comment template.

Add comments on some template files.

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
TomChv and others added 4 commits February 16, 2023 16:54
Merge returns template into files.
Add comments.
Make templates more readable.

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
@dolanor dolanor force-pushed the nodejs-refacto-codegen branch 2 times, most recently from 0021f39 to 56a8c9f Compare February 16, 2023 16:52
- (only use it on template comments {{- /* xxx */ -}} or if not possible
  to use a `{{- "" }}` on the next line.
- make templates directive indented by `\t`. Only use ` ` for actual TS
  code indentation

Signed-off-by: Tanguy ⧓ Herrmann <tanguy@dagger.io>
@dolanor
Copy link
Contributor Author

dolanor commented Feb 16, 2023

Ok, good to review/merge!

Copy link
Member

@TomChv TomChv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TomChv TomChv merged commit 32efa92 into dagger:main Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Refactor NodeJS SDK generator
3 participants