MCPcopy
hub / github.com/prisma/prisma / parse

Method parse

packages/migrate/src/commands/DbPull.ts:87–308  ·  view source on GitHub ↗
(
    argv: string[],
    config: PrismaConfigInternal,
    baseDir: string = process.cwd(),
  )

Source from the content-addressed store, hash-verified

85`)
86
87 public async parse(
88 argv: string[],
89 config: PrismaConfigInternal,
90 baseDir: string = process.cwd(),
91 ): Promise<string | Error> {
92 const args = arg(argv, {
93 '--help': Boolean,
94 '-h': '--help',
95 '--print': Boolean,
96 '--schema': String,
97 '--config': String,
98 '--schemas': String,
99 '--force': Boolean,
100 '--composite-type-depth': Number, // optional, only on mongodb
101 '--url': String,
102 })
103
104 const spinnerFactory = createSpinner(!args['--print'])
105
106 if (args instanceof Error) {
107 return this.help(args.message)
108 }
109
110 if (args['--help']) {
111 return this.help()
112 }
113
114 const schemaContext = await loadSchemaContext({
115 schemaPath: createSchemaPathInput({
116 schemaPathFromArgs: args['--schema'],
117 schemaPathFromConfig: config.schema,
118 baseDir,
119 }),
120 printLoadMessage: false,
121 allowNull: true,
122 })
123
124 let cmdSpecificConfig = config
125 if (args['--url']) {
126 cmdSpecificConfig = {
127 ...cmdSpecificConfig,
128 datasource: {
129 ...cmdSpecificConfig.datasource,
130 url: args['--url'],
131 },
132 }
133 }
134
135 const cmd = 'db pull'
136 const validatedConfig = validatePrismaConfigWithDatasource({ config: cmdSpecificConfig, cmd })
137
138 checkUnsupportedDataProxy({ cmd, validatedConfig })
139
140 // Print to console if --print is not passed to only have the schema in stdout
141 if (schemaContext && !args['--print']) {
142 printSchemaLoadedMessage(schemaContext.loadedFromPathForLogMessages)
143
144 printDatasource({ datasourceInfo: parseDatasourceInfo(schemaContext?.primaryDatasource, validatedConfig) })

Callers

nothing calls this directly

Calls 15

helpMethod · 0.95
getWarningMessageMethod · 0.95
argFunction · 0.90
createSpinnerFunction · 0.90
loadSchemaContextFunction · 0.90
createSchemaPathInputFunction · 0.90
printSchemaLoadedMessageFunction · 0.90
printDatasourceFunction · 0.90
parseDatasourceInfoFunction · 0.90
getConfigFunction · 0.90

Tested by

no test coverage detected