MCPcopy
hub / github.com/prisma/prisma / main

Function main

packages/cli/src/utils/test-handlePanic.ts:5–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import path from 'path'
4
5async function main() {
6 const packageJsonVersion = '0.0.0'
7 const enginesVersion = 'prismaEngineVersionHash'
8 const command = 'something-test'
9
10 try {
11 const dirPath = path.join(__dirname, '..', '__tests__', 'fixtures', 'introspection', 'postgresql')
12
13 process.chdir(dirPath)
14
15 const schemaContext = await loadSchemaContext({
16 schemaPath: { cliProvidedPath: path.join(dirPath, 'schema.prisma') },
17 })
18 const { viewsDirPath } = inferDirectoryConfig(schemaContext)
19
20 const config = require(path.join(dirPath, 'prisma.config.ts'))
21
22 const migrate = await Migrate.setup({ schemaContext, schemaEngineConfig: config, baseDir: dirPath })
23 const engine = migrate.engine
24
25 await engine.introspect({
26 schema: toSchemasContainer(schemaContext.schemaFiles),
27 viewsDirectoryPath: viewsDirPath,
28 baseDirectoryPath: dirPath,
29 force: false,
30 })
31 await engine.debugPanic()
32 } catch (err) {
33 console.debug({ err })
34
35 const getDatabaseVersionSafe = () => Promise.resolve(undefined)
36 handlePanic({
37 error: err,
38 cliVersion: packageJsonVersion,
39 enginesVersion,
40 command,
41 getDatabaseVersionSafe,
42 })
43 .catch((e) => {
44 console.error('Error: ' + e.stack)
45 console.error('Error: ' + e.message)
46 })
47 .finally(() => {
48 process.exit(1)
49 })
50 }
51}
52
53main().catch((e) => {
54 console.error(e)

Callers 1

Calls 11

loadSchemaContextFunction · 0.90
inferDirectoryConfigFunction · 0.90
toSchemasContainerFunction · 0.90
handlePanicFunction · 0.90
finallyMethod · 0.80
catchMethod · 0.80
errorMethod · 0.80
introspectMethod · 0.65
debugPanicMethod · 0.65
setupMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected