Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/oliwierptak/prisma-generator-builder

Creates ready to run latest prisma generator. Together with pre-configured packages, and pluggable architecture, it creates project ready for prisma generator development.
https://github.com/oliwierptak/prisma-generator-builder

generator prisma-generator prisma-orm prisma4 typescript

Last synced: 2 days ago
JSON representation

Creates ready to run latest prisma generator. Together with pre-configured packages, and pluggable architecture, it creates project ready for prisma generator development.

Awesome Lists containing this project

README

        

# prisma-generator-builder

Creates ready to run latest `prisma generator`.

Together with pre-configured packages, and pluggable architecture,
it creates project ready for prisma generator development.

### Preconfigured packages

- typescript
- prisma
- eslint
- prettier
- jest

### Pluggable architecture

Read more about [plugins here](README_PLUGINS.md).

## Installation

Install as dev dependency:

```
npm install prisma-generator-builder -D
```

## Usage

Run the builder to get started.

```
npx prisma-generator-builder
```

Switch to the output directory and run

```
npm install
npx prisma generate
```

That's it.

## Requirements

Prisma ORM `version 5.x.x`.

## Custom Builder Development

### Project structure

```

└──src
├── bin.ts
└── generator
├── helper
├ ├── helper.file-writer.test.ts
├ ├── helper.file-writer.ts
├ ├── helper.hello-world.test.ts
├ ├── helper.hello-world.ts
└── builder.ts
├── package.json
...
└── README.md
```

### Helpers

#### HelloWorld Helper

The generator uses very basic `HelloWorld` helper example.
However, thanks to this separation, prisma and custom generator
logic are not mixed together.

To see the example check [builder.ts](src/generator/generator.ts).

#### FileWriter Helper

Handles file writing.

`saveFile()` - saves any file
```typescript
FileWriter.saveFile("foo.txt", `foo`);
```

`saveTypescriptFile()` - saves and formats typescript file

```typescript
FileWriter.saveTypescriptFile("foo.ts", `const foo="foo"; console.log(foo);`);
```

### Tests

Generated package comes together with pre-configured `jest`.

`npx jest`