firestore-dart-generator 1.0.0-beta.1 → 1.0.0
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 +0 -68
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/interactive-cli.d.ts +1 -1
- package/dist/interactive-cli.d.ts.map +1 -1
- package/dist/interactive-cli.js +7 -22
- package/dist/interactive-cli.js.map +1 -1
- package/dist/types.d.ts +0 -11
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/CONFIG_FILE_GUIDE.md +0 -445
- package/IMPLEMENTATION_SUMMARY.md +0 -305
- package/QUICK_START.md +0 -241
- package/dist/config-file-loader.d.ts +0 -35
- package/dist/config-file-loader.d.ts.map +0 -1
- package/dist/config-file-loader.js +0 -130
- package/dist/config-file-loader.js.map +0 -1
- package/firestore-dart-gen.example.yaml +0 -28
package/CONFIG_FILE_GUIDE.md
DELETED
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
# 📄 Guía de Archivo de Configuración
|
|
2
|
-
|
|
3
|
-
## ✅ IMPLEMENTACIÓN COMPLETA
|
|
4
|
-
|
|
5
|
-
El CLI ahora soporta un archivo de configuración YAML que hace el uso mucho más conveniente.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 🚀 Uso Rápido
|
|
10
|
-
|
|
11
|
-
### 1. Crear archivo de configuración
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
# Copiar el ejemplo
|
|
15
|
-
cp firestore-dart-gen.example.yaml firestore-dart-gen.yaml
|
|
16
|
-
|
|
17
|
-
# Editar con tus valores
|
|
18
|
-
nano firestore-dart-gen.yaml
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### 2. Configurar
|
|
22
|
-
|
|
23
|
-
```yaml
|
|
24
|
-
# firestore-dart-gen.yaml
|
|
25
|
-
firebase:
|
|
26
|
-
serviceAccount: ./firebase_service_account.json
|
|
27
|
-
|
|
28
|
-
collections:
|
|
29
|
-
- users
|
|
30
|
-
- products
|
|
31
|
-
|
|
32
|
-
output:
|
|
33
|
-
directory: ./lib/src/models
|
|
34
|
-
sampleSize: 20
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### 3. Ejecutar
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
# Simplemente ejecuta sin argumentos
|
|
41
|
-
firestore-dart-gen
|
|
42
|
-
|
|
43
|
-
# El CLI:
|
|
44
|
-
# ✓ Carga credenciales del YAML
|
|
45
|
-
# ✓ Pre-selecciona users y products
|
|
46
|
-
# ✓ Usa ./lib/src/models como directorio por defecto
|
|
47
|
-
# ✓ Usa 20 como sample size por defecto
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## 📋 Estructura del Archivo
|
|
53
|
-
|
|
54
|
-
### Completo (todos los campos opcionales)
|
|
55
|
-
|
|
56
|
-
```yaml
|
|
57
|
-
# Firebase Configuration
|
|
58
|
-
firebase:
|
|
59
|
-
# Path al service account (requerido si no usas CLI args)
|
|
60
|
-
serviceAccount: ./firebase_service_account.json
|
|
61
|
-
|
|
62
|
-
# Project ID (opcional, se puede obtener del service account)
|
|
63
|
-
projectId: my-project-id
|
|
64
|
-
|
|
65
|
-
# Collections que aparecerán pre-seleccionadas (opcional)
|
|
66
|
-
collections:
|
|
67
|
-
- users
|
|
68
|
-
- products
|
|
69
|
-
- orders
|
|
70
|
-
- reviews
|
|
71
|
-
- settings
|
|
72
|
-
|
|
73
|
-
# Configuración de output (opcional)
|
|
74
|
-
output:
|
|
75
|
-
# Directorio donde se generarán los modelos
|
|
76
|
-
directory: ./lib/src/models
|
|
77
|
-
|
|
78
|
-
# Cantidad de documentos a samplear por colección
|
|
79
|
-
sampleSize: 20
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Mínimo (solo credenciales)
|
|
83
|
-
|
|
84
|
-
```yaml
|
|
85
|
-
firebase:
|
|
86
|
-
serviceAccount: ./firebase_service_account.json
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Solo pre-selección (sin credenciales)
|
|
90
|
-
|
|
91
|
-
```yaml
|
|
92
|
-
collections:
|
|
93
|
-
- users
|
|
94
|
-
- products
|
|
95
|
-
|
|
96
|
-
output:
|
|
97
|
-
directory: ./lib/src/models
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Luego ejecutar:
|
|
101
|
-
```bash
|
|
102
|
-
firestore-dart-gen --service-account credentials.json
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## 🎯 Comportamiento
|
|
108
|
-
|
|
109
|
-
### Sin Archivo de Config
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
firestore-dart-gen --service-account credentials.json
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
**Resultado:**
|
|
116
|
-
- Todas las colecciones SIN pre-seleccionar
|
|
117
|
-
- Default output: `./lib/src/models`
|
|
118
|
-
- Default sample size: `20`
|
|
119
|
-
|
|
120
|
-
### Con Archivo de Config
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
# firestore-dart-gen.yaml existe
|
|
124
|
-
firestore-dart-gen
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
**Resultado:**
|
|
128
|
-
- Colecciones del YAML aparecen **✓ PRE-SELECCIONADAS**
|
|
129
|
-
- Output directory del YAML como default
|
|
130
|
-
- Sample size del YAML como default
|
|
131
|
-
- Usuario puede cambiar cualquier valor en los prompts
|
|
132
|
-
|
|
133
|
-
### Con Config + CLI Args
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
# firestore-dart-gen.yaml existe
|
|
137
|
-
firestore-dart-gen --service-account other.json
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
**Resultado:**
|
|
141
|
-
- Usa `other.json` (CLI arg gana sobre YAML)
|
|
142
|
-
- Pre-selecciona colecciones del YAML
|
|
143
|
-
- Usa outputs del YAML
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## 🔐 Prioridad de Configuración
|
|
148
|
-
|
|
149
|
-
```
|
|
150
|
-
┌─────────────────────────────────────────────┐
|
|
151
|
-
│ 1. CLI Arguments (highest priority) │
|
|
152
|
-
│ --service-account │
|
|
153
|
-
│ --project-id │
|
|
154
|
-
│ --config │
|
|
155
|
-
├─────────────────────────────────────────────┤
|
|
156
|
-
│ 2. Config File │
|
|
157
|
-
│ firestore-dart-gen.yaml │
|
|
158
|
-
├─────────────────────────────────────────────┤
|
|
159
|
-
│ 3. Environment Variables (lowest priority) │
|
|
160
|
-
│ GOOGLE_APPLICATION_CREDENTIALS │
|
|
161
|
-
│ FIREBASE_PROJECT_ID │
|
|
162
|
-
└─────────────────────────────────────────────┘
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
**Ejemplo práctico:**
|
|
166
|
-
|
|
167
|
-
```yaml
|
|
168
|
-
# firestore-dart-gen.yaml
|
|
169
|
-
firebase:
|
|
170
|
-
serviceAccount: ./dev-credentials.json # Priority 2
|
|
171
|
-
|
|
172
|
-
# .env
|
|
173
|
-
GOOGLE_APPLICATION_CREDENTIALS=./prod-credentials.json # Priority 3
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
# Usa dev-credentials.json (del YAML, priority 2)
|
|
178
|
-
firestore-dart-gen
|
|
179
|
-
|
|
180
|
-
# Usa prod-credentials.json (CLI arg, priority 1)
|
|
181
|
-
firestore-dart-gen --service-account ./prod-credentials.json
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
## 📁 Ubicación del Archivo
|
|
187
|
-
|
|
188
|
-
El CLI busca el archivo de config en este orden:
|
|
189
|
-
|
|
190
|
-
1. Path especificado con `--config`
|
|
191
|
-
2. `firestore-dart-gen.yaml` (en directorio actual)
|
|
192
|
-
3. `firestore-dart-gen.yml`
|
|
193
|
-
4. `.firestore-dart-gen.yaml` (hidden)
|
|
194
|
-
5. `.firestore-dart-gen.yml` (hidden)
|
|
195
|
-
|
|
196
|
-
**Recomendación:** Usa `firestore-dart-gen.yaml` en la raíz de tu proyecto Flutter.
|
|
197
|
-
|
|
198
|
-
---
|
|
199
|
-
|
|
200
|
-
## 🎨 Ejemplo de Sesión Interactiva
|
|
201
|
-
|
|
202
|
-
### Con archivo de config:
|
|
203
|
-
|
|
204
|
-
```bash
|
|
205
|
-
$ firestore-dart-gen
|
|
206
|
-
|
|
207
|
-
🔥 Firestore Dart Generator - Interactive Mode
|
|
208
|
-
|
|
209
|
-
📄 Found config file: firestore-dart-gen.yaml
|
|
210
|
-
|
|
211
|
-
✓ Connected to Firebase Project: my-awesome-app
|
|
212
|
-
|
|
213
|
-
🔍 Discovering collections...
|
|
214
|
-
|
|
215
|
-
Found 7 collection(s)
|
|
216
|
-
|
|
217
|
-
Pre-selected from config: users, products
|
|
218
|
-
|
|
219
|
-
? Select collections to generate models for: (Use ↑↓, Space, Enter)
|
|
220
|
-
❯◉ users ← Pre-seleccionado ✓
|
|
221
|
-
◉ products ← Pre-seleccionado ✓
|
|
222
|
-
◯ orders
|
|
223
|
-
◯ reviews
|
|
224
|
-
◯ settings
|
|
225
|
-
◯ notifications
|
|
226
|
-
◯ analytics
|
|
227
|
-
|
|
228
|
-
🌳 Checking for subcollections...
|
|
229
|
-
|
|
230
|
-
Analyzing users...
|
|
231
|
-
Found 2 subcollection(s): profiles, settings
|
|
232
|
-
Include subcollections for users? (Y/n) y
|
|
233
|
-
|
|
234
|
-
? Output directory: ./lib/src/models ← Default del config
|
|
235
|
-
? Sample size: 20 ← Default del config
|
|
236
|
-
|
|
237
|
-
📋 Generation Summary:
|
|
238
|
-
────────────────────────────────────────────────
|
|
239
|
-
Firebase Project: my-awesome-app
|
|
240
|
-
Collections: users, products
|
|
241
|
-
Subcollections:
|
|
242
|
-
└─ users: profiles, settings
|
|
243
|
-
Output: ./lib/src/models
|
|
244
|
-
Sample Size: 20 documents per collection
|
|
245
|
-
────────────────────────────────────────────────
|
|
246
|
-
|
|
247
|
-
? Generate? (Y/n) y
|
|
248
|
-
|
|
249
|
-
✨ Success! Generated 4 model(s)
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
---
|
|
253
|
-
|
|
254
|
-
## 💡 Casos de Uso
|
|
255
|
-
|
|
256
|
-
### Desarrollo Local
|
|
257
|
-
|
|
258
|
-
```yaml
|
|
259
|
-
# firestore-dart-gen.yaml
|
|
260
|
-
firebase:
|
|
261
|
-
serviceAccount: ./dev-credentials.json
|
|
262
|
-
projectId: my-app-dev
|
|
263
|
-
|
|
264
|
-
collections:
|
|
265
|
-
- users
|
|
266
|
-
- products
|
|
267
|
-
|
|
268
|
-
output:
|
|
269
|
-
directory: ./lib/src/models
|
|
270
|
-
sampleSize: 10 # Menos documentos para desarrollo
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### Producción / CI/CD
|
|
274
|
-
|
|
275
|
-
```yaml
|
|
276
|
-
# firestore-dart-gen.yaml (commitear en repo)
|
|
277
|
-
collections:
|
|
278
|
-
- users
|
|
279
|
-
- products
|
|
280
|
-
- orders
|
|
281
|
-
|
|
282
|
-
output:
|
|
283
|
-
directory: ./lib/src/models
|
|
284
|
-
sampleSize: 50 # Más documentos para mejor análisis
|
|
285
|
-
|
|
286
|
-
# NO incluir firebase.serviceAccount aquí!
|
|
287
|
-
# Usar variable de entorno o CLI arg en CI
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
En CI:
|
|
291
|
-
```bash
|
|
292
|
-
firestore-dart-gen --service-account $SERVICE_ACCOUNT_PATH
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
### Equipos
|
|
296
|
-
|
|
297
|
-
```yaml
|
|
298
|
-
# firestore-dart-gen.yaml (compartir en repo)
|
|
299
|
-
# NO incluir credenciales
|
|
300
|
-
|
|
301
|
-
collections:
|
|
302
|
-
- users
|
|
303
|
-
- products
|
|
304
|
-
- orders
|
|
305
|
-
- reviews
|
|
306
|
-
- notifications
|
|
307
|
-
|
|
308
|
-
output:
|
|
309
|
-
directory: ./packages/core/lib/models
|
|
310
|
-
sampleSize: 20
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
Cada desarrollador crea su propio `.env`:
|
|
314
|
-
```bash
|
|
315
|
-
GOOGLE_APPLICATION_CREDENTIALS=./mi-credentials.json
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
---
|
|
319
|
-
|
|
320
|
-
## ⚠️ Seguridad
|
|
321
|
-
|
|
322
|
-
### ✅ Buenas Prácticas
|
|
323
|
-
|
|
324
|
-
```yaml
|
|
325
|
-
# firestore-dart-gen.yaml (SAFE para commitear)
|
|
326
|
-
collections:
|
|
327
|
-
- users
|
|
328
|
-
- products
|
|
329
|
-
|
|
330
|
-
output:
|
|
331
|
-
directory: ./lib/src/models
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
```bash
|
|
335
|
-
# .gitignore
|
|
336
|
-
firestore-dart-gen.yaml # Si incluye credenciales
|
|
337
|
-
*service-account.json
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
### ❌ NO Hacer
|
|
341
|
-
|
|
342
|
-
```yaml
|
|
343
|
-
# ❌ NO commitear credenciales en el YAML
|
|
344
|
-
firebase:
|
|
345
|
-
serviceAccount: ./super-secret-credentials.json # PELIGRO!
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
**Solución:** Usa variables de entorno o CLI args para credenciales sensibles.
|
|
349
|
-
|
|
350
|
-
---
|
|
351
|
-
|
|
352
|
-
## 🔧 Troubleshooting
|
|
353
|
-
|
|
354
|
-
### "Could not load config file"
|
|
355
|
-
|
|
356
|
-
```bash
|
|
357
|
-
# Verifica que el YAML es válido
|
|
358
|
-
cat firestore-dart-gen.yaml
|
|
359
|
-
|
|
360
|
-
# Verifica la sintaxis YAML
|
|
361
|
-
npm install -g js-yaml
|
|
362
|
-
js-yaml firestore-dart-gen.yaml
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
### "Service account file not found"
|
|
366
|
-
|
|
367
|
-
```bash
|
|
368
|
-
# Verifica el path en el config
|
|
369
|
-
cat firestore-dart-gen.yaml
|
|
370
|
-
|
|
371
|
-
# Verifica que el archivo existe
|
|
372
|
-
ls -la firebase_service_account.json
|
|
373
|
-
|
|
374
|
-
# Usa path absoluto si es necesario
|
|
375
|
-
firebase:
|
|
376
|
-
serviceAccount: /Users/you/projects/credentials.json
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
### Config no se carga
|
|
380
|
-
|
|
381
|
-
```bash
|
|
382
|
-
# Verifica que estás en el directorio correcto
|
|
383
|
-
pwd
|
|
384
|
-
ls firestore-dart-gen.yaml
|
|
385
|
-
|
|
386
|
-
# O especifica el path explícitamente
|
|
387
|
-
firestore-dart-gen --config ./path/to/config.yaml
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
---
|
|
391
|
-
|
|
392
|
-
## 📊 Archivos Creados
|
|
393
|
-
|
|
394
|
-
### Nuevos Archivos
|
|
395
|
-
- ✅ `src/config-file-loader.ts` (108 líneas) - Loader de configuración
|
|
396
|
-
- ✅ `firestore-dart-gen.example.yaml` (27 líneas) - Ejemplo de configuración
|
|
397
|
-
- ✅ `CONFIG_FILE_GUIDE.md` (este archivo) - Guía completa
|
|
398
|
-
|
|
399
|
-
### Archivos Modificados
|
|
400
|
-
- ✅ `src/interactive-cli.ts` - Integra configuración YAML
|
|
401
|
-
- ✅ `src/index.ts` - Agrega opción --config
|
|
402
|
-
- ✅ `src/types.ts` - Define CLIConfig interface
|
|
403
|
-
- ✅ `.gitignore` - Ignora archivos de config
|
|
404
|
-
- ✅ `README.md` - Documenta configuración
|
|
405
|
-
|
|
406
|
-
---
|
|
407
|
-
|
|
408
|
-
## ✨ Beneficios
|
|
409
|
-
|
|
410
|
-
### Para Desarrolladores
|
|
411
|
-
✅ No escribir credenciales cada vez
|
|
412
|
-
✅ Pre-selección automática de colecciones frecuentes
|
|
413
|
-
✅ Configuración compartible entre equipo
|
|
414
|
-
✅ Valores por defecto personalizables
|
|
415
|
-
|
|
416
|
-
### Para Equipos
|
|
417
|
-
✅ Configuración estándar compartida en repo
|
|
418
|
-
✅ Credenciales manejadas externamente
|
|
419
|
-
✅ Consistencia en outputs
|
|
420
|
-
✅ Fácil onboarding de nuevos miembros
|
|
421
|
-
|
|
422
|
-
### Para CI/CD
|
|
423
|
-
✅ Config en repo, credenciales en secrets
|
|
424
|
-
✅ Override con CLI args
|
|
425
|
-
✅ Configuración versionada
|
|
426
|
-
✅ Reproducible
|
|
427
|
-
|
|
428
|
-
---
|
|
429
|
-
|
|
430
|
-
## 🎉 Estado
|
|
431
|
-
|
|
432
|
-
**✅ COMPLETAMENTE IMPLEMENTADO Y FUNCIONAL**
|
|
433
|
-
|
|
434
|
-
- Build exitoso ✓
|
|
435
|
-
- Tests pasando (23/23) ✓
|
|
436
|
-
- CLI funcionando ✓
|
|
437
|
-
- Documentación completa ✓
|
|
438
|
-
|
|
439
|
-
**Listo para usar!** 🚀
|
|
440
|
-
|
|
441
|
-
---
|
|
442
|
-
|
|
443
|
-
*Creado: Diciembre 17, 2024*
|
|
444
|
-
*Versión: 1.1.0*
|
|
445
|
-
|