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: initial support for case type selection #1501

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

espoal
Copy link

@espoal espoal commented Jul 31, 2023

Summary

This is the first of a multi PR effort aiming at supporting custom name casing conventions, as detailed here.

  1. This PR attempts to update @nestjs/schematics to accept a caseType option when generating a controller.
  2. In this PR we add a caseNaming field to GenerateOptions
  3. This is the PR to document the new option
  4. Future PRs will extend this feature in term of supported actions, tests and configuration

For now I decided to support only controllers, to reduce the changes size and make reviewing easier. If the approach will be approved I will make sure to extend it to other objects and to add more tests. For the reviewer please check this in particular.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Currently @nestjs/cli uses kebab-or-snake case, as mentioned in this issue.

What is the new behavior?

The goal is to add a caseNaming option to nest-cli.json so that generated files will follow the desired name casing convention.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other informations

@espoal espoal changed the title feat: initial support for case selection feat: initial support for case type selection Jul 31, 2023
@espoal espoal marked this pull request as ready for review August 15, 2023 13:45
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/lib/application/application.factory.test.ts Outdated Show resolved Hide resolved
src/lib/application/application.schema.d.ts Show resolved Hide resolved
src/lib/application/schema.json Outdated Show resolved Hide resolved
);

target.caseNaming = !!target.caseNaming ? target.caseNaming : 'snake';
Copy link

Choose a reason for hiding this comment

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

Hi, maybe i missed something, but this shouldn't be pascal by default ?

Copy link
Author

@espoal espoal Jan 25, 2024

Choose a reason for hiding this comment

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

In the original implementation a case named kebab-or-snake is used, which is the snake you see referred here. I kept the original default to avoid unintended side effects, for example other piece of the nestjs codebase default to and expect snake as input, or they will complain

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.

None yet

4 participants