The CLI's last feature work was 12 July; core has shipped 26.8 and 26.9 since. Two consequences, fixed together because they share an entry-file convention. Every runtime overlay pinned `^26.7.0-beta.0`. Core is prerelease-only, and npm's semver excludes a prerelease from any range whose comparators carry a different major.minor.patch — so that caret is not a loose pin, it is a pin to the oldest matching prerelease that nothing can move off. Every project `matcha new` has produced since July installed 26.7.0-beta.0 and could not upgrade: no logger, no request budget, no resumable `@Sse` id, and none of the crashes 26.9 fixed. The pin is now exact, lives in one `CORE_VERSION` const, and Deno resolves through JSR — which is core's native path for Deno and the one 26.9 repaired. Nothing caught that because CI never ran JavaScript. `cargo test` proves the CLI writes the files it means to write; it cannot prove those files describe a project the current core will run. `scripts/starter-smoke.sh` scaffolds, installs, type-checks, boots, curls `/` and the `/zen` stream, and introspects a real starter per runtime; a weekly job fails when the pin falls behind the `beta` dist-tag. The smoke immediately found a second defect: the bun overlay carried no Bun types, so `tsc --noEmit` — and therefore `matcha create --check` — failed on every bun project the CLI has ever scaffolded. `matcha graph` and `matcha explain <pattern>` close the widest gap in the surface: the framework's claim is that an API is a graph rather than a middleware chain, `toMermaid`/`toDOT`/`graph`/`explain` have been exported all along, and the CLI could not draw any of it. Both reach the app through `app.ready()`, which resolves the graph and is documented as deliberately not running provider factories — asking for a diagram must not open your database connections. Formatting lives in the generated script rather than in Rust, which keeps serde out for output `console.log` already has the values for. That needed an app the CLI can import without binding a port, so the starter now composes the graph in `src/app.ts` and leaves `src/main.ts` holding only the serve call. `create module` follows, preferring `src/app.ts` and falling back to `src/main.ts` so projects scaffolded before the split keep working. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012x1UPw987zNSxjH2DxHy2C
83 lines
3.4 KiB
Bash
Executable File
83 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Scaffolds a starter with the matcha binary, installs it, type-checks it, boots
|
|
# it, and asks it for its graph.
|
|
#
|
|
# This is the check the repository did not have. `cargo test` proves the CLI
|
|
# writes the files it means to write; it cannot prove those files describe a
|
|
# project the current `@green-tea/core` will run — which is exactly how the
|
|
# templates sat two core releases behind for two months without a red build.
|
|
#
|
|
# Usage: scripts/starter-smoke.sh <node|deno|bun>
|
|
set -euo pipefail
|
|
|
|
RUNTIME="${1:?usage: starter-smoke.sh <node|deno|bun>}"
|
|
MATCHA="${MATCHA:-$PWD/target/debug/matcha}"
|
|
[ -x "$MATCHA" ] || { echo "no matcha binary at $MATCHA (cargo build first)" >&2; exit 2; }
|
|
|
|
case "$RUNTIME" in
|
|
node) TEMPLATE_PORT=3000; INSTALL=(npm install); CHECK=(npx --yes tsc --noEmit) ;;
|
|
deno) TEMPLATE_PORT=8000; INSTALL=(deno install); CHECK=(deno check src/main.ts) ;;
|
|
bun) TEMPLATE_PORT=8000; INSTALL=(bun install); CHECK=(bunx --bun tsc --noEmit) ;;
|
|
*) echo "unknown runtime: $RUNTIME" >&2; exit 2 ;;
|
|
esac
|
|
|
|
# The starter hardcodes its port, so the script rewrites it to a free one rather
|
|
# than colliding with whatever the person running this already has on 3000. A
|
|
# check that only survives on a clean CI runner is a check nobody runs locally.
|
|
PORT="${PORT:-$((20000 + RANDOM % 20000))}"
|
|
|
|
WORK="$(mktemp -d)"
|
|
SERVER=""
|
|
cleanup() {
|
|
[ -n "$SERVER" ] && { pkill -P "$SERVER" 2>/dev/null || true; kill "$SERVER" 2>/dev/null || true; }
|
|
rm -rf "$WORK"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
cd "$WORK"
|
|
echo "▸ matcha new demo --runtime $RUNTIME"
|
|
"$MATCHA" new demo --runtime "$RUNTIME"
|
|
cd demo
|
|
sed -i.bak "s/$TEMPLATE_PORT/$PORT/g" src/main.ts && rm -f src/main.ts.bak
|
|
|
|
echo "▸ ${INSTALL[*]}"
|
|
"${INSTALL[@]}"
|
|
|
|
echo "▸ ${CHECK[*]}"
|
|
"${CHECK[@]}"
|
|
|
|
echo "▸ matcha run (boot on :$PORT)"
|
|
"$MATCHA" run >"$WORK/server.log" 2>&1 &
|
|
SERVER=$!
|
|
for _ in $(seq 1 60); do
|
|
curl -fsS -o /dev/null "http://localhost:$PORT/" 2>/dev/null && break
|
|
sleep 1
|
|
done
|
|
|
|
# The starter's two halves: the @Html page, and the @Sse stream that is the
|
|
# reason the starter is alive rather than a JSON hello.
|
|
code=$(curl -fsS -o /dev/null -w '%{http_code}' "http://localhost:$PORT/" 2>/dev/null || echo 000)
|
|
[ "$code" = 200 ] || { echo "GET / returned $code"; echo '--- server log ---'; cat "$WORK/server.log"; exit 1; }
|
|
# Read one frame and stop. `head -1` closing the pipe kills curl with SIGPIPE,
|
|
# which under `pipefail` fails the pipeline for a stream that arrived exactly as
|
|
# intended — hence the capture-then-compare instead of a piped `grep -q`.
|
|
zen="$(curl -fsS -N --max-time 5 "http://localhost:$PORT/zen" 2>/dev/null | head -1 || true)"
|
|
case "$zen" in
|
|
'data: {"zen":'*) ;;
|
|
*) echo "GET /zen did not stream an SSE frame (got: ${zen:-<nothing>})"; cat "$WORK/server.log"; exit 1 ;;
|
|
esac
|
|
echo "✓ serves / and streams /zen"
|
|
|
|
pkill -P "$SERVER" 2>/dev/null || true; kill "$SERVER" 2>/dev/null || true; SERVER=""
|
|
|
|
# Introspection runs against the same project, so it also proves the entry file
|
|
# the templates scaffold still exports the `app` that graph/explain import.
|
|
echo "▸ matcha graph"
|
|
"$MATCHA" graph | grep -q '^flowchart LR' || { echo "graph produced no mermaid"; exit 1; }
|
|
"$MATCHA" graph --format dot | grep -q '^digraph green_tea' || { echo "graph produced no DOT"; exit 1; }
|
|
"$MATCHA" explain /zen | grep -q '\[sse\]' || { echo "explain did not report the sse route"; exit 1; }
|
|
echo "✓ graph and explain resolve"
|
|
|
|
echo "✓ $RUNTIME starter is good"
|