@deeeed/metamask-harness 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.1 - 2026-07-06
4
+
5
+ Fresh-install fixes found live on a published-0.6.0 install.
6
+
7
+ ### Fixed
8
+ - **Mobile `launch` no longer dies on empty `METAMASK_BUILD_TYPE`** — the quick-launch runs `expo start` directly (bypassing scripts/build.sh, which passes the build type as an arg); the fixture `.js.env` shipped `METAMASK_BUILD_TYPE=""`, which Metro's transform rejects (`Invalid METAMASK_BUILD_TYPE`). start-metro now defaults to the main dev client when unset, so already-installed slots launch without re-syncing fixtures.
9
+ - **`doctor` no longer false-flags orphan Metros** — the detector matched any argv containing "metro" (caught the `tail -F metro.log` viewer) and reported the live, valid bundler as leaked. Now it matches only `expo start` bundlers and excludes the one serving the current port.
10
+
11
+ ### Internal
12
+ - Reap-checkout-metros test hardened against a SIGTERM timing flake (polls for exit).
3
13
  ## 0.6.0 - 2026-07-06
4
14
 
5
15
  Minor release: CLI hardening (decomposed, single-parser, dist-only) plus a
@@ -117,6 +117,12 @@ printf '(Full log: %s — mm-harness logs | mm-harness logs --full)\n' "$LOG_FIL
117
117
  # shellcheck disable=SC1091
118
118
  [ ! -f .env.local ] || . ./.env.local
119
119
  set +a
120
+ # The quick-launch runs `expo start` directly, bypassing scripts/build.sh which
121
+ # passes the build type as an argument (start:ios = build.sh ios main dev). The
122
+ # fixture .js.env ships METAMASK_BUILD_TYPE="" (empty), which Metro's transform
123
+ # rejects. Default to the main dev client (what runway installs / launch targets)
124
+ # so already-installed slots work without re-syncing fixtures.
125
+ [ -n "${METAMASK_BUILD_TYPE:-}" ] || export METAMASK_BUILD_TYPE=main
120
126
  export EXPO_NO_TYPESCRIPT_SETUP=1
121
127
  export WATCHER_PORT="${PORT}" METRO_PORT="${PORT}"
122
128
  export METRO_MAX_WORKERS="${METRO_WORKERS}"
@@ -1,32 +1,38 @@
1
1
  #!/usr/bin/env bash
2
- # reap-checkout-metros.sh — kill EVERY Metro/Expo bundler bound to a given
3
- # checkout, regardless of port. Port-scoped stop leaks a bundler whenever a
4
- # launch drifts ports or fails to record its pid; this sweeps them by checkout
5
- # path so `stop` fully cleans up and `launch` starts from zero.
2
+ # reap-checkout-metros.sh — find/kill Metro (Expo) bundlers bound to a checkout.
3
+ # The harness starts Metro exactly one way: `yarn expo start`. Match ONLY that
4
+ # signature matching bare "metro" also caught the `tail -F …/metro.log` viewer
5
+ # and other noise, producing false orphans.
6
6
  #
7
- # reap_checkout_metros <checkout-abs-path> [keep-pid]
8
- # keep-pid (optional): a pid to spare (the bundler just started/handled).
7
+ # reap_checkout_metros <checkout-abs-path> [keep-pid]
8
+ # detect_checkout_metros <checkout-abs-path> [live-port]
9
+ # reap kills every bundler for the checkout (stop wants a clean slate), sparing
10
+ # keep-pid. detect lists orphans for doctor and EXCLUDES the bundler serving
11
+ # live-port (the currently-running valid Metro is not a leak).
12
+
13
+ _checkout_metro_pids() {
14
+ # pids of `expo start` bundlers whose argv references this checkout (boundary
15
+ # anchored so /repos/mm-1 never matches /repos/mm-10).
16
+ local repo="$1" pid args
17
+ while IFS= read -r pid; do
18
+ [ -n "$pid" ] || continue
19
+ args="$(ps -o args= -p "$pid" 2>/dev/null || true)"
20
+ case "$args" in *"$repo/"*|*"$repo "*) : ;; *) continue ;; esac
21
+ case "$args" in *"expo start"*) printf '%s\n' "$pid" ;; esac
22
+ done <<LIST
23
+ $(pgrep -f "expo start" 2>/dev/null)
24
+ LIST
25
+ }
26
+
9
27
  reap_checkout_metros() {
10
- local repo="$1" keep="${2:-}" reaped=""
28
+ local repo="$1" keep="${2:-}" reaped="" pid
11
29
  [ -n "$repo" ] || return 0
12
- # Match the bundler's argv: `expo start` / metro under this checkout. ps argv
13
- # embeds the cwd-launched command; expo/metro run with the repo on the path.
14
- local pid args
15
30
  while IFS= read -r pid; do
16
31
  [ -n "$pid" ] || continue
17
32
  [ "$pid" = "$keep" ] && continue
18
- args="$(ps -o args= -p "$pid" 2>/dev/null || true)"
19
- # Anchor to a path boundary so /repos/mm-1 does not match /repos/mm-10.
20
- case "$args" in
21
- *"$repo/"*|*"$repo "*) : ;; # argv references this checkout
22
- *) continue ;;
23
- esac
24
- case "$args" in
25
- *"expo start"*|*"metro"*|*"react-native/cli"*|*"@react-native-community/cli"*)
26
- kill "$pid" 2>/dev/null && reaped="$reaped $pid" ;;
27
- esac
33
+ kill "$pid" 2>/dev/null && reaped="$reaped $pid"
28
34
  done <<LIST
29
- $(pgrep -f "expo start|metro" 2>/dev/null)
35
+ $(_checkout_metro_pids "$repo")
30
36
  LIST
31
37
  if [ -n "$reaped" ]; then
32
38
  printf 'Reaped leaked Metro bundler(s) for this checkout:%s\n' "$reaped" >&2
@@ -34,20 +40,19 @@ LIST
34
40
  return 0
35
41
  }
36
42
 
37
- # detect_checkout_metros <checkout-abs-path> — print pids of every metro/expo
38
- # bundler bound to the checkout, one per line, WITHOUT killing. Powers doctor's
39
- # orphan visibility so leaked bundlers are surfaced without a launch.
40
43
  detect_checkout_metros() {
41
- local repo="$1" pid args
44
+ local repo="$1" live_port="${2:-}" pid args
42
45
  [ -n "$repo" ] || return 0
43
46
  while IFS= read -r pid; do
44
47
  [ -n "$pid" ] || continue
45
- args="$(ps -o args= -p "$pid" 2>/dev/null || true)"
46
- case "$args" in *"$repo/"*|*"$repo "*) : ;; *) continue ;; esac
47
- case "$args" in
48
- *"expo start"*|*"metro"*|*"react-native/cli"*|*"@react-native-community/cli"*) printf '%s\n' "$pid" ;;
49
- esac
48
+ # A bundler serving the currently-managed port is the LIVE valid Metro, not
49
+ # an orphan exclude it so doctor never flags the running server.
50
+ if [ -n "$live_port" ]; then
51
+ args="$(ps -o args= -p "$pid" 2>/dev/null || true)"
52
+ case "$args" in *"--port $live_port"*|*"--port=$live_port"*) continue ;; esac
53
+ fi
54
+ printf '%s\n' "$pid"
50
55
  done <<LIST
51
- $(pgrep -f "expo start|metro" 2>/dev/null)
56
+ $(_checkout_metro_pids "$repo")
52
57
  LIST
53
58
  }
@@ -43,7 +43,7 @@ async function handleDoctor({ options }) {
43
43
  runtime = await surface.runtimeStatus(target);
44
44
  } catch {
45
45
  }
46
- const orphanMetros = adapter === "mobile" ? detectOrphanMetros(target) : [];
46
+ const orphanMetros = adapter === "mobile" ? detectOrphanMetros(target, process.env.WATCHER_PORT) : [];
47
47
  if (json) console.log(JSON.stringify({ ...result, runtime, orphanMetros }, null, 2));
48
48
  else {
49
49
  const out = (style, text) => color(style, text, { stream: process.stdout });
@@ -70,10 +70,10 @@ async function handleDoctor({ options }) {
70
70
  }
71
71
  return result.status === "pass" ? 0 : 1;
72
72
  }
73
- function detectOrphanMetros(target) {
73
+ function detectOrphanMetros(target, livePort) {
74
74
  try {
75
75
  const script = path.join(runnerDir, "adapters/shared/reap-checkout-metros.sh");
76
- const out = execFileSync("bash", ["-c", `. "$1"; detect_checkout_metros "$2"`, "mm-harness-doctor", script, target], {
76
+ const out = execFileSync("bash", ["-c", `. "$1"; detect_checkout_metros "$2" "$3"`, "mm-harness-doctor", script, target, livePort ?? ""], {
77
77
  encoding: "utf8",
78
78
  timeout: 5e3
79
79
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deeeed/metamask-harness",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mm-harness": "bin/mm-harness"