@learnpack/learnpack 5.0.38 → 5.0.39

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.38 win32-x64 node-v22.14.0
24
+ @learnpack/learnpack/5.0.39 win32-x64 node-v22.14.0
25
25
  $ learnpack --help [COMMAND]
26
26
  USAGE
27
27
  $ learnpack COMMAND
@@ -58,6 +58,9 @@ learnpack audit is the command in charge of creating an auditory of the reposito
58
58
  USAGE
59
59
  $ learnpack audit
60
60
 
61
+ OPTIONS
62
+ -s, --strict strict mode
63
+
61
64
  DESCRIPTION
62
65
  ...
63
66
  learnpack audit checks for the following information in a repository:
@@ -76,7 +79,7 @@ DESCRIPTION
76
79
  12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
77
80
  ```
78
81
 
79
- _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.38/src\commands\audit.ts)_
82
+ _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.39/src\commands\audit.ts)_
80
83
 
81
84
  ## `learnpack breakToken`
82
85
 
@@ -91,7 +94,7 @@ OPTIONS
91
94
  -y, --yes Skip all prompts and initialize an empty project
92
95
  ```
93
96
 
94
- _See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.38/src\commands\breakToken.ts)_
97
+ _See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.39/src\commands\breakToken.ts)_
95
98
 
96
99
  ## `learnpack clean`
97
100
 
@@ -106,7 +109,7 @@ DESCRIPTION
106
109
  Extra documentation goes here
107
110
  ```
108
111
 
109
- _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.38/src\commands\clean.ts)_
112
+ _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.39/src\commands\clean.ts)_
110
113
 
111
114
  ## `learnpack download [PACKAGE]`
112
115
 
@@ -124,7 +127,7 @@ DESCRIPTION
124
127
  Extra documentation goes here
125
128
  ```
126
129
 
127
- _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.38/src\commands\download.ts)_
130
+ _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.39/src\commands\download.ts)_
128
131
 
129
132
  ## `learnpack help [COMMAND]`
130
133
 
@@ -156,7 +159,7 @@ OPTIONS
156
159
  -y, --yes Skip all prompts and initialize an empty project
157
160
  ```
158
161
 
159
- _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.38/src\commands\init.ts)_
162
+ _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.39/src\commands\init.ts)_
160
163
 
161
164
  ## `learnpack login [PACKAGE]`
162
165
 
@@ -174,7 +177,7 @@ DESCRIPTION
174
177
  Extra documentation goes here
175
178
  ```
176
179
 
177
- _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.38/src\commands\login.ts)_
180
+ _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.39/src\commands\login.ts)_
178
181
 
179
182
  ## `learnpack logout [PACKAGE]`
180
183
 
@@ -192,7 +195,7 @@ DESCRIPTION
192
195
  Extra documentation goes here
193
196
  ```
194
197
 
195
- _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.38/src\commands\logout.ts)_
198
+ _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.39/src\commands\logout.ts)_
196
199
 
197
200
  ## `learnpack plugins`
198
201
 
@@ -320,10 +323,11 @@ USAGE
320
323
  $ learnpack publish
321
324
 
322
325
  OPTIONS
323
- -h, --help show CLI help
326
+ -h, --help show CLI help
327
+ -s, --strict strict mode
324
328
  ```
325
329
 
326
- _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.38/src\commands\publish.ts)_
330
+ _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.39/src\commands\publish.ts)_
327
331
 
328
332
  ## `learnpack start`
329
333
 
@@ -345,7 +349,7 @@ OPTIONS
345
349
  -y, --yes Skip all prompts and initialize an empty project
346
350
  ```
347
351
 
348
- _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.38/src\commands\start.ts)_
352
+ _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.39/src\commands\start.ts)_
349
353
 
350
354
  ## `learnpack test [EXERCISESLUG]`
351
355
 
@@ -362,7 +366,7 @@ OPTIONS
362
366
  -y, --yes Skip all prompts and initialize an empty project
363
367
  ```
364
368
 
365
- _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.38/src\commands\test.ts)_
369
+ _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.39/src\commands\test.ts)_
366
370
 
367
371
  ## `learnpack translate`
368
372
 
@@ -376,7 +380,7 @@ OPTIONS
376
380
  -y, --yes Skip all prompts and initialize an empty project
377
381
  ```
378
382
 
379
- _See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.38/src\commands\translate.ts)_
383
+ _See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.39/src\commands\translate.ts)_
380
384
  <!-- commandsstop -->
381
385
 
382
386
  > > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
@@ -6,6 +6,7 @@ const console_1 = require("../utils/console");
6
6
  const audit_1 = require("../utils/audit");
7
7
  const SessionCommand_1 = require("../utils/SessionCommand");
8
8
  const path = require("path");
9
+ const command_1 = require("@oclif/command");
9
10
  // eslint-disable-next-line
10
11
  const fetch = require("node-fetch");
11
12
  class AuditCommand extends SessionCommand_1.default {
@@ -15,6 +16,8 @@ class AuditCommand extends SessionCommand_1.default {
15
16
  }
16
17
  async run() {
17
18
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
19
+ const { flags } = this.parse(AuditCommand);
20
+ const strict = flags.strict;
18
21
  console_1.default.log("Running command audit...");
19
22
  // Get configuration object.
20
23
  let config = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.get();
@@ -87,12 +90,19 @@ class AuditCommand extends SessionCommand_1.default {
87
90
  msg: "The difficulty property is not in the configuration object",
88
91
  });
89
92
  // check if the bugs_link property is in the configuration object
90
- if (!((_h = config.config) === null || _h === void 0 ? void 0 : _h.bugsLink))
91
- errors.push({
92
- exercise: undefined,
93
- msg: "The bugsLink property is not in the configuration object",
94
- });
95
- // check if the video_solutions property is in the configuration object
93
+ if (!((_h = config.config) === null || _h === void 0 ? void 0 : _h.bugsLink)) {
94
+ if (strict)
95
+ errors.push({
96
+ exercise: undefined,
97
+ msg: "The bugsLink property is not in the configuration object",
98
+ });
99
+ else
100
+ warnings.push({
101
+ exercise: undefined,
102
+ msg: "The bugsLink property is not in the configuration object",
103
+ });
104
+ }
105
+ // check if the video_solutions property is in the configuration object
96
106
  if (((_j = config.config) === null || _j === void 0 ? void 0 : _j.videoSolutions) === undefined)
97
107
  warnings.push({
98
108
  exercise: undefined,
@@ -100,11 +110,18 @@ class AuditCommand extends SessionCommand_1.default {
100
110
  });
101
111
  // These two lines check if the 'repository' property is inside the configuration object.
102
112
  console_1.default.debug("Checking if the repository property is inside the configuration object...");
103
- if (!((_k = config.config) === null || _k === void 0 ? void 0 : _k.repository))
104
- errors.push({
105
- exercise: undefined,
106
- msg: "The repository property is not in the configuration object",
107
- });
113
+ if (!((_k = config.config) === null || _k === void 0 ? void 0 : _k.repository)) {
114
+ if (strict)
115
+ errors.push({
116
+ exercise: undefined,
117
+ msg: "The repository property is not in the configuration object",
118
+ });
119
+ else
120
+ warnings.push({
121
+ exercise: undefined,
122
+ msg: "The repository property is not in the configuration object",
123
+ });
124
+ }
108
125
  else
109
126
  audit_1.default.isUrl((_l = config.config) === null || _l === void 0 ? void 0 : _l.repository, errors, counter);
110
127
  // These two lines check if the 'description' property is inside the configuration object.
@@ -117,7 +134,7 @@ class AuditCommand extends SessionCommand_1.default {
117
134
  if (!((_o = config.config) === null || _o === void 0 ? void 0 : _o.projectType))
118
135
  errors.push({
119
136
  exercise: undefined,
120
- msg: "The projectType property mandatory in the configuration object",
137
+ msg: "The projectType property is mandatory in the configuration object",
121
138
  });
122
139
  if (errors.length === 0)
123
140
  console_1.default.log("The config file is ok");
@@ -346,6 +363,10 @@ learnpack audit checks for the following information in a repository:
346
363
  12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
347
364
  `;
348
365
  AuditCommand.flags = {
349
- // name: flags.string({char: 'n', description: 'name to print'}),
366
+ strict: command_1.flags.boolean({
367
+ char: "s",
368
+ description: "strict mode",
369
+ default: false,
370
+ }),
350
371
  };
351
372
  exports.default = AuditCommand;
@@ -25,6 +25,7 @@ const PARAMS = {
25
25
  max_fkgl: 8,
26
26
  max_words: 200,
27
27
  max_rewrite_attempts: 3,
28
+ max_title_length: 25,
28
29
  };
29
30
  const whichTargetAudience = async () => {
30
31
  const res = await prompts([
@@ -133,6 +134,9 @@ const initializeInteractiveCreation = async (rigoToken, courseInfo) => {
133
134
  duration,
134
135
  };
135
136
  };
137
+ process.emitWarning = (warning) => {
138
+ console_1.default.debug("A Warning was emitted by Node.js: ", warning);
139
+ };
136
140
  const appendContentIndex = async () => {
137
141
  const choices = await prompts([
138
142
  {
@@ -292,6 +296,12 @@ const getChoices = async (empty) => {
292
296
  name: "title",
293
297
  initial: "My Interactive Tutorial",
294
298
  message: "Title for your tutorial? Press enter to leave as it is",
299
+ validate: (value) => {
300
+ if (value.length > PARAMS.max_title_length) {
301
+ return `Title must be less than ${PARAMS.max_title_length} characters`;
302
+ }
303
+ return true;
304
+ },
295
305
  },
296
306
  {
297
307
  type: "text",
@@ -1,11 +1,13 @@
1
1
  import SessionCommand from "../utils/SessionCommand";
2
- export default class BuildCommand extends SessionCommand {
2
+ declare class BuildCommand extends SessionCommand {
3
3
  static description: string;
4
4
  static flags: {
5
5
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
6
+ strict: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
6
7
  };
7
8
  init(): Promise<void>;
8
9
  run(): Promise<void>;
9
10
  copyDirectory(src: string, dest: string): void;
10
11
  removeDirectory(dir: string): void;
11
12
  }
13
+ export default BuildCommand;
@@ -20,10 +20,12 @@ const RIGOBOT_HOST = "https://rigobot.herokuapp.com";
20
20
  // const RIGOBOT_HOST =
21
21
  // "https://8000-charlytoc-rigobot-bmwdeam7cev.ws-us116.gitpod.io"
22
22
  const uploadZipEndpont = RIGOBOT_HOST + "/v1/learnpack/upload";
23
- const runAudit = () => {
23
+ const runAudit = (strict) => {
24
24
  try {
25
25
  console_1.default.info("Running learnpack audit before publishing...");
26
- (0, child_process_1.execSync)("learnpack audit", { stdio: "inherit" });
26
+ (0, child_process_1.execSync)(`learnpack audit ${strict ? "--strict" : ""}`, {
27
+ stdio: "inherit",
28
+ });
27
29
  }
28
30
  catch (error) {
29
31
  console_1.default.error("Failed to audit with learnpack");
@@ -68,6 +70,9 @@ class BuildCommand extends SessionCommand_1.default {
68
70
  async run() {
69
71
  var _a, _b, _c;
70
72
  const buildDir = path.join(process.cwd(), "build");
73
+ const { flags } = this.parse(BuildCommand);
74
+ const strict = flags.strict;
75
+ console_1.default.debug("Strict mode: ", strict);
71
76
  // this.configManager?.clean()
72
77
  const configObject = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.get();
73
78
  let sessionPayload = await session_1.default.getPayload();
@@ -98,7 +103,7 @@ class BuildCommand extends SessionCommand_1.default {
98
103
  console_1.default.info("Cleaning configuration files");
99
104
  (_b = this.configManager) === null || _b === void 0 ? void 0 : _b.clean();
100
105
  // build exerises
101
- runAudit();
106
+ runAudit(strict);
102
107
  console_1.default.debug("Building exercises");
103
108
  (_c = this.configManager) === null || _c === void 0 ? void 0 : _c.buildIndex();
104
109
  }
@@ -267,5 +272,18 @@ class BuildCommand extends SessionCommand_1.default {
267
272
  BuildCommand.description = "Builds the project by copying necessary files and directories into a zip file";
268
273
  BuildCommand.flags = {
269
274
  help: command_1.flags.help({ char: "h" }),
275
+ strict: command_1.flags.boolean({
276
+ char: "s",
277
+ description: "strict mode",
278
+ default: false,
279
+ }),
280
+ };
281
+ BuildCommand.flags = {
282
+ strict: command_1.flags.boolean({
283
+ char: "s",
284
+ description: "strict mode",
285
+ default: false,
286
+ }),
287
+ help: command_1.flags.help({ char: "h" }),
270
288
  };
271
289
  exports.default = BuildCommand;
@@ -1 +1 @@
1
- {"version":"5.0.38","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":[]},"breakToken":{"id":"breakToken","description":"Break the token","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":[]},"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.39","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":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false}},"args":[]},"breakToken":{"id":"breakToken","description":"Break the token","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":[]},"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":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false},"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.38",
4
+ "version": "5.0.39",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -10,6 +10,7 @@ import { IFrontmatter } from "../models/front-matter"
10
10
  import { IAuditErrors } from "../models/audit"
11
11
  import { ICounter } from "../models/counter"
12
12
  import { IFindings } from "../models/findings"
13
+ import { flags } from "@oclif/command"
13
14
 
14
15
  // eslint-disable-next-line
15
16
  const fetch = require("node-fetch")
@@ -21,6 +22,9 @@ class AuditCommand extends SessionCommand {
21
22
  }
22
23
 
23
24
  async run() {
25
+ const { flags }: { flags: { strict: boolean } } = this.parse(AuditCommand)
26
+
27
+ const strict = flags.strict
24
28
  Console.log("Running command audit...")
25
29
 
26
30
  // Get configuration object.
@@ -114,12 +118,20 @@ class AuditCommand extends SessionCommand {
114
118
  msg: "The difficulty property is not in the configuration object",
115
119
  })
116
120
  // check if the bugs_link property is in the configuration object
117
- if (!config!.config?.bugsLink)
118
- errors.push({
119
- exercise: undefined,
120
- msg: "The bugsLink property is not in the configuration object",
121
- })
122
- // check if the video_solutions property is in the configuration object
121
+ if (!config!.config?.bugsLink) {
122
+ if (strict)
123
+ errors.push({
124
+ exercise: undefined,
125
+ msg: "The bugsLink property is not in the configuration object",
126
+ })
127
+ else
128
+ warnings.push({
129
+ exercise: undefined,
130
+ msg: "The bugsLink property is not in the configuration object",
131
+ })
132
+ }
133
+
134
+ // check if the video_solutions property is in the configuration object
123
135
  if (config!.config?.videoSolutions === undefined)
124
136
  warnings.push({
125
137
  exercise: undefined,
@@ -130,12 +142,18 @@ class AuditCommand extends SessionCommand {
130
142
  Console.debug(
131
143
  "Checking if the repository property is inside the configuration object..."
132
144
  )
133
- if (!config!.config?.repository)
134
- errors.push({
135
- exercise: undefined,
136
- msg: "The repository property is not in the configuration object",
137
- })
138
- else
145
+ if (!config!.config?.repository) {
146
+ if (strict)
147
+ errors.push({
148
+ exercise: undefined,
149
+ msg: "The repository property is not in the configuration object",
150
+ })
151
+ else
152
+ warnings.push({
153
+ exercise: undefined,
154
+ msg: "The repository property is not in the configuration object",
155
+ })
156
+ } else
139
157
  Audit.isUrl(config!.config?.repository, errors, counter)
140
158
 
141
159
  // These two lines check if the 'description' property is inside the configuration object.
@@ -150,7 +168,7 @@ Audit.isUrl(config!.config?.repository, errors, counter)
150
168
  if (!config!.config?.projectType)
151
169
  errors.push({
152
170
  exercise: undefined,
153
- msg: "The projectType property mandatory in the configuration object",
171
+ msg: "The projectType property is mandatory in the configuration object",
154
172
  })
155
173
 
156
174
  if (errors.length === 0)
@@ -443,7 +461,11 @@ learnpack audit checks for the following information in a repository:
443
461
  `
444
462
 
445
463
  AuditCommand.flags = {
446
- // name: flags.string({char: 'n', description: 'name to print'}),
464
+ strict: flags.boolean({
465
+ char: "s",
466
+ description: "strict mode",
467
+ default: false,
468
+ }),
447
469
  }
448
470
 
449
471
  export default AuditCommand
@@ -47,6 +47,7 @@ const PARAMS = {
47
47
  max_fkgl: 8,
48
48
  max_words: 200,
49
49
  max_rewrite_attempts: 3,
50
+ max_title_length: 25,
50
51
  }
51
52
 
52
53
  const whichTargetAudience = async () => {
@@ -221,6 +222,10 @@ const initializeInteractiveCreation = async (
221
222
  }
222
223
  }
223
224
 
225
+ process.emitWarning = (warning: string) => {
226
+ Console.debug("A Warning was emitted by Node.js: ", warning)
227
+ }
228
+
224
229
  const appendContentIndex = async () => {
225
230
  const choices = await prompts([
226
231
  {
@@ -425,9 +430,17 @@ const getChoices = async (empty: boolean) => {
425
430
  },
426
431
  {
427
432
  type: "text",
433
+
428
434
  name: "title",
429
435
  initial: "My Interactive Tutorial",
430
436
  message: "Title for your tutorial? Press enter to leave as it is",
437
+ validate: (value: string) => {
438
+ if (value.length > PARAMS.max_title_length) {
439
+ return `Title must be less than ${PARAMS.max_title_length} characters`
440
+ }
441
+
442
+ return true
443
+ },
431
444
  },
432
445
  {
433
446
  type: "text",
@@ -24,10 +24,12 @@ const RIGOBOT_HOST = "https://rigobot.herokuapp.com"
24
24
  // "https://8000-charlytoc-rigobot-bmwdeam7cev.ws-us116.gitpod.io"
25
25
  const uploadZipEndpont = RIGOBOT_HOST + "/v1/learnpack/upload"
26
26
 
27
- const runAudit = () => {
27
+ const runAudit = (strict: boolean) => {
28
28
  try {
29
29
  Console.info("Running learnpack audit before publishing...")
30
- execSync("learnpack audit", { stdio: "inherit" })
30
+ execSync(`learnpack audit ${strict ? "--strict" : ""}`, {
31
+ stdio: "inherit",
32
+ })
31
33
  } catch (error) {
32
34
  Console.error("Failed to audit with learnpack")
33
35
 
@@ -71,12 +73,17 @@ const selectAcademy = async (academies: TAcademy[]) => {
71
73
  return response.academy
72
74
  }
73
75
 
74
- export default class BuildCommand extends SessionCommand {
76
+ class BuildCommand extends SessionCommand {
75
77
  static description =
76
78
  "Builds the project by copying necessary files and directories into a zip file"
77
79
 
78
80
  static flags = {
79
81
  help: flags.help({ char: "h" }),
82
+ strict: flags.boolean({
83
+ char: "s",
84
+ description: "strict mode",
85
+ default: false,
86
+ }),
80
87
  }
81
88
 
82
89
  async init() {
@@ -86,6 +93,10 @@ export default class BuildCommand extends SessionCommand {
86
93
 
87
94
  async run() {
88
95
  const buildDir = path.join(process.cwd(), "build")
96
+
97
+ const { flags }: { flags: { strict: boolean } } = this.parse(BuildCommand)
98
+ const strict = flags.strict
99
+ Console.debug("Strict mode: ", strict)
89
100
  // this.configManager?.clean()
90
101
 
91
102
  const configObject = this.configManager?.get()
@@ -134,7 +145,7 @@ export default class BuildCommand extends SessionCommand {
134
145
  Console.info("Cleaning configuration files")
135
146
  this.configManager?.clean()
136
147
  // build exerises
137
- runAudit()
148
+ runAudit(strict)
138
149
 
139
150
  Console.debug("Building exercises")
140
151
  this.configManager?.buildIndex()
@@ -334,3 +345,14 @@ export default class BuildCommand extends SessionCommand {
334
345
  }
335
346
  }
336
347
  }
348
+
349
+ BuildCommand.flags = {
350
+ strict: flags.boolean({
351
+ char: "s",
352
+ description: "strict mode",
353
+ default: false,
354
+ }),
355
+ help: flags.help({ char: "h" }),
356
+ }
357
+
358
+ export default BuildCommand
@@ -26,4 +26,4 @@ jobs:
26
26
  with:
27
27
  node-version: ${{ matrix.node-version }}
28
28
  - run: npm install @learnpack/learnpack@latest -g
29
- - run: learnpack audit
29
+ - run: learnpack audit --strict
@@ -26,4 +26,4 @@ jobs:
26
26
  with:
27
27
  node-version: ${{ matrix.node-version }}
28
28
  - run: npm install @learnpack/learnpack@latest -g
29
- - run: learnpack audit
29
+ - run: learnpack audit --strict