application icon indicating copy to clipboard operation
application copied to clipboard

Wrong filename and class name when creating an email class with ace.

Open gribbl opened this issue 1 year ago • 6 comments

Package version

9.2.1

Describe the bug

When using the node ace make:mail verify_email command, the file generated is as follows:

app
└── mails
    ├── ...
    └── verify_e_notification.ts

And the class name :

import { BaseMail } from '@adonisjs/mail'

export default class VerifyENotification extends BaseMail {
  // ...
}

The mailName generator deletes mail and mailer. Is this intentional?

Reproduction repo

No response

gribbl avatar May 24 '24 09:05 gribbl

I believe adding a removeSuffix('email') here should be enough :

https://github.com/adonisjs/application/blob/12258d0ff44e7ca14852612c7294b02731f4bb7e/src/generators.ts#L415

Can you create a PR and adding a test for that please?

Julien-R44 avatar May 24 '24 22:05 Julien-R44

So if I get it right. If we want a verify_email_notification.ts file we would end up with a verify_notification.ts file instead?

gribbl avatar May 27 '24 09:05 gribbl

Yup You can use the --intent parameter to set another suffix

Julien-R44 avatar May 27 '24 10:05 Julien-R44

I think the concern is that our normalizer is from mail from the word email and hence the file is left with e only. Is it correct @JeanCastellotti ?

thetutlage avatar May 27 '24 16:05 thetutlage

Yeah. If someone wants to name his file verify_email_intent.ts (like this example in the documentation) we end up with verify_e_intent.ts or with verify_intent.ts with the solution suggested above. But what if the user wants to keep the word email in the filename with the default intent? But, this isn't a huge issue, just rename it. :grin: I just wanted to point it out as I have used the ace command recently to generate mail classes.

gribbl avatar May 28 '24 13:05 gribbl

Yeah, we should fix it

thetutlage avatar May 28 '24 14:05 thetutlage

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 26 '25 01:04 stale[bot]