-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
index.ts
83 lines (76 loc) · 3.4 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import Debug from '@prisma/debug'
import { enginesVersion } from '@prisma/engines-version'
import { BinaryType, download } from '@prisma/fetch-engine'
import type { Platform } from '@prisma/get-platform'
import path from 'path'
const debug = Debug('prisma:engines')
export function getEnginesPath() {
return path.join(__dirname, '../')
}
export const DEFAULT_CLI_QUERY_ENGINE_BINARY_TYPE = BinaryType.QueryEngineLibrary
/**
* Checks if the env override `PRISMA_CLI_QUERY_ENGINE_TYPE` is set to `library` or `binary`
* Otherwise returns the default
*/
export function getCliQueryEngineBinaryType(): BinaryType.QueryEngineLibrary | BinaryType.QueryEngineBinary {
const envCliQueryEngineType = process.env.PRISMA_CLI_QUERY_ENGINE_TYPE
if (envCliQueryEngineType) {
if (envCliQueryEngineType === 'binary') {
return BinaryType.QueryEngineBinary
}
if (envCliQueryEngineType === 'library') {
return BinaryType.QueryEngineLibrary
}
}
return DEFAULT_CLI_QUERY_ENGINE_BINARY_TYPE
}
export async function ensureBinariesExist() {
const binaryDir = path.join(__dirname, '../')
let binaryTargets: string[] | undefined
if (process.env.PRISMA_CLI_BINARY_TARGETS) {
binaryTargets = process.env.PRISMA_CLI_BINARY_TARGETS.split(',')
}
const cliQueryEngineBinaryType = getCliQueryEngineBinaryType()
const binaries = {
[cliQueryEngineBinaryType]: binaryDir,
[BinaryType.MigrationEngineBinary]: binaryDir,
}
debug(`binaries to download ${Object.keys(binaries).join(', ')}`)
await download({
binaries: binaries,
showProgress: true,
version: enginesVersion,
failSilent: false,
binaryTargets: binaryTargets as Platform[],
})
}
export { enginesVersion } from '@prisma/engines-version'
/**
* This annotation is used for `node-file-trace`
* See https://github.com/zeit/node-file-trace/issues/104
* It's necessary to run this package standalone or within the sdk in Vercel
* And needed for https://github.com/vercel/pkg#detecting-assets-in-source-code
*/
path.join(__dirname, '../query-engine-darwin')
path.join(__dirname, '../query-engine-darwin-arm64')
path.join(__dirname, '../query-engine-debian-openssl-1.0.x')
path.join(__dirname, '../query-engine-debian-openssl-1.1.x')
path.join(__dirname, '../query-engine-debian-openssl-3.0.x')
path.join(__dirname, '../query-engine-rhel-openssl-1.0.x')
path.join(__dirname, '../query-engine-rhel-openssl-1.1.x')
path.join(__dirname, '../query-engine-rhel-openssl-3.0.x')
// Node API
path.join(__dirname, '../libquery_engine-darwin.dylib.node')
path.join(__dirname, '../libquery_engine-darwin-arm64.dylib.node')
path.join(__dirname, '../libquery_engine-debian-openssl-1.0.x.so.node')
path.join(__dirname, '../libquery_engine-debian-openssl-1.1.x.so.node')
path.join(__dirname, '../libquery_engine-debian-openssl-3.0.x.so.node')
path.join(__dirname, '../libquery_engine-linux-arm64-openssl-1.0.x.so.node')
path.join(__dirname, '../libquery_engine-linux-arm64-openssl-1.1.x.so.node')
path.join(__dirname, '../libquery_engine-linux-arm64-openssl-3.0.x.so.node')
path.join(__dirname, '../libquery_engine-linux-musl.so.node')
path.join(__dirname, '../libquery_engine-linux-musl-openssl-3.0.x.so.node')
path.join(__dirname, '../libquery_engine-rhel-openssl-1.0.x.so.node')
path.join(__dirname, '../libquery_engine-rhel-openssl-1.1.x.so.node')
path.join(__dirname, '../libquery_engine-rhel-openssl-3.0.x.so.node')
path.join(__dirname, '../query_engine-windows.dll.node')