Skip to content

omar-dulaimi/prisma-schema-sorter

Repository files navigation

Prisma Schema Sorter

npm version npm npm Node.js Version

A modern tool to sort Prisma schema elements alphabetically - models, enums, generators, and datasources. Keep your schema organized and maintainable.

✨ Features

  • 🔄 Sorts all schema elements: Models, enums, generators, and datasources
  • 🛠️ CLI and programmatic usage: Use it however fits your workflow
  • 📦 Zero configuration: Works out of the box
  • 🚀 Fast and lightweight: Built with performance in mind
  • 🔧 TypeScript support: Fully typed for better development experience

📖 Full documentation

📦 Installation

npm install prisma-schema-sorter
yarn add prisma-schema-sorter
pnpm add prisma-schema-sorter

🚀 Usage

CLI Usage

Run as a one-time command:

npx prisma-schema-sorter sort --schema="./prisma/schema.prisma"

Add to your package.json scripts:

{
  "scripts": {
    "sort-schema": "prisma-schema-sorter sort --schema='./prisma/schema.prisma'"
  }
}

Then run with:

npm run sort-schema

Programmatic Usage

ES Modules / TypeScript

import { sortPrismaSchema } from 'prisma-schema-sorter';

await sortPrismaSchema('./prisma/schema.prisma');
// => Success

CommonJS

const { sortPrismaSchema } = require('prisma-schema-sorter');

sortPrismaSchema('./prisma/schema.prisma').then(() => {
  console.log('Schema sorted successfully!');
});

🤝 Contributing

Contributions, issues and feature requests are welcome!

📝 License

This project is MIT licensed.

About

Prisma 2 tool to sort schema models, enums, generators and datasources

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •