@learnpack/learnpack 5.0.94 → 5.0.98

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-EA507Y8n.js"></script>
13
+ <script type="module" crossorigin src="/creator/assets/index-DayC-cyC.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="/creator/assets/index-ldEC0yWM.css">
15
15
  </head>
16
16
  <body>
@@ -1 +1 @@
1
- {"version":"5.0.94","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.98","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.94",
4
+ "version": "5.0.98",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -10,7 +10,7 @@ import SessionCommand from "../utils/SessionCommand"
10
10
  import { Storage } from "@google-cloud/storage"
11
11
  import { downloadEditor, decompress } from "../managers/file"
12
12
  import * as fs from "fs"
13
- import { translateExercise } from "../utils/rigoActions"
13
+ import { translateExercise, isValidRigoToken } from "../utils/rigoActions"
14
14
  import * as dotenv from "dotenv"
15
15
  // import { handleAssetCreation } from "./publish"
16
16
  import axios from "axios"
@@ -202,59 +202,6 @@ export default class ServeCommand extends SessionCommand {
202
202
  }
203
203
  })
204
204
 
205
- // app.get("/config", async (req, res) => {
206
- // const courseSlug = req.query.slug
207
- // const files = await listFilesWithPrefix(`courses/${courseSlug}`)
208
-
209
- // const learnJson = files.find((file) => file.name.endsWith("learn.json"))
210
- // const learnJsonContent = await learnJson?.download()
211
- // const learnJsonParsed = JSON.parse(learnJsonContent?.toString() || "{}")
212
-
213
- // const exerciseMap: ExerciseMap = {}
214
-
215
- // // Agrupar archivos por ejercicio
216
- // for (const file of files) {
217
- // const pathParts = file.name.split("/")
218
- // const isExercise = pathParts.includes("exercises")
219
- // if (!isExercise) continue
220
-
221
- // const slug = pathParts[pathParts.indexOf("exercises") + 1]
222
- // if (!exerciseMap[slug]) {
223
- // exerciseMap[slug] = {
224
- // title: slug,
225
- // slug: slug,
226
- // graded: false,
227
- // files: [],
228
- // translations: {},
229
- // }
230
- // }
231
-
232
- // const fileName = pathParts.at(-1)
233
-
234
- // // Traducciones
235
- // const readmeMatch = fileName?.match(/^readme(?:\.([a-z]{2}))?\.md$/i)
236
- // if (readmeMatch) {
237
- // const lang = readmeMatch[1] || "us"
238
- // exerciseMap[slug].translations[lang] = fileName || ""
239
- // } else {
240
- // exerciseMap[slug].files.push(fileName || "")
241
- // }
242
- // }
243
-
244
- // const exercises = Object.values(exerciseMap).map((ex, index) => ({
245
- // ...ex,
246
- // position: index,
247
- // }))
248
-
249
- // res.set("X-Creator-Web", "true")
250
- // res.set("Access-Control-Expose-Headers", "X-Creator-Web")
251
-
252
- // res.send({
253
- // config: { ...learnJsonParsed, title: { us: courseSlug } },
254
- // exercises,
255
- // })
256
- // })
257
-
258
205
  app.get("/exercise/:slug/readme", async (req, res) => {
259
206
  console.log("GET /exercise/:slug/readme")
260
207
 
@@ -594,6 +541,45 @@ export default class ServeCommand extends SessionCommand {
594
541
  return res.status(500).json({ error: (error as Error).message })
595
542
  }
596
543
  })
544
+
545
+ app.delete("/packages/:slug", async (req, res) => {
546
+ console.log("DELETE /packages/:slug")
547
+
548
+ const { slug } = req.params
549
+ const rigoToken = req.header("x-rigo-token")
550
+
551
+ if (!rigoToken) {
552
+ return res.status(400).json({ error: "x-rigo-token is required" })
553
+ }
554
+
555
+ const isValid = await isValidRigoToken(rigoToken)
556
+
557
+ if (!isValid) {
558
+ return res.status(400).json({ error: "Invalid RigoToken" })
559
+ }
560
+
561
+ const filePrefix = `courses/${slug}/`
562
+
563
+ try {
564
+ const [files] = await bucket.getFiles({ prefix: filePrefix })
565
+
566
+ if (files.length === 0) {
567
+ return res
568
+ .status(404)
569
+ .json({ error: "No package found with the given slug" })
570
+ }
571
+
572
+ await Promise.all(files.map(file => file.delete()))
573
+
574
+ console.log(`✅ Successfully deleted package from GCP: ${slug}`)
575
+
576
+ return res.json({ message: `Package ${slug} deleted successfully` })
577
+ } catch (error) {
578
+ console.error("❌ Error deleting package:", error)
579
+ return res.status(500).json({ error: "Failed to delete the package" })
580
+ }
581
+ })
582
+
597
583
  app.listen(PORT, () => {
598
584
  console.log(
599
585
  `🚀 Creator UI server running at http://localhost:${PORT}/creator`
@@ -46,16 +46,17 @@ const SyllabusEditor: React.FC = () => {
46
46
  const [showLoginModal, setShowLoginModal] = useState(false)
47
47
  const [isThinking, setIsThinking] = useState(false)
48
48
 
49
- const { history, auth, setAuth, push, uploadedFiles, cleanHistory } = useStore(
50
- useShallow((state) => ({
51
- history: state.history,
52
- auth: state.auth,
53
- setAuth: state.setAuth,
54
- push: state.push,
55
- uploadedFiles: state.uploadedFiles,
56
- cleanHistory: state.cleanHistory,
57
- }))
58
- )
49
+ const { history, auth, setAuth, push, uploadedFiles, cleanHistory } =
50
+ useStore(
51
+ useShallow((state) => ({
52
+ history: state.history,
53
+ auth: state.auth,
54
+ setAuth: state.setAuth,
55
+ push: state.push,
56
+ uploadedFiles: state.uploadedFiles,
57
+ cleanHistory: state.cleanHistory,
58
+ }))
59
+ )
59
60
 
60
61
  const syllabus = history[history.length - 1]
61
62
 
@@ -189,7 +190,9 @@ const SyllabusEditor: React.FC = () => {
189
190
  JSON.stringify(learnJson),
190
191
  "courses/" + slugify(syllabus.courseInfo.title) + "/learn.json"
191
192
  )
192
-
193
+
194
+ cleanHistory()
195
+
193
196
  window.location.href = `/preview/${slugify(
194
197
  syllabus.courseInfo.title
195
198
  )}?token=${auth.bcToken}`