How to use @prisma/engine-core - 4 common examples

To help you get started, we’ve selected a few @prisma/engine-core 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 / getGenerators.ts View on Github external
)

      if (!resolvedBinaryTargets.includes(platform)) {
        if (generator) {
          console.log(`${chalk.yellow(
            'Warning:',
          )} Your current platform \`${chalk.bold(
            platform,
          )}\` is not included in your generator's \`binaryTargets\` configuration ${JSON.stringify(
            generator.binaryTargets,
          )}.
    To fix it, use this generator config in your ${chalk.bold('schema.prisma')}:
    ${chalk.greenBright(
      printGeneratorConfig({
        ...generator,
        binaryTargets: fixPlatforms(generator.binaryTargets as any[], platform),
      }),
    )}
    ${chalk.gray(
      `Note, that by providing \`native\`, Photon automatically resolves \`${platform}\`.
    Read more about deploying Photon: ${chalk.underline(
      'https://github.com/prisma/prisma2/blob/master/docs/core/generators/photonjs.md',
    )}`,
    )}\n`)
        } else {
          console.log(
            `${chalk.yellow('Warning')} The binaryTargets ${JSON.stringify(
              binaryTargets,
            )} don't include your local platform ${platform}, which you can also point to with \`native\`.
    In case you want to fix this, you can provide ${chalk.greenBright(
      `binaryTargets: ${JSON.stringify(['native', ...(binaryTargets || [])])}`,
    )} in the schema.prisma file.`,
github prisma / photonjs / packages / photon-generate / src / generation / generateClient.ts View on Github external
export async function buildClient({
  datamodel,
  prismaYmlPath,
  transpile = false,
  runtimePath = './runtime',
  browser = false,
}: BuildClientOptions): Promise> {
  const fileMap = {}
  const prismaConfig = prismaYmlPath ? await fs.readFile(prismaYmlPath, 'utf-8') : undefined
  const internalDatamodelJson =
    process.env.PRISMA_INTERNAL_DATAMODEL_JSON ||
    (await getInternalDatamodelJson(datamodel, path.join(__dirname, '../../runtime/schema-inferrer-bin')))

  if (process.env.PRISMA_INTERNAL_DATAMODEL_JSON) {
    console.log(`Taking cached datamodel json`)
  }

  const dmmf = getDMMF(datamodel)
  const client = new TSClient({
    document: dmmf,
    prismaYmlPath,
    prismaConfig,
    datamodel,
    datamodelJson: internalDatamodelJson,
    runtimePath,
    browser,
  })
  const generatedClient = String(client)
github prisma / prisma2 / cli / sdk / src / getGenerators.ts View on Github external
const resolvedBinaryTargets = binaryTargets.map(p =>
        p === 'native' ? platform : p,
      )

      if (!resolvedBinaryTargets.includes(platform)) {
        if (generator) {
          console.log(`${chalk.yellow(
            'Warning:',
          )} Your current platform \`${chalk.bold(
            platform,
          )}\` is not included in your generator's \`binaryTargets\` configuration ${JSON.stringify(
            generator.binaryTargets,
          )}.
    To fix it, use this generator config in your ${chalk.bold('schema.prisma')}:
    ${chalk.greenBright(
      printGeneratorConfig({
        ...generator,
        binaryTargets: fixPlatforms(generator.binaryTargets as any[], platform),
      }),
    )}
    ${chalk.gray(
      `Note, that by providing \`native\`, Photon automatically resolves \`${platform}\`.
    Read more about deploying Photon: ${chalk.underline(
      'https://github.com/prisma/prisma2/blob/master/docs/core/generators/photonjs.md',
    )}`,
    )}\n`)
        } else {
          console.log(
            `${chalk.yellow('Warning')} The binaryTargets ${JSON.stringify(
              binaryTargets,
            )} don't include your local platform ${platform}, which you can also point to with \`native\`.
    In case you want to fix this, you can provide ${chalk.greenBright(
github prisma / photonjs / packages / photon-generate / src / generation / index.ts View on Github external
export async function generateClient(datamodel: string, prismaYmlPath: string, outputDir: string) {
  if (!(await fs.pathExists(prismaYmlPath))) {
    throw new Error(`Provided prisma.yml path ${prismaYmlPath} does not exist`)
  }

  const prismaConfig = await fs.readFile(prismaYmlPath, 'utf-8')
  const internalDatamodelJson = await getInternalDatamodelJson(
    datamodel,
    path.join(__dirname, '../../runtime/schema-inferrer-bin'),
  )

  await fs.mkdirp(outputDir)

  const client = new TSClient(getDMMF(datamodel), prismaYmlPath, prismaConfig, datamodel, internalDatamodelJson)
  const generatedClient = String(client)
  await fs.copy(path.join(__dirname, '../../runtime'), path.join(outputDir, '/runtime'))
  await fs.writeFile(path.join(outputDir, 'index.ts'), generatedClient)
}

@prisma/engine-core

This package is intended for Prisma's internal use

Apache-2.0
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis

Similar packages