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: Generator CLI support #80

Merged
merged 7 commits into from
Dec 13, 2024
Merged

feat: Generator CLI support #80

merged 7 commits into from
Dec 13, 2024

Conversation

jmuzina
Copy link
Member

@jmuzina jmuzina commented Dec 12, 2024

Done

Creates a prompting module that allows generators to request and read CLI input. Switches the generator to use CLI input only.

This will allow the generator to be executed programmatically, enhancing its testability.

QA

  • bun i
  • yo @canonical/canonical-ds:component - see that the generator now fails due to missing required positional argument
  • yo @canonical/canonical-ds:component path/to/button - see that the generator creates a default button component
  • yo @canonical/canonical-ds:component path/to/button --withStories --withStyles - see the generators also includes storybook and style files
  • yo @canonical/canonical-ds:component --help - see the generator displays input parameter help

PR readiness check

  • PR should have one of the following labels:
    • Feature 🎁, Breaking Change 💣, Bug 🐛, Documentation 📝, Maintenance 🔨.
  • All packages define the required scripts in package.json:
    • All packages: check and check:fix.
    • Packages with a build step: build.

Screenshots

Screenshot 2024-12-13 at 14 38 30

Copy link
Contributor

@advl advl left a comment

Choose a reason for hiding this comment

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

In general, while I support the approach, I am skeptical of the quantity of code required to have the two modes working together.

It seems we are adding a lot of custom code to implement a mixin-like functionality, that is likely outside of the domain of this package.

Trying to reduce complexity, I would recommend :

  • either trying to upstream such logic directly to yo,
  • or reconsidering making a custom generator (in a separate package)
  • or implementing cli mode as default, without interactive mode.

@bartaz
Copy link
Member

bartaz commented Dec 13, 2024

I guess "yeoman-way" is to use config files if you don't want interactive prompts: https://yeoman.io/authoring/storage

@jmuzina jmuzina marked this pull request as ready for review December 13, 2024 20:22
Copy link
Contributor

@advl advl left a comment

Choose a reason for hiding this comment

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

If we go for cli only, we can get rid of the prompting helpers and keep the generator to one file using this.argument

apps/generator-canonical-ds/src/component/index.ts Outdated Show resolved Hide resolved
apps/generator-canonical-ds/src/component/index.ts Outdated Show resolved Hide resolved
@jmuzina jmuzina requested review from advl and bartaz December 13, 2024 21:48
@advl advl merged commit 294460e into main Dec 13, 2024
2 checks passed
@jmuzina jmuzina deleted the generator-cli branch December 16, 2024 21:09
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.

3 participants