Skip to content

Commit a751bd2

Browse files
committed
Make the TypeScript code depend on the publish argon2id-wasm package
This makes sure we don’t need to build the Rust code when making TS-only changes.
1 parent 26b31fd commit a751bd2

6 files changed

Lines changed: 58 additions & 19 deletions

File tree

.github/workflows/rust.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,48 @@ jobs:
4141

4242
- name: Compile for wasm32 target
4343
run: just check
44+
45+
comment:
46+
name: Comment on PR
47+
if: github.event_name == 'pull_request'
48+
runs-on: ubuntu-latest
49+
permissions:
50+
pull-requests: write
51+
steps:
52+
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
53+
with:
54+
script: |
55+
const marker = '<!-- rust-code-modified -->';
56+
const body = [
57+
marker,
58+
'⚠️ **This PR modifies the Rust code.**',
59+
'',
60+
'For these changes to take effect in the TypeScript code, you will need to:',
61+
'',
62+
'1. Publish a new version of the `argon2id-wasm` package on npm.',
63+
'2. Update the dependency on `argon2id-wasm` in the `core` component.',
64+
].join('\n');
65+
66+
const { data: comments } = await github.rest.issues.listComments({
67+
owner: context.repo.owner,
68+
repo: context.repo.repo,
69+
issue_number: context.issue.number,
70+
});
71+
72+
const existing = comments.find((c) => c.body.includes(marker));
73+
74+
if (existing) {
75+
await github.rest.issues.updateComment({
76+
owner: context.repo.owner,
77+
repo: context.repo.repo,
78+
comment_id: existing.id,
79+
body,
80+
});
81+
} else {
82+
await github.rest.issues.createComment({
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
issue_number: context.issue.number,
86+
body,
87+
});
88+
}

README.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@ This branch contains a WIP implementation of Convex Auth v2.
66

77
Use `pnpm install` at the root.
88

9-
The `argon2id-wasm` package depends on some Rust code compiled to WebAssembly.
10-
Its `prepare` script builds it automatically on `pnpm install` when the compiled
11-
output is missing, so you'll need [`just`](https://github.com/casey/just) and the
12-
toolchain pinned in `packages/argon2id-wasm/src/argon2-wasm/rust-toolchain.toml` (installed
13-
automatically by `rustup` on first use).
14-
15-
To rebuild the WASM after changing the Rust source, run:
16-
17-
```bash
18-
pnpm --filter argon2id-wasm build:wasm
19-
```
20-
219
Common tasks:
2210

2311
- `pnpm test` — run tests across packages (Vitest).

packages/argon2id-wasm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"scripts": {
1717
"build:wasm": "cd rust && just build",
18-
"prepare": "test -f src/argon2-wasm/pkg/argon2_wasm_bg.wasm || pnpm run build:wasm",
18+
"prepack": "pnpm run build:wasm",
1919
"typecheck": "tsc --noEmit"
2020
},
2121
"devDependencies": {

packages/argon2id-wasm/rust/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ just build # regenerate pkg/ via wasm-pack (pinned version)
1818
`pkg/` is gitignored and regenerated by `just build`. After changing `src/lib.rs`, run
1919
`just build` (or `pnpm --filter argon2id-wasm build:wasm`) to regenerate it.
2020

21-
The `argon2id-wasm` package's `prepare` script runs `just build` automatically on
22-
`pnpm install` whenever `pkg/` is missing, so a fresh checkout builds it without manual
23-
steps.
21+
The core package depends on the version of the package published to NPM,
22+
so that contributors don’t need to run the Rust toolchain when doing NPM-only changes.
23+
After making changes to argon2id-wasm, manually publish the package and update the
24+
dependency version.

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"dependencies": {
4040
"@convex-dev/rate-limiter": "^0.3.2",
41-
"argon2id-wasm": "workspace:*",
41+
"argon2id-wasm": "0.0.0-alpha.1",
4242
"jose": "^5.2.2"
4343
},
4444
"devDependencies": {

pnpm-lock.yaml

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)