@icarusmx/creta 1.5.16 → 1.5.17
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/lib/data/command-help/curl.js +228 -38
- package/package.json +1 -1
|
@@ -1,80 +1,270 @@
|
|
|
1
1
|
export const curl = {
|
|
2
2
|
command: 'curl',
|
|
3
|
-
description: 'Realiza peticiones HTTP desde la terminal -
|
|
3
|
+
description: 'Realiza peticiones HTTP desde la terminal - para APIs y descargar scripts',
|
|
4
4
|
usage: 'curl [opciones] [URL]',
|
|
5
|
+
|
|
6
|
+
learningPath: {
|
|
7
|
+
intro: 'curl tiene dos usos principales: trabajar con APIs y descargar scripts',
|
|
8
|
+
progression: [
|
|
9
|
+
'Primero: Aprende cada flag individual (-L, -s, -f, -S)',
|
|
10
|
+
'Segundo: Combínalos para formar -fsSL',
|
|
11
|
+
'Tercero: Úsalo en instalaciones reales (curl -fsSL url | bash)',
|
|
12
|
+
'Cuarto: Aplícalo a APIs REST (-X, -H, -d)'
|
|
13
|
+
],
|
|
14
|
+
goal: 'Dominar -fsSL te hace ver profesional. Lo verás en toda instalación de herramientas.'
|
|
15
|
+
},
|
|
16
|
+
|
|
5
17
|
commonOptions: [
|
|
6
18
|
{
|
|
7
|
-
flag: '-
|
|
8
|
-
description: '
|
|
19
|
+
flag: '-L',
|
|
20
|
+
description: 'Sigue redirects automáticamente',
|
|
21
|
+
why: 'Las URLs pueden redirigir. Sin -L, curl se detiene en la primera respuesta',
|
|
22
|
+
example: 'curl -L https://bit.ly/ejemplo',
|
|
23
|
+
level: 1
|
|
9
24
|
},
|
|
10
25
|
{
|
|
11
|
-
flag: '-
|
|
12
|
-
description: '
|
|
26
|
+
flag: '-s',
|
|
27
|
+
description: 'Modo silencioso - oculta la barra de progreso',
|
|
28
|
+
why: 'El progreso es ruido visual cuando haces piping o scripts',
|
|
29
|
+
example: 'curl -s https://api.ejemplo.com | jq',
|
|
30
|
+
level: 2
|
|
13
31
|
},
|
|
14
32
|
{
|
|
15
|
-
flag: '-
|
|
16
|
-
description: '
|
|
33
|
+
flag: '-f',
|
|
34
|
+
description: 'Falla visiblemente en errores HTTP (400+, 500+)',
|
|
35
|
+
why: 'Sin esto, curl devuelve el HTML de error como si fuera éxito',
|
|
36
|
+
example: 'curl -f https://api.ejemplo.com/404',
|
|
37
|
+
level: 3
|
|
17
38
|
},
|
|
18
39
|
{
|
|
19
|
-
flag: '-
|
|
20
|
-
description: '
|
|
40
|
+
flag: '-S',
|
|
41
|
+
description: 'Muestra errores incluso en modo silencioso',
|
|
42
|
+
why: 'Para combinar con -s: silencioso pero con errores visibles',
|
|
43
|
+
example: 'curl -sS https://api.ejemplo.com',
|
|
44
|
+
level: 4
|
|
21
45
|
},
|
|
22
46
|
{
|
|
23
|
-
flag: '-
|
|
24
|
-
description: '
|
|
47
|
+
flag: '-fsSL',
|
|
48
|
+
description: 'EL COMBO DEFINITIVO - Siempre úsalo para instalar herramientas',
|
|
49
|
+
why: 'Combina todo: fail on error + silent + show errors + follow redirects',
|
|
50
|
+
example: 'curl -fsSL https://deno.land/install.sh | bash',
|
|
51
|
+
level: 5,
|
|
52
|
+
note: 'Este patrón aparece en TODAS las instalaciones profesionales'
|
|
25
53
|
},
|
|
26
54
|
{
|
|
27
|
-
flag: '-
|
|
28
|
-
description: '
|
|
55
|
+
flag: '-X METHOD',
|
|
56
|
+
description: 'Especifica método HTTP: GET, POST, PUT, DELETE',
|
|
57
|
+
context: 'APIs REST',
|
|
58
|
+
example: 'curl -X POST https://api.ejemplo.com/users'
|
|
29
59
|
},
|
|
30
60
|
{
|
|
31
|
-
flag: '-
|
|
32
|
-
description: '
|
|
61
|
+
flag: '-H "Header: valor"',
|
|
62
|
+
description: 'Agrega headers HTTP a la petición',
|
|
63
|
+
context: 'Content-Type, Authorization, etc.',
|
|
64
|
+
example: 'curl -H "Content-Type: application/json"'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
flag: '-d "data"',
|
|
68
|
+
description: 'Envía datos en el body (JSON, form data)',
|
|
69
|
+
context: 'POST/PUT requests',
|
|
70
|
+
example: 'curl -d \'{"nombre": "Juan"}\''
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
flag: '-i',
|
|
74
|
+
description: 'Incluye headers de respuesta en output',
|
|
75
|
+
context: 'Ver status codes: 200 OK, 404 Not Found, 500 Error',
|
|
76
|
+
example: 'curl -i https://api.ejemplo.com'
|
|
33
77
|
},
|
|
34
78
|
{
|
|
35
79
|
flag: '-v',
|
|
36
|
-
description: 'Modo verbose
|
|
80
|
+
description: 'Modo verbose - muestra request y response completos',
|
|
81
|
+
context: 'Debugging profundo',
|
|
82
|
+
example: 'curl -v https://api.ejemplo.com'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
flag: '-o archivo',
|
|
86
|
+
description: 'Guarda output en archivo',
|
|
87
|
+
context: 'Descargar recursos',
|
|
88
|
+
example: 'curl -o data.json https://api.ejemplo.com/data'
|
|
37
89
|
}
|
|
38
90
|
],
|
|
91
|
+
|
|
39
92
|
examples: [
|
|
40
93
|
{
|
|
41
|
-
|
|
42
|
-
|
|
94
|
+
title: 'LA PROGRESIÓN: Construyendo hacia -fsSL',
|
|
95
|
+
commands: [
|
|
96
|
+
{
|
|
97
|
+
command: 'curl https://api.github.com',
|
|
98
|
+
step: 'Paso 1: GET básico',
|
|
99
|
+
output: 'Verás barra de progreso y datos',
|
|
100
|
+
problema: 'Demasiado ruido visual'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
command: 'curl -L https://nodejs.org/install',
|
|
104
|
+
step: 'Paso 2: + sigue redirects',
|
|
105
|
+
output: 'Sigue automáticamente si la URL redirige',
|
|
106
|
+
mejora: 'Ahora funciona con URLs acortadas'
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
command: 'curl -sL https://nodejs.org/install',
|
|
110
|
+
step: 'Paso 3: + modo silencioso',
|
|
111
|
+
output: 'Sin barra de progreso, solo datos',
|
|
112
|
+
mejora: 'Output limpio, listo para piping'
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
command: 'curl -fsSL https://deno.land/install.sh',
|
|
116
|
+
step: 'Paso 4: + falla en errores + muestra errores',
|
|
117
|
+
output: 'El combo completo',
|
|
118
|
+
nivel: 'PROFESIONAL - Memoriza esto'
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
command: 'curl -fsSL https://deno.land/install.sh | bash',
|
|
122
|
+
step: 'Paso 5: + ejecuta con piping',
|
|
123
|
+
output: 'Descarga e instala en un comando',
|
|
124
|
+
uso: 'Así instalan los profesionales'
|
|
125
|
+
}
|
|
126
|
+
]
|
|
43
127
|
},
|
|
44
128
|
{
|
|
45
|
-
|
|
46
|
-
|
|
129
|
+
title: 'CASOS REALES: Instalaciones que verás constantemente',
|
|
130
|
+
commands: [
|
|
131
|
+
{
|
|
132
|
+
command: 'curl -fsSL https://get.docker.com | sh',
|
|
133
|
+
tool: 'Docker',
|
|
134
|
+
note: 'Containerización'
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
command: 'curl -fsSL https://deno.land/install.sh | sh',
|
|
138
|
+
tool: 'Deno',
|
|
139
|
+
note: 'Runtime de JavaScript/TypeScript'
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
command: 'curl -fsSL https://sh.rustup.rs | sh',
|
|
143
|
+
tool: 'Rust',
|
|
144
|
+
note: 'Lenguaje de sistemas'
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
command: 'curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash',
|
|
148
|
+
tool: 'Homebrew',
|
|
149
|
+
note: 'Package manager para macOS'
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
command: 'curl -fsSL https://get.pnpm.io/install.sh | sh',
|
|
153
|
+
tool: 'pnpm',
|
|
154
|
+
note: 'Package manager rápido'
|
|
155
|
+
}
|
|
156
|
+
]
|
|
47
157
|
},
|
|
48
158
|
{
|
|
49
|
-
|
|
50
|
-
|
|
159
|
+
title: 'TRABAJANDO CON APIs REST',
|
|
160
|
+
commands: [
|
|
161
|
+
{
|
|
162
|
+
command: 'curl https://api.github.com/users/octocat',
|
|
163
|
+
use: 'GET simple - API pública',
|
|
164
|
+
response: 'JSON con datos del usuario'
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
command: 'curl -X POST https://httpbin.org/post -H "Content-Type: application/json" -d \'{"nombre": "Juan", "edad": 25}\'',
|
|
168
|
+
use: 'POST con JSON - enviar datos',
|
|
169
|
+
response: 'Echo del servidor con tus datos'
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
command: 'curl -H "Authorization: Bearer TOKEN" https://api.ejemplo.com/protected',
|
|
173
|
+
use: 'GET autenticado - API privada',
|
|
174
|
+
response: 'Recursos protegidos'
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
command: 'curl -X PUT https://api.ejemplo.com/users/123 -H "Content-Type: application/json" -d \'{"nombre": "Juan Actualizado"}\'',
|
|
178
|
+
use: 'PUT - actualizar recurso',
|
|
179
|
+
response: 'Recurso modificado'
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
command: 'curl -X DELETE https://api.ejemplo.com/users/123 -H "Authorization: Bearer TOKEN"',
|
|
183
|
+
use: 'DELETE - eliminar recurso',
|
|
184
|
+
response: 'Confirmación de eliminación'
|
|
185
|
+
}
|
|
186
|
+
]
|
|
51
187
|
},
|
|
52
188
|
{
|
|
53
|
-
|
|
54
|
-
|
|
189
|
+
title: 'DEBUGGING: Cuando las cosas no funcionan',
|
|
190
|
+
commands: [
|
|
191
|
+
{
|
|
192
|
+
command: 'curl -i https://api.ejemplo.com',
|
|
193
|
+
purpose: 'Ver headers de respuesta',
|
|
194
|
+
verás: 'HTTP/1.1 200 OK, Content-Type, etc.'
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
command: 'curl -v https://api.ejemplo.com',
|
|
198
|
+
purpose: 'Ver comunicación completa',
|
|
199
|
+
verás: 'Request headers, response headers, handshake SSL, etc.'
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
command: 'curl -f https://api.ejemplo.com/404',
|
|
203
|
+
purpose: 'Forzar error visible en 404/500',
|
|
204
|
+
verás: 'curl: (22) The requested URL returned error: 404'
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
command: 'curl -w "\\nStatus: %{http_code}\\n" https://api.ejemplo.com',
|
|
208
|
+
purpose: 'Mostrar solo el status code',
|
|
209
|
+
verás: 'Status: 200'
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
|
|
215
|
+
relatedLesson: 'APIs y HTTP',
|
|
216
|
+
|
|
217
|
+
tips: [
|
|
218
|
+
'REGLA DE ORO: curl -fsSL url | bash es el patrón universal para instalaciones',
|
|
219
|
+
'Desglose de -fsSL: (f)ail on error + (s)ilent + (S)how errors + (L)ocation',
|
|
220
|
+
'Para APIs: curl -X POST -H "Content-Type: application/json" -d \'{"key":"val"}\'',
|
|
221
|
+
'Para ver status codes: curl -i (headers) o curl -v (todo)',
|
|
222
|
+
'Siempre usa -L con URLs acortadas o que pueden redirigir'
|
|
223
|
+
],
|
|
224
|
+
|
|
225
|
+
commonMistakes: [
|
|
226
|
+
{
|
|
227
|
+
error: 'Olvidar -L cuando la URL redirige',
|
|
228
|
+
resultado: 'Verás HTML de redirect en vez del recurso',
|
|
229
|
+
solución: 'Siempre agrega -L por defecto'
|
|
55
230
|
},
|
|
56
231
|
{
|
|
57
|
-
|
|
58
|
-
|
|
232
|
+
error: 'No usar -f en scripts automatizados',
|
|
233
|
+
resultado: 'curl "tiene éxito" incluso con 404/500',
|
|
234
|
+
solución: 'Usa -f para que falle visiblemente'
|
|
59
235
|
},
|
|
60
236
|
{
|
|
61
|
-
|
|
62
|
-
|
|
237
|
+
error: 'Usar -v en scripts de producción',
|
|
238
|
+
resultado: 'Logs llenos de ruido innecesario',
|
|
239
|
+
solución: 'Usa -i para ver solo headers o -s para silencio'
|
|
63
240
|
},
|
|
64
241
|
{
|
|
65
|
-
|
|
66
|
-
|
|
242
|
+
error: 'Olvidar comillas en JSON',
|
|
243
|
+
resultado: 'curl -d {"key":"value"} falla (bash interpreta las llaves)',
|
|
244
|
+
solución: 'Siempre usa comillas simples: -d \'{"key":"value"}\''
|
|
67
245
|
},
|
|
68
246
|
{
|
|
69
|
-
|
|
70
|
-
|
|
247
|
+
error: 'No especificar Content-Type en POST',
|
|
248
|
+
resultado: 'El servidor no entiende el formato',
|
|
249
|
+
solución: 'Siempre agrega -H "Content-Type: application/json"'
|
|
71
250
|
}
|
|
72
251
|
],
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
252
|
+
|
|
253
|
+
proTips: [
|
|
254
|
+
{
|
|
255
|
+
tip: 'Combina curl con jq para parsear JSON',
|
|
256
|
+
command: 'curl -s https://api.github.com/users/octocat | jq .name',
|
|
257
|
+
output: '"The Octocat"'
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
tip: 'Usa alias para curl -fsSL',
|
|
261
|
+
command: 'alias curlsh="curl -fsSL"',
|
|
262
|
+
entonces: 'curlsh https://ejemplo.com/install.sh | bash'
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
tip: 'Guarda cookies para sesiones',
|
|
266
|
+
command: 'curl -c cookies.txt -d "user=juan" https://ejemplo.com/login',
|
|
267
|
+
luego: 'curl -b cookies.txt https://ejemplo.com/dashboard'
|
|
268
|
+
}
|
|
79
269
|
]
|
|
80
270
|
}
|