(argv: string[], config: PrismaConfigInternal, baseDir: string)
| 62 | `) |
| 63 | |
| 64 | public async parse(argv: string[], config: PrismaConfigInternal, baseDir: string): Promise<string | Error> { |
| 65 | const args = arg(argv, { |
| 66 | '--help': Boolean, |
| 67 | '-h': '--help', |
| 68 | '--preview-feature': Boolean, |
| 69 | '--force': Boolean, |
| 70 | '-f': '--force', |
| 71 | '--schema': String, |
| 72 | '--config': String, |
| 73 | '--telemetry-information': String, |
| 74 | }) |
| 75 | |
| 76 | if (isError(args)) { |
| 77 | return this.help(args.message) |
| 78 | } |
| 79 | |
| 80 | if (args['--help']) { |
| 81 | return this.help() |
| 82 | } |
| 83 | |
| 84 | if (!args['--preview-feature']) { |
| 85 | throw new PreviewFlagError() |
| 86 | } |
| 87 | |
| 88 | const schemaContext = await loadSchemaContext({ |
| 89 | schemaPath: createSchemaPathInput({ |
| 90 | schemaPathFromArgs: args['--schema'], |
| 91 | schemaPathFromConfig: config.schema, |
| 92 | baseDir, |
| 93 | }), |
| 94 | }) |
| 95 | |
| 96 | const cmd = 'db drop' |
| 97 | const validatedConfig = validatePrismaConfigWithDatasource({ config, cmd }) |
| 98 | |
| 99 | checkUnsupportedDataProxy({ cmd, validatedConfig }) |
| 100 | |
| 101 | const datasourceInfo = parseDatasourceInfo(schemaContext.primaryDatasource, validatedConfig) |
| 102 | printDatasource({ datasourceInfo }) |
| 103 | |
| 104 | process.stdout.write('\n') // empty line |
| 105 | |
| 106 | if (!args['--force']) { |
| 107 | if (!canPrompt()) { |
| 108 | throw new DbDropNeedsForceError('drop') |
| 109 | } |
| 110 | |
| 111 | const confirmation = await prompt({ |
| 112 | type: 'text', |
| 113 | name: 'value', |
| 114 | message: `Enter the ${datasourceInfo.prettyProvider} database name "${ |
| 115 | datasourceInfo.dbName |
| 116 | }" to drop it.\nLocation: "${datasourceInfo.dbLocation}".\n${red('All data will be lost')}.`, |
| 117 | }) |
| 118 | process.stdout.write('\n') // empty line |
| 119 | |
| 120 | if (!confirmation.value) { |
| 121 | process.stdout.write('Drop cancelled.\n') |
nothing calls this directly
no test coverage detected