@learnpack/learnpack 5.0.297 → 5.0.300

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.
Files changed (79) hide show
  1. package/README.md +409 -409
  2. package/lib/commands/audit.js +15 -15
  3. package/lib/commands/breakToken.js +19 -19
  4. package/lib/commands/clean.js +3 -3
  5. package/lib/commands/logout.js +3 -3
  6. package/lib/commands/serve.js +32 -11
  7. package/lib/creatorDist/assets/{index-D25zkBaN.js → index-DoYRptnk.js} +11875 -11992
  8. package/lib/creatorDist/index.html +1 -1
  9. package/lib/managers/config/index.js +77 -77
  10. package/lib/utils/creatorUtilities.js +14 -14
  11. package/lib/utils/templates/isolated/exercises/01-hello-world/README.es.md +26 -26
  12. package/lib/utils/templates/isolated/exercises/01-hello-world/README.md +26 -26
  13. package/lib/utils/templates/scorm/adlcp_rootv1p2.xsd +110 -110
  14. package/lib/utils/templates/scorm/config/index.html +209 -209
  15. package/lib/utils/templates/scorm/ims_xml.xsd +1 -1
  16. package/lib/utils/templates/scorm/imscp_rootv1p1p2.xsd +345 -345
  17. package/lib/utils/templates/scorm/imsmanifest.xml +38 -38
  18. package/lib/utils/templates/scorm/imsmd_rootv1p2p1.xsd +573 -573
  19. package/package.json +1 -1
  20. package/src/commands/audit.ts +487 -487
  21. package/src/commands/breakToken.ts +67 -67
  22. package/src/commands/clean.ts +30 -30
  23. package/src/commands/logout.ts +38 -38
  24. package/src/commands/serve.ts +49 -26
  25. package/src/commands/start.ts +333 -333
  26. package/src/commands/translate.ts +123 -123
  27. package/src/creator/README.md +54 -54
  28. package/src/creator/package-lock.json +6621 -6621
  29. package/src/creator/package.json +55 -55
  30. package/src/creator/src/App.tsx +569 -569
  31. package/src/creator/src/components/FileUploader.tsx +302 -302
  32. package/src/creator/src/components/Icon.tsx +18 -18
  33. package/src/creator/src/components/LessonItem.tsx +152 -152
  34. package/src/creator/src/components/Login.tsx +259 -259
  35. package/src/creator/src/components/syllabus/ContentIndex.tsx +323 -323
  36. package/src/creator/src/components/syllabus/SyllabusEditor.tsx +337 -337
  37. package/src/creator/src/i18n.ts +28 -28
  38. package/src/creator/src/locales/en.json +127 -127
  39. package/src/creator/src/locales/es.json +127 -127
  40. package/src/creator/src/utils/configTypes.ts +122 -122
  41. package/src/creator/src/utils/constants.ts +13 -13
  42. package/src/creator/src/utils/creatorUtils.ts +46 -46
  43. package/src/creator/src/utils/eventBus.ts +2 -2
  44. package/src/creator/src/utils/socket.ts +61 -61
  45. package/src/creator/src/utils/store.ts +222 -222
  46. package/src/creator/src/vite-env.d.ts +1 -1
  47. package/src/creator/vite.config.ts +13 -13
  48. package/src/creatorDist/assets/{index-D25zkBaN.js → index-DoYRptnk.js} +11875 -11992
  49. package/src/creatorDist/index.html +1 -1
  50. package/src/managers/config/defaults.ts +49 -49
  51. package/src/managers/config/exercise.ts +364 -364
  52. package/src/managers/config/index.ts +775 -775
  53. package/src/managers/file.ts +236 -236
  54. package/src/managers/server/routes.ts +554 -554
  55. package/src/managers/telemetry.ts +188 -188
  56. package/src/models/action.ts +13 -13
  57. package/src/models/config-manager.ts +28 -28
  58. package/src/models/config.ts +106 -106
  59. package/src/models/exercise-obj.ts +30 -30
  60. package/src/models/session.ts +39 -39
  61. package/src/models/socket.ts +61 -61
  62. package/src/models/status.ts +16 -16
  63. package/src/utils/BaseCommand.ts +56 -56
  64. package/src/utils/audit.ts +392 -392
  65. package/src/utils/checkNotInstalled.ts +267 -267
  66. package/src/utils/convertCreds.js +34 -34
  67. package/src/utils/creatorUtilities.ts +504 -504
  68. package/src/utils/export/README.md +178 -178
  69. package/src/utils/incrementVersion.js +74 -74
  70. package/src/utils/misc.ts +58 -58
  71. package/src/utils/sidebarGenerator.ts +195 -195
  72. package/src/utils/templates/isolated/exercises/01-hello-world/README.es.md +26 -26
  73. package/src/utils/templates/isolated/exercises/01-hello-world/README.md +26 -26
  74. package/src/utils/templates/scorm/adlcp_rootv1p2.xsd +110 -110
  75. package/src/utils/templates/scorm/config/index.html +209 -209
  76. package/src/utils/templates/scorm/ims_xml.xsd +1 -1
  77. package/src/utils/templates/scorm/imscp_rootv1p1p2.xsd +345 -345
  78. package/src/utils/templates/scorm/imsmanifest.xml +38 -38
  79. package/src/utils/templates/scorm/imsmd_rootv1p2p1.xsd +573 -573
@@ -369,21 +369,21 @@ class AuditCommand extends SessionCommand_1.default {
369
369
  }
370
370
  }
371
371
  }
372
- AuditCommand.description = `learnpack audit is the command in charge of creating an auditory of the repository
373
- ...
374
- learnpack audit checks for the following information in a repository:
375
- 1. The configuration object has slug, repository and description. (Error)
376
- 2. The command learnpack clean has been run. (Error)
377
- 3. If a markdown or test file doesn't have any content. (Error)
378
- 4. The links are accessing to valid servers. (Error)
379
- 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)
380
- 6. The external images are working (If they are pointing to a valid server). (Error)
381
- 7. The exercises directory names are valid. (Error)
382
- 8. If an exercise doesn't have a README file. (Error)
383
- 9. The exercises array (Of the config file) has content. (Error)
384
- 10. The exercses have the same translations. (Warning)
385
- 11. The .gitignore file exists. (Warning)
386
- 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
372
+ AuditCommand.description = `learnpack audit is the command in charge of creating an auditory of the repository
373
+ ...
374
+ learnpack audit checks for the following information in a repository:
375
+ 1. The configuration object has slug, repository and description. (Error)
376
+ 2. The command learnpack clean has been run. (Error)
377
+ 3. If a markdown or test file doesn't have any content. (Error)
378
+ 4. The links are accessing to valid servers. (Error)
379
+ 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)
380
+ 6. The external images are working (If they are pointing to a valid server). (Error)
381
+ 7. The exercises directory names are valid. (Error)
382
+ 8. If an exercise doesn't have a README file. (Error)
383
+ 9. The exercises array (Of the config file) has content. (Error)
384
+ 10. The exercses have the same translations. (Warning)
385
+ 11. The .gitignore file exists. (Warning)
386
+ 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
387
387
  `;
388
388
  AuditCommand.flags = {
389
389
  strict: command_1.flags.boolean({
@@ -4,25 +4,25 @@ const command_1 = require("@oclif/command");
4
4
  const BaseCommand_1 = require("../utils/BaseCommand");
5
5
  const console_1 = require("../utils/console");
6
6
  const creatorUtilities_1 = require("../utils/creatorUtilities");
7
- const exampleMd = `# How to Install Node.js
8
-
9
- Node.js lets you run JavaScript outside a web browser.
10
-
11
- ## Step 1: Download Node.js
12
-
13
- Get the Node.js installer from the [official site](https://nodejs.org/en/download/).
14
-
15
- ## Step 2: Install Node.js
16
-
17
- Open the installer and follow the steps to finish.
18
-
19
- ## Step 3: Verify the Installation
20
-
21
- Open a terminal and type:
22
-
23
- \`\`\`bash
24
- node -v
25
- \`\`\`
7
+ const exampleMd = `# How to Install Node.js
8
+
9
+ Node.js lets you run JavaScript outside a web browser.
10
+
11
+ ## Step 1: Download Node.js
12
+
13
+ Get the Node.js installer from the [official site](https://nodejs.org/en/download/).
14
+
15
+ ## Step 2: Install Node.js
16
+
17
+ Open the installer and follow the steps to finish.
18
+
19
+ ## Step 3: Verify the Installation
20
+
21
+ Open a terminal and type:
22
+
23
+ \`\`\`bash
24
+ node -v
25
+ \`\`\`
26
26
  `;
27
27
  class BreakTokenCommand extends BaseCommand_1.default {
28
28
  async run() {
@@ -16,9 +16,9 @@ class CleanCommand extends SessionCommand_1.default {
16
16
  console_1.default.success("Package cleaned successfully, ready to publish");
17
17
  }
18
18
  }
19
- CleanCommand.description = `Clean the configuration object
20
- ...
21
- Extra documentation goes here
19
+ CleanCommand.description = `Clean the configuration object
20
+ ...
21
+ Extra documentation goes here
22
22
  `;
23
23
  CleanCommand.flags = {
24
24
  // name: flags.string({char: 'n', description: 'name to print'}),
@@ -14,9 +14,9 @@ class LogoutCommand extends SessionCommand_1.default {
14
14
  session_1.default.destroy();
15
15
  }
16
16
  }
17
- LogoutCommand.description = `Describe the command here
18
- ...
19
- Extra documentation goes here
17
+ LogoutCommand.description = `Describe the command here
18
+ ...
19
+ Extra documentation goes here
20
20
  `;
21
21
  LogoutCommand.flags = {
22
22
  // name: flags.string({char: 'n', description: 'name to print'}),
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processImage = exports.createLearnJson = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ require("newrelic");
5
6
  const command_1 = require("@oclif/command");
6
7
  const buffer_1 = require("buffer");
7
8
  const express = require("express");
@@ -642,15 +643,15 @@ class ServeCommand extends SessionCommand_1.default {
642
643
  console.log("📁 Files received:", files);
643
644
  if (files && Array.isArray(files)) {
644
645
  console.log("✅ Processing files for coding challenge...");
645
- // Get the current exercise info to determine the exercise directory
646
- const syllabus = await getSyllabus(courseSlug, bucket);
647
- const exercise = syllabus.lessons[parseInt(exercisePosition)];
646
+ const configFile = await bucket.file(`courses/${courseSlug}/.learn/config.json`);
647
+ const [configContent] = await configFile.download();
648
+ const { exercises } = JSON.parse(configContent.toString());
649
+ const exercise = exercises[parseInt(exercisePosition)];
648
650
  if (!exercise) {
649
651
  console.error(`❌ Exercise not found at position ${exercisePosition}`);
650
652
  return res.status(404).json({ error: "Exercise not found" });
651
653
  }
652
- const exSlug = (0, creatorUtilities_2.slugify)(exercise.id + "-" + exercise.title);
653
- const exerciseDir = `courses/${courseSlug}/exercises/${exSlug}`;
654
+ const exerciseDir = `courses/${courseSlug}/exercises/${exercise.slug}`;
654
655
  for (const fileStr of files) {
655
656
  try {
656
657
  const fileObj = JSON.parse(fileStr);
@@ -1794,6 +1795,30 @@ class ServeCommand extends SessionCommand_1.default {
1794
1795
  });
1795
1796
  }
1796
1797
  });
1798
+ app.delete("/courses/:courseSlug/exercises/:exerciseSlug/file/:filename", async (req, res) => {
1799
+ console.log("DELETE /courses/:courseSlug/exercises/:exerciseSlug/file/:filename", req.params);
1800
+ const { courseSlug, exerciseSlug, filename } = req.params;
1801
+ try {
1802
+ const filePath = `courses/${courseSlug}/exercises/${exerciseSlug}/${filename}`;
1803
+ const file = bucket.file(filePath);
1804
+ const [exists] = await file.exists();
1805
+ if (!exists) {
1806
+ return res.status(404).json({ error: "File not found" });
1807
+ }
1808
+ await file.delete();
1809
+ console.log(`✅ Deleted file: ${filePath}`);
1810
+ return res.json({
1811
+ success: true,
1812
+ message: "File deleted successfully",
1813
+ });
1814
+ }
1815
+ catch (error) {
1816
+ console.error("❌ Error deleting file:", error);
1817
+ return res.status(500).json({
1818
+ error: error.message || "Unable to delete file",
1819
+ });
1820
+ }
1821
+ });
1797
1822
  const YT_REGEX = /(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]{11})/;
1798
1823
  app.get("/actions/fetch/:link", async (req, res) => {
1799
1824
  const { link } = req.params;
@@ -1829,9 +1854,7 @@ class ServeCommand extends SessionCommand_1.default {
1829
1854
  }
1830
1855
  catch (error) {
1831
1856
  console.error("❌ /actions/fetch error:", error.message || error);
1832
- res
1833
- .status(500)
1834
- .json({ error: error.message || "Failed to fetch link" });
1857
+ res.status(500).json({ error: error.message || "Failed to fetch link" });
1835
1858
  }
1836
1859
  });
1837
1860
  app.delete("/packages/:slug", async (req, res) => {
@@ -2015,9 +2038,7 @@ class ServeCommand extends SessionCommand_1.default {
2015
2038
  }
2016
2039
  catch (error) {
2017
2040
  console.error("Export error:", error);
2018
- res
2019
- .status(500)
2020
- .json({ error: "Export failed", details: error.message });
2041
+ res.status(500).json({ error: "Export failed", details: error.message });
2021
2042
  }
2022
2043
  });
2023
2044
  server.listen(PORT, () => {