@icarusmx/creta 0.7.2 → 0.8.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/bin/creta.js +131 -32
- package/package.json +1 -1
package/bin/creta.js
CHANGED
|
@@ -49,12 +49,13 @@ const ENUNCIADOS = [
|
|
|
49
49
|
const args = process.argv.slice(2)
|
|
50
50
|
const command = args[0]
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
console.log("
|
|
52
|
+
// Welcome message
|
|
53
|
+
console.log("🏛️ Bienvenido a Creta")
|
|
54
|
+
console.log("La escuela de software de icarus.mx\n")
|
|
54
55
|
|
|
55
56
|
if (!command) {
|
|
56
|
-
// Default behavior: show
|
|
57
|
-
await
|
|
57
|
+
// Default behavior: show main menu
|
|
58
|
+
await startMainMenu()
|
|
58
59
|
process.exit(0)
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -578,51 +579,93 @@ function showHelp() {
|
|
|
578
579
|
console.log(" construir comprensión real, no solo sintaxis.")
|
|
579
580
|
}
|
|
580
581
|
|
|
581
|
-
async function
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
582
|
+
async function startMainMenu() {
|
|
583
|
+
const rl = createInterface({
|
|
584
|
+
input: process.stdin,
|
|
585
|
+
output: process.stdout
|
|
586
|
+
})
|
|
586
587
|
|
|
587
|
-
|
|
588
|
-
|
|
588
|
+
const askQuestion = (question) => {
|
|
589
|
+
return new Promise((resolve) => {
|
|
590
|
+
rl.question(question, resolve)
|
|
591
|
+
})
|
|
592
|
+
}
|
|
589
593
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
594
|
+
try {
|
|
595
|
+
console.log("¿Qué quieres hacer hoy?")
|
|
596
|
+
console.log("")
|
|
597
|
+
console.log("1. 🧠 Conceptos - Explora los enunciados fundamentales")
|
|
598
|
+
console.log("2. 🚀 Proyectos - Crea tu portafolio personal")
|
|
599
|
+
console.log("")
|
|
600
|
+
|
|
601
|
+
const respuesta = await askQuestion("Elige una opción (1-2) o 'q' para salir: ")
|
|
602
|
+
|
|
603
|
+
if (respuesta.toLowerCase() === 'q') {
|
|
604
|
+
console.log("¡Hasta la vista! 👋")
|
|
605
|
+
rl.close()
|
|
606
|
+
return
|
|
597
607
|
}
|
|
608
|
+
|
|
609
|
+
const opcionSeleccionada = parseInt(respuesta)
|
|
610
|
+
|
|
611
|
+
if (opcionSeleccionada === 1) {
|
|
612
|
+
rl.close()
|
|
613
|
+
await startEnunciadosSelector()
|
|
614
|
+
} else if (opcionSeleccionada === 2) {
|
|
615
|
+
rl.close()
|
|
616
|
+
await startProyectosSelector()
|
|
617
|
+
} else {
|
|
618
|
+
console.log("❌ Opción no válida. Elige 1 o 2.")
|
|
619
|
+
rl.close()
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
} catch (error) {
|
|
623
|
+
console.error('Error:', error.message)
|
|
624
|
+
rl.close()
|
|
625
|
+
process.exit(1)
|
|
598
626
|
}
|
|
627
|
+
}
|
|
599
628
|
|
|
600
|
-
|
|
601
|
-
|
|
629
|
+
async function startEnunciadosSelector() {
|
|
630
|
+
// Always try interactive mode first, fall back only if it fails
|
|
631
|
+
try {
|
|
632
|
+
return await startEnunciadosSelectorInteractive()
|
|
633
|
+
} catch (error) {
|
|
634
|
+
// If interactive mode fails, fall back to numbered selection
|
|
635
|
+
console.log('\nModo interactivo no disponible, usando selección numérica...\n')
|
|
636
|
+
return await startEnunciadosSelectorFallback()
|
|
637
|
+
}
|
|
602
638
|
}
|
|
603
639
|
|
|
604
640
|
async function startEnunciadosSelectorInteractive() {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
641
|
+
// Check if setRawMode is available before trying to use it
|
|
642
|
+
if (typeof process.stdin.setRawMode !== 'function') {
|
|
643
|
+
throw new Error('setRawMode not available')
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
console.log("\n🧠 Conceptos Fundamentales")
|
|
647
|
+
console.log("¿Cuáles de estos enunciados quieres explorar?")
|
|
608
648
|
console.log("Usa ↑/↓ para navegar, Enter para seleccionar, 'q' para salir\n")
|
|
609
649
|
|
|
610
650
|
let selectedIndex = 0
|
|
611
651
|
let running = true
|
|
612
652
|
|
|
613
653
|
// Enable raw mode to capture arrow keys
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
654
|
+
try {
|
|
655
|
+
process.stdin.setRawMode(true)
|
|
656
|
+
process.stdin.resume()
|
|
657
|
+
process.stdin.setEncoding('utf8')
|
|
658
|
+
} catch (error) {
|
|
659
|
+
throw new Error('Failed to enable raw mode: ' + error.message)
|
|
660
|
+
}
|
|
617
661
|
|
|
618
662
|
const renderOptions = () => {
|
|
619
663
|
// Clear previous output and move cursor to top
|
|
620
664
|
process.stdout.write('\x1b[2J')
|
|
621
665
|
process.stdout.write('\x1b[H')
|
|
622
666
|
|
|
623
|
-
console.log("🧠
|
|
624
|
-
console.log("
|
|
625
|
-
console.log("¿Cuál de estos enunciados te genera más 'ruido' (curiosidad/confusión)?")
|
|
667
|
+
console.log("🧠 Conceptos Fundamentales")
|
|
668
|
+
console.log("¿Cuáles de estos enunciados quieres explorar?")
|
|
626
669
|
console.log("Usa ↑/↓ para navegar, Enter para seleccionar, 'q' para salir\n")
|
|
627
670
|
|
|
628
671
|
ENUNCIADOS.forEach((enunciado, index) => {
|
|
@@ -722,9 +765,8 @@ async function startEnunciadosSelectorFallback() {
|
|
|
722
765
|
}
|
|
723
766
|
|
|
724
767
|
try {
|
|
725
|
-
console.log("\n🧠
|
|
726
|
-
console.log("
|
|
727
|
-
console.log("¿Cuál de estos enunciados te genera más 'ruido' (curiosidad/confusión)?")
|
|
768
|
+
console.log("\n🧠 Conceptos Fundamentales")
|
|
769
|
+
console.log("¿Cuáles de estos enunciados quieres explorar?")
|
|
728
770
|
console.log("")
|
|
729
771
|
|
|
730
772
|
ENUNCIADOS.forEach((enunciado, index) => {
|
|
@@ -770,3 +812,60 @@ async function startEnunciadosSelectorFallback() {
|
|
|
770
812
|
process.exit(1)
|
|
771
813
|
}
|
|
772
814
|
}
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
async function startProyectosSelector() {
|
|
818
|
+
const rl = createInterface({
|
|
819
|
+
input: process.stdin,
|
|
820
|
+
output: process.stdout
|
|
821
|
+
})
|
|
822
|
+
|
|
823
|
+
const askQuestion = (question) => {
|
|
824
|
+
return new Promise((resolve) => {
|
|
825
|
+
rl.question(question, resolve)
|
|
826
|
+
})
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
try {
|
|
830
|
+
console.log("\n🚀 Proyectos Disponibles")
|
|
831
|
+
console.log("¿Qué proyecto quieres crear?")
|
|
832
|
+
console.log("")
|
|
833
|
+
console.log("1. 🎨 Portafolio Personal - Reto completo")
|
|
834
|
+
console.log("2. 🔓 Portafolio Nivel 1 - Solo navbar")
|
|
835
|
+
console.log("3. 🔓 Portafolio Nivel 2 - Navbar + hero")
|
|
836
|
+
console.log("4. 🔓 Portafolio Nivel 3 - Solución completa")
|
|
837
|
+
console.log("")
|
|
838
|
+
|
|
839
|
+
const respuesta = await askQuestion("Elige una opción (1-4) o 'q' para salir: ")
|
|
840
|
+
|
|
841
|
+
if (respuesta.toLowerCase() === 'q') {
|
|
842
|
+
console.log("¡Hasta la vista! 👋")
|
|
843
|
+
rl.close()
|
|
844
|
+
return
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
const opcionSeleccionada = parseInt(respuesta)
|
|
848
|
+
|
|
849
|
+
if (opcionSeleccionada >= 1 && opcionSeleccionada <= 4) {
|
|
850
|
+
rl.close()
|
|
851
|
+
|
|
852
|
+
// Map selection to portfolio level
|
|
853
|
+
const level = opcionSeleccionada === 1 ? 0 : opcionSeleccionada - 1
|
|
854
|
+
|
|
855
|
+
// Check if we're in an existing Creta project
|
|
856
|
+
if (level > 0 && isInCretaProject()) {
|
|
857
|
+
await unstuckProject(level)
|
|
858
|
+
} else {
|
|
859
|
+
await createPortfolioProject(level)
|
|
860
|
+
}
|
|
861
|
+
} else {
|
|
862
|
+
console.log("❌ Opción no válida. Elige un número entre 1 y 4.")
|
|
863
|
+
rl.close()
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
} catch (error) {
|
|
867
|
+
console.error('Error:', error.message)
|
|
868
|
+
rl.close()
|
|
869
|
+
process.exit(1)
|
|
870
|
+
}
|
|
871
|
+
}
|