@learnpack/learnpack 5.0.156 → 5.0.158
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 +38 -1
- package/lib/creatorDist/assets/{index-Df4pwBvU.js → index-BG3HTk_l.js} +33919 -41582
- package/lib/creatorDist/index.html +1 -1
- package/lib/utils/misc.d.ts +1 -0
- package/lib/utils/misc.js +7 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/serve.ts +46 -2
- package/src/creator/src/components/syllabus/SyllabusEditor.tsx +0 -2
- package/src/creator/src/main.tsx +0 -2
- package/src/creatorDist/assets/{index-Df4pwBvU.js → index-BG3HTk_l.js} +33919 -41582
- package/src/creatorDist/index.html +1 -1
- package/src/utils/misc.ts +6 -0
@@ -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-BG3HTk_l.js"></script>
|
14
14
|
<link rel="stylesheet" crossorigin href="/creator/assets/index-C_YTggyk.css">
|
15
15
|
</head>
|
16
16
|
<body>
|
package/lib/utils/misc.d.ts
CHANGED
package/lib/utils/misc.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.prioritizeHTMLFile = void 0;
|
3
|
+
exports.createUploadMiddleware = exports.prioritizeHTMLFile = void 0;
|
4
4
|
exports.minutesToISO8601Duration = minutesToISO8601Duration;
|
5
5
|
const prioritizeHTMLFile = (entryFiles) => {
|
6
6
|
let files = [];
|
@@ -45,3 +45,9 @@ function minutesToISO8601Duration(minutes) {
|
|
45
45
|
duration += `${mins}M`;
|
46
46
|
return duration;
|
47
47
|
}
|
48
|
+
const createUploadMiddleware = () => {
|
49
|
+
// eslint-disable-next-line
|
50
|
+
const multer = require("multer");
|
51
|
+
return multer({ limits: { fileSize: 25 * 1024 * 1024 } });
|
52
|
+
};
|
53
|
+
exports.createUploadMiddleware = createUploadMiddleware;
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"5.0.
|
1
|
+
{"version":"5.0.158","commands":{"audit":{"id":"audit","description":"learnpack audit is the command in charge of creating an auditory of the repository\n...\nlearnpack audit checks for the following information in a repository:\n 1. The configuration object has slug, repository and description. (Error)\n 2. The command learnpack clean has been run. (Error)\n 3. If a markdown or test file doesn't have any content. (Error)\n 4. The links are accessing to valid servers. (Error)\n 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)\n 6. The external images are working (If they are pointing to a valid server). (Error)\n 7. The exercises directory names are valid. (Error)\n 8. If an exercise doesn't have a README file. (Error)\n 9. The exercises array (Of the config file) has content. (Error)\n 10. The exercses have the same translations. (Warning)\n 11. The .gitignore file exists. (Warning)\n 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false}},"args":[]},"breakToken":{"id":"breakToken","description":"Break the token","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"login":{"id":"login","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"logout":{"id":"logout","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"publish":{"id":"publish","description":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"serve":{"id":"serve","description":"Runs a small server to build tutorials","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"disableGrading":{"name":"disableGrading","type":"boolean","char":"D","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"editor":{"name":"editor","type":"option","char":"e","description":"[preview, extension]","options":["extension","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1"},"grading":{"name":"grading","type":"option","char":"g","description":"[isolated, incremental]","options":["isolated","incremental"]},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"test":{"id":"test","description":"Test exercises","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]},"translate":{"id":"translate","description":"List all the lessons, the user is able of select many of them to translate to the given languages","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[]}}}
|
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.158",
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
6
6
|
"contributors": [
|
7
7
|
{
|
package/src/commands/serve.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { flags } from "@oclif/command"
|
2
|
+
// import multer from "multer"
|
2
3
|
// import * as ytdl from "ytdl-core"
|
3
4
|
import { YoutubeTranscript } from "youtube-transcript"
|
4
5
|
import * as express from "express"
|
@@ -34,7 +35,7 @@ import {
|
|
34
35
|
import axios from "axios"
|
35
36
|
import * as FormData from "form-data"
|
36
37
|
import { RIGOBOT_HOST } from "../utils/api"
|
37
|
-
import { minutesToISO8601Duration } from "../utils/misc"
|
38
|
+
import { createUploadMiddleware, minutesToISO8601Duration } from "../utils/misc"
|
38
39
|
import { buildConfig, ConfigResponse } from "../utils/configBuilder"
|
39
40
|
import { checkReadability, slugify } from "../utils/creatorUtilities"
|
40
41
|
import { checkAndFixSidebarPure } from "../utils/sidebarGenerator"
|
@@ -415,7 +416,7 @@ export default class ServeCommand extends SessionCommand {
|
|
415
416
|
|
416
417
|
app.post(
|
417
418
|
"/upload-image",
|
418
|
-
express.json({ limit:
|
419
|
+
express.json({ limit: "10mb" }),
|
419
420
|
async (req, res) => {
|
420
421
|
const { image_url, destination } = req.body
|
421
422
|
if (!image_url || !destination) {
|
@@ -451,6 +452,49 @@ export default class ServeCommand extends SessionCommand {
|
|
451
452
|
}
|
452
453
|
)
|
453
454
|
|
455
|
+
const upload = createUploadMiddleware()
|
456
|
+
|
457
|
+
app.post("/upload-image-file", upload.single("file"), async (req, res) => {
|
458
|
+
console.log("UPLOADING IMAGE FILE")
|
459
|
+
|
460
|
+
const destination = (req.body as { destination?: string }).destination
|
461
|
+
|
462
|
+
// eslint-disable-next-line
|
463
|
+
// @ts-ignore
|
464
|
+
if (!req.file || !destination) {
|
465
|
+
return res
|
466
|
+
.status(400)
|
467
|
+
.json({ error: "File and destination are required" })
|
468
|
+
}
|
469
|
+
|
470
|
+
try {
|
471
|
+
// eslint-disable-next-line
|
472
|
+
// @ts-ignore
|
473
|
+
const fileData = req.file.buffer
|
474
|
+
|
475
|
+
const file = bucket.file(destination)
|
476
|
+
await file.save(fileData, {
|
477
|
+
resumable: false,
|
478
|
+
// eslint-disable-next-line
|
479
|
+
// @ts-ignore
|
480
|
+
contentType: req.file.mimetype,
|
481
|
+
})
|
482
|
+
|
483
|
+
console.log(`✅ Image uploaded to ${file.name}`)
|
484
|
+
res.json({ message: "Image uploaded successfully", path: file.name })
|
485
|
+
} catch (error) {
|
486
|
+
console.error("❌ upload-image-file error:", error)
|
487
|
+
res.status(500).json({ error: (error as Error).message })
|
488
|
+
}
|
489
|
+
})
|
490
|
+
|
491
|
+
app.get("/check-preview-image/:slug", async (req, res) => {
|
492
|
+
const { slug } = req.params
|
493
|
+
const file = bucket.file(`courses/${slug}/preview.png`)
|
494
|
+
const [exists] = await file.exists()
|
495
|
+
res.json({ exists, file: file.name })
|
496
|
+
})
|
497
|
+
|
454
498
|
app.get("/create", (req, res) => {
|
455
499
|
console.log("GET /create")
|
456
500
|
res.redirect("/creator/")
|
@@ -20,7 +20,6 @@ import { ContentIndex } from "./ContentIndex"
|
|
20
20
|
import { Sidebar } from "./Sidebar"
|
21
21
|
import Login from "../Login"
|
22
22
|
import { useNavigate } from "react-router"
|
23
|
-
import PreviewGenerator from "../PreviewGenerator"
|
24
23
|
import { ParamsChecker } from "../ParamsChecker"
|
25
24
|
import { slugify } from "../../utils/creatorUtils"
|
26
25
|
import { RIGO_FLOAT_GIT } from "../../utils/constants"
|
@@ -177,7 +176,6 @@ const SyllabusEditor: React.FC = () => {
|
|
177
176
|
text="Learnpack is setting up your tutorial.
|
178
177
|
It may take a moment..."
|
179
178
|
/>
|
180
|
-
<PreviewGenerator />
|
181
179
|
</>
|
182
180
|
) : (
|
183
181
|
<div className="flex w-full bg-white rounded-md shadow-md overflow-hidden h-screen ">
|
package/src/creator/src/main.tsx
CHANGED
@@ -5,7 +5,6 @@ import "./index.css"
|
|
5
5
|
import App from "./App.tsx"
|
6
6
|
import SyllabusEditor from "./components/syllabus/SyllabusEditor.tsx"
|
7
7
|
import { Toaster } from "react-hot-toast"
|
8
|
-
import PreviewGenerator from "./components/PreviewGenerator.tsx"
|
9
8
|
createRoot(document.getElementById("root")!).render(
|
10
9
|
<StrictMode>
|
11
10
|
<Toaster />
|
@@ -13,7 +12,6 @@ createRoot(document.getElementById("root")!).render(
|
|
13
12
|
<Routes>
|
14
13
|
<Route path="/creator" element={<App />} />
|
15
14
|
<Route path="/creator/syllabus" element={<SyllabusEditor />} />
|
16
|
-
<Route path="/creator/image" element={<PreviewGenerator />} />
|
17
15
|
</Routes>
|
18
16
|
</BrowserRouter>
|
19
17
|
</StrictMode>
|