@famgia/omnify-cli 0.0.4 → 0.0.6
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.
- package/README.md +261 -23
- package/dist/cli.js +916 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +447 -278
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +144 -1
- package/dist/index.d.ts +144 -1
- package/dist/index.js +447 -277
- package/dist/index.js.map +1 -1
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -5,67 +5,305 @@ CLI tool for the Omnify schema system. Generate Laravel migrations and TypeScrip
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
+
# Global installation
|
|
8
9
|
npm install -g @famgia/omnify-cli
|
|
9
|
-
|
|
10
|
-
npx
|
|
10
|
+
|
|
11
|
+
# Or use with npx
|
|
12
|
+
npx @famgia/omnify-cli <command>
|
|
13
|
+
|
|
14
|
+
# Or install in project
|
|
15
|
+
npm install @famgia/omnify-cli @famgia/omnify-laravel
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# 1. Initialize project
|
|
22
|
+
npx omnify init
|
|
23
|
+
|
|
24
|
+
# 2. Edit omnify.config.ts to set your database URL
|
|
25
|
+
|
|
26
|
+
# 3. Define schemas in schemas/ directory
|
|
27
|
+
|
|
28
|
+
# 4. Validate and generate
|
|
29
|
+
npx omnify validate
|
|
30
|
+
npx omnify generate
|
|
11
31
|
```
|
|
12
32
|
|
|
13
33
|
## Commands
|
|
14
34
|
|
|
15
|
-
###
|
|
35
|
+
### `omnify init`
|
|
36
|
+
|
|
37
|
+
Initialize a new Omnify project.
|
|
16
38
|
|
|
17
39
|
```bash
|
|
18
|
-
omnify init
|
|
40
|
+
omnify init [options]
|
|
41
|
+
|
|
42
|
+
Options:
|
|
43
|
+
-f, --force Overwrite existing files
|
|
19
44
|
```
|
|
20
45
|
|
|
21
|
-
Creates
|
|
46
|
+
Creates:
|
|
47
|
+
- `omnify.config.ts` - Configuration file with plugin setup
|
|
48
|
+
- `schemas/User.yaml` - Example schema file
|
|
22
49
|
|
|
23
|
-
|
|
50
|
+
After initialization, you'll see step-by-step setup instructions.
|
|
51
|
+
|
|
52
|
+
### `omnify validate`
|
|
53
|
+
|
|
54
|
+
Validate all schema files for errors.
|
|
24
55
|
|
|
25
56
|
```bash
|
|
26
|
-
omnify validate
|
|
57
|
+
omnify validate [options]
|
|
58
|
+
|
|
59
|
+
Options:
|
|
60
|
+
-v, --verbose Show detailed output
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Example output:
|
|
27
64
|
```
|
|
65
|
+
Validating Schemas
|
|
28
66
|
|
|
29
|
-
|
|
67
|
+
Loading schemas from ./schemas
|
|
68
|
+
Found 3 schema(s)
|
|
69
|
+
Validating schemas...
|
|
70
|
+
|
|
71
|
+
All schemas are valid!
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `omnify diff`
|
|
75
|
+
|
|
76
|
+
Show pending schema changes without generating files.
|
|
30
77
|
|
|
31
78
|
```bash
|
|
32
|
-
omnify
|
|
79
|
+
omnify diff [options]
|
|
80
|
+
|
|
81
|
+
Options:
|
|
82
|
+
-v, --verbose Show detailed output
|
|
33
83
|
```
|
|
34
84
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- Atlas HCL schemas
|
|
85
|
+
Uses Atlas to compare your schemas against the lock file and shows what migrations would be generated.
|
|
86
|
+
|
|
87
|
+
### `omnify generate`
|
|
39
88
|
|
|
40
|
-
|
|
89
|
+
Generate Laravel migrations and TypeScript types.
|
|
41
90
|
|
|
42
91
|
```bash
|
|
43
|
-
omnify
|
|
92
|
+
omnify generate [options]
|
|
93
|
+
|
|
94
|
+
Options:
|
|
95
|
+
-v, --verbose Show detailed output
|
|
96
|
+
--migrations-only Only generate Laravel migrations
|
|
97
|
+
--types-only Only generate TypeScript types
|
|
98
|
+
-f, --force Generate even if no changes detected
|
|
44
99
|
```
|
|
45
100
|
|
|
46
|
-
|
|
101
|
+
Example:
|
|
102
|
+
```bash
|
|
103
|
+
# Generate everything
|
|
104
|
+
omnify generate
|
|
105
|
+
|
|
106
|
+
# Only migrations
|
|
107
|
+
omnify generate --migrations-only
|
|
108
|
+
|
|
109
|
+
# Only TypeScript types
|
|
110
|
+
omnify generate --types-only
|
|
111
|
+
|
|
112
|
+
# Force regeneration
|
|
113
|
+
omnify generate --force
|
|
114
|
+
|
|
115
|
+
# Verbose output
|
|
116
|
+
omnify generate -v
|
|
117
|
+
```
|
|
47
118
|
|
|
48
119
|
## Configuration
|
|
49
120
|
|
|
121
|
+
### Basic Configuration
|
|
122
|
+
|
|
50
123
|
Create `omnify.config.ts`:
|
|
51
124
|
|
|
52
125
|
```typescript
|
|
53
|
-
import { defineConfig } from '@famgia/omnify
|
|
126
|
+
import { defineConfig } from '@famgia/omnify';
|
|
127
|
+
import laravel from '@famgia/omnify-laravel/plugin';
|
|
54
128
|
|
|
55
129
|
export default defineConfig({
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
130
|
+
schemasDir: './schemas',
|
|
131
|
+
lockFilePath: './omnify.lock',
|
|
132
|
+
|
|
133
|
+
database: {
|
|
134
|
+
driver: 'mysql',
|
|
135
|
+
devUrl: 'mysql://root:password@localhost:3306/omnify_dev',
|
|
60
136
|
},
|
|
61
|
-
|
|
62
|
-
|
|
137
|
+
|
|
138
|
+
plugins: [
|
|
139
|
+
laravel({
|
|
140
|
+
migrationsPath: 'database/migrations',
|
|
141
|
+
typesPath: 'resources/js/types',
|
|
142
|
+
singleFile: true,
|
|
143
|
+
}),
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Configuration Options
|
|
149
|
+
|
|
150
|
+
| Option | Type | Required | Description |
|
|
151
|
+
|--------|------|----------|-------------|
|
|
152
|
+
| `schemasDir` | `string` | Yes | Directory containing schema files |
|
|
153
|
+
| `lockFilePath` | `string` | Yes | Path to lock file for change tracking |
|
|
154
|
+
| `database.driver` | `string` | Yes | Database driver: `mysql`, `postgres`, `sqlite` |
|
|
155
|
+
| `database.devUrl` | `string` | Yes* | Development database URL for Atlas (*required for generate) |
|
|
156
|
+
| `plugins` | `Plugin[]` | No | Array of generator plugins |
|
|
157
|
+
|
|
158
|
+
### Database URL Format
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
mysql://user:password@host:port/database
|
|
162
|
+
postgres://user:password@host:port/database
|
|
163
|
+
sqlite://path/to/file.db
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Multiple Plugins
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
import { defineConfig } from '@famgia/omnify';
|
|
170
|
+
import laravel from '@famgia/omnify-laravel/plugin';
|
|
171
|
+
// Future plugins
|
|
172
|
+
// import prisma from '@famgia/omnify-prisma/plugin';
|
|
173
|
+
// import drizzle from '@famgia/omnify-drizzle/plugin';
|
|
174
|
+
|
|
175
|
+
export default defineConfig({
|
|
176
|
+
schemasDir: './schemas',
|
|
177
|
+
lockFilePath: './omnify.lock',
|
|
178
|
+
|
|
179
|
+
database: {
|
|
180
|
+
driver: 'mysql',
|
|
181
|
+
devUrl: 'mysql://root@localhost:3306/dev',
|
|
63
182
|
},
|
|
183
|
+
|
|
184
|
+
plugins: [
|
|
185
|
+
// Laravel migrations + TypeScript types
|
|
186
|
+
laravel({
|
|
187
|
+
migrationsPath: 'database/migrations',
|
|
188
|
+
typesPath: 'resources/js/types',
|
|
189
|
+
}),
|
|
190
|
+
|
|
191
|
+
// Prisma schema (future)
|
|
192
|
+
// prisma({
|
|
193
|
+
// schemaPath: 'prisma/schema.prisma',
|
|
194
|
+
// }),
|
|
195
|
+
],
|
|
64
196
|
});
|
|
65
197
|
```
|
|
66
198
|
|
|
199
|
+
## Schema Files
|
|
200
|
+
|
|
201
|
+
### Basic Schema
|
|
202
|
+
|
|
203
|
+
`schemas/User.yaml`:
|
|
204
|
+
```yaml
|
|
205
|
+
name: User
|
|
206
|
+
kind: object
|
|
207
|
+
|
|
208
|
+
properties:
|
|
209
|
+
email:
|
|
210
|
+
type: Email
|
|
211
|
+
unique: true
|
|
212
|
+
name:
|
|
213
|
+
type: String
|
|
214
|
+
age:
|
|
215
|
+
type: Int
|
|
216
|
+
nullable: true
|
|
217
|
+
|
|
218
|
+
options:
|
|
219
|
+
timestamps: true
|
|
220
|
+
softDeletes: true
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### With Associations
|
|
224
|
+
|
|
225
|
+
`schemas/Post.yaml`:
|
|
226
|
+
```yaml
|
|
227
|
+
name: Post
|
|
228
|
+
kind: object
|
|
229
|
+
|
|
230
|
+
properties:
|
|
231
|
+
title:
|
|
232
|
+
type: String
|
|
233
|
+
content:
|
|
234
|
+
type: Text
|
|
235
|
+
published:
|
|
236
|
+
type: Boolean
|
|
237
|
+
default: false
|
|
238
|
+
|
|
239
|
+
associations:
|
|
240
|
+
author:
|
|
241
|
+
type: belongsTo
|
|
242
|
+
model: User
|
|
243
|
+
foreignKey: user_id
|
|
244
|
+
|
|
245
|
+
options:
|
|
246
|
+
timestamps: true
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Enum
|
|
250
|
+
|
|
251
|
+
`schemas/Status.yaml`:
|
|
252
|
+
```yaml
|
|
253
|
+
name: Status
|
|
254
|
+
kind: enum
|
|
255
|
+
|
|
256
|
+
values:
|
|
257
|
+
- draft
|
|
258
|
+
- published
|
|
259
|
+
- archived
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Exit Codes
|
|
263
|
+
|
|
264
|
+
| Code | Meaning |
|
|
265
|
+
|------|---------|
|
|
266
|
+
| 0 | Success |
|
|
267
|
+
| 1 | General error |
|
|
268
|
+
| 2 | Validation error |
|
|
269
|
+
|
|
270
|
+
## Environment Variables
|
|
271
|
+
|
|
272
|
+
| Variable | Description |
|
|
273
|
+
|----------|-------------|
|
|
274
|
+
| `OMNIFY_DEV_URL` | Override database.devUrl from config |
|
|
275
|
+
| `DEBUG` | Set to `omnify:*` for debug output |
|
|
276
|
+
|
|
277
|
+
## Troubleshooting
|
|
278
|
+
|
|
279
|
+
### "devUrl is required for generate command"
|
|
280
|
+
|
|
281
|
+
Set your database URL in `omnify.config.ts`:
|
|
282
|
+
```typescript
|
|
283
|
+
database: {
|
|
284
|
+
driver: 'mysql',
|
|
285
|
+
devUrl: 'mysql://root:password@localhost:3306/dev_db',
|
|
286
|
+
},
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### "No schema files found"
|
|
290
|
+
|
|
291
|
+
Make sure your `schemasDir` points to the correct directory and contains `.yaml` or `.json` files.
|
|
292
|
+
|
|
293
|
+
### "Atlas command not found"
|
|
294
|
+
|
|
295
|
+
Install Atlas CLI:
|
|
296
|
+
```bash
|
|
297
|
+
# macOS
|
|
298
|
+
brew install ariga/tap/atlas
|
|
299
|
+
|
|
300
|
+
# Linux
|
|
301
|
+
curl -sSf https://atlasgo.sh | sh
|
|
302
|
+
```
|
|
303
|
+
|
|
67
304
|
## Related Packages
|
|
68
305
|
|
|
306
|
+
- [@famgia/omnify](https://www.npmjs.com/package/@famgia/omnify) - Main package
|
|
69
307
|
- [@famgia/omnify-core](https://www.npmjs.com/package/@famgia/omnify-core) - Core engine
|
|
70
308
|
- [@famgia/omnify-types](https://www.npmjs.com/package/@famgia/omnify-types) - Type definitions
|
|
71
309
|
- [@famgia/omnify-laravel](https://www.npmjs.com/package/@famgia/omnify-laravel) - Laravel generator
|