Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/omar-dulaimi/prisma-schema-sorter
Prisma 2 tool to sort schema models, enums, generators and datasources
https://github.com/omar-dulaimi/prisma-schema-sorter
cli prisma prisma-schema
Last synced: 29 days ago
JSON representation
Prisma 2 tool to sort schema models, enums, generators and datasources
- Host: GitHub
- URL: https://github.com/omar-dulaimi/prisma-schema-sorter
- Owner: omar-dulaimi
- License: mit
- Created: 2021-10-29T17:26:25.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-11T17:50:42.000Z (8 months ago)
- Last Synced: 2024-11-07T23:42:07.944Z (about 1 month ago)
- Topics: cli, prisma, prisma-schema
- Language: TypeScript
- Homepage:
- Size: 285 KB
- Stars: 23
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-prisma - Prisma Schema Sorter - sort schema models, enums, generators and datasources
README
[![npm version](https://badge.fury.io/js/prisma-schema-sorter.svg)](https://badge.fury.io/js/prisma-schema-sorter)
[![npm](https://img.shields.io/npm/dt/prisma-schema-sorter.svg)](https://www.npmjs.com/package/prisma-schema-sorter)
[![npm](https://img.shields.io/npm/l/prisma-schema-sorter.svg)](LICENSE)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)# Prisma Schema Sorter
Prisma 2 tool to sort schema models, enums, generators and datasources
> Full docs can be found here: [docs](https://omar-dulaimi.github.io/prisma-schema-sorter/index.html)
## Table of Contents
- [Installation](#installing)
- [Usage](#usage)
- [Using the CLI](#using-the-cli)
- [Programmatically](#programmatically)
- [ES Module](#es-module)
- [CommonJS](#commonjs)## Installation
Using npm:
```bash
$ npm install prisma-schema-sorter
```Using yarn:
```bash
$ yarn add prisma-schema-sorter
```# Usage
You can use the library in multiple ways as described below.
## 1- Using the CLI:
With the CLI, you get the same functionality but with greater flexibility. You could run the command as a one-off every now and then from the terminal like this:
```bash
$ npx prisma-schema-sorter sort --schema="./prisma/schema.prisma"
```You could also keep the command as an npm script to run it as part of your workflow:
```js
{
"scripts": {
"sort-schema": "npx prisma-schema-sorter sort --schema='./prisma/schema.prisma'"
}
}
```Or even without the `npx` prefix:
```js
{
"scripts": {
"sort-schema": "prisma-schema-sorter sort --schema='./prisma/schema.prisma'"
}
}
```## 2- Programmatically:
### ES Module
```ts
import { sortPrismaSchema } from 'prisma-schema-sorter';
await sortPrismaSchema('./prisma/schema.prisma');
// => Success
```### CommonJS
```js
var sortPrismaSchema = require('prisma-schema-sorter').sortPrismaSchema;
sortPrismaSchema('./prisma/schema.prisma').then();
// => Success
```