@learnpack/learnpack 5.0.6 → 5.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. package/README.md +17 -17
  2. package/bin/run +17 -17
  3. package/bin/run.cmd +3 -3
  4. package/lib/commands/audit.js +30 -21
  5. package/lib/commands/clean.js +3 -3
  6. package/lib/commands/download.js +3 -3
  7. package/lib/commands/init.js +29 -4
  8. package/lib/commands/login.js +3 -3
  9. package/lib/commands/logout.js +3 -3
  10. package/lib/utils/rigoActions.d.ts +5 -0
  11. package/lib/utils/rigoActions.js +15 -1
  12. package/oclif.manifest.json +1 -1
  13. package/package.json +152 -152
  14. package/src/commands/audit.ts +449 -443
  15. package/src/commands/clean.ts +29 -29
  16. package/src/commands/download.ts +61 -61
  17. package/src/commands/init.ts +40 -12
  18. package/src/commands/login.ts +42 -42
  19. package/src/commands/logout.ts +43 -43
  20. package/src/commands/test.ts +85 -85
  21. package/src/index.ts +1 -1
  22. package/src/managers/config/allowed_files.ts +29 -29
  23. package/src/managers/gitpod.ts +84 -84
  24. package/src/managers/server/index.ts +78 -78
  25. package/src/managers/telemetry.ts +353 -353
  26. package/src/managers/test.ts +83 -83
  27. package/src/models/audit.ts +16 -16
  28. package/src/models/config-manager.ts +23 -23
  29. package/src/models/counter.ts +11 -11
  30. package/src/models/errors.ts +22 -22
  31. package/src/models/exercise-obj.ts +29 -29
  32. package/src/models/file.ts +5 -5
  33. package/src/models/findings.ts +18 -18
  34. package/src/models/flags.ts +10 -10
  35. package/src/models/front-matter.ts +11 -11
  36. package/src/models/gitpod-data.ts +19 -19
  37. package/src/models/language.ts +4 -4
  38. package/src/models/package.ts +7 -7
  39. package/src/models/plugin-config.ts +17 -17
  40. package/src/models/success-types.ts +1 -1
  41. package/src/plugin/command/compile.ts +17 -17
  42. package/src/plugin/command/test.ts +30 -30
  43. package/src/plugin/index.ts +6 -6
  44. package/src/plugin/plugin.ts +94 -94
  45. package/src/plugin/utils.ts +87 -87
  46. package/src/types/node-fetch.d.ts +1 -1
  47. package/src/ui/download.ts +71 -71
  48. package/src/utils/BaseCommand.ts +48 -48
  49. package/src/utils/SessionCommand.ts +43 -43
  50. package/src/utils/audit.ts +393 -393
  51. package/src/utils/errors.ts +117 -117
  52. package/src/utils/exercisesQueue.ts +51 -51
  53. package/src/utils/fileQueue.ts +199 -199
  54. package/src/utils/misc.ts +23 -23
  55. package/src/utils/osOperations.ts +79 -79
  56. package/src/utils/rigoActions.ts +27 -0
  57. package/src/utils/templates/gitignore.txt +19 -19
  58. package/src/utils/templates/incremental/.learn/exercises/01-hello-world/README.es.md +24 -24
  59. package/src/utils/templates/incremental/.learn/exercises/01-hello-world/README.md +24 -24
  60. package/src/utils/templates/incremental/.vscode/schema.json +121 -121
  61. package/src/utils/templates/incremental/.vscode/settings.json +13 -13
  62. package/src/utils/templates/incremental/README.ejs +4 -4
  63. package/src/utils/templates/incremental/README.es.ejs +4 -4
  64. package/src/utils/templates/isolated/.vscode/schema.json +121 -121
  65. package/src/utils/templates/isolated/.vscode/settings.json +13 -13
  66. package/src/utils/templates/isolated/README.ejs +4 -4
  67. package/src/utils/templates/isolated/README.es.ejs +4 -4
  68. package/src/utils/templates/no-grading/README.ejs +4 -4
  69. package/src/utils/templates/no-grading/README.es.ejs +4 -4
  70. package/src/utils/validators.ts +18 -18
  71. package/src/utils/watcher.ts +27 -27
@@ -1,117 +1,117 @@
1
- import Console from './console'
2
-
3
- import {ISolution, IError} from '../models/errors'
4
-
5
- // eslint-disable-next-line
6
- const fetch = require("node-fetch");
7
-
8
- let solutions: { [key: string]: ISolution } | null = null
9
-
10
- const uknown: ISolution = {
11
- video: 'https://www.youtube.com/watch?v=gD1Sa99GiE4',
12
- message: 'Uknown internal error',
13
- slug: 'uknown',
14
- gif: 'https://github.com/breatheco-de/breathecode-cli/blob/master/docs/errors/uknown.gif?raw=true',
15
- }
16
-
17
- export const getSolution = (slug?: string): ISolution => {
18
- if (!slug) {
19
- Console.debug('Getting solution templates from the learnpack repository')
20
- } else {
21
- Console.debug(`Getting solution for ${slug}`, solutions)
22
- }
23
-
24
- if (!solutions) {
25
- Console.debug('Fetching for errors.json on github')
26
- fetch(
27
- 'https://raw.githubusercontent.com/breatheco-de/breathecode-cli/master/docs/errors/errors.json',
28
- )
29
- .then((r: Response) => r.json())
30
- .then(function (_s: { [key: string]: ISolution }) {
31
- solutions = _s
32
- })
33
- return uknown
34
- }
35
-
36
- return typeof solutions[slug || ''] === 'undefined' || !slug ?
37
- uknown :
38
- solutions[slug]
39
- }
40
-
41
- export const ValidationError = (error: IError | string) => {
42
- const message: string = (error as IError).message || (error as string)
43
- const _err = new Error(message) as IError
44
- _err.status = 400
45
- _err.type = 'validation-error'
46
-
47
- const sol: ISolution = getSolution((error as IError).slug)
48
- _err.video = sol.video
49
- _err.gif = sol.gif
50
- _err.message = typeof message === 'string' ? message : sol.message
51
- return _err
52
- }
53
-
54
- export const NotFoundError = (error: IError | string) => {
55
- const message = (error as IError).message || (error as string)
56
- const _err = new Error(message) as IError
57
- _err.status = 400
58
- _err.type = 'not-found-error'
59
-
60
- const sol = getSolution((error as IError).slug)
61
- _err.video = sol.video
62
- _err.gif = sol.gif
63
- _err.message = typeof message === 'string' ? message : sol.message
64
- return _err
65
- }
66
-
67
- export const CompilerError = (error: IError | string) => {
68
- const message = (error as IError).message || (error as string)
69
- const _err = new Error(message) as IError
70
- _err.status = 400
71
- _err.type = 'compiler-error'
72
-
73
- const sol = getSolution((error as IError).slug)
74
- _err.video = sol.video
75
- _err.gif = sol.gif
76
- _err.message = typeof message === 'string' ? message : sol.message
77
- return _err
78
- }
79
-
80
- export const TestingError = (error: IError | string) => {
81
- const message = (error as IError).message || (error as string)
82
- const _err = new Error(message) as IError
83
- _err.status = 400
84
- _err.type = 'testing-error'
85
- return _err
86
- }
87
-
88
- export const AuthError = (error: IError | string) => {
89
- const message = (error as IError).message || (error as string)
90
- const _err = new Error(message) as IError
91
- _err.status = 403
92
- _err.type = 'auth-error'
93
- return _err
94
- }
95
-
96
- export const InternalError = (error: IError | string) => {
97
- const message = (error as IError).message || (error as string)
98
- const _err = new Error(message) as IError
99
- _err.status = 500
100
- _err.type = 'internal-error'
101
-
102
- const sol = getSolution((error as IError).slug)
103
- _err.video = sol.video
104
- _err.gif = sol.gif
105
- _err.message = typeof message === 'string' ? message : sol.message
106
- return _err
107
- }
108
-
109
- getSolution()
110
- export default {
111
- ValidationError,
112
- CompilerError,
113
- TestingError,
114
- NotFoundError,
115
- InternalError,
116
- AuthError,
117
- }
1
+ import Console from './console'
2
+
3
+ import {ISolution, IError} from '../models/errors'
4
+
5
+ // eslint-disable-next-line
6
+ const fetch = require("node-fetch");
7
+
8
+ let solutions: { [key: string]: ISolution } | null = null
9
+
10
+ const uknown: ISolution = {
11
+ video: 'https://www.youtube.com/watch?v=gD1Sa99GiE4',
12
+ message: 'Uknown internal error',
13
+ slug: 'uknown',
14
+ gif: 'https://github.com/breatheco-de/breathecode-cli/blob/master/docs/errors/uknown.gif?raw=true',
15
+ }
16
+
17
+ export const getSolution = (slug?: string): ISolution => {
18
+ if (!slug) {
19
+ Console.debug('Getting solution templates from the learnpack repository')
20
+ } else {
21
+ Console.debug(`Getting solution for ${slug}`, solutions)
22
+ }
23
+
24
+ if (!solutions) {
25
+ Console.debug('Fetching for errors.json on github')
26
+ fetch(
27
+ 'https://raw.githubusercontent.com/breatheco-de/breathecode-cli/master/docs/errors/errors.json',
28
+ )
29
+ .then((r: Response) => r.json())
30
+ .then(function (_s: { [key: string]: ISolution }) {
31
+ solutions = _s
32
+ })
33
+ return uknown
34
+ }
35
+
36
+ return typeof solutions[slug || ''] === 'undefined' || !slug ?
37
+ uknown :
38
+ solutions[slug]
39
+ }
40
+
41
+ export const ValidationError = (error: IError | string) => {
42
+ const message: string = (error as IError).message || (error as string)
43
+ const _err = new Error(message) as IError
44
+ _err.status = 400
45
+ _err.type = 'validation-error'
46
+
47
+ const sol: ISolution = getSolution((error as IError).slug)
48
+ _err.video = sol.video
49
+ _err.gif = sol.gif
50
+ _err.message = typeof message === 'string' ? message : sol.message
51
+ return _err
52
+ }
53
+
54
+ export const NotFoundError = (error: IError | string) => {
55
+ const message = (error as IError).message || (error as string)
56
+ const _err = new Error(message) as IError
57
+ _err.status = 400
58
+ _err.type = 'not-found-error'
59
+
60
+ const sol = getSolution((error as IError).slug)
61
+ _err.video = sol.video
62
+ _err.gif = sol.gif
63
+ _err.message = typeof message === 'string' ? message : sol.message
64
+ return _err
65
+ }
66
+
67
+ export const CompilerError = (error: IError | string) => {
68
+ const message = (error as IError).message || (error as string)
69
+ const _err = new Error(message) as IError
70
+ _err.status = 400
71
+ _err.type = 'compiler-error'
72
+
73
+ const sol = getSolution((error as IError).slug)
74
+ _err.video = sol.video
75
+ _err.gif = sol.gif
76
+ _err.message = typeof message === 'string' ? message : sol.message
77
+ return _err
78
+ }
79
+
80
+ export const TestingError = (error: IError | string) => {
81
+ const message = (error as IError).message || (error as string)
82
+ const _err = new Error(message) as IError
83
+ _err.status = 400
84
+ _err.type = 'testing-error'
85
+ return _err
86
+ }
87
+
88
+ export const AuthError = (error: IError | string) => {
89
+ const message = (error as IError).message || (error as string)
90
+ const _err = new Error(message) as IError
91
+ _err.status = 403
92
+ _err.type = 'auth-error'
93
+ return _err
94
+ }
95
+
96
+ export const InternalError = (error: IError | string) => {
97
+ const message = (error as IError).message || (error as string)
98
+ const _err = new Error(message) as IError
99
+ _err.status = 500
100
+ _err.type = 'internal-error'
101
+
102
+ const sol = getSolution((error as IError).slug)
103
+ _err.video = sol.video
104
+ _err.gif = sol.gif
105
+ _err.message = typeof message === 'string' ? message : sol.message
106
+ return _err
107
+ }
108
+
109
+ getSolution()
110
+ export default {
111
+ ValidationError,
112
+ CompilerError,
113
+ TestingError,
114
+ NotFoundError,
115
+ InternalError,
116
+ AuthError,
117
+ }
@@ -1,51 +1,51 @@
1
- import { IConfig } from "../models/config"
2
- import { IExercise } from "../models/exercise-obj"
3
- import { ISocket } from "../models/socket"
4
-
5
- class Exercise {
6
- exercise: IExercise
7
- constructor(exercise: IExercise) {
8
- this.exercise = exercise
9
- }
10
-
11
- test(sessionConfig: IConfig, config: IConfig, socket: ISocket) {
12
- if (this.exercise.language) {
13
- socket.log(
14
- "testing",
15
- `Testing exercise ${this.exercise.slug} using ${this.exercise.language} engine`
16
- )
17
-
18
- sessionConfig.runHook("action", {
19
- action: "test",
20
- socket,
21
- configuration: config,
22
- exercise: this.exercise,
23
- })
24
- } else {
25
- socket.onTestingFinished({ result: "success" })
26
- }
27
- }
28
- }
29
-
30
- class ExercisesQueue {
31
- exercises: IExercise[]
32
- constructor(exercises: any) {
33
- this.exercises = exercises.map((exercise: IExercise) => {
34
- return new Exercise(exercise)
35
- })
36
- }
37
-
38
- pop() {
39
- return this.exercises.shift()
40
- }
41
-
42
- isEmpty() {
43
- return this.size() === 0
44
- }
45
-
46
- size() {
47
- return this.exercises.length
48
- }
49
- }
50
-
51
- export default ExercisesQueue
1
+ import { IConfig } from "../models/config"
2
+ import { IExercise } from "../models/exercise-obj"
3
+ import { ISocket } from "../models/socket"
4
+
5
+ class Exercise {
6
+ exercise: IExercise
7
+ constructor(exercise: IExercise) {
8
+ this.exercise = exercise
9
+ }
10
+
11
+ test(sessionConfig: IConfig, config: IConfig, socket: ISocket) {
12
+ if (this.exercise.language) {
13
+ socket.log(
14
+ "testing",
15
+ `Testing exercise ${this.exercise.slug} using ${this.exercise.language} engine`
16
+ )
17
+
18
+ sessionConfig.runHook("action", {
19
+ action: "test",
20
+ socket,
21
+ configuration: config,
22
+ exercise: this.exercise,
23
+ })
24
+ } else {
25
+ socket.onTestingFinished({ result: "success" })
26
+ }
27
+ }
28
+ }
29
+
30
+ class ExercisesQueue {
31
+ exercises: IExercise[]
32
+ constructor(exercises: any) {
33
+ this.exercises = exercises.map((exercise: IExercise) => {
34
+ return new Exercise(exercise)
35
+ })
36
+ }
37
+
38
+ pop() {
39
+ return this.exercises.shift()
40
+ }
41
+
42
+ isEmpty() {
43
+ return this.size() === 0
44
+ }
45
+
46
+ size() {
47
+ return this.exercises.length
48
+ }
49
+ }
50
+
51
+ export default ExercisesQueue