@learnpack/learnpack 5.0.156 → 5.0.160

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-Df4pwBvU.js"></script>
13
+ <script type="module" crossorigin src="/creator/assets/index-BG3HTk_l.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="/creator/assets/index-C_YTggyk.css">
15
15
  </head>
16
16
  <body>
@@ -21,8 +21,9 @@ type TAssetMissing = {
21
21
  category: number;
22
22
  owner: number;
23
23
  author: number;
24
+ preview: string;
24
25
  };
25
- export declare const createAsset: (token: string, academyId: number, asset: TAssetMissing) => Promise<any>;
26
+ export declare const createAsset: (token: string, asset: TAssetMissing) => Promise<any>;
26
27
  export declare const doesAssetExists: (token: string, assetSlug: string) => Promise<{
27
28
  exists: boolean;
28
29
  academyId?: number;
@@ -41,12 +42,13 @@ declare const _default: {
41
42
  sendStreamTelemetry: (url: string, body: object) => Promise<void>;
42
43
  listUserAcademies: (breathecodeToken: string) => Promise<TAcademy[]>;
43
44
  validateToken: (token: string) => Promise<any>;
44
- createAsset: (token: string, academyId: number, asset: TAssetMissing) => Promise<any>;
45
+ createAsset: (token: string, asset: TAssetMissing) => Promise<any>;
45
46
  doesAssetExists: (token: string, assetSlug: string) => Promise<{
46
47
  exists: boolean;
47
48
  academyId?: number;
48
49
  }>;
49
- updateAsset: (token: string, academyId: number, assetSlug: string, asset: Partial<TAssetMissing>) => Promise<any>;
50
+ updateAsset: (token: string, assetSlug: string, asset: Partial<TAssetMissing>) => Promise<any>;
50
51
  getCategories: (token: string) => Promise<any>;
52
+ updateRigoAssetID: (token: string, slug: string, asset_id: number) => Promise<any>;
51
53
  };
52
54
  export default _default;
package/lib/utils/api.js CHANGED
@@ -324,7 +324,7 @@ const validateToken = async (token) => {
324
324
  }
325
325
  };
326
326
  exports.validateToken = validateToken;
327
- const createAsset = async (token, academyId, asset) => {
327
+ const createAsset = async (token, asset) => {
328
328
  const body = {
329
329
  slug: asset.slug,
330
330
  title: asset.title,
@@ -332,7 +332,7 @@ const createAsset = async (token, academyId, asset) => {
332
332
  asset_type: "EXERCISE",
333
333
  visibility: "PUBLIC",
334
334
  status: "DRAFT",
335
- url: "https://4geeksacademy.com",
335
+ url: asset.url,
336
336
  readme_url: null,
337
337
  difficulty: null,
338
338
  duration: null,
@@ -341,7 +341,7 @@ const createAsset = async (token, academyId, asset) => {
341
341
  category: asset.category,
342
342
  owner: asset.owner,
343
343
  author: asset.author,
344
- preview: null,
344
+ preview: asset.preview,
345
345
  description: asset.description,
346
346
  external: false,
347
347
  interactive: true,
@@ -351,17 +351,16 @@ const createAsset = async (token, academyId, asset) => {
351
351
  learnpack_deploy_url: asset.learnpack_deploy_url,
352
352
  technologies: asset.technologies,
353
353
  };
354
- const url = `https://breathecode.herokuapp.com/v1/registry/academy/asset`;
354
+ const url = `https://breathecode.herokuapp.com/v1/registry/asset/me`;
355
355
  const headers = {
356
356
  Authorization: `Token ${token}`,
357
- Academy: academyId,
358
357
  };
359
358
  try {
360
359
  const response = await axios_1.default.post(url, body, { headers });
361
360
  return response.data;
362
361
  }
363
362
  catch (error) {
364
- // console.error("Failed to create asset:", error)
363
+ console.error("Failed to create asset:", error);
365
364
  throw error.response.data;
366
365
  }
367
366
  };
@@ -374,9 +373,7 @@ const doesAssetExists = async (token, assetSlug) => {
374
373
  try {
375
374
  const response = await axios_1.default.get(url, { headers });
376
375
  if (response.status === 200) {
377
- const data = response.data;
378
- const academy = data.academy.id;
379
- return { exists: true, academyId: academy };
376
+ return { exists: true };
380
377
  }
381
378
  return { exists: false };
382
379
  }
@@ -386,18 +383,17 @@ const doesAssetExists = async (token, assetSlug) => {
386
383
  }
387
384
  };
388
385
  exports.doesAssetExists = doesAssetExists;
389
- const updateAsset = async (token, academyId, assetSlug, asset) => {
390
- const url = `https://breathecode.herokuapp.com/v1/registry/academy/asset/${assetSlug}`;
386
+ const updateAsset = async (token, assetSlug, asset) => {
387
+ const url = `https://breathecode.herokuapp.com/v1/registry/asset/me/${assetSlug}`;
391
388
  const headers = {
392
389
  Authorization: `Token ${token}`,
393
- Academy: academyId,
394
390
  };
395
391
  try {
396
392
  const response = await axios_1.default.put(url, asset, { headers });
397
393
  return response.data;
398
394
  }
399
395
  catch (error) {
400
- // console.error("Failed to update asset:", error)
396
+ console.error("Failed to update asset:", error);
401
397
  // Try to print the data
402
398
  // console.log(error.response.data)
403
399
  throw error.response.data;
@@ -417,6 +413,20 @@ const getCategories = async (token) => {
417
413
  throw error;
418
414
  }
419
415
  };
416
+ const updateRigoAssetID = async (token, slug, asset_id) => {
417
+ const url = `${exports.RIGOBOT_HOST}/v1/learnpack/package/${slug}/`;
418
+ const headers = {
419
+ Authorization: `Token ${token}`,
420
+ };
421
+ try {
422
+ const response = await axios_1.default.put(url, { asset_id }, { headers });
423
+ return response.data;
424
+ }
425
+ catch (error) {
426
+ console.error("Failed to update Rigo package:", error);
427
+ throw error;
428
+ }
429
+ };
420
430
  exports.default = {
421
431
  login,
422
432
  publish,
@@ -432,4 +442,5 @@ exports.default = {
432
442
  doesAssetExists: exports.doesAssetExists,
433
443
  updateAsset,
434
444
  getCategories,
445
+ updateRigoAssetID,
435
446
  };
@@ -1,2 +1,3 @@
1
1
  export declare const prioritizeHTMLFile: (entryFiles: string[]) => string[];
2
2
  export declare function minutesToISO8601Duration(minutes: number): string;
3
+ export declare const createUploadMiddleware: () => any;
package/lib/utils/misc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prioritizeHTMLFile = void 0;
3
+ exports.createUploadMiddleware = exports.prioritizeHTMLFile = void 0;
4
4
  exports.minutesToISO8601Duration = minutesToISO8601Duration;
5
5
  const prioritizeHTMLFile = (entryFiles) => {
6
6
  let files = [];
@@ -45,3 +45,9 @@ function minutesToISO8601Duration(minutes) {
45
45
  duration += `${mins}M`;
46
46
  return duration;
47
47
  }
48
+ const createUploadMiddleware = () => {
49
+ // eslint-disable-next-line
50
+ const multer = require("multer");
51
+ return multer({ limits: { fileSize: 25 * 1024 * 1024 } });
52
+ };
53
+ exports.createUploadMiddleware = createUploadMiddleware;
@@ -71,4 +71,8 @@ type TFillSidebarJSONInputs = {
71
71
  sidebar_json: string;
72
72
  };
73
73
  export declare const fillSidebarJSON: (token: string, inputs: TFillSidebarJSONInputs) => Promise<any>;
74
+ export declare const isPackageAuthor: (token: string, packageSlug: string) => Promise<{
75
+ isAuthor: boolean;
76
+ status: number;
77
+ }>;
74
78
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fillSidebarJSON = exports.generateCourseShortName = exports.isValidRigoToken = exports.readmeCreator = exports.createCodingReadme = exports.createCodeFile = exports.interactiveCreation = exports.generateCourseIntroduction = exports.translateExercise = exports.generateImage = exports.hasCreatorPermission = exports.createReadme = void 0;
3
+ exports.isPackageAuthor = exports.fillSidebarJSON = exports.generateCourseShortName = exports.isValidRigoToken = exports.readmeCreator = exports.createCodingReadme = exports.createCodeFile = exports.interactiveCreation = exports.generateCourseIntroduction = exports.translateExercise = exports.generateImage = exports.hasCreatorPermission = exports.createReadme = void 0;
4
4
  exports.downloadImage = downloadImage;
5
5
  exports.createPreviewReadme = createPreviewReadme;
6
6
  exports.makeReadmeReadable = makeReadmeReadable;
@@ -218,3 +218,20 @@ const fillSidebarJSON = async (token, inputs) => {
218
218
  return response.data;
219
219
  };
220
220
  exports.fillSidebarJSON = fillSidebarJSON;
221
+ const isPackageAuthor = async (token, packageSlug) => {
222
+ var _a;
223
+ const url = `${api_1.RIGOBOT_HOST}/v1/learnpack/package/${packageSlug}/`;
224
+ const headers = {
225
+ Authorization: `Token ${token}`,
226
+ };
227
+ try {
228
+ const response = await axios_1.default.get(url, { headers });
229
+ return { isAuthor: response.status === 200, status: response.status };
230
+ }
231
+ catch (error) {
232
+ const status = ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) || 500;
233
+ console.error("Error fetching package:", error);
234
+ return { isAuthor: false, status };
235
+ }
236
+ };
237
+ exports.isPackageAuthor = isPackageAuthor;
@@ -1 +1 @@
1
- {"version":"5.0.156","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.160","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.156",
4
+ "version": "5.0.160",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {