@learnpack/learnpack 5.0.162 → 5.0.166

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-BG3HTk_l.js"></script>
13
+ <script type="module" crossorigin src="/creator/assets/index-4XkqESUr.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="/creator/assets/index-C_YTggyk.css">
15
15
  </head>
16
16
  <body>
@@ -50,5 +50,6 @@ declare const _default: {
50
50
  updateAsset: (token: string, assetSlug: string, asset: Partial<TAssetMissing>) => Promise<any>;
51
51
  getCategories: (token: string) => Promise<any>;
52
52
  updateRigoAssetID: (token: string, slug: string, asset_id: number) => Promise<any>;
53
+ createRigoPackage: (token: string, slug: string, config: any) => Promise<any>;
53
54
  };
54
55
  export default _default;
package/lib/utils/api.js CHANGED
@@ -427,6 +427,20 @@ const updateRigoAssetID = async (token, slug, asset_id) => {
427
427
  throw error;
428
428
  }
429
429
  };
430
+ const createRigoPackage = async (token, slug, config) => {
431
+ const url = `${exports.RIGOBOT_HOST}/v1/learnpack/package`;
432
+ const headers = {
433
+ Authorization: `Token ${token}`,
434
+ };
435
+ try {
436
+ const response = await axios_1.default.post(url, { slug, config }, { headers });
437
+ return response.data;
438
+ }
439
+ catch (error) {
440
+ console.error("Failed to create Rigo package:", error);
441
+ throw error;
442
+ }
443
+ };
430
444
  exports.default = {
431
445
  login,
432
446
  publish,
@@ -443,4 +457,5 @@ exports.default = {
443
457
  updateAsset,
444
458
  getCategories,
445
459
  updateRigoAssetID,
460
+ createRigoPackage,
446
461
  };
@@ -1 +1 @@
1
- {"version":"5.0.162","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.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":[]}}}
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.162",
4
+ "version": "5.0.166",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -35,7 +35,7 @@ import {
35
35
  // import { handleAssetCreation } from "./publish"
36
36
  import axios from "axios"
37
37
  import * as FormData from "form-data"
38
- import { RIGOBOT_HOST } from "../utils/api"
38
+ import api, { RIGOBOT_HOST } from "../utils/api"
39
39
  import { createUploadMiddleware, minutesToISO8601Duration } from "../utils/misc"
40
40
  import { buildConfig, ConfigResponse } from "../utils/configBuilder"
41
41
  import { checkReadability, slugify } from "../utils/creatorUtilities"
@@ -262,14 +262,8 @@ interface Lesson {
262
262
  }
263
263
 
264
264
  interface ParsedLink {
265
- url: string
266
- title?: string
267
- text?: string
268
- transcript?: string
269
- description?: string
270
- author?: string
271
- duration?: number
272
- thumbnail?: string
265
+ name: string
266
+ text: string
273
267
  }
274
268
  type FormState = {
275
269
  description: string
@@ -288,6 +282,7 @@ type FormState = {
288
282
  type Syllabus = {
289
283
  lessons: Lesson[]
290
284
  courseInfo: FormState
285
+ sources: ParsedLink[]
291
286
  }
292
287
 
293
288
  const fixPreviewUrl = (slug: string, previewUrl: string) => {
@@ -916,9 +911,18 @@ export default class ServeCommand extends SessionCommand {
916
911
  return res.status(400).json({ error: "Missing tokens" })
917
912
  }
918
913
 
919
- const tutorialDir = "courses/" + slugify(syllabus.courseInfo.title)
914
+ const slug = slugify(syllabus.courseInfo.title)
920
915
 
916
+ const tutorialDir = `courses/${slug}`
921
917
  const learnJson = createLearnJson(syllabus.courseInfo)
918
+
919
+ try {
920
+ await api.createRigoPackage(rigoToken, slug, learnJson)
921
+ } catch (error) {
922
+ console.error("Failed to create Rigo package:", error)
923
+ return res.status(400).json({ error: "Failed to create Rigo package" })
924
+ }
925
+
922
926
  await uploadFileToBucket(
923
927
  bucket,
924
928
  JSON.stringify(learnJson),
@@ -931,7 +935,10 @@ export default class ServeCommand extends SessionCommand {
931
935
  bucket,
932
936
  rigoToken,
933
937
  syllabus.lessons,
934
- JSON.stringify(syllabus.courseInfo),
938
+ `{
939
+ "courseInfo": ${JSON.stringify(syllabus.courseInfo)},
940
+ "sources": ${JSON.stringify(syllabus.sources)}
941
+ }`,
935
942
  lesson,
936
943
  tutorialDir + "/exercises",
937
944
  slugify(syllabus.courseInfo.title)
@@ -122,6 +122,7 @@ ${
122
122
  title: res.parsed.title,
123
123
  description: res.parsed.description,
124
124
  },
125
+ sources: uploadedFiles,
125
126
  })
126
127
  navigate("/creator/syllabus")
127
128
  setFormState({
@@ -132,6 +133,12 @@ ${
132
133
  contentIndex: "",
133
134
  isCompleted: false,
134
135
  currentStep: "description",
136
+ variables: [
137
+ "description",
138
+ "duration",
139
+ "hasContentIndex",
140
+ "verifyHuman",
141
+ ],
135
142
  })
136
143
  } catch (error) {
137
144
  console.error(error)
@@ -360,9 +360,9 @@ export const SVGS = {
360
360
  <g
361
361
  id="Icons"
362
362
  stroke="none"
363
- stroke-width="1"
363
+ strokeWidth="1"
364
364
  fill="none"
365
- fill-rule="evenodd"
365
+ fillRule="evenodd"
366
366
  >
367
367
  <g id="Color-" transform="translate(-401.000000, -860.000000)">
368
368
  <g id="Google" transform="translate(401.000000, 860.000000)">
@@ -86,31 +86,40 @@ export const GenerateButton = ({
86
86
  const setAuth = useStore((state) => state.setAuth)
87
87
  const prev = history[history.length - 2]
88
88
  return (
89
- <div className="flex flex-col space-y-2 sm:flex-row sm:space-y-0 sm:space-x-4 justify-end mt-6">
90
- {prev && prev.lessons.length > 0 && (
89
+ <div>
90
+ <div className="flex flex-col space-y-2 sm:flex-row sm:space-y-0 sm:space-x-4 justify-end mt-6">
91
+ {prev && prev.lessons.length > 0 && (
92
+ <button
93
+ onClick={() => {
94
+ undo()
95
+ toast.success("Changes reverted!")
96
+ }}
97
+ className="w-full sm:w-auto text-gray-500 bg-gray-200 rounded px-4 py-2 hover:bg-gray-300 flex items-center justify-center gap-2 cursor-pointer"
98
+ >
99
+ {SVGS.undo}
100
+ Revert changes
101
+ </button>
102
+ )}
103
+
91
104
  <button
92
- onClick={() => {
93
- undo()
94
- toast.success("Changes reverted!")
95
- }}
96
- className="w-full sm:w-auto text-gray-500 bg-gray-200 rounded px-4 py-2 hover:bg-gray-300 flex items-center justify-center gap-2 cursor-pointer"
105
+ onClick={handleSubmit}
106
+ className="w-full sm:w-auto bg-blue-600 text-white rounded px-4 py-2 hover:bg-blue-700 flex items-center justify-center gap-2 cursor-pointer"
97
107
  >
98
- {SVGS.undo}
99
- Revert changes
108
+ <span>I'm ready. Create the course for me!</span>
109
+ {SVGS.rigoSoftBlue}
100
110
  </button>
101
- )}
102
- {auth.user && (
103
- <div
104
- // onClick={handleSubmit}
105
- className="text-sm text-gray-500 bg-gray-200 rounded px-4 py-2 flex items-center justify-center flex-col"
106
- >
107
- <span>
108
- Creating the course as <strong>{auth.user.first_name}</strong>
109
- </span>
110
- <span>
111
- or{" "}
111
+ </div>
112
+ <div className="mt-2 justify-end flex">
113
+ {auth.user && (
114
+ <div
115
+ // onClick={handleSubmit}
116
+ className="text-sm text-gray-500 rounded px-4 py-2 flex items-center justify-center gap-1 "
117
+ >
118
+ <span>
119
+ Creating the course as <strong>{auth.user.first_name}</strong> or
120
+ </span>
112
121
  <button
113
- className="text-sm text-gray-500 bg-gray-200 rounded hover:bg-gray-300 items-center justify-center cursor-pointer "
122
+ className="text-sm rounded items-center justify-center cursor-pointer text-blue-600"
114
123
  onClick={() => {
115
124
  setAuth({
116
125
  rigoToken: "",
@@ -121,18 +130,11 @@ export const GenerateButton = ({
121
130
  openLogin()
122
131
  }}
123
132
  >
124
- <strong>login as someone else</strong>
133
+ login as someone else
125
134
  </button>
126
- </span>
127
- </div>
128
- )}
129
- <button
130
- onClick={handleSubmit}
131
- className="w-full sm:w-auto bg-blue-600 text-white rounded px-4 py-2 hover:bg-blue-700 flex items-center justify-center gap-2 cursor-pointer"
132
- >
133
- <span>I'm ready. Create the course for me!</span>
134
- {SVGS.rigoSoftBlue}
135
- </button>
135
+ </div>
136
+ )}
137
+ </div>
136
138
  </div>
137
139
  )
138
140
  }
@@ -9,6 +9,8 @@ import {
9
9
  checkParams,
10
10
  loginWithToken,
11
11
  createCourse,
12
+ isSlugAvailable,
13
+ reWriteTitle,
12
14
  } from "../../utils/lib"
13
15
 
14
16
  import Loader from "../Loader"
@@ -76,8 +78,27 @@ const SyllabusEditor: React.FC = () => {
76
78
  }
77
79
  }
78
80
  })()
81
+ checkSlug()
79
82
  }, [])
80
83
 
84
+ const checkSlug = async () => {
85
+ const slug = slugify(syllabus.courseInfo.title || "")
86
+ const isAvailable = await isSlugAvailable(slug)
87
+ if (!isAvailable) {
88
+ const newTitle = await reWriteTitle(
89
+ syllabus.courseInfo.title || "",
90
+ auth.rigoToken
91
+ )
92
+ push({
93
+ ...syllabus,
94
+ courseInfo: {
95
+ ...syllabus.courseInfo,
96
+ title: newTitle,
97
+ },
98
+ })
99
+ }
100
+ }
101
+
81
102
  const sendPrompt = async (prompt: string) => {
82
103
  setIsThinking(true)
83
104
 
@@ -153,6 +174,9 @@ const SyllabusEditor: React.FC = () => {
153
174
  toast.error("You don't have enough credits to generate a course!")
154
175
  return
155
176
  }
177
+ syllabus.sources = uploadedFiles
178
+ console.log(syllabus)
179
+
156
180
  setIsGenerating(true)
157
181
  createCourse(syllabus, tokenToUse, auth.bcToken)
158
182
 
@@ -318,3 +318,49 @@ export const createCourse = async (
318
318
  )
319
319
  return response.data
320
320
  }
321
+
322
+ interface SlugAvailabilityResponse {
323
+ slug: string
324
+ available: boolean
325
+ }
326
+
327
+ export const isSlugAvailable = async (slug: string): Promise<boolean> => {
328
+ try {
329
+ const url = `${RIGOBOT_HOST}/v1/learnpack/check-slug-availability?slug=${encodeURIComponent(
330
+ slug
331
+ )}`
332
+ const response = await axios.get<SlugAvailabilityResponse>(url)
333
+ return response.data.available
334
+ } catch (error) {
335
+ console.error("Error checking slug availability:", error)
336
+ throw error
337
+ }
338
+ }
339
+
340
+ export const reWriteTitle = async (title: string, token: string) => {
341
+ // We hav in the parsed the newTitle
342
+ try {
343
+ const response = await axios.post(
344
+ `${RIGOBOT_HOST}/v1/prompting/completion/1050/`,
345
+ {
346
+ inputs: {
347
+ current_title: title,
348
+ },
349
+ include_purpose_objective: false,
350
+ execute_async: false,
351
+ },
352
+ {
353
+ headers: {
354
+ "Content-Type": "application/json",
355
+ Authorization: "Token " + token,
356
+ },
357
+ }
358
+ )
359
+ console.log("RESPONSE", response.data)
360
+ return response.data.parsed.newTitle
361
+ } catch (error) {
362
+ console.error("Error rewriting title:", error)
363
+ // Return the title as it is with a random number of 4 characters
364
+ return `${title} ${Math.random().toString(36).substring(2, 6)}`
365
+ }
366
+ }
@@ -27,6 +27,7 @@ type Auth = {
27
27
  export type Syllabus = {
28
28
  lessons: Lesson[]
29
29
  courseInfo: FormState
30
+ sources: ParsedFile[]
30
31
  }
31
32
 
32
33
  type Consumables = {