1.0.8 • Published 13 days ago

ysf-gen v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
13 days ago

Forks Stargazers Issues MIT License LinkedIn

About The Project

YSF Generator CLI is a powerful command-line tool that helps you quickly generate server and client entities for your projects. It supports initializing new projects, creating CRUD structures, and more to streamline your development process.

Built With

  • Nodejs
  • Postgresql

Tech Stack

Frontend:

  • Next
  • Tailwind
  • Shadcn

Backend:

  • Nodejs
  • Expressjs
  • Mysql
  • Postgresql

YSF Generator CLI supports initializing projects and creating CRUD structures. Below are examples of the key commands.

Initialize a Project

Use the init command to initialize a new project:

ysf-gen init <type> <projectName>

Example

ysf-gen init fullstack fullstack-project-name

Available types:

  • server
  • client
  • fullstack

Create an Entity

Use the create command to generate CRUD structures for an entity:

ysf-gen create <type>:[options]

Example

ysf-gen create fullstack:posts

PS: You have to make the model first on the prisma.schema, then use "pnpm migrate" to migrate db with prisma

Options:

--include relatedEntities: Include related entities in the CRUD structure. --protected rolesRoutes: Protect routes with roles in the format role=route1,route2,.... --search field: Add a search field (for client and fullstack types).

Commands

init

Initialize a new project.

: Type of project (server, client, fullstack). : Name of the project.

create

Create a CRUD structure for an entity.

: Type of entity (server:, client:, fullstack:). --include: Include related entities. --protected: Protect routes with roles. --search: Add search field for quick filtering.

Utilities

YSF Generator CLI provides utilities for interacting with your Prisma schema and project configuration.

generateEntityCrud

Generate CRUD operations for a given entity.

initializeProject

Initialize a new project with the specified type and name.

cli/protectedRoutes

Configure protection for routes based on user roles.

getRolesFromDb

Fetch user roles from the Prisma schema.

getEntityRelations

Fetch entity relationships from the schema.

generateClientEntity

Generate client-side code for a specified entity.

getEntityFields

Fetch fields from the schema for an entity.

updateConfig

Update the configuration file with new entity information.

Prisma Schema Template

This section covers the Prisma schema template for the YSF Generator CLI, including models, enums, and rules.

Models

  • users: Main user entity.
  • local_users: Represents users authenticating locally.
  • oauth_users: Represents users authenticating via OAuth.
  • user_details: Additional user details.
  • user_preferences: User preferences.
  • addresses: User addresses.
  • email_verifies: Email verification records.
  • images: Image management.

Enums

  • Role: User roles.
  • Gender: Gender options.
  • OAuthProvider: OAuth providers.

Rules for Using ysf-gen with Prisma

  • Image Integration: Link models representing images with the images model.
  • Plural Model Names: Keep model names plural for consistency.
  • Naming Conventions: Use camelCase for fields and models.
  • Unique Identifiers: Ensure each model has a unique identifier.
  • Relationships: Use @relation to define relationships.
  • Indexes: Apply indexes for frequently searched fields.
  • Default Values: Use @default for fields where applicable.
  • Enum Usage: Use enums for fields with predefined values.
  • Optional Fields: Use ? for optional fields.
  • Cascade Deletion: Use onDelete: Cascade for related child records.

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Fikri Nurdiansyah

gmail tele linkedin

Project Link: https://github.com/Fnz11/ysf-gen

PS: This README includes comprehensive details for the YSF Generator CLI, using a clean structure similar to your example. Let me know if you'd like to refine any sections!