@learnpack/learnpack 5.0.2 → 5.0.3

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @learnpack/learnpack
21
21
  $ learnpack COMMAND
22
22
  running command...
23
23
  $ learnpack (-v|--version|version)
24
- @learnpack/learnpack/5.0.2 win32-x64 node-v20.16.0
24
+ @learnpack/learnpack/5.0.3 win32-x64 node-v20.16.0
25
25
  $ learnpack --help [COMMAND]
26
26
  USAGE
27
27
  $ learnpack COMMAND
@@ -74,7 +74,7 @@ DESCRIPTION
74
74
  12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
75
75
  ```
76
76
 
77
- _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.2/src\commands\audit.ts)_
77
+ _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.3/src\commands\audit.ts)_
78
78
 
79
79
  ## `learnpack clean`
80
80
 
@@ -89,7 +89,7 @@ DESCRIPTION
89
89
  Extra documentation goes here
90
90
  ```
91
91
 
92
- _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.2/src\commands\clean.ts)_
92
+ _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.3/src\commands\clean.ts)_
93
93
 
94
94
  ## `learnpack download [PACKAGE]`
95
95
 
@@ -107,7 +107,7 @@ DESCRIPTION
107
107
  Extra documentation goes here
108
108
  ```
109
109
 
110
- _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.2/src\commands\download.ts)_
110
+ _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.3/src\commands\download.ts)_
111
111
 
112
112
  ## `learnpack help [COMMAND]`
113
113
 
@@ -138,7 +138,7 @@ OPTIONS
138
138
  -h, --grading show CLI help
139
139
  ```
140
140
 
141
- _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.2/src\commands\init.ts)_
141
+ _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.3/src\commands\init.ts)_
142
142
 
143
143
  ## `learnpack login [PACKAGE]`
144
144
 
@@ -156,7 +156,7 @@ DESCRIPTION
156
156
  Extra documentation goes here
157
157
  ```
158
158
 
159
- _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.2/src\commands\login.ts)_
159
+ _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.3/src\commands\login.ts)_
160
160
 
161
161
  ## `learnpack logout [PACKAGE]`
162
162
 
@@ -174,7 +174,7 @@ DESCRIPTION
174
174
  Extra documentation goes here
175
175
  ```
176
176
 
177
- _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.2/src\commands\logout.ts)_
177
+ _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.3/src\commands\logout.ts)_
178
178
 
179
179
  ## `learnpack plugins`
180
180
 
@@ -305,7 +305,7 @@ OPTIONS
305
305
  -h, --help show CLI help
306
306
  ```
307
307
 
308
- _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.2/src\commands\publish.ts)_
308
+ _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.3/src\commands\publish.ts)_
309
309
 
310
310
  ## `learnpack start`
311
311
 
@@ -326,7 +326,7 @@ OPTIONS
326
326
  -w, --watch Watch for file changes
327
327
  ```
328
328
 
329
- _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.2/src\commands\start.ts)_
329
+ _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.3/src\commands\start.ts)_
330
330
 
331
331
  ## `learnpack test [EXERCISESLUG]`
332
332
 
@@ -340,7 +340,7 @@ ARGUMENTS
340
340
  EXERCISESLUG The name of the exercise to test
341
341
  ```
342
342
 
343
- _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.2/src\commands\test.ts)_
343
+ _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.3/src\commands\test.ts)_
344
344
  <!-- commandsstop -->
345
345
 
346
346
  > > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
@@ -7,50 +7,44 @@ const fs_1 = require("fs");
7
7
  const console_1 = require("../utils/console");
8
8
  const RIGOBOT_HOST = "https://rigobot.herokuapp.com";
9
9
  const getExercisesNames = async (token, inputs) => {
10
- const result = await fetch(`${RIGOBOT_HOST}/v1/prompting/completion/60/`, {
11
- method: "POST",
10
+ const response = await axios_1.default.post(`${RIGOBOT_HOST}/v1/prompting/completion/60/`, {
11
+ inputs: inputs,
12
+ include_purpose_objective: false,
13
+ execute_async: false,
14
+ }, {
12
15
  headers: {
13
16
  "Content-Type": "application/json",
14
17
  Authorization: "Token " + token,
15
18
  },
16
- body: JSON.stringify({
17
- inputs: inputs,
18
- include_purpose_objective: false,
19
- execute_async: false,
20
- }),
21
19
  });
22
- const json = await result.json();
23
- return json;
20
+ return response.data;
24
21
  };
25
22
  exports.getExercisesNames = getExercisesNames;
26
23
  const createReadme = async (token, inputs) => {
27
- const result = await fetch(`${RIGOBOT_HOST}/v1/prompting/completion/61/`, {
28
- method: "POST",
24
+ const response = await axios_1.default.post(`${RIGOBOT_HOST}/v1/prompting/completion/61/`, {
25
+ inputs: inputs,
26
+ include_purpose_objective: false,
27
+ execute_async: false,
28
+ }, {
29
29
  headers: {
30
30
  "Content-Type": "application/json",
31
31
  Authorization: "Token " + token,
32
32
  },
33
- body: JSON.stringify({
34
- inputs: inputs,
35
- include_purpose_objective: false,
36
- execute_async: false,
37
- }),
38
33
  });
39
- const json = await result.json();
40
- return json;
34
+ return response.data;
41
35
  };
42
36
  exports.createReadme = createReadme;
43
37
  const hasCreatorPermission = async (token) => {
44
38
  console_1.default.debug("Checking if user has creator permission");
45
39
  try {
46
- const result = await fetch(`${RIGOBOT_HOST}/v1/learnpack/permissions/creator`, {
47
- method: "GET",
40
+ const response = await axios_1.default.get(`${RIGOBOT_HOST}/v1/learnpack/permissions/creator`, {
48
41
  headers: {
49
42
  "Content-Type": "application/json",
50
43
  Authorization: "Token " + token,
51
44
  },
52
45
  });
53
- if (result.status === 403)
46
+ // If the status code is 403, it means no permission
47
+ if (response.status === 403)
54
48
  return false;
55
49
  console_1.default.debug("The user is a creator! 🎉");
56
50
  return true;
@@ -63,19 +57,18 @@ const hasCreatorPermission = async (token) => {
63
57
  exports.hasCreatorPermission = hasCreatorPermission;
64
58
  const generateImage = async (token, { prompt }) => {
65
59
  try {
66
- const result = await fetch(`${RIGOBOT_HOST}/v1/learnpack/tools/images`, {
67
- method: "POST",
60
+ const response = await axios_1.default.post(`${RIGOBOT_HOST}/v1/learnpack/tools/images`, {
61
+ prompt,
62
+ }, {
68
63
  headers: {
69
64
  "Content-Type": "application/json",
70
65
  Authorization: "Token " + token,
71
66
  },
72
- body: JSON.stringify({ prompt }),
73
67
  });
74
- const json = await result.json();
75
- return json;
68
+ return response.data;
76
69
  }
77
70
  catch (error) {
78
- console.log(error);
71
+ console_1.default.debug(error);
79
72
  return null;
80
73
  }
81
74
  };
@@ -85,7 +78,7 @@ async function downloadImage(imageUrl, savePath) {
85
78
  const buffer = Buffer.from(response.data, "binary");
86
79
  (0, fs_1.writeFile)(savePath, buffer, err => {
87
80
  if (err) {
88
- console.error("Error saving the image:", err);
81
+ console_1.default.error(`Error saving the image: ${err}`);
89
82
  }
90
83
  });
91
84
  }
@@ -1 +1 @@
1
- {"version":"5.0.2","commands":{"audit":{"id":"audit","description":"learnpack audit is the command in charge of creating an auditory of the repository\n...\nlearnpack audit checks for the following information in a repository:\n 1. The configuration object has slug, repository and description. (Error)\n 2. The command learnpack clean has been run. (Error)\n 3. If a markdown or test file doesn't have any content. (Error)\n 4. The links are accessing to valid servers. (Error)\n 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)\n 6. The external images are working (If they are pointing to a valid server). (Error)\n 7. The exercises directory names are valid. (Error)\n 8. If an exercise doesn't have a README file. (Error)\n 9. The exercises array (Of the config file) has content. (Error)\n 10. The exercses have the same translations. (Warning)\n 11. The .gitignore file exists. (Warning)\n 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"login":{"id":"login","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"logout":{"id":"logout","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"publish":{"id":"publish","description":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"disableGrading":{"name":"disableGrading","type":"boolean","char":"D","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"editor":{"name":"editor","type":"option","char":"e","description":"[preview, extension]","options":["extension","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1"},"grading":{"name":"grading","type":"option","char":"g","description":"[isolated, incremental]","options":["isolated","incremental"]},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"test":{"id":"test","description":"Test exercises","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]}}}
1
+ {"version":"5.0.3","commands":{"audit":{"id":"audit","description":"learnpack audit is the command in charge of creating an auditory of the repository\n...\nlearnpack audit checks for the following information in a repository:\n 1. The configuration object has slug, repository and description. (Error)\n 2. The command learnpack clean has been run. (Error)\n 3. If a markdown or test file doesn't have any content. (Error)\n 4. The links are accessing to valid servers. (Error)\n 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)\n 6. The external images are working (If they are pointing to a valid server). (Error)\n 7. The exercises directory names are valid. (Error)\n 8. If an exercise doesn't have a README file. (Error)\n 9. The exercises array (Of the config file) has content. (Error)\n 10. The exercses have the same translations. (Warning)\n 11. The .gitignore file exists. (Warning)\n 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"login":{"id":"login","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"logout":{"id":"logout","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"publish":{"id":"publish","description":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"disableGrading":{"name":"disableGrading","type":"boolean","char":"D","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"editor":{"name":"editor","type":"option","char":"e","description":"[preview, extension]","options":["extension","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1"},"grading":{"name":"grading","type":"option","char":"g","description":"[isolated, incremental]","options":["isolated","incremental"]},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"test":{"id":"test","description":"Test exercises","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@learnpack/learnpack",
3
3
  "description": "Seamlessly build, sell and/or take interactive & auto-graded tutorials, start learning now or build a new tutorial to your audience.",
4
- "version": "5.0.2",
4
+ "version": "5.0.3",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -5,21 +5,22 @@ import Console from "../utils/console"
5
5
  const RIGOBOT_HOST = "https://rigobot.herokuapp.com"
6
6
 
7
7
  export const getExercisesNames = async (token: string, inputs: object) => {
8
- const result = await fetch(`${RIGOBOT_HOST}/v1/prompting/completion/60/`, {
9
- method: "POST",
10
- headers: {
11
- "Content-Type": "application/json",
12
- Authorization: "Token " + token,
13
- },
14
- body: JSON.stringify({
8
+ const response = await axios.post(
9
+ `${RIGOBOT_HOST}/v1/prompting/completion/60/`,
10
+ {
15
11
  inputs: inputs,
16
12
  include_purpose_objective: false,
17
13
  execute_async: false,
18
- }),
19
- })
20
- const json = await result.json()
14
+ },
15
+ {
16
+ headers: {
17
+ "Content-Type": "application/json",
18
+ Authorization: "Token " + token,
19
+ },
20
+ }
21
+ )
21
22
 
22
- return json
23
+ return response.data
23
24
  }
24
25
 
25
26
  type TCreateReadmeInputs = {
@@ -28,41 +29,44 @@ type TCreateReadmeInputs = {
28
29
  list_of_exercises: string
29
30
  tutorial_description: string
30
31
  }
32
+
31
33
  export const createReadme = async (
32
34
  token: string,
33
35
  inputs: TCreateReadmeInputs
34
36
  ) => {
35
- const result = await fetch(`${RIGOBOT_HOST}/v1/prompting/completion/61/`, {
36
- method: "POST",
37
- headers: {
38
- "Content-Type": "application/json",
39
- Authorization: "Token " + token,
40
- },
41
- body: JSON.stringify({
37
+ const response = await axios.post(
38
+ `${RIGOBOT_HOST}/v1/prompting/completion/61/`,
39
+ {
42
40
  inputs: inputs,
43
41
  include_purpose_objective: false,
44
42
  execute_async: false,
45
- }),
46
- })
47
- const json = await result.json()
43
+ },
44
+ {
45
+ headers: {
46
+ "Content-Type": "application/json",
47
+ Authorization: "Token " + token,
48
+ },
49
+ }
50
+ )
48
51
 
49
- return json
52
+ return response.data
50
53
  }
51
54
 
52
55
  export const hasCreatorPermission = async (token: string) => {
53
56
  Console.debug("Checking if user has creator permission")
54
57
  try {
55
- const result = await fetch(
58
+ const response = await axios.get(
56
59
  `${RIGOBOT_HOST}/v1/learnpack/permissions/creator`,
57
60
  {
58
- method: "GET",
59
61
  headers: {
60
62
  "Content-Type": "application/json",
61
63
  Authorization: "Token " + token,
62
64
  },
63
65
  }
64
66
  )
65
- if (result.status === 403)
67
+
68
+ // If the status code is 403, it means no permission
69
+ if (response.status === 403)
66
70
  return false
67
71
 
68
72
  Console.debug("The user is a creator! 🎉")
@@ -82,20 +86,22 @@ export const generateImage = async (
82
86
  { prompt }: TGenerateImageParams
83
87
  ) => {
84
88
  try {
85
- const result = await fetch(`${RIGOBOT_HOST}/v1/learnpack/tools/images`, {
86
- method: "POST",
87
- headers: {
88
- "Content-Type": "application/json",
89
- Authorization: "Token " + token,
89
+ const response = await axios.post(
90
+ `${RIGOBOT_HOST}/v1/learnpack/tools/images`,
91
+ {
92
+ prompt,
90
93
  },
91
- body: JSON.stringify({ prompt }),
92
- })
94
+ {
95
+ headers: {
96
+ "Content-Type": "application/json",
97
+ Authorization: "Token " + token,
98
+ },
99
+ }
100
+ )
93
101
 
94
- const json = await result.json()
95
- return json
102
+ return response.data
96
103
  } catch (error) {
97
- console.log(error)
98
-
104
+ Console.debug(error)
99
105
  return null
100
106
  }
101
107
  }
@@ -109,7 +115,7 @@ export async function downloadImage(
109
115
 
110
116
  writeFile(savePath, buffer, err => {
111
117
  if (err) {
112
- console.error("Error saving the image:", err)
118
+ Console.error(`Error saving the image: ${err}`)
113
119
  }
114
120
  })
115
121
  }