@learnpack/learnpack 5.0.166 → 5.0.172

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.
@@ -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-4XkqESUr.js"></script>
13
+ <script type="module" crossorigin src="/creator/assets/index-CCvMFC6N.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="/creator/assets/index-C_YTggyk.css">
15
15
  </head>
16
16
  <body>
@@ -1,9 +1,14 @@
1
1
  import { Bucket } from "@google-cloud/storage";
2
+ type TFile = {
3
+ name: string;
4
+ slug: string;
5
+ hidden: boolean;
6
+ };
2
7
  export type Exercise = {
3
8
  title: string;
4
9
  slug: string;
5
10
  graded: boolean;
6
- files: string[];
11
+ files: TFile[];
7
12
  translations: Record<string, string>;
8
13
  position: number;
9
14
  };
@@ -19,3 +24,4 @@ export type ConfigResponse = {
19
24
  * @returns Promise con objeto { config, exercises } listo para usar.
20
25
  */
21
26
  export declare function buildConfig(bucket: Bucket, courseSlug: string): Promise<ConfigResponse>;
27
+ export {};
@@ -38,7 +38,11 @@ async function buildConfig(bucket, courseSlug) {
38
38
  map[slug].translations[lang] = fname;
39
39
  }
40
40
  else {
41
- map[slug].files.push(fname);
41
+ map[slug].files.push({
42
+ name: fname,
43
+ slug: fname,
44
+ hidden: false,
45
+ });
42
46
  }
43
47
  }
44
48
  const exercises = Object.values(map).map((ex, i) => (Object.assign(Object.assign({}, ex), { position: i })));
@@ -1 +1 @@
1
- {"version":"5.0.166","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":[]}}}
1
+ {"version":"5.0.172","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.166",
4
+ "version": "5.0.172",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -986,6 +986,49 @@ export default class ServeCommand extends SessionCommand {
986
986
  })
987
987
  })
988
988
 
989
+ app.get(
990
+ "/courses/:courseSlug/exercises/:exerciseSlug/",
991
+ async (req, res) => {
992
+ console.log("GET /courses/:courseSlug/exercises/:exerciseSlug/")
993
+
994
+ const { courseSlug, exerciseSlug } = req.params
995
+
996
+ try {
997
+ const prefix = `courses/${courseSlug}/exercises/${exerciseSlug}/`
998
+ const [files] = await bucket.getFiles({ prefix })
999
+
1000
+ if (files.length === 0) {
1001
+ return res.status(404).json({ error: "Exercise not found" })
1002
+ }
1003
+
1004
+ const fileList = files.map(file => ({
1005
+ name: path.basename(file.name),
1006
+ path: file.name,
1007
+ }))
1008
+
1009
+ const entryFile = fileList.find(
1010
+ f => /^index\.\w+$/.test(f.name) || /^app\.\w+$/.test(f.name)
1011
+ )?.name
1012
+
1013
+ const langMatch = entryFile?.match(/\.(js|ts|py|java|cpp|html|rb)/)
1014
+ const language = langMatch ? langMatch[1] : null
1015
+
1016
+ const isTesteable = Boolean(entryFile)
1017
+
1018
+ return res.json({
1019
+ slug: exerciseSlug,
1020
+ graded: isTesteable,
1021
+ entry: entryFile || null,
1022
+ language,
1023
+ files: fileList,
1024
+ })
1025
+ } catch (error) {
1026
+ console.error("❌ Error fetching exercise info:", error)
1027
+ return res.status(500).json({ error: (error as Error).message })
1028
+ }
1029
+ }
1030
+ )
1031
+
989
1032
  app.post("/actions/publish/:slug", async (req, res) => {
990
1033
  try {
991
1034
  const { slug } = req.params
@@ -1121,6 +1164,36 @@ export default class ServeCommand extends SessionCommand {
1121
1164
  }
1122
1165
  })
1123
1166
 
1167
+ app.get(
1168
+ "/courses/:courseSlug/exercises/:exerciseSlug/file/:filename",
1169
+ async (req, res) => {
1170
+ console.log(
1171
+ "GET /courses/:courseSlug/exercises/:exerciseSlug/file/:filename",
1172
+ req.params
1173
+ )
1174
+ const { courseSlug, exerciseSlug, filename } = req.params
1175
+
1176
+ try {
1177
+ const filePath = `courses/${courseSlug}/exercises/${exerciseSlug}/${filename}`
1178
+ const file = bucket.file(filePath)
1179
+ const [exists] = await file.exists()
1180
+
1181
+ if (!exists) {
1182
+ return res.status(404).json({ error: "File not found" })
1183
+ }
1184
+
1185
+ const [content] = await file.download()
1186
+ res.set("Content-Type", "text/plain")
1187
+ return res.send(content.toString("utf-8"))
1188
+ } catch (error) {
1189
+ console.error("❌ Error fetching file:", error)
1190
+ return res
1191
+ .status(500)
1192
+ .json({ error: (error as Error).message || "Unable to fetch file" })
1193
+ }
1194
+ }
1195
+ )
1196
+
1124
1197
  const YT_REGEX = /(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]{11})/
1125
1198
 
1126
1199
  app.get("/actions/fetch/:link", async (req, res) => {
@@ -4,7 +4,7 @@ import useStore from "../../utils/store"
4
4
  import { interactiveCreation } from "../../utils/rigo"
5
5
  import {
6
6
  parseLesson,
7
- useConsumableCall,
7
+ // useConsumableCall,
8
8
  validateTokens,
9
9
  checkParams,
10
10
  loginWithToken,
@@ -166,14 +166,14 @@ const SyllabusEditor: React.FC = () => {
166
166
  setShowLoginModal(true)
167
167
  return
168
168
  }
169
- const success = await useConsumableCall(
170
- auth.bcToken,
171
- "ai-course-generation"
172
- )
173
- if (!success) {
174
- toast.error("You don't have enough credits to generate a course!")
175
- return
176
- }
169
+ // const success = await useConsumableCall(
170
+ // auth.bcToken,
171
+ // "ai-course-generation"
172
+ // )
173
+ // if (!success) {
174
+ // toast.error("You don't have enough credits to generate a course!")
175
+ // return
176
+ // }
177
177
  syllabus.sources = uploadedFiles
178
178
  console.log(syllabus)
179
179