@learnpack/learnpack 5.0.272 → 5.0.274

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 (75) hide show
  1. package/README.md +409 -409
  2. package/lib/commands/audit.js +15 -15
  3. package/lib/commands/breakToken.js +19 -19
  4. package/lib/commands/clean.js +3 -3
  5. package/lib/commands/init.js +41 -41
  6. package/lib/commands/logout.js +3 -3
  7. package/lib/commands/serve.js +32 -17
  8. package/lib/creatorDist/assets/{index-C1pv1wUb.js → index-BfLyIQVh.js} +10351 -10227
  9. package/lib/creatorDist/assets/{index-B4khtb0r.css → index-C39zeF3W.css} +3 -3
  10. package/lib/creatorDist/index.html +2 -2
  11. package/lib/managers/config/index.js +77 -77
  12. package/lib/utils/api.js +1 -0
  13. package/lib/utils/creatorUtilities.js +14 -14
  14. package/package.json +1 -1
  15. package/src/commands/audit.ts +487 -487
  16. package/src/commands/breakToken.ts +67 -67
  17. package/src/commands/clean.ts +30 -30
  18. package/src/commands/init.ts +650 -650
  19. package/src/commands/logout.ts +38 -38
  20. package/src/commands/publish.ts +522 -522
  21. package/src/commands/serve.ts +38 -28
  22. package/src/commands/start.ts +333 -333
  23. package/src/commands/translate.ts +123 -123
  24. package/src/creator/README.md +54 -54
  25. package/src/creator/eslint.config.js +28 -28
  26. package/src/creator/src/components/syllabus/ContentIndex.tsx +1 -1
  27. package/src/creator/src/i18n.ts +28 -28
  28. package/src/creator/src/index.css +217 -217
  29. package/src/creator/src/locales/en.json +1 -0
  30. package/src/creator/src/locales/es.json +1 -0
  31. package/src/creator/src/utils/configTypes.ts +122 -122
  32. package/src/creator/src/utils/constants.ts +13 -13
  33. package/src/creator/src/utils/creatorUtils.ts +46 -46
  34. package/src/creator/src/utils/eventBus.ts +2 -2
  35. package/src/creator/src/utils/lib.ts +468 -468
  36. package/src/creator/src/utils/rigo.ts +26 -26
  37. package/src/creator/src/utils/socket.ts +61 -61
  38. package/src/creator/src/utils/store.ts +222 -222
  39. package/src/creator/src/vite-env.d.ts +1 -1
  40. package/src/creator/vite.config.ts +13 -13
  41. package/src/creatorDist/assets/{index-C1pv1wUb.js → index-BfLyIQVh.js} +10351 -10227
  42. package/src/creatorDist/assets/{index-B4khtb0r.css → index-C39zeF3W.css} +3 -3
  43. package/src/creatorDist/index.html +2 -2
  44. package/src/managers/config/defaults.ts +49 -49
  45. package/src/managers/config/exercise.ts +364 -364
  46. package/src/managers/config/index.ts +775 -775
  47. package/src/managers/file.ts +236 -236
  48. package/src/managers/server/routes.ts +554 -554
  49. package/src/managers/session.ts +182 -182
  50. package/src/managers/telemetry.ts +188 -188
  51. package/src/models/action.ts +13 -13
  52. package/src/models/config-manager.ts +28 -28
  53. package/src/models/config.ts +106 -106
  54. package/src/models/creator.ts +40 -40
  55. package/src/models/exercise-obj.ts +30 -30
  56. package/src/models/session.ts +39 -39
  57. package/src/models/socket.ts +61 -61
  58. package/src/models/status.ts +16 -16
  59. package/src/ui/_app/app.css +1 -1
  60. package/src/ui/_app/app.js +435 -414
  61. package/src/ui/_app/learnpack.svg +7 -7
  62. package/src/ui/app.tar.gz +0 -0
  63. package/src/utils/BaseCommand.ts +56 -56
  64. package/src/utils/api.ts +31 -30
  65. package/src/utils/audit.ts +392 -392
  66. package/src/utils/checkNotInstalled.ts +267 -267
  67. package/src/utils/configBuilder.ts +82 -82
  68. package/src/utils/convertCreds.js +34 -34
  69. package/src/utils/creatorUtilities.ts +504 -504
  70. package/src/utils/incrementVersion.js +74 -74
  71. package/src/utils/misc.ts +58 -58
  72. package/src/utils/rigoActions.ts +500 -500
  73. package/src/utils/sidebarGenerator.ts +195 -195
  74. package/src/utils/templates/isolated/exercises/01-hello-world/README.es.md +26 -26
  75. package/src/utils/templates/isolated/exercises/01-hello-world/README.md +26 -26
@@ -1,12 +1,12 @@
1
- import toast from "react-hot-toast"
2
- import { RIGOBOT_HOST, DEV_MODE } from "./constants"
3
- import axios, { AxiosError } from "axios"
4
- import { randomUUID } from "./creatorUtils"
1
+ import toast from "react-hot-toast";
2
+ import { RIGOBOT_HOST, DEV_MODE } from "./constants";
3
+ import axios, { AxiosError } from "axios";
4
+ import { randomUUID } from "./creatorUtils";
5
5
 
6
6
  type TInteractiveCreationInputs = {
7
- courseInfo: string
8
- prevInteractions: string
9
- }
7
+ courseInfo: string;
8
+ prevInteractions: string;
9
+ };
10
10
 
11
11
  export const publicInteractiveCreation = async (
12
12
  inputs: TInteractiveCreationInputs,
@@ -15,15 +15,15 @@ export const publicInteractiveCreation = async (
15
15
  publicRequest: boolean = true
16
16
  ): Promise<any | null> => {
17
17
  try {
18
- const randomUID = randomUUID(15)
18
+ const randomUID = randomUUID(15);
19
19
  const webhookUrl = `${
20
20
  DEV_MODE
21
- ? "https://9cw5zmww-3000.use2.devtunnels.ms"
21
+ ? "https://1gm40gnb-3000.use2.devtunnels.ms"
22
22
  : window.location.origin
23
- // "https://9cw5zmww-3000.use2.devtunnels.ms"
24
- }/notifications/${randomUID}`
23
+ // : "https://1gm40gnb-3000.use2.devtunnels.ms"
24
+ }/notifications/${randomUID}`;
25
25
 
26
- console.log("WEBHOOK URL to send to Rigo", webhookUrl)
26
+ console.log("WEBHOOK URL to send to Rigo", webhookUrl);
27
27
 
28
28
  const response = await axios.post(
29
29
  `${RIGOBOT_HOST}/v1/prompting${
@@ -41,28 +41,28 @@ export const publicInteractiveCreation = async (
41
41
  Authorization: `Token ${token}`,
42
42
  },
43
43
  }
44
- )
44
+ );
45
45
 
46
- return { res: response.data, notificationId: randomUID }
46
+ return { res: response.data, notificationId: randomUID };
47
47
  } catch (error: unknown) {
48
- const err = error as AxiosError
49
- console.log("error trying to create course", err)
48
+ const err = error as AxiosError;
49
+ console.log("error trying to create course", err);
50
50
 
51
51
  if (err.response?.status === 403) {
52
- toast.error("You've reached the limit. Please log in to continue.")
52
+ toast.error("You've reached the limit. Please log in to continue.");
53
53
  } else {
54
- toast.error("Something went wrong while generating the course.")
54
+ toast.error("Something went wrong while generating the course.");
55
55
  }
56
56
 
57
- return null
57
+ return null;
58
58
  }
59
- }
59
+ };
60
60
 
61
61
  export const isHuman = async (token: string) => {
62
62
  try {
63
63
  const body = {
64
64
  access_token: token,
65
- }
65
+ };
66
66
  const response = await axios.post(
67
67
  `${RIGOBOT_HOST}/v1/auth/verify/humanity`,
68
68
  body,
@@ -71,15 +71,15 @@ export const isHuman = async (token: string) => {
71
71
  "Content-Type": "application/json",
72
72
  },
73
73
  }
74
- )
74
+ );
75
75
 
76
76
  return {
77
77
  human: response.status === 200,
78
78
  message: response.data.message,
79
79
  token: response.data.public_access_token,
80
- }
80
+ };
81
81
  } catch (error) {
82
- console.error(error)
83
- return { human: false, message: error, token: null }
82
+ console.error(error);
83
+ return { human: false, message: error, token: null };
84
84
  }
85
- }
85
+ };
@@ -1,61 +1,61 @@
1
- import { io, Socket } from "socket.io-client"
2
-
3
- type EventCallback = (...args: any[]) => void
4
-
5
- class CreatorSocket {
6
- private socket: Socket | null = null
7
- private readonly url: string
8
-
9
- constructor(url: string) {
10
- this.url = url
11
- }
12
-
13
- /**
14
- * Conecta manualmente al servidor de websockets
15
- */
16
- connect() {
17
- if (this.socket) return
18
- this.socket = io(this.url, { autoConnect: false, path: "/sockete" })
19
- this.socket.connect()
20
- }
21
-
22
- /**
23
- * Desconecta del servidor
24
- */
25
- disconnect() {
26
- if (this.socket) {
27
- this.socket.disconnect()
28
- this.socket = null
29
- }
30
- }
31
-
32
- /**
33
- * Verifica si está conectado
34
- */
35
- isConnected(): boolean {
36
- return !!this.socket?.connected
37
- }
38
-
39
- /**
40
- * Registra un evento personalizado
41
- */
42
- on(event: string, callback: EventCallback) {
43
- this.socket?.on(event, callback)
44
- }
45
-
46
- /**
47
- * Emite un evento al servidor
48
- */
49
- emit(event: string, ...args: any[]) {
50
- this.socket?.emit(event, ...args)
51
- }
52
-
53
- /**
54
- * Elimina un evento registrado
55
- */
56
- off(event: string, callback?: EventCallback) {
57
- this.socket?.off(event, callback)
58
- }
59
- }
60
-
61
- export default CreatorSocket
1
+ import { io, Socket } from "socket.io-client"
2
+
3
+ type EventCallback = (...args: any[]) => void
4
+
5
+ class CreatorSocket {
6
+ private socket: Socket | null = null
7
+ private readonly url: string
8
+
9
+ constructor(url: string) {
10
+ this.url = url
11
+ }
12
+
13
+ /**
14
+ * Conecta manualmente al servidor de websockets
15
+ */
16
+ connect() {
17
+ if (this.socket) return
18
+ this.socket = io(this.url, { autoConnect: false, path: "/sockete" })
19
+ this.socket.connect()
20
+ }
21
+
22
+ /**
23
+ * Desconecta del servidor
24
+ */
25
+ disconnect() {
26
+ if (this.socket) {
27
+ this.socket.disconnect()
28
+ this.socket = null
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Verifica si está conectado
34
+ */
35
+ isConnected(): boolean {
36
+ return !!this.socket?.connected
37
+ }
38
+
39
+ /**
40
+ * Registra un evento personalizado
41
+ */
42
+ on(event: string, callback: EventCallback) {
43
+ this.socket?.on(event, callback)
44
+ }
45
+
46
+ /**
47
+ * Emite un evento al servidor
48
+ */
49
+ emit(event: string, ...args: any[]) {
50
+ this.socket?.emit(event, ...args)
51
+ }
52
+
53
+ /**
54
+ * Elimina un evento registrado
55
+ */
56
+ off(event: string, callback?: EventCallback) {
57
+ this.socket?.off(event, callback)
58
+ }
59
+ }
60
+
61
+ export default CreatorSocket
@@ -1,222 +1,222 @@
1
- import { create } from "zustand"
2
- import { persist } from "zustand/middleware"
3
- import { Lesson } from "../components/LessonItem"
4
- import { ParsedFile } from "../components/FileUploader"
5
- import { TMessage } from "../components/Message"
6
- // import { ParsedLink } from "../components/LinkUploader"
7
- export type TDifficulty = "easy" | "beginner" | "intermediate" | "hard"
8
-
9
- export type FormState = {
10
- description: string
11
- duration: number
12
- hasContentIndex: boolean
13
- contentIndex: string
14
- purpose: string
15
- difficulty: TDifficulty
16
- slug: string
17
- language?: string
18
- isCompleted: boolean
19
- variables: string[]
20
- currentStep: string
21
- title?: string
22
- technologies?: string[]
23
- }
24
-
25
- type Auth = {
26
- bcToken: string
27
- rigoToken: string
28
- userId: string
29
- user: any
30
- publicToken: string
31
- }
32
- export type Syllabus = {
33
- lessons: Lesson[]
34
- courseInfo: FormState
35
- // messages: TMessage[]
36
- }
37
-
38
- type Consumables = {
39
- [key: string]: number
40
- }
41
-
42
- type TTechnology = {
43
- slug: string
44
- lang: string
45
- }
46
-
47
- type Store = {
48
- auth: Auth
49
- formState: FormState
50
- setFormState: (formState: Partial<FormState>) => void
51
- resetFormState: () => void
52
- setAuth: (auth: Auth) => void
53
- // syllabus: Syllabus
54
- planToRedirect: string
55
- setPlanToRedirect: (planToRedirect: string) => void
56
- uploadedFiles: ParsedFile[]
57
- setUploadedFiles: (uploadedFiles: ParsedFile[]) => void
58
- messages: TMessage[]
59
- setMessages: (
60
- messages: TMessage[] | ((prev: TMessage[]) => TMessage[])
61
- ) => void
62
- cleanHistory: () => void
63
- history: Syllabus[]
64
- technologies: TTechnology[]
65
- setTechnologies: (technologies: TTechnology[]) => void
66
- undo: () => void
67
- push: (syllabus: Syllabus) => void
68
- cleanAll: () => void
69
- // setSyllabus: (syllabus: Partial<Syllabus>) => void
70
- consumables: Consumables
71
- setConsumables: (consumables: Partial<Consumables>) => void
72
- mode: "student" | "teacher"
73
- setMode: (mode: "student" | "teacher") => void
74
- }
75
-
76
- const useStore = create<Store>()(
77
- persist(
78
- (set) => ({
79
- auth: {
80
- bcToken: "",
81
- rigoToken: "",
82
- userId: "",
83
- user: null,
84
- publicToken: "",
85
- },
86
- planToRedirect: "learnpack-creator",
87
- setPlanToRedirect: (planToRedirect: string) => set({ planToRedirect }),
88
- formState: {
89
- description: "",
90
- duration: 0,
91
- slug: "",
92
- hasContentIndex: false,
93
- contentIndex: "",
94
- purpose: "",
95
- language: "en",
96
- technologies: [],
97
- difficulty: "beginner",
98
- // sources: [],
99
- isCompleted: false,
100
- currentStep: "description",
101
- variables: [
102
- "description",
103
- "duration",
104
- "purpose",
105
- "hasContentIndex",
106
- "verifyHuman",
107
- ],
108
- },
109
- messages: [],
110
- technologies: [],
111
- setTechnologies: (technologies: TTechnology[]) => set({ technologies }),
112
- setMessages: (
113
- messages: TMessage[] | ((prev: TMessage[]) => TMessage[])
114
- ) => {
115
- set((state) => ({
116
- messages:
117
- typeof messages === "function"
118
- ? messages(state.messages)
119
- : messages,
120
- }))
121
- },
122
- setFormState: (formState: Partial<FormState>) =>
123
- set((state) => ({ formState: { ...state.formState, ...formState } })),
124
- resetFormState: () =>
125
- set({
126
- formState: {
127
- slug: "",
128
- currentStep: "description",
129
- description: "",
130
- duration: 0,
131
- language: "en",
132
- difficulty: "beginner",
133
- technologies: [],
134
- hasContentIndex: false,
135
- contentIndex: "",
136
- purpose: "",
137
- isCompleted: false,
138
- variables: [
139
- "description",
140
- "duration",
141
- "purpose",
142
- "hasContentIndex",
143
- "verifyHuman",
144
- ],
145
- },
146
- }),
147
-
148
- setUploadedFiles: (uploadedFiles) =>
149
- set(() => ({
150
- uploadedFiles: [...uploadedFiles],
151
- })),
152
- uploadedFiles: [],
153
- history: [],
154
- push: (syllabus: Syllabus) => {
155
- set((state) => ({
156
- history: [...state.history, syllabus],
157
- }))
158
- },
159
-
160
- undo: () => {
161
- set((state) => {
162
- return {
163
- history: state.history.slice(0, -1),
164
- }
165
- })
166
- },
167
- cleanHistory: () => {
168
- set(() => ({ history: [] }))
169
- },
170
- cleanAll: () => {
171
- set({
172
- uploadedFiles: [],
173
- messages: [],
174
- history: [],
175
- technologies: [],
176
- formState: {
177
- description: "",
178
- duration: 0,
179
- slug: "",
180
- difficulty: "beginner",
181
- language: "en",
182
- technologies: [],
183
- hasContentIndex: false,
184
- contentIndex: "",
185
- purpose: "",
186
- isCompleted: false,
187
- variables: [
188
- "description",
189
- "duration",
190
- "purpose",
191
- "hasContentIndex",
192
- "verifyHuman",
193
- ],
194
- currentStep: "description",
195
- },
196
- })
197
- },
198
- consumables: {},
199
- setConsumables: (consumables: Partial<Consumables>) =>
200
- set((state) => {
201
- const sanitized: Consumables = Object.fromEntries(
202
- Object.entries(consumables).map(([k, v]) => [k, v ?? 0])
203
- )
204
- return {
205
- consumables: {
206
- ...state.consumables,
207
- ...sanitized,
208
- },
209
- }
210
- }),
211
-
212
- setAuth: (auth: Auth) => set({ auth }),
213
- mode: "student",
214
- setMode: (mode: "student" | "teacher") => set({ mode }),
215
- }),
216
- {
217
- name: "syllabus-storage",
218
- }
219
- )
220
- )
221
-
222
- export default useStore
1
+ import { create } from "zustand"
2
+ import { persist } from "zustand/middleware"
3
+ import { Lesson } from "../components/LessonItem"
4
+ import { ParsedFile } from "../components/FileUploader"
5
+ import { TMessage } from "../components/Message"
6
+ // import { ParsedLink } from "../components/LinkUploader"
7
+ export type TDifficulty = "easy" | "beginner" | "intermediate" | "hard"
8
+
9
+ export type FormState = {
10
+ description: string
11
+ duration: number
12
+ hasContentIndex: boolean
13
+ contentIndex: string
14
+ purpose: string
15
+ difficulty: TDifficulty
16
+ slug: string
17
+ language?: string
18
+ isCompleted: boolean
19
+ variables: string[]
20
+ currentStep: string
21
+ title?: string
22
+ technologies?: string[]
23
+ }
24
+
25
+ type Auth = {
26
+ bcToken: string
27
+ rigoToken: string
28
+ userId: string
29
+ user: any
30
+ publicToken: string
31
+ }
32
+ export type Syllabus = {
33
+ lessons: Lesson[]
34
+ courseInfo: FormState
35
+ // messages: TMessage[]
36
+ }
37
+
38
+ type Consumables = {
39
+ [key: string]: number
40
+ }
41
+
42
+ type TTechnology = {
43
+ slug: string
44
+ lang: string
45
+ }
46
+
47
+ type Store = {
48
+ auth: Auth
49
+ formState: FormState
50
+ setFormState: (formState: Partial<FormState>) => void
51
+ resetFormState: () => void
52
+ setAuth: (auth: Auth) => void
53
+ // syllabus: Syllabus
54
+ planToRedirect: string
55
+ setPlanToRedirect: (planToRedirect: string) => void
56
+ uploadedFiles: ParsedFile[]
57
+ setUploadedFiles: (uploadedFiles: ParsedFile[]) => void
58
+ messages: TMessage[]
59
+ setMessages: (
60
+ messages: TMessage[] | ((prev: TMessage[]) => TMessage[])
61
+ ) => void
62
+ cleanHistory: () => void
63
+ history: Syllabus[]
64
+ technologies: TTechnology[]
65
+ setTechnologies: (technologies: TTechnology[]) => void
66
+ undo: () => void
67
+ push: (syllabus: Syllabus) => void
68
+ cleanAll: () => void
69
+ // setSyllabus: (syllabus: Partial<Syllabus>) => void
70
+ consumables: Consumables
71
+ setConsumables: (consumables: Partial<Consumables>) => void
72
+ mode: "student" | "teacher"
73
+ setMode: (mode: "student" | "teacher") => void
74
+ }
75
+
76
+ const useStore = create<Store>()(
77
+ persist(
78
+ (set) => ({
79
+ auth: {
80
+ bcToken: "",
81
+ rigoToken: "",
82
+ userId: "",
83
+ user: null,
84
+ publicToken: "",
85
+ },
86
+ planToRedirect: "learnpack-creator",
87
+ setPlanToRedirect: (planToRedirect: string) => set({ planToRedirect }),
88
+ formState: {
89
+ description: "",
90
+ duration: 0,
91
+ slug: "",
92
+ hasContentIndex: false,
93
+ contentIndex: "",
94
+ purpose: "",
95
+ language: "en",
96
+ technologies: [],
97
+ difficulty: "beginner",
98
+ // sources: [],
99
+ isCompleted: false,
100
+ currentStep: "description",
101
+ variables: [
102
+ "description",
103
+ "duration",
104
+ "purpose",
105
+ "hasContentIndex",
106
+ "verifyHuman",
107
+ ],
108
+ },
109
+ messages: [],
110
+ technologies: [],
111
+ setTechnologies: (technologies: TTechnology[]) => set({ technologies }),
112
+ setMessages: (
113
+ messages: TMessage[] | ((prev: TMessage[]) => TMessage[])
114
+ ) => {
115
+ set((state) => ({
116
+ messages:
117
+ typeof messages === "function"
118
+ ? messages(state.messages)
119
+ : messages,
120
+ }))
121
+ },
122
+ setFormState: (formState: Partial<FormState>) =>
123
+ set((state) => ({ formState: { ...state.formState, ...formState } })),
124
+ resetFormState: () =>
125
+ set({
126
+ formState: {
127
+ slug: "",
128
+ currentStep: "description",
129
+ description: "",
130
+ duration: 0,
131
+ language: "en",
132
+ difficulty: "beginner",
133
+ technologies: [],
134
+ hasContentIndex: false,
135
+ contentIndex: "",
136
+ purpose: "",
137
+ isCompleted: false,
138
+ variables: [
139
+ "description",
140
+ "duration",
141
+ "purpose",
142
+ "hasContentIndex",
143
+ "verifyHuman",
144
+ ],
145
+ },
146
+ }),
147
+
148
+ setUploadedFiles: (uploadedFiles) =>
149
+ set(() => ({
150
+ uploadedFiles: [...uploadedFiles],
151
+ })),
152
+ uploadedFiles: [],
153
+ history: [],
154
+ push: (syllabus: Syllabus) => {
155
+ set((state) => ({
156
+ history: [...state.history, syllabus],
157
+ }))
158
+ },
159
+
160
+ undo: () => {
161
+ set((state) => {
162
+ return {
163
+ history: state.history.slice(0, -1),
164
+ }
165
+ })
166
+ },
167
+ cleanHistory: () => {
168
+ set(() => ({ history: [] }))
169
+ },
170
+ cleanAll: () => {
171
+ set({
172
+ uploadedFiles: [],
173
+ messages: [],
174
+ history: [],
175
+ technologies: [],
176
+ formState: {
177
+ description: "",
178
+ duration: 0,
179
+ slug: "",
180
+ difficulty: "beginner",
181
+ language: "en",
182
+ technologies: [],
183
+ hasContentIndex: false,
184
+ contentIndex: "",
185
+ purpose: "",
186
+ isCompleted: false,
187
+ variables: [
188
+ "description",
189
+ "duration",
190
+ "purpose",
191
+ "hasContentIndex",
192
+ "verifyHuman",
193
+ ],
194
+ currentStep: "description",
195
+ },
196
+ })
197
+ },
198
+ consumables: {},
199
+ setConsumables: (consumables: Partial<Consumables>) =>
200
+ set((state) => {
201
+ const sanitized: Consumables = Object.fromEntries(
202
+ Object.entries(consumables).map(([k, v]) => [k, v ?? 0])
203
+ )
204
+ return {
205
+ consumables: {
206
+ ...state.consumables,
207
+ ...sanitized,
208
+ },
209
+ }
210
+ }),
211
+
212
+ setAuth: (auth: Auth) => set({ auth }),
213
+ mode: "student",
214
+ setMode: (mode: "student" | "teacher") => set({ mode }),
215
+ }),
216
+ {
217
+ name: "syllabus-storage",
218
+ }
219
+ )
220
+ )
221
+
222
+ export default useStore
@@ -1 +1 @@
1
- /// <reference types="vite/client" />
1
+ /// <reference types="vite/client" />