From ee4979b471c3e0402eee88f6967f7ef07f5b4816 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 25 Nov 2022 19:43:54 +0100 Subject: [PATCH] Clean up website build --- plugs/directive/command.ts | 8 -------- plugs/directive/directive.plug.yaml | 3 --- scripts/build_demo.sh | 19 +++++++++++++------ scripts/generate_fs_list.js | 29 ----------------------------- scripts/release.sh | 9 --------- 5 files changed, 13 insertions(+), 55 deletions(-) delete mode 100644 scripts/generate_fs_list.js delete mode 100755 scripts/release.sh diff --git a/plugs/directive/command.ts b/plugs/directive/command.ts index 74ef2ba8..8d8f9cb3 100644 --- a/plugs/directive/command.ts +++ b/plugs/directive/command.ts @@ -35,14 +35,6 @@ export async function updateDirectivesOnPageCommand(arg: any) { // Collect all directives and their body replacements const replacements: { fullMatch: string; text?: string }[] = []; - // Sanity checking if the server gives useful responses (will not be the case on silverbullet.md) - try { - await system.invokeFunction("server", "serverPing"); - } catch { - console.warn("Server not functional, not updating directives"); - return; - } - await replaceAsync( text, directiveRegex, diff --git a/plugs/directive/directive.plug.yaml b/plugs/directive/directive.plug.yaml index 335ccecb..be14fe65 100644 --- a/plugs/directive/directive.plug.yaml +++ b/plugs/directive/directive.plug.yaml @@ -11,9 +11,6 @@ functions: key: "Alt-q" events: - editor:pageLoaded - serverPing: - env: server - path: ./command.ts:serverPing indexData: path: ./data.ts:indexData events: diff --git a/scripts/build_demo.sh b/scripts/build_demo.sh index 77dd4912..f905e167 100755 --- a/scripts/build_demo.sh +++ b/scripts/build_demo.sh @@ -1,8 +1,8 @@ #!/bin/bash echo "Install Deno" -# curl -fsSL https://deno.land/install.sh | sh -# export PATH=~/.deno/bin:$PATH +curl -fsSL https://deno.land/install.sh | sh +export PATH=~/.deno/bin:$PATH echo "Building silver bullet" deno task build @@ -11,14 +11,21 @@ rm -rf website_build mkdir -p website_build/fs/_plug echo "Copying silverbullet runtime files" 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/ -echo "Copying website markdown files" +echo "And all plugs" +cp -r dist_bundle/_plug/* website_build/fs/_plug/ +echo "But remove some plugs" +rm -rf website_build/fs/_plug/{directive,plugmd,publish}.plug.json +#echo "Copying netlify config files" +#cp website/{_redirects,_headers} website_build/ + +echo "Copying website content into fs/" cp -r website/* website_build/fs/ rm website_build/fs/{_redirects,_headers} +echo "Copy website files another time into the root" +cp -r website/* website_build/ + echo "Generating file listing" deno run -A scripts/generate_fs_list.ts > website_build/index.json diff --git a/scripts/generate_fs_list.js b/scripts/generate_fs_list.js deleted file mode 100644 index 94156e8d..00000000 --- a/scripts/generate_fs_list.js +++ /dev/null @@ -1,29 +0,0 @@ -const { resolve } = require("path"); -const { readdir } = require("fs").promises; -const mime = require("mime-types"); - -async function getFiles(dir) { - const dirents = await readdir(dir, { withFileTypes: true }); - const files = await Promise.all( - dirents.map((dirent) => { - const res = resolve(dir, dirent.name); - return dirent.isDirectory() ? getFiles(res) : res; - }), - ); - return Array.prototype.concat(...files); -} - -const rootDir = resolve("website_build/fs"); - -getFiles(rootDir).then((files) => { - files = files - .map((file) => ({ - name: file.substring(rootDir.length + 1), - lastModified: 0, - contentType: mime.lookup(file), - size: 0, - perm: "rw", - })) - .filter((pageMeta) => !pageMeta.name.startsWith(".")); - console.log(JSON.stringify(files, null, 2)); -}); diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100755 index a2846338..00000000 --- a/scripts/release.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -e - -VERSION=$1 -npm version --ws $VERSION || true -npm install --workspace packages/server --save @silverbulletmd/web@$VERSION @silverbulletmd/common@$VERSION @silverbulletmd/plugs@$VERSION -npm install --workspace packages/plugs --save @silverbulletmd/common@$VERSION - -npm run clean-build -npm run publish-all \ No newline at end of file