Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Export the current Prisma version #573

Closed
steebchen opened this issue Mar 2, 2020 · 7 comments
Closed

Export the current Prisma version #573

steebchen opened this issue Mar 2, 2020 · 7 comments
Assignees
Labels
kind/feature A request for a new feature.
Milestone

Comments

@steebchen
Copy link
Contributor

I'd like to be able to access the current Prisma version:

import { version } from "PrismaClient"

console.log(version)

which would print

2.0.0-alpha.785

The main use case for this is to verify our deployment platforms are not out of sync and actually test the latest Prisma version. Also, we think it may be useful if the version string is printed somewhere (maybe additionally in a comment in the first few lines), so users can easily verify that the generated code is indeed generated by a given Prisma version.

@pantharshit00
Copy link
Contributor

You can do the following to get the current Prisma client version:
image

@steebchen
Copy link
Contributor Author

Thanks for the tip. I'm not sure if this works with tools such as ncc or in specific cloud contexts where node_modules may be handled differently.

@Jolg42
Copy link
Member

Jolg42 commented Mar 6, 2020

Thanks to @timsuchanek

It's here in 2.0.0-alpha.874
f53b9e4

Usage:

import { PrismaClient, Post, User, version } from '@prisma/client'

const prisma = new PrismaClient()

console.log(version.client)

@Jolg42 Jolg42 closed this as completed Mar 6, 2020
@steebchen
Copy link
Contributor Author

This logs latest right now instead of the actual version:

❯ node -e "const { version } = require('@prisma/client'); console.log(version.client)"
latest

@steebchen steebchen reopened this Mar 7, 2020
@timsuchanek
Copy link
Contributor

Thanks a lot for reporting 🙏
This issue is fixed in the latest alpha version of prisma2.
You can try it out with npm i -g prisma2@alpha.

In case it’s not fixed for you - please let us know and we’ll reopen this issue!

@steebchen
Copy link
Contributor Author

This reports the SHA of the binary version, not the Prisma version. I would have expected to get the Prisma version such as 2.0.0-alpha.785. Additionally, it may make sense to expose the binary version as an additional variable in the version object.

@steebchen steebchen reopened this Mar 13, 2020
@janpio janpio transferred this issue from prisma/prisma Mar 15, 2020
@janpio janpio added the kind/feature A request for a new feature. label Mar 15, 2020
@janpio janpio added this to the Preview 25 milestone Mar 15, 2020
@timsuchanek
Copy link
Contributor

Thanks @steebchen.
We now export the following:

/**
 * Query Engine version: 4ff8379527ec7797e7bb5b55d374f82f5812a6f9
 * Prisma Client JS version: 2.0.0-alpha.913
 */
exports.version = {
  engine: "4ff8379527ec7797e7bb5b55d374f82f5812a6f9",
  client: "2.0.0-alpha.913"
}

You can try it out in the latest alpha.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature A request for a new feature.
Projects
None yet
Development

No branches or pull requests

5 participants