@learnpack/learnpack 5.0.164 → 5.0.168

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 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.164 win32-x64 node-v22.15.0
24
+ @learnpack/learnpack/5.0.168 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.164/src\commands\audit.ts)_
83
+ _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/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.164/src\commands\breakToken.ts)_
98
+ _See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/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.164/src\commands\clean.ts)_
113
+ _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/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.164/src\commands\download.ts)_
131
+ _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/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.164/src\commands\init.ts)_
163
+ _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/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.164/src\commands\login.ts)_
181
+ _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/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.164/src\commands\logout.ts)_
199
+ _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/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.164/src\commands\publish.ts)_
331
+ _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/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.164/src\commands\serve.ts)_
348
+ _See code: [src\commands\serve.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/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.164/src\commands\start.ts)_
370
+ _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/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.164/src\commands\test.ts)_
387
+ _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/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.164/src\commands\translate.ts)_
401
+ _See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.168/src\commands\translate.ts)_
402
402
  <!-- commandsstop -->
403
403
 
404
404
  > > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
@@ -27,14 +27,8 @@ interface Lesson {
27
27
  duration?: number;
28
28
  }
29
29
  interface ParsedLink {
30
- url: string;
31
- title?: string;
32
- text?: string;
33
- transcript?: string;
34
- description?: string;
35
- author?: string;
36
- duration?: number;
37
- thumbnail?: string;
30
+ name: string;
31
+ text: string;
38
32
  }
39
33
  type FormState = {
40
34
  description: string;
@@ -643,7 +643,10 @@ class ServeCommand extends SessionCommand_1.default {
643
643
  }
644
644
  await uploadFileToBucket(bucket, JSON.stringify(learnJson), `${tutorialDir}/learn.json`);
645
645
  console.log("🔄 Learn.json uploaded to bucket to", tutorialDir);
646
- 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)));
646
+ const lessonsPromises = syllabus.lessons.map(lesson => processExercise(bucket, rigoToken, syllabus.lessons, `{
647
+ "courseInfo": ${JSON.stringify(syllabus.courseInfo)},
648
+ "sources": ${JSON.stringify(syllabus.sources)}
649
+ }`, lesson, tutorialDir + "/exercises", (0, creatorUtilities_2.slugify)(syllabus.courseInfo.title)));
647
650
  const readmeContents = await Promise.all(lessonsPromises);
648
651
  let imagesArray = [];
649
652
  for (const content of readmeContents) {
@@ -662,6 +665,37 @@ class ServeCommand extends SessionCommand_1.default {
662
665
  slug: (0, creatorUtilities_2.slugify)(syllabus.courseInfo.title),
663
666
  });
664
667
  });
668
+ app.get("/courses/:courseSlug/exercises/:exerciseSlug/", async (req, res) => {
669
+ var _a;
670
+ console.log("GET /courses/:courseSlug/exercises/:exerciseSlug/");
671
+ const { courseSlug, exerciseSlug } = req.params;
672
+ try {
673
+ const prefix = `courses/${courseSlug}/exercises/${exerciseSlug}/`;
674
+ const [files] = await bucket.getFiles({ prefix });
675
+ if (files.length === 0) {
676
+ return res.status(404).json({ error: "Exercise not found" });
677
+ }
678
+ const fileList = files.map(file => ({
679
+ name: path.basename(file.name),
680
+ path: file.name,
681
+ }));
682
+ const entryFile = (_a = fileList.find(f => /^index\.\w+$/.test(f.name) || /^app\.\w+$/.test(f.name))) === null || _a === void 0 ? void 0 : _a.name;
683
+ const langMatch = entryFile === null || entryFile === void 0 ? void 0 : entryFile.match(/\.(js|ts|py|java|cpp|html|rb)/);
684
+ const language = langMatch ? langMatch[1] : null;
685
+ const isTesteable = Boolean(entryFile);
686
+ return res.json({
687
+ slug: exerciseSlug,
688
+ graded: isTesteable,
689
+ entry: entryFile || null,
690
+ language,
691
+ files: fileList,
692
+ });
693
+ }
694
+ catch (error) {
695
+ console.error("❌ Error fetching exercise info:", error);
696
+ return res.status(500).json({ error: error.message });
697
+ }
698
+ });
665
699
  app.post("/actions/publish/:slug", async (req, res) => {
666
700
  try {
667
701
  const { slug } = req.params;
@@ -755,6 +789,27 @@ class ServeCommand extends SessionCommand_1.default {
755
789
  return res.status(500).json({ error: error.message });
756
790
  }
757
791
  });
792
+ app.get("/courses/:courseSlug/exercises/:exerciseSlug/file/:filename", async (req, res) => {
793
+ console.log("GET /courses/:courseSlug/exercises/:exerciseSlug/file/:filename", req.params);
794
+ const { courseSlug, exerciseSlug, filename } = req.params;
795
+ try {
796
+ const filePath = `courses/${courseSlug}/exercises/${exerciseSlug}/${filename}`;
797
+ const file = bucket.file(filePath);
798
+ const [exists] = await file.exists();
799
+ if (!exists) {
800
+ return res.status(404).json({ error: "File not found" });
801
+ }
802
+ const [content] = await file.download();
803
+ res.set("Content-Type", "text/plain");
804
+ return res.send(content.toString("utf-8"));
805
+ }
806
+ catch (error) {
807
+ console.error("❌ Error fetching file:", error);
808
+ return res
809
+ .status(500)
810
+ .json({ error: error.message || "Unable to fetch file" });
811
+ }
812
+ });
758
813
  const YT_REGEX = /(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]{11})/;
759
814
  app.get("/actions/fetch/:link", async (req, res) => {
760
815
  const { link } = req.params;