1
0
silverbullet/scripts/generate_fs_list.ts
Zef Hemel fb75ea1a65
No More Collab. Fixes #449
* Fully removes real-time collaboration
* URL scheme rewrite
2023-07-06 16:47:50 +02:00

31 lines
925 B
TypeScript

import type { FileMeta } from "../common/types.ts";
import { walk } from "https://deno.land/std@0.165.0/fs/mod.ts";
import { resolve } from "https://deno.land/std@0.165.0/path/mod.ts";
import { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts";
const rootDir = resolve("website_build");
const lastModifiedTimestamp = +Deno.env.get("LAST_MODIFIED_TIMESTAMP")! ||
Date.now();
const allFiles: FileMeta[] = [];
for await (
const file of walk(rootDir, {
includeDirs: false,
// Exclude hidden files
skip: [/^.*\/(\..+|_redirects|_headers|_client\/.*)$/],
})
) {
const fullPath = file.path;
const s = await Deno.stat(fullPath);
allFiles.push({
name: fullPath.substring(rootDir.length + 1),
lastModified: lastModifiedTimestamp,
contentType: mime.getType(fullPath) || "application/octet-stream",
size: s.size,
perm: "rw",
});
}
console.log(JSON.stringify(allFiles, null, 2));