core: Pluralization is broken
Package version
6.2.2
Describe the bug
When I want to create new models or controllers (and probably other things), the name formatter behaves wrongly in some cases. For example, try:
node ace make:model cookies
This creates cooky.ts!
This happens for many other words, including made-up words.
I investigated a bit, and seems like the problem comes from pluralize library which is used under the hood by poppinss/utils. Pluralize was last updated in 2019, and has many open pull requests.
So, 3 possible solutions come to my mind:
- replace pluralize or fork it to fix this bugs and avoid conversion of made-up words
- add a flag for all
make:*commands to prevent this auto fix. - instead of changing the word automatically, add an extra step in cli to ask users if they want their new controller/model/… name to be changed or not… something like:
Do you want to change "CookiesCOntroLLer" to "cooky"? (Y/n)
Reproduction repo
No response
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 19 (6 by maintainers)
When I have some time (which might not be soon), I’ll develop a new module using the Doctrine Inflector API to replace our current pluralization API. It’ll be a framework-agnostic package under the BoringNode organisation.
Not sure what really the solution is, if most of the popular libs get it wrong.
But I agree, bypassing the transformation with a flag seems like a nice middle ground. Not in favor of a prompt.
People can already change all scaffolding option https://docs.adonisjs.com/guides/scaffolding
Don’t try to switch to the fancy
compromiselibrary; which is an amazing lib… but it gets this wrong too. I was about to post that this would be a great alternative, but it’s not. Demo: https://codesandbox.io/p/sandbox/compromise-forked-h2vg55