@learnpack/learnpack 5.0.142 → 5.0.146
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 +13 -13
- package/lib/commands/serve.js +56 -0
- package/lib/creatorDist/assets/{index-BLd63KeV.js → index-CzMCewx6.js} +2854 -2841
- package/lib/creatorDist/assets/{index-Cz25oPGo.css → index-DSOj0E0h.css} +6 -0
- package/lib/creatorDist/index.html +7 -2
- package/lib/utils/sidebarGenerator.d.ts +4 -0
- package/lib/utils/sidebarGenerator.js +47 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/serve.ts +108 -0
- package/src/creator/index.html +5 -0
- package/src/creator/src/App.tsx +59 -35
- package/src/creator/src/components/Login.tsx +2 -1
- package/src/creator/src/components/TurnstileChallenge.tsx +83 -0
- package/src/creator/src/utils/store.ts +4 -0
- package/src/creatorDist/assets/{index-BLd63KeV.js → index-CzMCewx6.js} +2854 -2841
- package/src/creatorDist/assets/{index-Cz25oPGo.css → index-DSOj0E0h.css} +6 -0
- package/src/creatorDist/index.html +7 -2
- package/src/ui/_app/app.js +1 -1
- package/src/ui/_app/rigo-float.gif +0 -0
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/sidebarGenerator.ts +68 -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/5.0.
|
24
|
+
@learnpack/learnpack/5.0.146 win32-x64 node-v22.15.0
|
25
25
|
$ learnpack --help [COMMAND]
|
26
26
|
USAGE
|
27
27
|
$ learnpack COMMAND
|
@@ -80,7 +80,7 @@ DESCRIPTION
|
|
80
80
|
12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
|
81
81
|
```
|
82
82
|
|
83
|
-
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
83
|
+
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\audit.ts)_
|
84
84
|
|
85
85
|
## `learnpack breakToken`
|
86
86
|
|
@@ -95,7 +95,7 @@ OPTIONS
|
|
95
95
|
-y, --yes Skip all prompts and initialize an empty project
|
96
96
|
```
|
97
97
|
|
98
|
-
_See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
98
|
+
_See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\breakToken.ts)_
|
99
99
|
|
100
100
|
## `learnpack clean`
|
101
101
|
|
@@ -110,7 +110,7 @@ DESCRIPTION
|
|
110
110
|
Extra documentation goes here
|
111
111
|
```
|
112
112
|
|
113
|
-
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
113
|
+
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\clean.ts)_
|
114
114
|
|
115
115
|
## `learnpack download [PACKAGE]`
|
116
116
|
|
@@ -128,7 +128,7 @@ DESCRIPTION
|
|
128
128
|
Extra documentation goes here
|
129
129
|
```
|
130
130
|
|
131
|
-
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
131
|
+
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\download.ts)_
|
132
132
|
|
133
133
|
## `learnpack help [COMMAND]`
|
134
134
|
|
@@ -160,7 +160,7 @@ OPTIONS
|
|
160
160
|
-y, --yes Skip all prompts and initialize an empty project
|
161
161
|
```
|
162
162
|
|
163
|
-
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
163
|
+
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\init.ts)_
|
164
164
|
|
165
165
|
## `learnpack login [PACKAGE]`
|
166
166
|
|
@@ -178,7 +178,7 @@ DESCRIPTION
|
|
178
178
|
Extra documentation goes here
|
179
179
|
```
|
180
180
|
|
181
|
-
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
181
|
+
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\login.ts)_
|
182
182
|
|
183
183
|
## `learnpack logout [PACKAGE]`
|
184
184
|
|
@@ -196,7 +196,7 @@ DESCRIPTION
|
|
196
196
|
Extra documentation goes here
|
197
197
|
```
|
198
198
|
|
199
|
-
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
199
|
+
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\logout.ts)_
|
200
200
|
|
201
201
|
## `learnpack plugins`
|
202
202
|
|
@@ -328,7 +328,7 @@ OPTIONS
|
|
328
328
|
-s, --strict strict mode
|
329
329
|
```
|
330
330
|
|
331
|
-
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
331
|
+
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\publish.ts)_
|
332
332
|
|
333
333
|
## `learnpack serve`
|
334
334
|
|
@@ -345,7 +345,7 @@ OPTIONS
|
|
345
345
|
-y, --yes Skip all prompts and initialize an empty project
|
346
346
|
```
|
347
347
|
|
348
|
-
_See code: [src\commands\serve.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
348
|
+
_See code: [src\commands\serve.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\serve.ts)_
|
349
349
|
|
350
350
|
## `learnpack start`
|
351
351
|
|
@@ -367,7 +367,7 @@ OPTIONS
|
|
367
367
|
-y, --yes Skip all prompts and initialize an empty project
|
368
368
|
```
|
369
369
|
|
370
|
-
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
370
|
+
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\start.ts)_
|
371
371
|
|
372
372
|
## `learnpack test [EXERCISESLUG]`
|
373
373
|
|
@@ -384,7 +384,7 @@ OPTIONS
|
|
384
384
|
-y, --yes Skip all prompts and initialize an empty project
|
385
385
|
```
|
386
386
|
|
387
|
-
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
387
|
+
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\test.ts)_
|
388
388
|
|
389
389
|
## `learnpack translate`
|
390
390
|
|
@@ -398,7 +398,7 @@ OPTIONS
|
|
398
398
|
-y, --yes Skip all prompts and initialize an empty project
|
399
399
|
```
|
400
400
|
|
401
|
-
_See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
401
|
+
_See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.146/src\commands\translate.ts)_
|
402
402
|
<!-- commandsstop -->
|
403
403
|
|
404
404
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
package/lib/commands/serve.js
CHANGED
@@ -29,6 +29,7 @@ const api_1 = require("../utils/api");
|
|
29
29
|
const misc_1 = require("../utils/misc");
|
30
30
|
const configBuilder_1 = require("../utils/configBuilder");
|
31
31
|
const creatorUtilities_2 = require("../utils/creatorUtilities");
|
32
|
+
const sidebarGenerator_1 = require("../utils/sidebarGenerator");
|
32
33
|
const frontMatter = require("front-matter");
|
33
34
|
dotenv.config();
|
34
35
|
const createLearnJson = (courseInfo) => {
|
@@ -91,6 +92,15 @@ const processImage = async (bucket, tutorialDir, url, description, rigoToken) =>
|
|
91
92
|
}
|
92
93
|
};
|
93
94
|
exports.processImage = processImage;
|
95
|
+
const createInitialSidebar = async (slugs) => {
|
96
|
+
const sidebar = {};
|
97
|
+
for (const slug of slugs) {
|
98
|
+
sidebar[slug] = {
|
99
|
+
us: slug,
|
100
|
+
};
|
101
|
+
}
|
102
|
+
return sidebar;
|
103
|
+
};
|
94
104
|
async function processExercise(bucket, rigoToken, steps, packageContext, exercise, exercisesDir, courseSlug) {
|
95
105
|
// const tid = toast.loading("Generating lesson...")
|
96
106
|
const exSlug = (0, creatorUtilities_2.slugify)(exercise.id + "-" + exercise.title);
|
@@ -441,6 +451,49 @@ class ServeCommand extends SessionCommand_1.default {
|
|
441
451
|
}
|
442
452
|
res.send({ message: "Files deleted" });
|
443
453
|
});
|
454
|
+
app.get("/translations/sidebar", async (req, res) => {
|
455
|
+
const { slug } = req.query;
|
456
|
+
const rigoToken = req.header("x-rigo-token");
|
457
|
+
console.log("GETTING SIDEBAR FOR", slug);
|
458
|
+
if (!slug) {
|
459
|
+
return res.status(400).json({ error: "Slug is required" });
|
460
|
+
}
|
461
|
+
const courseSlug = slug;
|
462
|
+
try {
|
463
|
+
const file = bucket.file(`courses/${courseSlug}/.learn/sidebar.json`);
|
464
|
+
const [content] = await file.download();
|
465
|
+
const sidebar = JSON.parse(content.toString());
|
466
|
+
if (rigoToken) {
|
467
|
+
const { exercises } = await (0, configBuilder_1.buildConfig)(bucket, courseSlug);
|
468
|
+
const { fixedSidebar, valid } = await (0, sidebarGenerator_1.checkAndFixSidebarPure)(sidebar, exercises, rigoToken);
|
469
|
+
if (fixedSidebar) {
|
470
|
+
await uploadFileToBucket(bucket, JSON.stringify(fixedSidebar), `courses/${courseSlug}/.learn/sidebar.json`);
|
471
|
+
return res.json(fixedSidebar);
|
472
|
+
}
|
473
|
+
}
|
474
|
+
res.json(sidebar);
|
475
|
+
}
|
476
|
+
catch (error) {
|
477
|
+
if (error.code === 404) {
|
478
|
+
console.log("SIDEBAR FILE NOT FOUND", courseSlug);
|
479
|
+
const { exercises } = await (0, configBuilder_1.buildConfig)(bucket, courseSlug);
|
480
|
+
const exerciseSlugsArray = exercises.map(exercise => exercise.slug);
|
481
|
+
const sidebar = await createInitialSidebar(exerciseSlugsArray);
|
482
|
+
if (rigoToken) {
|
483
|
+
const { fixedSidebar } = await (0, sidebarGenerator_1.checkAndFixSidebarPure)(sidebar, exercises, rigoToken);
|
484
|
+
if (fixedSidebar) {
|
485
|
+
await uploadFileToBucket(bucket, JSON.stringify(fixedSidebar), `courses/${courseSlug}/.learn/sidebar.json`);
|
486
|
+
}
|
487
|
+
await uploadFileToBucket(bucket, JSON.stringify(sidebar), `courses/${courseSlug}/.learn/sidebar.json`);
|
488
|
+
return res.status(200).json(fixedSidebar);
|
489
|
+
}
|
490
|
+
await uploadFileToBucket(bucket, JSON.stringify(sidebar), `courses/${courseSlug}/.learn/sidebar.json`);
|
491
|
+
return res.status(200).json(sidebar);
|
492
|
+
}
|
493
|
+
console.error("Unexpected error:", error);
|
494
|
+
res.status(500).json({ error: error.message });
|
495
|
+
}
|
496
|
+
});
|
444
497
|
app.get("/test/:slug", (req, res) => {
|
445
498
|
(0, creatorSocket_1.emitToCourse)(req.params.slug, "course-creation", {
|
446
499
|
lesson: "000-welcome-to-bird-domestication",
|
@@ -511,6 +564,9 @@ class ServeCommand extends SessionCommand_1.default {
|
|
511
564
|
return (0, exports.processImage)(bucket, tutorialDir, image.url, image.alt, rigoToken);
|
512
565
|
});
|
513
566
|
await Promise.all(imagePromises);
|
567
|
+
const sidebar = await createInitialSidebar(syllabus.lessons.map(lesson => (0, creatorUtilities_2.slugify)(lesson.id + "-" + lesson.title)));
|
568
|
+
await uploadFileToBucket(bucket, JSON.stringify(sidebar), `${tutorialDir}/.learn/sidebar.json`);
|
569
|
+
console.log("SIDEBAR UPLOADED", sidebar);
|
514
570
|
return res.json({
|
515
571
|
message: "Course created",
|
516
572
|
slug: (0, creatorUtilities_2.slugify)(syllabus.courseInfo.title),
|