@icarusmx/creta 0.6.0 → 0.7.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.
Files changed (2) hide show
  1. package/bin/creta.js +114 -0
  2. package/package.json +1 -1
package/bin/creta.js CHANGED
@@ -579,6 +579,120 @@ function showHelp() {
579
579
  }
580
580
 
581
581
  async function startEnunciadosSelector() {
582
+ // Check if we have a proper TTY for interactive mode
583
+ if (!process.stdin.isTTY || !process.stdin.setRawMode) {
584
+ // Fallback to numbered selection
585
+ return await startEnunciadosSelectorFallback()
586
+ }
587
+
588
+ console.log("\n🧠 Los 6 Enunciados Fundamentales de Programación Orientada a Objetos")
589
+ console.log("=" .repeat(70))
590
+ console.log("¿Cuál de estos enunciados te genera más 'ruido' (curiosidad/confusión)?")
591
+ console.log("Usa ↑/↓ para navegar, Enter para seleccionar, 'q' para salir\n")
592
+
593
+ let selectedIndex = 0
594
+ let running = true
595
+
596
+ // Enable raw mode to capture arrow keys
597
+ process.stdin.setRawMode(true)
598
+ process.stdin.resume()
599
+ process.stdin.setEncoding('utf8')
600
+
601
+ const renderOptions = () => {
602
+ // Clear previous output and move cursor to top
603
+ process.stdout.write('\x1b[2J')
604
+ process.stdout.write('\x1b[H')
605
+
606
+ console.log("🧠 Los 6 Enunciados Fundamentales de Programación Orientada a Objetos")
607
+ console.log("=" .repeat(70))
608
+ console.log("¿Cuál de estos enunciados te genera más 'ruido' (curiosidad/confusión)?")
609
+ console.log("Usa ↑/↓ para navegar, Enter para seleccionar, 'q' para salir\n")
610
+
611
+ ENUNCIADOS.forEach((enunciado, index) => {
612
+ const isSelected = index === selectedIndex
613
+ const prefix = isSelected ? '▶ ' : ' '
614
+ const highlight = isSelected ? '\x1b[36m' : '\x1b[37m' // cyan for selected, white for normal
615
+ const reset = '\x1b[0m'
616
+
617
+ console.log(`${highlight}${prefix}${index + 1}. [${enunciado.nivel}] ${enunciado.enfoque}${reset}`)
618
+
619
+ if (isSelected) {
620
+ // Show full text for selected option with word wrapping
621
+ const maxWidth = 66
622
+ const words = enunciado.texto.split(' ')
623
+ let currentLine = ' "'
624
+
625
+ words.forEach(word => {
626
+ if (currentLine.length + word.length + 1 <= maxWidth) {
627
+ currentLine += (currentLine === ' "' ? '' : ' ') + word
628
+ } else {
629
+ console.log(`${highlight}${currentLine}${reset}`)
630
+ currentLine = ' ' + word
631
+ }
632
+ })
633
+
634
+ if (currentLine.length > 6) {
635
+ console.log(`${highlight}${currentLine}"${reset}`)
636
+ }
637
+ }
638
+ console.log("")
639
+ })
640
+ }
641
+
642
+ return new Promise((resolve) => {
643
+ renderOptions()
644
+
645
+ const onKeyPress = (key) => {
646
+ if (key === 'q' || key === '\x03') { // q or Ctrl+C
647
+ process.stdin.setRawMode(false)
648
+ process.stdin.removeListener('data', onKeyPress)
649
+ console.log("\n¡Hasta la vista! 👋")
650
+ resolve()
651
+ return
652
+ }
653
+
654
+ if (key === '\r' || key === '\n') { // Enter
655
+ process.stdin.setRawMode(false)
656
+ process.stdin.removeListener('data', onKeyPress)
657
+
658
+ const enunciadoSeleccionado = ENUNCIADOS[selectedIndex]
659
+
660
+ // Clear screen and show selection
661
+ process.stdout.write('\x1b[2J')
662
+ process.stdout.write('\x1b[H')
663
+
664
+ console.log(`🎯 Has seleccionado el enunciado ${selectedIndex + 1}:`)
665
+ console.log(`"${enunciadoSeleccionado.texto}"`)
666
+ console.log(`\n💡 Enfoque: ${enunciadoSeleccionado.enfoque}`)
667
+ console.log(`📚 Nivel: ${enunciadoSeleccionado.nivel}`)
668
+
669
+ console.log("\n🚀 Próximamente:")
670
+ console.log("- Sesiones de estudio dirigidas basadas en este enunciado")
671
+ console.log("- Ejercicios prácticos que ilustren el concepto")
672
+ console.log("- Proyectos específicos para internalizar la idea")
673
+
674
+ console.log("\n💭 Por ahora, reflexiona: ¿qué parte específica de este enunciado")
675
+ console.log(" te genera más curiosidad o confusión?")
676
+
677
+ resolve()
678
+ return
679
+ }
680
+
681
+ // Handle arrow keys (escape sequences)
682
+ if (key === '\u001b[A') { // Up arrow
683
+ selectedIndex = selectedIndex > 0 ? selectedIndex - 1 : ENUNCIADOS.length - 1
684
+ renderOptions()
685
+ } else if (key === '\u001b[B') { // Down arrow
686
+ selectedIndex = selectedIndex < ENUNCIADOS.length - 1 ? selectedIndex + 1 : 0
687
+ renderOptions()
688
+ }
689
+ }
690
+
691
+ process.stdin.on('data', onKeyPress)
692
+ })
693
+ }
694
+
695
+ async function startEnunciadosSelectorFallback() {
582
696
  const rl = createInterface({
583
697
  input: process.stdin,
584
698
  output: process.stdout
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icarusmx/creta",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Salgamos de este laberinto.",
5
5
  "type": "module",
6
6
  "bin": {