From 63aea3c593c4638b1af85283c479534c942062d4 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Sat, 29 Oct 2022 16:27:16 +0200 Subject: [PATCH] Fix demo --- scripts/build_demo.sh | 14 ++++++++------ scripts/generate_fs_list.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 scripts/generate_fs_list.ts diff --git a/scripts/build_demo.sh b/scripts/build_demo.sh index 52864ff..efe9aeb 100755 --- a/scripts/build_demo.sh +++ b/scripts/build_demo.sh @@ -1,12 +1,17 @@ #!/bin/bash +echo "Install Deno" +# curl -fsSL https://deno.land/install.sh | sh +# export PATH=~/.deno/bin:$PATH + echo "Building silver bullet" -npm run clean-build +deno task build echo "Cleaning website build dir" rm -rf website_build mkdir -p website_build/fs/_plug echo "Copying silverbullet runtime files" -cp -r packages/web/dist/* website_build/ +cp -r dist_bundle/web/* website_build/ +cp -r dist_bundle/_plug/* website_build/fs/_plug/ echo "Copying netlify config files" cp website/{_redirects,_headers} website_build/ @@ -14,11 +19,8 @@ echo "Copying website markdown files" cp -r website/* website_build/fs/ rm website_build/fs/{_redirects,_headers} -echo "Copying standard set of plugs" -cp packages/plugs/dist/* website_build/fs/_plug/ - echo "Generating file listing" -node scripts/generate_fs_list.js > website_build/index.json +deno run -A scripts/generate_fs_list.ts > website_build/index.json echo > website_build/empty.md diff --git a/scripts/generate_fs_list.ts b/scripts/generate_fs_list.ts new file mode 100644 index 0000000..f5eaa2b --- /dev/null +++ b/scripts/generate_fs_list.ts @@ -0,0 +1,27 @@ +import type { FileMeta } from "../common/types.ts"; + +import { walk } from "https://deno.land/std@0.159.0/fs/mod.ts"; +import { resolve } from "https://deno.land/std@0.159.0/path/mod.ts"; +import { mime } from "https://deno.land/x/mimetypes@v1.0.0/mod.ts"; + +const rootDir = resolve("website_build/fs"); + +const allFiles: FileMeta[] = []; +for await ( + const file of walk(rootDir, { + includeDirs: false, + // Exclude hidden files + skip: [/^.*\/\..+$/], + }) +) { + const fullPath = file.path; + const s = await Deno.stat(fullPath); + allFiles.push({ + name: fullPath.substring(rootDir.length + 1), + lastModified: s.mtime!.getTime(), + contentType: mime.getType(fullPath) || "application/octet-stream", + size: s.size, + perm: "rw", + }); +} +console.log(JSON.stringify(allFiles, null, 2));