@learnpack/learnpack 5.0.217 → 5.0.231
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 +31 -26
- package/lib/commands/publish.d.ts +1 -1
- package/lib/commands/publish.js +17 -9
- package/lib/commands/serve.js +64 -30
- package/lib/creatorDist/assets/{index-CZrxF_55.js → index-BjBYI-9r.js} +4705 -4667
- package/lib/creatorDist/index.html +1 -1
- package/lib/utils/api.d.ts +7 -0
- package/lib/utils/api.js +54 -1
- package/oclif.manifest.json +1 -1
- package/package.json +3 -3
- package/src/commands/publish.ts +20 -8
- package/src/commands/serve.ts +73 -29
- package/src/creator/src/App.tsx +51 -9
- package/src/creator/src/components/syllabus/SyllabusEditor.tsx +35 -20
- package/src/creator/src/utils/lib.ts +5 -0
- package/src/creator/src/utils/store.ts +10 -0
- package/src/creatorDist/assets/{index-CZrxF_55.js → index-BjBYI-9r.js} +4705 -4667
- package/src/creatorDist/index.html +1 -1
- package/src/ui/_app/app.js +366 -366
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/api.ts +80 -10
package/README.md
CHANGED
@@ -8,14 +8,16 @@ Create, sell or download and take learning amazing learning packages.
|
|
8
8
|
[](https://github.com/learnpack/learnpack-cli/blob/master/package.json)
|
9
9
|
|
10
10
|
<!-- toc -->
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
|
12
|
+
- [learnpack](#learnpack)
|
13
|
+
- [Usage](#usage)
|
14
|
+
- [Commands](#commands)
|
14
15
|
<!-- tocstop -->
|
15
16
|
|
16
17
|
# Usage
|
17
18
|
|
18
19
|
<!-- usage -->
|
20
|
+
|
19
21
|
```sh-session
|
20
22
|
$ npm install -g @learnpack/learnpack
|
21
23
|
$ learnpack COMMAND
|
@@ -27,29 +29,31 @@ USAGE
|
|
27
29
|
$ learnpack COMMAND
|
28
30
|
...
|
29
31
|
```
|
32
|
+
|
30
33
|
<!-- usagestop -->
|
31
34
|
|
32
35
|
# Commands
|
33
36
|
|
34
37
|
<!-- commands -->
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
38
|
+
|
39
|
+
- [`learnpack audit`](#learnpack-audit)
|
40
|
+
- [`learnpack breakToken`](#learnpack-breaktoken)
|
41
|
+
- [`learnpack clean`](#learnpack-clean)
|
42
|
+
- [`learnpack download [PACKAGE]`](#learnpack-download-package)
|
43
|
+
- [`learnpack help [COMMAND]`](#learnpack-help-command)
|
44
|
+
- [`learnpack init`](#learnpack-init)
|
45
|
+
- [`learnpack login [PACKAGE]`](#learnpack-login-package)
|
46
|
+
- [`learnpack logout [PACKAGE]`](#learnpack-logout-package)
|
47
|
+
- [`learnpack plugins`](#learnpack-plugins)
|
48
|
+
- [`learnpack plugins:install PLUGIN...`](#learnpack-pluginsinstall-plugin)
|
49
|
+
- [`learnpack plugins:link PLUGIN`](#learnpack-pluginslink-plugin)
|
50
|
+
- [`learnpack plugins:uninstall PLUGIN...`](#learnpack-pluginsuninstall-plugin)
|
51
|
+
- [`learnpack plugins:update`](#learnpack-pluginsupdate)
|
52
|
+
- [`learnpack publish`](#learnpack-publish)
|
53
|
+
- [`learnpack serve`](#learnpack-serve)
|
54
|
+
- [`learnpack start`](#learnpack-start)
|
55
|
+
- [`learnpack test [EXERCISESLUG]`](#learnpack-test-exerciseslug)
|
56
|
+
- [`learnpack translate`](#learnpack-translate)
|
53
57
|
|
54
58
|
## `learnpack audit`
|
55
59
|
|
@@ -69,7 +73,7 @@ DESCRIPTION
|
|
69
73
|
2. The command learnpack clean has been run. (Error)
|
70
74
|
3. If a markdown or test file doesn't have any content. (Error)
|
71
75
|
4. The links are accessing to valid servers. (Error)
|
72
|
-
5. The relative images are working (If they have the shortest path to the image or if the images exists in the
|
76
|
+
5. The relative images are working (If they have the shortest path to the image or if the images exists in the
|
73
77
|
assets). (Error)
|
74
78
|
6. The external images are working (If they are pointing to a valid server). (Error)
|
75
79
|
7. The exercises directory names are valid. (Error)
|
@@ -236,15 +240,15 @@ DESCRIPTION
|
|
236
240
|
|
237
241
|
Installation of a user-installed plugin will override a core plugin.
|
238
242
|
|
239
|
-
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
|
240
|
-
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
|
243
|
+
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
|
244
|
+
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
|
241
245
|
the CLI without the need to patch and update the whole CLI.
|
242
246
|
|
243
247
|
ALIASES
|
244
248
|
$ learnpack plugins:add
|
245
249
|
|
246
250
|
EXAMPLES
|
247
|
-
$ learnpack plugins:install myplugin
|
251
|
+
$ learnpack plugins:install myplugin
|
248
252
|
$ learnpack plugins:install https://github.com/someuser/someplugin
|
249
253
|
$ learnpack plugins:install someuser/someplugin
|
250
254
|
```
|
@@ -269,7 +273,7 @@ OPTIONS
|
|
269
273
|
DESCRIPTION
|
270
274
|
Installation of a linked plugin will override a user-installed or core plugin.
|
271
275
|
|
272
|
-
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
276
|
+
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
273
277
|
command will override the user-installed or core plugin implementation. This is useful for development work.
|
274
278
|
|
275
279
|
EXAMPLE
|
@@ -399,6 +403,7 @@ OPTIONS
|
|
399
403
|
```
|
400
404
|
|
401
405
|
_See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.217/src\commands\translate.ts)_
|
406
|
+
|
402
407
|
<!-- commandsstop -->
|
403
408
|
|
404
409
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
@@ -2,7 +2,7 @@ import SessionCommand from "../utils/SessionCommand";
|
|
2
2
|
export declare const handleAssetCreation: (sessionPayload: {
|
3
3
|
token: string;
|
4
4
|
rigobotToken: string;
|
5
|
-
}, learnJson: any, learnpackDeployUrl: string) => Promise<void>;
|
5
|
+
}, learnJson: any, selectedLang: string, learnpackDeployUrl: string) => Promise<void>;
|
6
6
|
declare class BuildCommand extends SessionCommand {
|
7
7
|
static description: string;
|
8
8
|
static flags: {
|
package/lib/commands/publish.js
CHANGED
@@ -19,7 +19,15 @@ const prompts = require("prompts");
|
|
19
19
|
const rigoActions_1 = require("../utils/rigoActions");
|
20
20
|
const misc_1 = require("../utils/misc");
|
21
21
|
const uploadZipEndpont = api_1.RIGOBOT_HOST + "/v1/learnpack/upload";
|
22
|
-
const handleAssetCreation = async (sessionPayload, learnJson, learnpackDeployUrl) => {
|
22
|
+
const handleAssetCreation = async (sessionPayload, learnJson, selectedLang, learnpackDeployUrl) => {
|
23
|
+
const categories = {
|
24
|
+
us: 91,
|
25
|
+
es: 92,
|
26
|
+
};
|
27
|
+
let category = categories[selectedLang];
|
28
|
+
if (!category) {
|
29
|
+
category = 91;
|
30
|
+
}
|
23
31
|
try {
|
24
32
|
const user = await api_1.default.validateToken(sessionPayload.token);
|
25
33
|
const { exists } = await api_1.default.doesAssetExists(sessionPayload.token, learnJson.slug);
|
@@ -27,13 +35,13 @@ const handleAssetCreation = async (sessionPayload, learnJson, learnpackDeployUrl
|
|
27
35
|
console_1.default.info("Asset does not exist in this academy, creating it");
|
28
36
|
const asset = await api_1.default.createAsset(sessionPayload.token, {
|
29
37
|
slug: learnJson.slug,
|
30
|
-
title: learnJson.title
|
31
|
-
lang:
|
32
|
-
description: learnJson.description
|
38
|
+
title: learnJson.title[selectedLang],
|
39
|
+
lang: selectedLang,
|
40
|
+
description: learnJson.description[selectedLang],
|
33
41
|
learnpack_deploy_url: learnpackDeployUrl,
|
34
|
-
technologies:
|
42
|
+
technologies: learnJson.technologies,
|
35
43
|
url: learnpackDeployUrl,
|
36
|
-
category:
|
44
|
+
category: category,
|
37
45
|
owner: user.id,
|
38
46
|
author: user.id,
|
39
47
|
preview: learnJson.preview,
|
@@ -45,8 +53,8 @@ const handleAssetCreation = async (sessionPayload, learnJson, learnpackDeployUrl
|
|
45
53
|
console_1.default.info("Asset exists, updating it");
|
46
54
|
const asset = await api_1.default.updateAsset(sessionPayload.token, learnJson.slug, {
|
47
55
|
learnpack_deploy_url: learnpackDeployUrl,
|
48
|
-
title: learnJson.title
|
49
|
-
description: learnJson.description
|
56
|
+
title: learnJson.title[selectedLang],
|
57
|
+
description: learnJson.description[selectedLang],
|
50
58
|
});
|
51
59
|
await api_1.default.updateRigoAssetID(sessionPayload.rigobotToken, learnJson.slug, asset.id);
|
52
60
|
console_1.default.info("Asset updated with id", asset.id);
|
@@ -287,7 +295,7 @@ class BuildCommand extends SessionCommand_1.default {
|
|
287
295
|
console.log(res.data);
|
288
296
|
fs.unlinkSync(zipFilePath);
|
289
297
|
this.removeDirectory(buildDir);
|
290
|
-
await (0, exports.handleAssetCreation)(sessionPayload, learnJson, res.data.url);
|
298
|
+
await (0, exports.handleAssetCreation)(sessionPayload, learnJson, "us", res.data.url);
|
291
299
|
}
|
292
300
|
catch (error) {
|
293
301
|
if (axios_1.default.isAxiosError(error)) {
|
package/lib/commands/serve.js
CHANGED
@@ -71,7 +71,7 @@ const createLearnJson = (courseInfo) => {
|
|
71
71
|
exports.createLearnJson = createLearnJson;
|
72
72
|
const uploadFileToBucket = async (bucket, file, path) => {
|
73
73
|
const fileRef = bucket.file(path);
|
74
|
-
await fileRef.save(file);
|
74
|
+
await fileRef.save(Buffer.from(file, "utf8"));
|
75
75
|
};
|
76
76
|
const uploadImageToBucket = async (bucket, url, path) => {
|
77
77
|
const response = await fetch(url);
|
@@ -138,6 +138,7 @@ async function startExerciseGeneration(bucket, rigoToken, steps, packageContext,
|
|
138
138
|
const exSlug = (0, creatorUtilities_2.slugify)(exercise.id + "-" + exercise.title);
|
139
139
|
console.log("Starting generation of", exSlug);
|
140
140
|
const webhookUrl = `${process.env.HOST}/webhooks/${courseSlug}/exercise-processor/${exercise.id}/${rigoToken}`;
|
141
|
+
console.log("WEBHOOK URL", webhookUrl);
|
141
142
|
await (0, rigoActions_1.readmeCreator)(rigoToken, {
|
142
143
|
title: `${exercise.id} - ${exercise.title}`,
|
143
144
|
output_lang: packageContext.language || "en",
|
@@ -729,33 +730,38 @@ class ServeCommand extends SessionCommand_1.default {
|
|
729
730
|
res.status(500).json({ error: error.message });
|
730
731
|
}
|
731
732
|
});
|
732
|
-
app.get("/test/:slug", (req, res) => {
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
733
|
+
// app.get("/test/:slug", (req, res) => {
|
734
|
+
// emitToCourse(req.params.slug, "course-creation", {
|
735
|
+
// lesson: "000-welcome-to-bird-domestication",
|
736
|
+
// status: "generating",
|
737
|
+
// log: "Hello",
|
738
|
+
// })
|
739
|
+
// emitToCourse(req.params.slug, "course-creation", {
|
740
|
+
// lesson: "000-welcome-to-bird-domestication",
|
741
|
+
// status: "generating",
|
742
|
+
// log: "Hello",
|
743
|
+
// })
|
744
|
+
// emitToCourse(req.params.slug, "course-creation", {
|
745
|
+
// lesson: "000-welcome-to-bird-domestication",
|
746
|
+
// status: "generating",
|
747
|
+
// log: "Hello broder",
|
748
|
+
// })
|
749
|
+
// emitToCourse(req.params.slug, "course-creation", {
|
750
|
+
// lesson: "000-welcome-to-bird-domestication",
|
751
|
+
// status: "done",
|
752
|
+
// log: "Hello broder",
|
753
|
+
// })
|
754
|
+
// emitToCourse(req.params.slug, "course-creation", {
|
755
|
+
// lesson: "other",
|
756
|
+
// status: "generating",
|
757
|
+
// log: "Hello",
|
758
|
+
// })
|
759
|
+
// res.send({ message: "Course creation started" })
|
760
|
+
// })
|
761
|
+
app.get("/technologies", async (req, res) => {
|
762
|
+
console.log("GET /technologies");
|
763
|
+
const technologies = await api_1.default.getCurrentTechnologies();
|
764
|
+
res.json(technologies);
|
759
765
|
});
|
760
766
|
app.get("/assets/:file", (req, res) => {
|
761
767
|
const file = path.join(localAppPath, req.params.file);
|
@@ -826,6 +832,35 @@ class ServeCommand extends SessionCommand_1.default {
|
|
826
832
|
slug: (0, creatorUtilities_2.slugify)(syllabus.courseInfo.title),
|
827
833
|
});
|
828
834
|
});
|
835
|
+
// app.post(
|
836
|
+
// "/check-latex/:courseSlug/:exerciseSlug/:lang",
|
837
|
+
// async (req, res) => {
|
838
|
+
// const { courseSlug, exerciseSlug, lang } = req.params
|
839
|
+
// const rigoToken = req.header("x-rigo-token")
|
840
|
+
// if (!rigoToken) {
|
841
|
+
// return res.status(400).json({ error: "Missing tokens" })
|
842
|
+
// }
|
843
|
+
// const exercise = await bucket.file(
|
844
|
+
// `courses/${courseSlug}/exercises/${exerciseSlug}/README.${lang}.md`
|
845
|
+
// )
|
846
|
+
// const [content] = await exercise.download()
|
847
|
+
// const headers = {
|
848
|
+
// Authorization: `Token ${rigoToken}`,
|
849
|
+
// }
|
850
|
+
// const response = await axios.get(
|
851
|
+
// `${RIGOBOT_HOST}/v1/prompting/completion/60865/`,
|
852
|
+
// {
|
853
|
+
// headers,
|
854
|
+
// }
|
855
|
+
// )
|
856
|
+
// console.log(response.data.parsed.content, "RESPONSE from Rigobot")
|
857
|
+
// res.json({
|
858
|
+
// message: "Exercise downloaded",
|
859
|
+
// completion: response.data,
|
860
|
+
// exercise: content.toString(),
|
861
|
+
// })
|
862
|
+
// }
|
863
|
+
// )
|
829
864
|
app.get("/courses/:courseSlug/syllabus", async (req, res) => {
|
830
865
|
try {
|
831
866
|
console.log("GET /courses/:courseSlug/syllabus");
|
@@ -988,9 +1023,8 @@ class ServeCommand extends SessionCommand_1.default {
|
|
988
1023
|
const rigoRes = await axios_1.default.post(`${api_1.RIGOBOT_HOST}/v1/learnpack/upload`, form, {
|
989
1024
|
headers: Object.assign(Object.assign({}, form.getHeaders()), { Authorization: `Token ${rigoToken}` }),
|
990
1025
|
});
|
991
|
-
await (0, publish_1.handleAssetCreation)({ token: bcToken, rigobotToken: rigoToken }, fullConfig.config, rigoRes.data.url);
|
1026
|
+
await (0, publish_1.handleAssetCreation)({ token: bcToken, rigobotToken: rigoToken }, fullConfig.config, selectedLang, rigoRes.data.url);
|
992
1027
|
rimraf.sync(tmpRoot);
|
993
|
-
console.log("RIGO RES", rigoRes.data);
|
994
1028
|
return res.json({ url: rigoRes.data.url });
|
995
1029
|
});
|
996
1030
|
archive.on("error", err => {
|