Skip to content

Commit 7aba2a7

Browse files
authored
Add version to binary name (#33)
1 parent 90dec46 commit 7aba2a7

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

Cargo.lock

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

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "deno-webview"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
edition = "2021"
55

66
[profile.release]

deno.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dev": "deno run --watch main.ts",
77
"gen": "cargo test && deno run -A scripts/generate-zod.ts && deno run -A scripts/sync-versions.ts",
88
"build": "deno task gen && cargo build -F transparent",
9-
"example:simple": "deno run -A examples/simple.ts"
9+
"example:simple": "WEBVIEW_BIN=./target/debug/deno-webview deno run -A examples/simple.ts"
1010
},
1111
"publish": {
1212
"include": ["README.md", "LICENSE", "src/**/*.ts"]

scripts/sync-versions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const libContent = await Deno.readTextFile(libPath);
1515

1616
// Replace the version in the URL
1717
const updatedContent = libContent.replace(
18-
/releases\/download\/v\d+\.\d+\.\d+\/deno-webview/,
19-
`releases/download/v${latestVersion}/deno-webview`,
18+
/const BIN_VERSION = "[^"]+"/,
19+
`const BIN_VERSION = "${latestVersion}"`,
2020
);
2121

2222
// Write the updated content back to src/lib.ts

src/lib.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import type { Except } from "npm:type-fest";
1010
import { join } from "jsr:@std/path";
1111
import { ensureDir, exists } from "jsr:@std/fs";
1212

13+
/* The version of the webview binary to use; should match the cargo package version */
14+
const BIN_VERSION = "0.1.5";
15+
1316
type JSON =
1417
| string
1518
| number
@@ -83,7 +86,7 @@ async function getWebViewBin(options: WebViewOptions) {
8386
: "";
8487

8588
const cacheDir = getCacheDir();
86-
const fileName = `deno-webview${flags}${
89+
const fileName = `deno-webview-${BIN_VERSION}${flags}${
8790
Deno.build.os === "windows" ? ".exe" : ""
8891
}`;
8992
const filePath = join(cacheDir, fileName);
@@ -95,7 +98,7 @@ async function getWebViewBin(options: WebViewOptions) {
9598

9699
// If not in cache, download it
97100
let url =
98-
"https://github.com/zephraph/webview/releases/download/v0.1.4/deno-webview";
101+
`https://github.com/zephraph/webview/releases/download/v${BIN_VERSION}/deno-webview`;
99102
switch (Deno.build.os) {
100103
case "darwin": {
101104
url += "-mac" + flags;

src/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ fn main() -> wry::Result<()> {
221221
}
222222
Event::MainEventsCleared => {
223223
if let Ok(req) = rx.try_recv() {
224-
eprintln!("Received event: {:?}", event);
225224
match req {
226225
Request::Eval { id, js } => {
227226
let result = webview.evaluate_script(&js);

0 commit comments

Comments
 (0)