@icarusmx/creta 1.3.0 → 1.3.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.
- package/bin/creta.js +170 -27
- package/package.json +1 -1
package/bin/creta.js
CHANGED
|
@@ -622,8 +622,7 @@ async function startMainMenuInteractive() {
|
|
|
622
622
|
|
|
623
623
|
const options = [
|
|
624
624
|
{ id: 1, title: "Aprender conceptos", description: "Explora los enunciados fundamentales" },
|
|
625
|
-
{ id: 2, title: "Construir proyectos", description: "
|
|
626
|
-
{ id: 3, title: "Crea una pull-request", description: "Aprende el flujo de contribución con Git" }
|
|
625
|
+
{ id: 2, title: "Construir proyectos", description: "Practica con proyectos reales" }
|
|
627
626
|
]
|
|
628
627
|
|
|
629
628
|
let selectedIndex = 0
|
|
@@ -694,8 +693,6 @@ Salgamos de este laberinto 🏛️
|
|
|
694
693
|
startEnunciadosSelector().then(resolve)
|
|
695
694
|
} else if (selectedOption.id === 2) {
|
|
696
695
|
startProyectosSelector().then(resolve)
|
|
697
|
-
} else if (selectedOption.id === 3) {
|
|
698
|
-
startPullRequestTutorial().then(resolve)
|
|
699
696
|
}
|
|
700
697
|
return
|
|
701
698
|
}
|
|
@@ -730,11 +727,10 @@ async function startMainMenuFallback() {
|
|
|
730
727
|
console.log("Te ofrecemos las siguientes opciones:")
|
|
731
728
|
console.log("")
|
|
732
729
|
console.log("1. Aprender conceptos - Explora los enunciados fundamentales")
|
|
733
|
-
console.log("2. Construir proyectos -
|
|
734
|
-
console.log("3. Crea una pull-request - Aprende el flujo de contribución con Git")
|
|
730
|
+
console.log("2. Construir proyectos - Practica con proyectos reales")
|
|
735
731
|
console.log("")
|
|
736
732
|
|
|
737
|
-
const respuesta = await askQuestion("Elige una opción (1-
|
|
733
|
+
const respuesta = await askQuestion("Elige una opción (1-2) o 'q' para salir: ")
|
|
738
734
|
|
|
739
735
|
if (respuesta.toLowerCase() === 'q') {
|
|
740
736
|
console.log("Hecho con <3 por icarus.mx")
|
|
@@ -750,11 +746,8 @@ async function startMainMenuFallback() {
|
|
|
750
746
|
} else if (opcionSeleccionada === 2) {
|
|
751
747
|
rl.close()
|
|
752
748
|
await startProyectosSelector()
|
|
753
|
-
} else if (opcionSeleccionada === 3) {
|
|
754
|
-
rl.close()
|
|
755
|
-
await startPullRequestTutorial()
|
|
756
749
|
} else {
|
|
757
|
-
console.log("❌ Opción no válida. Elige 1
|
|
750
|
+
console.log("❌ Opción no válida. Elige 1 o 2.")
|
|
758
751
|
rl.close()
|
|
759
752
|
}
|
|
760
753
|
|
|
@@ -1241,14 +1234,12 @@ async function startProyectosSelectorInteractive() {
|
|
|
1241
1234
|
throw new Error('setRawMode not available')
|
|
1242
1235
|
}
|
|
1243
1236
|
|
|
1244
|
-
console.log("\n🚀 Proyectos
|
|
1245
|
-
console.log("
|
|
1237
|
+
console.log("\n🚀 Construir Proyectos")
|
|
1238
|
+
console.log("Elige qué proyecto quieres construir:")
|
|
1246
1239
|
|
|
1247
1240
|
const projects = [
|
|
1248
|
-
{ id: 1, title: "
|
|
1249
|
-
{ id: 2, title: "
|
|
1250
|
-
{ id: 3, title: "🔓 Portafolio Nivel 2", description: "Navbar + hero", level: 2 },
|
|
1251
|
-
{ id: 4, title: "🔓 Portafolio Nivel 3", description: "Solución completa", level: 3 }
|
|
1241
|
+
{ id: 1, title: "🔀 Construye una pull-request", type: 'pr' },
|
|
1242
|
+
{ id: 2, title: "🎨 Construye tu portafolio", type: 'portfolio' }
|
|
1252
1243
|
]
|
|
1253
1244
|
|
|
1254
1245
|
let selectedIndex = 0
|
|
@@ -1267,8 +1258,8 @@ async function startProyectosSelectorInteractive() {
|
|
|
1267
1258
|
process.stdout.write('\x1b[2J')
|
|
1268
1259
|
process.stdout.write('\x1b[H')
|
|
1269
1260
|
|
|
1270
|
-
console.log("🚀 Proyectos
|
|
1271
|
-
console.log("
|
|
1261
|
+
console.log("🚀 Construir Proyectos")
|
|
1262
|
+
console.log("Elige qué proyecto quieres construir:")
|
|
1272
1263
|
|
|
1273
1264
|
projects.forEach((project, index) => {
|
|
1274
1265
|
const isSelected = index === selectedIndex
|
|
@@ -1301,17 +1292,15 @@ async function startProyectosSelectorInteractive() {
|
|
|
1301
1292
|
process.stdin.removeListener('data', onKeyPress)
|
|
1302
1293
|
|
|
1303
1294
|
const selectedProject = projects[selectedIndex]
|
|
1304
|
-
const level = selectedProject.level
|
|
1305
1295
|
|
|
1306
1296
|
// Clear screen
|
|
1307
1297
|
process.stdout.write('\x1b[2J')
|
|
1308
1298
|
process.stdout.write('\x1b[H')
|
|
1309
1299
|
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
createPortfolioProject(level).then(resolve)
|
|
1300
|
+
if (selectedProject.type === 'pr') {
|
|
1301
|
+
startPullRequestTutorial().then(resolve)
|
|
1302
|
+
} else if (selectedProject.type === 'portfolio') {
|
|
1303
|
+
startPortfolioSelector().then(resolve)
|
|
1315
1304
|
}
|
|
1316
1305
|
return
|
|
1317
1306
|
}
|
|
@@ -1371,8 +1360,162 @@ async function startProyectosSelectorFallback() {
|
|
|
1371
1360
|
}
|
|
1372
1361
|
|
|
1373
1362
|
try {
|
|
1374
|
-
console.log("\n🚀 Proyectos
|
|
1375
|
-
console.log("
|
|
1363
|
+
console.log("\n🚀 Construir Proyectos")
|
|
1364
|
+
console.log("Elige qué proyecto quieres construir:")
|
|
1365
|
+
console.log("")
|
|
1366
|
+
console.log("1. 🔀 Construye una pull-request")
|
|
1367
|
+
console.log("2. 🎨 Construye tu portafolio")
|
|
1368
|
+
console.log("")
|
|
1369
|
+
|
|
1370
|
+
const respuesta = await askQuestion("Elige una opción (1-2) o 'q' para salir: ")
|
|
1371
|
+
|
|
1372
|
+
if (respuesta.toLowerCase() === 'q') {
|
|
1373
|
+
console.log("Hecho con <3 por icarus.mx")
|
|
1374
|
+
rl.close()
|
|
1375
|
+
return
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
const opcionSeleccionada = parseInt(respuesta)
|
|
1379
|
+
|
|
1380
|
+
if (opcionSeleccionada === 1) {
|
|
1381
|
+
rl.close()
|
|
1382
|
+
await startPullRequestTutorial()
|
|
1383
|
+
} else if (opcionSeleccionada === 2) {
|
|
1384
|
+
rl.close()
|
|
1385
|
+
await startPortfolioSelector()
|
|
1386
|
+
} else {
|
|
1387
|
+
console.log("❌ Opción no válida. Elige 1 o 2.")
|
|
1388
|
+
rl.close()
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
} catch (error) {
|
|
1392
|
+
console.error('Error:', error.message)
|
|
1393
|
+
rl.close()
|
|
1394
|
+
process.exit(1)
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
async function startPortfolioSelector() {
|
|
1399
|
+
// Always try interactive mode first, fall back only if it fails
|
|
1400
|
+
try {
|
|
1401
|
+
return await startPortfolioSelectorInteractive()
|
|
1402
|
+
} catch (error) {
|
|
1403
|
+
// If interactive mode fails, fall back to numbered selection
|
|
1404
|
+
console.log('\nModo interactivo no disponible, usando selección numérica...\n')
|
|
1405
|
+
return await startPortfolioSelectorFallback()
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
async function startPortfolioSelectorInteractive() {
|
|
1410
|
+
// Check if setRawMode is available before trying to use it
|
|
1411
|
+
if (typeof process.stdin.setRawMode !== 'function') {
|
|
1412
|
+
throw new Error('setRawMode not available')
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
console.log("\n🎨 Construye tu Portafolio")
|
|
1416
|
+
console.log("Elige el nivel:")
|
|
1417
|
+
|
|
1418
|
+
const projects = [
|
|
1419
|
+
{ id: 1, title: "🎨 Portafolio Personal", description: "Reto completo", level: 0 },
|
|
1420
|
+
{ id: 2, title: "🔓 Portafolio Nivel 1", description: "Solo navbar", level: 1 },
|
|
1421
|
+
{ id: 3, title: "🔓 Portafolio Nivel 2", description: "Navbar + hero", level: 2 },
|
|
1422
|
+
{ id: 4, title: "🔓 Portafolio Nivel 3", description: "Solución completa", level: 3 }
|
|
1423
|
+
]
|
|
1424
|
+
|
|
1425
|
+
let selectedIndex = 0
|
|
1426
|
+
|
|
1427
|
+
// Enable raw mode to capture arrow keys
|
|
1428
|
+
try {
|
|
1429
|
+
process.stdin.setRawMode(true)
|
|
1430
|
+
process.stdin.resume()
|
|
1431
|
+
process.stdin.setEncoding('utf8')
|
|
1432
|
+
} catch (error) {
|
|
1433
|
+
throw new Error('Failed to enable raw mode: ' + error.message)
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
const renderOptions = () => {
|
|
1437
|
+
// Clear previous output and move cursor to top
|
|
1438
|
+
process.stdout.write('\x1b[2J')
|
|
1439
|
+
process.stdout.write('\x1b[H')
|
|
1440
|
+
|
|
1441
|
+
console.log("🎨 Construye tu Portafolio")
|
|
1442
|
+
console.log("Elige el nivel:")
|
|
1443
|
+
|
|
1444
|
+
projects.forEach((project, index) => {
|
|
1445
|
+
const isSelected = index === selectedIndex
|
|
1446
|
+
const prefix = isSelected ? '▶ ' : ' '
|
|
1447
|
+
const highlight = isSelected ? '\x1b[36m' : '\x1b[37m' // cyan for selected, white for normal
|
|
1448
|
+
const reset = '\x1b[0m'
|
|
1449
|
+
|
|
1450
|
+
console.log(`${highlight}${prefix}${project.title}${reset}`)
|
|
1451
|
+
if (isSelected) {
|
|
1452
|
+
console.log(`${highlight} ${project.description}${reset}`)
|
|
1453
|
+
}
|
|
1454
|
+
console.log("")
|
|
1455
|
+
})
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
return new Promise((resolve) => {
|
|
1459
|
+
renderOptions()
|
|
1460
|
+
|
|
1461
|
+
const onKeyPress = (key) => {
|
|
1462
|
+
if (key === 'q' || key === '\x03') { // q or Ctrl+C
|
|
1463
|
+
process.stdin.setRawMode(false)
|
|
1464
|
+
process.stdin.removeListener('data', onKeyPress)
|
|
1465
|
+
console.log("\nHecho con <3 por icarus.mx")
|
|
1466
|
+
resolve()
|
|
1467
|
+
return
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
if (key === '\r' || key === '\n') { // Enter
|
|
1471
|
+
process.stdin.setRawMode(false)
|
|
1472
|
+
process.stdin.removeListener('data', onKeyPress)
|
|
1473
|
+
|
|
1474
|
+
const selectedProject = projects[selectedIndex]
|
|
1475
|
+
const level = selectedProject.level
|
|
1476
|
+
|
|
1477
|
+
// Clear screen
|
|
1478
|
+
process.stdout.write('\x1b[2J')
|
|
1479
|
+
process.stdout.write('\x1b[H')
|
|
1480
|
+
|
|
1481
|
+
// Check if we're in an existing Creta project
|
|
1482
|
+
if (level > 0 && isInCretaProject()) {
|
|
1483
|
+
unstuckProject(level).then(resolve)
|
|
1484
|
+
} else {
|
|
1485
|
+
createPortfolioProject(level).then(resolve)
|
|
1486
|
+
}
|
|
1487
|
+
return
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
// Handle arrow keys (escape sequences)
|
|
1491
|
+
if (key === '\u001b[A') { // Up arrow
|
|
1492
|
+
selectedIndex = selectedIndex > 0 ? selectedIndex - 1 : projects.length - 1
|
|
1493
|
+
renderOptions()
|
|
1494
|
+
} else if (key === '\u001b[B') { // Down arrow
|
|
1495
|
+
selectedIndex = selectedIndex < projects.length - 1 ? selectedIndex + 1 : 0
|
|
1496
|
+
renderOptions()
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
process.stdin.on('data', onKeyPress)
|
|
1501
|
+
})
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
async function startPortfolioSelectorFallback() {
|
|
1505
|
+
const rl = createInterface({
|
|
1506
|
+
input: process.stdin,
|
|
1507
|
+
output: process.stdout
|
|
1508
|
+
})
|
|
1509
|
+
|
|
1510
|
+
const askQuestion = (question) => {
|
|
1511
|
+
return new Promise((resolve) => {
|
|
1512
|
+
rl.question(question, resolve)
|
|
1513
|
+
})
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
try {
|
|
1517
|
+
console.log("\n🎨 Construye tu Portafolio")
|
|
1518
|
+
console.log("Elige el nivel:")
|
|
1376
1519
|
console.log("")
|
|
1377
1520
|
console.log("1. 🎨 Portafolio Personal - Reto completo")
|
|
1378
1521
|
console.log("2. 🔓 Portafolio Nivel 1 - Solo navbar")
|