Skip to content

Commit

Permalink
fix binary versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Dec 19, 2019
1 parent e6177bb commit 973ef07
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cli/sdk/src/engineCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export async function getDMMF({
datamodelPath,
retry = 4,
}: GetDMMFOptions): Promise<DMMF.Document> {
debug(`getDMMF, override prismaPath = ${prismaPath}`)
prismaPath = prismaPath || (await getPrismaPath())
let result
try {
Expand Down Expand Up @@ -154,6 +155,7 @@ export async function getConfig({
prismaPath,
datamodelPath,
}: GetDMMFOptions): Promise<ConfigMetaFormat> {
debug(`getConfig, override prismaPath = ${prismaPath}`)
prismaPath = prismaPath || (await getPrismaPath())

let tempDatamodelPath: string | undefined = datamodelPath
Expand Down
21 changes: 20 additions & 1 deletion cli/sdk/src/getGenerators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,35 @@ export async function getGenerators({
if (!fs.existsSync(schemaPath)) {
throw new Error(`${schemaPath} does not exist`)
}
const platform = await getPlatform()

let prismaPath: string | undefined = undefined

if (version) {
const downloadParams: DownloadOptions = {
binaries: {
'query-engine': eval(`require('path').join(__dirname, '..')`),
},
binaryTargets: [platform],
showProgress: false,
version: version || 'latest',
skipDownload,
}

const binaryPathsWithEngineType = await download(downloadParams)
prismaPath = binaryPathsWithEngineType.queryEngine![platform]
}

const datamodel = fs.readFileSync(schemaPath, 'utf-8')
const dmmf = await getDMMF({
datamodel,
datamodelPath: schemaPath,
prismaPath,
})
const config = await getConfig({
datamodel,
datamodelPath: schemaPath,
prismaPath,
})

const generatorConfigs = overrideGenerators || config.generators
Expand Down Expand Up @@ -169,7 +189,6 @@ The generator needs to either define the \`defaultOutput\` path in the manifest
const binaries = generators.flatMap(g =>
g.manifest ? g.manifest.requiresEngines || [] : [],
)
const platform = await getPlatform()

let binaryTargets = unique(
generatorConfigs.flatMap(g => g.binaryTargets || []),
Expand Down

0 comments on commit 973ef07

Please sign in to comment.