From d0ff5e1549f80ae45c216ac36f0dca4a6fc2c770 Mon Sep 17 00:00:00 2001 From: m4rc3l05 <15786310+M4RC3L05@users.noreply.github.com> Date: Thu, 21 Nov 2024 21:02:29 +0000 Subject: [PATCH] Update to deno v2.1.1 Signed-off-by: m4rc3l05 <15786310+M4RC3L05@users.noreply.github.com> --- .github/workflows/release.yaml | 2 +- .mise.toml | 2 +- .prettierignore | 6 ------ deno.json | 4 ++-- scripts/embed.ts | 17 ----------------- src/main.ts | 9 ++++----- 6 files changed, 8 insertions(+), 32 deletions(-) delete mode 100644 .prettierignore delete mode 100755 scripts/embed.ts diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8cc7845..34fd466 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -25,7 +25,7 @@ jobs: run: deno install - name: build - run: ./scripts/bundle.ts && ./scripts/embed.ts && ./scripts/build.ts + run: ./scripts/bundle.ts && ./scripts/build.ts - name: release uses: ncipollo/release-action@v1 diff --git a/.mise.toml b/.mise.toml index 4c657bf..cdb4d0b 100644 --- a/.mise.toml +++ b/.mise.toml @@ -2,7 +2,7 @@ experimental = true [tools] -deno = "2.0.5" +deno = "2.1.1" [tasks."check:format"] run = """ diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 71a6166..0000000 --- a/.prettierignore +++ /dev/null @@ -1,6 +0,0 @@ -*.js -*.md -*.json -*.yaml -*.ts -*.tsx diff --git a/deno.json b/deno.json index 8f66f65..2a97d49 100644 --- a/deno.json +++ b/deno.json @@ -3,8 +3,8 @@ "version": "4.6.3", "exports": "./src/main.ts", "tasks": { - "run": "./scripts/bundle.ts && ./scripts/embed.ts && deno run --cached-only --allow-env=ENV --allow-net=127.0.0.1 src/main.ts", - "compile": "./scripts/bundle.ts && ./scripts/embed.ts && deno compile --cached-only --allow-env=ENV --allow-net=127.0.0.1 --env=.env -o ./.bin/denotag ./src/main.ts" + "run": "./scripts/bundle.ts && deno run --allow-read=./data --cached-only --allow-env=ENV --allow-net=127.0.0.1 src/main.ts", + "compile": "./scripts/bundle.ts && deno compile --allow-read=./data --cached-only --allow-env=ENV --allow-net=127.0.0.1 --include ./data/index.html --env=.env -o ./.bin/denotag ./src/main.ts" }, "compilerOptions": { "lib": ["DOM", "deno.ns"], diff --git a/scripts/embed.ts b/scripts/embed.ts deleted file mode 100755 index 7a63754..0000000 --- a/scripts/embed.ts +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env -S deno run -A --cached-only - -import { resolve } from "@std/path"; - -const rootDir = resolve(import.meta.dirname!, "../"); -const dataDir = resolve(rootDir, "data"); -const embedFilePath = resolve(rootDir, "embed.json"); - -const embed: Record = {}; - -for (const file of Deno.readDirSync(dataDir)) { - if (file.name !== "index.html") continue; - - embed[file.name] = Array.from(Deno.readFileSync(resolve(dataDir, file.name))); -} - -Deno.writeTextFileSync(embedFilePath, JSON.stringify(embed)); diff --git a/src/main.ts b/src/main.ts index 1e617da..1bf8ea4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,6 +7,9 @@ import { import { bootActions } from "./actions.ts"; import meta from "./../deno.json" with { type: "json" }; +const indexFile = new URL("./../data/index.html", import.meta.url); +const indexFileContents = Deno.readTextFileSync(indexFile); + const multipartToObj = async (request: Request) => { const response = new Map(); @@ -80,10 +83,6 @@ const onTagCmd = async ({ dir }: { dir: string }) => { throw new Error(`Dir "${dir}" it not a directory`); } - const embed = await import("./../embed.json", { with: { type: "json" } }) - .then(({ default: main }) => main); - - const ui = Uint8Array.from(embed["index.html"]); const { invokeAction } = bootActions({ dir: join(dir) }); return Deno.serve({ @@ -113,7 +112,7 @@ const onTagCmd = async ({ dir }: { dir: string }) => { return Response.json(await invokeAction(callName as any, ...args)); } - return new Response(ui, { + return new Response(indexFileContents, { headers: { "content-type": "text/html" }, status: 200, });