@learnpack/learnpack 5.0.288 → 5.0.291
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/lib/commands/serve.js +62 -76
- package/lib/creatorDist/assets/{index-BjO3hUuz.js → index-wLKEQIG6.js} +4470 -4491
- package/lib/creatorDist/index.html +1 -1
- package/lib/utils/configBuilder.js +20 -1
- package/lib/utils/export/index.d.ts +1 -0
- package/lib/utils/export/index.js +3 -1
- package/lib/utils/export/types.d.ts +1 -1
- package/lib/utils/export/zip.d.ts +2 -0
- package/lib/utils/export/zip.js +46 -0
- package/package.json +1 -1
- package/src/commands/serve.ts +75 -88
- package/src/creator/src/App.tsx +59 -43
- package/src/creator/src/components/syllabus/SyllabusEditor.tsx +1 -21
- package/src/creator/src/utils/lib.ts +468 -477
- package/src/creator/src/utils/store.ts +222 -223
- package/src/creatorDist/assets/{index-BjO3hUuz.js → index-wLKEQIG6.js} +4470 -4491
- package/src/creatorDist/index.html +1 -1
- package/src/ui/_app/app.js +397 -397
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/configBuilder.ts +100 -82
- package/src/utils/export/index.ts +1 -0
- package/src/utils/export/types.ts +1 -1
- package/src/utils/export/zip.ts +55 -0
- package/src/creator/src/components/PassphraseValidator.tsx +0 -47
package/lib/commands/serve.js
CHANGED
@@ -121,9 +121,17 @@ const createMultiLangAsset = async (bucket, rigoToken, bcToken, courseSlug, cour
|
|
121
121
|
for (const lang of availableLangs) {
|
122
122
|
// eslint-disable-next-line no-await-in-loop
|
123
123
|
const indexReadme = await bucket.file(`courses/${courseSlug}/README${(0, creatorUtilities_1.getReadmeExtension)(lang)}`);
|
124
|
-
|
125
|
-
|
126
|
-
|
124
|
+
let indexReadmeString = "";
|
125
|
+
try {
|
126
|
+
// eslint-disable-next-line no-await-in-loop
|
127
|
+
const [indexReadmeContent] = await indexReadme.download();
|
128
|
+
indexReadmeString = indexReadmeContent.toString();
|
129
|
+
}
|
130
|
+
catch (error) {
|
131
|
+
console.error("Error downloading index readme", error);
|
132
|
+
// TODO: Trigger generation of the index readme
|
133
|
+
indexReadmeString = "";
|
134
|
+
}
|
127
135
|
const b64IndexReadme = buffer_1.Buffer.from(indexReadmeString).toString("base64");
|
128
136
|
// eslint-disable-next-line no-await-in-loop
|
129
137
|
const asset = await (0, publish_1.handleAssetCreation)({ token: bcToken, rigobotToken: rigoToken.trim() }, courseJson, lang, deployUrl, b64IndexReadme, all_translations);
|
@@ -458,6 +466,7 @@ class ServeCommand extends SessionCommand_1.default {
|
|
458
466
|
await uploadFileToBucket(bucket, JSON.stringify(syllabusJson), `courses/${courseSlug}/.learn/initialSyllabus.json`);
|
459
467
|
res.json({ status: "SUCCESS" });
|
460
468
|
});
|
469
|
+
// TODO: Check if this command is being used
|
461
470
|
app.post("/actions/generate-image/:courseSlug", async (req, res) => {
|
462
471
|
const rigoToken = req.header("x-rigo-token");
|
463
472
|
const { courseSlug } = req.params;
|
@@ -659,6 +668,8 @@ class ServeCommand extends SessionCommand_1.default {
|
|
659
668
|
try {
|
660
669
|
console.log("GET CONFIG, COURSE SLUG", courseSlug);
|
661
670
|
const { config, exercises } = await (0, configBuilder_1.buildConfig)(bucket, courseSlug);
|
671
|
+
console.log("CONFIG", config);
|
672
|
+
console.log("EXERCISES", exercises);
|
662
673
|
res.set("X-Creator-Web", "true");
|
663
674
|
res.set("Access-Control-Expose-Headers", "X-Creator-Web");
|
664
675
|
await uploadFileToBucket(bucket, JSON.stringify({ config, exercises }), `courses/${courseSlug}/.learn/config.json`);
|
@@ -674,7 +685,6 @@ class ServeCommand extends SessionCommand_1.default {
|
|
674
685
|
const { slug } = req.params;
|
675
686
|
const courseSlug = req.query.slug;
|
676
687
|
const lang = req.query.lang || "en";
|
677
|
-
console.log("LANG", lang);
|
678
688
|
if (!courseSlug) {
|
679
689
|
return res.status(400).json({ error: "Missing courseSlug" });
|
680
690
|
}
|
@@ -1024,44 +1034,6 @@ class ServeCommand extends SessionCommand_1.default {
|
|
1024
1034
|
return res.status(500).json({ error: "Error getting syllabus" });
|
1025
1035
|
}
|
1026
1036
|
});
|
1027
|
-
// app.post("/actions/continue-course/:courseSlug", async (req, res) => {
|
1028
|
-
// console.log("POST /actions/continue-course/:courseSlug")
|
1029
|
-
// const { courseSlug } = req.params
|
1030
|
-
// const { feedback }: { feedback: string } = req.body
|
1031
|
-
// const rigoToken = req.header("x-rigo-token")
|
1032
|
-
// const bcToken = req.header("x-breathecode-token")
|
1033
|
-
// if (!rigoToken || !bcToken) {
|
1034
|
-
// return res.status(400).json({ error: "Missing tokens" })
|
1035
|
-
// }
|
1036
|
-
// const syllabus = await bucket.file(
|
1037
|
-
// `courses/${courseSlug}/.learn/initialSyllabus.json`
|
1038
|
-
// )
|
1039
|
-
// const [content] = await syllabus.download()
|
1040
|
-
// const syllabusJson: Syllabus = JSON.parse(content.toString())
|
1041
|
-
// const notGeneratedLessons = syllabusJson.lessons.filter(
|
1042
|
-
// lesson => !lesson.generated
|
1043
|
-
// )
|
1044
|
-
// const lastGeneratedLesson = findLast(
|
1045
|
-
// syllabusJson.lessons,
|
1046
|
-
// lesson => lesson.generated ?? false
|
1047
|
-
// )
|
1048
|
-
// console.log("ABout to generate", notGeneratedLessons.length, "lessons")
|
1049
|
-
// const firstLessonToGenerate = notGeneratedLessons[0]
|
1050
|
-
// const completionId = await startExerciseGeneration(
|
1051
|
-
// rigoToken,
|
1052
|
-
// syllabusJson.lessons,
|
1053
|
-
// syllabusJson.courseInfo,
|
1054
|
-
// firstLessonToGenerate,
|
1055
|
-
// courseSlug,
|
1056
|
-
// syllabusJson.courseInfo.purpose,
|
1057
|
-
// JSON.stringify(lastGeneratedLesson) +
|
1058
|
-
// `\n\nThe user provided this feedback in relation to the course: ${feedback}`
|
1059
|
-
// )
|
1060
|
-
// return res.json({
|
1061
|
-
// message: "Course continued",
|
1062
|
-
// slug: courseSlug,
|
1063
|
-
// })
|
1064
|
-
// })
|
1065
1037
|
app.get("/courses/:courseSlug/exercises/:exerciseSlug/", async (req, res) => {
|
1066
1038
|
var _a;
|
1067
1039
|
console.log("GET /courses/:courseSlug/exercises/:exerciseSlug/");
|
@@ -1382,43 +1354,57 @@ class ServeCommand extends SessionCommand_1.default {
|
|
1382
1354
|
try {
|
1383
1355
|
let outputPath;
|
1384
1356
|
let filename;
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1357
|
+
switch (format) {
|
1358
|
+
case "scorm": {
|
1359
|
+
outputPath = await (0, export_1.exportToScorm)({
|
1360
|
+
courseSlug: course_slug,
|
1361
|
+
format: "scorm",
|
1362
|
+
bucket,
|
1363
|
+
outDir: path.join(__dirname, "../output/directory"),
|
1364
|
+
});
|
1365
|
+
filename = `${course_slug}-scorm.zip`;
|
1366
|
+
break;
|
1367
|
+
}
|
1368
|
+
case "zip": {
|
1369
|
+
outputPath = await (0, export_1.exportToZip)({
|
1370
|
+
courseSlug: course_slug,
|
1371
|
+
format: "zip",
|
1372
|
+
bucket,
|
1373
|
+
outDir: path.join(__dirname, "../output/directory"),
|
1374
|
+
});
|
1375
|
+
filename = `${course_slug}.zip`;
|
1376
|
+
break;
|
1377
|
+
}
|
1378
|
+
case "epub": {
|
1379
|
+
console.log("EPUB export", metadata);
|
1380
|
+
// Validate required metadata for EPUB
|
1381
|
+
if (!metadata ||
|
1382
|
+
!metadata.creator ||
|
1383
|
+
!metadata.publisher ||
|
1384
|
+
!metadata.title ||
|
1385
|
+
!metadata.rights ||
|
1386
|
+
!metadata.lang) {
|
1387
|
+
console.log("Missing required metadata for EPUB export", metadata);
|
1388
|
+
return res.status(400).json({
|
1389
|
+
error: "Missing required metadata for EPUB export",
|
1390
|
+
required: ["creator", "publisher", "title", "rights", "lang"],
|
1391
|
+
});
|
1392
|
+
}
|
1393
|
+
outputPath = await (0, export_1.exportToEpub)({
|
1394
|
+
courseSlug: course_slug,
|
1395
|
+
format: "epub",
|
1396
|
+
bucket,
|
1397
|
+
outDir: path.join(__dirname, "../output/directory"),
|
1398
|
+
language: language,
|
1399
|
+
}, metadata);
|
1400
|
+
filename = `${course_slug}.epub`;
|
1401
|
+
break;
|
1402
|
+
}
|
1403
|
+
default: {
|
1404
1404
|
return res.status(400).json({
|
1405
|
-
error: "
|
1406
|
-
required: ["creator", "publisher", "title", "rights", "lang"],
|
1405
|
+
error: "Invalid format. Supported formats: scorm, epub, zip",
|
1407
1406
|
});
|
1408
1407
|
}
|
1409
|
-
outputPath = await (0, export_1.exportToEpub)({
|
1410
|
-
courseSlug: course_slug,
|
1411
|
-
format: "epub",
|
1412
|
-
bucket,
|
1413
|
-
outDir: path.join(__dirname, "../output/directory"),
|
1414
|
-
language: language,
|
1415
|
-
}, metadata);
|
1416
|
-
filename = `${course_slug}.epub`;
|
1417
|
-
}
|
1418
|
-
else {
|
1419
|
-
return res.status(400).json({
|
1420
|
-
error: "Invalid format. Supported formats: scorm, epub",
|
1421
|
-
});
|
1422
1408
|
}
|
1423
1409
|
// Send the file and clean up
|
1424
1410
|
res.download(outputPath, filename, err => {
|