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

feat: Add Scaffolding to CLI #11

Merged
merged 85 commits into from May 15, 2024

Conversation

amritanshusikdar
Copy link
Contributor

@amritanshusikdar amritanshusikdar commented Mar 27, 2024

Description
This PR aims to have a more reliable project structure for the CLI and move the scaffold feature from the regular Kyma CLI.

Related issue(s)
Resolves #9

Aspects to consider for knowledge sharing

  • business logic (internal/scaffold) is decoupled from command logic (cmd/modulectl/create/scaffold)
  • business logic invocation has a clear contract (internal/scaffold/options.go)
    • validation has been shifted left (previously flags were validated after creating the object, now at the beginning of the business logic invocation)
  • business logic is unit tested, overall command logic is covered by e2e tests
    • we decided to not introduce integration tests in addition as the unit tests and e2e tests should already be sufficient
  • comments on SOLID:
    • S: e.g., dedicated services (file generator, content provider, ...) each having a single responsibility
    • O: e.g., FileGenerator and ReuseFileGenerator (decorator pattern), where the later adds functionality on top of the former without modifying the former's code
    • L: n/a
    • I: e.g., ScaffoldService and (Reuse)FileGenerators, each defining the exact dependencies as interfaces they rely on
      • e.g., FileGenerator requiring a FileWriter, while ReuseFileGenerator requires a FileReader (+ the generator)
    • D: e.g., all services, dependencies are injected into constructor method allowing easy and extensive unit testing (see also the test stubs)
  • guard clauses used to prevent developer errors when composing the functionality

@CLAassistant
Copy link

CLAassistant commented Mar 27, 2024

CLA assistant check
All committers have signed the CLA.

@kyma-bot kyma-bot added size/XXL and removed size/M labels Apr 3, 2024
refactor Makefile and adhere to PR comments
adjust Version in Makefile
@kyma-bot kyma-bot added size/L and removed size/XXL labels Apr 9, 2024
@kyma-bot kyma-bot added size/XXL and removed size/L labels Apr 17, 2024
refine tests

add flags

add structure to codebase
refactor RunE() method

add new lines to error outputs

update help message

add e2e tests
cmd/modulectl/create/create.go Outdated Show resolved Hide resolved
cmd/modulectl/modulectl.go Outdated Show resolved Hide resolved
tools/create/scaffold/moduleconfig.go Outdated Show resolved Hide resolved
tools/create/scaffold/moduleconfig.go Outdated Show resolved Hide resolved
tools/create/scaffold/moduleconfig.go Outdated Show resolved Hide resolved
tests/create/scaffold/scaffold_e2e_test.go Outdated Show resolved Hide resolved
tools/create/scaffold/scaffold.go Outdated Show resolved Hide resolved
tools/create/scaffold/scaffold.go Outdated Show resolved Hide resolved
tests/create/scaffold/scaffold_test.go Outdated Show resolved Hide resolved
tests/create/scaffold/scaffold_test.go Outdated Show resolved Hide resolved
@c-pius c-pius requested a review from lindnerby May 13, 2024 13:06
lindnerby
lindnerby previously approved these changes May 14, 2024
@kyma-bot kyma-bot added the lgtm label May 14, 2024
Copy link

@mmitoraj mmitoraj left a comment

Choose a reason for hiding this comment

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

The docs look great. I've added 3 suggestions; however, I wasn't sure where to add them. Are those autogenerated .md files? Where is the source? As far as I know, the autogenerated docs cannot be edited, I usually added comments for those to the respective .go or .yaml files - not sure which ones. Does it work the same here?

cmd/modulectl/create/scaffold/long.txt Outdated Show resolved Hide resolved
cmd/modulectl/create/scaffold/long.txt Outdated Show resolved Hide resolved
cmd/modulectl/create/scaffold/long.txt Outdated Show resolved Hide resolved
@kyma-bot kyma-bot merged commit b36b3f6 into kyma-project:main May 15, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move Module Scaffolding command from Kyma CLI to the modulectl
7 participants