@learnpack/learnpack 5.0.275 → 5.0.276

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 (71) 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/init.js +41 -41
  6. package/lib/commands/logout.js +3 -3
  7. package/lib/commands/publish.js +5 -10
  8. package/lib/commands/serve.js +3 -2
  9. package/lib/creatorDist/assets/index-BfLyIQVh.js +10343 -10224
  10. package/lib/managers/config/index.js +77 -77
  11. package/lib/utils/api.d.ts +1 -1
  12. package/lib/utils/api.js +12 -9
  13. package/lib/utils/creatorUtilities.js +14 -14
  14. package/package.json +1 -1
  15. package/src/commands/audit.ts +487 -487
  16. package/src/commands/breakToken.ts +67 -67
  17. package/src/commands/clean.ts +30 -30
  18. package/src/commands/init.ts +650 -650
  19. package/src/commands/logout.ts +38 -38
  20. package/src/commands/publish.ts +20 -25
  21. package/src/commands/serve.ts +8 -3
  22. package/src/commands/start.ts +333 -333
  23. package/src/commands/translate.ts +123 -123
  24. package/src/creator/README.md +54 -54
  25. package/src/creator/eslint.config.js +28 -28
  26. package/src/creator/src/components/syllabus/ContentIndex.tsx +312 -312
  27. package/src/creator/src/i18n.ts +28 -28
  28. package/src/creator/src/index.css +217 -217
  29. package/src/creator/src/locales/en.json +126 -126
  30. package/src/creator/src/locales/es.json +126 -126
  31. package/src/creator/src/utils/configTypes.ts +122 -122
  32. package/src/creator/src/utils/constants.ts +13 -13
  33. package/src/creator/src/utils/creatorUtils.ts +46 -46
  34. package/src/creator/src/utils/eventBus.ts +2 -2
  35. package/src/creator/src/utils/lib.ts +468 -468
  36. package/src/creator/src/utils/socket.ts +61 -61
  37. package/src/creator/src/utils/store.ts +222 -222
  38. package/src/creator/src/vite-env.d.ts +1 -1
  39. package/src/creator/vite.config.ts +13 -13
  40. package/src/creatorDist/assets/index-BfLyIQVh.js +10343 -10224
  41. package/src/managers/config/defaults.ts +49 -49
  42. package/src/managers/config/exercise.ts +364 -364
  43. package/src/managers/config/index.ts +775 -775
  44. package/src/managers/file.ts +236 -236
  45. package/src/managers/server/routes.ts +554 -554
  46. package/src/managers/session.ts +182 -182
  47. package/src/managers/telemetry.ts +188 -188
  48. package/src/models/action.ts +13 -13
  49. package/src/models/config-manager.ts +28 -28
  50. package/src/models/config.ts +106 -106
  51. package/src/models/creator.ts +47 -47
  52. package/src/models/exercise-obj.ts +30 -30
  53. package/src/models/session.ts +39 -39
  54. package/src/models/socket.ts +61 -61
  55. package/src/models/status.ts +16 -16
  56. package/src/ui/_app/app.css +1 -1
  57. package/src/ui/_app/app.js +366 -363
  58. package/src/ui/app.tar.gz +0 -0
  59. package/src/utils/BaseCommand.ts +56 -56
  60. package/src/utils/api.ts +53 -39
  61. package/src/utils/audit.ts +392 -392
  62. package/src/utils/checkNotInstalled.ts +267 -267
  63. package/src/utils/configBuilder.ts +82 -82
  64. package/src/utils/convertCreds.js +34 -34
  65. package/src/utils/creatorUtilities.ts +504 -504
  66. package/src/utils/incrementVersion.js +74 -74
  67. package/src/utils/misc.ts +58 -58
  68. package/src/utils/rigoActions.ts +500 -500
  69. package/src/utils/sidebarGenerator.ts +195 -195
  70. package/src/utils/templates/isolated/exercises/01-hello-world/README.es.md +26 -26
  71. package/src/utils/templates/isolated/exercises/01-hello-world/README.md +26 -26
@@ -474,66 +474,66 @@ function deepMerge(...sources) {
474
474
  return acc;
475
475
  }
476
476
  const buildAgentWarning = (current, suggested) => {
477
- const message = `# Agent mismatch!\n
478
-
479
- In LearnPack, the agent is in charge of running the LearnPack interface.
480
-
481
- You're currently using LearnPack through \`${current}\` but the suggested agent is \`${suggested}\`.
482
-
483
- We recommend strongly recommend changing your agent.
484
-
485
- ${stepsToChangeAgent(suggested)}
477
+ const message = `# Agent mismatch!\n
478
+
479
+ In LearnPack, the agent is in charge of running the LearnPack interface.
480
+
481
+ You're currently using LearnPack through \`${current}\` but the suggested agent is \`${suggested}\`.
482
+
483
+ We recommend strongly recommend changing your agent.
484
+
485
+ ${stepsToChangeAgent(suggested)}
486
486
  `;
487
487
  return message;
488
488
  };
489
489
  const stepsToChangeAgent = (agent) => {
490
490
  if (agent === "vscode") {
491
- return `
492
- # Steps to Change Agent to VSCode
493
-
494
- 1. **Install VSCode**:
495
- - Visit the [VSCode website](https://code.visualstudio.com/Download) and download the latest version.
496
- - Follow the installation instructions for your operating system.
497
-
498
- 2. **Install LearnPack VSCode Extension**:
499
- - Open VSCode.
500
- - Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing \`Ctrl+Shift+X\`.
501
- - Search for "LearnPack" and click "Install".
502
- - If the extension is already installed but disabled, enable it.
503
-
504
- 3. **Run LearnPack in VSCode**:
505
- - Open your terminal in VSCode.
506
- - Navigate to your LearnPack project directory.
507
- - Run the following command:
508
- \`\`\`sh
509
- learnpack start
510
- \`\`\`
511
-
512
- We strongly recommend using VSCode for a better learning experience.
491
+ return `
492
+ # Steps to Change Agent to VSCode
493
+
494
+ 1. **Install VSCode**:
495
+ - Visit the [VSCode website](https://code.visualstudio.com/Download) and download the latest version.
496
+ - Follow the installation instructions for your operating system.
497
+
498
+ 2. **Install LearnPack VSCode Extension**:
499
+ - Open VSCode.
500
+ - Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing \`Ctrl+Shift+X\`.
501
+ - Search for "LearnPack" and click "Install".
502
+ - If the extension is already installed but disabled, enable it.
503
+
504
+ 3. **Run LearnPack in VSCode**:
505
+ - Open your terminal in VSCode.
506
+ - Navigate to your LearnPack project directory.
507
+ - Run the following command:
508
+ \`\`\`sh
509
+ learnpack start
510
+ \`\`\`
511
+
512
+ We strongly recommend using VSCode for a better learning experience.
513
513
  `;
514
514
  }
515
515
  if (agent === "os") {
516
- return `
517
- # Steps to Change Agent to OS
518
-
519
- This learning package was designed to run outside of VSCode. We strongly recommend closing VSCode and running the package independently.
520
-
521
- 1. **Close VSCode**:
522
- - Save your work and close the VSCode application.
523
-
524
- 2. **Open a New Terminal**:
525
- - Open a terminal or command prompt on your operating system.
526
-
527
- 3. **Navigate to Your LearnPack Project Directory**:
528
- - Use the \`cd\` command to navigate to the directory where your LearnPack project is located.
529
-
530
- 4. **Run LearnPack**:
531
- - Run the following command to start LearnPack:
532
- \`\`\`sh
533
- learnpack start
534
- \`\`\`
535
-
536
- We strongly recommend running the package independently for a better learning experience.
516
+ return `
517
+ # Steps to Change Agent to OS
518
+
519
+ This learning package was designed to run outside of VSCode. We strongly recommend closing VSCode and running the package independently.
520
+
521
+ 1. **Close VSCode**:
522
+ - Save your work and close the VSCode application.
523
+
524
+ 2. **Open a New Terminal**:
525
+ - Open a terminal or command prompt on your operating system.
526
+
527
+ 3. **Navigate to Your LearnPack Project Directory**:
528
+ - Use the \`cd\` command to navigate to the directory where your LearnPack project is located.
529
+
530
+ 4. **Run LearnPack**:
531
+ - Run the following command to start LearnPack:
532
+ \`\`\`sh
533
+ learnpack start
534
+ \`\`\`
535
+
536
+ We strongly recommend running the package independently for a better learning experience.
537
537
  `;
538
538
  }
539
539
  return "";
@@ -559,31 +559,31 @@ const isExtensionInstalled = (extensionName) => {
559
559
  const result = shell.exec("code --list-extensions", { silent: true });
560
560
  return result.stdout.split("\n").includes(extensionName);
561
561
  };
562
- const EXTENSION_INSTALLATION_STEPS = `
563
- # Steps to Install LearnPack VSCode Extension
564
-
565
- 1. **Open VSCode**:
566
- - Launch the Visual Studio Code application on your computer.
567
-
568
- 2. **Go to Extensions View**:
569
- - Click on the Extensions icon in the Activity Bar on the side of the window.
570
- - Alternatively, you can open the Extensions view by pressing \`Ctrl+Shift+X\`.
571
-
572
- 3. **Search for LearnPack**:
573
- - In the Extensions view, type "LearnPack" into the search bar.
574
-
575
- 4. **Install the Extension**:
576
- - Find the "LearnPack" extension in the search results and click the "Install" button.
577
- - If the extension is already installed but disabled, click the "Enable" button.
578
-
579
- 5. **Verify Installation**:
580
- - Once installed, you can verify the installation by running the following command in the terminal:
581
- \`\`\`sh
582
- code --list-extensions | grep learn-pack.learnpack-vscode
583
- \`\`\`
584
- - If the extension is listed, it means the installation was successful.
585
-
586
- We strongly recommend using the LearnPack extension in VSCode for a better learning experience.
562
+ const EXTENSION_INSTALLATION_STEPS = `
563
+ # Steps to Install LearnPack VSCode Extension
564
+
565
+ 1. **Open VSCode**:
566
+ - Launch the Visual Studio Code application on your computer.
567
+
568
+ 2. **Go to Extensions View**:
569
+ - Click on the Extensions icon in the Activity Bar on the side of the window.
570
+ - Alternatively, you can open the Extensions view by pressing \`Ctrl+Shift+X\`.
571
+
572
+ 3. **Search for LearnPack**:
573
+ - In the Extensions view, type "LearnPack" into the search bar.
574
+
575
+ 4. **Install the Extension**:
576
+ - Find the "LearnPack" extension in the search results and click the "Install" button.
577
+ - If the extension is already installed but disabled, click the "Enable" button.
578
+
579
+ 5. **Verify Installation**:
580
+ - Once installed, you can verify the installation by running the following command in the terminal:
581
+ \`\`\`sh
582
+ code --list-extensions | grep learn-pack.learnpack-vscode
583
+ \`\`\`
584
+ - If the extension is listed, it means the installation was successful.
585
+
586
+ We strongly recommend using the LearnPack extension in VSCode for a better learning experience.
587
587
  `;
588
588
  /**
589
589
  * Installs the LearnPack VSCode extension if the 'code' command is available.
@@ -19,7 +19,7 @@ type TAssetMissing = {
19
19
  description: string;
20
20
  learnpack_deploy_url: string;
21
21
  technologies: string[];
22
- category: number;
22
+ category: number | string;
23
23
  owner: number;
24
24
  author: number;
25
25
  preview: string;
package/lib/utils/api.js CHANGED
@@ -420,13 +420,14 @@ const getCategories = async (token) => {
420
420
  }
421
421
  };
422
422
  const updateRigoAssetID = async (token, slug, asset_id) => {
423
+ const cleanToken = token.replace(/[\n\r]/g, "");
423
424
  const url = `${exports.RIGOBOT_HOST}/v1/learnpack/package/${slug}/`;
424
- const headers = {
425
- Authorization: "Token " + token.trim(),
426
- };
427
- console.log("HEADERS", headers);
428
425
  try {
429
- const response = await axios_1.default.put(url, { asset_id }, { headers });
426
+ const response = await axios_1.default.put(url, { asset_id }, {
427
+ headers: {
428
+ Authorization: "Token " + cleanToken,
429
+ },
430
+ });
430
431
  return response.data;
431
432
  }
432
433
  catch (error) {
@@ -436,11 +437,13 @@ const updateRigoAssetID = async (token, slug, asset_id) => {
436
437
  };
437
438
  const createRigoPackage = async (token, slug, config) => {
438
439
  const url = `${exports.RIGOBOT_HOST}/v1/learnpack/package`;
439
- const headers = {
440
- Authorization: "Token " + token.trim(),
441
- };
440
+ const cleanToken = token.replace(/[\n\r]/g, "");
442
441
  try {
443
- const response = await axios_1.default.post(url, { slug, config }, { headers });
442
+ const response = await axios_1.default.post(url, { slug, config }, {
443
+ headers: {
444
+ Authorization: "Token " + cleanToken,
445
+ },
446
+ });
444
447
  return response.data;
445
448
  }
446
449
  catch (error) {
@@ -333,13 +333,13 @@ function countSentences(text) {
333
333
  function howManyDifficultParagraphs(paragraphs, maxFKGL) {
334
334
  return paragraphs.filter(paragraph => paragraph.fkgl > maxFKGL).length;
335
335
  }
336
- const example_content = `Write or paste your table of content below this line, each topic should be defined on a new line, here is an example:
337
-
338
- Introduction to AI: Explain what is AI and its applications
339
- Introduction to Machine Learning: Explain what is machine learning and its applications
340
- What is an AI Model: Explain what is an AI model and its applications
341
- How to use an AI Model: Different APIs, local models, etc.
342
- How to build an AI Model: Fine-tuning, data collection, cleaning and more.
336
+ const example_content = `Write or paste your table of content below this line, each topic should be defined on a new line, here is an example:
337
+
338
+ Introduction to AI: Explain what is AI and its applications
339
+ Introduction to Machine Learning: Explain what is machine learning and its applications
340
+ What is an AI Model: Explain what is an AI model and its applications
341
+ How to use an AI Model: Different APIs, local models, etc.
342
+ How to build an AI Model: Fine-tuning, data collection, cleaning and more.
343
343
  `;
344
344
  const appendContentIndex = async () => {
345
345
  const choices = await prompts([
@@ -369,13 +369,13 @@ const appendContentIndex = async () => {
369
369
  return null;
370
370
  };
371
371
  exports.appendContentIndex = appendContentIndex;
372
- const example_airules = `
373
- Write with an engaging tone, use simple words and avoid complex sentences.
374
- Write in first person, as if you are talking to the reader.
375
- Add mental maps to help the reader understand the content.
376
- Add diagrams to help the reader understand the content.
377
- No code exercises required
378
-
372
+ const example_airules = `
373
+ Write with an engaging tone, use simple words and avoid complex sentences.
374
+ Write in first person, as if you are talking to the reader.
375
+ Add mental maps to help the reader understand the content.
376
+ Add diagrams to help the reader understand the content.
377
+ No code exercises required
378
+
379
379
  `;
380
380
  const appendAIRules = async () => {
381
381
  const choices = await prompts([
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.275",
4
+ "version": "5.0.276",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {