@learnpack/learnpack 5.0.144 → 5.0.148
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.
- package/README.md +13 -13
- package/lib/commands/serve.js +56 -0
- package/lib/creatorDist/assets/{index-DSOj0E0h.css → index-DUPYM87B.css} +25 -8
- package/lib/creatorDist/assets/{index-CzMCewx6.js → index-ETBXfIew.js} +3325 -3277
- package/lib/creatorDist/index.html +2 -2
- package/lib/utils/sidebarGenerator.d.ts +4 -0
- package/lib/utils/sidebarGenerator.js +47 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/serve.ts +108 -0
- package/src/creator/src/App.tsx +3 -4
- package/src/creator/src/components/ConsumablesManager.tsx +1 -0
- package/src/creator/src/components/ContentCard.tsx +28 -7
- package/src/creator/src/components/FileUploader.tsx +44 -17
- package/src/creator/src/components/Loader.tsx +1 -1
- package/src/creator/src/components/PreviewGenerator.tsx +13 -11
- package/src/creator/src/components/TurnstileChallenge.tsx +5 -5
- package/src/creator/src/components/syllabus/ContentIndex.tsx +2 -2
- package/src/creator/src/components/syllabus/Sidebar.tsx +23 -23
- package/src/creator/src/components/syllabus/SyllabusEditor.tsx +4 -1
- package/src/creator/src/index.css +0 -5
- package/src/creatorDist/assets/{index-DSOj0E0h.css → index-DUPYM87B.css} +25 -8
- package/src/creatorDist/assets/{index-CzMCewx6.js → index-ETBXfIew.js} +3325 -3277
- package/src/creatorDist/index.html +2 -2
- package/src/ui/_app/app.css +1 -1
- package/src/ui/_app/app.js +22 -22
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/sidebarGenerator.ts +68 -0
package/src/ui/app.tar.gz
CHANGED
Binary file
|
@@ -125,3 +125,71 @@ export const checkAndFixSidebar = async (
|
|
125
125
|
|
126
126
|
return false
|
127
127
|
}
|
128
|
+
|
129
|
+
export const checkAndFixSidebarPure = async (
|
130
|
+
sidebarJson: Record<string, Record<string, string>>,
|
131
|
+
exercises: any[],
|
132
|
+
rigoToken: string,
|
133
|
+
autoFix = true
|
134
|
+
): Promise<{
|
135
|
+
valid: boolean
|
136
|
+
fixedSidebar?: Record<string, Record<string, string>>
|
137
|
+
}> => {
|
138
|
+
const exerciseTranslations: Set<string> = new Set()
|
139
|
+
for (const e of exercises) {
|
140
|
+
for (const lang of Object.keys(e.translations || {})) {
|
141
|
+
exerciseTranslations.add(lang)
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
let hasErrors = false
|
146
|
+
const fixedSidebar: Record<string, Record<string, string>> = {
|
147
|
+
...sidebarJson,
|
148
|
+
}
|
149
|
+
|
150
|
+
for (const exercise of exercises) {
|
151
|
+
const slug = exercise.slug
|
152
|
+
const existingEntry = fixedSidebar[slug]
|
153
|
+
|
154
|
+
if (!existingEntry) {
|
155
|
+
hasErrors = true
|
156
|
+
fixedSidebar[slug] = { us: exercise.slug }
|
157
|
+
continue
|
158
|
+
}
|
159
|
+
|
160
|
+
for (const lang of exerciseTranslations) {
|
161
|
+
if (!Object.prototype.hasOwnProperty.call(existingEntry, lang)) {
|
162
|
+
hasErrors = true
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
if (hasErrors && autoFix) {
|
168
|
+
if (!rigoToken) {
|
169
|
+
Console.error("No Rigobot token provided!")
|
170
|
+
return { valid: false }
|
171
|
+
}
|
172
|
+
|
173
|
+
Console.warning(
|
174
|
+
"Filling sidebar JSON with missing translations or exercises"
|
175
|
+
)
|
176
|
+
|
177
|
+
const response = await fillSidebarJSON(rigoToken, {
|
178
|
+
needed_translations: JSON.stringify([...exerciseTranslations]),
|
179
|
+
sidebar_json: JSON.stringify(fixedSidebar),
|
180
|
+
})
|
181
|
+
|
182
|
+
const newSidebarJson = JSON.parse(response.parsed.new_sidebar_file)
|
183
|
+
|
184
|
+
Console.info("Sidebar JSON was fixed")
|
185
|
+
return {
|
186
|
+
valid: true,
|
187
|
+
fixedSidebar: newSidebarJson,
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
return {
|
192
|
+
valid: !hasErrors,
|
193
|
+
fixedSidebar: hasErrors ? fixedSidebar : undefined,
|
194
|
+
}
|
195
|
+
}
|