How to use @prisma/fetch-engine - 8 common examples

To help you get started, we’ve selected a few @prisma/fetch-engine 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 / prisma2 / src / CLI.ts View on Github external
return Version.new().parse(argv)
    }
    // display help for help flag or no subcommand
    if (args._.length === 0 || args['--help']) {
      return this.help()
    }

    // check if we have that subcommand
    const cmdName = args._[0]
    const cmd = this.cmds[cmdName]
    if (cmd) {
      // if we have that subcommand, let's ensure that the binary is there in case the command needs it
      if (this.ensureBinaries.includes(cmdName)) {
        const binaryPath = eval(`require('path').join(__dirname, '../')`)
        const version = (pkg && pkg.prisma && pkg.prisma.version) || 'latest'
        await download({
          binaries: {
            'query-engine': binaryPath,
            'migration-engine': binaryPath,
            'introspection-engine': binaryPath,
          },
          showProgress: true,
          version,
          failSilent: false,
        })
      }

      return cmd.parse(args._.slice(1))
    }
    // unknown command
    return unknownCommand(CLI.help, args._[0])
  }
github prisma / prisma2 / cli / introspection / src / prompt / screens / Step60DownloadExample.tsx View on Github external
export async function downloadRepo(organization: string, repo: string, branch: string): Promise {
  const downloadUrl = `https://api.github.com/repos/${organization}/${repo}/tarball/${branch}` // TODO: use master instead of prisma2
  const tmpFile = getTmpFile(`prisma-download-${organization}-${repo}-${branch}.tar.gz`)
  const response = await fetch(downloadUrl, {
    agent: getProxyAgent(downloadUrl),
    headers: {
      'User-Agent': 'prisma/prisma-init',
    },
  })
  await new Promise((resolve, reject) => {
    response.body
      .pipe(fs.createWriteStream(tmpFile))
      .on('error', reject)
      .on('close', resolve)
  })
  return tmpFile
}
github prisma / photonjs / packages / photon-generate / scripts / download.js View on Github external
const { ensureBinaries } = require('@prisma/fetch-engine')
const path = require('path')
const debug = require('debug')('download')
// Until https://github.com/zeit/ncc/issues/390 is resolved we have to do this 🙈
const runtimePath = eval(`path.join(__dirname, '../runtime')`)
debug(`Downloading binaries to ${runtimePath}`)
ensureBinaries(runtimePath)
github MichalLytek / type-graphql / tests / helpers / ensure-engine.ts View on Github external
import { download } from "@prisma/fetch-engine";
import path from "path";
import fs from "fs";

const photonRuntimeDir = path.join(
  __dirname,
  "../../node_modules/@prisma/photon",
);

if (!fs.existsSync(photonRuntimeDir)) {
  throw new Error("Missing Photon directory: " + photonRuntimeDir);
}

download({
  binaries: {
    "query-engine": photonRuntimeDir,
  },
  showProgress: true,
})
  .then(() => process.exit(0))
  .catch(() => process.exit(1));
github prisma / prisma2 / cli / prisma2 / scripts / updateTag.js View on Github external
async function main() {
  const tag = await getLatestAlphaTag()
  console.log(tag)
  pkg.prisma = pkg.prisma || {}
  pkg.prisma.version = tag
  fs.writeFileSync(path.join(__dirname, '../package.json'), JSON.stringify(pkg, null, 2))
}
github prisma / prisma2 / cli / prisma2 / scripts / updateTag.js View on Github external
async function main() {
  const tag = await getLatestAlphaTag()
  console.log(tag)
  pkg.prisma = pkg.prisma || {}
  pkg.prisma.version = tag
  fs.writeFileSync(path.join(__dirname, '../package.json'), JSON.stringify(pkg, null, 2))
}
github prisma / prisma2 / cli / sdk / src / getGenerators.ts View on Github external
},
      {},
    )

    const downloadParams: DownloadOptions = {
      binaries: binariesConfig,
      binaryTargets: binaryTargets as any[],
      showProgress:
        typeof printDownloadProgress === 'boolean'
          ? printDownloadProgress
          : true,
      version: version || 'latest',
      skipDownload,
    }

    const binaryPathsWithEngineType = await download(downloadParams)
    const binaryPaths = mapKeys(
      binaryPathsWithEngineType,
      binaryTypeToEngineType,
    )

    for (const generator of generators) {
      if (generator.manifest && generator.manifest.requiresEngines) {
        const generatorBinaryPaths = pick(
          binaryPaths,
          generator.manifest.requiresEngines,
        )
        generator.setBinaryPaths(generatorBinaryPaths)
      }
    }

    return generators
github prisma / prisma2 / cli / introspection / src / prompt / utils / useFetch.ts View on Github external
useEffect(() => {
    if (resultCache[url]) {
      setState(resultCache[url])
    } else {
      fetch(url, {
        agent: getProxyAgent(url),
      })
        .then(res => res.json())
        .then(res => {
          const result = transform ? transform(res) : res
          resultCache[url] = result
          setState(result)
        })
    }
  }, [url])

@prisma/fetch-engine

This package is intended for Prisma's internal use

Apache-2.0
Latest version published 13 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages