@learnpack/learnpack 5.0.132 → 5.0.136
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.d.ts +1 -1
- package/lib/commands/serve.js +57 -11
- package/lib/creatorDist/assets/{index-wpTTgviz.js → index-nI-XBrtB.js} +19737 -21971
- package/lib/creatorDist/index.html +1 -1
- package/lib/utils/creatorSocket.d.ts +4 -0
- package/lib/utils/creatorSocket.js +56 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/serve.ts +64 -26
- package/src/creator/package.json +2 -1
- package/src/creator/src/components/LessonItem.tsx +14 -11
- package/src/creator/src/components/PreviewGenerator.tsx +4 -4
- package/src/creator/src/components/syllabus/SyllabusEditor.tsx +1 -1
- package/src/creator/src/utils/lib.ts +21 -0
- package/src/creatorDist/assets/{index-wpTTgviz.js → index-nI-XBrtB.js} +19737 -21971
- package/src/creatorDist/index.html +1 -1
- package/src/ui/_app/app.css +1 -1
- package/src/ui/_app/app.js +388 -389
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/creatorSocket.ts +63 -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.136 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.136/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.136/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.136/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.136/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.136/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.136/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.136/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.136/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.136/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.136/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.136/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.136/src\commands\translate.ts)_
|
402
402
|
<!-- commandsstop -->
|
403
403
|
|
404
404
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
package/lib/commands/serve.d.ts
CHANGED
@@ -17,7 +17,7 @@ export declare const createLearnJson: (courseInfo: FormState) => {
|
|
17
17
|
preview: string;
|
18
18
|
};
|
19
19
|
export declare const processImage: (bucket: Bucket, tutorialDir: string, url: string, description: string, rigoToken: string) => Promise<boolean>;
|
20
|
-
export declare function processExercise(bucket: Bucket, rigoToken: string, steps: Lesson[], packageContext: string, exercise: Lesson, exercisesDir: string): Promise<string>;
|
20
|
+
export declare function processExercise(bucket: Bucket, rigoToken: string, steps: Lesson[], packageContext: string, exercise: Lesson, exercisesDir: string, courseSlug: string): Promise<string>;
|
21
21
|
interface Lesson {
|
22
22
|
id: string;
|
23
23
|
uid: string;
|
package/lib/commands/serve.js
CHANGED
@@ -8,6 +8,8 @@ const youtube_transcript_1 = require("youtube-transcript");
|
|
8
8
|
const express = require("express");
|
9
9
|
const cors = require("cors");
|
10
10
|
const path = require("path");
|
11
|
+
const http = require("http");
|
12
|
+
const creatorSocket_1 = require("../utils/creatorSocket");
|
11
13
|
const os = require("os");
|
12
14
|
const archiver = require("archiver");
|
13
15
|
const mkdirp = require("mkdirp");
|
@@ -89,18 +91,17 @@ const processImage = async (bucket, tutorialDir, url, description, rigoToken) =>
|
|
89
91
|
}
|
90
92
|
};
|
91
93
|
exports.processImage = processImage;
|
92
|
-
async function processExercise(bucket, rigoToken, steps, packageContext, exercise, exercisesDir) {
|
94
|
+
async function processExercise(bucket, rigoToken, steps, packageContext, exercise, exercisesDir, courseSlug) {
|
93
95
|
// const tid = toast.loading("Generating lesson...")
|
94
96
|
const exSlug = (0, creatorUtilities_2.slugify)(exercise.id + "-" + exercise.title);
|
95
97
|
const readmeFilename = "README.md";
|
96
98
|
const targetDir = `${exercisesDir}/${exSlug}`;
|
97
99
|
console.log("✍🏻 Generating lesson", exercise.id, exercise.title);
|
98
|
-
const isGeneratingText = `
|
99
|
-
|
100
|
+
const isGeneratingText = `
|
100
101
|
\`\`\`loader slug="${exSlug}"
|
101
|
-
|
102
|
+
:rigo
|
102
103
|
\`\`\`
|
103
|
-
|
104
|
+
`;
|
104
105
|
await uploadFileToBucket(bucket, isGeneratingText, `${targetDir}/${readmeFilename}`);
|
105
106
|
const readme = await (0, rigoActions_1.readmeCreator)(rigoToken, {
|
106
107
|
title: `${exercise.id} - ${exercise.title}`,
|
@@ -115,7 +116,11 @@ async function processExercise(bucket, rigoToken, steps, packageContext, exercis
|
|
115
116
|
let readability = (0, creatorUtilities_2.checkReadability)(readme.parsed.content, 200, duration || 1);
|
116
117
|
while (readability.fkglResult.fkgl > PARAMS.max_fkgl &&
|
117
118
|
attempts < PARAMS.max_rewrite_attempts) {
|
118
|
-
|
119
|
+
(0, creatorSocket_1.emitToCourse)(courseSlug, "course-creation", {
|
120
|
+
lesson: exSlug,
|
121
|
+
status: "generating",
|
122
|
+
log: `🔄 The lesson ${exercise.id} - ${exercise.title} has a readability score of ${readability.fkglResult.fkgl}`,
|
123
|
+
});
|
119
124
|
// eslint-disable-next-line
|
120
125
|
const reducedReadme = await (0, rigoActions_1.makeReadmeReadable)(rigoToken, {
|
121
126
|
lesson: readability.body,
|
@@ -129,8 +134,12 @@ async function processExercise(bucket, rigoToken, steps, packageContext, exercis
|
|
129
134
|
readability = (0, creatorUtilities_2.checkReadability)(reducedReadme.parsed.content, PARAMS.max_words, duration || 1);
|
130
135
|
attempts++;
|
131
136
|
}
|
132
|
-
console.log(`✅ After ${attempts} attempts, the lesson ${exercise.title} has a readability score of ${readability.fkglResult.fkgl} using FKGL. And it has ${readability.minutes.toFixed(2)} minutes of reading time.`);
|
133
137
|
await uploadFileToBucket(bucket, readability.newMarkdown, `${targetDir}/${readmeFilename}`);
|
138
|
+
(0, creatorSocket_1.emitToCourse)(courseSlug, "course-creation", {
|
139
|
+
lesson: exSlug,
|
140
|
+
status: "done",
|
141
|
+
log: `✅ The lesson ${exercise.id} - ${exercise.title} has been generated successfully!`,
|
142
|
+
});
|
134
143
|
if (exercise.type.toLowerCase() === "code") {
|
135
144
|
console.log("🔍 Creating code file for", exercise.title);
|
136
145
|
const codeFile = await (0, rigoActions_1.createCodeFile)(rigoToken, {
|
@@ -138,6 +147,11 @@ async function processExercise(bucket, rigoToken, steps, packageContext, exercis
|
|
138
147
|
tutorial_info: packageContext,
|
139
148
|
});
|
140
149
|
await uploadFileToBucket(bucket, codeFile.parsed.content, `${targetDir}/index.${codeFile.parsed.extension.replace(".", "")}`);
|
150
|
+
(0, creatorSocket_1.emitToCourse)(courseSlug, "course-creation", {
|
151
|
+
lesson: exSlug,
|
152
|
+
status: "done",
|
153
|
+
log: `✅ The code file for ${exercise.title} has been generated successfully!`,
|
154
|
+
});
|
141
155
|
}
|
142
156
|
return readability.newMarkdown;
|
143
157
|
}
|
@@ -178,6 +192,8 @@ class ServeCommand extends SessionCommand_1.default {
|
|
178
192
|
// return files
|
179
193
|
// }
|
180
194
|
const app = express();
|
195
|
+
const server = http.createServer(app);
|
196
|
+
(0, creatorSocket_1.initSocketIO)(server);
|
181
197
|
const PORT = process.env.PORT || 3000;
|
182
198
|
const distPath = path.resolve(__dirname, "../creatorDist");
|
183
199
|
// Servir archivos estáticos
|
@@ -266,7 +282,7 @@ class ServeCommand extends SessionCommand_1.default {
|
|
266
282
|
}
|
267
283
|
});
|
268
284
|
app.get("/preview/:slug", async (req, res) => {
|
269
|
-
console.log("GET COURSE /");
|
285
|
+
console.log("GET COURSE PREVIEW /");
|
270
286
|
const file = path.resolve(__dirname, "../ui/_app/index.html");
|
271
287
|
res.sendFile(file);
|
272
288
|
});
|
@@ -276,6 +292,7 @@ class ServeCommand extends SessionCommand_1.default {
|
|
276
292
|
return res.status(400).json({ error: "Course slug required" });
|
277
293
|
}
|
278
294
|
try {
|
295
|
+
console.log("GET CONFIG, COURSE SLUG", courseSlug);
|
279
296
|
const { config, exercises } = await (0, configBuilder_1.buildConfig)(bucket, courseSlug);
|
280
297
|
res.set("X-Creator-Web", "true");
|
281
298
|
res.set("Access-Control-Expose-Headers", "X-Creator-Web");
|
@@ -423,6 +440,34 @@ class ServeCommand extends SessionCommand_1.default {
|
|
423
440
|
}
|
424
441
|
res.send({ message: "Files deleted" });
|
425
442
|
});
|
443
|
+
app.get("/test/:slug", (req, res) => {
|
444
|
+
(0, creatorSocket_1.emitToCourse)(req.params.slug, "course-creation", {
|
445
|
+
lesson: "000-welcome-to-bird-domestication",
|
446
|
+
status: "generating",
|
447
|
+
log: "Hello",
|
448
|
+
});
|
449
|
+
(0, creatorSocket_1.emitToCourse)(req.params.slug, "course-creation", {
|
450
|
+
lesson: "000-welcome-to-bird-domestication",
|
451
|
+
status: "generating",
|
452
|
+
log: "Hello",
|
453
|
+
});
|
454
|
+
(0, creatorSocket_1.emitToCourse)(req.params.slug, "course-creation", {
|
455
|
+
lesson: "000-welcome-to-bird-domestication",
|
456
|
+
status: "generating",
|
457
|
+
log: "Hello broder",
|
458
|
+
});
|
459
|
+
(0, creatorSocket_1.emitToCourse)(req.params.slug, "course-creation", {
|
460
|
+
lesson: "000-welcome-to-bird-domestication",
|
461
|
+
status: "done",
|
462
|
+
log: "Hello broder",
|
463
|
+
});
|
464
|
+
(0, creatorSocket_1.emitToCourse)(req.params.slug, "course-creation", {
|
465
|
+
lesson: "other",
|
466
|
+
status: "generating",
|
467
|
+
log: "Hello",
|
468
|
+
});
|
469
|
+
res.send({ message: "Course creation started" });
|
470
|
+
});
|
426
471
|
app.get("/assets/:file", (req, res) => {
|
427
472
|
const file = path.join(localAppPath, req.params.file);
|
428
473
|
res.sendFile(file);
|
@@ -452,8 +497,9 @@ class ServeCommand extends SessionCommand_1.default {
|
|
452
497
|
}
|
453
498
|
const tutorialDir = "courses/" + (0, creatorUtilities_2.slugify)(syllabus.courseInfo.title);
|
454
499
|
const learnJson = (0, exports.createLearnJson)(syllabus.courseInfo);
|
455
|
-
await uploadFileToBucket(bucket, JSON.stringify(learnJson),
|
456
|
-
|
500
|
+
await uploadFileToBucket(bucket, JSON.stringify(learnJson), `${tutorialDir}/learn.json`);
|
501
|
+
console.log("🔄 Learn.json uploaded to bucket to", tutorialDir);
|
502
|
+
const lessonsPromises = syllabus.lessons.map(lesson => processExercise(bucket, rigoToken, syllabus.lessons, JSON.stringify(syllabus.courseInfo), lesson, tutorialDir + "/exercises", (0, creatorUtilities_2.slugify)(syllabus.courseInfo.title)));
|
457
503
|
const readmeContents = await Promise.all(lessonsPromises);
|
458
504
|
let imagesArray = [];
|
459
505
|
for (const content of readmeContents) {
|
@@ -655,7 +701,7 @@ class ServeCommand extends SessionCommand_1.default {
|
|
655
701
|
res.status(500).json({ error: "Failed to fetch the resource" });
|
656
702
|
}
|
657
703
|
});
|
658
|
-
|
704
|
+
server.listen(PORT, () => {
|
659
705
|
console.log(`🚀 Creator UI server running at http://localhost:${PORT}/creator`);
|
660
706
|
});
|
661
707
|
}
|