@learnpack/learnpack 5.0.298 → 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 +31 -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 +47 -25
  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
@@ -1,178 +1,178 @@
1
- # Export Utilities
2
-
3
- This directory contains utilities for exporting courses to different formats.
4
-
5
- ## Supported Formats
6
-
7
- - **SCORM**: Learning Management System compatible package
8
- - **EPUB**: E-book format for offline reading
9
-
10
- ## Usage
11
-
12
- ### API Endpoints
13
-
14
- The export functionality is available through the `/export/:course_slug/:format` endpoint:
15
-
16
- - `GET /export/{course_slug}/scorm` - Export course to SCORM format
17
- - `GET /export/{course_slug}/epub` - Export course to EPUB format
18
-
19
- ### Example Usage
20
-
21
- ```bash
22
- # Export course to SCORM
23
- curl -O "http://localhost:3000/export/my-course/scorm"
24
-
25
- # Export course to EPUB (default English)
26
- curl -O "http://localhost:3000/export/my-course/epub"
27
-
28
- # Export course to EPUB in Spanish
29
- curl -O "http://localhost:3000/export/my-course/epub?language=es"
30
-
31
- # Export course to EPUB in French
32
- curl -O "http://localhost:3000/export/my-course/epub?language=fr"
33
- ```
34
-
35
- ## Requirements
36
-
37
- ### SCORM Export
38
-
39
- - No additional requirements
40
-
41
- ### EPUB Export
42
-
43
- - **Pandoc** must be installed on the system
44
- - Pandoc is used to convert markdown to HTML and generate EPUB files
45
- - **Language Support**: Use the `language` query parameter to specify the language
46
- - Default: `en` (English)
47
- - The system will prioritize language-specific files (e.g., `README.es.md` for Spanish)
48
- - Falls back to `README.md` if no language-specific file is found
49
-
50
- ### Installing Pandoc
51
-
52
- #### Windows
53
-
54
- ```bash
55
- # Using Chocolatey
56
- choco install pandoc
57
-
58
- # Using Scoop
59
- scoop install pandoc
60
-
61
- # Or download from https://pandoc.org/installing.html
62
- ```
63
-
64
- #### macOS
65
-
66
- ```bash
67
- # Using Homebrew
68
- brew install pandoc
69
-
70
- # Using MacPorts
71
- sudo port install pandoc
72
- ```
73
-
74
- #### Linux
75
-
76
- ```bash
77
- # Ubuntu/Debian
78
- sudo apt-get install pandoc
79
-
80
- # CentOS/RHEL
81
- sudo yum install pandoc
82
-
83
- # Arch Linux
84
- sudo pacman -S pandoc
85
- ```
86
-
87
- ## Architecture
88
-
89
- The export system is modular and consists of:
90
-
91
- - **`types.ts`**: Type definitions for export options and course metadata
92
- - **`shared.ts`**: Common utility functions used by all export formats
93
- - **`scorm.ts`**: SCORM export implementation
94
- - **`epub.ts`**: EPUB export implementation using Pandoc
95
- - **`index.ts`**: Main export interface
96
-
97
- ## Adding New Export Formats
98
-
99
- To add a new export format:
100
-
101
- 1. Create a new file in the export directory (e.g., `pdf.ts`)
102
- 2. Implement the export function following the same pattern
103
- 3. Add the new format to the `ExportFormat` type in `types.ts`
104
- 4. Update the main export endpoint in `serve.ts`
105
- 5. Add the new format to the export index
106
-
107
- ### Example New Format
108
-
109
- ```typescript
110
- // pdf.ts
111
- export async function exportToPdf(options: ExportOptions): Promise<string> {
112
- // Implementation here
113
- return outputPath;
114
- }
115
-
116
- // types.ts
117
- export type ExportFormat = 'scorm' | 'epub' | 'pdf';
118
-
119
- // serve.ts
120
- } else if (format === "pdf") {
121
- outputPath = await exportToPdf({
122
- courseSlug: course_slug,
123
- format: "pdf",
124
- bucket,
125
- outDir: path.join(__dirname, "../output/directory")
126
- });
127
- filename = `${course_slug}.pdf`;
128
- }
129
- ```
130
-
131
- ## File Structure
132
-
133
- ```
134
- src/utils/export/
135
- ├── index.ts # Main export interface
136
- ├── types.ts # Type definitions
137
- ├── shared.ts # Shared utilities
138
- ├── scorm.ts # SCORM export
139
- ├── epub.ts # EPUB export
140
- ├── templates/ # Export templates
141
- │ ├── scorm/ # SCORM template files
142
- │ └── epub/ # EPUB template files
143
- └── README.md # This file
144
- ```
145
-
146
- ## Templates
147
-
148
- ### SCORM Template
149
-
150
- Contains the necessary files for a SCORM package:
151
-
152
- - `imsmanifest.xml` - Course manifest
153
- - `config/` - Configuration files
154
- - XSD schema files for validation
155
-
156
- ### EPUB Template
157
-
158
- Contains styling and assets for EPUB generation:
159
-
160
- - `epub.css` - Basic EPUB styling
161
- - `cover.png` - Default cover image (placeholder)
162
-
163
- ## Error Handling
164
-
165
- The export system includes comprehensive error handling:
166
-
167
- - Invalid format validation
168
- - File system operation errors
169
- - Pandoc execution errors (for EPUB)
170
- - Network/download errors
171
- - Cleanup on failure
172
-
173
- ## Performance Considerations
174
-
175
- - Temporary files are automatically cleaned up
176
- - Large courses may take time to process
177
- - Consider implementing progress indicators for long-running exports
178
- - Memory usage scales with course size
1
+ # Export Utilities
2
+
3
+ This directory contains utilities for exporting courses to different formats.
4
+
5
+ ## Supported Formats
6
+
7
+ - **SCORM**: Learning Management System compatible package
8
+ - **EPUB**: E-book format for offline reading
9
+
10
+ ## Usage
11
+
12
+ ### API Endpoints
13
+
14
+ The export functionality is available through the `/export/:course_slug/:format` endpoint:
15
+
16
+ - `GET /export/{course_slug}/scorm` - Export course to SCORM format
17
+ - `GET /export/{course_slug}/epub` - Export course to EPUB format
18
+
19
+ ### Example Usage
20
+
21
+ ```bash
22
+ # Export course to SCORM
23
+ curl -O "http://localhost:3000/export/my-course/scorm"
24
+
25
+ # Export course to EPUB (default English)
26
+ curl -O "http://localhost:3000/export/my-course/epub"
27
+
28
+ # Export course to EPUB in Spanish
29
+ curl -O "http://localhost:3000/export/my-course/epub?language=es"
30
+
31
+ # Export course to EPUB in French
32
+ curl -O "http://localhost:3000/export/my-course/epub?language=fr"
33
+ ```
34
+
35
+ ## Requirements
36
+
37
+ ### SCORM Export
38
+
39
+ - No additional requirements
40
+
41
+ ### EPUB Export
42
+
43
+ - **Pandoc** must be installed on the system
44
+ - Pandoc is used to convert markdown to HTML and generate EPUB files
45
+ - **Language Support**: Use the `language` query parameter to specify the language
46
+ - Default: `en` (English)
47
+ - The system will prioritize language-specific files (e.g., `README.es.md` for Spanish)
48
+ - Falls back to `README.md` if no language-specific file is found
49
+
50
+ ### Installing Pandoc
51
+
52
+ #### Windows
53
+
54
+ ```bash
55
+ # Using Chocolatey
56
+ choco install pandoc
57
+
58
+ # Using Scoop
59
+ scoop install pandoc
60
+
61
+ # Or download from https://pandoc.org/installing.html
62
+ ```
63
+
64
+ #### macOS
65
+
66
+ ```bash
67
+ # Using Homebrew
68
+ brew install pandoc
69
+
70
+ # Using MacPorts
71
+ sudo port install pandoc
72
+ ```
73
+
74
+ #### Linux
75
+
76
+ ```bash
77
+ # Ubuntu/Debian
78
+ sudo apt-get install pandoc
79
+
80
+ # CentOS/RHEL
81
+ sudo yum install pandoc
82
+
83
+ # Arch Linux
84
+ sudo pacman -S pandoc
85
+ ```
86
+
87
+ ## Architecture
88
+
89
+ The export system is modular and consists of:
90
+
91
+ - **`types.ts`**: Type definitions for export options and course metadata
92
+ - **`shared.ts`**: Common utility functions used by all export formats
93
+ - **`scorm.ts`**: SCORM export implementation
94
+ - **`epub.ts`**: EPUB export implementation using Pandoc
95
+ - **`index.ts`**: Main export interface
96
+
97
+ ## Adding New Export Formats
98
+
99
+ To add a new export format:
100
+
101
+ 1. Create a new file in the export directory (e.g., `pdf.ts`)
102
+ 2. Implement the export function following the same pattern
103
+ 3. Add the new format to the `ExportFormat` type in `types.ts`
104
+ 4. Update the main export endpoint in `serve.ts`
105
+ 5. Add the new format to the export index
106
+
107
+ ### Example New Format
108
+
109
+ ```typescript
110
+ // pdf.ts
111
+ export async function exportToPdf(options: ExportOptions): Promise<string> {
112
+ // Implementation here
113
+ return outputPath;
114
+ }
115
+
116
+ // types.ts
117
+ export type ExportFormat = 'scorm' | 'epub' | 'pdf';
118
+
119
+ // serve.ts
120
+ } else if (format === "pdf") {
121
+ outputPath = await exportToPdf({
122
+ courseSlug: course_slug,
123
+ format: "pdf",
124
+ bucket,
125
+ outDir: path.join(__dirname, "../output/directory")
126
+ });
127
+ filename = `${course_slug}.pdf`;
128
+ }
129
+ ```
130
+
131
+ ## File Structure
132
+
133
+ ```
134
+ src/utils/export/
135
+ ├── index.ts # Main export interface
136
+ ├── types.ts # Type definitions
137
+ ├── shared.ts # Shared utilities
138
+ ├── scorm.ts # SCORM export
139
+ ├── epub.ts # EPUB export
140
+ ├── templates/ # Export templates
141
+ │ ├── scorm/ # SCORM template files
142
+ │ └── epub/ # EPUB template files
143
+ └── README.md # This file
144
+ ```
145
+
146
+ ## Templates
147
+
148
+ ### SCORM Template
149
+
150
+ Contains the necessary files for a SCORM package:
151
+
152
+ - `imsmanifest.xml` - Course manifest
153
+ - `config/` - Configuration files
154
+ - XSD schema files for validation
155
+
156
+ ### EPUB Template
157
+
158
+ Contains styling and assets for EPUB generation:
159
+
160
+ - `epub.css` - Basic EPUB styling
161
+ - `cover.png` - Default cover image (placeholder)
162
+
163
+ ## Error Handling
164
+
165
+ The export system includes comprehensive error handling:
166
+
167
+ - Invalid format validation
168
+ - File system operation errors
169
+ - Pandoc execution errors (for EPUB)
170
+ - Network/download errors
171
+ - Cleanup on failure
172
+
173
+ ## Performance Considerations
174
+
175
+ - Temporary files are automatically cleaned up
176
+ - Large courses may take time to process
177
+ - Consider implementing progress indicators for long-running exports
178
+ - Memory usage scales with course size
@@ -1,74 +1,74 @@
1
- const fs = require("fs")
2
- const path = require("path")
3
- const readline = require("readline")
4
-
5
- // Get command-line arguments
6
- const args = process.argv.slice(2)
7
- const partIndex = args.findIndex(arg => arg === "-p" || arg === "--part")
8
- const part =
9
- partIndex !== -1 && args[partIndex + 1] ?
10
- args[partIndex + 1].toLowerCase() :
11
- null
12
-
13
- const packagePath = path.resolve(process.cwd(), "package.json")
14
-
15
- try {
16
- // Read package.json file
17
- const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf8"))
18
-
19
- // Check if "version" field exists
20
- if (!packageJson.version) {
21
- throw new Error(
22
- 'El archivo package.json no contiene una propiedad "version".'
23
- )
24
- }
25
-
26
- const [major, minor, patch] = packageJson.version.split(".").map(Number)
27
-
28
- // Function to update version
29
- const updateVersion = part => {
30
- let newVersion
31
- switch (part) {
32
- case "major":
33
- newVersion = `${major + 1}.0.0`
34
- break
35
- case "minor":
36
- newVersion = `${major}.${minor + 1}.0`
37
- break
38
- case "patch":
39
- newVersion = `${major}.${minor}.${patch + 1}`
40
- break
41
- default:
42
- console.error("Opción no válida. Usa: major, minor o patch.")
43
- process.exit(1)
44
- }
45
-
46
- // Update package.json
47
- packageJson.version = newVersion
48
- fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2), "utf8")
49
-
50
- console.log(`Versión actualizada: ${packageJson.version} -> ${newVersion}`)
51
- }
52
-
53
- if (part) {
54
- // If flag is provided, update immediately
55
- updateVersion(part)
56
- } else {
57
- // Otherwise, ask the user interactively
58
- const rl = readline.createInterface({
59
- input: process.stdin,
60
- output: process.stdout,
61
- })
62
-
63
- rl.question(
64
- "¿Qué parte de la versión deseas incrementar? (major, minor, patch): ",
65
- answer => {
66
- updateVersion(answer.toLowerCase())
67
- rl.close()
68
- }
69
- )
70
- }
71
- } catch (error) {
72
- console.error(`Error: ${error.message}`)
73
- process.exit(1)
74
- }
1
+ const fs = require("fs")
2
+ const path = require("path")
3
+ const readline = require("readline")
4
+
5
+ // Get command-line arguments
6
+ const args = process.argv.slice(2)
7
+ const partIndex = args.findIndex(arg => arg === "-p" || arg === "--part")
8
+ const part =
9
+ partIndex !== -1 && args[partIndex + 1] ?
10
+ args[partIndex + 1].toLowerCase() :
11
+ null
12
+
13
+ const packagePath = path.resolve(process.cwd(), "package.json")
14
+
15
+ try {
16
+ // Read package.json file
17
+ const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf8"))
18
+
19
+ // Check if "version" field exists
20
+ if (!packageJson.version) {
21
+ throw new Error(
22
+ 'El archivo package.json no contiene una propiedad "version".'
23
+ )
24
+ }
25
+
26
+ const [major, minor, patch] = packageJson.version.split(".").map(Number)
27
+
28
+ // Function to update version
29
+ const updateVersion = part => {
30
+ let newVersion
31
+ switch (part) {
32
+ case "major":
33
+ newVersion = `${major + 1}.0.0`
34
+ break
35
+ case "minor":
36
+ newVersion = `${major}.${minor + 1}.0`
37
+ break
38
+ case "patch":
39
+ newVersion = `${major}.${minor}.${patch + 1}`
40
+ break
41
+ default:
42
+ console.error("Opción no válida. Usa: major, minor o patch.")
43
+ process.exit(1)
44
+ }
45
+
46
+ // Update package.json
47
+ packageJson.version = newVersion
48
+ fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2), "utf8")
49
+
50
+ console.log(`Versión actualizada: ${packageJson.version} -> ${newVersion}`)
51
+ }
52
+
53
+ if (part) {
54
+ // If flag is provided, update immediately
55
+ updateVersion(part)
56
+ } else {
57
+ // Otherwise, ask the user interactively
58
+ const rl = readline.createInterface({
59
+ input: process.stdin,
60
+ output: process.stdout,
61
+ })
62
+
63
+ rl.question(
64
+ "¿Qué parte de la versión deseas incrementar? (major, minor, patch): ",
65
+ answer => {
66
+ updateVersion(answer.toLowerCase())
67
+ rl.close()
68
+ }
69
+ )
70
+ }
71
+ } catch (error) {
72
+ console.error(`Error: ${error.message}`)
73
+ process.exit(1)
74
+ }
package/src/utils/misc.ts CHANGED
@@ -1,58 +1,58 @@
1
- export const prioritizeHTMLFile = (entryFiles: string[]) => {
2
- let files = []
3
-
4
- // Find the html file and put it as latest in the files array
5
- // in order to keep the html file opened in vscode plugin
6
- const index = entryFiles.findIndex(file => {
7
- return /.*\.html$/.test(file)
8
- })
9
-
10
- if (index !== -1) {
11
- for (const [i, entryFile] of entryFiles.entries()) {
12
- if (i !== index) {
13
- files.push(entryFile)
14
- }
15
- }
16
-
17
- files.push(entryFiles[index])
18
- } else {
19
- files = entryFiles
20
- }
21
-
22
- return files
23
- }
24
-
25
- export function minutesToISO8601Duration(minutes: number): string {
26
- if (minutes <= 0)
27
- return "PT0M"
28
-
29
- const weeks = Math.floor(minutes / (60 * 24 * 7))
30
- minutes %= 60 * 24 * 7
31
-
32
- const days = Math.floor(minutes / (60 * 24))
33
- minutes %= 60 * 24
34
-
35
- const hours = Math.floor(minutes / 60)
36
- const mins = minutes % 60
37
-
38
- let duration = "P"
39
- if (weeks)
40
- duration += `${weeks}W`
41
- if (days)
42
- duration += `${days}D`
43
-
44
- if (hours || mins)
45
- duration += "T"
46
- if (hours)
47
- duration += `${hours}H`
48
- if (mins)
49
- duration += `${mins}M`
50
-
51
- return duration
52
- }
53
-
54
- export const createUploadMiddleware = () => {
55
- // eslint-disable-next-line
56
- const multer = require("multer")
57
- return multer({ limits: { fileSize: 25 * 1024 * 1024 } })
58
- }
1
+ export const prioritizeHTMLFile = (entryFiles: string[]) => {
2
+ let files = []
3
+
4
+ // Find the html file and put it as latest in the files array
5
+ // in order to keep the html file opened in vscode plugin
6
+ const index = entryFiles.findIndex(file => {
7
+ return /.*\.html$/.test(file)
8
+ })
9
+
10
+ if (index !== -1) {
11
+ for (const [i, entryFile] of entryFiles.entries()) {
12
+ if (i !== index) {
13
+ files.push(entryFile)
14
+ }
15
+ }
16
+
17
+ files.push(entryFiles[index])
18
+ } else {
19
+ files = entryFiles
20
+ }
21
+
22
+ return files
23
+ }
24
+
25
+ export function minutesToISO8601Duration(minutes: number): string {
26
+ if (minutes <= 0)
27
+ return "PT0M"
28
+
29
+ const weeks = Math.floor(minutes / (60 * 24 * 7))
30
+ minutes %= 60 * 24 * 7
31
+
32
+ const days = Math.floor(minutes / (60 * 24))
33
+ minutes %= 60 * 24
34
+
35
+ const hours = Math.floor(minutes / 60)
36
+ const mins = minutes % 60
37
+
38
+ let duration = "P"
39
+ if (weeks)
40
+ duration += `${weeks}W`
41
+ if (days)
42
+ duration += `${days}D`
43
+
44
+ if (hours || mins)
45
+ duration += "T"
46
+ if (hours)
47
+ duration += `${hours}H`
48
+ if (mins)
49
+ duration += `${mins}M`
50
+
51
+ return duration
52
+ }
53
+
54
+ export const createUploadMiddleware = () => {
55
+ // eslint-disable-next-line
56
+ const multer = require("multer")
57
+ return multer({ limits: { fileSize: 25 * 1024 * 1024 } })
58
+ }