How to use the @prisma/get-platform.getPlatform function in @prisma/get-platform

To help you get started, we’ve selected a few @prisma/get-platform examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prisma / prisma2 / cli / sdk / src / engineCommands.ts View on Github external
async function getPrismaPath(): Promise {
  // tslint:disable-next-line
  if (process.env.PRISMA_QUERY_ENGINE_BINARY) {
    if (!fs.existsSync(process.env.PRISMA_QUERY_ENGINE_BINARY)) {
      throw new Error(
        `Env var PRISMA_QUERY_ENGINE_BINARY is provided but provided path ${process.env.PRISMA_QUERY_ENGINE_BINARY} can't be resolved.`,
      )
    }
    return process.env.PRISMA_QUERY_ENGINE_BINARY
  }
  const dir = eval('__dirname')
  const platform = await getPlatform()
  const extension = platform === 'windows' ? '.exe' : ''
  const relative = `query-engine-${platform}${extension}`
  let prismaPath = path.join(dir, '..', relative)
  if (fs.existsSync(prismaPath)) {
    return prismaPath
  }
  // for pkg
  prismaPath = path.join(dir, '../..', relative)
  if (fs.existsSync(prismaPath)) {
    return prismaPath
  }

  prismaPath = path.join(__dirname, '..', relative)
  if (fs.existsSync(prismaPath)) {
    return prismaPath
  }
github prisma / photonjs / packages / photon / src / engineCommands.ts View on Github external
async function getPrismaPath(): Promise {
  // tslint:disable-next-line
  const dir = eval('__dirname')
  const platform = await getPlatform()
  const extension = (platform === 'windows') ? '.exe' : ''
  const relative = `../query-engine-${platform}${extension}`
  return path.join(dir, relative)
}
github prisma / lift / src / liftEngineCommands.ts View on Github external
async function getMigrationEnginePath(): Promise {
  // tslint:disable-next-line
  const dir = eval('__dirname')
  const platform = await getPlatform()
  const extension = platform === 'windows' ? '.exe' : ''
  const relative = `../migration-engine${extension}`
  return path.join(dir, relative)
}
github prisma / lift / src / Studio.ts View on Github external
public async start(providerAliases: ProviderAliases): Promise {
    try {
      if (this.instance) {
        throw new Error(`Studio is already started`)
      }

      const platform = await getPlatform()
      const extension = platform === 'windows' ? '.exe' : ''

      const pathCandidates = [
        // ncc go home
        // tslint:disable-next-line
        eval(`require('path').join(__dirname, '../node_modules/@prisma/sdk/query-engine-${platform}${extension}')`), // for local dev
        // tslint:disable-next-line
        eval(`require('path').join(__dirname, '../query-engine-${platform}${extension}')`), // for production
      ]

      const pathsExist = await Promise.all(
        pathCandidates.map(async candidate => ({ exists: fs.existsSync(candidate), path: candidate })),
      )

      const firstExistingPath = pathsExist.find(p => p.exists)
github prisma / prisma2 / cli / sdk / src / IntrospectionEngine.ts View on Github external
private async getBinaryPath() {
    if (this.binaryPath) {
      return this.binaryPath
    }

    const platform = await getPlatform()
    const extension = platform === 'windows' ? '.exe' : ''

    this.binaryPath = path.join(
      eval(`require('path').join(__dirname, '../')`),
      `introspection-engine-${platform}${extension}`,
    )
    if (!fs.existsSync(this.binaryPath)) {
      throw new Error(
        `Expected introspection engine at ${this.binaryPath} does not exist.`,
      )
    }
    return this.binaryPath
  }
  private internalInit(): Promise {
github prisma / prisma2 / cli / sdk / src / getGenerators.ts View on Github external
async function validateGenerators(generators: GeneratorConfig[]) {
  const platform = await getPlatform()

  for (const generator of generators) {
    if (generator.provider === 'nexus-prisma') {
      throw new Error(
        '`nexus-prisma` is no longer a generator. You can read more at https://pris.ly/nexus-prisma-upgrade-0.4',
      )
    }
    if (generator.config.platforms) {
      throw new Error(
        `The \`platforms\` field on the generator definition is deprecated. Please rename it to \`binaryTargets\`.`,
      )
    }
    if (generator.config.pinnedPlatform) {
      throw new Error(
        `The \`pinnedPlatform\` field on the generator definition is deprecated.
Please use the PRISMA_QUERY_ENGINE_BINARY env var instead to pin the binary target.`,
github prisma / photonjs / packages / photon / src / utils / generateInFolder.ts View on Github external
`Project dir missing. Usage: ts-node examples/generate.ts examples/accounts`,
    )
  }
  if (!fs.existsSync(projectDir)) {
    throw new Error(`Path ${projectDir} does not exist`)
  }
  const schemaPath = getSchemaPath(projectDir)
  const datamodel = fs.readFileSync(schemaPath, 'utf-8')

  const dmmf = await getDMMF({ datamodel })
  const config = await getConfig({ datamodel })

  const outputDir = path.join(projectDir, 'node_modules/@prisma/photon')
  await getPackedPackage('@prisma/photon', outputDir)

  const platform = await getPlatform()

  await generateClient({
    binaryPaths: {
      queryEngine: {
        [platform]: path.join(
          __dirname,
          `../../query-engine-${platform}${
            platform === 'windows' ? '.exe' : ''
          }`,
        ),
      },
    },
    datamodel,
    dmmf,
    ...config,
    outputDir,
github prisma / photonjs / packages / engine-core / src / NodeEngine.ts View on Github external
async getPlatform() {
    if (this.platformPromise) {
      return this.platformPromise
    }

    this.platformPromise = getPlatform()

    return this.platformPromise
  }
github prisma / lift / src / utils / sendPanic.ts View on Github external
export async function sendPanic(error: LiftPanic, cliVersion: string, binaryVersion: string): Promise {
  try {
    const schema = fs.readFileSync(error.schemaPath, 'utf-8')
    const maskedSchema = maskSchema(schema)

    const signedUrl = await createErrorReport({
      area: ErrorArea.LIFT_CLI,
      kind: ErrorKind.RUST_PANIC,
      cliVersion,
      binaryVersion,
      command: process.argv.slice(2).join(' '),
      jsStackTrace: stripAnsi(error.stack || error.message),
      rustStackTrace: error.rustStack,
      operatingSystem: `${os.arch()} ${os.platform()} ${os.release()}`,
      platform: await getPlatform(),
      liftRequest: JSON.stringify(error.request),
      schemaFile: maskedSchema,
      fingerprint: getFid() || undefined,
    })

    const zip = await makeErrorZip(error)
    await uploadZip(zip, signedUrl)

    const id = await makeErrorReportCompleted(signedUrl)
    return id
  } catch (e) {
    debug(e)
  }
}

@prisma/get-platform

This package is intended for Prisma's internal use

Apache-2.0
Latest version published 4 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages