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

Function main

packages/client/tests/e2e/_utils/run.ts:35–202  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33)
34
35async function main() {
36 if (args instanceof Error) {
37 console.log(args.message)
38 process.exit(1)
39 }
40
41 args['--maxWorkers'] = args['--maxWorkers'] ?? os.cpus().length
42 args['--runInBand'] = args['--runInBand'] ?? false
43 args['--skipPack'] = args['--skipPack'] ?? false
44 args['--verbose'] = args['--verbose'] ?? false
45 args['--clean'] = args['--clean'] ?? false
46 $.verbose = args['--verbose']
47
48 if (args['--verbose'] === true) {
49 await $`docker -v`
50 }
51
52 console.log('🧹 Cleaning up old files')
53 if (args['--clean'] === true) {
54 await $`docker compose -f ${__dirname}/docker-compose-clean.yml down --remove-orphans`
55 await $`docker compose -f ${__dirname}/docker-compose-clean.yml up clean`
56 }
57
58 console.log('🎠 Preparing e2e tests')
59
60 let allPackageFolderNames = await fs.readdir(path.join(monorepoRoot, 'packages'))
61 allPackageFolderNames = allPackageFolderNames.filter((p) => !p.includes('DS_Store'))
62
63 const prismaTmpDir = path.join(os.homedir(), '.local', 'share', 'prisma-tmp')
64
65 if (args['--skipPack'] === false) {
66 // this process will need to modify some package.json, we save copies
67 await $`pnpm -r exec cp package.json package.copy.json`
68
69 // we prepare to replace references to local packages with their tarballs names
70 const localPackageNames = [...allPackageFolderNames.map((p) => `@prisma/${p}`), 'prisma']
71 const allPackageFolders = allPackageFolderNames.map((p) => path.join(monorepoRoot, 'packages', p))
72 const allPkgJsonPaths = allPackageFolders.map((p) => path.join(p, 'package.json'))
73 const allPkgJson = allPkgJsonPaths.map((p) => require(p))
74
75 // replace references to unbundled local packages with built and packaged tarballs
76 for (let i = 0; i < allPkgJson.length; i++) {
77 for (const key of Object.keys(allPkgJson[i].dependencies ?? {})) {
78 if (localPackageNames.includes(key)) {
79 allPkgJson[i].dependencies[key] = `/tmp/${key.replace('@prisma/', 'prisma-')}-0.0.0.tgz`
80 }
81 }
82
83 await fs.writeFile(allPkgJsonPaths[i], JSON.stringify(allPkgJson[i], null, 2))
84 }
85
86 await $`pnpm -r --parallel exec pnpm pack --pack-destination ${prismaTmpDir}/`
87 await restoreOriginalState()
88 }
89
90 console.log('🐳 Starting tests in docker')
91 // tarball was created, ready to send it to docker and begin e2e tests
92 const testStepFiles = await glob(['../**/_steps.ts', '../**/_steps.cts'], { cwd: __dirname })

Callers 1

run.tsFile · 0.70

Calls 12

acquireMethod · 0.95
releaseMethod · 0.95
existsSyncFunction · 0.90
$Class · 0.85
restoreOriginalStateFunction · 0.85
isFileFunction · 0.85
printFileFunction · 0.85
logMethod · 0.80
includesMethod · 0.80
entriesMethod · 0.80
finallyMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected