@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.
Files changed (2) hide show
  1. package/bin/creta.js +131 -32
  2. 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
- console.log("¡Bienvenida de vuelta! 🏛️")
53
- console.log("Retomemos desde donde nos quedamos: hagamos tu portafolio.\n")
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 enunciados selector
57
- await startEnunciadosSelector()
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 startEnunciadosSelector() {
582
- // Debug TTY detection
583
- const hasSetRawMode = typeof process.stdin.setRawMode === 'function'
584
- const isOutputTTY = process.stdout.isTTY
585
- const isInputTTY = process.stdin.isTTY
582
+ async function startMainMenu() {
583
+ const rl = createInterface({
584
+ input: process.stdin,
585
+ output: process.stdout
586
+ })
586
587
 
587
- // DEBUG: Show detection values for troubleshooting
588
- console.log(`DEBUG: hasSetRawMode=${hasSetRawMode}, isOutputTTY=${isOutputTTY}, isInputTTY=${isInputTTY}`)
588
+ const askQuestion = (question) => {
589
+ return new Promise((resolve) => {
590
+ rl.question(question, resolve)
591
+ })
592
+ }
589
593
 
590
- // Try interactive mode unless explicitly disabled
591
- if (hasSetRawMode && !process.env.CRETA_NO_INTERACTIVE) {
592
- try {
593
- return await startEnunciadosSelectorInteractive()
594
- } catch (error) {
595
- // If interactive mode fails, fall back to numbered selection
596
- console.log('\nCambiando a modo de selección numérica...\n')
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
- // Fallback to numbered selection
601
- return await startEnunciadosSelectorFallback()
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
- console.log("\n🧠 Los 6 Enunciados Fundamentales de Programación Orientada a Objetos")
606
- console.log("=" .repeat(70))
607
- console.log("¿Cuál de estos enunciados te genera más 'ruido' (curiosidad/confusión)?")
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
- process.stdin.setRawMode(true)
615
- process.stdin.resume()
616
- process.stdin.setEncoding('utf8')
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("🧠 Los 6 Enunciados Fundamentales de Programación Orientada a Objetos")
624
- console.log("=" .repeat(70))
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🧠 Los 6 Enunciados Fundamentales de Programación Orientada a Objetos")
726
- console.log("=" .repeat(70))
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icarusmx/creta",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "Salgamos de este laberinto.",
5
5
  "type": "module",
6
6
  "bin": {