Skip to content

Commit 76aa85c

Browse files
committed
light brush up to deno v2
1 parent be18c58 commit 76aa85c

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

.github/dependabot.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2
22
updates:
3-
# Maintain dependencies for GitHub Actions
4-
- package-ecosystem: "github-actions"
5-
directory: "/"
3+
4+
- package-ecosystem: github-actions
5+
directory: /
66
schedule:
7-
interval: "weekly"
7+
interval: monthly

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM denoland/deno:alpine-1.43.5
1+
FROM denoland/deno:alpine-2.2.10
22
RUN apk add --no-cache graphviz
33
ADD fonts/ /usr/share/fonts/truetype/
44

@@ -8,4 +8,4 @@ ADD deps.ts .
88
RUN deno check deps.ts
99
ADD . .
1010
RUN deno check entrypoint.ts
11-
ENTRYPOINT ["deno","run","--allow-sys=hostname,osRelease","--allow-env","--allow-net","--allow-run=deno,dot","--allow-read=.","entrypoint.ts"]
11+
ENTRYPOINT ["deno","run","--allow-sys","--allow-env","--allow-net","--allow-run=deno,dot","--allow-read=.","entrypoint.ts"]

feat/dependencies-of/api.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ async function renderModuleToHtml(modUrl: string, args: URLSearchParams) {
106106
.slice(fullSvg.indexOf('<!--'))
107107
.replace(/<svg width="[^"]+" height="[^"]+"/, '<svg '+attrs.join(' '));
108108

109-
} catch (err) {
109+
} catch (thrown) {
110+
const err = thrown as Error & {subproc?: SubprocessErrorData};
110111
if (err.subproc) {
111-
const info = err.subproc as SubprocessErrorData;
112+
const info = err.subproc;
112113
return `
113114
<div id="graph-error">
114115
<h2>${entities.encode(info.procLabel.toUpperCase())} FAILED</h2>
@@ -121,7 +122,7 @@ async function renderModuleToHtml(modUrl: string, args: URLSearchParams) {
121122
</div>`.replace(/^ +/gm, '');
122123
}
123124
console.error('Graph computation error:', err.stack);
124-
return `<div id="graph-error">${entities.encode(err.stack)}</div>`;
125+
return `<div id="graph-error">${entities.encode(err.stack ?? '')}</div>`;
125126
}
126127
}
127128

@@ -136,7 +137,8 @@ async function serveHtmlGraphPage(req: Request, modUrl: string, modSlug: string,
136137
module_url: entities.encode(modUrl),
137138
export_prefix: entities.encode(`${req.url}${req.url.includes('?') ? '&' : '?'}format=`),
138139
});
139-
} catch (err) {
140+
} catch (thrown) {
141+
const err = thrown as Error;
140142
return makeErrorResponse(err);
141143
}
142144

lib/module-map.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class ModuleMap {
4040
totalSize: 0,
4141
deps: new Set(),
4242
depsUnversioned: new Set(),
43-
files: new Array(),
43+
files: [],
4444
};
4545
this.modules.set(base + fragment, moduleInfo);
4646
}
@@ -212,17 +212,19 @@ export function computeDependencies(data: ModuleGraphJson, args: URLSearchParams
212212

213213
case 'dot':
214214
case null:
215-
const lines = new Array<string>();
216-
map.emitDOT(line => lines.push(line));
217-
return lines.join('\n')+'\n';
215+
{
216+
const lines = new Array<string>();
217+
map.emitDOT(line => lines.push(line));
218+
return lines.join('\n')+'\n';
219+
}
218220

219221
default:
220222
throw new Error(`Unexpected format ${JSON.stringify(args.get('format'))}`);
221223
}
222224
}
223225

224226
if (import.meta.main) {
225-
const rawData = new TextDecoder().decode(await Deno.readAll(Deno.stdin));
227+
const rawData = await new Response(Deno.stdin.readable).text();
226228
if (rawData[0] !== '{') throw new Error(`Expected JSON from "deno info --json"`);
227229
const data = JSON.parse(rawData) as ModuleGraphJson;
228230

server.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env -S deno run --watch --check --allow-sys=hostname --allow-read --allow-net --allow-run=deno,dot --allow-env
1+
#!/usr/bin/env -S deno run --watch --check --allow-sys --allow-read --allow-net --allow-run=deno,dot --allow-env --allow-import=deno.land,crux.land
22

33
import { httpTracer, trace } from "./deps.ts";
44
import { serveFont, servePublic, serveTemplatedHtml } from './lib/request-handling.ts';
@@ -8,10 +8,11 @@ import * as DependenciesOf from './feat/dependencies-of/api.ts';
88
import * as Shields from './feat/shields/api.ts';
99
import * as RegistryKey from './feat/registry-key/api.ts';
1010

11-
let port = 5000;
11+
let port = 8000;
1212
try {
1313
port = parseInt(Deno.env.get('PORT') || port.toString());
14-
} catch (err) {
14+
} catch (thrown) {
15+
const err = thrown as Error;
1516
console.error(`WARN: failed to read $PORT due to ${err.name}`);
1617
}
1718

0 commit comments

Comments
 (0)