From d0cd4964ac3990730008b95ec77b4faf22dcbc37 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Sun, 7 Mar 2021 20:05:52 +0100 Subject: [PATCH] chore: fix watch mode for deno 1.8, release 0.10.5 (#68) --- README.md | 2 +- cli.ts | 2 +- example/Dockerfile | 8 ++++---- example/deps.ts | 2 +- src/dependency_graph.ts | 21 ++++++++++++++------- src/util.ts | 2 +- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 387dc3b..4c0ba20 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ To install, run the following command. This will make the `dext` CLI available in your path. ``` -deno install --allow-read --allow-write --allow-env --allow-net --allow-run --unstable -f -n dext https://deno.land/x/dext@0.10.4/cli.ts +deno install --allow-read --allow-write --allow-env --allow-net --allow-run --unstable -f -n dext https://deno.land/x/dext@0.10.5/cli.ts ``` ## Getting started diff --git a/cli.ts b/cli.ts index bef002f..5f4c1b8 100644 --- a/cli.ts +++ b/cli.ts @@ -16,7 +16,7 @@ import { exportCommand } from "./src/export.ts"; import { serve } from "./src/serve.ts"; import { findPages, printError } from "./src/util.ts"; -const VERSION = "0.10.4"; +const VERSION = "0.10.5"; try { await new Command() diff --git a/example/Dockerfile b/example/Dockerfile index 5a8edca..1bf8606 100644 --- a/example/Dockerfile +++ b/example/Dockerfile @@ -1,14 +1,14 @@ FROM hayd/alpine-deno:1.7.5 as builder WORKDIR /app -RUN deno cache --unstable https://deno.land/x/dext@0.10.4/cli.ts +RUN deno cache --unstable https://deno.land/x/dext@0.10.5/cli.ts COPY deps.ts deps.ts COPY tsconfig.json tsconfig.json RUN deno cache -c tsconfig.json deps.ts COPY . . -RUN deno run --allow-read --allow-write --allow-env --allow-net --allow-run --unstable https://deno.land/x/dext@0.10.4/cli.ts build +RUN deno run --allow-read --allow-write --allow-env --allow-net --allow-run --unstable https://deno.land/x/dext@0.10.5/cli.ts build FROM hayd/alpine-deno:1.7.5 WORKDIR /app -RUN deno cache --unstable https://deno.land/x/dext@0.10.4/cli.ts +RUN deno cache --unstable https://deno.land/x/dext@0.10.5/cli.ts COPY --from=builder /app/.dext /app/.dext -CMD [ "deno", "run", "--allow-read", "--allow-net", "--allow-env", "--unstable", "https://deno.land/x/dext@0.10.4/cli.ts", "start" ] +CMD [ "deno", "run", "--allow-read", "--allow-net", "--allow-env", "--unstable", "https://deno.land/x/dext@0.10.5/cli.ts", "start" ] diff --git a/example/deps.ts b/example/deps.ts index f780ebd..3b90359 100644 --- a/example/deps.ts +++ b/example/deps.ts @@ -8,4 +8,4 @@ export type { GetStaticDataContext, GetStaticPaths, PageProps, -} from "https://deno.land/x/dext@0.10.4/mod.ts"; +} from "https://deno.land/x/dext@0.10.5/mod.ts"; diff --git a/src/dependency_graph.ts b/src/dependency_graph.ts index 32e35fe..ad83c52 100644 --- a/src/dependency_graph.ts +++ b/src/dependency_graph.ts @@ -1,12 +1,20 @@ const decoder = new TextDecoder(); export interface DepGraph { - [file: string]: Dep; + root: string; + modules: Module[]; } -export interface Dep { - size: number; - deps: string[]; +export interface Module { + specifier: string; + dependencies: []; +} + +export interface Dependency { + specifier: string; + isDynamic: boolean; + code?: string; + type?: string; } async function runDenoInfo(entrypoint: string): Promise { @@ -29,8 +37,7 @@ async function runDenoInfo(entrypoint: string): Promise { throw new Error(`Failed to run deno info for ${entrypoint}`); } const text = decoder.decode(file); - const { files } = JSON.parse(text); - return files; + return JSON.parse(text); } export async function dependencyList(entrypoints: string[]): Promise { @@ -39,7 +46,7 @@ export async function dependencyList(entrypoints: string[]): Promise { for (const entrypoint of entrypoints) { if (dependencies.has(entrypoint)) continue; const graph = await runDenoInfo(entrypoint); - Object.keys(graph).forEach((dep) => dependencies.add(dep)); + graph.modules.forEach((dep) => dependencies.add(dep.specifier)); } return [...dependencies]; diff --git a/src/util.ts b/src/util.ts index 26f72b7..2aec202 100644 --- a/src/util.ts +++ b/src/util.ts @@ -147,7 +147,7 @@ export async function checkHasDataHooks( // deno-lint-ignore no-explicit-any export function printError(err: any) { if (err.message != "Failed to prerender page") { - console.log(colors.red(colors.bold("error: ")) + err.message); + console.log(colors.red(colors.bold("error: ")) + err); if (err.code === "PARSE_ERROR") { console.log( `${err.loc.file}:${err.loc.line}:${err.loc.column}\n${err.frame}`,