@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,188 +1,188 @@
1
- import { IFile } from "../models/file"
2
- import { ISocket } from "../models/socket"
3
- const packageInfo = require("../../package.json")
4
- import Console from "../utils/console"
5
-
6
- const fs = require("fs")
7
-
8
- function createUUID(): string {
9
- return (
10
- Math.random().toString(36).slice(2, 10) +
11
- Math.random().toString(36).slice(2, 10)
12
- )
13
- }
14
-
15
- function stringToBase64(input: string): string {
16
- return Buffer.from(input).toString("base64")
17
- }
18
-
19
- type TCompilationAttempt = {
20
- source_code: string
21
- stdout: string
22
- exit_code: number
23
- starting_at: number
24
- ending_at: number
25
- }
26
-
27
- type TTestAttempt = {
28
- source_code: string
29
- stdout: string
30
- exit_code: number
31
- starting_at: number
32
- ending_at: number
33
- }
34
-
35
- type TAIInteraction = {
36
- student_message: string
37
- source_code: string
38
- ai_response: string
39
- starting_at: number
40
- ending_at: number
41
- }
42
-
43
- type TQuizSelection = {
44
- question: string
45
- answer: string
46
- isCorrect: boolean
47
- }
48
-
49
- type TQuizSubmission = {
50
- quiz_hash: string
51
- selections: TQuizSelection[]
52
- submitted_at: number
53
- }
54
-
55
- export type TStep = {
56
- slug: string
57
- position: number
58
- files: IFile[]
59
- is_testeable: boolean
60
- opened_at?: number // The time when the step was opened
61
- completed_at?: number // If the step has tests, the time when all the tests passed, else, the time when the user opens the next step
62
- compilations: TCompilationAttempt[] // Everytime the user tries to compile the code
63
- tests: TTestAttempt[] // Everytime the user tries to run the tests
64
- ai_interactions: TAIInteraction[] // Everytime the user interacts with the AI
65
- quiz_submissions: TQuizSubmission[] // Everytime the user submits a quiz
66
- }
67
-
68
- type TWorkoutSession = {
69
- started_at: number
70
- ended_at?: number
71
- }
72
-
73
- type TStudent = {
74
- token: string
75
- user_id: string
76
- email: string
77
- }
78
-
79
- export interface ITelemetryJSONSchema {
80
- telemetry_id?: string
81
- version: string
82
- user_id?: number | string
83
- slug: string
84
- agent?: string
85
- tutorial_started_at: number
86
- last_interaction_at: number
87
- steps: Array<TStep> // The steps should be the same as the exercise
88
- workout_session: TWorkoutSession[] // It start when the user starts Learnpack, if the last_interaction_at is available, it automatically fills with that
89
- // number and start another session
90
- }
91
-
92
- export type TStepEvent =
93
- | "compile"
94
- | "test"
95
- | "ai_interaction"
96
- | "open_step"
97
- | "quiz_submission"
98
-
99
- export type TTelemetryUrls = {
100
- streaming?: string
101
- batch?: string
102
- }
103
-
104
- type TUser = {
105
- token: string
106
- id: string
107
- email: string
108
- }
109
-
110
- interface ITelemetryManagerCLI {
111
- configPath: string | null
112
- socket: ISocket | null
113
- version: string
114
- start: (path: string, socket: ISocket) => void
115
- registerStepEvent: (
116
- stepPosition: number,
117
- event: TStepEvent,
118
- data: any
119
- ) => void
120
- save: (telemetry: ITelemetryJSONSchema) => void
121
- retrieve: () => Promise<ITelemetryJSONSchema | null>
122
- }
123
-
124
- const TelemetryManager: ITelemetryManagerCLI = {
125
- version: packageInfo.version,
126
- socket: null,
127
-
128
- configPath: "",
129
-
130
- start: function (path, socket) {
131
- this.configPath = path
132
- this.socket = socket
133
- },
134
-
135
- registerStepEvent: function (stepPosition, event, data) {
136
- Console.debug(`Registering Telemetry Event ${event}`)
137
-
138
- this.socket?.emit(
139
- "telemetry_event",
140
- "ready",
141
- [`Registering telemetry event ${event}`],
142
- [],
143
- [],
144
- {
145
- stepPosition,
146
- event,
147
- data,
148
- }
149
- )
150
- },
151
- retrieve: function () {
152
- return new Promise((resolve, reject) => {
153
- fs.readFile(
154
- `${this.configPath}/telemetry.json`,
155
- "utf8",
156
- (err: any, data: any) => {
157
- if (err) {
158
- if (err.code === "ENOENT") {
159
- // File does not exist, resolve with undefined
160
- resolve(null)
161
- } else {
162
- reject(err)
163
- }
164
- } else {
165
- try {
166
- resolve(JSON.parse(data))
167
- } catch {
168
- resolve(null)
169
- }
170
- }
171
- }
172
- )
173
- })
174
- },
175
-
176
- save: function (telemetry: ITelemetryJSONSchema) {
177
- fs.writeFile(
178
- `${this.configPath}/telemetry.json`,
179
- JSON.stringify(telemetry),
180
- (err: any) => {
181
- if (err)
182
- throw err
183
- }
184
- )
185
- },
186
- }
187
-
188
- export default TelemetryManager
1
+ import { IFile } from "../models/file"
2
+ import { ISocket } from "../models/socket"
3
+ const packageInfo = require("../../package.json")
4
+ import Console from "../utils/console"
5
+
6
+ const fs = require("fs")
7
+
8
+ function createUUID(): string {
9
+ return (
10
+ Math.random().toString(36).slice(2, 10) +
11
+ Math.random().toString(36).slice(2, 10)
12
+ )
13
+ }
14
+
15
+ function stringToBase64(input: string): string {
16
+ return Buffer.from(input).toString("base64")
17
+ }
18
+
19
+ type TCompilationAttempt = {
20
+ source_code: string
21
+ stdout: string
22
+ exit_code: number
23
+ starting_at: number
24
+ ending_at: number
25
+ }
26
+
27
+ type TTestAttempt = {
28
+ source_code: string
29
+ stdout: string
30
+ exit_code: number
31
+ starting_at: number
32
+ ending_at: number
33
+ }
34
+
35
+ type TAIInteraction = {
36
+ student_message: string
37
+ source_code: string
38
+ ai_response: string
39
+ starting_at: number
40
+ ending_at: number
41
+ }
42
+
43
+ type TQuizSelection = {
44
+ question: string
45
+ answer: string
46
+ isCorrect: boolean
47
+ }
48
+
49
+ type TQuizSubmission = {
50
+ quiz_hash: string
51
+ selections: TQuizSelection[]
52
+ submitted_at: number
53
+ }
54
+
55
+ export type TStep = {
56
+ slug: string
57
+ position: number
58
+ files: IFile[]
59
+ is_testeable: boolean
60
+ opened_at?: number // The time when the step was opened
61
+ completed_at?: number // If the step has tests, the time when all the tests passed, else, the time when the user opens the next step
62
+ compilations: TCompilationAttempt[] // Everytime the user tries to compile the code
63
+ tests: TTestAttempt[] // Everytime the user tries to run the tests
64
+ ai_interactions: TAIInteraction[] // Everytime the user interacts with the AI
65
+ quiz_submissions: TQuizSubmission[] // Everytime the user submits a quiz
66
+ }
67
+
68
+ type TWorkoutSession = {
69
+ started_at: number
70
+ ended_at?: number
71
+ }
72
+
73
+ type TStudent = {
74
+ token: string
75
+ user_id: string
76
+ email: string
77
+ }
78
+
79
+ export interface ITelemetryJSONSchema {
80
+ telemetry_id?: string
81
+ version: string
82
+ user_id?: number | string
83
+ slug: string
84
+ agent?: string
85
+ tutorial_started_at: number
86
+ last_interaction_at: number
87
+ steps: Array<TStep> // The steps should be the same as the exercise
88
+ workout_session: TWorkoutSession[] // It start when the user starts Learnpack, if the last_interaction_at is available, it automatically fills with that
89
+ // number and start another session
90
+ }
91
+
92
+ export type TStepEvent =
93
+ | "compile"
94
+ | "test"
95
+ | "ai_interaction"
96
+ | "open_step"
97
+ | "quiz_submission"
98
+
99
+ export type TTelemetryUrls = {
100
+ streaming?: string
101
+ batch?: string
102
+ }
103
+
104
+ type TUser = {
105
+ token: string
106
+ id: string
107
+ email: string
108
+ }
109
+
110
+ interface ITelemetryManagerCLI {
111
+ configPath: string | null
112
+ socket: ISocket | null
113
+ version: string
114
+ start: (path: string, socket: ISocket) => void
115
+ registerStepEvent: (
116
+ stepPosition: number,
117
+ event: TStepEvent,
118
+ data: any
119
+ ) => void
120
+ save: (telemetry: ITelemetryJSONSchema) => void
121
+ retrieve: () => Promise<ITelemetryJSONSchema | null>
122
+ }
123
+
124
+ const TelemetryManager: ITelemetryManagerCLI = {
125
+ version: packageInfo.version,
126
+ socket: null,
127
+
128
+ configPath: "",
129
+
130
+ start: function (path, socket) {
131
+ this.configPath = path
132
+ this.socket = socket
133
+ },
134
+
135
+ registerStepEvent: function (stepPosition, event, data) {
136
+ Console.debug(`Registering Telemetry Event ${event}`)
137
+
138
+ this.socket?.emit(
139
+ "telemetry_event",
140
+ "ready",
141
+ [`Registering telemetry event ${event}`],
142
+ [],
143
+ [],
144
+ {
145
+ stepPosition,
146
+ event,
147
+ data,
148
+ }
149
+ )
150
+ },
151
+ retrieve: function () {
152
+ return new Promise((resolve, reject) => {
153
+ fs.readFile(
154
+ `${this.configPath}/telemetry.json`,
155
+ "utf8",
156
+ (err: any, data: any) => {
157
+ if (err) {
158
+ if (err.code === "ENOENT") {
159
+ // File does not exist, resolve with undefined
160
+ resolve(null)
161
+ } else {
162
+ reject(err)
163
+ }
164
+ } else {
165
+ try {
166
+ resolve(JSON.parse(data))
167
+ } catch {
168
+ resolve(null)
169
+ }
170
+ }
171
+ }
172
+ )
173
+ })
174
+ },
175
+
176
+ save: function (telemetry: ITelemetryJSONSchema) {
177
+ fs.writeFile(
178
+ `${this.configPath}/telemetry.json`,
179
+ JSON.stringify(telemetry),
180
+ (err: any) => {
181
+ if (err)
182
+ throw err
183
+ }
184
+ )
185
+ },
186
+ }
187
+
188
+ export default TelemetryManager
@@ -1,13 +1,13 @@
1
- export type TAction =
2
- | "test"
3
- | "log"
4
- | "reload"
5
- | "ready"
6
- | "clean"
7
- | "ask"
8
- | "file_change"
9
- | "dialog"
10
- | "session-refreshed"
11
- | "telemetry_event"
12
-
13
- export type ICallback = (...agrs: any[]) => any
1
+ export type TAction =
2
+ | "test"
3
+ | "log"
4
+ | "reload"
5
+ | "ready"
6
+ | "clean"
7
+ | "ask"
8
+ | "file_change"
9
+ | "dialog"
10
+ | "session-refreshed"
11
+ | "telemetry_event"
12
+
13
+ export type ICallback = (...agrs: any[]) => any
@@ -1,28 +1,28 @@
1
- import { TSidebar } from "../utils/sidebarGenerator"
2
- import { IConfigObj, TGrading } from "./config"
3
- import { IExercise } from "./exercise-obj"
4
-
5
- export interface IConfigManagerAttributes {
6
- grading: TGrading
7
- disableGrading: boolean
8
- version: string
9
- mode?: string
10
- }
11
-
12
- export interface IConfigManager {
13
- validLanguages?: any
14
- get: () => IConfigObj
15
- clean: () => void
16
- getExercise: (slug: string | undefined) => IExercise
17
- startExercise: (slug: string) => IExercise
18
- reset: (slug: string) => void
19
- createExercise: (slug: string, content: string, language: string) => boolean
20
- deleteExercise: (slug: string) => boolean
21
- buildIndex: () => boolean | void
22
- watchIndex: (onChange: (...args: Array<any>) => void) => void
23
- save: () => void
24
- getSidebar: () => TSidebar
25
- // checkAndFixSidebar: () => void
26
- noCurrentExercise: () => void
27
- getAllExercises: () => IExercise[]
28
- }
1
+ import { TSidebar } from "../utils/sidebarGenerator"
2
+ import { IConfigObj, TGrading } from "./config"
3
+ import { IExercise } from "./exercise-obj"
4
+
5
+ export interface IConfigManagerAttributes {
6
+ grading: TGrading
7
+ disableGrading: boolean
8
+ version: string
9
+ mode?: string
10
+ }
11
+
12
+ export interface IConfigManager {
13
+ validLanguages?: any
14
+ get: () => IConfigObj
15
+ clean: () => void
16
+ getExercise: (slug: string | undefined) => IExercise
17
+ startExercise: (slug: string) => IExercise
18
+ reset: (slug: string) => void
19
+ createExercise: (slug: string, content: string, language: string) => boolean
20
+ deleteExercise: (slug: string) => boolean
21
+ buildIndex: () => boolean | void
22
+ watchIndex: (onChange: (...args: Array<any>) => void) => void
23
+ save: () => void
24
+ getSidebar: () => TSidebar
25
+ // checkAndFixSidebar: () => void
26
+ noCurrentExercise: () => void
27
+ getAllExercises: () => IExercise[]
28
+ }
@@ -1,106 +1,106 @@
1
- import { IExercise } from "./exercise-obj"
2
- import { TTelemetryUrls } from "../managers/telemetry"
3
-
4
- export type TGrading = "isolated" | "incremental" | "no-grading"
5
-
6
- export type TMode = "preview" | "extension"
7
-
8
- export type TConfigAction = "test" | "build" | "tutorial" | "reset" | "generate"
9
-
10
- export type TConfigObjAttributes = "config" | "exercises" | "grading"
11
-
12
- export type TCompiler =
13
- | "webpack"
14
- | "vanillajs"
15
- | "react"
16
- | "html"
17
- | "node"
18
- | "python"
19
- | "css"
20
-
21
- export interface IConfigPath {
22
- base: string
23
- }
24
-
25
- export interface IEditor {
26
- mode?: TMode
27
- version?: string
28
- agent?: TAgent
29
- hideTerminal?: boolean
30
- }
31
-
32
- export interface TEntries {
33
- python3?: string
34
- html?: string
35
- node?: string
36
- react?: string
37
- java?: string
38
- }
39
-
40
- export interface IConfig {
41
- os: string
42
- port?: string
43
- repository?: string
44
- description?: string
45
- slug?: string
46
- dirPath: string
47
- preview?: string // Picture thumbnail
48
- entries: TEntries
49
- grading: TGrading
50
- configPath: string
51
- translations: Array<string>
52
- outputPath?: string
53
- editor: IEditor
54
- language: string
55
- title: string
56
- duration: number
57
- difficulty?: string
58
- exercisesPath: string
59
- disableGrading: boolean // TODO: Deprecate
60
- actions: Array<string> // TODO: Deprecate
61
- autoPlay: boolean
62
- projectType?: string
63
- // TODO: nameExerciseValidation
64
- contact?: string
65
- disabledActions?: Array<TConfigAction>
66
- compiler: TCompiler
67
- compilers: Array<TCompiler>
68
- publicPath: string
69
- publicUrl?: string
70
- bugsLink?: string
71
- videoSolutions?: boolean
72
- skills: Array<string>
73
- telemetry?: TTelemetryUrls
74
- variables?: TVariables
75
- suggestions: TSuggestions
76
- warnings: TWarnings
77
- runHook: (...agrs: Array<any>) => void
78
- testingFinishedCallback: (arg: any | undefined) => void
79
- }
80
- export type TAgent = "os" | "vscode" | null
81
-
82
- export type TSuggestions = {
83
- agent: TAgent
84
- }
85
-
86
- type TWarnings = {
87
- agent?: string
88
- extension?: string
89
- }
90
-
91
- type TVariable = {
92
- type: "command" | "string"
93
- source: string
94
- }
95
- type TVariables = {
96
- [key: string]: TVariable | string
97
- }
98
-
99
- export interface IConfigObj {
100
- session?: number
101
- currentExercise?: any
102
- config?: IConfig
103
- exercises?: Array<IExercise>
104
- confPath?: IConfigPath
105
- address?: string // Maybe
106
- }
1
+ import { IExercise } from "./exercise-obj"
2
+ import { TTelemetryUrls } from "../managers/telemetry"
3
+
4
+ export type TGrading = "isolated" | "incremental" | "no-grading"
5
+
6
+ export type TMode = "preview" | "extension"
7
+
8
+ export type TConfigAction = "test" | "build" | "tutorial" | "reset" | "generate"
9
+
10
+ export type TConfigObjAttributes = "config" | "exercises" | "grading"
11
+
12
+ export type TCompiler =
13
+ | "webpack"
14
+ | "vanillajs"
15
+ | "react"
16
+ | "html"
17
+ | "node"
18
+ | "python"
19
+ | "css"
20
+
21
+ export interface IConfigPath {
22
+ base: string
23
+ }
24
+
25
+ export interface IEditor {
26
+ mode?: TMode
27
+ version?: string
28
+ agent?: TAgent
29
+ hideTerminal?: boolean
30
+ }
31
+
32
+ export interface TEntries {
33
+ python3?: string
34
+ html?: string
35
+ node?: string
36
+ react?: string
37
+ java?: string
38
+ }
39
+
40
+ export interface IConfig {
41
+ os: string
42
+ port?: string
43
+ repository?: string
44
+ description?: string
45
+ slug?: string
46
+ dirPath: string
47
+ preview?: string // Picture thumbnail
48
+ entries: TEntries
49
+ grading: TGrading
50
+ configPath: string
51
+ translations: Array<string>
52
+ outputPath?: string
53
+ editor: IEditor
54
+ language: string
55
+ title: string
56
+ duration: number
57
+ difficulty?: string
58
+ exercisesPath: string
59
+ disableGrading: boolean // TODO: Deprecate
60
+ actions: Array<string> // TODO: Deprecate
61
+ autoPlay: boolean
62
+ projectType?: string
63
+ // TODO: nameExerciseValidation
64
+ contact?: string
65
+ disabledActions?: Array<TConfigAction>
66
+ compiler: TCompiler
67
+ compilers: Array<TCompiler>
68
+ publicPath: string
69
+ publicUrl?: string
70
+ bugsLink?: string
71
+ videoSolutions?: boolean
72
+ skills: Array<string>
73
+ telemetry?: TTelemetryUrls
74
+ variables?: TVariables
75
+ suggestions: TSuggestions
76
+ warnings: TWarnings
77
+ runHook: (...agrs: Array<any>) => void
78
+ testingFinishedCallback: (arg: any | undefined) => void
79
+ }
80
+ export type TAgent = "os" | "vscode" | null
81
+
82
+ export type TSuggestions = {
83
+ agent: TAgent
84
+ }
85
+
86
+ type TWarnings = {
87
+ agent?: string
88
+ extension?: string
89
+ }
90
+
91
+ type TVariable = {
92
+ type: "command" | "string"
93
+ source: string
94
+ }
95
+ type TVariables = {
96
+ [key: string]: TVariable | string
97
+ }
98
+
99
+ export interface IConfigObj {
100
+ session?: number
101
+ currentExercise?: any
102
+ config?: IConfig
103
+ exercises?: Array<IExercise>
104
+ confPath?: IConfigPath
105
+ address?: string // Maybe
106
+ }