bynk_driver/tools/pins.rs
1//! The versions of the external tools the toolchain fetches on demand.
2//!
3//! `WRANGLER_SPEC` is the one place `wrangler@4` is written in production code
4//! (#4043): the spawn site, [`super::wrangler::command`], `bynk dev`'s warm-up
5//! line, `bynk doctor`'s install hints, and the test harness all read it.
6
7/// The TypeScript package a runner fetches when `tsc` is not installed:
8/// `typescript@<major>`, the major the generated output is verified against
9/// (`bynk_emit::TYPESCRIPT_MAJOR_TESTED`, #1672). Also the package the install
10/// advice names.
11pub fn typescript_spec() -> String {
12 format!("typescript@{}", bynk_emit::TYPESCRIPT_MAJOR_TESTED)
13}
14
15/// The `tsx` package a runner fetches when `tsx` is not installed. Unpinned:
16/// pinning it would change what a user's `bynk test` fetches (#4003,
17/// Decision G).
18pub const TSX_SPEC: &str = "tsx";
19
20/// The wrangler package a runner fetches when wrangler is not installed:
21/// `wrangler@<major>`, so a new major cannot arrive unannounced. The test
22/// harness provisions exactly this spec before its smokes run, and CI's
23/// pre-warm step names it too (`bynk-tests/tests/system/wrangler_prewarm.rs`).
24pub const WRANGLER_SPEC: &str = "wrangler@4";
25
26#[cfg(test)]
27mod tests {
28 use super::*;
29
30 #[test]
31 fn typescript_is_pinned_to_the_tested_major() {
32 assert_eq!(
33 typescript_spec(),
34 format!("typescript@{}", bynk_emit::TYPESCRIPT_MAJOR_TESTED)
35 );
36 let major = typescript_spec()
37 .strip_prefix("typescript@")
38 .map(str::to_string)
39 .unwrap();
40 assert!(
41 !major.is_empty() && major.bytes().all(|b| b.is_ascii_digit()),
42 "a major version alone: {major}"
43 );
44 }
45
46 #[test]
47 fn wrangler_is_pinned_to_a_major() {
48 let major = WRANGLER_SPEC.strip_prefix("wrangler@").unwrap();
49 assert!(
50 !major.is_empty() && major.bytes().all(|b| b.is_ascii_digit()),
51 "a major version alone: {major}"
52 );
53 }
54
55 #[test]
56 fn tsx_is_unpinned() {
57 assert_eq!(TSX_SPEC, "tsx");
58 }
59}