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])
}
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));
},
{},
)
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