https://github.com/jednano/prisma2-sdl
Parses a subset of the Prisma 2 schema definition language
https://github.com/jednano/prisma2-sdl
ast parser pretty-print prisma prisma2 schema sdl typesc
Last synced: 3 months ago
JSON representation
Parses a subset of the Prisma 2 schema definition language
- Host: GitHub
- URL: https://github.com/jednano/prisma2-sdl
- Owner: jednano
- License: mit
- Created: 2019-10-16T23:47:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T12:29:29.000Z (over 2 years ago)
- Last Synced: 2025-03-15T08:48:45.032Z (4 months ago)
- Topics: ast, parser, pretty-print, prisma, prisma2, schema, sdl, typesc
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@jedmao/prisma2-sdl
- Size: 410 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- Contributing: contributing.md
- License: license
Awesome Lists containing this project
README
# @jedmao/prisma2-sdl
[](https://github.com/jedmao/prisma2-sdl/actions)
[](https://codecov.io/gh/jedmao/prisma2-sdl)
[](http://commitizen.github.io/cz-cli/)
[](https://github.com/xojs/xo)
[](https://github.com/prettier/prettier)
[](https://typescriptlang.org)Parses a subset of the
[Prisma2 Schema Language (PSL)](https://github.com/prisma/specs/tree/master/schema).## Installation
```sh
npm install @jedmao/prisma2-sdl
```## Usage
```ts
import { parse, prettify } from '@jedmao/prisma2-sdl'
import { readFileSync } from 'fs'const ast = parse(readFileSync('schema.prisma'))
console.log(prettify(ast))
```## Limitations
This library only parses a subset of the
[Prisma2 Schema Language (PSL)](https://github.com/prisma/specs/tree/master/schema).```prisma
model User {
id Int @id
name String
email String
age Int?
posts Post[]
}model Post {
id Int @id
title String
content String
author User
}
```## Scripts
The following [npm scripts](https://docs.npmjs.com/misc/scripts) are made
available to you in the project root. You can run each of them with
`npm run `.### build
Runs the [TypeScript][] compiler.
### test
Runs [AVA][] in
[watch mode](https://github.com/avajs/ava/blob/master/docs/recipes/watch-mode.md),
which attempts to run only on changed files.### cover
Runs [AVA][] with
[coverage](https://github.com/avajs/ava/blob/master/docs/recipes/code-coverage.md),
dumping coverage results in `./coverage` and showing a text summary in the
console output.### commit
Runs [Commitizen](http://commitizen.github.io/cz-cli/) commit wizard, ensuring
that your commit messages conform to
[Conventional Commits](https://www.conventionalcommits.org/).### Tips
Use the [`git commit`](https://git-scm.com/docs/git-commit) command directly
with the
[`-n`, `--no-verify` option](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--n)
to bypasses the pre-commit and commit-msg hooks.[ava]: https://github.com/avajs/ava
[typescript]: http://www.typescriptlang.org/