@learnpack/learnpack 4.0.16 → 4.0.18
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +10 -10
- package/lib/commands/publish.js +30 -7
- package/lib/managers/file.js +1 -1
- package/lib/managers/session.js +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/publish.ts +44 -9
- package/src/managers/file.ts +2 -1
- package/src/managers/session.ts +1 -0
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.
|
24
|
+
@learnpack/learnpack/4.0.18 win32-x64 node-v20.16.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.
|
77
|
+
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.18/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.
|
92
|
+
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.18/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.
|
110
|
+
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.18/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.
|
141
|
+
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.18/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.
|
159
|
+
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.18/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.
|
177
|
+
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.18/src\commands\logout.ts)_
|
178
178
|
|
179
179
|
## `learnpack plugins`
|
180
180
|
|
@@ -305,7 +305,7 @@ OPTIONS
|
|
305
305
|
-h, --help show CLI help
|
306
306
|
```
|
307
307
|
|
308
|
-
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
308
|
+
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.18/src\commands\publish.ts)_
|
309
309
|
|
310
310
|
## `learnpack start`
|
311
311
|
|
@@ -326,7 +326,7 @@ OPTIONS
|
|
326
326
|
-w, --watch Watch for file changes
|
327
327
|
```
|
328
328
|
|
329
|
-
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
329
|
+
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.18/src\commands\start.ts)_
|
330
330
|
|
331
331
|
## `learnpack test [EXERCISESLUG]`
|
332
332
|
|
@@ -340,7 +340,7 @@ ARGUMENTS
|
|
340
340
|
EXERCISESLUG The name of the exercise to test
|
341
341
|
```
|
342
342
|
|
343
|
-
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.
|
343
|
+
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v4.0.18/src\commands\test.ts)_
|
344
344
|
<!-- commandsstop -->
|
345
345
|
|
346
346
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
package/lib/commands/publish.js
CHANGED
@@ -11,10 +11,8 @@ const archiver = require("archiver");
|
|
11
11
|
const axios_1 = require("axios");
|
12
12
|
const FormData = require("form-data");
|
13
13
|
const console_1 = require("../utils/console");
|
14
|
-
const
|
15
|
-
|
16
|
-
// "https://8000-charlytoc-rigobot-bmwdeam7cev.ws-us116.gitpod.io"
|
17
|
-
"https://rigobot.herokuapp.com";
|
14
|
+
const file_1 = require("../managers/file");
|
15
|
+
const RIGOBOT_HOST = "https://rigobot.herokuapp.com";
|
18
16
|
const uploadZipEndpont = RIGOBOT_HOST + "/v1/learnpack/upload";
|
19
17
|
class BuildCommand extends SessionCommand_1.default {
|
20
18
|
async init() {
|
@@ -22,11 +20,26 @@ class BuildCommand extends SessionCommand_1.default {
|
|
22
20
|
await this.initSession(flags);
|
23
21
|
}
|
24
22
|
async run() {
|
23
|
+
var _a, _b;
|
25
24
|
const buildDir = path.join(process.cwd(), "build");
|
26
|
-
|
25
|
+
// this.configManager?.clean()
|
26
|
+
const configObject = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.get();
|
27
|
+
// Console.success("Package cleaned successfully, ready to publish")
|
28
|
+
if (configObject) {
|
29
|
+
// build exerises
|
30
|
+
console_1.default.debug("Building exercises");
|
31
|
+
(_b = this.configManager) === null || _b === void 0 ? void 0 : _b.buildIndex();
|
32
|
+
}
|
33
|
+
let sessionPayload = await session_1.default.getPayload();
|
27
34
|
if (!sessionPayload || !sessionPayload.rigobot) {
|
28
|
-
console_1.default.error("You must be logged in to upload a LearnPack
|
29
|
-
|
35
|
+
console_1.default.error("You must be logged in to upload a LearnPack package");
|
36
|
+
try {
|
37
|
+
sessionPayload = await session_1.default.login();
|
38
|
+
}
|
39
|
+
catch (error) {
|
40
|
+
console_1.default.error("Error trying to authenticate");
|
41
|
+
console_1.default.error(error.message || error);
|
42
|
+
}
|
30
43
|
}
|
31
44
|
const rigoToken = sessionPayload.rigobot.key;
|
32
45
|
// const rigoToken = "417d612d226a1606ad3a4e94b1881a9f0124b667"
|
@@ -41,6 +54,16 @@ class BuildCommand extends SessionCommand_1.default {
|
|
41
54
|
if (!fs.existsSync(buildDir)) {
|
42
55
|
fs.mkdirSync(buildDir);
|
43
56
|
}
|
57
|
+
if (configObject) {
|
58
|
+
const { config } = configObject;
|
59
|
+
const appAlreadyExists = (0, file_1.checkIfDirectoryExists)(`${config === null || config === void 0 ? void 0 : config.dirPath}/_app`);
|
60
|
+
if (!appAlreadyExists) {
|
61
|
+
// download app and decompress
|
62
|
+
await (0, file_1.downloadEditor)(config === null || config === void 0 ? void 0 : config.editor.version, `${config === null || config === void 0 ? void 0 : config.dirPath}/app.tar.gz`);
|
63
|
+
console_1.default.info("Decompressing LearnPack UI, this may take a minute...");
|
64
|
+
await (0, file_1.decompress)(`${config === null || config === void 0 ? void 0 : config.dirPath}/app.tar.gz`, `${config === null || config === void 0 ? void 0 : config.dirPath}/_app/`);
|
65
|
+
}
|
66
|
+
}
|
44
67
|
// Copy config.json
|
45
68
|
const configPath = path.join(process.cwd(), ".learn", "config.json");
|
46
69
|
if (fs.existsSync(configPath)) {
|
package/lib/managers/file.js
CHANGED
@@ -57,7 +57,7 @@ const downloadEditor = async (version, destination) => {
|
|
57
57
|
if (tags.length === 0 || !tags)
|
58
58
|
throw (0, errors_1.InternalError)(`No found tags in versions.json ${tags}`);
|
59
59
|
matchingTags = tags
|
60
|
-
.filter(tag => tag.includes(versionPrefix))
|
60
|
+
.filter(tag => tag.includes(`learnpack-${versionPrefix}`))
|
61
61
|
.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
|
62
62
|
if (matchingTags.length === 0)
|
63
63
|
throw (0, errors_1.InternalError)(`No matching version found for prefix ${versionPrefix} in the versions.json`);
|
package/lib/managers/session.js
CHANGED
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"4.0.
|
1
|
+
{"version":"4.0.18","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":"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":{"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
package/src/commands/publish.ts
CHANGED
@@ -9,11 +9,13 @@ import * as archiver from "archiver"
|
|
9
9
|
import axios from "axios"
|
10
10
|
import FormData = require("form-data")
|
11
11
|
import Console from "../utils/console"
|
12
|
+
import {
|
13
|
+
decompress,
|
14
|
+
downloadEditor,
|
15
|
+
checkIfDirectoryExists,
|
16
|
+
} from "../managers/file"
|
12
17
|
|
13
|
-
const RIGOBOT_HOST =
|
14
|
-
// "https://rigobot-test-cca7d841c9d8.herokuapp.com"
|
15
|
-
// "https://8000-charlytoc-rigobot-bmwdeam7cev.ws-us116.gitpod.io"
|
16
|
-
"https://rigobot.herokuapp.com"
|
18
|
+
const RIGOBOT_HOST = "https://rigobot.herokuapp.com"
|
17
19
|
const uploadZipEndpont = RIGOBOT_HOST + "/v1/learnpack/upload"
|
18
20
|
|
19
21
|
export default class BuildCommand extends SessionCommand {
|
@@ -31,12 +33,26 @@ export default class BuildCommand extends SessionCommand {
|
|
31
33
|
|
32
34
|
async run() {
|
33
35
|
const buildDir = path.join(process.cwd(), "build")
|
34
|
-
|
36
|
+
// this.configManager?.clean()
|
37
|
+
|
38
|
+
const configObject = this.configManager?.get()
|
39
|
+
// Console.success("Package cleaned successfully, ready to publish")
|
40
|
+
|
41
|
+
if (configObject) {
|
42
|
+
// build exerises
|
43
|
+
Console.debug("Building exercises")
|
44
|
+
this.configManager?.buildIndex()
|
45
|
+
}
|
46
|
+
|
47
|
+
let sessionPayload = await SessionManager.getPayload()
|
35
48
|
if (!sessionPayload || !sessionPayload.rigobot) {
|
36
|
-
Console.error(
|
37
|
-
|
38
|
-
|
39
|
-
|
49
|
+
Console.error("You must be logged in to upload a LearnPack package")
|
50
|
+
try {
|
51
|
+
sessionPayload = await SessionManager.login()
|
52
|
+
} catch (error) {
|
53
|
+
Console.error("Error trying to authenticate")
|
54
|
+
Console.error((error as TypeError).message || (error as string))
|
55
|
+
}
|
40
56
|
}
|
41
57
|
|
42
58
|
const rigoToken = sessionPayload.rigobot.key
|
@@ -57,6 +73,25 @@ export default class BuildCommand extends SessionCommand {
|
|
57
73
|
fs.mkdirSync(buildDir)
|
58
74
|
}
|
59
75
|
|
76
|
+
if (configObject) {
|
77
|
+
const { config } = configObject
|
78
|
+
const appAlreadyExists = checkIfDirectoryExists(`${config?.dirPath}/_app`)
|
79
|
+
|
80
|
+
if (!appAlreadyExists) {
|
81
|
+
// download app and decompress
|
82
|
+
await downloadEditor(
|
83
|
+
config?.editor.version,
|
84
|
+
`${config?.dirPath}/app.tar.gz`
|
85
|
+
)
|
86
|
+
|
87
|
+
Console.info("Decompressing LearnPack UI, this may take a minute...")
|
88
|
+
await decompress(
|
89
|
+
`${config?.dirPath}/app.tar.gz`,
|
90
|
+
`${config?.dirPath}/_app/`
|
91
|
+
)
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
60
95
|
// Copy config.json
|
61
96
|
const configPath = path.join(process.cwd(), ".learn", "config.json")
|
62
97
|
if (fs.existsSync(configPath)) {
|
package/src/managers/file.ts
CHANGED
@@ -77,7 +77,7 @@ export const downloadEditor = async (
|
|
77
77
|
throw InternalError(`No found tags in versions.json ${tags}`)
|
78
78
|
|
79
79
|
matchingTags = tags
|
80
|
-
.filter(tag => tag.includes(versionPrefix))
|
80
|
+
.filter(tag => tag.includes(`learnpack-${versionPrefix}`))
|
81
81
|
.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }))
|
82
82
|
|
83
83
|
if (matchingTags.length === 0)
|
@@ -93,6 +93,7 @@ export const downloadEditor = async (
|
|
93
93
|
const latestVersion = matchingTags[0]
|
94
94
|
.replace("learnpack-", "")
|
95
95
|
.replace(".tar.gz", "")
|
96
|
+
|
96
97
|
const versionNumber = parseInt(latestVersion.split(".")[0])
|
97
98
|
|
98
99
|
let url = `https://github.com/learnpack/coding-ide/blob/${latestVersion}/dist`
|