@learnpack/learnpack 5.0.252 → 5.0.256
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 +26 -3
- package/lib/creatorDist/assets/{index-CFM_Ypyi.js → index-DZq54NPa.js} +5 -1
- package/lib/creatorDist/index.html +1 -1
- package/lib/utils/api.js +1 -0
- package/package.json +1 -1
- package/src/commands/serve.ts +36 -4
- package/src/creator/src/utils/rigo.ts +1 -3
- package/src/creatorDist/assets/{index-CFM_Ypyi.js → index-DZq54NPa.js} +5 -1
- package/src/creatorDist/index.html +1 -1
- package/src/ui/_app/app.js +379 -379
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/api.ts +1 -0
package/lib/commands/serve.js
CHANGED
@@ -75,7 +75,6 @@ const PARAMS = {
|
|
75
75
|
};
|
76
76
|
const processImage = async (url, description, rigoToken, courseSlug) => {
|
77
77
|
try {
|
78
|
-
// TODO: MAKE THIS ASYNC
|
79
78
|
const filename = (0, creatorUtilities_1.getFilenameFromUrl)(url);
|
80
79
|
const webhookUrl = `${process.env.HOST}/webhooks/${courseSlug}/images/${filename}`;
|
81
80
|
await (0, rigoActions_1.generateImage)(rigoToken, {
|
@@ -445,6 +444,21 @@ class ServeCommand extends SessionCommand_1.default {
|
|
445
444
|
const [exists] = await file.exists();
|
446
445
|
res.json({ exists, file: file.name });
|
447
446
|
});
|
447
|
+
app.post("/webhooks/:courseSlug/:exSlug/:lang/update-readme/:notificationId", async (req, res) => {
|
448
|
+
console.log("RECEIVING README UPDATE WEBHOOK");
|
449
|
+
const { courseSlug, exSlug, lang, notificationId } = req.params;
|
450
|
+
const body = req.body;
|
451
|
+
console.log("BODY", body);
|
452
|
+
const readmePath = `courses/${courseSlug}/exercises/${exSlug}/README${(0, creatorUtilities_1.getReadmeExtension)(lang)}`;
|
453
|
+
if (body.parsed.content) {
|
454
|
+
await uploadFileToBucket(bucket, body.parsed.content, readmePath);
|
455
|
+
}
|
456
|
+
(0, creatorSocket_1.emitToNotification)(notificationId, {
|
457
|
+
status: "SUCCESS",
|
458
|
+
message: "Readme updated successfully",
|
459
|
+
});
|
460
|
+
res.json({ status: "SUCCESS" });
|
461
|
+
});
|
448
462
|
app.get("/create", (req, res) => {
|
449
463
|
console.log("GET /create");
|
450
464
|
res.redirect("/creator/");
|
@@ -516,8 +530,17 @@ class ServeCommand extends SessionCommand_1.default {
|
|
516
530
|
foundLang = match[1].toLowerCase();
|
517
531
|
}
|
518
532
|
const [contentBuffer] = await bucket.file(selectedFile).download();
|
519
|
-
|
520
|
-
|
533
|
+
try {
|
534
|
+
const { attributes, body } = frontMatter(contentBuffer.toString());
|
535
|
+
res.send({ attributes, body, lang: foundLang });
|
536
|
+
}
|
537
|
+
catch (_a) {
|
538
|
+
res.status(200).json({
|
539
|
+
attributes: {},
|
540
|
+
body: contentBuffer.toString(),
|
541
|
+
lang: foundLang,
|
542
|
+
});
|
543
|
+
}
|
521
544
|
}
|
522
545
|
catch (error) {
|
523
546
|
console.error(error);
|
@@ -18250,7 +18250,11 @@ const d2 = async (e) => {
|
|
18250
18250
|
var a
|
18251
18251
|
try {
|
18252
18252
|
const l = Ku(15),
|
18253
|
-
u =
|
18253
|
+
u = `${
|
18254
|
+
L1
|
18255
|
+
? "https://9cw5zmww-3000.use2.devtunnels.ms"
|
18256
|
+
: window.location.origin
|
18257
|
+
}/notifications/${l}`
|
18254
18258
|
return (
|
18255
18259
|
console.log("WEBHOOK URL to send to Rigo", u),
|
18256
18260
|
{
|
@@ -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-DZq54NPa.js"></script>
|
14
14
|
<link rel="stylesheet" crossorigin href="/creator/assets/index-DmpsXknz.css">
|
15
15
|
</head>
|
16
16
|
<body>
|
package/lib/utils/api.js
CHANGED
@@ -422,6 +422,7 @@ const updateRigoAssetID = async (token, slug, asset_id) => {
|
|
422
422
|
const headers = {
|
423
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;
|
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.256",
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
6
6
|
"contributors": [
|
7
7
|
{
|
package/src/commands/serve.ts
CHANGED
@@ -113,7 +113,6 @@ export const processImage = async (
|
|
113
113
|
courseSlug: string
|
114
114
|
) => {
|
115
115
|
try {
|
116
|
-
// TODO: MAKE THIS ASYNC
|
117
116
|
const filename = getFilenameFromUrl(url)
|
118
117
|
|
119
118
|
const webhookUrl = `${process.env.HOST}/webhooks/${courseSlug}/images/${filename}`
|
@@ -715,6 +714,32 @@ export default class ServeCommand extends SessionCommand {
|
|
715
714
|
res.json({ exists, file: file.name })
|
716
715
|
})
|
717
716
|
|
717
|
+
app.post(
|
718
|
+
"/webhooks/:courseSlug/:exSlug/:lang/update-readme/:notificationId",
|
719
|
+
async (req, res) => {
|
720
|
+
console.log("RECEIVING README UPDATE WEBHOOK")
|
721
|
+
const { courseSlug, exSlug, lang, notificationId } = req.params
|
722
|
+
const body = req.body
|
723
|
+
|
724
|
+
console.log("BODY", body)
|
725
|
+
|
726
|
+
const readmePath = `courses/${courseSlug}/exercises/${exSlug}/README${getReadmeExtension(
|
727
|
+
lang
|
728
|
+
)}`
|
729
|
+
|
730
|
+
if (body.parsed.content) {
|
731
|
+
await uploadFileToBucket(bucket, body.parsed.content, readmePath)
|
732
|
+
}
|
733
|
+
|
734
|
+
emitToNotification(notificationId, {
|
735
|
+
status: "SUCCESS",
|
736
|
+
message: "Readme updated successfully",
|
737
|
+
})
|
738
|
+
|
739
|
+
res.json({ status: "SUCCESS" })
|
740
|
+
}
|
741
|
+
)
|
742
|
+
|
718
743
|
app.get("/create", (req, res) => {
|
719
744
|
console.log("GET /create")
|
720
745
|
res.redirect("/creator/")
|
@@ -809,9 +834,16 @@ export default class ServeCommand extends SessionCommand {
|
|
809
834
|
}
|
810
835
|
|
811
836
|
const [contentBuffer] = await bucket.file(selectedFile).download()
|
812
|
-
|
813
|
-
|
814
|
-
|
837
|
+
try {
|
838
|
+
const { attributes, body } = frontMatter(contentBuffer.toString())
|
839
|
+
res.send({ attributes, body, lang: foundLang })
|
840
|
+
} catch {
|
841
|
+
res.status(200).json({
|
842
|
+
attributes: {},
|
843
|
+
body: contentBuffer.toString(),
|
844
|
+
lang: foundLang,
|
845
|
+
})
|
846
|
+
}
|
815
847
|
} catch (error) {
|
816
848
|
console.error(error)
|
817
849
|
res.status(500).json({ error: "Internal server error" })
|
@@ -19,9 +19,7 @@ export const publicInteractiveCreation = async (
|
|
19
19
|
const webhookUrl = `${
|
20
20
|
DEV_MODE
|
21
21
|
? "https://9cw5zmww-3000.use2.devtunnels.ms"
|
22
|
-
:
|
23
|
-
// : window.location.origin
|
24
|
-
"https://9cw5zmww-3000.use2.devtunnels.ms"
|
22
|
+
: window.location.origin
|
25
23
|
}/notifications/${randomUID}`
|
26
24
|
|
27
25
|
console.log("WEBHOOK URL to send to Rigo", webhookUrl)
|
@@ -18250,7 +18250,11 @@ const d2 = async (e) => {
|
|
18250
18250
|
var a
|
18251
18251
|
try {
|
18252
18252
|
const l = Ku(15),
|
18253
|
-
u =
|
18253
|
+
u = `${
|
18254
|
+
L1
|
18255
|
+
? "https://9cw5zmww-3000.use2.devtunnels.ms"
|
18256
|
+
: window.location.origin
|
18257
|
+
}/notifications/${l}`
|
18254
18258
|
return (
|
18255
18259
|
console.log("WEBHOOK URL to send to Rigo", u),
|
18256
18260
|
{
|
@@ -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-DZq54NPa.js"></script>
|
14
14
|
<link rel="stylesheet" crossorigin href="/creator/assets/index-DmpsXknz.css">
|
15
15
|
</head>
|
16
16
|
<body>
|