Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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])
}
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
}
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)
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));
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))
}
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))
}
},
{},
)
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
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])