Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 75 lines 2.23 KB
Raw
1 #!/usr/bin/env bun
2
3 /**
4 * Asserts that the Bun revision declared in `mise.toml` matches the binary mise
5 * actually installs.
6 *
7 * `[tool_alias] bun = "http:bun"` decouples the version label from the tarball
8 * URLs, and mise never cross-checks the two: the per-platform checksums prove a
9 * tarball is the one we named, not that it contains the revision we claimed. So
10 * bumping the URLs without the `version` string (or the reverse) silently ships
11 * the wrong Bun to every contributor and every CI job. This is the only check
12 * that catches that.
13 *
14 * The binary is resolved through `mise which bun` rather than `$PATH`, so a
15 * contributor running their own Bun does not get a spurious failure. When mise
16 * cannot resolve Bun the check skips locally, but fails under CI, where the
17 * toolchain is installed by `.github/actions/setup-node-pnpm-bun`.
18 */
19
20 import { execFileSync } from 'node:child_process';
21
22 function run(command: string, args: string[]): string {
23 return execFileSync(command, args, {
24 encoding: 'utf-8',
25 stdio: ['ignore', 'pipe', 'pipe'],
26 }).trim();
27 }
28
29 function skipOrFail(reason: string) {
30 if (process.env.CI) {
31 console.error(
32 `mise-bun-pin: ${reason}
33 CI must run under the mise-installed toolchain, so this is a failure here.`
34 );
35 process.exit(1);
36 }
37
38 console.log(
39 `mise-bun-pin: skipped (${reason}).
40 Run \`mise install\` to enable this check locally.`
41 );
42 process.exit(0);
43 }
44
45 function main() {
46 let declaredRevision: string;
47 let bunPath: string;
48
49 try {
50 declaredRevision = run('mise', ['current', 'bun']);
51 bunPath = run('mise', ['which', 'bun']);
52 } catch (err) {
53 skipOrFail(`could not resolve Bun from mise (${(err as Error).message})`);
54 return;
55 }
56
57 const installedRevision = run(bunPath, ['--revision']);
58
59 if (installedRevision !== declaredRevision) {
60 console.error(
61 `Bun revision mismatch between mise.toml and the installed binary.
62
63 mise.toml declares: ${declaredRevision}
64 ${bunPath} is: ${installedRevision}
65
66 The \`version\` under [tools.bun] and the per-platform tarball URLs are set
67 independently. Update whichever one is stale, then run \`mise install\`.`
68 );
69 process.exit(1);
70 }
71
72 console.log(`mise-bun-pin: ok (${installedRevision})`);
73 }
74
75 main();