Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Feat/case #2

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Feat/case #2

wants to merge 2 commits into from

Conversation

espoal
Copy link

@espoal espoal commented Jul 14, 2023

Summary

This is the second of a multi PR effort aiming at supporting custom name casing conventions, as detailed nestjs/nest-cli#462.

  1. In this PR attempts to update @nestjs/schematics to accept a caseType option when generating a controller.
  2. The second PR we add a --case option to the CLI so that it can be correctly passed to the schematic generator.
  3. A third PR will add support for filenames casing convention, on top of variable names, and extend this approach to classes other than controllers

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.

This PR has been sponsored by South Pole. South pole is currently hiring, make sure to check the available positions!.

Open questions

TBD

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • 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/schematics uses kebab-case, as mentioned here.

Issue Number: 462

What is the new behavior?

A new SchematicOption called caseType will allow us to specify a case convention and the output will be formatted accordingly.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@@ -1,3 +1,48 @@
import { CaseToCase } from 'case-to-case'
Copy link
Author

Choose a reason for hiding this comment

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

I might use another package

@@ -1,4 +1,4 @@
import { Controller } from '@nestjs/common';

@Controller('<%= dasherize(name) %>')
@Controller('<%= name %>')
Copy link
Author

Choose a reason for hiding this comment

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

I expect the name to be passed with the correct casing option so dasherize shouldn't be needed anymore.

@espoal espoal mentioned this pull request Jul 14, 2023
12 tasks
@espoal espoal self-assigned this Jul 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant