mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
feat(edit-docs): start creating input zip file
This commit is contained in:
parent
2b891adc34
commit
a1918ad491
@ -5,6 +5,7 @@ import type NoteMeta from "./src/services/meta/note_meta.js";
|
||||
import type { NoteMetaFile } from "./src/services/meta/note_meta.js";
|
||||
import cls from "./src/services/cls.js";
|
||||
import { initializeTranslations } from "./src/services/i18n.js";
|
||||
import archiver from "archiver";
|
||||
|
||||
const NOTE_ID_USER_GUIDE = "_help_user_guide";
|
||||
const destRootPath = path.join("src", "public", "app", "doc_notes", "en", "User Guide");
|
||||
@ -15,6 +16,7 @@ async function startElectron() {
|
||||
|
||||
async function main() {
|
||||
await initializeTranslations();
|
||||
await createImportZip();
|
||||
await initializeDatabase();
|
||||
cls.init(() => {
|
||||
importData();
|
||||
@ -50,6 +52,35 @@ async function importData() {
|
||||
});
|
||||
}
|
||||
|
||||
async function createImportZip() {
|
||||
const archive = archiver("zip", {
|
||||
zlib: { level: 0 }
|
||||
});
|
||||
|
||||
async function iterate(currentPath: string) {
|
||||
console.log("Found ", currentPath);
|
||||
for (const entry of await fs.readdir(currentPath, { withFileTypes: true })) {
|
||||
const entryPath = path.join(currentPath, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
await iterate(entryPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
const source = fsExtra.createReadStream(entryPath);
|
||||
archive.append(source, {
|
||||
name: entryPath
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
await iterate(destRootPath);
|
||||
|
||||
const outputStream = fsExtra.createWriteStream("input.zip");
|
||||
archive.pipe(outputStream);
|
||||
await archive.finalize();
|
||||
}
|
||||
|
||||
async function exportData() {
|
||||
const zipFilePath = "output.zip";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user