Skip to content

Commit

Permalink
fix binaryTargets
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Nov 22, 2019
1 parent 333ccf8 commit df58ec9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cli/introspection/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prisma/introspection",
"version": "0.0.130",
"version": "0.0.134",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion cli/prisma2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prisma2",
"version": "2.0.0-alpha.345",
"version": "2.0.0-alpha.349",
"main": "build/index.js",
"repository": "git@github.com:prisma/prisma2-cli.git",
"author": "Tim Suchanek <suchanek@prisma.io>",
Expand Down
2 changes: 1 addition & 1 deletion cli/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prisma/sdk",
"version": "0.0.55",
"version": "0.0.59",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:prisma/prisma2.git",
Expand Down
30 changes: 23 additions & 7 deletions cli/sdk/src/getGenerators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { unique } from './unique'
import { pick } from './pick'
import { Generator } from './Generator'
import { resolveOutput } from './resolveOutput'
import { getPlatform } from '@prisma/get-platform'
import { getPlatform, Platform } from '@prisma/get-platform'
import { printGeneratorConfig, fixPlatforms } from '@prisma/engine-core'
import {
predefinedGeneratorResolvers,
Expand Down Expand Up @@ -232,16 +232,23 @@ export function skipIndex<T = any>(arr: T[], index: number): T[] {
return [...arr.slice(0, index), ...arr.slice(index + 1)]
}

export const knownBinaryTargets = [
export const knownBinaryTargets: Platform[] = [
'native',
'darwin',
'linux-glibc-libssl1.0.1',
'linux-glibc-libssl1.0.2',
'linux-glibc-libssl1.1.0',
'linux-musl-libssl1.1.0',
'debian-openssl-1.0.x',
'debian-openssl-1.1.x',
'rhel-openssl-1.0.x',
'rhel-openssl-1.1.x',
'windows',
]

const oldToNewBinaryTargetsMapping = {
'linux-glibc-libssl1.0.1': 'debian-openssl-1.0.x',
'linux-glibc-libssl1.0.2': 'debian-openssl-1.0.x',
'linux-glibc-libssl1.1.0': 'debian-openssl1.1.x',
'linux-musl-libssl1.1.0': 'debian-openssl1.1.x',
}

async function validateGenerators(generators: GeneratorConfig[]) {
const platform = await getPlatform()

Expand All @@ -264,7 +271,16 @@ Please use the PRISMA_QUERY_ENGINE_BINARY env var instead to pin the binary targ
}
if (generator.binaryTargets) {
for (const binaryTarget of generator.binaryTargets) {
if (!knownBinaryTargets.includes(binaryTarget)) {
if (oldToNewBinaryTargetsMapping[binaryTarget]) {
throw new Error(
`Binary target ${chalk.red.bold(
binaryTarget,
)} doesn't exist anymore. Please use ${chalk.green.bold(
oldToNewBinaryTargetsMapping[binaryTarget],
)} instead.`,
)
}
if (!knownBinaryTargets.includes(binaryTarget as Platform)) {
throw new Error(
`Unknown binary target ${chalk.red(
binaryTarget,
Expand Down
11 changes: 9 additions & 2 deletions cli/sdk/src/getPackedPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,26 @@ import copy from '@apexearth/copy'
import makeDir from 'make-dir'
import { promisify } from 'util'
import rimraf from 'rimraf'
import Debug from 'debug'
const debug = Debug('getPackedPackage')

// why not directly use Sindre's 'del'? Because it's not ncc-able :/
const del = promisify(rimraf)

export async function getPackedPackage(
name: string,
target: string,
packageDir?: string,
): Promise<void> {
if (!target) {
throw new Error(`Error in getPackage: Please provide a target`)
}
const packageDir =
resolvePkg(name, { cwd: __dirname }) || resolvePkg(name, { cwd: target })
packageDir =
packageDir ||
resolvePkg(name, { cwd: __dirname }) ||
resolvePkg(name, { cwd: target })

debug({ packageDir })

if (!packageDir) {
throw new Error(
Expand Down

0 comments on commit df58ec9

Please sign in to comment.