-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add option to hide enums (#201)
* feat: Add option to hide enums * refactor: Change option name to ignoreEnums * docs: Add description of ignoreEnums * refactor: Lint by prettier
- Loading branch information
Showing
4 changed files
with
101 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as child_process from 'child_process'; | ||
|
||
test('ignore-enums.prisma', async () => { | ||
const fileName = 'ignoreEnums.svg'; | ||
const folderName = '__tests__'; | ||
child_process.execSync(`rm -f ${folderName}/${fileName}`); | ||
child_process.execSync( | ||
`prisma generate --schema ./prisma/ignore-enums.prisma` | ||
); | ||
const listFile = child_process.execSync(`ls -la ${folderName}/${fileName}`); | ||
// did it generate a file | ||
expect(listFile.toString()).toContain(fileName); | ||
|
||
const svgAsString = child_process | ||
.execSync(`cat ${folderName}/${fileName}`) | ||
.toString(); | ||
|
||
// did it generate a file without enum | ||
expect(svgAsString).toContain(`<svg`); | ||
// include tables | ||
expect(svgAsString).toContain(`Booking`); | ||
expect(svgAsString).toContain(`Event`); | ||
// incluse table columns | ||
expect(svgAsString).toContain(`name`); | ||
expect(svgAsString).toContain(`startDate`); | ||
expect(svgAsString).toContain(`status`); | ||
expect(svgAsString).toContain(`inviteeEmail`); | ||
expect(svgAsString).toContain(`startDateUTC`); | ||
expect(svgAsString).toContain(`cancelCode`); | ||
// include enum names | ||
expect(svgAsString).toContain(`Status`); | ||
// exclude enums | ||
expect(svgAsString).not.toContain(`PENDING`); | ||
expect(svgAsString).not.toContain(`CONFIRMED`); | ||
expect(svgAsString).not.toContain(`CANCELLED`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
generator erd { | ||
provider = "node ./dist/index.js" | ||
output = "../__tests__/ignoreEnums.svg" | ||
theme = "forest" | ||
ignoreEnums = true | ||
} | ||
|
||
model Booking { | ||
id Int @id @default(autoincrement()) | ||
inviteeEmail String | ||
startDateUTC DateTime | ||
cancelCode String | ||
events Event[] | ||
} | ||
|
||
model Event { | ||
id Int @id @default(autoincrement()) | ||
name String | ||
startDate DateTime | ||
bookings Booking[] | ||
status Status @default(PENDING) | ||
} | ||
|
||
enum Status { | ||
PENDING | ||
CANCELLED | ||
CONFIRMED | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters