@learnpack/learnpack 2.1.15 → 2.1.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,6 +14,7 @@ declare const _default: {
14
14
  contact: string;
15
15
  language: string;
16
16
  autoPlay: boolean;
17
+ projectType: string;
17
18
  grading: string;
18
19
  exercisesPath: string;
19
20
  webpackTemplate: null;
@@ -16,6 +16,7 @@ exports.default = {
16
16
  contact: "https://github.com/learnpack/learnpack/issues/new",
17
17
  language: "auto",
18
18
  autoPlay: true,
19
+ projectType: "tutorial",
19
20
  grading: "isolated",
20
21
  exercisesPath: "./",
21
22
  webpackTemplate: null,
@@ -254,7 +254,7 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
254
254
  if (configObj.config && !configObj.config.exercisesPath)
255
255
  throw errors_1.ValidationError("No exercises directory to watch: " + configObj.config.exercisesPath);
256
256
  this.buildIndex();
257
- watcher_1.default(((_a = configObj === null || configObj === void 0 ? void 0 : configObj.config) === null || _a === void 0 ? void 0 : _a.exercisesPath) || "", this, onChange)
257
+ watcher_1.default(((_a = configObj === null || configObj === void 0 ? void 0 : configObj.config) === null || _a === void 0 ? void 0 : _a.exercisesPath) || "", onChange)
258
258
  .then(( /* eventname, filename */) => {
259
259
  console_1.default.debug("Changes detected on your exercises");
260
260
  this.buildIndex();
@@ -0,0 +1,15 @@
1
+ export interface IAuditErrors {
2
+ exercise?: string;
3
+ msg: string;
4
+ }
5
+ declare type TType = "string" | "array" | "number" | "url" | "boolean";
6
+ export interface ISchemaItem {
7
+ key: string;
8
+ mandatory: boolean;
9
+ type: TType;
10
+ max_size?: number;
11
+ allowed_extensions?: string[];
12
+ enum?: string[];
13
+ max_item_size?: number;
14
+ }
15
+ export {};
File without changes
@@ -40,6 +40,7 @@ export interface IConfig {
40
40
  disableGrading: boolean;
41
41
  actions: Array<string>;
42
42
  autoPlay: boolean;
43
+ projectType?: string;
43
44
  contact?: string;
44
45
  disabledActions?: Array<TConfigAction>;
45
46
  compiler: TCompiler;
@@ -1,13 +1,13 @@
1
- import { IAuditErrors } from '../models/audit-errors';
2
- import { IConfigObj } from '../models/config';
3
- import { ICounter } from '../models/counter';
4
- import { IFindings } from '../models/findings';
1
+ import { IAuditErrors } from "../models/audit";
2
+ import { IConfigObj } from "../models/config";
3
+ import { ICounter } from "../models/counter";
4
+ import { IFindings } from "../models/findings";
5
5
  declare const _default: {
6
6
  isUrl: (url: string, errors: IAuditErrors[], counter: ICounter) => Promise<boolean>;
7
7
  checkForEmptySpaces: (str: string) => boolean;
8
8
  checkLearnpackClean: (configObj: IConfigObj, errors: IAuditErrors[]) => void;
9
9
  findInFile: (types: string[], content: string) => IFindings;
10
- showErrors: (errors: IAuditErrors[], counter: ICounter) => Promise<unknown>;
10
+ showErrors: (errors: IAuditErrors[], counter: ICounter | undefined) => Promise<unknown>;
11
11
  showWarnings: (warnings: IAuditErrors[]) => Promise<unknown>;
12
12
  };
13
13
  export default _default;
@@ -17,7 +17,7 @@ exports.default = {
17
17
  });
18
18
  return false;
19
19
  }
20
- const res = await fetch(url, { method: 'HEAD' });
20
+ const res = await fetch(url, { method: "HEAD" });
21
21
  if (!res.ok) {
22
22
  counter.links.error++;
23
23
  errors.push({
@@ -30,7 +30,7 @@ exports.default = {
30
30
  checkForEmptySpaces: (str) => {
31
31
  const isEmpty = true;
32
32
  for (const letter of str) {
33
- if (letter !== ' ') {
33
+ if (letter !== " ") {
34
34
  return false;
35
35
  }
36
36
  }
@@ -48,7 +48,7 @@ exports.default = {
48
48
  fs.existsSync(`${(_h = configObj.config) === null || _h === void 0 ? void 0 : _h.dirPath}/vscode_queue.json`)) {
49
49
  errors.push({
50
50
  exercise: undefined,
51
- msg: 'You have to run learnpack clean command',
51
+ msg: "You have to run learnpack clean command",
52
52
  });
53
53
  }
54
54
  },
@@ -66,7 +66,7 @@ exports.default = {
66
66
  const findings = {};
67
67
  for (const type of types) {
68
68
  if (!validTypes.includes(type))
69
- throw new Error('Invalid type: ' + type);
69
+ throw new Error("Invalid type: " + type);
70
70
  else
71
71
  findings[type] = {};
72
72
  }
@@ -94,19 +94,29 @@ exports.default = {
94
94
  return new Promise((resolve, reject) => {
95
95
  if (errors) {
96
96
  if (errors.length > 0) {
97
- console_1.default.log('Checking for errors...');
97
+ console_1.default.log("Checking for errors...");
98
98
  for (const [i, error] of errors.entries())
99
- console_1.default.error(`${i + 1}) ${error.msg} ${error.exercise ? `(Exercise: ${error.exercise})` : ''}`);
100
- console_1.default.error(` We found ${errors.length} errors among ${counter.images.total} images, ${counter.links.total} link, ${counter.readmeFiles} README files and ${counter.exercises} exercises.`);
99
+ console_1.default.error(`${i + 1}) ${error.msg} ${error.exercise ? `(Exercise: ${error.exercise})` : ""}`);
100
+ if (counter) {
101
+ console_1.default.error(` We found ${errors.length} error${errors.length > 1 ? "s" : ""} among ${counter.images.total} images, ${counter.links.total} link, ${counter.readmeFiles} README files and ${counter.exercises} exercises.`);
102
+ }
103
+ else {
104
+ console_1.default.error(` We found ${errors.length} error${errors.length > 1 ? "s" : ""} related with the project integrity.`);
105
+ }
101
106
  process.exit(1);
102
107
  }
103
108
  else {
104
- console_1.default.success(`We didn't find any errors in this repository among ${counter.images.total} images, ${counter.links.total} link, ${counter.readmeFiles} README files and ${counter.exercises} exercises.`);
109
+ if (counter) {
110
+ console_1.default.success(`We didn't find any errors in this repository among ${counter.images.total} images, ${counter.links.total} link, ${counter.readmeFiles} README files and ${counter.exercises} exercises.`);
111
+ }
112
+ else {
113
+ console_1.default.success(`We didn't find any errors in this repository.`);
114
+ }
105
115
  process.exit(0);
106
116
  }
107
117
  }
108
118
  else {
109
- reject('Failed');
119
+ reject("Failed");
110
120
  }
111
121
  });
112
122
  },
@@ -115,14 +125,14 @@ exports.default = {
115
125
  return new Promise((resolve, reject) => {
116
126
  if (warnings) {
117
127
  if (warnings.length > 0) {
118
- console_1.default.log('Checking for warnings...');
128
+ console_1.default.log("Checking for warnings...");
119
129
  for (const [i, warning] of warnings.entries())
120
- console_1.default.warning(`${i + 1}) ${warning.msg} ${warning.exercise ? `File: ${warning.exercise}` : ''}`);
130
+ console_1.default.warning(`${i + 1}) ${warning.msg} ${warning.exercise ? `File: ${warning.exercise}` : ""}`);
121
131
  }
122
- resolve('SUCCESS');
132
+ resolve("SUCCESS");
123
133
  }
124
134
  else {
125
- reject('Failed');
135
+ reject("Failed");
126
136
  }
127
137
  });
128
138
  },
@@ -1,3 +1,2 @@
1
- import { IConfigManager } from "../models/config-manager";
2
- declare const _default: (path: string, configManager: IConfigManager, reloadSocket: () => void) => Promise<unknown>;
1
+ declare const _default: (path: string, reloadSocket: () => void) => Promise<unknown>;
3
2
  export default _default;
@@ -3,22 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const chokidar = require("chokidar");
4
4
  const console_1 = require("./console");
5
5
  const debounce = require("debounce");
6
- exports.default = (path, configManager, reloadSocket) => new Promise((resolve /* , reject */) => {
6
+ exports.default = (path, reloadSocket) => new Promise((resolve /* , reject */) => {
7
7
  console_1.default.debug("PATH:", path);
8
8
  const watcher = chokidar.watch(path, {
9
9
  // TODO: This watcher is not ready yet
10
+ ignored: /^(?=.*(\.\w+)$)(?!.*\.md$).*$/gm,
10
11
  ignoreInitial: true,
11
12
  });
12
13
  const onChange = (eventname, _filename) => {
13
14
  resolve(eventname /* , filename */);
14
- console_1.default.log(_filename);
15
- if (/^(?=.*(\\\w+)$).*$/gm.test(_filename) === false ||
16
- /^(?=.*(\.\w+)$)(?!.*\.md$).*$/gm.test(_filename) === false) {
17
- configManager.buildIndex();
18
- }
19
- else {
20
- reloadSocket();
21
- }
15
+ reloadSocket();
22
16
  };
23
17
  watcher.on("all", debounce(onChange, 500, true));
24
18
  // watcher.on('all', onChange)
@@ -1 +1 @@
1
- {"version":"2.1.15","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":"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}]},"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":"[standalone, gitpod]","options":["standalone","gitpod"]},"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":"2.1.20","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":"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}]},"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":"[standalone, gitpod]","options":["standalone","gitpod"]},"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": "Create, sell or download and take learning amazing learning packages",
4
- "version": "2.1.15",
4
+ "version": "2.1.20",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "bin": {
7
7
  "learnpack": "bin/run"