-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): Output version of generated Prisma Client in prisma -v #16874
base: main
Are you sure you want to change the base?
feat(cli): Output version of generated Prisma Client in prisma -v #16874
Conversation
Hi @DavidHancu! |
After taking a second look, we are actually missing tests here in https://github.com/prisma/prisma/blob/main/packages/cli/src/__tests__/commands/Version.test.ts We should test
And in 2 different situations
Note: we might need tests using different package managers potentially, but at the moment in the codebase we do not have a setup for this. So we could start with some manual tests and see how it goes with npm / yarn 1 / pnpm at least. I'm wondering if adding the file modified date would make sense in the output 🤔 |
I've already tested this manually and implemented a
If the directory doesn't exist, the If necessary, I will write the tests required for this pull request, but I will need some indication on what kind of tests need to be created and which cases should be checked. |
What about adding a |
As suggested, I've submitted a Pull Request implementing |
The ecosystem-tests for the packagers that @DavidHancu added worked fine, but some unrelated Docker tests now failed. It turned out there was a Not sure this would have been caught via the suggested tests - but now that the complexity of this is clearer, we definitely need tests with some expectations that need to be met - and that is much better implemented here than in ecosystem-tests. What might not be obvious to @DavidHancu is how to add a "generate a Client" step to these existing tests. Should this call out to the CLI itself, or do it some other way? |
Co-authored-by: Jan Piotrowski <piotrowski+github@gmail.com>
@@ -90,17 +93,38 @@ export class Version implements Command { | |||
}) | |||
|
|||
const prismaClientVersion = await getInstalledPrismaClientVersion() | |||
|
|||
const rows = [ | |||
const schemaPath = await getSchemaPath() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, getSchemaPath
's return type changed recently.
const schemaPath = await getSchemaPath() | |
const { schemaPath } = await getSchemaPath() |
@@ -143,6 +166,39 @@ export class Version implements Command { | |||
return [] | |||
} | |||
|
|||
private async getPrismaClientJSGenerators(schemaPath: string | null): Promise< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should take the { schemas }
output of getSchemaPath
as input, rather than calling getSchema()
internally.
Scope
This Pull Request represents the base implementation for #11807 and adds the version of all generated Prisma Clients to the
prisma -v
command, which will be expanded in a nicer format later on.Example Output