0.1.3 • Published 4 months ago

prismalux v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Prismalux šŸŒ“ - A Zero-Dependency Prisma Schema Highlighter

npm version License: MIT

✨ Prismalux is a lightweight, zero-dependency CLI tool & library for highlighting Prisma schema files in the terminal.

šŸ” You can also highlight a specific model or enum using the --filter= option.

Just run it with npx:

npx prismalux

šŸš€ Features

āœ” Zero dependencies - No extra packages required
āœ” Syntax highlighting for Prisma schema files
āœ” Works as CLI & library (use as prismalux [path] or import in code)
āœ” Filter a specific model or enum using --filter=User āœ” ESM & CommonJS support


šŸ“ø Preview

Prismalux Syntax Highlighting


šŸ“¦ Get Started

If you just want to run Prismalux without installing it, simply use:

npx prismalux

This will automatically find the Prisma schema in the current directory (e.g., prisma/schema.prisma).
If your schema is located elsewhere, specify the path manually:

npx prismalux --path=./path/to/schema.prisma

šŸ” Highlight a Specific Model or Enum

If you only want to highlight a specific model or enum, use the --filter= option:

prismalux --filter=User

Or multiple models/enums:

Use "," or "|" to separate multiple models/enums:

prismalux --filter="User|Role"
prismalux --filter=User,Role

This will only display:

model User {
  id        String   @id @default(cuid())
  email     String   @unique
  role      Role
  createdAt DateTime @default(now())
}

You can also combine it with a custom schema path:

prismalux --path=./custom/schema.prisma --filter=Post

šŸ“¦ Installation

Global Installation (CLI)

If you want to use Prismalux as a command-line tool:

npm install -g prismalux

Now you can run:

prismalux

Or specify a custom path:

prismalux --path=./path/to/schema.prisma

šŸŽ® Usage

1ļøāƒ£ CLI Mode

# Display help
prismalux --help

# Show version
prismalux --version

# Highlight Prisma schema (auto-detects "prisma/schema.prisma")
prismalux

# Highlight a specific file
prismalux --path=./custom/schema.prisma

# Highlight a specific model or enum
prismalux --filter=User

2ļøāƒ£ Import in Code

šŸ“¦ ESM (ES Modules)

import { PrismaHighlighter } from "prismalux";
const highlighter = new PrismaHighlighter();

const schema = `
model User {
  id        String   @id @default(cuid())
  email     String   @unique
  role      Role
  createdAt DateTime @default(now())
}
`;

console.log(highlighter.highlight(schema));

šŸ“¦ CommonJS (CJS)

Similar to ESM

import { PrismaHighlighter } from "prismalux"; // or require("prismalux")
const highlighter = new PrismaHighlighter();

šŸ”§ Configuration

Prismalux allows you to customize colors and disable highlighting if needed.

const highlighter = new PrismaHighlighter({
  enableColors: true,
  colors: {
    yellow: "\x1b[38;5;220m", // Custom yellow
    orange: "\x1b[38;5;214m", // Custom orange
  },
});

console.log(highlighter.highlight(schema));

To disable colors (useful for logs):

const plainHighlighter = new PrismaHighlighter({ enableColors: false });
console.log(plainHighlighter.highlight(schema));

šŸ“œ License

MIT License Ā© Artyom Gorlovetskiy