How to use the @prisma/cli.getSchemaPath function in @prisma/cli

To help you get started, weโ€™ve selected a few @prisma/cli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prisma / prisma2 / cli / prisma2 / src / Generate.ts View on Github external
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
github prisma / prisma2 / cli / introspection / src / introspectionConnector.ts View on Github external
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)
    }
  }
github prisma / prisma2 / cli / introspection / src / commands / Introspect.ts View on Github external
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) {

@prisma/cli

Prisma is an open-source database toolkit. It includes a JavaScript/TypeScript ORM for Node.js, migrations and a modern GUI to view and edit the data in your database. You can use Prisma in new projects or add it to an existing one.

Apache-2.0
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis