@learnpack/learnpack 4.0.3 → 4.0.5

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/4.0.3 win32-x64 node-v20.10.0
24
+ @learnpack/learnpack/4.0.5 win32-x64 node-v20.10.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/v4.0.3/src\commands\audit.ts)_
77
+ _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.5/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/v4.0.3/src\commands\clean.ts)_
92
+ _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.5/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/v4.0.3/src\commands\download.ts)_
110
+ _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.5/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/v4.0.3/src\commands\init.ts)_
141
+ _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.5/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/v4.0.3/src\commands\login.ts)_
159
+ _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.5/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/v4.0.3/src\commands\logout.ts)_
177
+ _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.5/src\commands\logout.ts)_
178
178
 
179
179
  ## `learnpack plugins`
180
180
 
@@ -309,7 +309,7 @@ DESCRIPTION
309
309
  Extra documentation goes here
310
310
  ```
311
311
 
312
- _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.3/src\commands\publish.ts)_
312
+ _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.5/src\commands\publish.ts)_
313
313
 
314
314
  ## `learnpack start`
315
315
 
@@ -330,7 +330,7 @@ OPTIONS
330
330
  -w, --watch Watch for file changes
331
331
  ```
332
332
 
333
- _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.3/src\commands\start.ts)_
333
+ _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.5/src\commands\start.ts)_
334
334
 
335
335
  ## `learnpack test [EXERCISESLUG]`
336
336
 
@@ -344,7 +344,7 @@ ARGUMENTS
344
344
  EXERCISESLUG The name of the exercise to test
345
345
  ```
346
346
 
347
- _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.3/src\commands\test.ts)_
347
+ _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.5/src\commands\test.ts)_
348
348
  <!-- commandsstop -->
349
349
 
350
350
  > > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
@@ -28,6 +28,7 @@ exports.decompress = (sourcePath, destinationPath) => new Promise((resolve, reje
28
28
  });
29
29
  });
30
30
  exports.downloadEditor = async (version, destination) => {
31
+ console_1.default.info("Downloading the LearnPack coding UI, this may take a minute...");
31
32
  if (!version) {
32
33
  const res = await fetch("https://raw.githubusercontent.com/learnpack/ide/master/package.json");
33
34
  const json = await res.json();
@@ -37,14 +38,34 @@ exports.downloadEditor = async (version, destination) => {
37
38
  }
38
39
  const [major, minor] = version.split(".");
39
40
  const versionPrefix = `${major}.${minor}`;
40
- const tagsRes = await fetch("https://api.github.com/repos/learnpack/ide/contents/bin");
41
- const tags = await tagsRes.json();
42
- if (tags.length === 0 || !tags)
43
- throw errors_1.InternalError(`No found tags in destination repo ${tags}`);
44
- const matchingTags = tags.filter((tag) => tag.name.includes(versionPrefix))
45
- .sort((a, b) => b.name.localeCompare(a.name, undefined, { numeric: true }));
46
- if (matchingTags.length === 0)
47
- throw errors_1.InternalError(`No matching version found for prefix ${versionPrefix} in the learnpack repository`);
41
+ let tags;
42
+ try {
43
+ const tagsRes = await fetch("https://api.github.com/repos/learnpack/ide/contents/bin");
44
+ tags = await tagsRes.json();
45
+ if (tags.message) {
46
+ throw new Error(`GitHub API error: ${tags.message}`);
47
+ }
48
+ }
49
+ catch (error) {
50
+ console_1.default.error("GitHub API error, defaulting to version 4.0.2", error);
51
+ version = "4.0.2";
52
+ tags = [{ name: `learnpack-${version}.tar.gz` }];
53
+ }
54
+ let matchingTags;
55
+ try {
56
+ if (tags.length === 0 || !tags)
57
+ throw errors_1.InternalError(`No found tags in destination repo ${tags}`);
58
+ matchingTags = tags
59
+ .filter((tag) => tag.name.includes(versionPrefix))
60
+ .sort((a, b) => b.name.localeCompare(a.name, undefined, { numeric: true }));
61
+ if (matchingTags.length === 0)
62
+ throw errors_1.InternalError(`No matching version found for prefix ${versionPrefix} in the learnpack repository`);
63
+ }
64
+ catch (error) {
65
+ console_1.default.error("Error processing tags, defaulting to version 4.0.2", error);
66
+ version = "4.0.2";
67
+ matchingTags = [{ name: `learnpack-${version}.tar.gz` }];
68
+ }
48
69
  const latestVersion = matchingTags[0].name
49
70
  .replace("learnpack-", "")
50
71
  .replace(".tar.gz", "");
@@ -55,7 +76,6 @@ exports.downloadEditor = async (version, destination) => {
55
76
  const resp2 = await fetch(url, { method: "HEAD" });
56
77
  if (!resp2.ok)
57
78
  throw errors_1.InternalError(`Coding Editor ${latestVersion} was not found on learnpack repository, check the config.editor.version property on learn.json`);
58
- console_1.default.info("Downloading the LearnPack coding UI, this may take a minute...");
59
79
  url += versionNumber > 2 ? `?raw=true` : `/app.tar.gz?raw=true`;
60
80
  return exports.download(url, destination);
61
81
  };
@@ -1 +1 @@
1
- {"version":"4.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":"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":"[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":"4.0.5","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":"[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": "Create, sell or download and take learning amazing learning packages",
4
- "version": "4.0.3",
4
+ "version": "4.0.5",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -29,11 +29,12 @@ export const decompress = (sourcePath: string, destinationPath: string) =>
29
29
  }
30
30
  )
31
31
  })
32
-
33
32
  export const downloadEditor = async (
34
33
  version: string | undefined,
35
34
  destination: string
36
35
  ) => {
36
+ Console.info("Downloading the LearnPack coding UI, this may take a minute...")
37
+
37
38
  if (!version) {
38
39
  const res = await fetch(
39
40
  "https://raw.githubusercontent.com/learnpack/ide/master/package.json"
@@ -50,23 +51,42 @@ export const downloadEditor = async (
50
51
  const [major, minor] = version.split(".")
51
52
  const versionPrefix = `${major}.${minor}`
52
53
 
53
- const tagsRes = await fetch(
54
- "https://api.github.com/repos/learnpack/ide/contents/bin"
55
- )
56
- const tags = await tagsRes.json()
54
+ let tags
55
+ try {
56
+ const tagsRes = await fetch(
57
+ "https://api.github.com/repos/learnpack/ide/contents/bin"
58
+ )
59
+ tags = await tagsRes.json()
57
60
 
58
- if (tags.length === 0 || !tags)
59
- throw InternalError(`No found tags in destination repo ${tags}`)
61
+ if (tags.message) {
62
+ throw new Error(`GitHub API error: ${tags.message}`)
63
+ }
64
+ } catch (error) {
65
+ Console.error("GitHub API error, defaulting to version 4.0.2", error)
66
+ version = "4.0.2"
67
+ tags = [{ name: `learnpack-${version}.tar.gz` }]
68
+ }
60
69
 
61
- const matchingTags = tags.filter((tag: any) => tag.name.includes(versionPrefix))
62
- .sort((a: any, b: any) =>
63
- b.name.localeCompare(a.name, undefined, { numeric: true })
64
- )
70
+ let matchingTags
71
+ try {
72
+ if (tags.length === 0 || !tags)
73
+ throw InternalError(`No found tags in destination repo ${tags}`)
65
74
 
66
- if (matchingTags.length === 0)
67
- throw InternalError(
68
- `No matching version found for prefix ${versionPrefix} in the learnpack repository`
69
- )
75
+ matchingTags = tags
76
+ .filter((tag: any) => tag.name.includes(versionPrefix))
77
+ .sort((a: any, b: any) =>
78
+ b.name.localeCompare(a.name, undefined, { numeric: true })
79
+ )
80
+
81
+ if (matchingTags.length === 0)
82
+ throw InternalError(
83
+ `No matching version found for prefix ${versionPrefix} in the learnpack repository`
84
+ )
85
+ } catch (error) {
86
+ Console.error("Error processing tags, defaulting to version 4.0.2", error)
87
+ version = "4.0.2"
88
+ matchingTags = [{ name: `learnpack-${version}.tar.gz` }]
89
+ }
70
90
 
71
91
  const latestVersion = matchingTags[0].name
72
92
  .replace("learnpack-", "")
@@ -84,8 +104,6 @@ export const downloadEditor = async (
84
104
  `Coding Editor ${latestVersion} was not found on learnpack repository, check the config.editor.version property on learn.json`
85
105
  )
86
106
 
87
- Console.info("Downloading the LearnPack coding UI, this may take a minute...")
88
-
89
107
  url += versionNumber > 2 ? `?raw=true` : `/app.tar.gz?raw=true`
90
108
 
91
109
  return download(url, destination)