@matserdam/prisma-neighborhood 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +43 -95
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,80 +1,75 @@
1
- # prisma-subgraph-cli
1
+ # prisma-neighbourhood
2
2
 
3
- CLI tool that generates Entity-Relationship Diagrams from Prisma schemas, starting from a specified model and traversing relationships to a configurable depth.
3
+ Generate focused ERD diagrams from a Prisma schema by starting from one model and traversing relationships up to a configurable depth.
4
4
 
5
- ## Installation
5
+ The npm package is **`@matserdam/prisma-neighborhood`** and it exposes two CLI commands:
6
+
7
+ - **`prisma-hood`** (short alias)
8
+ - **`prisma-neighborhood`** (full name)
9
+
10
+ ## Run with Bun (recommended)
6
11
 
7
12
  ```bash
8
- bun install
13
+ # Mermaid ERD to stdout
14
+ bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User
9
15
  ```
10
16
 
11
- ## Usage
17
+ ## Common examples
12
18
 
13
19
  ```bash
14
- # Basic usage - generate ERD starting from User model (stdout)
15
- bun src/index.ts -s ./prisma/schema.prisma -m User
20
+ # Limit to direct relationships only (depth 1)
21
+ bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -d 1
16
22
 
17
- # With custom depth (default is 3)
18
- bun src/index.ts -s ./prisma/schema.prisma -m User -d 5
19
-
20
- # Output to Mermaid file
21
- bun src/index.ts -s ./prisma/schema.prisma -m User -o diagram.mmd
23
+ # Write Mermaid to a file (use .mmd or .md)
24
+ bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -o erd.mmd
22
25
 
23
26
  # Export to PNG
24
- bun src/index.ts -s ./prisma/schema.prisma -m User -o diagram.png
27
+ bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -o erd.png
25
28
 
26
29
  # Export to PDF
27
- bun src/index.ts -s ./prisma/schema.prisma -m User -o diagram.pdf
30
+ bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -o erd.pdf
31
+
32
+ # List renderers (and see which ones support PNG/PDF export)
33
+ bunx @matserdam/prisma-neighborhood --list-renderers
34
+ ```
35
+
36
+ ## Install globally (optional)
28
37
 
29
- # List available renderers
30
- bun src/index.ts --list-renderers
38
+ ```bash
39
+ npm install -g @matserdam/prisma-neighborhood
31
40
 
32
- # Show help
33
- bun src/index.ts --help
41
+ # Then you can run:
42
+ prisma-hood -s ./prisma/schema.prisma -m User
34
43
  ```
35
44
 
36
- ## Options
45
+ ## CLI options
37
46
 
38
47
  | Option | Alias | Description | Default |
39
48
  |--------|-------|-------------|---------|
40
- | `--schema <path>` | `-s` | Path to the Prisma schema file | (required) |
41
- | `--model <name>` | `-m` | Name of the model to start traversal from | (required) |
42
- | `--depth <n>` | `-d` | Traversal depth | 3 |
43
- | `--renderer <name>` | `-r` | Diagram renderer | mermaid |
44
- | `--output <file>` | `-o` | Output file (stdout if omitted) | - |
45
- | `--list-renderers` | - | Show available renderers | - |
46
- | `--help` | `-h` | Display help | - |
47
- | `--version` | `-V` | Output version | - |
49
+ | `--schema <path>` | `-s` | Path to the Prisma schema file | required |
50
+ | `--model <name>` | `-m` | Model to start traversal from | required |
51
+ | `--depth <n>` | `-d` | Relationship levels to traverse | `3` |
52
+ | `--renderer <name>` | `-r` | Renderer to use | `mermaid` |
53
+ | `--output <file>` | `-o` | Write to a file instead of stdout | stdout |
54
+ | `--list-renderers` | | Show available renderers | |
55
+ | `--help` | `-h` | Show help | |
56
+ | `--version` | `-V` | Show version | |
48
57
 
49
- ### Output Formats
58
+ ## Output formats
50
59
 
51
60
  The output format is determined by the file extension:
52
61
 
53
- | Extension | Format |
62
+ | Extension | Output |
54
63
  |-----------|--------|
55
- | `.mmd` | Mermaid text |
56
- | `.md` | Mermaid text |
64
+ | `.mmd` / `.md` | Mermaid ERD text |
57
65
  | `.png` | PNG image |
58
- | `.pdf` | PDF document |
59
-
60
- ### PNG/PDF Export Requirements
66
+ | `.pdf` | PDF |
61
67
 
62
- PNG and PDF export uses `@mermaid-js/mermaid-cli` which relies on Puppeteer (headless Chromium).
68
+ ## PNG/PDF on Linux
63
69
 
64
- #### Platform Compatibility
65
-
66
- | Platform | Status | Notes |
67
- |----------|--------|-------|
68
- | macOS | Works out of the box | No additional setup needed |
69
- | Windows | Works out of the box | No additional setup needed |
70
- | Linux | Requires dependencies | See below |
71
-
72
- #### Linux Dependencies
73
-
74
- On Linux, Puppeteer requires additional system libraries:
70
+ PNG/PDF export uses headless Chromium. On Debian/Ubuntu, install:
75
71
 
76
72
  ```bash
77
- # Debian/Ubuntu
78
73
  sudo apt-get install -y \
79
74
  libnss3 \
80
75
  libatk1.0-0 \
@@ -89,53 +84,6 @@ sudo apt-get install -y \
89
84
  libasound2 \
90
85
  libpangocairo-1.0-0 \
91
86
  libgtk-3-0
92
-
93
- # Alpine (Docker)
94
- apk add chromium
95
87
  ```
96
88
 
97
- #### CI/CD Environments
98
-
99
- For CI pipelines, either:
100
- - Install the dependencies listed above
101
- - Use a Docker image with Chromium pre-installed (e.g., `node:18-bullseye`)
102
-
103
- #### Alternative: Text-only Mode
104
-
105
- If PNG/PDF export is problematic, you can:
106
- 1. Output to `.mmd` file and use an online renderer like [mermaid.live](https://mermaid.live)
107
- 2. Use VS Code with a Mermaid preview extension
108
- 3. Embed the Mermaid syntax directly in Markdown documentation
109
-
110
- ## Example Output
111
-
112
- Given a Prisma schema with User, Post, and Profile models:
113
-
114
- ```mermaid
115
- erDiagram
116
- User {
117
- Int id PK
118
- String email UK
119
- String name
120
- DateTime createdAt
121
- }
122
- Post {
123
- Int id PK
124
- String title
125
- String content
126
- Boolean published
127
- Int authorId
128
- DateTime createdAt
129
- }
130
- Profile {
131
- Int id PK
132
- String bio
133
- Int userId UK
134
- }
135
- User ||--o{ Post : "posts"
136
- User ||--|| Profile : "profile"
137
- ```
138
-
139
- ## License
140
-
141
- MIT
89
+ If that’s a hassle, output `.mmd` and render it elsewhere (e.g. VS Code Mermaid preview).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matserdam/prisma-neighborhood",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "CLI tool that generates ERD diagrams from Prisma schemas with configurable depth traversal",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",