Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async parse(argv: string[], minimalOutput = false): Promise {
const datamodelPath = await getSchemaPath()
if (!datamodelPath) {
throw new Error(`Can't find schema.prisma`) // TODO: Add this into a central place in getSchemaPath() as an arg
}
const generators = await getGenerators({
schemaPath: datamodelPath,
providerAliases: this.aliases,
printDownloadProgress: true,
version: pkg.prisma.version,
})
if (generators.length === 0) {
console.log(missingGeneratorMessage)
}
// CONTINUE HERE
export async function getCredentialsFromExistingDatamodel(): Promise {
const schemaPath = await getSchemaPath()
if (schemaPath) {
const datamodel = readFileSync(schemaPath, 'utf-8')
const { datasources } = await getConfig({ datamodel })
// For now just take the first data source
if (datasources && datasources.length > 1) {
console.error(
`There are more than 1 datasources listed in the datamodel ${datasources.map(d => d.name).join(', ')}, taking ${
datasources[0].name
}`,
)
}
if (datasources && datasources.length > 0) {
const uri = datasources[0].url.value
return uriToCredentials(uri)
}
}
const log = (...messages) => {
if (!args['--print']) {
console.log(...messages)
}
}
if (args instanceof Error) {
return this.help(args.message)
}
if (args['--help']) {
return this.help()
}
let url: string | undefined = args['--url']
let schemaPath = await getSchemaPath()
let config: ConfigMetaFormat | undefined
if (!url) {
if (!schemaPath) {
throw new Error(
`Either provide ${chalk.greenBright(
'--url',
)} or make sure that you are in a folder with a ${chalk.greenBright('schema.prisma')} file.`,
)
}
config = await getConfig({
datamodelPath: schemaPath,
})
const datasource = config.datasources[0]
if (!datasource) {