@learnpack/learnpack 2.1.57 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +10 -10
- package/lib/managers/config/defaults.d.ts +1 -0
- package/lib/managers/config/defaults.js +1 -0
- package/lib/managers/config/index.js +2 -2
- package/lib/managers/file.js +17 -7
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/managers/config/defaults.ts +1 -0
- package/src/managers/config/index.ts +6 -8
- package/src/managers/file.ts +28 -12
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/
|
24
|
+
@learnpack/learnpack/4.0.1 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/
|
77
|
+
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.1/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/
|
92
|
+
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.1/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/
|
110
|
+
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.1/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/
|
141
|
+
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.1/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/
|
159
|
+
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.1/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/
|
177
|
+
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.1/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/
|
312
|
+
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.1/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/
|
333
|
+
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.1/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/
|
347
|
+
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.1/src\commands\test.ts)_
|
348
348
|
<!-- commandsstop -->
|
349
349
|
|
350
350
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
@@ -145,12 +145,12 @@ exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
|
145
145
|
console_1.default.debug("Config version not found, downloading default.");
|
146
146
|
const resp = await fetch("https://raw.githubusercontent.com/learnpack/ide/master/package.json");
|
147
147
|
const packageJSON = await resp.json();
|
148
|
-
configObj.config.editor.version = packageJSON.version || "
|
148
|
+
configObj.config.editor.version = packageJSON.version || "4.0.0";
|
149
149
|
}
|
150
150
|
configObj.config.dirPath = "./" + confPath.base;
|
151
151
|
configObj.config.exercisesPath = getExercisesPath(confPath.base) || "./";
|
152
|
-
const allowedCommands = new Set(["ls", "pwd", "echo", "node", "python"]);
|
153
152
|
if (configObj.config.variables) {
|
153
|
+
const allowedCommands = new Set(["ls", "pwd", "echo", "node", "python"]);
|
154
154
|
const variableKeys = Object.keys(configObj.config.variables);
|
155
155
|
const promises = [];
|
156
156
|
for (const v of variableKeys) {
|
package/lib/managers/file.js
CHANGED
@@ -28,22 +28,32 @@ exports.decompress = (sourcePath, destinationPath) => new Promise((resolve, reje
|
|
28
28
|
});
|
29
29
|
});
|
30
30
|
exports.downloadEditor = async (version, destination) => {
|
31
|
-
// https://raw.githubusercontent.com/learnpack/coding-ide/master/dist/app.tar.gz
|
32
|
-
// if(versions[version] === undefined) throw new Error(`Invalid editor version ${version}`)
|
33
31
|
if (!version) {
|
34
32
|
const res = await fetch("https://raw.githubusercontent.com/learnpack/ide/master/package.json");
|
35
33
|
const json = await res.json();
|
36
|
-
version = json.version;
|
34
|
+
version = json.version || "4.0.0";
|
37
35
|
if (!version)
|
38
36
|
throw errors_1.InternalError(`Coding Editor version was not found on learnpack repository, check the config.editor.version property on learn.json`);
|
39
37
|
}
|
40
|
-
const
|
41
|
-
|
38
|
+
const [major, minor] = version.split(".");
|
39
|
+
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
|
+
const matchingTags = tags
|
43
|
+
.filter((tag) => tag.name.includes(versionPrefix))
|
44
|
+
.sort((a, b) => b.name.localeCompare(a.name, undefined, { numeric: true }));
|
45
|
+
if (matchingTags.length === 0)
|
46
|
+
throw errors_1.InternalError(`No matching version found for prefix ${versionPrefix} in the learnpack repository`);
|
47
|
+
const latestVersion = matchingTags[0].name
|
48
|
+
.replace("learnpack-", "")
|
49
|
+
.replace(".tar.gz", "");
|
50
|
+
const versionNumber = parseInt(latestVersion.split(".")[0]);
|
51
|
+
let url = `https://github.com/learnpack/coding-ide/blob/${latestVersion}/dist`;
|
42
52
|
if (versionNumber > 2)
|
43
|
-
url = `https://github.com/learnpack/ide/blob/master/bin/learnpack-${
|
53
|
+
url = `https://github.com/learnpack/ide/blob/master/bin/learnpack-${latestVersion}.tar.gz`;
|
44
54
|
const resp2 = await fetch(url, { method: "HEAD" });
|
45
55
|
if (!resp2.ok)
|
46
|
-
throw errors_1.InternalError(`Coding Editor ${
|
56
|
+
throw errors_1.InternalError(`Coding Editor ${latestVersion} was not found on learnpack repository, check the config.editor.version property on learn.json`);
|
47
57
|
console_1.default.info("Downloading the LearnPack coding UI, this may take a minute...");
|
48
58
|
url += versionNumber > 2 ? `?raw=true` : `/app.tar.gz?raw=true`;
|
49
59
|
return exports.download(url, destination);
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"
|
1
|
+
{"version":"4.0.1","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
@@ -28,9 +28,9 @@ import { IFile } from "../../models/file"
|
|
28
28
|
/* exercise folder name standard */
|
29
29
|
|
30
30
|
// eslint-disable-next-line
|
31
|
-
const fetch = require("node-fetch")
|
31
|
+
const fetch = require("node-fetch")
|
32
32
|
// eslint-disable-next-line
|
33
|
-
const chalk = require("chalk")
|
33
|
+
const chalk = require("chalk")
|
34
34
|
|
35
35
|
/* exercise folder name standard */
|
36
36
|
|
@@ -206,15 +206,15 @@ configObj.config.editor.version = version
|
|
206
206
|
"https://raw.githubusercontent.com/learnpack/ide/master/package.json"
|
207
207
|
)
|
208
208
|
const packageJSON = await resp.json()
|
209
|
-
configObj.config.editor.version = packageJSON.version || "
|
209
|
+
configObj.config.editor.version = packageJSON.version || "4.0.0"
|
210
210
|
}
|
211
211
|
|
212
212
|
configObj.config.dirPath = "./" + confPath.base
|
213
213
|
configObj.config.exercisesPath = getExercisesPath(confPath.base) || "./"
|
214
214
|
|
215
|
-
const allowedCommands = new Set(["ls", "pwd", "echo", "node", "python"])
|
216
|
-
|
217
215
|
if (configObj.config.variables) {
|
216
|
+
const allowedCommands = new Set(["ls", "pwd", "echo", "node", "python"])
|
217
|
+
|
218
218
|
const variableKeys = Object.keys(configObj.config.variables)
|
219
219
|
const promises = []
|
220
220
|
|
@@ -384,9 +384,7 @@ fs.unlinkSync(_path)
|
|
384
384
|
ex => ex.slug === slug
|
385
385
|
)
|
386
386
|
if (!exercise)
|
387
|
-
throw ValidationError(
|
388
|
-
`Exercise ${slug} not found on the configuration`
|
389
|
-
)
|
387
|
+
throw ValidationError(`Exercise ${slug} not found on the configuration`)
|
390
388
|
|
391
389
|
if (configObj.config) {
|
392
390
|
for (const fileName of fs.readdirSync(
|
package/src/managers/file.ts
CHANGED
@@ -8,7 +8,7 @@ import * as https from "https"
|
|
8
8
|
import { InternalError } from "../utils/errors"
|
9
9
|
|
10
10
|
// eslint-disable-next-line
|
11
|
-
const fetch = require("node-fetch")
|
11
|
+
const fetch = require("node-fetch")
|
12
12
|
|
13
13
|
export const decompress = (sourcePath: string, destinationPath: string) =>
|
14
14
|
new Promise((resolve, reject) => {
|
@@ -34,15 +34,12 @@ export const downloadEditor = async (
|
|
34
34
|
version: string | undefined,
|
35
35
|
destination: string
|
36
36
|
) => {
|
37
|
-
// https://raw.githubusercontent.com/learnpack/coding-ide/master/dist/app.tar.gz
|
38
|
-
// if(versions[version] === undefined) throw new Error(`Invalid editor version ${version}`)
|
39
|
-
|
40
37
|
if (!version) {
|
41
38
|
const res = await fetch(
|
42
39
|
"https://raw.githubusercontent.com/learnpack/ide/master/package.json"
|
43
40
|
)
|
44
41
|
const json = await res.json()
|
45
|
-
version = json.version
|
42
|
+
version = json.version || "4.0.0"
|
46
43
|
|
47
44
|
if (!version)
|
48
45
|
throw InternalError(
|
@@ -50,22 +47,41 @@ export const downloadEditor = async (
|
|
50
47
|
)
|
51
48
|
}
|
52
49
|
|
53
|
-
const
|
50
|
+
const [major, minor] = version.split(".")
|
51
|
+
const versionPrefix = `${major}.${minor}`
|
54
52
|
|
55
|
-
|
53
|
+
const tagsRes = await fetch(
|
54
|
+
"https://api.github.com/repos/learnpack/ide/contents/bin"
|
55
|
+
)
|
56
|
+
const tags = await tagsRes.json()
|
57
|
+
const matchingTags = tags
|
58
|
+
.filter((tag: any) => tag.name.includes(versionPrefix))
|
59
|
+
.sort((a: any, b: any) =>
|
60
|
+
b.name.localeCompare(a.name, undefined, { numeric: true })
|
61
|
+
)
|
62
|
+
|
63
|
+
if (matchingTags.length === 0)
|
64
|
+
throw InternalError(
|
65
|
+
`No matching version found for prefix ${versionPrefix} in the learnpack repository`
|
66
|
+
)
|
67
|
+
|
68
|
+
const latestVersion = matchingTags[0].name
|
69
|
+
.replace("learnpack-", "")
|
70
|
+
.replace(".tar.gz", "")
|
71
|
+
const versionNumber = parseInt(latestVersion.split(".")[0])
|
72
|
+
|
73
|
+
let url = `https://github.com/learnpack/coding-ide/blob/${latestVersion}/dist`
|
56
74
|
|
57
75
|
if (versionNumber > 2)
|
58
|
-
url = `https://github.com/learnpack/ide/blob/master/bin/learnpack-${
|
76
|
+
url = `https://github.com/learnpack/ide/blob/master/bin/learnpack-${latestVersion}.tar.gz`
|
59
77
|
|
60
78
|
const resp2 = await fetch(url, { method: "HEAD" })
|
61
79
|
if (!resp2.ok)
|
62
80
|
throw InternalError(
|
63
|
-
`Coding Editor ${
|
81
|
+
`Coding Editor ${latestVersion} was not found on learnpack repository, check the config.editor.version property on learn.json`
|
64
82
|
)
|
65
83
|
|
66
|
-
Console.info(
|
67
|
-
"Downloading the LearnPack coding UI, this may take a minute..."
|
68
|
-
)
|
84
|
+
Console.info("Downloading the LearnPack coding UI, this may take a minute...")
|
69
85
|
|
70
86
|
url += versionNumber > 2 ? `?raw=true` : `/app.tar.gz?raw=true`
|
71
87
|
|