Skip to content

Commit bd8639f

Browse files
authoredOct 19, 2024··
Merge pull request #2 from andrewbrey/deno_2
feat: upgrade to support deno 2
2 parents 8f1af9e + 0231711 commit bd8639f

File tree

17 files changed

+364
-669
lines changed

17 files changed

+364
-669
lines changed
 

‎.github/demos/Dockerfile

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/charmbracelet/vhs:v0.7.2-devel
1+
FROM ghcr.io/charmbracelet/vhs:v0.8.1-devel
22

33
ARG MDRB_HASH
44

@@ -13,12 +13,8 @@ RUN apt install curl unzip bat -y \
1313

1414
ADD . /vhs/
1515

16-
RUN deno install -Arfn mdrb /vhs/mod.ts
16+
RUN deno install --global --config=/vhs/deno.jsonc -Arfn mdrb /vhs/mod.ts
1717

1818
RUN deno cache --lock=/vhs/deno.lock /vhs/deps.ts /vhs/deps.dev.ts
1919

2020
RUN mdrb /vhs/demo.md --mode isolated
21-
22-
ENTRYPOINT [] # override parent layer
23-
24-
CMD [ "/usr/bin/vhs" ]

‎.github/demos/generate.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expandGlob, joinGlobs } from "../../deps.dev.ts";
22
import { $ } from "../../deps.ts";
3+
import { invariant } from "../../src/util.ts";
34

45
const root = $.relativePath(import.meta.url, "..", "..");
56
const latestHash = await $`git rev-parse HEAD`.cwd(root).text();
@@ -12,10 +13,13 @@ await $`docker build --build-arg MDRB_HASH=${latestHash} -t ${img} -f ${dockerfi
1213
const demos = [];
1314
for await (const tape of expandGlob(joinGlobs([demosDir.toString(), "**", "vhs.tape"]))) {
1415
const mount = $.path(tape.path).dirname();
15-
demos.push($`docker run --rm -v ${mount}:/vhs/demos ${img} vhs /vhs/demos/vhs.tape`.cwd(root));
16+
demos.push($`docker run --rm -v ${mount}:/vhs/demos ${img} /vhs/demos/vhs.tape`.cwd(root));
1617
}
1718

1819
await Promise.all(demos);
1920

2021
const me = Deno.env.get("USER");
22+
23+
invariant(typeof me === "string");
24+
2125
await $`sudo chown -R ${me}:${me} ${demosDir}`;

‎.github/demos/usage-basic/demo.gif

-1.81 KB
Loading

‎.github/demos/usage-dax/demo.gif

560 KB
Loading

‎.github/demos/usage-no-dax/demo.gif

2.63 KB
Loading
14.9 KB
Loading

‎.github/demos/usage-remote/demo.gif

12.6 KB
Loading

‎.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@v4
2424

2525
- name: Install Deno 🦕
26-
uses: denoland/setup-deno@v1
26+
uses: denoland/setup-deno@v2
2727

2828
- name: Lint 🧹
2929
if: runner.os == 'Linux'

‎.hooks/pre-commit

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { daxVersion, version } from "../mod.ts";
77
const root = $.relativePath(import.meta.url, "..");
88

99
const latestTag = await $`git describe --tags --abbrev=0`.cwd(root).text();
10-
const depsDaxVersion = Deno.readTextFileSync($.path(root).join("deps.ts").toString())
11-
.match(/deno.land\/x\/dax@([^\/]+)/)?.at(1) ?? "";
10+
const depsDaxVersion = Deno.readTextFileSync($.path(root).join("deno.jsonc").toString())
11+
.match(/@david\/dax@([^"]+)/)?.at(1) ?? "";
1212

1313
const nextIsNewer = greaterThan(parse(version), parse(latestTag));
1414
if (!nextIsNewer) {

‎.vscode/settings.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"deno.enable": true,
33
"deno.lint": true,
4-
"deno.unstable": true,
54
"deno.cacheOnSave": true,
65
"deno.config": "deno.jsonc",
76
"[json]": { "editor.defaultFormatter": "denoland.vscode-deno" },

‎README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ When provided a Markdown file (or a remote URL that points to one, or pipe the c
6161
## Installation
6262

6363
```sh
64-
deno install -Arfn mdrb https://deno.land/x/mdrb/mod.ts
64+
deno install --global --config=https://deno.land/x/mdrb/deno.jsonc -Arfn mdrb https://deno.land/x/mdrb/mod.ts
6565
```
6666

6767
> Note: if you prefer not to bake `--allow-all` permissions (with the `-A` flag) into the installed command, you can
68-
> specify alternate permissions, e.g. `deno install --allow-net -rfn mdrb https://deno.land/x/mdrb/mod.ts` but be aware
69-
> that this means you will be prompted for permissions at runtime.
68+
> specify alternate permissions, e.g.
69+
> `deno install --global --config=https://deno.land/x/mdrb/deno.jsonc --allow-net -rfn mdrb https://deno.land/x/mdrb/mod.ts`
70+
> but be aware that this means you will be prompted for permissions at runtime.
7071
7172
## Demos
7273

‎deno.jsonc

+19-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,26 @@
44
"tasks": {
55
"test": "deno test -A --no-check",
66
"lint": "deno check mod.ts && deno lint && deno fmt --check",
7-
"deps": "deno run --allow-read=. --allow-write=. --allow-net https://deno.land/x/udd/main.ts deps.ts deps.dev.ts && deno cache --reload --lock=deno.lock deps.ts deps.dev.ts",
7+
// Bump dependencies using @molt/cli (https://jsr.io/@molt/cli) - may prompt for read perms on ~/.local/share/deno-wasmbuild
8+
"deps": "deno run -E=XDG_DATA_HOME,HOME,GITHUB_TOKEN -R='./' -W=deno.jsonc -N=api.jsr.io,jsr.io,deno.land,registry.npmjs.org,esm.sh jsr:@molt/cli --write deno.jsonc",
89
"demos": "deno run -A .github/demos/generate.ts",
910
"hooks": "export GITROOT=$(git rev-parse --show-toplevel); git config core.hooksPath $GITROOT/.hooks"
11+
},
12+
"imports": {
13+
"@cliffy/ansi": "jsr:@cliffy/ansi@1.0.0-rc.7",
14+
"@cliffy/command": "jsr:@cliffy/command@1.0.0-rc.7",
15+
"@cliffy/table": "jsr:@cliffy/table@1.0.0-rc.7",
16+
"@david/dax": "jsr:@david/dax@0.42.0",
17+
"@esm.sh/cheerio": "npm:cheerio@1.0.0",
18+
"@littletof/charmd": "jsr:@littletof/charmd@0.1.2",
19+
"@std/assert": "jsr:@std/assert@1.0.6",
20+
"@std/fs": "jsr:@std/fs@1.0.4",
21+
"@std/io": "jsr:@std/io@0.225.0",
22+
"@std/path": "jsr:@std/path@1.0.6",
23+
"@std/semver": "jsr:@std/semver@1.0.3",
24+
"@std/toml": "jsr:@std/toml@1.0.1",
25+
"@x/hue/theme": "https://deno.land/x/hue@0.0.0-alpha.1/themes/mod.ts",
26+
"@x/hue/typescript": "https://deno.land/x/hue@0.0.0-alpha.1/languages/typescript/typescript.ts",
27+
"@x/rusty_markdown": "https://deno.land/x/rusty_markdown@v0.4.1/mod.ts"
1028
}
1129
}

‎deno.lock

+311-628
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deps.dev.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
/* use `deno task deps` to bump deps */
2-
3-
export { assertEquals } from "https://deno.land/std@0.220.1/assert/assert_equals.ts";
4-
export { assertInstanceOf } from "https://deno.land/std@0.220.1/assert/assert_instance_of.ts";
5-
export { assertRejects } from "https://deno.land/std@0.220.1/assert/assert_rejects.ts";
6-
export { assertStringIncludes } from "https://deno.land/std@0.220.1/assert/assert_string_includes.ts";
7-
export { assertThrows } from "https://deno.land/std@0.220.1/assert/assert_throws.ts";
8-
export { expandGlob } from "https://deno.land/std@0.220.1/fs/mod.ts";
9-
export { joinGlobs } from "https://deno.land/std@0.220.1/path/mod.ts";
10-
export { greaterThan, parse } from "https://deno.land/std@0.220.1/semver/mod.ts";
1+
export { assertEquals, assertInstanceOf, assertRejects, assertStringIncludes, assertThrows } from "@std/assert";
2+
export { expandGlob } from "@std/fs";
3+
export { joinGlobs } from "@std/path";
4+
export { greaterThan, parse } from "@std/semver";

‎deps.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/* use `deno task deps` to bump deps */
22

3-
import { parse as parseTOML } from "https://deno.land/std@0.220.1/toml/mod.ts";
4-
import { $ as basic$, build$, CommandBuilder } from "https://deno.land/x/dax@0.39.2/mod.ts";
5-
import { tokens as parseMarkdown } from "https://deno.land/x/rusty_markdown@v0.4.1/mod.ts";
6-
import { load as parseHTML } from "https://esm.sh/cheerio@1.0.0-rc.12";
3+
import { $ as basic$, build$, CommandBuilder } from "@david/dax";
4+
import { load as parseHTML } from "@esm.sh/cheerio";
5+
import { parse as parseTOML } from "@std/toml";
6+
import { tokens as parseMarkdown } from "@x/rusty_markdown";
77

8-
export { readAll } from "https://deno.land/std@0.220.1/io/mod.ts";
9-
export { SEPARATOR as SEP } from "https://deno.land/std@0.220.1/path/mod.ts";
10-
export { SEPARATOR as POSIX_SEP } from "https://deno.land/std@0.220.1/path/posix/mod.ts";
11-
export { type Extension, renderMarkdown } from "https://deno.land/x/charmd@v0.0.2/mod.ts";
12-
export { colors } from "https://deno.land/x/cliffy@v1.0.0-rc.3/ansi/mod.ts";
13-
export { Command, EnumType, ValidationError } from "https://deno.land/x/cliffy@v1.0.0-rc.3/command/mod.ts";
14-
export { default as Typescript } from "https://deno.land/x/hue@0.0.0-alpha.1/languages/typescript/typescript.ts";
15-
export { DefaultTheme } from "https://deno.land/x/hue@0.0.0-alpha.1/themes/mod.ts";
8+
export { colors } from "@cliffy/ansi/colors";
9+
export { Command, EnumType, ValidationError } from "@cliffy/command";
10+
export { type Extension, renderMarkdown } from "@littletof/charmd";
11+
export { readAll } from "@std/io";
12+
export { SEPARATOR as SEP } from "@std/path";
13+
export { SEPARATOR as POSIX_SEP } from "@std/path/posix";
14+
export { DefaultTheme } from "@x/hue/theme";
15+
export { default as Typescript } from "@x/hue/typescript";
1616
export { CommandBuilder };
1717

1818
export const $ = build$({

‎mod.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function withServer(action: (serverUrl: URL) => Promise<void>) {
3333
hostname: "localhost",
3434
signal,
3535
async onListen(details) {
36-
const url = new URL(`http://${details.hostname}:${details.port}/`);
36+
const url = new URL(`http://localhost:${details.port}/`);
3737
try {
3838
await action(url);
3939
resolve();

‎mod.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { $, colors, Command, EnumType, readAll, ValidationError } from "./deps.t
22
import { type CodeBlock, mdCodeBlocks, renderMDToString } from "./src/markdown.ts";
33
import { invariant, toFileURL } from "./src/util.ts";
44

5-
export const version = "2.0.1";
6-
export const daxVersion = "0.39.2";
5+
export const version = "3.0.0";
6+
export const daxVersion = "0.42.0";
77

88
if (import.meta.main) {
99
const modes = ["runbook", "isolated", "single"] as const;
@@ -63,7 +63,7 @@ if (import.meta.main) {
6363

6464
let maybeDaxImport = "";
6565
if (dax) {
66-
maybeDaxImport = `import { $ } from "https://deno.land/x/dax@${daxVersion}/mod.ts";\n`;
66+
maybeDaxImport = `import { $ } from "jsr:@david/dax@${daxVersion}";\n`;
6767
}
6868

6969
switch (executionMode) {

0 commit comments

Comments
 (0)
Please sign in to comment.