kepelrs / nestjs-prisma-crud-schematics

MIT License
1 stars 5 forks source link

Optional use of pluralize #83

Open robblovell opened 1 year ago

robblovell commented 1 year ago

Is there an existing issue that is already proposing this?

Is your feature request related to a problem? Please describe it

I am using a set of prisma generators which do not remove the plural endings for dtos or entities. I would like to leverage the generated dto's and entities of the other generator and overwrite the dto's and entites generated by this package and keep the controllers. However, when the 's' or 'es' is removed, the two generators are incompatible.

Describe the solution you'd like

Looking at the code:

in resource.schema.d.ts:

In src/lib/crud-resource/crud-resource.factory.ts: Change line 100 to:

        singular: (name: string) => options.pluralize ? pluralize.singular(name) : name,

in src/lib/resource/resource.factory.ts: Change line 137 to:

        singular: (name: string) => options.pluralize ? pluralize.singular(name) : name,

in src/lib/resource/schema.json and src/lib/crud_resource/

schema.json

   "pluralize": {
      "type": "boolean",
      "default": true,
      "description": "Flag to determine if plural endings should be removed from dto filenames."
    },

resource.schema.d.ts and crud-resource.schema.d.ts

  /**
   * If true, pluralize is used to generate names for dto files.
   */
  pluralize?: boolean;

I am uncertain of any other changes that would be required for publishing. I am working on a pull request here: feature-branch

Teachability, documentation, adoption, migration strategy

I believe if the flag defaults to true, it will not be a breaking change.

What is the motivation / use case for changing the behaviour?

By setting the pluralize flag to false, I can use both generators together.

kepelrs commented 1 year ago

Hey, this looks good. Feel free to submit the PR whenever you are ready.

Can you share details about which Prisma generators you are using? I may want to add a note about it in the main docs, and keep the specifics of it in mind during the work I'm targeting for the next few months...