@icarusmx/creta 1.5.1 → 1.5.3

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 CHANGED
@@ -9,13 +9,14 @@ import { CretaCodeSession } from '../lib/session.js'
9
9
  import { PullRequestTutorial } from '../lib/pr-tutorial.js'
10
10
  import { CommandHelpExecutor } from '../lib/executors/CommandHelpExecutor.js'
11
11
  import { PapersExecutor } from '../lib/papers/PapersExecutor.js'
12
- import { Lesson1SystemDecomposition } from '../lessons/lesson1-system-decomposition.js'
13
- import { Lesson2ObjectRequests } from '../lessons/lesson2-object-requests.js'
14
- import { Lesson3OnlyWay } from '../lessons/lesson3-only-way.js'
15
- import { Lesson4OperationSignatures } from '../lessons/lesson4-operation-signatures.js'
16
- import { Lesson5InterfaceSet } from '../lessons/lesson5-interface-set.js'
17
- import { Lesson6InterfaceDesign } from '../lessons/lesson6-interface-design.js'
18
- import { Lesson7ObjectDefinition } from '../lessons/lesson7-object-definition.js'
12
+ import { LessonBuilder } from '../lib/builders/LessonBuilder.js'
13
+ import { LESSON_1_SYSTEM_DECOMPOSITION } from '../lib/data/lessons/lesson1-system-decomposition.js'
14
+ import { LESSON_2_OBJECT_REQUESTS } from '../lib/data/lessons/lesson2-object-requests.js'
15
+ import { LESSON_3_ONLY_WAY } from '../lib/data/lessons/lesson3-only-way.js'
16
+ import { LESSON_4_OPERATION_SIGNATURES } from '../lib/data/lessons/lesson4-operation-signatures.js'
17
+ import { LESSON_5_INTERFACE_SET } from '../lib/data/lessons/lesson5-interface-set.js'
18
+ import { LESSON_6_INTERFACE_DESIGN } from '../lib/data/lessons/lesson6-interface-design.js'
19
+ import { LESSON_7_OBJECT_DEFINITION } from '../lib/data/lessons/lesson7-object-definition.js'
19
20
 
20
21
  const ENUNCIADOS = [
21
22
  {
@@ -892,7 +893,7 @@ async function startEnunciadosSelectorInteractive() {
892
893
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
893
894
 
894
895
  try {
895
- const lesson1 = new Lesson1SystemDecomposition()
896
+ const lesson1 = new LessonBuilder(LESSON_1_SYSTEM_DECOMPOSITION)
896
897
  await lesson1.start()
897
898
  await returnToMainMenu()
898
899
  } catch (error) {
@@ -908,7 +909,7 @@ async function startEnunciadosSelectorInteractive() {
908
909
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
909
910
 
910
911
  try {
911
- const lesson1 = new Lesson1SystemDecomposition()
912
+ const lesson1 = new LessonBuilder(LESSON_1_SYSTEM_DECOMPOSITION)
912
913
  await lesson1.start()
913
914
  await returnToMainMenu()
914
915
  } catch (error) {
@@ -924,7 +925,7 @@ async function startEnunciadosSelectorInteractive() {
924
925
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
925
926
 
926
927
  try {
927
- const lesson2 = new Lesson2ObjectRequests()
928
+ const lesson2 = new LessonBuilder(LESSON_2_OBJECT_REQUESTS)
928
929
  await lesson2.start()
929
930
  await returnToMainMenu()
930
931
  } catch (error) {
@@ -940,7 +941,7 @@ async function startEnunciadosSelectorInteractive() {
940
941
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
941
942
 
942
943
  try {
943
- const lesson3 = new Lesson3OnlyWay()
944
+ const lesson3 = new LessonBuilder(LESSON_3_ONLY_WAY)
944
945
  await lesson3.start()
945
946
  await returnToMainMenu()
946
947
  } catch (error) {
@@ -956,7 +957,7 @@ async function startEnunciadosSelectorInteractive() {
956
957
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
957
958
 
958
959
  try {
959
- const lesson4 = new Lesson4OperationSignatures()
960
+ const lesson4 = new LessonBuilder(LESSON_4_OPERATION_SIGNATURES)
960
961
  await lesson4.start()
961
962
  await returnToMainMenu()
962
963
  } catch (error) {
@@ -972,7 +973,7 @@ async function startEnunciadosSelectorInteractive() {
972
973
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
973
974
 
974
975
  try {
975
- const lesson5 = new Lesson5InterfaceSet()
976
+ const lesson5 = new LessonBuilder(LESSON_5_INTERFACE_SET)
976
977
  await lesson5.start()
977
978
  await returnToMainMenu()
978
979
  } catch (error) {
@@ -988,7 +989,7 @@ async function startEnunciadosSelectorInteractive() {
988
989
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
989
990
 
990
991
  try {
991
- const lesson6 = new Lesson6InterfaceDesign()
992
+ const lesson6 = new LessonBuilder(LESSON_6_INTERFACE_DESIGN)
992
993
  await lesson6.start()
993
994
  await returnToMainMenu()
994
995
  } catch (error) {
@@ -1004,7 +1005,7 @@ async function startEnunciadosSelectorInteractive() {
1004
1005
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
1005
1006
 
1006
1007
  try {
1007
- const lesson7 = new Lesson7ObjectDefinition()
1008
+ const lesson7 = new LessonBuilder(LESSON_7_OBJECT_DEFINITION)
1008
1009
  await lesson7.start()
1009
1010
  await returnToMainMenu()
1010
1011
  } catch (error) {
@@ -1098,7 +1099,7 @@ async function startEnunciadosSelectorFallback() {
1098
1099
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
1099
1100
 
1100
1101
  try {
1101
- const lesson1 = new Lesson1SystemDecomposition()
1102
+ const lesson1 = new LessonBuilder(LESSON_1_SYSTEM_DECOMPOSITION)
1102
1103
  await lesson1.start()
1103
1104
  } catch (error) {
1104
1105
  console.error("\n❌ Error al ejecutar la lección:", error.message)
@@ -1114,7 +1115,7 @@ async function startEnunciadosSelectorFallback() {
1114
1115
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
1115
1116
 
1116
1117
  try {
1117
- const lesson1 = new Lesson1SystemDecomposition()
1118
+ const lesson1 = new LessonBuilder(LESSON_1_SYSTEM_DECOMPOSITION)
1118
1119
  await lesson1.start()
1119
1120
  } catch (error) {
1120
1121
  console.error("\n❌ Error al ejecutar la lección:", error.message)
@@ -1130,7 +1131,7 @@ async function startEnunciadosSelectorFallback() {
1130
1131
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
1131
1132
 
1132
1133
  try {
1133
- const lesson2 = new Lesson2ObjectRequests()
1134
+ const lesson2 = new LessonBuilder(LESSON_2_OBJECT_REQUESTS)
1134
1135
  await lesson2.start()
1135
1136
  } catch (error) {
1136
1137
  console.error("\n❌ Error al ejecutar la lección:", error.message)
@@ -1146,7 +1147,7 @@ async function startEnunciadosSelectorFallback() {
1146
1147
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
1147
1148
 
1148
1149
  try {
1149
- const lesson3 = new Lesson3OnlyWay()
1150
+ const lesson3 = new LessonBuilder(LESSON_3_ONLY_WAY)
1150
1151
  await lesson3.start()
1151
1152
  } catch (error) {
1152
1153
  console.error("\n❌ Error al ejecutar la lección:", error.message)
@@ -1162,7 +1163,7 @@ async function startEnunciadosSelectorFallback() {
1162
1163
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
1163
1164
 
1164
1165
  try {
1165
- const lesson4 = new Lesson4OperationSignatures()
1166
+ const lesson4 = new LessonBuilder(LESSON_4_OPERATION_SIGNATURES)
1166
1167
  await lesson4.start()
1167
1168
  } catch (error) {
1168
1169
  console.error("\n❌ Error al ejecutar la lección:", error.message)
@@ -1178,7 +1179,7 @@ async function startEnunciadosSelectorFallback() {
1178
1179
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
1179
1180
 
1180
1181
  try {
1181
- const lesson5 = new Lesson5InterfaceSet()
1182
+ const lesson5 = new LessonBuilder(LESSON_5_INTERFACE_SET)
1182
1183
  await lesson5.start()
1183
1184
  } catch (error) {
1184
1185
  console.error("\n❌ Error al ejecutar la lección:", error.message)
@@ -1194,7 +1195,7 @@ async function startEnunciadosSelectorFallback() {
1194
1195
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
1195
1196
 
1196
1197
  try {
1197
- const lesson6 = new Lesson6InterfaceDesign()
1198
+ const lesson6 = new LessonBuilder(LESSON_6_INTERFACE_DESIGN)
1198
1199
  await lesson6.start()
1199
1200
  } catch (error) {
1200
1201
  console.error("\n❌ Error al ejecutar la lección:", error.message)
@@ -1210,7 +1211,7 @@ async function startEnunciadosSelectorFallback() {
1210
1211
  await new Promise(resolve => setTimeout(resolve, 1500)) // Brief pause
1211
1212
 
1212
1213
  try {
1213
- const lesson7 = new Lesson7ObjectDefinition()
1214
+ const lesson7 = new LessonBuilder(LESSON_7_OBJECT_DEFINITION)
1214
1215
  await lesson7.start()
1215
1216
  } catch (error) {
1216
1217
  console.error("\n❌ Error al ejecutar la lección:", error.message)
@@ -66,6 +66,7 @@ export class UserState {
66
66
 
67
67
  static setName(name) {
68
68
  const state = loadState()
69
+ if (!state) return null
69
70
  state.name = name
70
71
  saveState(state)
71
72
  return state
@@ -73,6 +74,18 @@ export class UserState {
73
74
 
74
75
  static updateLastSeen() {
75
76
  const state = loadState()
77
+ if (!state) {
78
+ console.error('Warning: Could not load user state')
79
+ return {
80
+ name: null,
81
+ createdAt: new Date().toISOString(),
82
+ lessonsCompleted: [],
83
+ projectsCreated: [],
84
+ discord: null,
85
+ stats: { totalSessions: 0, lastSeen: null },
86
+ lastSeen: null
87
+ }
88
+ }
76
89
  const now = new Date().toISOString()
77
90
  state.lastSeen = now
78
91
  state.stats = state.stats || { totalSessions: 0, lastSeen: null }
@@ -84,6 +97,7 @@ export class UserState {
84
97
 
85
98
  static addCompletedLesson(lessonId) {
86
99
  const state = loadState()
100
+ if (!state) return null
87
101
  const alreadyCompleted = state.lessonsCompleted.some(
88
102
  lesson => typeof lesson === 'object' ? lesson.id === lessonId : lesson === lessonId
89
103
  )
@@ -100,6 +114,7 @@ export class UserState {
100
114
 
101
115
  static addProject(projectName) {
102
116
  const state = loadState()
117
+ if (!state) return null
103
118
  state.projectsCreated = state.projectsCreated || []
104
119
  state.projectsCreated.push({
105
120
  name: projectName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icarusmx/creta",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "Salgamos de este laberinto.",
5
5
  "type": "module",
6
6
  "bin": {