@learnpack/learnpack 5.0.19 → 5.0.21

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/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.19 win32-x64 node-v20.16.0
24
+ @learnpack/learnpack/5.0.21 win32-x64 node-v20.16.0
25
25
  $ learnpack --help [COMMAND]
26
26
  USAGE
27
27
  $ learnpack COMMAND
@@ -75,7 +75,7 @@ DESCRIPTION
75
75
  12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
76
76
  ```
77
77
 
78
- _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.19/src\commands\audit.ts)_
78
+ _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.21/src\commands\audit.ts)_
79
79
 
80
80
  ## `learnpack clean`
81
81
 
@@ -90,7 +90,7 @@ DESCRIPTION
90
90
  Extra documentation goes here
91
91
  ```
92
92
 
93
- _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.19/src\commands\clean.ts)_
93
+ _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.21/src\commands\clean.ts)_
94
94
 
95
95
  ## `learnpack download [PACKAGE]`
96
96
 
@@ -108,7 +108,7 @@ DESCRIPTION
108
108
  Extra documentation goes here
109
109
  ```
110
110
 
111
- _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.19/src\commands\download.ts)_
111
+ _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.21/src\commands\download.ts)_
112
112
 
113
113
  ## `learnpack help [COMMAND]`
114
114
 
@@ -140,7 +140,7 @@ OPTIONS
140
140
  -y, --yes Skip all prompts and initialize an empty project
141
141
  ```
142
142
 
143
- _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.19/src\commands\init.ts)_
143
+ _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.21/src\commands\init.ts)_
144
144
 
145
145
  ## `learnpack login [PACKAGE]`
146
146
 
@@ -158,7 +158,7 @@ DESCRIPTION
158
158
  Extra documentation goes here
159
159
  ```
160
160
 
161
- _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.19/src\commands\login.ts)_
161
+ _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.21/src\commands\login.ts)_
162
162
 
163
163
  ## `learnpack logout [PACKAGE]`
164
164
 
@@ -176,7 +176,7 @@ DESCRIPTION
176
176
  Extra documentation goes here
177
177
  ```
178
178
 
179
- _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.19/src\commands\logout.ts)_
179
+ _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.21/src\commands\logout.ts)_
180
180
 
181
181
  ## `learnpack plugins`
182
182
 
@@ -307,7 +307,7 @@ OPTIONS
307
307
  -h, --help show CLI help
308
308
  ```
309
309
 
310
- _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.19/src\commands\publish.ts)_
310
+ _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.21/src\commands\publish.ts)_
311
311
 
312
312
  ## `learnpack start`
313
313
 
@@ -329,7 +329,7 @@ OPTIONS
329
329
  -y, --yes Skip all prompts and initialize an empty project
330
330
  ```
331
331
 
332
- _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.19/src\commands\start.ts)_
332
+ _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.21/src\commands\start.ts)_
333
333
 
334
334
  ## `learnpack test [EXERCISESLUG]`
335
335
 
@@ -346,7 +346,7 @@ OPTIONS
346
346
  -y, --yes Skip all prompts and initialize an empty project
347
347
  ```
348
348
 
349
- _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.19/src\commands\test.ts)_
349
+ _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.21/src\commands\test.ts)_
350
350
 
351
351
  ## `learnpack translate`
352
352
 
@@ -360,7 +360,7 @@ OPTIONS
360
360
  -y, --yes Skip all prompts and initialize an empty project
361
361
  ```
362
362
 
363
- _See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.19/src\commands\translate.ts)_
363
+ _See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.21/src\commands\translate.ts)_
364
364
  <!-- commandsstop -->
365
365
 
366
366
  > > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /* eslint-disable arrow-parens */
4
4
  /* eslint-disable unicorn/no-array-for-each */
5
+ const child_process_1 = require("child_process");
5
6
  const command_1 = require("@oclif/command");
6
7
  const SessionCommand_1 = require("../utils/SessionCommand");
7
8
  const session_1 = require("../managers/session");
@@ -16,6 +17,26 @@ const RIGOBOT_HOST = "https://rigobot.herokuapp.com";
16
17
  // const RIGOBOT_HOST =
17
18
  // "https://8000-charlytoc-rigobot-bmwdeam7cev.ws-us116.gitpod.io"
18
19
  const uploadZipEndpont = RIGOBOT_HOST + "/v1/learnpack/upload";
20
+ const runAudit = () => {
21
+ try {
22
+ console_1.default.info("Running learnpack audit before publishing...");
23
+ (0, child_process_1.execSync)("learnpack audit", { stdio: "inherit" });
24
+ }
25
+ catch (error) {
26
+ console_1.default.error("Failed to audit with learnpack");
27
+ // Si `execSync` lanza un error, capturamos el mensaje de error
28
+ if (error instanceof Error) {
29
+ console_1.default.error(error.message);
30
+ }
31
+ else {
32
+ console_1.default.error("Unknown error occurred");
33
+ }
34
+ // Detener la ejecución del comando si `learnpack publish` falla
35
+ process.exit(1);
36
+ }
37
+ // Continuar con el proceso de build solo si `learnpack publish` fue exitoso
38
+ console_1.default.info("Learnpack publish completed successfully. Proceeding with build...");
39
+ };
19
40
  class BuildCommand extends SessionCommand_1.default {
20
41
  async init() {
21
42
  const { flags } = this.parse(BuildCommand);
@@ -42,6 +63,7 @@ class BuildCommand extends SessionCommand_1.default {
42
63
  console_1.default.info("Cleaning configuration files");
43
64
  (_b = this.configManager) === null || _b === void 0 ? void 0 : _b.clean();
44
65
  // build exerises
66
+ runAudit();
45
67
  console_1.default.debug("Building exercises");
46
68
  (_c = this.configManager) === null || _c === void 0 ? void 0 : _c.buildIndex();
47
69
  }
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const socket_io_1 = require("socket.io");
4
4
  const console_1 = require("../utils/console");
5
5
  const fileQueue_1 = require("../utils/fileQueue");
6
+ const languageToMessage = {
7
+ python3: "Your code executed without erros, but no output is shown on the terminal. Maybe you forgot to include a print statement in your code?",
8
+ node: "Your code executed without erros, but no output is shown on the terminal. Maybe you forgot to include a console.log statement in your code?",
9
+ };
6
10
  const SocketManager = {
7
11
  socket: null,
8
12
  config: null,
@@ -144,14 +148,20 @@ const SocketManager = {
144
148
  ready: function (message) {
145
149
  this.log("ready", [message]);
146
150
  },
147
- success: function (type, stdout) {
151
+ success: function (type, stdout, lang) {
148
152
  const types = ["compiler", "testing"];
149
153
  if (!types.includes(type))
150
154
  this.fatal(`Invalid socket success type "${type}" on socket`);
151
- else if (stdout === "")
155
+ else if (stdout === "" &&
156
+ lang &&
157
+ Object.keys(languageToMessage).includes(lang)) {
158
+ this.log((type + "-success"), [languageToMessage[lang]]);
159
+ }
160
+ else if (stdout === "") {
152
161
  this.log((type + "-success"), [
153
162
  "No stdout to display on the console",
154
163
  ]);
164
+ }
155
165
  else
156
166
  this.log((type + "-success"), [stdout]);
157
167
  },
@@ -29,7 +29,7 @@ export interface ISocket {
29
29
  error: (type: any, stdout: string) => void;
30
30
  fatal: (msg: string) => void;
31
31
  dialog: (message: string) => void;
32
- success: (type: any, stdout: string) => void;
32
+ success: (type: any, stdout: string, lang?: string) => void;
33
33
  onTestingFinished: (obj: any) => void;
34
34
  }
35
35
  export type TOpenWindowData = {
@@ -1 +1 @@
1
- {"version":"5.0.19","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":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"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":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"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":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]},"translate":{"id":"translate","description":"List all the lessons, the user is able of select many of them to translate to the given languages","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[]}}}
1
+ {"version":"5.0.21","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":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"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":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"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":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]},"translate":{"id":"translate","description":"List all the lessons, the user is able of select many of them to translate to the given languages","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[]}}}
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.19",
4
+ "version": "5.0.21",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable arrow-parens */
2
2
  /* eslint-disable unicorn/no-array-for-each */
3
+ import { execSync } from "child_process"
3
4
  import { flags } from "@oclif/command"
4
5
  import SessionCommand from "../utils/SessionCommand"
5
6
  import SessionManager from "../managers/session"
@@ -20,6 +21,30 @@ const RIGOBOT_HOST = "https://rigobot.herokuapp.com"
20
21
  // "https://8000-charlytoc-rigobot-bmwdeam7cev.ws-us116.gitpod.io"
21
22
  const uploadZipEndpont = RIGOBOT_HOST + "/v1/learnpack/upload"
22
23
 
24
+ const runAudit = () => {
25
+ try {
26
+ Console.info("Running learnpack audit before publishing...")
27
+ execSync("learnpack audit", { stdio: "inherit" })
28
+ } catch (error) {
29
+ Console.error("Failed to audit with learnpack")
30
+
31
+ // Si `execSync` lanza un error, capturamos el mensaje de error
32
+ if (error instanceof Error) {
33
+ Console.error(error.message)
34
+ } else {
35
+ Console.error("Unknown error occurred")
36
+ }
37
+
38
+ // Detener la ejecución del comando si `learnpack publish` falla
39
+ process.exit(1)
40
+ }
41
+
42
+ // Continuar con el proceso de build solo si `learnpack publish` fue exitoso
43
+ Console.info(
44
+ "Learnpack publish completed successfully. Proceeding with build..."
45
+ )
46
+ }
47
+
23
48
  export default class BuildCommand extends SessionCommand {
24
49
  static description =
25
50
  "Builds the project by copying necessary files and directories into a zip file"
@@ -56,6 +81,8 @@ export default class BuildCommand extends SessionCommand {
56
81
  Console.info("Cleaning configuration files")
57
82
  this.configManager?.clean()
58
83
  // build exerises
84
+ runAudit()
85
+
59
86
  Console.debug("Building exercises")
60
87
  this.configManager?.buildIndex()
61
88
  }
@@ -10,6 +10,12 @@ import { TStatus } from "../models/status"
10
10
  import { TSuccessType } from "../models/success-types"
11
11
  import * as http from "http"
12
12
 
13
+ const languageToMessage: Record<string, string> = {
14
+ python3:
15
+ "Your code executed without erros, but no output is shown on the terminal. Maybe you forgot to include a print statement in your code?",
16
+ node: "Your code executed without erros, but no output is shown on the terminal. Maybe you forgot to include a console.log statement in your code?",
17
+ }
18
+
13
19
  const SocketManager: ISocket = {
14
20
  socket: null,
15
21
  config: null,
@@ -211,16 +217,22 @@ actions = [actions]
211
217
  ready: function (message: string) {
212
218
  this.log("ready", [message])
213
219
  },
214
- success: function (type: TSuccessType, stdout: string) {
220
+ success: function (type: TSuccessType, stdout: string, lang) {
215
221
  const types = ["compiler", "testing"]
216
222
 
217
223
  if (!types.includes(type))
218
224
  this.fatal(`Invalid socket success type "${type}" on socket`)
219
- else if (stdout === "")
225
+ else if (
226
+ stdout === "" &&
227
+ lang &&
228
+ Object.keys(languageToMessage).includes(lang)
229
+ ) {
230
+ this.log((type + "-success") as TSuccessType, [languageToMessage[lang]])
231
+ } else if (stdout === "") {
220
232
  this.log((type + "-success") as TSuccessType, [
221
233
  "No stdout to display on the console",
222
234
  ])
223
- else
235
+ } else
224
236
  this.log((type + "-success") as TSuccessType, [stdout])
225
237
  },
226
238
  error: function (type: TStatus, stdout: string) {
@@ -51,7 +51,7 @@ export interface ISocket {
51
51
  error: (type: any, stdout: string) => void
52
52
  fatal: (msg: string) => void
53
53
  dialog: (message: string) => void
54
- success: (type: any, stdout: string) => void
54
+ success: (type: any, stdout: string, lang?: string) => void
55
55
  onTestingFinished: (obj: any) => void
56
56
  }
57
57