@icarusmx/creta 0.7.3 → 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 +127 -16
- 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,6 +579,53 @@ function showHelp() {
|
|
|
578
579
|
console.log(" construir comprensión real, no solo sintaxis.")
|
|
579
580
|
}
|
|
580
581
|
|
|
582
|
+
async function startMainMenu() {
|
|
583
|
+
const rl = createInterface({
|
|
584
|
+
input: process.stdin,
|
|
585
|
+
output: process.stdout
|
|
586
|
+
})
|
|
587
|
+
|
|
588
|
+
const askQuestion = (question) => {
|
|
589
|
+
return new Promise((resolve) => {
|
|
590
|
+
rl.question(question, resolve)
|
|
591
|
+
})
|
|
592
|
+
}
|
|
593
|
+
|
|
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
|
|
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)
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
581
629
|
async function startEnunciadosSelector() {
|
|
582
630
|
// Always try interactive mode first, fall back only if it fails
|
|
583
631
|
try {
|
|
@@ -590,27 +638,34 @@ async function startEnunciadosSelector() {
|
|
|
590
638
|
}
|
|
591
639
|
|
|
592
640
|
async function startEnunciadosSelectorInteractive() {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
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?")
|
|
596
648
|
console.log("Usa ↑/↓ para navegar, Enter para seleccionar, 'q' para salir\n")
|
|
597
649
|
|
|
598
650
|
let selectedIndex = 0
|
|
599
651
|
let running = true
|
|
600
652
|
|
|
601
653
|
// Enable raw mode to capture arrow keys
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
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
|
+
}
|
|
605
661
|
|
|
606
662
|
const renderOptions = () => {
|
|
607
663
|
// Clear previous output and move cursor to top
|
|
608
664
|
process.stdout.write('\x1b[2J')
|
|
609
665
|
process.stdout.write('\x1b[H')
|
|
610
666
|
|
|
611
|
-
console.log("🧠
|
|
612
|
-
console.log("
|
|
613
|
-
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?")
|
|
614
669
|
console.log("Usa ↑/↓ para navegar, Enter para seleccionar, 'q' para salir\n")
|
|
615
670
|
|
|
616
671
|
ENUNCIADOS.forEach((enunciado, index) => {
|
|
@@ -710,9 +765,8 @@ async function startEnunciadosSelectorFallback() {
|
|
|
710
765
|
}
|
|
711
766
|
|
|
712
767
|
try {
|
|
713
|
-
console.log("\n🧠
|
|
714
|
-
console.log("
|
|
715
|
-
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?")
|
|
716
770
|
console.log("")
|
|
717
771
|
|
|
718
772
|
ENUNCIADOS.forEach((enunciado, index) => {
|
|
@@ -758,3 +812,60 @@ async function startEnunciadosSelectorFallback() {
|
|
|
758
812
|
process.exit(1)
|
|
759
813
|
}
|
|
760
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
|
+
}
|