Skip to content

A command-line tool for generating NestJS code form schema.prisma file.

License

Notifications You must be signed in to change notification settings

gylove1994/nestjs-prisma-generator

Repository files navigation

NestJS Prisma Generator

NPM Version

中文文档

Project Overview

NestJS Prisma Generator is a command-line tool for generating NestJS and Prisma code.

Features

  • Automatically generate Entity code, synchronized with Prisma models
  • Generate Enum code to ensure type safety
  • Create complete Module structures, including controllers, services, and DTOs
  • Support generating all types of code to meet different development needs
  • Generate code structures that comply with my own best practices(This is an opinionated tool
  • Support custom templates for flexible adaptation to project requirements (TBD)

Installation

npm install @gylove1994/npg -g

Usage

Generating Code

You can use the following command to generate code:

npg

Follow the prompts to select the type of code you want to generate, the path to your Prisma schema file, and the output directory.

Command Line Options

wip

Project Structure

  • src/index.ts - Main entry file, defines the core logic of the command-line tool
  • src/generateEntity.ts - Module responsible for generating entity code
  • src/generateEnum.ts - Handles the logic for generating enum code
  • src/generateNestModule.ts - Core code for generating NestJS module structures
  • src/generateNestController.ts - Module for creating controller code
  • src/generateNestDto.ts - Logic for generating Data Transfer Objects (DTOs)
  • src/utils - Utility functions, including file operations, type mapping, etc.

Development

Local Development

npm run dev

Build

npm run build

Code Linting

npm run lint

License

MIT

Author

gylove1994

Contribution Guidelines

We welcome and appreciate any form of contribution! If you want to contribute to the project, please follow these steps:

  1. Fork this repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request