(argv: string[], config: PrismaConfigInternal, baseDir: string = process.cwd())
| 28 | ) {} |
| 29 | |
| 30 | async parse(argv: string[], config: PrismaConfigInternal, baseDir: string = process.cwd()): Promise<string | Error> { |
| 31 | const args = arg(argv, { |
| 32 | '--help': Boolean, |
| 33 | '-h': '--help', |
| 34 | '--version': Boolean, |
| 35 | '-v': '--version', |
| 36 | '--config': String, |
| 37 | '--json': Boolean, // for -v |
| 38 | '--experimental': Boolean, |
| 39 | '--preview-feature': Boolean, |
| 40 | '--early-access': Boolean, |
| 41 | '--telemetry-information': String, |
| 42 | }) |
| 43 | |
| 44 | if (isError(args)) { |
| 45 | return this.help(args.message) |
| 46 | } |
| 47 | |
| 48 | // display help for help flag or no subcommand |
| 49 | if (!args['--version'] && (args._.length === 0 || args['--help'])) { |
| 50 | return this.help() |
| 51 | } |
| 52 | |
| 53 | if (args['--version']) { |
| 54 | await ensureNeededBinariesExist({ |
| 55 | download: this.download, |
| 56 | }) |
| 57 | return Version.new().parse(argv, config, baseDir) |
| 58 | } |
| 59 | |
| 60 | // check if we have that subcommand |
| 61 | const cmdName = args._[0] |
| 62 | // Throw if "lift" |
| 63 | if (cmdName === 'lift') { |
| 64 | throw new Error(`${red('prisma lift')} has been renamed to ${green('prisma migrate')}`) |
| 65 | } |
| 66 | |
| 67 | const cmd = this.cmds[cmdName] |
| 68 | if (cmd) { |
| 69 | // Only track if the command actually exists |
| 70 | const checkResultPromise = runCheckpointClientCheck({ schemaPathFromConfig: config.schema, baseDir }).catch( |
| 71 | () => { |
| 72 | /* noop */ |
| 73 | }, |
| 74 | ) |
| 75 | |
| 76 | // if we have that subcommand, let's ensure that the binary is there in case the command needs it |
| 77 | if (this.ensureBinaries.includes(cmdName)) { |
| 78 | await ensureNeededBinariesExist({ |
| 79 | download: this.download, |
| 80 | }) |
| 81 | } |
| 82 | |
| 83 | let argsForCmd: string[] |
| 84 | if (args['--experimental']) { |
| 85 | argsForCmd = [...args._.slice(1), `--experimental=${args['--experimental']}`] |
| 86 | } else if (args['--preview-feature']) { |
| 87 | argsForCmd = [...args._.slice(1), `--preview-feature=${args['--preview-feature']}`] |
nothing calls this directly
no test coverage detected