2022-11-19 15:05:37 +00:00
|
|
|
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";
|
2022-10-29 14:27:16 +00:00
|
|
|
import { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts";
|
2023-08-20 15:51:00 +00:00
|
|
|
import { FileMeta } from "$sb/types.ts";
|
2022-10-29 14:27:16 +00:00
|
|
|
|
2023-07-06 14:47:50 +00:00
|
|
|
const rootDir = resolve("website_build");
|
2023-05-23 18:53:53 +00:00
|
|
|
|
|
|
|
const lastModifiedTimestamp = +Deno.env.get("LAST_MODIFIED_TIMESTAMP")! ||
|
|
|
|
Date.now();
|
2022-10-29 14:27:16 +00:00
|
|
|
|
|
|
|
const allFiles: FileMeta[] = [];
|
|
|
|
for await (
|
|
|
|
const file of walk(rootDir, {
|
|
|
|
includeDirs: false,
|
|
|
|
// Exclude hidden files
|
2023-07-31 19:06:08 +00:00
|
|
|
skip: [
|
|
|
|
/^.*\/(\..+|_redirects|_headers|service_worker\.js.*|index\.json|_client\/.*)$/,
|
|
|
|
],
|
2022-10-29 14:27:16 +00:00
|
|
|
})
|
|
|
|
) {
|
|
|
|
const fullPath = file.path;
|
|
|
|
const s = await Deno.stat(fullPath);
|
|
|
|
allFiles.push({
|
|
|
|
name: fullPath.substring(rootDir.length + 1),
|
2023-05-23 18:53:53 +00:00
|
|
|
lastModified: lastModifiedTimestamp,
|
2023-11-03 08:38:04 +00:00
|
|
|
created: lastModifiedTimestamp,
|
2022-10-29 14:27:16 +00:00
|
|
|
contentType: mime.getType(fullPath) || "application/octet-stream",
|
|
|
|
size: s.size,
|
|
|
|
perm: "rw",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
console.log(JSON.stringify(allFiles, null, 2));
|