@learnpack/learnpack 5.0.250 → 5.0.254
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/audit.js +1 -1
- package/lib/commands/publish.js +4 -3
- package/lib/commands/serve.d.ts +0 -3
- package/lib/commands/serve.js +50 -47
- package/lib/creatorDist/assets/{index-CZYzWk3G.js → index-CFM_Ypyi.js} +25 -22
- package/lib/creatorDist/index.html +1 -1
- package/lib/managers/config/exercise.js +1 -1
- package/lib/utils/api.js +4 -3
- package/lib/utils/configBuilder.js +1 -1
- package/lib/utils/creatorUtilities.d.ts +1 -0
- package/lib/utils/creatorUtilities.js +5 -1
- package/package.json +1 -1
- package/src/commands/audit.ts +9 -18
- package/src/commands/publish.ts +4 -3
- package/src/commands/serve.ts +75 -68
- package/src/creator/src/App.tsx +1 -1
- package/src/creator/src/utils/rigo.ts +2 -0
- package/src/creatorDist/assets/{index-CZYzWk3G.js → index-CFM_Ypyi.js} +25 -22
- package/src/creatorDist/index.html +1 -1
- package/src/managers/config/exercise.ts +8 -16
- package/src/ui/_app/app.js +379 -379
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/api.ts +4 -3
- package/src/utils/configBuilder.ts +1 -1
- package/src/utils/creatorUtilities.ts +4 -0
- package/src/utils/templates/incremental/.vscode/schema.json +5 -5
- package/src/utils/templates/isolated/.vscode/schema.json +5 -5
package/lib/commands/audit.js
CHANGED
@@ -309,7 +309,7 @@ class AuditCommand extends SessionCommand_1.default {
|
|
309
309
|
for (const readmeFile of readmeFiles) {
|
310
310
|
// Checking the language of each README file.
|
311
311
|
if (readmeFile === "README.md")
|
312
|
-
translations.push("
|
312
|
+
translations.push("en");
|
313
313
|
else {
|
314
314
|
const regexGroups = translationRegex.exec(readmeFile);
|
315
315
|
if (regexGroups)
|
package/lib/commands/publish.js
CHANGED
@@ -22,6 +22,7 @@ const creatorUtilities_1 = require("../utils/creatorUtilities");
|
|
22
22
|
const uploadZipEndpont = api_1.RIGOBOT_HOST + "/v1/learnpack/upload";
|
23
23
|
const handleAssetCreation = async (sessionPayload, learnJson, selectedLang, learnpackDeployUrl, b64IndexReadme, all_translations = []) => {
|
24
24
|
const categories = {
|
25
|
+
en: 9,
|
25
26
|
us: 9,
|
26
27
|
es: 10,
|
27
28
|
};
|
@@ -232,8 +233,8 @@ class BuildCommand extends SessionCommand_1.default {
|
|
232
233
|
const buildManifestPWA = path.join(buildDir, "manifest.webmanifest");
|
233
234
|
if (fs.existsSync(indexHtmlPath)) {
|
234
235
|
let indexHtmlContent = fs.readFileSync(indexHtmlPath, "utf-8");
|
235
|
-
const description = learnJson.description.
|
236
|
-
const title = learnJson.title.
|
236
|
+
const description = learnJson.description.en || "LearnPack is awesome!";
|
237
|
+
const title = learnJson.title.en || "LearnPack: Interactive Learning as a Service";
|
237
238
|
const previewUrl = learnJson.preview ||
|
238
239
|
"https://raw.githubusercontent.com/learnpack/ide/refs/heads/master/public/learnpack.svg";
|
239
240
|
// Replace placeholders and the <title>Old title </title> tag for a new tag with the title
|
@@ -301,7 +302,7 @@ class BuildCommand extends SessionCommand_1.default {
|
|
301
302
|
console.log(res.data);
|
302
303
|
fs.unlinkSync(zipFilePath);
|
303
304
|
this.removeDirectory(buildDir);
|
304
|
-
await (0, exports.handleAssetCreation)(sessionPayload, learnJson, "
|
305
|
+
await (0, exports.handleAssetCreation)(sessionPayload, learnJson, "en", res.data.url, "", []);
|
305
306
|
}
|
306
307
|
catch (error) {
|
307
308
|
if (axios_1.default.isAxiosError(error)) {
|
package/lib/commands/serve.d.ts
CHANGED
package/lib/commands/serve.js
CHANGED
@@ -42,21 +42,16 @@ function findLast(array, predicate) {
|
|
42
42
|
const createLearnJson = (courseInfo) => {
|
43
43
|
// console.log("courseInfo to create learn json", courseInfo)
|
44
44
|
const expectedPreviewUrl = `https://${courseInfo.slug}.learn-pack.com/preview.png`;
|
45
|
-
console.log("Preview url in generated learn.json", expectedPreviewUrl);
|
46
45
|
const language = courseInfo.language || "en";
|
47
46
|
const learnJson = {
|
48
47
|
slug: courseInfo.slug,
|
49
|
-
title:
|
50
|
-
|
51
|
-
|
52
|
-
} :
|
53
|
-
{
|
54
|
-
[language]: courseInfo.title,
|
55
|
-
},
|
48
|
+
title: {
|
49
|
+
[language]: courseInfo.title,
|
50
|
+
},
|
56
51
|
technologies: courseInfo.technologies || [],
|
57
52
|
difficulty: "beginner",
|
58
53
|
description: {
|
59
|
-
[language
|
54
|
+
[language]: courseInfo.description,
|
60
55
|
},
|
61
56
|
grading: "isolated",
|
62
57
|
telemetry: {
|
@@ -96,11 +91,10 @@ const processImage = async (url, description, rigoToken, courseSlug) => {
|
|
96
91
|
};
|
97
92
|
exports.processImage = processImage;
|
98
93
|
const createInitialSidebar = async (slugs, initialLanguage = "en") => {
|
99
|
-
const language = initialLanguage === "en" ? "us" : initialLanguage;
|
100
94
|
const sidebar = {};
|
101
95
|
for (const slug of slugs) {
|
102
96
|
sidebar[slug] = {
|
103
|
-
[
|
97
|
+
[initialLanguage]: slug,
|
104
98
|
};
|
105
99
|
}
|
106
100
|
return sidebar;
|
@@ -126,13 +120,17 @@ const createMultiLangAsset = async (bucket, rigoToken, bcToken, courseSlug, cour
|
|
126
120
|
const all_translations = [];
|
127
121
|
for (const lang of availableLangs) {
|
128
122
|
// eslint-disable-next-line no-await-in-loop
|
129
|
-
const indexReadme = await bucket.file(`courses/${courseSlug}/README
|
123
|
+
const indexReadme = await bucket.file(`courses/${courseSlug}/README${(0, creatorUtilities_1.getReadmeExtension)(lang)}`);
|
130
124
|
// eslint-disable-next-line no-await-in-loop
|
131
125
|
const [indexReadmeContent] = await indexReadme.download();
|
132
126
|
const indexReadmeString = indexReadmeContent.toString();
|
133
127
|
const b64IndexReadme = Buffer.from(indexReadmeString).toString("base64");
|
134
128
|
// eslint-disable-next-line no-await-in-loop
|
135
129
|
const asset = await (0, publish_1.handleAssetCreation)({ token: bcToken, rigobotToken: rigoToken.trim() }, courseJson, lang, deployUrl, b64IndexReadme, all_translations);
|
130
|
+
if (!asset) {
|
131
|
+
console.log("No se pudo crear el asset, saltando idioma", lang);
|
132
|
+
continue;
|
133
|
+
}
|
136
134
|
all_translations.push(asset.slug);
|
137
135
|
}
|
138
136
|
};
|
@@ -334,13 +332,8 @@ class ServeCommand extends SessionCommand_1.default {
|
|
334
332
|
const { courseSlug } = req.params;
|
335
333
|
const body = req.body;
|
336
334
|
// Save the file as courses/courseSlug/README.md
|
337
|
-
const filePath = `courses/${courseSlug}/README
|
338
|
-
body.parsed.language_code === "en" ?
|
339
|
-
"md" :
|
340
|
-
`${body.parsed.language_code}.md`}`;
|
341
|
-
console.log("Saving initial readme to", filePath);
|
335
|
+
const filePath = `courses/${courseSlug}/README${(0, creatorUtilities_1.getReadmeExtension)(body.parsed.language_code)}`;
|
342
336
|
await uploadFileToBucket(bucket, body.parsed.content, filePath);
|
343
|
-
console.log("Initial readme saved to", filePath);
|
344
337
|
res.json({ status: "SUCCESS" });
|
345
338
|
});
|
346
339
|
app.post("/webhooks/:courseSlug/images/:imageId", async (req, res) => {
|
@@ -452,6 +445,21 @@ class ServeCommand extends SessionCommand_1.default {
|
|
452
445
|
const [exists] = await file.exists();
|
453
446
|
res.json({ exists, file: file.name });
|
454
447
|
});
|
448
|
+
app.post("/webhooks/:courseSlug/:exSlug/:lang/update-readme/:notificationId", async (req, res) => {
|
449
|
+
console.log("RECEIVING README UPDATE WEBHOOK");
|
450
|
+
const { courseSlug, exSlug, lang, notificationId } = req.params;
|
451
|
+
const body = req.body;
|
452
|
+
console.log("BODY", body);
|
453
|
+
const readmePath = `courses/${courseSlug}/exercises/${exSlug}/README${(0, creatorUtilities_1.getReadmeExtension)(lang)}`;
|
454
|
+
if (body.parsed.content) {
|
455
|
+
await uploadFileToBucket(bucket, body.parsed.content, readmePath);
|
456
|
+
}
|
457
|
+
(0, creatorSocket_1.emitToNotification)(notificationId, {
|
458
|
+
status: "SUCCESS",
|
459
|
+
message: "Readme updated successfully",
|
460
|
+
});
|
461
|
+
res.json({ status: "SUCCESS" });
|
462
|
+
});
|
455
463
|
app.get("/create", (req, res) => {
|
456
464
|
console.log("GET /create");
|
457
465
|
res.redirect("/creator/");
|
@@ -497,7 +505,8 @@ class ServeCommand extends SessionCommand_1.default {
|
|
497
505
|
console.log("GET /exercise/:slug/readme");
|
498
506
|
const { slug } = req.params;
|
499
507
|
const courseSlug = req.query.slug;
|
500
|
-
const lang = req.query.lang || "
|
508
|
+
const lang = req.query.lang || "en";
|
509
|
+
console.log("LANG", lang);
|
501
510
|
if (!courseSlug) {
|
502
511
|
return res.status(400).json({ error: "Missing courseSlug" });
|
503
512
|
}
|
@@ -509,22 +518,30 @@ class ServeCommand extends SessionCommand_1.default {
|
|
509
518
|
if (readmeFiles.length === 0) {
|
510
519
|
return res.status(404).json({ error: "No README files found" });
|
511
520
|
}
|
512
|
-
const requestedFilename =
|
513
|
-
`${basePath}README.md` :
|
514
|
-
`${basePath}README.${lang}.md`;
|
521
|
+
const requestedFilename = `${basePath}README${(0, creatorUtilities_1.getReadmeExtension)(lang)}`;
|
515
522
|
let selectedFile = readmeFiles.find(f => f === requestedFilename);
|
516
523
|
if (!selectedFile) {
|
524
|
+
console.log("No se encontro en ese idioma, devolviendo el primero");
|
517
525
|
selectedFile = readmeFiles[0];
|
518
526
|
console.warn(`Requested README not found for lang '${lang}', using '${selectedFile}'`);
|
519
527
|
}
|
520
|
-
let foundLang = "
|
528
|
+
let foundLang = "en";
|
521
529
|
const match = selectedFile.match(/readme(?:\.([a-z]{2}))?\.md$/i);
|
522
530
|
if (match && match[1]) {
|
523
531
|
foundLang = match[1].toLowerCase();
|
524
532
|
}
|
525
533
|
const [contentBuffer] = await bucket.file(selectedFile).download();
|
526
|
-
|
527
|
-
|
534
|
+
try {
|
535
|
+
const { attributes, body } = frontMatter(contentBuffer.toString());
|
536
|
+
res.send({ attributes, body, lang: foundLang });
|
537
|
+
}
|
538
|
+
catch (_a) {
|
539
|
+
res.status(200).json({
|
540
|
+
attributes: {},
|
541
|
+
body: contentBuffer.toString(),
|
542
|
+
lang: foundLang,
|
543
|
+
});
|
544
|
+
}
|
528
545
|
}
|
529
546
|
catch (error) {
|
530
547
|
console.error(error);
|
@@ -575,7 +592,7 @@ class ServeCommand extends SessionCommand_1.default {
|
|
575
592
|
.json({ error: "Missing title or readme content" });
|
576
593
|
}
|
577
594
|
const courseSlug = query.slug;
|
578
|
-
const fileName = `courses/${courseSlug}/exercises/${title}/README${
|
595
|
+
const fileName = `courses/${courseSlug}/exercises/${title}/README${(0, creatorUtilities_1.getReadmeExtension)(language)}`;
|
579
596
|
const file = bucket.file(fileName);
|
580
597
|
await file.save(readme);
|
581
598
|
const created = await file.exists();
|
@@ -614,9 +631,7 @@ class ServeCommand extends SessionCommand_1.default {
|
|
614
631
|
const languageCodes = new Set();
|
615
632
|
try {
|
616
633
|
await Promise.all(exerciseSlugs.map(async (slug) => {
|
617
|
-
const readmePath = `courses/${courseSlug}/exercises/${slug}/README${
|
618
|
-
"" :
|
619
|
-
`.${currentLanguage}`}.md`;
|
634
|
+
const readmePath = `courses/${courseSlug}/exercises/${slug}/README${(0, creatorUtilities_1.getReadmeExtension)(currentLanguage)}`;
|
620
635
|
const readme = await bucket.file(readmePath).download();
|
621
636
|
await Promise.all(languagesToTranslate.map(async (language) => {
|
622
637
|
const response = await (0, rigoActions_1.translateExercise)(rigoToken, {
|
@@ -624,18 +639,11 @@ class ServeCommand extends SessionCommand_1.default {
|
|
624
639
|
output_language: language,
|
625
640
|
exercise_slug: slug,
|
626
641
|
});
|
627
|
-
const translatedReadme = await bucket.file(`courses/${courseSlug}/exercises/${slug}/README${response.parsed.output_language_code
|
628
|
-
response.parsed.output_language_code === "en" ?
|
629
|
-
"" :
|
630
|
-
`.${response.parsed.output_language_code}`}.md`);
|
642
|
+
const translatedReadme = await bucket.file(`courses/${courseSlug}/exercises/${slug}/README${(0, creatorUtilities_1.getReadmeExtension)(response.parsed.output_language_code)}`);
|
631
643
|
await translatedReadme.save(response.parsed.translation);
|
632
644
|
languageCodes.add(response.parsed.output_language_code);
|
633
645
|
}));
|
634
646
|
}));
|
635
|
-
if (languageCodes.has("en")) {
|
636
|
-
languageCodes.delete("en");
|
637
|
-
languageCodes.add("us");
|
638
|
-
}
|
639
647
|
const currentLanguages = Object.keys(courseJson.title);
|
640
648
|
for (const languageCode of currentLanguages) {
|
641
649
|
if (languageCodes.has(languageCode)) {
|
@@ -643,7 +651,6 @@ class ServeCommand extends SessionCommand_1.default {
|
|
643
651
|
}
|
644
652
|
}
|
645
653
|
if ([...languageCodes].length > 0) {
|
646
|
-
console.log("TRANSLATING COURSE METADATA", languageCodes);
|
647
654
|
const translatedCourseMetadata = await Promise.all([...languageCodes].map(async (languageCode) => {
|
648
655
|
const result = await (0, rigoActions_1.translateCourseMetadata)(rigoToken, {
|
649
656
|
title: courseJson.title[currentLanguage],
|
@@ -662,9 +669,7 @@ class ServeCommand extends SessionCommand_1.default {
|
|
662
669
|
metadata.description;
|
663
670
|
}
|
664
671
|
await uploadFileToBucket(bucket, JSON.stringify(courseJson), `courses/${courseSlug}/learn.json`);
|
665
|
-
const previewReadme = await bucket.file(`courses/${courseSlug}/README${
|
666
|
-
"" :
|
667
|
-
`.${currentLanguage}`}.md`);
|
672
|
+
const previewReadme = await bucket.file(`courses/${courseSlug}/README${(0, creatorUtilities_1.getReadmeExtension)(currentLanguage)}`);
|
668
673
|
const [previewReadmeContent] = await previewReadme.download();
|
669
674
|
const previewReadmeContentString = previewReadmeContent.toString();
|
670
675
|
await Promise.all([...languageCodes].map(async (languageCode) => {
|
@@ -674,9 +679,7 @@ class ServeCommand extends SessionCommand_1.default {
|
|
674
679
|
exercise_slug: "preview-readme",
|
675
680
|
});
|
676
681
|
await bucket
|
677
|
-
.file(`courses/${courseSlug}/README${
|
678
|
-
"" :
|
679
|
-
`.${languageCode}`}.md`)
|
682
|
+
.file(`courses/${courseSlug}/README${(0, creatorUtilities_1.getReadmeExtension)(languageCode)}`)
|
680
683
|
.save(translatedPreviewReadme.parsed.translation);
|
681
684
|
}));
|
682
685
|
}
|
@@ -919,10 +922,10 @@ class ServeCommand extends SessionCommand_1.default {
|
|
919
922
|
};
|
920
923
|
copyDir(uiSrc, buildRoot);
|
921
924
|
const availableLangs = Object.keys(config.title);
|
922
|
-
let selectedLang = "
|
925
|
+
let selectedLang = "en";
|
923
926
|
let title = "";
|
924
|
-
if (availableLangs.includes("
|
925
|
-
title = config.title.
|
927
|
+
if (availableLangs.includes("en")) {
|
928
|
+
title = config.title.en;
|
926
929
|
}
|
927
930
|
else {
|
928
931
|
// Select the first available lang
|
@@ -18251,28 +18251,31 @@ const d2 = async (e) => {
|
|
18251
18251
|
try {
|
18252
18252
|
const l = Ku(15),
|
18253
18253
|
u = `https://9cw5zmww-3000.use2.devtunnels.ms/notifications/${l}`
|
18254
|
-
return
|
18255
|
-
|
18256
|
-
|
18257
|
-
|
18258
|
-
|
18259
|
-
|
18260
|
-
|
18261
|
-
|
18262
|
-
|
18263
|
-
|
18264
|
-
|
18265
|
-
|
18266
|
-
|
18267
|
-
headers: {
|
18268
|
-
"Content-Type": "application/json",
|
18269
|
-
Authorization: `Token ${t}`,
|
18254
|
+
return (
|
18255
|
+
console.log("WEBHOOK URL to send to Rigo", u),
|
18256
|
+
{
|
18257
|
+
res: (
|
18258
|
+
await Pe.post(
|
18259
|
+
`${Ds}/v1/prompting${r ? "/public" : ""}/completion/${
|
18260
|
+
L1 ? "39" : "390"
|
18261
|
+
}/`,
|
18262
|
+
{
|
18263
|
+
inputs: e,
|
18264
|
+
include_purpose_objective: !0,
|
18265
|
+
purpose_slug: n,
|
18266
|
+
webhook_url: u,
|
18270
18267
|
},
|
18271
|
-
|
18272
|
-
|
18273
|
-
|
18274
|
-
|
18275
|
-
|
18268
|
+
{
|
18269
|
+
headers: {
|
18270
|
+
"Content-Type": "application/json",
|
18271
|
+
Authorization: `Token ${t}`,
|
18272
|
+
},
|
18273
|
+
}
|
18274
|
+
)
|
18275
|
+
).data,
|
18276
|
+
notificationId: l,
|
18277
|
+
}
|
18278
|
+
)
|
18276
18279
|
} catch (l) {
|
18277
18280
|
const u = l
|
18278
18281
|
return (
|
@@ -21192,7 +21195,7 @@ function K7() {
|
|
21192
21195
|
y.rigoToken &&
|
21193
21196
|
l({ ...y, rigoToken: "", bcToken: "", userId: "", user: null })
|
21194
21197
|
let $ = T.filter((ee) => ee.lang === r.language)
|
21195
|
-
$.length === 0 && ($ = T.filter((ee) => ee.lang === "
|
21198
|
+
$.length === 0 && ($ = T.filter((ee) => ee.lang === "en"))
|
21196
21199
|
const Q = await p2(
|
21197
21200
|
{
|
21198
21201
|
courseInfo: `${JSON.stringify(
|
@@ -10,7 +10,7 @@
|
|
10
10
|
/>
|
11
11
|
|
12
12
|
<title>Learnpack Creator: Craft tutorials in seconds!</title>
|
13
|
-
<script type="module" crossorigin src="/creator/assets/index-
|
13
|
+
<script type="module" crossorigin src="/creator/assets/index-CFM_Ypyi.js"></script>
|
14
14
|
<link rel="stylesheet" crossorigin href="/creator/assets/index-DmpsXknz.css">
|
15
15
|
</head>
|
16
16
|
<body>
|
@@ -89,7 +89,7 @@ const exercise = (path, position, configObject) => {
|
|
89
89
|
exercises[position].done :
|
90
90
|
false,
|
91
91
|
getReadme: function (lang = null) {
|
92
|
-
if (lang === "us")
|
92
|
+
if (lang === "en" || lang === "us")
|
93
93
|
lang = null; // <-- english is default, no need to append it to the file name
|
94
94
|
if (!fs.existsSync(`${this.path}/README${lang ? "." + lang : ""}.md`)) {
|
95
95
|
console_1.default.error(`Language ${lang} not found for exercise ${slug}, switching to default language`);
|
package/lib/utils/api.js
CHANGED
@@ -420,8 +420,9 @@ const getCategories = async (token) => {
|
|
420
420
|
const updateRigoAssetID = async (token, slug, asset_id) => {
|
421
421
|
const url = `${exports.RIGOBOT_HOST}/v1/learnpack/package/${slug}/`;
|
422
422
|
const headers = {
|
423
|
-
Authorization:
|
423
|
+
Authorization: "Token " + token.trim(),
|
424
424
|
};
|
425
|
+
console.log("HEADERS", headers);
|
425
426
|
try {
|
426
427
|
const response = await axios_1.default.put(url, { asset_id }, { headers });
|
427
428
|
return response.data;
|
@@ -434,7 +435,7 @@ const updateRigoAssetID = async (token, slug, asset_id) => {
|
|
434
435
|
const createRigoPackage = async (token, slug, config) => {
|
435
436
|
const url = `${exports.RIGOBOT_HOST}/v1/learnpack/package`;
|
436
437
|
const headers = {
|
437
|
-
Authorization:
|
438
|
+
Authorization: "Token " + token.trim(),
|
438
439
|
};
|
439
440
|
try {
|
440
441
|
const response = await axios_1.default.post(url, { slug, config }, { headers });
|
@@ -448,7 +449,7 @@ const createRigoPackage = async (token, slug, config) => {
|
|
448
449
|
let technologiesCache = [];
|
449
450
|
const fetchTechnologies = async () => {
|
450
451
|
const BREATHECODE_PERMANENT_TOKEN = process.env.BREATHECODE_PERMANENT_TOKEN;
|
451
|
-
const LANGS = ["en", "es"
|
452
|
+
const LANGS = ["en", "es"];
|
452
453
|
if (!BREATHECODE_PERMANENT_TOKEN) {
|
453
454
|
throw new Error("BREATHECODE_PERMANENT_TOKEN is not defined in environment variables");
|
454
455
|
}
|
@@ -34,7 +34,7 @@ async function buildConfig(bucket, courseSlug) {
|
|
34
34
|
const fname = parts.pop();
|
35
35
|
const m = fname.match(/^readme(?:\.([a-z]{2}))?\.md$/i);
|
36
36
|
if (m) {
|
37
|
-
const lang = m[1] || "
|
37
|
+
const lang = m[1] || "en";
|
38
38
|
map[slug].translations[lang] = fname;
|
39
39
|
}
|
40
40
|
else {
|
@@ -96,4 +96,5 @@ export declare function countSentences(text: string): number;
|
|
96
96
|
export declare function howManyDifficultParagraphs(paragraphs: TFKGLResult[], maxFKGL: number): number;
|
97
97
|
export declare const appendContentIndex: () => Promise<string | null>;
|
98
98
|
export declare const appendAIRules: () => Promise<string | null>;
|
99
|
+
export declare const getReadmeExtension: (language: string) => string;
|
99
100
|
export {};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.appendAIRules = exports.appendContentIndex = exports.saveTranslatedReadme = exports.makePackageInfo = exports.getExInfo = exports.slugify = exports.estimateReadingTime = void 0;
|
3
|
+
exports.getReadmeExtension = exports.appendAIRules = exports.appendContentIndex = exports.saveTranslatedReadme = exports.makePackageInfo = exports.getExInfo = exports.slugify = exports.estimateReadingTime = void 0;
|
4
4
|
exports.checkReadability = checkReadability;
|
5
5
|
exports.extractImagesFromMarkdown = extractImagesFromMarkdown;
|
6
6
|
exports.getFilenameFromUrl = getFilenameFromUrl;
|
@@ -405,3 +405,7 @@ const appendAIRules = async () => {
|
|
405
405
|
return null;
|
406
406
|
};
|
407
407
|
exports.appendAIRules = appendAIRules;
|
408
|
+
const getReadmeExtension = (language) => {
|
409
|
+
return language === "en" || language === "us" ? ".md" : `.${language}.md`;
|
410
|
+
};
|
411
|
+
exports.getReadmeExtension = getReadmeExtension;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@learnpack/learnpack",
|
3
3
|
"description": "Seamlessly build, sell and/or take interactive & auto-graded tutorials, start learning now or build a new tutorial to your audience.",
|
4
|
-
"version": "5.0.
|
4
|
+
"version": "5.0.254",
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
6
6
|
"contributors": [
|
7
7
|
{
|
package/src/commands/audit.ts
CHANGED
@@ -178,8 +178,7 @@ class AuditCommand extends SessionCommand {
|
|
178
178
|
exercise: undefined,
|
179
179
|
msg: "The repository property is not in the configuration object",
|
180
180
|
})
|
181
|
-
} else
|
182
|
-
Audit.isUrl(config!.config?.repository, errors, counter)
|
181
|
+
} else Audit.isUrl(config!.config?.repository, errors, counter)
|
183
182
|
|
184
183
|
// These two lines check if the 'description' property is inside the configuration object.
|
185
184
|
Console.debug(
|
@@ -196,8 +195,7 @@ Audit.isUrl(config!.config?.repository, errors, counter)
|
|
196
195
|
msg: "The projectType property is mandatory in the configuration object",
|
197
196
|
})
|
198
197
|
|
199
|
-
if (errors.length === 0)
|
200
|
-
Console.log("The config file is ok")
|
198
|
+
if (errors.length === 0) Console.log("The config file is ok")
|
201
199
|
|
202
200
|
// Validates if images and links are working at every README file.
|
203
201
|
const exercises = config!.exercises
|
@@ -314,13 +312,11 @@ Console.log("The config file is ok")
|
|
314
312
|
const files: string[] = []
|
315
313
|
let count = 0
|
316
314
|
for (const item of readmeFiles) {
|
317
|
-
if (count < item.count)
|
318
|
-
count = item.count
|
315
|
+
if (count < item.count) count = item.count
|
319
316
|
}
|
320
317
|
|
321
318
|
for (const item of readmeFiles) {
|
322
|
-
if (item.count !== count)
|
323
|
-
files.push(` ${item.exercise}`)
|
319
|
+
if (item.count !== count) files.push(` ${item.exercise}`)
|
324
320
|
}
|
325
321
|
|
326
322
|
if (files.length > 0) {
|
@@ -390,12 +386,10 @@ files.push(` ${item.exercise}`)
|
|
390
386
|
|
391
387
|
for (const readmeFile of readmeFiles) {
|
392
388
|
// Checking the language of each README file.
|
393
|
-
if (readmeFile === "README.md")
|
394
|
-
translations.push("us")
|
389
|
+
if (readmeFile === "README.md") translations.push("en")
|
395
390
|
else {
|
396
391
|
const regexGroups = translationRegex.exec(readmeFile)
|
397
|
-
if (regexGroups)
|
398
|
-
translations.push(regexGroups[1])
|
392
|
+
if (regexGroups) translations.push(regexGroups[1])
|
399
393
|
}
|
400
394
|
|
401
395
|
const readme = fs.readFileSync(path.resolve(readmeFile)).toString()
|
@@ -450,12 +444,9 @@ translations.push(regexGroups[1])
|
|
450
444
|
const date = new Date()
|
451
445
|
learnjson.validationAt = date.getTime()
|
452
446
|
|
453
|
-
if (errors.length > 0)
|
454
|
-
learnjson.validationStatus = "
|
455
|
-
else
|
456
|
-
learnjson.validationStatus = "warning"
|
457
|
-
else
|
458
|
-
learnjson.validationStatus = "success"
|
447
|
+
if (errors.length > 0) learnjson.validationStatus = "error"
|
448
|
+
else if (warnings.length > 0) learnjson.validationStatus = "warning"
|
449
|
+
else learnjson.validationStatus = "success"
|
459
450
|
|
460
451
|
// Writes the "learn.json" file with all the new properties
|
461
452
|
await fs.promises.writeFile("./learn.json", JSON.stringify(learnjson))
|
package/src/commands/publish.ts
CHANGED
@@ -32,6 +32,7 @@ export const handleAssetCreation = async (
|
|
32
32
|
all_translations: string[] = []
|
33
33
|
) => {
|
34
34
|
const categories: Record<string, number> = {
|
35
|
+
en: 9,
|
35
36
|
us: 9,
|
36
37
|
es: 10,
|
37
38
|
}
|
@@ -346,9 +347,9 @@ class BuildCommand extends SessionCommand {
|
|
346
347
|
if (fs.existsSync(indexHtmlPath)) {
|
347
348
|
let indexHtmlContent = fs.readFileSync(indexHtmlPath, "utf-8")
|
348
349
|
|
349
|
-
const description = learnJson.description.
|
350
|
+
const description = learnJson.description.en || "LearnPack is awesome!"
|
350
351
|
const title =
|
351
|
-
learnJson.title.
|
352
|
+
learnJson.title.en || "LearnPack: Interactive Learning as a Service"
|
352
353
|
|
353
354
|
const previewUrl =
|
354
355
|
learnJson.preview ||
|
@@ -441,7 +442,7 @@ class BuildCommand extends SessionCommand {
|
|
441
442
|
await handleAssetCreation(
|
442
443
|
sessionPayload,
|
443
444
|
learnJson,
|
444
|
-
"
|
445
|
+
"en",
|
445
446
|
res.data.url,
|
446
447
|
"",
|
447
448
|
[]
|