Skip to content

Commit

Permalink
feat: upgrade to support deno 2
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbrey committed Oct 19, 2024
1 parent 8f1af9e commit 8079769
Show file tree
Hide file tree
Showing 16 changed files with 360 additions and 666 deletions.
8 changes: 2 additions & 6 deletions .github/demos/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/charmbracelet/vhs:v0.7.2-devel
FROM ghcr.io/charmbracelet/vhs:v0.8.1-devel

ARG MDRB_HASH

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

ADD . /vhs/

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

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

RUN mdrb /vhs/demo.md --mode isolated

ENTRYPOINT [] # override parent layer

CMD [ "/usr/bin/vhs" ]
6 changes: 5 additions & 1 deletion .github/demos/generate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expandGlob, joinGlobs } from "../../deps.dev.ts";
import { $ } from "../../deps.ts";
import { invariant } from "../../src/util.ts";

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

await Promise.all(demos);

const me = Deno.env.get("USER");

invariant(typeof me === "string");

await $`sudo chown -R ${me}:${me} ${demosDir}`;
Binary file modified .github/demos/usage-basic/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/demos/usage-dax/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/demos/usage-no-dax/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/demos/usage-remote-pipe/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/demos/usage-remote/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { daxVersion, version } from "../mod.ts";
const root = $.relativePath(import.meta.url, "..");

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

const nextIsNewer = greaterThan(parse(version), parse(latestTag));
if (!nextIsNewer) {
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": true,
"deno.cacheOnSave": true,
"deno.config": "deno.jsonc",
"[json]": { "editor.defaultFormatter": "denoland.vscode-deno" },
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ When provided a Markdown file (or a remote URL that points to one, or pipe the c
## Installation

```sh
deno install -Arfn mdrb https://deno.land/x/mdrb/mod.ts
deno install --global --config=https://deno.land/x/mdrb/deno.jsonc -Arfn mdrb https://deno.land/x/mdrb/mod.ts
```

> Note: if you prefer not to bake `--allow-all` permissions (with the `-A` flag) into the installed command, you can
Expand Down
20 changes: 19 additions & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,26 @@
"tasks": {
"test": "deno test -A --no-check",
"lint": "deno check mod.ts && deno lint && deno fmt --check",
"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",
// Bump dependencies using @molt/cli (https://jsr.io/@molt/cli) - may prompt for read perms on ~/.local/share/deno-wasmbuild
"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",
"demos": "deno run -A .github/demos/generate.ts",
"hooks": "export GITROOT=$(git rev-parse --show-toplevel); git config core.hooksPath $GITROOT/.hooks"
},
"imports": {
"@cliffy/ansi": "jsr:@cliffy/[email protected]",
"@cliffy/command": "jsr:@cliffy/[email protected]",
"@cliffy/table": "jsr:@cliffy/[email protected]",
"@david/dax": "jsr:@david/[email protected]",
"@esm.sh/cheerio": "npm:[email protected]",
"@littletof/charmd": "jsr:@littletof/[email protected]",
"@std/assert": "jsr:@std/[email protected]",
"@std/fs": "jsr:@std/[email protected]",
"@std/io": "jsr:@std/[email protected]",
"@std/path": "jsr:@std/[email protected]",
"@std/semver": "jsr:@std/[email protected]",
"@std/toml": "jsr:@std/[email protected]",
"@x/hue/theme": "https://deno.land/x/[email protected]/themes/mod.ts",
"@x/hue/typescript": "https://deno.land/x/[email protected]/languages/typescript/typescript.ts",
"@x/rusty_markdown": "https://deno.land/x/[email protected]/mod.ts"
}
}
Loading

0 comments on commit 8079769

Please sign in to comment.