Skip to content

Commit

Permalink
chore: fix watch mode for deno 1.8, release 0.10.5 (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato committed Mar 7, 2021
1 parent 22bae6a commit d0cd496
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions example/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
2 changes: 1 addition & 1 deletion example/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
21 changes: 14 additions & 7 deletions src/dependency_graph.ts
Original file line number Diff line number Diff line change
@@ -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<DepGraph> {
Expand All @@ -29,8 +37,7 @@ async function runDenoInfo(entrypoint: string): Promise<DepGraph> {
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<string[]> {
Expand All @@ -39,7 +46,7 @@ export async function dependencyList(entrypoints: string[]): Promise<string[]> {
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];
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down

0 comments on commit d0cd496

Please sign in to comment.