Skip to main content
Glama

Prisma MCP Server

Official
by prisma
Apache 2.0
4
44,210
  • Linux
  • Apple
SubCommand.vitest.ts3.41 kB
import { rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { defaultTestConfig } from '@prisma/config' import * as execa from 'execa' import { copy } from 'fs-extra' import { afterEach, beforeEach, expect, test, vi } from 'vitest' import { SubCommand } from '../../SubCommand' vi.mock('execa') vi.useFakeTimers().setSystemTime(new Date('2025-01-01')) const getDayMillis = () => new Date().setHours(0, 0, 0, 0) beforeEach(async () => { await rm(join(tmpdir(), `sub-command@0.0.0`), { recursive: true, force: true }) await rm(join(tmpdir(), `sub-command@latest-${getDayMillis()}`), { recursive: true, force: true }) }) afterEach(() => { vi.clearAllMocks() globalThis.Deno = undefined }) test('@<version>', async () => { const cmd = new SubCommand('sub-command') const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {}) const copySrc = join(__dirname, '..', 'fixtures', 'sub-command') const copyDest = join(tmpdir(), `sub-command@0.0.0`) await copy(copySrc, copyDest) await cmd.parse(['@0.0.0', '--help'], defaultTestConfig()) expect(consoleLogSpy.mock.calls).toMatchInlineSnapshot(` [ [ "sub-command", [ [ "--help", ], { "deprecatedPackageJson": null, "loadedFromFile": null, }, { "cliVersion": "0.0.0", }, ], ], ] `) consoleLogSpy.mockRestore() }) test('@latest', async () => { const cmd = new SubCommand('sub-command') const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {}) const copySrc = join(__dirname, '..', 'fixtures', 'sub-command') const copyDest = join(tmpdir(), `sub-command@latest-${getDayMillis()}`) await copy(copySrc, copyDest) await cmd.parse(['--help'], defaultTestConfig()) expect(consoleLogSpy.mock.calls).toMatchInlineSnapshot(` [ [ "sub-command", [ [ "--help", ], { "deprecatedPackageJson": null, "loadedFromFile": null, }, { "cliVersion": "0.0.0", }, ], ], ] `) consoleLogSpy.mockRestore() }) test('autoinstall', async () => { const cmd = new SubCommand('sub-command') const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {}) const copySrc = join(__dirname, '..', 'fixtures', 'sub-command') const copyDest = join(tmpdir(), 'sub-command@0.0.0') vi.mocked(execa.default).mockImplementation((async () => { await copy(copySrc, copyDest) }) as () => any) await cmd.parse(['@0.0.0', '--help'], defaultTestConfig()) expect(consoleLogSpy.mock.calls).toMatchInlineSnapshot(` [ [ "sub-command", [ [ "--help", ], { "deprecatedPackageJson": null, "loadedFromFile": null, }, { "cliVersion": "0.0.0", }, ], ], ] `) expect(execa.default).toHaveBeenCalled() consoleLogSpy.mockRestore() }) test('aborts on deno', async () => { globalThis.Deno = { version: '2.0.0' } // fake being Deno const cmd = new SubCommand('sub-command') await cmd.parse(['@0.0.0', '--help'], defaultTestConfig()) expect(execa.default).not.toHaveBeenCalled() })

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/prisma/prisma'

If you have feedback or need assistance with the MCP directory API, please join our Discord server