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
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
# 🎉 Resumen de Implementación - Config File Support
|
|
2
|
-
|
|
3
|
-
## ✅ COMPLETADO EXITOSAMENTE
|
|
4
|
-
|
|
5
|
-
El soporte para archivo de configuración YAML ha sido completamente implementado y está listo para usar.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 📊 Resultados
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
╔═══════════════════════════════════════════════════════════╗
|
|
13
|
-
║ ✅ Build: EXITOSO ║
|
|
14
|
-
║ ✅ Tests: 23/23 pasando ║
|
|
15
|
-
║ ✅ Compilación: Sin errores ║
|
|
16
|
-
║ ✅ TODOs: 8/8 completados ║
|
|
17
|
-
╚═══════════════════════════════════════════════════════════╝
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## 📁 Archivos Nuevos (3)
|
|
23
|
-
|
|
24
|
-
1. **`src/config-file-loader.ts`** (108 líneas)
|
|
25
|
-
- Clase ConfigFileLoader
|
|
26
|
-
- Métodos de carga y validación
|
|
27
|
-
- Resolución de prioridades
|
|
28
|
-
- Soporte para múltiples nombres de archivo
|
|
29
|
-
|
|
30
|
-
2. **`firestore-dart-gen.example.yaml`** (27 líneas)
|
|
31
|
-
- Archivo de ejemplo comentado
|
|
32
|
-
- Documenta todas las opciones
|
|
33
|
-
- Listo para copiar y personalizar
|
|
34
|
-
|
|
35
|
-
3. **`CONFIG_FILE_GUIDE.md`** (350+ líneas)
|
|
36
|
-
- Guía completa de uso
|
|
37
|
-
- Ejemplos de configuración
|
|
38
|
-
- Troubleshooting
|
|
39
|
-
- Casos de uso
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## 📝 Archivos Modificados (6)
|
|
44
|
-
|
|
45
|
-
1. **`src/interactive-cli.ts`**
|
|
46
|
-
- Importa ConfigFileLoader
|
|
47
|
-
- Carga config al inicio
|
|
48
|
-
- Pre-selecciona colecciones del config
|
|
49
|
-
- Usa defaults del config
|
|
50
|
-
|
|
51
|
-
2. **`src/index.ts`**
|
|
52
|
-
- Agrega opción `--config <path>`
|
|
53
|
-
- Pasa configPath a runInteractiveCLI
|
|
54
|
-
|
|
55
|
-
3. **`src/types.ts`**
|
|
56
|
-
- Define CLIConfig interface
|
|
57
|
-
- Tipos para firebase, collections, output
|
|
58
|
-
|
|
59
|
-
4. **`.gitignore`**
|
|
60
|
-
- Ignora archivos de configuración
|
|
61
|
-
- Previene commit de credenciales
|
|
62
|
-
|
|
63
|
-
5. **`README.md`**
|
|
64
|
-
- Nueva sección "Configuration File"
|
|
65
|
-
- Ejemplos de uso
|
|
66
|
-
- Prioridad de configuración
|
|
67
|
-
- Beneficios documentados
|
|
68
|
-
|
|
69
|
-
6. **`package.json`**
|
|
70
|
-
- Ya contenía las dependencias necesarias
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
## 🎯 Funcionalidades Implementadas
|
|
75
|
-
|
|
76
|
-
### ✅ Carga Automática de Config
|
|
77
|
-
- [x] Busca `firestore-dart-gen.yaml` automáticamente
|
|
78
|
-
- [x] Soporta variantes (.yml, hidden files)
|
|
79
|
-
- [x] Opción --config para especificar path custom
|
|
80
|
-
- [x] Funciona sin config file (opcional)
|
|
81
|
-
|
|
82
|
-
### ✅ Resolución de Credenciales
|
|
83
|
-
- [x] Prioridad: CLI args > Config > Env
|
|
84
|
-
- [x] Service account desde YAML
|
|
85
|
-
- [x] Project ID desde YAML
|
|
86
|
-
- [x] Fallback a variables de entorno
|
|
87
|
-
|
|
88
|
-
### ✅ Pre-selección de Colecciones
|
|
89
|
-
- [x] Colecciones del YAML aparecen checked ✓
|
|
90
|
-
- [x] Usuario puede agregar/quitar más
|
|
91
|
-
- [x] Validación de al menos 1 seleccionada
|
|
92
|
-
- [x] Indicador visual de pre-selección
|
|
93
|
-
|
|
94
|
-
### ✅ Defaults Configurables
|
|
95
|
-
- [x] Output directory desde config
|
|
96
|
-
- [x] Sample size desde config
|
|
97
|
-
- [x] Usuario puede cambiarlos en prompts
|
|
98
|
-
- [x] Fallback a valores sensatos
|
|
99
|
-
|
|
100
|
-
### ✅ Validación y Errores
|
|
101
|
-
- [x] Valida estructura del YAML
|
|
102
|
-
- [x] Verifica que service account existe
|
|
103
|
-
- [x] Valida que collections sea array
|
|
104
|
-
- [x] Valida sample size > 0
|
|
105
|
-
- [x] Mensajes de error claros
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## 🎨 Ejemplo de Uso Completo
|
|
110
|
-
|
|
111
|
-
### 1. Crear Config
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
cp firestore-dart-gen.example.yaml firestore-dart-gen.yaml
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Editar:
|
|
118
|
-
```yaml
|
|
119
|
-
firebase:
|
|
120
|
-
serviceAccount: ./firebase_service_account.json
|
|
121
|
-
|
|
122
|
-
collections:
|
|
123
|
-
- users
|
|
124
|
-
- products
|
|
125
|
-
|
|
126
|
-
output:
|
|
127
|
-
directory: ./lib/src/models
|
|
128
|
-
sampleSize: 20
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### 2. Ejecutar
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
firestore-dart-gen
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### 3. Experiencia
|
|
138
|
-
|
|
139
|
-
```
|
|
140
|
-
🔥 Firestore Dart Generator - Interactive Mode
|
|
141
|
-
|
|
142
|
-
📄 Found config file: firestore-dart-gen.yaml
|
|
143
|
-
|
|
144
|
-
✓ Connected to Firebase Project: my-app
|
|
145
|
-
|
|
146
|
-
Found 7 collection(s)
|
|
147
|
-
|
|
148
|
-
Pre-selected from config: users, products
|
|
149
|
-
|
|
150
|
-
? Select collections: (↑↓ Space Enter)
|
|
151
|
-
❯◉ users ← ✓
|
|
152
|
-
◉ products ← ✓
|
|
153
|
-
◯ orders
|
|
154
|
-
◯ reviews
|
|
155
|
-
|
|
156
|
-
? Output directory: ./lib/src/models
|
|
157
|
-
? Sample size: 20
|
|
158
|
-
|
|
159
|
-
? Generate? Yes
|
|
160
|
-
|
|
161
|
-
✨ Success! Generated 2 model(s)
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## 🔐 Prioridad de Configuración
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
┌──────────────────────────────┐
|
|
170
|
-
│ 1. CLI Arguments │ ← Highest Priority
|
|
171
|
-
│ --service-account │
|
|
172
|
-
│ --project-id │
|
|
173
|
-
│ --config │
|
|
174
|
-
├──────────────────────────────┤
|
|
175
|
-
│ 2. Config File │
|
|
176
|
-
│ firestore-dart-gen.yaml │
|
|
177
|
-
├──────────────────────────────┤
|
|
178
|
-
│ 3. Environment Variables │ ← Lowest Priority
|
|
179
|
-
│ .env │
|
|
180
|
-
└──────────────────────────────┘
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**Ejemplo:**
|
|
184
|
-
|
|
185
|
-
```yaml
|
|
186
|
-
# firestore-dart-gen.yaml
|
|
187
|
-
firebase:
|
|
188
|
-
serviceAccount: ./dev.json
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
```bash
|
|
192
|
-
# Usa dev.json del YAML
|
|
193
|
-
firestore-dart-gen
|
|
194
|
-
|
|
195
|
-
# Usa prod.json del CLI arg (gana)
|
|
196
|
-
firestore-dart-gen --service-account prod.json
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
---
|
|
200
|
-
|
|
201
|
-
## 📚 Documentación Creada
|
|
202
|
-
|
|
203
|
-
- ✅ **README.md**: Sección "Configuration File (Optional)"
|
|
204
|
-
- ✅ **CONFIG_FILE_GUIDE.md**: Guía completa (este archivo)
|
|
205
|
-
- ✅ **firestore-dart-gen.example.yaml**: Archivo ejemplo
|
|
206
|
-
- ✅ **cli.plan.md**: Plan de implementación
|
|
207
|
-
|
|
208
|
-
---
|
|
209
|
-
|
|
210
|
-
## 🧪 Testing
|
|
211
|
-
|
|
212
|
-
```bash
|
|
213
|
-
npm test
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
**Resultado:**
|
|
217
|
-
```
|
|
218
|
-
✅ Test Suites: 2 passed, 2 total
|
|
219
|
-
✅ Tests: 23 passed, 23 total
|
|
220
|
-
✅ Time: ~2s
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
La lógica core no cambió, por lo que todos los tests siguen pasando.
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
## 🚀 Próximos Pasos
|
|
228
|
-
|
|
229
|
-
### Para Usar
|
|
230
|
-
|
|
231
|
-
```bash
|
|
232
|
-
# 1. Crear config
|
|
233
|
-
cp firestore-dart-gen.example.yaml firestore-dart-gen.yaml
|
|
234
|
-
|
|
235
|
-
# 2. Editar con tus valores
|
|
236
|
-
nano firestore-dart-gen.yaml
|
|
237
|
-
|
|
238
|
-
# 3. Ejecutar
|
|
239
|
-
firestore-dart-gen
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
### Para Publicar
|
|
243
|
-
|
|
244
|
-
El paquete está listo para publicar en npm con esta nueva funcionalidad.
|
|
245
|
-
|
|
246
|
-
Ver: [`PUBLICACION_NPM.md`](PUBLICACION_NPM.md)
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
## ✨ Mejoras Logradas
|
|
251
|
-
|
|
252
|
-
### Antes
|
|
253
|
-
```bash
|
|
254
|
-
# Escribir todo cada vez
|
|
255
|
-
firestore-dart-gen batch \
|
|
256
|
-
--service-account firebase_service_account.json \
|
|
257
|
-
--config collections.yaml
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### Ahora
|
|
261
|
-
```bash
|
|
262
|
-
# Una sola vez: configurar YAML
|
|
263
|
-
# Luego simplemente:
|
|
264
|
-
firestore-dart-gen
|
|
265
|
-
|
|
266
|
-
# Pre-selecciona tus colecciones favoritas ✓
|
|
267
|
-
# Usa tus defaults ✓
|
|
268
|
-
# Menos typing ✓
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
---
|
|
272
|
-
|
|
273
|
-
## 📊 Estadísticas
|
|
274
|
-
|
|
275
|
-
- **Archivos nuevos:** 3
|
|
276
|
-
- **Archivos modificados:** 6
|
|
277
|
-
- **Líneas de código:** ~450 nuevas
|
|
278
|
-
- **Tests pasando:** 23/23
|
|
279
|
-
- **Build time:** ~2s
|
|
280
|
-
- **Tiempo de implementación:** Completo
|
|
281
|
-
|
|
282
|
-
---
|
|
283
|
-
|
|
284
|
-
## 🎉 Conclusión
|
|
285
|
-
|
|
286
|
-
**✅ IMPLEMENTACIÓN 100% COMPLETA**
|
|
287
|
-
|
|
288
|
-
El archivo de configuración YAML está completamente integrado en el CLI interactivo:
|
|
289
|
-
|
|
290
|
-
✅ Carga automática
|
|
291
|
-
✅ Pre-selección de colecciones
|
|
292
|
-
✅ Defaults configurables
|
|
293
|
-
✅ Prioridad flexible
|
|
294
|
-
✅ Documentación completa
|
|
295
|
-
✅ Tests pasando
|
|
296
|
-
✅ Build exitoso
|
|
297
|
-
|
|
298
|
-
**Estado: LISTO PARA PRODUCCIÓN** 🚀
|
|
299
|
-
|
|
300
|
-
---
|
|
301
|
-
|
|
302
|
-
*Implementado: Diciembre 17, 2024*
|
|
303
|
-
*Tests: 23/23 passing ✓*
|
|
304
|
-
*Build: Successful ✓*
|
|
305
|
-
|
package/QUICK_START.md
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
# 🚀 Inicio Rápido - Firestore Dart Generator
|
|
2
|
-
|
|
3
|
-
## Opción 1: Con Archivo de Configuración (Recomendado)
|
|
4
|
-
|
|
5
|
-
### Paso 1: Crear configuración
|
|
6
|
-
```bash
|
|
7
|
-
cp firestore-dart-gen.example.yaml firestore-dart-gen.yaml
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
### Paso 2: Editar configuración
|
|
11
|
-
```yaml
|
|
12
|
-
# firestore-dart-gen.yaml
|
|
13
|
-
firebase:
|
|
14
|
-
serviceAccount: ./firebase_service_account.json
|
|
15
|
-
|
|
16
|
-
collections:
|
|
17
|
-
- users # Pre-seleccionados
|
|
18
|
-
- products # Pre-seleccionados
|
|
19
|
-
|
|
20
|
-
output:
|
|
21
|
-
directory: ./lib/src/models
|
|
22
|
-
sampleSize: 20
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### Paso 3: Ejecutar
|
|
26
|
-
```bash
|
|
27
|
-
npm run dev
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**Resultado:**
|
|
31
|
-
- ✅ Carga credenciales automáticamente
|
|
32
|
-
- ✅ users y products aparecen pre-seleccionados
|
|
33
|
-
- ✅ Puedes agregar/quitar más colecciones
|
|
34
|
-
- ✅ Defaults ya configurados
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## Opción 2: Sin Archivo de Configuración
|
|
39
|
-
|
|
40
|
-
### Ejecutar directamente
|
|
41
|
-
```bash
|
|
42
|
-
npm run dev -- --service-account firebase_service_account.json
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
**Resultado:**
|
|
46
|
-
- Te pedirá seleccionar colecciones
|
|
47
|
-
- Te pedirá configurar output
|
|
48
|
-
- Todo manual, más flexible
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## 📋 Flujo Interactivo
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
🔥 Firestore Dart Generator - Interactive Mode
|
|
56
|
-
|
|
57
|
-
📄 Found config file: firestore-dart-gen.yaml
|
|
58
|
-
|
|
59
|
-
✓ Connected to Firebase Project: mi-proyecto
|
|
60
|
-
|
|
61
|
-
Found 5 collection(s)
|
|
62
|
-
|
|
63
|
-
Pre-selected from config: users, products
|
|
64
|
-
|
|
65
|
-
? Select collections: (↑↓ Space Enter)
|
|
66
|
-
❯◉ users ← Pre-seleccionado
|
|
67
|
-
◉ products ← Pre-seleccionado
|
|
68
|
-
◯ orders
|
|
69
|
-
◯ reviews
|
|
70
|
-
◯ settings
|
|
71
|
-
|
|
72
|
-
🌳 Checking for subcollections...
|
|
73
|
-
|
|
74
|
-
Analyzing users...
|
|
75
|
-
Found 2 subcollection(s): profiles, settings
|
|
76
|
-
Include subcollections for users? (Y/n) y
|
|
77
|
-
|
|
78
|
-
? Output directory: ./lib/src/models
|
|
79
|
-
? Sample size: 20
|
|
80
|
-
|
|
81
|
-
📋 Generation Summary:
|
|
82
|
-
────────────────────────────────────────────
|
|
83
|
-
Firebase Project: mi-proyecto
|
|
84
|
-
Collections: users, products
|
|
85
|
-
Subcollections:
|
|
86
|
-
└─ users: profiles, settings
|
|
87
|
-
Output: ./lib/src/models
|
|
88
|
-
Sample Size: 20 documents per collection
|
|
89
|
-
────────────────────────────────────────────
|
|
90
|
-
|
|
91
|
-
? Generate Dart models with these settings? (Y/n) y
|
|
92
|
-
|
|
93
|
-
🚀 Starting generation...
|
|
94
|
-
|
|
95
|
-
📦 Processing collection: users
|
|
96
|
-
Analyzing schema for users...
|
|
97
|
-
✓ Detected 10 fields
|
|
98
|
-
✓ Generated UserDTO model
|
|
99
|
-
with 2 nested class(es)
|
|
100
|
-
✓ Written to: lib/src/models/user_dto.dart
|
|
101
|
-
|
|
102
|
-
📦 Processing subcollection: users/profiles
|
|
103
|
-
...
|
|
104
|
-
|
|
105
|
-
✨ Success! Generated 4 model(s)
|
|
106
|
-
|
|
107
|
-
Generated files:
|
|
108
|
-
✓ lib/src/models/user_dto.dart
|
|
109
|
-
✓ lib/src/models/profile_dto.dart
|
|
110
|
-
✓ lib/src/models/setting_dto.dart
|
|
111
|
-
✓ lib/src/models/product_dto.dart
|
|
112
|
-
|
|
113
|
-
📚 Next steps:
|
|
114
|
-
1. Review the generated files
|
|
115
|
-
2. Import the models in your Dart code
|
|
116
|
-
3. Add 'equatable' to your pubspec.yaml
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
|
-
## ⚙️ Configuración Avanzada
|
|
122
|
-
|
|
123
|
-
### Pre-seleccionar colecciones específicas
|
|
124
|
-
|
|
125
|
-
```yaml
|
|
126
|
-
collections:
|
|
127
|
-
- users
|
|
128
|
-
- products
|
|
129
|
-
- orders
|
|
130
|
-
- reviews
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Al ejecutar el CLI, estas 4 aparecerán **pre-seleccionadas con ✓**.
|
|
134
|
-
|
|
135
|
-
### Cambiar directorio de salida
|
|
136
|
-
|
|
137
|
-
```yaml
|
|
138
|
-
output:
|
|
139
|
-
directory: ./packages/core/lib/models
|
|
140
|
-
sampleSize: 50
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Override con CLI args
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
# Usa prod.json en lugar del del config
|
|
147
|
-
firestore-dart-gen --service-account prod.json
|
|
148
|
-
|
|
149
|
-
# Usa config custom
|
|
150
|
-
firestore-dart-gen --config my-config.yaml
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
|
|
155
|
-
## 🎯 Casos de Uso
|
|
156
|
-
|
|
157
|
-
### Desarrollo diario
|
|
158
|
-
```yaml
|
|
159
|
-
# firestore-dart-gen.yaml
|
|
160
|
-
firebase:
|
|
161
|
-
serviceAccount: ./dev-credentials.json
|
|
162
|
-
|
|
163
|
-
collections:
|
|
164
|
-
- users
|
|
165
|
-
- products
|
|
166
|
-
|
|
167
|
-
output:
|
|
168
|
-
directory: ./lib/src/models
|
|
169
|
-
sampleSize: 10 # Rápido para desarrollo
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
firestore-dart-gen # ¡Eso es todo!
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Diferentes ambientes
|
|
177
|
-
|
|
178
|
-
```bash
|
|
179
|
-
# Desarrollo
|
|
180
|
-
firestore-dart-gen --service-account dev.json
|
|
181
|
-
|
|
182
|
-
# Staging
|
|
183
|
-
firestore-dart-gen --service-account staging.json
|
|
184
|
-
|
|
185
|
-
# Producción
|
|
186
|
-
firestore-dart-gen --service-account prod.json
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
Las colecciones pre-seleccionadas permanecen, solo cambias credenciales.
|
|
190
|
-
|
|
191
|
-
---
|
|
192
|
-
|
|
193
|
-
## 🔧 Comandos Útiles
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
# Desarrollo con config
|
|
197
|
-
npm run dev
|
|
198
|
-
|
|
199
|
-
# Desarrollo con service account específico
|
|
200
|
-
npm run dev -- --service-account credentials.json
|
|
201
|
-
|
|
202
|
-
# Con config custom
|
|
203
|
-
npm run dev -- --config other-config.yaml
|
|
204
|
-
|
|
205
|
-
# Ver help
|
|
206
|
-
npm run dev -- --help
|
|
207
|
-
|
|
208
|
-
# Build y ejecutar producción
|
|
209
|
-
npm run build
|
|
210
|
-
npm start
|
|
211
|
-
|
|
212
|
-
# Ejecutar tests
|
|
213
|
-
npm test
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
---
|
|
217
|
-
|
|
218
|
-
## 📚 Más Información
|
|
219
|
-
|
|
220
|
-
- **Guía Completa**: [`CONFIG_FILE_GUIDE.md`](CONFIG_FILE_GUIDE.md)
|
|
221
|
-
- **Archivo Ejemplo**: [`firestore-dart-gen.example.yaml`](firestore-dart-gen.example.yaml)
|
|
222
|
-
- **README Principal**: [`README.md`](README.md)
|
|
223
|
-
- **Testing**: [`TESTING.md`](TESTING.md)
|
|
224
|
-
- **Publicación**: [`PUBLICACION_NPM.md`](PUBLICACION_NPM.md)
|
|
225
|
-
|
|
226
|
-
---
|
|
227
|
-
|
|
228
|
-
## ✅ Checklist para Empezar
|
|
229
|
-
|
|
230
|
-
- [ ] Crear `firestore-dart-gen.yaml` desde el ejemplo
|
|
231
|
-
- [ ] Configurar path de service account
|
|
232
|
-
- [ ] Listar colecciones que usas frecuentemente
|
|
233
|
-
- [ ] Ejecutar `npm run dev`
|
|
234
|
-
- [ ] Seleccionar colecciones (pre-seleccionadas por ti)
|
|
235
|
-
- [ ] Revisar modelos generados
|
|
236
|
-
- [ ] ¡Listo para usar en tu app Flutter!
|
|
237
|
-
|
|
238
|
-
---
|
|
239
|
-
|
|
240
|
-
🎉 **¡Disfruta del nuevo sistema de configuración!**
|
|
241
|
-
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export interface CLIConfig {
|
|
2
|
-
firebase?: {
|
|
3
|
-
serviceAccount?: string;
|
|
4
|
-
projectId?: string;
|
|
5
|
-
};
|
|
6
|
-
collections?: string[];
|
|
7
|
-
output?: {
|
|
8
|
-
directory?: string;
|
|
9
|
-
sampleSize?: number;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export declare class ConfigFileLoader {
|
|
13
|
-
private static CONFIG_FILES;
|
|
14
|
-
/**
|
|
15
|
-
* Load configuration from YAML file if exists
|
|
16
|
-
*/
|
|
17
|
-
static loadConfig(configPath?: string): CLIConfig | null;
|
|
18
|
-
/**
|
|
19
|
-
* Load config from specific path
|
|
20
|
-
*/
|
|
21
|
-
private static loadFromPath;
|
|
22
|
-
/**
|
|
23
|
-
* Validate configuration structure
|
|
24
|
-
*/
|
|
25
|
-
private static validateConfig;
|
|
26
|
-
/**
|
|
27
|
-
* Resolve service account path
|
|
28
|
-
*/
|
|
29
|
-
static resolveServiceAccountPath(config: CLIConfig | null, cliArg?: string): string | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Resolve project ID
|
|
32
|
-
*/
|
|
33
|
-
static resolveProjectId(config: CLIConfig | null, cliArg?: string): string | undefined;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=config-file-loader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-file-loader.d.ts","sourceRoot":"","sources":["../src/config-file-loader.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE;QACT,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,YAAY,CAKzB;IAEF;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAkBxD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAe3B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAoB7B;;OAEG;IACH,MAAM,CAAC,yBAAyB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAS/F;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAMvF"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.ConfigFileLoader = void 0;
|
|
40
|
-
const fs = __importStar(require("fs"));
|
|
41
|
-
const path = __importStar(require("path"));
|
|
42
|
-
const yaml = __importStar(require("js-yaml"));
|
|
43
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
44
|
-
class ConfigFileLoader {
|
|
45
|
-
/**
|
|
46
|
-
* Load configuration from YAML file if exists
|
|
47
|
-
*/
|
|
48
|
-
static loadConfig(configPath) {
|
|
49
|
-
// If path provided, try to load it
|
|
50
|
-
if (configPath) {
|
|
51
|
-
return this.loadFromPath(configPath);
|
|
52
|
-
}
|
|
53
|
-
// Try default config file names
|
|
54
|
-
for (const fileName of this.CONFIG_FILES) {
|
|
55
|
-
const filePath = path.resolve(process.cwd(), fileName);
|
|
56
|
-
if (fs.existsSync(filePath)) {
|
|
57
|
-
console.log(chalk_1.default.gray(`📄 Found config file: ${fileName}\n`));
|
|
58
|
-
return this.loadFromPath(filePath);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Load config from specific path
|
|
65
|
-
*/
|
|
66
|
-
static loadFromPath(filePath) {
|
|
67
|
-
try {
|
|
68
|
-
const fileContents = fs.readFileSync(filePath, 'utf8');
|
|
69
|
-
const config = yaml.load(fileContents);
|
|
70
|
-
// Validate basic structure
|
|
71
|
-
this.validateConfig(config);
|
|
72
|
-
return config;
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
console.error(chalk_1.default.yellow(`⚠ Could not load config file: ${error}`));
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Validate configuration structure
|
|
81
|
-
*/
|
|
82
|
-
static validateConfig(config) {
|
|
83
|
-
// Validate service account path if provided
|
|
84
|
-
if (config.firebase?.serviceAccount) {
|
|
85
|
-
const fullPath = path.resolve(process.cwd(), config.firebase.serviceAccount);
|
|
86
|
-
if (!fs.existsSync(fullPath)) {
|
|
87
|
-
console.warn(chalk_1.default.yellow(`⚠ Service account file not found: ${config.firebase.serviceAccount}`));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// Validate collections is array if provided
|
|
91
|
-
if (config.collections && !Array.isArray(config.collections)) {
|
|
92
|
-
throw new Error('Config error: collections must be an array');
|
|
93
|
-
}
|
|
94
|
-
// Validate sample size if provided
|
|
95
|
-
if (config.output?.sampleSize && config.output.sampleSize < 1) {
|
|
96
|
-
throw new Error('Config error: sampleSize must be greater than 0');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Resolve service account path
|
|
101
|
-
*/
|
|
102
|
-
static resolveServiceAccountPath(config, cliArg) {
|
|
103
|
-
// Priority: CLI argument > config file > env variable
|
|
104
|
-
if (cliArg)
|
|
105
|
-
return cliArg;
|
|
106
|
-
if (config?.firebase?.serviceAccount) {
|
|
107
|
-
return path.resolve(process.cwd(), config.firebase.serviceAccount);
|
|
108
|
-
}
|
|
109
|
-
return process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Resolve project ID
|
|
113
|
-
*/
|
|
114
|
-
static resolveProjectId(config, cliArg) {
|
|
115
|
-
// Priority: CLI argument > config file > env variable
|
|
116
|
-
if (cliArg)
|
|
117
|
-
return cliArg;
|
|
118
|
-
if (config?.firebase?.projectId)
|
|
119
|
-
return config.firebase.projectId;
|
|
120
|
-
return process.env.FIREBASE_PROJECT_ID;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.ConfigFileLoader = ConfigFileLoader;
|
|
124
|
-
ConfigFileLoader.CONFIG_FILES = [
|
|
125
|
-
'firestore-dart-gen.yaml',
|
|
126
|
-
'firestore-dart-gen.yml',
|
|
127
|
-
'.firestore-dart-gen.yaml',
|
|
128
|
-
'.firestore-dart-gen.yml',
|
|
129
|
-
];
|
|
130
|
-
//# sourceMappingURL=config-file-loader.js.map
|