Skip to content

Commit d055e3b

Browse files
committed
fix: Generate distinct related enums with bound feature
1 parent b8aa548 commit d055e3b

File tree

6 files changed

+19
-28
lines changed

6 files changed

+19
-28
lines changed
File renamed without changes.
File renamed without changes.

src/@generated/enum/allowed-color.enum.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

src/generate-file-name.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@ import { toKebab } from 'to-kebab';
44
export type FileType = 'model' | 'input' | 'enum';
55

66
const splitKeywords = [
7-
'WhereInput',
8-
'ScalarWhereInput',
9-
'OrderByInput',
10-
'WhereUniqueInput',
117
'CreateInput',
12-
'UpdateInput',
13-
'UpsertWith',
14-
'UpsertWithout',
15-
'UpdateWith',
16-
'UpdateMany',
178
'CreateMany',
9+
'CreateOneWithout',
1810
'CreateWithout',
19-
'UpdateOneWithout',
11+
'DistinctField',
12+
'Filter',
2013
'ManyWithout',
21-
'CreateOneWithout',
14+
'OrderByInput',
15+
'ScalarWhereInput',
16+
'UpdateInput',
17+
'UpdateMany',
2218
'UpdateOneRequiredWithout',
23-
'Filter',
19+
'UpdateOneWithout',
20+
'UpdateWith',
21+
'UpsertWith',
22+
'UpsertWithout',
23+
'WhereInput',
24+
'WhereUniqueInput',
2425
].sort((a, b) => b.length - a.length);
2526

2627
type GenerateFileNameArgs = {
@@ -42,8 +43,12 @@ export function generateFileName(args: GenerateFileNameArgs) {
4243
}
4344
}
4445
let dasherizedName = toKebab(name);
45-
if (type === 'input' && dasherizedName.endsWith('-input')) {
46-
dasherizedName = dasherizedName.slice(0, -6);
46+
47+
for (const suffix of ['input', 'enum']) {
48+
const ending = `-${suffix}`;
49+
if (type === suffix && dasherizedName.endsWith(ending)) {
50+
dasherizedName = dasherizedName.slice(0, -ending.length);
51+
}
4752
}
4853

4954
return pupa(template, {

0 commit comments

Comments
 (0)