@learnpack/learnpack 5.0.287 → 5.0.290
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 +49 -73
- package/lib/creatorDist/assets/{index-CQMtxRqZ.js → index-7zTdUX04.js} +4797 -4828
- package/lib/creatorDist/index.html +1 -1
- package/lib/utils/export/index.d.ts +1 -0
- package/lib/utils/export/index.js +3 -1
- package/lib/utils/export/types.d.ts +1 -1
- package/lib/utils/export/zip.d.ts +2 -0
- package/lib/utils/export/zip.js +46 -0
- package/package.json +1 -1
- package/src/commands/serve.ts +28 -54
- package/src/creator/src/App.tsx +61 -67
- package/src/creator/src/components/syllabus/SyllabusEditor.tsx +1 -21
- package/src/creator/src/utils/lib.ts +468 -477
- package/src/creator/src/utils/store.ts +222 -223
- package/src/creatorDist/assets/{index-CQMtxRqZ.js → index-7zTdUX04.js} +4797 -4828
- package/src/creatorDist/index.html +1 -1
- package/src/utils/export/index.ts +1 -0
- package/src/utils/export/types.ts +1 -1
- package/src/utils/export/zip.ts +55 -0
- package/src/creator/src/components/PassphraseValidator.tsx +0 -47
@@ -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-7zTdUX04.js"></script>
|
14
14
|
<link rel="stylesheet" crossorigin href="/creator/assets/index-C39zeF3W.css">
|
15
15
|
</head>
|
16
16
|
<body>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import * as path from "path";
|
2
|
+
import * as fs from "fs";
|
3
|
+
import * as archiver from "archiver";
|
4
|
+
import * as mkdirp from "mkdirp";
|
5
|
+
import * as rimraf from "rimraf";
|
6
|
+
import { v4 as uuidv4 } from "uuid";
|
7
|
+
import { ExportOptions } from "./types";
|
8
|
+
import { downloadS3Folder, getCourseMetadata } from "./shared";
|
9
|
+
|
10
|
+
export async function exportToZip(options: ExportOptions): Promise<string> {
|
11
|
+
const { courseSlug, bucket, outDir } = options;
|
12
|
+
|
13
|
+
// 1. Create temporary folder
|
14
|
+
const tmpName = uuidv4();
|
15
|
+
const zipOutDir = path.join(outDir, tmpName);
|
16
|
+
rimraf.sync(zipOutDir);
|
17
|
+
mkdirp.sync(zipOutDir);
|
18
|
+
|
19
|
+
// 2. Download all course files from bucket to temporary directory
|
20
|
+
await downloadS3Folder(bucket, `courses/${courseSlug}/`, zipOutDir);
|
21
|
+
|
22
|
+
// 3. Create ZIP file
|
23
|
+
const zipName = `${courseSlug}.zip`;
|
24
|
+
const zipPath = path.join(outDir, zipName);
|
25
|
+
|
26
|
+
// Remove existing zip file if it exists
|
27
|
+
if (fs.existsSync(zipPath)) {
|
28
|
+
fs.unlinkSync(zipPath);
|
29
|
+
}
|
30
|
+
|
31
|
+
const output = fs.createWriteStream(zipPath);
|
32
|
+
const archive = archiver("zip", { zlib: { level: 9 } });
|
33
|
+
|
34
|
+
return new Promise((resolve, reject) => {
|
35
|
+
output.on("close", () => {
|
36
|
+
console.log(`✅ ZIP export completed: ${archive.pointer()} total bytes`);
|
37
|
+
// Clean up temporary directory
|
38
|
+
rimraf.sync(zipOutDir);
|
39
|
+
resolve(zipPath);
|
40
|
+
});
|
41
|
+
|
42
|
+
archive.on("error", (err) => {
|
43
|
+
console.error("❌ ZIP creation error:", err);
|
44
|
+
rimraf.sync(zipOutDir);
|
45
|
+
reject(err);
|
46
|
+
});
|
47
|
+
|
48
|
+
archive.pipe(output);
|
49
|
+
|
50
|
+
// Add all files from the temporary directory to the ZIP
|
51
|
+
archive.directory(zipOutDir, false);
|
52
|
+
|
53
|
+
archive.finalize();
|
54
|
+
});
|
55
|
+
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
import React, { useEffect } from 'react';
|
2
|
-
import { RIGOBOT_HOST } from '../utils/constants';
|
3
|
-
|
4
|
-
interface PassphraseValidatorProps {
|
5
|
-
onSuccess?: (response: any) => void;
|
6
|
-
onError?: (error: any) => void;
|
7
|
-
}
|
8
|
-
|
9
|
-
const PassphraseValidator: React.FC<PassphraseValidatorProps> = ({
|
10
|
-
onSuccess,
|
11
|
-
onError
|
12
|
-
}) => {
|
13
|
-
useEffect(() => {
|
14
|
-
const validatePassphrase = async () => {
|
15
|
-
try {
|
16
|
-
const response = await fetch(`${RIGOBOT_HOST}/v1/auth/public/token`, {
|
17
|
-
method: 'POST',
|
18
|
-
headers: {
|
19
|
-
'Content-Type': 'application/json',
|
20
|
-
},
|
21
|
-
body: JSON.stringify({
|
22
|
-
passphrase: 'bm29vnv4h43n'
|
23
|
-
})
|
24
|
-
});
|
25
|
-
|
26
|
-
const data = await response.json();
|
27
|
-
|
28
|
-
if (response.ok) {
|
29
|
-
onSuccess?.(data);
|
30
|
-
} else {
|
31
|
-
onError?.(data);
|
32
|
-
}
|
33
|
-
} catch (error) {
|
34
|
-
onError?.(error);
|
35
|
-
}
|
36
|
-
};
|
37
|
-
|
38
|
-
validatePassphrase();
|
39
|
-
}, [onSuccess, onError]);
|
40
|
-
|
41
|
-
return (
|
42
|
-
<div>
|
43
|
-
</div>
|
44
|
-
);
|
45
|
-
};
|
46
|
-
|
47
|
-
export default PassphraseValidator;
|