Closed gwesterman closed 1 year ago
I can't reproduce this issue. Can you please share all your config?
generator nestjsDto {
provider = "prisma-generator-nestjs-dto"
output = "../../libs/api/models/generated"
outputToNestJsResourceStructure = "true"
reExport = "true"
flatResourceStructure = "false"
exportRelationModifierClasses = "true"
createDtoPrefix = "Create"
updateDtoPrefix = "Update"
dtoSuffix = "Dto"
entityPrefix = ""
entitySuffix = ""
classValidation = "true"
fileNamingStyle = "kebab"
noDependencies = "false"
outputType = "class"
definiteAssignmentAssertion = "true"
prettier = "true"
}
This will generate the following structure:
.
├── ...
├── generated
│ ├── model1
│ │ ├── dto
│ │ │ ├── ..
│ │ │ └── index.ts
│ │ └── entity
│ │ ├── ..
│ │ └── index.ts
│ ├── model2
│ │ ├── dto
│ │ │ ├── ..
│ │ │ └── index.ts
│ │ └── entity
│ │ ├── ..
│ │ └── index.ts
│ └── ...
└── ...
There is a barrel index.ts
for every dto and entity folder, but there are no barrel in the parent folders that re-export them. This is a something that I currently have to maintain manually in the root level generated
.
If I set the configuration to the following:
generator nestjsDto {
...
outputToNestJsResourceStructure = "false"
flatResourceStructure = "true"
reExport = "true"
...
}
I get this folder structure, where every file, including a barrel index.ts
is contained within a single root folder.
.
├── ...
├── generated
│ ├── connect-model1 .dto.ts
│ ├── connect-model1 .entity.ts
│ ├── create-model1 .dto.ts
│ ├── create-model1 .entity.ts
│ ├── model1.dto.ts
│ ├── model1.entity.ts
│ ├── model2.dto.ts
│ ├── model2.entity.ts
│ ├── update-model1 .dto.ts
│ ├── update-model1 .entity.ts
│ ├── index..ts
│ └── ...
└── ...
This is quite messy but allows me to export everything from a single barrel index.ts
, which is quite useful.
I would like to have the following folder structure:
.
├── ...
├── generated
│ ├── model1
│ │ ├── dto
│ │ │ ├── ..
│ │ │ └── index.ts
│ │ ├── entity
│ │ │ ├── ..
│ │ │ └── index.ts
│ │ └── index.ts
│ ├── model1
│ │ ├── dto
│ │ │ ├── ..
│ │ │ └── index.ts
│ │ ├── entity
│ │ │ ├── ..
│ │ │ └── index.ts
│ │ └── index.ts
│ ├── index.ts
│ └── ...
└── ...
Here generated/index.ts
exports everything from generated/model1/index.ts
and generated/model2/index.ts
while generated/model1/index.ts
exports everything from generated/model1/dto/index.ts
and generated/model1/entity/index.ts
.
and generated/model2/index.ts
exports everything from generated/model2/dto/index.ts
and generated/model2/entity/index.ts
.
This allows me to re-export everything from a single barrel index.ts
on the root level but also keep the models separate from each other in, keeping things a little more tidy.
What about setting all 3 options to true
?
generator nestjsDto {
...
outputToNestJsResourceStructure = "true"
flatResourceStructure = "true"
reExport = "true"
...
}
It would generate a structure like below having model1 and model2 separated, but model1.dto.ts and model1.entity.ts are in the same folder with a common index.ts:
.
├── ...
├── generated
│ ├── model1
│ │ ├─ model1.dto.ts
│ │ ├─ model1.entity.ts
│ │ ├─ create-model1.dto.ts
│ │ ├─ ...
│ │ └─ index.ts
│ ├── model2
│ │ ├─ model2.dto.ts
│ │ ├─ model2.entity.ts
│ │ ├─ create-model2.dto.ts
│ │ ├─ ...
│ │ └─ index.ts
│ └── ...
└── ...
This would still require maintaining a barrel file on the root level manually. It's the smallest of inconveniences, I just wanted to put it out there ;-)
Ah, I missed the last index.ts in the generated folder in your example.
I added a combined index.ts in the root output folder. Please checkout https://www.npmjs.com/package/@brakebein/prisma-generator-nestjs-dto/v/1.18.0-beta4
When setting both outputToNestJsResourceStructure and reExport to true, no index.ts is created that re-exports from the individual dto and entity folders.
Perhaps a third option could be added to enable this behavior.