@learnpack/learnpack 5.0.360 → 5.0.362
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/lib/commands/serve.js +44 -1
- package/lib/creatorDist/assets/{index-GYxGB_X0.js → index-CKg5uuoj.js} +8050 -8008
- package/lib/creatorDist/index.html +1 -1
- package/lib/utils/lessonRecovery.d.ts +18 -0
- package/lib/utils/lessonRecovery.js +31 -0
- package/package.json +1 -1
- package/src/commands/serve.ts +65 -9
- package/src/creator/src/utils/lib.test.ts +101 -0
- package/src/creator/src/utils/lib.ts +4 -1
- package/src/creatorDist/assets/{index-GYxGB_X0.js → index-CKg5uuoj.js} +8050 -8008
- package/src/creatorDist/index.html +1 -1
- package/src/utils/lessonRecovery.ts +32 -0
|
@@ -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-
|
|
13
|
+
<script type="module" crossorigin src="/creator/assets/index-CKg5uuoj.js"></script>
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/creator/assets/index-B7s5Nmq8.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a lesson README holds generated content. The file starts as a
|
|
3
|
+
* `loader` block, and the generated content replaces it.
|
|
4
|
+
* @param readme - The README text, or null when the file does not exist.
|
|
5
|
+
* @returns True when the lesson has its generated content.
|
|
6
|
+
*/
|
|
7
|
+
export const hasGeneratedContent = (readme: string | null): boolean =>
|
|
8
|
+
readme !== null && readme.trim() !== "" && !readme.includes("```loader")
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Finds the lessons marked as ERROR that were generated anyway. Publishing and
|
|
12
|
+
* translating wait for every lesson, and the retry screen only shows while the
|
|
13
|
+
* README has its `loader`, so these lessons would otherwise stay stuck.
|
|
14
|
+
* @param lessons - The lessons of the syllabus.
|
|
15
|
+
* @param readReadme - Reads the README of a lesson, or null if it has none.
|
|
16
|
+
* @returns The lessons to mark as done.
|
|
17
|
+
*/
|
|
18
|
+
export const findFinishedLessons = async <T extends { status?: string }>(
|
|
19
|
+
lessons: T[],
|
|
20
|
+
readReadme: (lesson: T) => Promise<string | null>
|
|
21
|
+
): Promise<T[]> => {
|
|
22
|
+
const finished: T[] = []
|
|
23
|
+
|
|
24
|
+
for (const lesson of lessons) {
|
|
25
|
+
if (lesson.status !== "ERROR") continue
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line no-await-in-loop
|
|
28
|
+
if (hasGeneratedContent(await readReadme(lesson))) finished.push(lesson)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return finished
|
|
32
|
+
}
|