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 Generator #1772

Merged
merged 17 commits into from
Sep 26, 2024
Merged

Refactor Generator #1772

merged 17 commits into from
Sep 26, 2024

Conversation

jribbink
Copy link
Contributor

@jribbink jribbink commented Sep 24, 2024

Closes #1774

Description

Most of the work is just reoganizing logic

  • Removed branching logic based on template type in Generator.generate function. This logic was all moved to the TemplateType structs. This helps us generalize a bit better without needing special handling for each new type (i.e. README.md, tests, and anything else in the future.
  • Added a "TestTemplate" for generating tests instead of embedding this logic inside of Contract templates

I feel like this could be potentially abstracted further by breaking the template files themselves out of the generator, but probably out of scope for this PR/unnecessary right now and I think what's been changed in this PR is already an improvement.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@jribbink jribbink added the Improvement Technical work without new features, refactoring, improving tests label Sep 26, 2024
@jribbink jribbink changed the title Jribbink/refactor generator Refactor Generator Sep 26, 2024
@jribbink jribbink marked this pull request as ready for review September 26, 2024 10:01
@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 67.10526% with 50 lines in your changes missing coverage. Please review.

Project coverage is 29.73%. Comparing base (3b885aa) to head (0a5cb25).

Files with missing lines Patch % Lines
internal/super/generator/generator.go 71.42% 8 Missing and 8 partials ⚠️
internal/super/setup.go 0.00% 14 Missing ⚠️
internal/super/generate.go 0.00% 9 Missing ⚠️
internal/super/generator/contract_template.go 82.92% 5 Missing and 2 partials ⚠️
internal/super/generator/test_template.go 83.33% 2 Missing ⚠️
internal/super/generator/script_template.go 90.00% 1 Missing ⚠️
internal/super/generator/transaction_template.go 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1772      +/-   ##
==========================================
+ Coverage   29.65%   29.73%   +0.08%     
==========================================
  Files          89       94       +5     
  Lines        5197     5176      -21     
==========================================
- Hits         1541     1539       -2     
+ Misses       3469     3458      -11     
+ Partials      187      179       -8     
Flag Coverage Δ
unittests 29.73% <67.10%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chasefleming
Copy link
Member

@jribbink You tested this manually with init, generate, and with the custom directory flag in generate?

@jribbink
Copy link
Contributor Author

@jribbink You tested this manually with init, generate, and with the custom directory flag in generate?

Yup. No regressions. It fixes some issues in scripts/tx/test templates with missing values as well.

@jribbink jribbink merged commit 5ab1b47 into master Sep 26, 2024
7 checks passed
@jribbink jribbink deleted the jribbink/refactor-generator branch September 26, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Technical work without new features, refactoring, improving tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generalize & refactor project generator utility
3 participants