Author SHA1 Message Date
chrnx 2acd4561ff chore(release): 26.11.0-rc.2
CI / installer (macos-14) (pull_request) Successful in 3s
CI / check (pull_request) Successful in 36s
CI / starter (bun) (pull_request) Successful in 41s
CI / starter (deno) (pull_request) Failing after 36s
CI / starter (edge) (pull_request) Successful in 1m8s
CI / core-freshness (pull_request) Has been skipped
CI / installer (ubuntu-latest) (pull_request) Successful in 40s
CI / starter (node) (pull_request) Successful in 3m1s
Scaffold @green-tea/core 26.11.0-rc.2, which fixes nine security advisories reported against
rc.1. Bump CORE_VERSION, the plugin scaffold test, Cargo.toml and the lockfile, and close the
CHANGELOG section with the template and README changes merged since rc.1.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-11-23 12:23:58 -06:00
chrnx af2a853855 Merge pull request 'docs(template): current generators and plugin docs in AGENTS.md' (#27) from docs/agents-plugins-llms into develop
CI / installer (macos-14) (push) Successful in 3s
CI / check (push) Successful in 31s
CI / starter (bun) (push) Successful in 45s
CI / starter (deno) (push) Successful in 37s
CI / starter (edge) (push) Successful in 55s
CI / core-freshness (push) Has been skipped
CI / starter (node) (push) Successful in 33s
CI / installer (ubuntu-latest) (push) Successful in 34s
2026-11-19 20:03:27 +00:00
chrnx 958d69dfd9 Merge branch 'develop' into docs/agents-plugins-llms
CI / installer (macos-14) (pull_request) Successful in 3s
CI / check (pull_request) Successful in 36s
CI / starter (bun) (pull_request) Successful in 43s
CI / starter (deno) (pull_request) Successful in 44s
CI / starter (edge) (pull_request) Successful in 49s
CI / core-freshness (pull_request) Has been skipped
CI / starter (node) (pull_request) Successful in 42s
CI / installer (ubuntu-latest) (pull_request) Successful in 1m2s
2026-11-19 19:59:45 +00:00
chrnx e58d230596 Merge pull request 'docs: Homebrew install via expressive-tea/tap' (#25) from docs/homebrew-install into develop
CI / check (push) Successful in 36s
CI / starter (bun) (push) Failing after 36s
CI / starter (deno) (push) Successful in 43s
CI / installer (macos-14) (push) Successful in 3s
CI / starter (edge) (push) Successful in 51s
CI / core-freshness (push) Has been skipped
CI / starter (node) (push) Successful in 42s
CI / installer (ubuntu-latest) (push) Successful in 39s
2026-11-19 19:22:41 +00:00
chrnx 8573cdfb4b Merge develop into docs/homebrew-install
CI / check (pull_request) Successful in 28s
CI / starter (edge) (pull_request) Successful in 55s
CI / installer (ubuntu-latest) (pull_request) Successful in 40s
CI / starter (bun) (pull_request) Successful in 45s
CI / installer (macos-14) (pull_request) Successful in 3s
CI / starter (deno) (pull_request) Successful in 33s
CI / starter (node) (pull_request) Successful in 38s
CI / core-freshness (pull_request) Has been skipped
2026-11-19 13:17:21 -06:00
chrnx bcd5f79990 Merge pull request 'test(smoke): kill matcha run's whole process group' (#26) from fix/smoke-kill-server-group into develop
CI / check (push) Successful in 35s
CI / installer (macos-14) (push) Successful in 3s
CI / starter (bun) (push) Successful in 33s
CI / starter (deno) (push) Successful in 44s
CI / starter (edge) (push) Successful in 46s
CI / installer (ubuntu-latest) (push) Successful in 11s
CI / core-freshness (push) Has been skipped
CI / starter (node) (push) Successful in 42s
2026-11-19 19:17:16 +00:00
chrnx 56b5d7581f docs(template): current generators and plugin docs in AGENTS.md
CI / starter (bun) (pull_request) Successful in 44s
CI / starter (deno) (pull_request) Successful in 32s
CI / starter (node) (pull_request) Successful in 35s
CI / installer (macos-14) (pull_request) Successful in 3s
CI / core-freshness (pull_request) Has been skipped
CI / starter (edge) (pull_request) Failing after 57s
CI / check (pull_request) Successful in 36s
CI / installer (ubuntu-latest) (pull_request) Successful in 11s
The scaffolded AGENTS.md listed matcha add sse|ws|upload|stream|buffer and
create controller|step|provider|module. Add cookie, transformer and create
plugin, and point agents at the official plugins' READMEs, which are their
only agent-readable docs.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-11-19 13:15:32 -06:00
chrnx 0865d9a479 test(smoke): kill matcha run's whole process group
CI / core-freshness (pull_request) Has been skipped
CI / installer (ubuntu-latest) (pull_request) Successful in 11s
CI / installer (macos-14) (pull_request) Successful in 5s
CI / check (pull_request) Successful in 37s
CI / starter (deno) (pull_request) Successful in 43s
CI / starter (edge) (pull_request) Successful in 56s
CI / starter (bun) (pull_request) Successful in 6m40s
CI / starter (node) (pull_request) Successful in 42s
On edge, wrangler's workerd is a grandchild of matcha run. pkill -P only
reached direct children, so workerd kept writing demo/.wrangler and the
cleanup's rm -rf failed with "Directory not empty" after every check had
passed. Start the server in its own process group and kill the group.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-11-19 13:09:48 -06:00
chrnx ecbd441eb4 docs: Homebrew install via expressive-tea/tap
CI / installer (macos-14) (pull_request) Successful in 5s
CI / check (pull_request) Successful in 28s
CI / starter (bun) (pull_request) Successful in 45s
CI / starter (edge) (pull_request) Failing after 56s
CI / starter (deno) (pull_request) Successful in 36s
CI / starter (node) (pull_request) Successful in 34s
CI / core-freshness (pull_request) Has been skipped
CI / installer (ubuntu-latest) (pull_request) Successful in 9s
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-11-19 12:19:35 -06:00
chrnx 53d54cf250 Merge pull request 'ci: build macOS on macos-15 on GitHub' (#24) from fix/github-macos-runner into develop
CI / installer (macos-14) (push) Successful in 3s
CI / check (push) Successful in 29s
CI / starter (bun) (push) Successful in 45s
CI / starter (deno) (push) Failing after 34s
CI / starter (edge) (push) Successful in 51s
CI / core-freshness (push) Has been skipped
CI / starter (node) (push) Successful in 36s
CI / installer (ubuntu-latest) (push) Successful in 16s
2026-11-17 23:58:20 +00:00
chrnx 64ec413c25 ci: build macOS on macos-15 on GitHub
CI / installer (macos-14) (pull_request) Successful in 3s
CI / check (pull_request) Successful in 38s
CI / starter (bun) (pull_request) Successful in 41s
CI / starter (deno) (pull_request) Failing after 36s
CI / starter (edge) (pull_request) Successful in 45s
CI / core-freshness (pull_request) Has been skipped
CI / installer (ubuntu-latest) (pull_request) Successful in 11s
CI / starter (node) (pull_request) Successful in 42s
GitHub retired the macos-14 image, so both darwin release builds for v26.11.0-rc.1 were cancelled before running a step and the GitHub release shipped without macOS binaries (uploaded afterwards from the Gitea build of the same tag). On Gitea, macos-14 is the self-hosted runner's label, so the label only changes on GitHub.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-11-17 17:53:44 -06:00
chrnx 647aef5a1b Merge pull request 'chore(release): 26.11.0-rc.1' (#22) from release/26.11.0-rc.1 into develop
Release / prepare (push) Successful in 2s
CI / starter (deno) (pull_request) Failing after 28s
CI / starter (bun) (pull_request) Successful in 45s
CI / starter (edge) (pull_request) Successful in 38s
CI / core-freshness (pull_request) Has been skipped
Release / publish-crate (push) Has been skipped
CI / starter (node) (push) Successful in 42s
CI / starter (node) (pull_request) Successful in 43s
CI / installer (ubuntu-latest) (pull_request) Successful in 12s
Release / build (macos-14, aarch64-apple-darwin) (push) Successful in 33s
CI / check (push) Successful in 35s
CI / installer (macos-14) (push) Successful in 4s
Release / build (macos-14, x86_64-apple-darwin) (push) Successful in 13s
CI / starter (bun) (push) Successful in 35s
Release / build (ubuntu-latest, aarch64-unknown-linux-musl) (push) Successful in 1m29s
CI / starter (deno) (push) Failing after 37s
Release / build (ubuntu-latest, x86_64-unknown-linux-musl) (push) Successful in 1m29s
CI / installer (macos-14) (pull_request) Successful in 5s
CI / starter (edge) (push) Successful in 40s
CI / core-freshness (push) Has been skipped
Release / promote-tag (push) Successful in 5s
Release / verify-linux-arm64 (push) Has been cancelled
CI / installer (ubuntu-latest) (push) Successful in 10s
CI / check (pull_request) Successful in 26s
Promote → GitHub / push-github (push) Successful in 5s
2026-11-17 23:40:15 +00:00
chrnx 42b5cc2616 chore(release): 26.11.0-rc.1
CI / core-freshness (pull_request) Has been skipped
CI / installer (ubuntu-latest) (pull_request) Successful in 11s
CI / starter (node) (pull_request) Successful in 42s
CI / installer (macos-14) (pull_request) Successful in 3s
CI / check (pull_request) Successful in 36s
CI / starter (bun) (pull_request) Successful in 42s
CI / starter (deno) (pull_request) Failing after 37s
CI / starter (edge) (pull_request) Successful in 44s
matcha now releases with core: this version scaffolds @green-tea/core 26.11.0-rc.1. Bump Cargo.toml and the lockfile, close the CHANGELOG section, and record the edge and core-freshness changes from #21.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-11-17 17:37:51 -06:00
chrnx 04d7a25402 Merge pull request 'feat(add,create): matcha add cookie and matcha create transformer' (#21) from feat/cookie-transformer into develop
CI / starter (deno) (push) Failing after 36s
CI / starter (edge) (push) Successful in 49s
CI / core-freshness (push) Has been skipped
CI / installer (ubuntu-latest) (push) Successful in 10s
CI / starter (node) (push) Successful in 43s
CI / installer (macos-14) (push) Successful in 3s
CI / check (push) Successful in 36s
CI / starter (bun) (push) Successful in 39s
2026-11-17 23:35:29 +00:00
chrnx 8e45c1170f feat(templates): scaffold against core 26.11.0-rc.1; edge installs core from npm
CI / check (pull_request) Successful in 36s
CI / starter (bun) (pull_request) Successful in 45s
CI / starter (deno) (pull_request) Failing after 32s
CI / starter (edge) (pull_request) Successful in 52s
CI / core-freshness (pull_request) Has been skipped
CI / starter (node) (pull_request) Successful in 35s
CI / installer (ubuntu-latest) (pull_request) Successful in 12s
CI / installer (macos-14) (pull_request) Successful in 4s
core#93 is fixed in RC.1: the npm ESM build's createRequire banner no longer throws on workerd, so the edge starter drops its .npmrc and the npm:@jsr alias and installs @green-tea/core from npm like every other runtime. doctor still reads the alias, so edge projects scaffolded before this keep working.

The weekly core-freshness job compares against core's latest dist-tag: release candidates and the stable release publish there, and beta stays on 26.9.0-beta.2.

Starter smoke passes locally on node, deno, bun and edge. Deno needs --minimum-dependency-age=0 until RC.1 is a day old.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-11-17 17:31:03 -06:00
chrnx 8bd558991d feat(add,create): matcha add cookie and matcha create transformer
CI / installer (macos-14) (pull_request) Successful in 3s
CI / check (pull_request) Successful in 27s
CI / starter (bun) (pull_request) Failing after 31s
CI / starter (deno) (pull_request) Failing after 32s
CI / starter (edge) (pull_request) Failing after 37s
CI / installer (ubuntu-latest) (pull_request) Successful in 9s
CI / core-freshness (pull_request) Has been skipped
CI / starter (node) (pull_request) Failing after 32s
add cookie reads a cookie with @cookie and sets one through a
@Transformer and setCookie, since core sends Set-Cookie only as a
header. create transformer writes a typed TransformerFn and prints how to
attach it; there is nothing to wire into a module. starter-smoke now
covers both.

add cookie uses @cookie and setCookie, which are new in core RC.1, so
this lands together with the CORE_VERSION bump.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-10-30 23:02:35 -05:00
chrnx d9f2b07802 Merge pull request 'fix(create,starters): safe names and no overwrite in create; node starter awaits listen and declares engines' (#20) from fix/create-names into develop
CI / check (push) Successful in 28s
CI / starter (bun) (push) Successful in 31s
CI / starter (deno) (push) Successful in 41s
CI / installer (ubuntu-latest) (push) Successful in 10s
CI / starter (edge) (push) Successful in 39s
CI / core-freshness (push) Has been skipped
CI / starter (node) (push) Successful in 34s
CI / installer (macos-14) (push) Successful in 3s
2026-10-31 04:00:19 +00:00
17 changed files with 202 additions and 36 deletions

No files matched your search

+5 -4
View File
@@ -65,13 +65,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Compare the scaffold pin against the beta dist-tag
- name: Compare the scaffold pin against the latest dist-tag
run: |
pinned=$(grep -oP 'CORE_VERSION: &str = "\K[^"]+' src/template.rs)
latest=$(npm view @green-tea/core dist-tags.beta)
latest=$(npm view @green-tea/core dist-tags.latest)
echo "pinned=$pinned latest=$latest"
if [ "$pinned" != "$latest" ]; then
echo "::error::matcha scaffolds @green-tea/core@$pinned but the beta tag is $latest."
echo "::error::matcha scaffolds @green-tea/core@$pinned but the latest tag is $latest."
echo "Bump CORE_VERSION in src/template.rs and let the starter job prove it still boots."
exit 1
fi
@@ -81,7 +81,8 @@ jobs:
# checks both halves that matter: a good archive installs, and a bad checksum
# aborts without leaving a binary behind.
installer:
runs-on: ${{ matrix.os }}
# macos-14 is retired on GitHub but is the self-hosted runner's label on Gitea; see release.yml.
runs-on: ${{ matrix.os == 'macos-14' && github.server_url == 'https://github.com' && 'macos-15' || matrix.os }}
strategy:
fail-fast: false
matrix:
+3 -1
View File
@@ -48,7 +48,9 @@ jobs:
os: ubuntu-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
runs-on: ${{ matrix.os }}
# GitHub retired the macos-14 image (jobs are cancelled with "configuration not supported");
# on Gitea, macos-14 is the label of the self-hosted macOS runner, so only GitHub moves.
runs-on: ${{ matrix.os == 'macos-14' && github.server_url == 'https://github.com' && 'macos-15' || matrix.os }}
steps:
- uses: actions/checkout@v5
+32 -2
View File
@@ -5,14 +5,33 @@ All notable changes to `matcha-cli` are documented here.
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
matcha uses calendar versioning: `YY.M.PATCH` — the month is not zero-padded, matching
green-tea's convention. **The CLI ships on its own version line**: `matcha` 26.8 does not
mean `@green-tea/core` 26.8, and the two release independently. The core version a scaffold
green-tea's convention. **From 26.11.0-rc.1 matcha releases with core**: `matcha` X scaffolds
`@green-tea/core` X. Before that the CLI ran on its own version line. The core version a scaffold
is pinned to is `CORE_VERSION` in `src/template.rs`, and each entry below says when it moved.
## [Unreleased]
## [26.11.0-rc.2] - 2026-11-23
### Changed
- **New projects scaffold `@green-tea/core` 26.11.0-rc.2** (`CORE_VERSION`). That core release fixes
nine security advisories reported against 26.11.0-rc.1. Projects already scaffolded should run
`npm install @green-tea/core@26.11.0-rc.2` or the equivalent for their runtime.
- The scaffolded `AGENTS.md` lists every generator: `matcha add cookie`, `matcha create transformer`
and `matcha create plugin` were missing. It also points agents at the official plugins' READMEs.
- The README documents installing with Homebrew: `brew install expressive-tea/tap/matcha`.
## [26.11.0-rc.1] - 2026-11-17
### Added
- **`matcha add cookie`** adds `GET /prefs`, which reads a cookie with `@cookie('theme')`, and
`POST /prefs`, which sets it through a `@Transformer` and `setCookie()`. Core has no response-cookie
API, so the transformer is where a `Set-Cookie` header is sent. Needs `@green-tea/core` RC.1.
- **`matcha create transformer <Name>`** writes `src/transformers/<name>.transformer.ts`, a typed
`TransformerFn`, and prints the `@Transformer(...)` line that attaches it. A transformer belongs to
a route, not a module, so there is nothing to wire.
- **Every starter ships an `AGENTS.md` and a `CLAUDE.md` that imports it.** green-tea is new, so a
coding agent falls back on Express habits. The file states the rules that differ: it is a graph, not a
chain, a handler declares its needs in its signature, and the graph is checked at boot. It also points
@@ -30,6 +49,13 @@ is pinned to is `CORE_VERSION` in `src/template.rs`, and each entry below says w
### Changed
- **Scaffolds pin `@green-tea/core` 26.11.0-rc.1**, the API-freeze release candidate, and matcha's own
version now matches it.
- **The edge starter installs core from npm.** core#93 is fixed in RC.1, so the `.npmrc` and the
`npm:@jsr/green-tea__core` alias are gone. `matcha doctor` still reads the alias, so edge projects
scaffolded before this keep working.
- The weekly `core-freshness` CI job compares `CORE_VERSION` against core's `latest` dist-tag, where
release candidates and the stable release publish. `beta` stays on 26.9.0-beta.2.
- Introspection runs through one query layer (`src/introspect.rs`): every command asks one
question and gets one JSON document back, then renders it as text unless `--json` is passed.
Text output is unchanged. The layer is also the seam a future `matcha mcp` would serve over
@@ -249,6 +275,10 @@ First tagged release. A single native binary, no JS runtime needed to install it
- **A `curl | sh` installer** with sha256 verification, and cross-platform binaries attached
to each release.
[Unreleased]: https://github.com/Expressive-Tea/matcha/compare/v26.11.0-rc.2...HEAD
[26.11.0-rc.2]: https://github.com/Expressive-Tea/matcha/compare/v26.11.0-rc.1...v26.11.0-rc.2
[26.11.0-rc.1]: https://github.com/Expressive-Tea/matcha/compare/v26.9.0-beta.1...v26.11.0-rc.1
[26.9.0-beta.1]: https://github.com/Expressive-Tea/matcha/compare/v26.9.0-beta.0...v26.9.0-beta.1
[26.9.0-beta.0]: https://github.com/Expressive-Tea/matcha/compare/v26.8.0-beta.0...v26.9.0-beta.0
[26.8.0-beta.0]: https://github.com/Expressive-Tea/matcha/compare/v26.7.0...v26.8.0-beta.0
[26.7.0]: https://github.com/Expressive-Tea/matcha/releases/tag/v26.7.0
+1 -1
View File
@@ -126,7 +126,7 @@ scripts/starter-smoke.sh <the runtime you touched>
```
CI runs the smoke for all four runtimes on a matrix, plus a weekly `core-freshness` job
that fails when `CORE_VERSION` in `src/template.rs` falls behind core's `beta` dist-tag.
that fails when `CORE_VERSION` in `src/template.rs` falls behind core's `latest` dist-tag.
**Non-trivial logic leaves a check behind.** Not a suite — the smallest thing that fails if
the logic breaks. A generator gets a test that the generated code carries what it must; a
Generated
+1 -1
View File
@@ -260,7 +260,7 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
[[package]]
name = "matcha-cli"
version = "26.9.0-beta.1"
version = "26.11.0-rc.2"
dependencies = [
"assert_cmd",
"clap",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "matcha-cli"
version = "26.9.0-beta.1"
version = "26.11.0-rc.2"
edition = "2021"
description = "The green-tea CLI: scaffold a project, generate controllers, steps and providers already wired into their module, and run with your runtime detected. One native binary, no JS runtime needed to install it."
license = "MIT"
+8 -6
View File
@@ -11,6 +11,12 @@ cargo install matcha-cli
Builds from [crates.io](https://crates.io/crates/matcha-cli) and installs the `matcha`
binary. Needs a Rust toolchain; takes a few seconds.
**Homebrew** (macOS, Linux):
```bash
brew install expressive-tea/tap/matcha
```
**Prebuilt binary** (no Rust), from the latest GitHub release:
```bash
@@ -70,7 +76,7 @@ prerelease-only, and npm's semver excludes a prerelease from any range whose
comparators carry a different `major.minor.patch` — so `^26.7.0-beta.0` never
resolves past `26.7.0-beta.0` however many betas ship after it. CI scaffolds,
installs, boots and introspects a real starter on every runtime, and a weekly
job fails when the pin falls behind the `beta` dist-tag.
job fails when the pin falls behind the `latest` dist-tag.
### Introspection
@@ -194,11 +200,7 @@ which boots real workerd locally.
Two differences the edge cannot hide. `@Html('file')`, `static` and multipart
uploads need a filesystem workerd does not have, and shutdown teardown never
runs — an isolate is discarded, not closed. And core is installed from **JSR**
here rather than npm: the npm ESM build carries a `createRequire(import.meta.url)`
banner that throws at load on workerd. The scaffolded `.npmrc` says so and links
[the issue](https://github.com/Expressive-Tea/green-tea/issues/93); both it and
the alias can go once that is fixed.
runs — an isolate is discarded, not closed.
## Development
+16 -4
View File
@@ -8,7 +8,7 @@
# 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>
# Usage: scripts/starter-smoke.sh <node|deno|bun|edge>
set -euo pipefail
RUNTIME="${1:?usage: starter-smoke.sh <node|deno|bun|edge>}"
@@ -30,8 +30,17 @@ PORT="${PORT:-$((20000 + RANDOM % 20000))}"
WORK="$(mktemp -d)"
SERVER=""
# `matcha run` is started in its own process group (set -m below) so the whole tree dies
# together. `pkill -P` reached only direct children: on edge, wrangler's workerd is a
# grandchild, kept writing demo/.wrangler, and `rm -rf` failed with "Directory not empty".
stop_server() {
[ -n "$SERVER" ] || return 0
kill -- -"$SERVER" 2>/dev/null || true
wait "$SERVER" 2>/dev/null || true
SERVER=""
}
cleanup() {
[ -n "$SERVER" ] && { pkill -P "$SERVER" 2>/dev/null || true; kill "$SERVER" 2>/dev/null || true; }
stop_server
rm -rf "$WORK"
}
trap cleanup EXIT
@@ -55,8 +64,10 @@ echo "▸ ${CHECK[*]}"
"${CHECK[@]}"
echo "▸ matcha run (boot on :$PORT)"
set -m
"$MATCHA" run >"$WORK/server.log" 2>&1 &
SERVER=$!
set +m
for _ in $(seq 1 60); do
curl -fsS -o /dev/null "http://localhost:$PORT/" 2>/dev/null && break
sleep 1
@@ -78,7 +89,7 @@ case "$zen" in
esac
echo "✓ serves / and streams /zen"
pkill -P "$SERVER" 2>/dev/null || true; kill "$SERVER" 2>/dev/null || true; SERVER=""
stop_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.
@@ -96,9 +107,10 @@ echo "✓ graph, explain and openapi resolve"
# core lazy-requires `ws` and `busboy`, so neither is needed to compile, and a
# check that needed them would be hiding that fact.
echo "▸ matcha add (every capability)"
for cap in sse ws upload stream buffer; do
for cap in sse ws upload stream buffer cookie; do
"$MATCHA" add "$cap" >/dev/null || { echo "matcha add $cap failed"; exit 1; }
done
"$MATCHA" create transformer Csv >/dev/null || { echo "matcha create transformer failed"; exit 1; }
"${CHECK[@]}" || { echo "the generated handlers do not type-check"; exit 1; }
echo "✓ every add capability type-checks"
+33
View File
@@ -139,6 +139,39 @@ const CAPABILITIES: &[Capability] = &[
marker: "'/upload'",
peer: Some(("busboy", "every runtime")),
},
Capability {
name: "cookie",
// Reading is a decorator. Writing is a `Set-Cookie` header, which core only builds
// (`setCookie`) and a transformer sends: core has no response-cookie API of its own.
imports: &["Get", "Post", "Transformer", "body", "cookie", "setCookie"],
type_imports: &[],
method: r#"
@Get('/prefs')
prefs(@cookie('theme') theme?: string) {
return { theme: theme ?? 'light' };
}
@Post('/prefs')
@Transformer((value) => {
const { theme } = value as { theme: string };
return {
status: 200,
headers: {
'content-type': 'application/json',
// Secure and HttpOnly are on by default. Safari, a LAN IP or a plain-HTTP host other
// than localhost drops a Secure cookie: pass `secure: false` there in development.
'set-cookie': setCookie('theme', encodeURIComponent(theme), { maxAge: 60 * 60 * 24 * 365 }),
},
body: JSON.stringify({ theme }),
};
})
savePrefs(@body('theme') theme: string) {
return { theme };
}
"#,
marker: "'/prefs'",
peer: None,
},
];
/// The capability names, for clap's `value_parser` and for error messages.
+32 -1
View File
@@ -56,7 +56,7 @@ pub fn kinds() -> Vec<&'static str> {
["module"]
.into_iter()
.chain(PIECES.iter().map(|p| p.kind))
.chain(["plugin"])
.chain(["transformer", "plugin"])
.collect()
}
@@ -121,6 +121,9 @@ pub fn run(kind: &str, name: &str, check: bool) -> std::io::Result<()> {
if kind == "module" {
return create_module(name, check);
}
if kind == "transformer" {
return create_transformer(name, check);
}
match PIECES.iter().find(|p| p.kind == kind) {
Some(piece) => create_piece(name, check, piece),
None => Err(Error::new(
@@ -200,6 +203,34 @@ fn create_module(name: &str, check: bool) -> std::io::Result<()> {
maybe_check(check)
}
/// Writes `src/transformers/<name>.transformer.ts`. Nothing to wire: a transformer is attached
/// per route with `@Transformer`, so the hint says where it goes instead.
fn create_transformer(name: &str, check: bool) -> std::io::Result<()> {
let lower = name.to_lowercase();
let file = Path::new("src/transformers").join(format!("{lower}.transformer.ts"));
let symbol = format!("{}Transformer", token(name));
write_new(&file, transformer_stub(&symbol))?;
println!("✓ {}", file.display());
println!(
"→ attach it to a route: @Transformer({symbol}), imported from './transformers/{lower}.transformer'"
);
maybe_check(check)
}
fn transformer_stub(symbol: &str) -> String {
format!(
"import type {{ TransformerFn }} from '@green-tea/core';\n\n\
/**\n * Turns what a handler returns into the response. Attach it to a route with\n\
* `@Transformer({symbol})`; routes without one use the default JSON transformer.\n\
* Set the status and headers here (`set-cookie` takes an array, one header per cookie).\n */\n\
export const {symbol}: TransformerFn = (value) => ({{\n\
status: 200,\n\
headers: {{ 'content-type': 'application/json' }},\n\
body: JSON.stringify(value),\n\
}});\n"
)
}
pub(crate) fn maybe_check(check: bool) -> std::io::Result<()> {
if check {
match crate::check::run(Path::new(".")) {
+2 -2
View File
@@ -13,8 +13,8 @@ use crate::runtime::Runtime;
/// pin to the oldest matching prerelease that nothing can move off. When core
/// reaches a stable major this becomes a range (`^27`) and the exactness stops
/// mattering; until then the `core-freshness` CI job fails when this falls
/// behind the `beta` dist-tag, which is what keeps it current.
pub const CORE_VERSION: &str = "26.9.0-beta.2";
/// behind the `latest` dist-tag, which is what keeps it current.
pub const CORE_VERSION: &str = "26.11.0-rc.2";
pub static SHARED: Dir = include_dir!("$CARGO_MANIFEST_DIR/template/shared");
pub static RUNTIME_DENO: Dir = include_dir!("$CARGO_MANIFEST_DIR/template/runtimes/deno");
-9
View File
@@ -1,9 +0,0 @@
# core is installed from JSR here, and from npm on every other runtime.
#
# Not a preference: the npm ESM build carries tsup's
# `createRequire(import.meta.url)` banner at module scope, and `import.meta.url`
# is undefined on workerd — so `@green-tea/core/edge` throws at load, before any
# of its own code runs. JSR publishes transpiled source with no bundler and no
# banner, and boots clean. See Green-Tea/core#93; once that is fixed this file
# and the `npm:@jsr/...` alias in package.json can both go.
@jsr:registry=https://npm.jsr.io
+1 -1
View File
@@ -4,6 +4,6 @@
"private": true,
"engines": { "node": ">=22" },
"scripts": { "dev": "wrangler dev", "deploy": "wrangler deploy" },
"dependencies": { "@green-tea/core": "npm:@jsr/green-tea__core@{{core_version}}" },
"dependencies": { "@green-tea/core": "{{core_version}}" },
"devDependencies": { "tsx": "^4", "typescript": "^5", "wrangler": "^4" }
}
+6 -2
View File
@@ -38,8 +38,9 @@ matcha graph --format json # the whole graph
- `src/app.ts` builds and exports `app` (`createApp({ modules: [...] })`). Introspection and tests import it.
- `src/main.ts` serves `app`. It is the only file that differs per runtime.
- `src/app.module.ts` lists the providers, steps and controllers with `@Module`.
- `matcha create controller|step|provider|module <Name>` generates a piece and wires it into the module.
- `matcha add sse|ws|upload|stream|buffer` adds a capability to a controller.
- `matcha create controller|step|provider|module|transformer <Name>` generates a piece and wires it into the module.
- `matcha create plugin` scaffolds a plugin, in-app or (`--package`) as its own package.
- `matcha add sse|stream|buffer|ws|upload|cookie` adds a capability to a controller.
## Check your work
@@ -55,4 +56,7 @@ itself:
- npm / Bun: `node_modules/@green-tea/core/llms.txt`
- Deno (JSR): `https://jsr.io/@green-tea/core/{{core_version}}/llms.txt`
Official plugins (`@green-tea/jwt`, `@green-tea/metrics`, `@green-tea/rate-limit`, ...) ship no llms.txt;
read the installed one's `node_modules/@green-tea/<name>/README.md`.
The complete docs as one file: https://green-tea.expressive-tea.io/docs/llms-full.txt
+34
View File
@@ -199,3 +199,37 @@ fn add_rejects_a_controller_path_that_does_not_exist() {
.failure()
.stderr(predicates::str::contains("no such controller"));
}
#[test]
fn add_cookie_reads_with_the_decorator_and_writes_through_a_transformer() {
let d = tempdir().unwrap();
std::fs::create_dir_all(d.path().join("src/controllers")).unwrap();
std::fs::write(
d.path().join("src/controllers/home.controller.ts"),
"import { Route, Get } from '@green-tea/core';\n\n\
@Route('/')\nexport class HomeController {\n @Get('/')\n home() {}\n}\n",
)
.unwrap();
for _ in 0..2 {
Command::cargo_bin("matcha")
.unwrap()
.current_dir(d.path())
.args(["add", "cookie"])
.assert()
.success();
}
let out = std::fs::read_to_string(d.path().join("src/controllers/home.controller.ts")).unwrap();
assert!(out.contains("@cookie('theme')"), "{out}");
assert!(out.contains("'set-cookie': setCookie("), "{out}");
for symbol in ["Post", "Transformer", "body", "cookie", "setCookie"] {
assert!(
out.contains(&format!("{symbol},")) || out.contains(&format!("{symbol} }}")),
"{symbol} not imported:\n{out}"
);
}
assert_eq!(
out.matches("@Post('/prefs')").count(),
1,
"not idempotent:\n{out}"
);
}
+26
View File
@@ -170,3 +170,29 @@ fn create_does_not_overwrite_an_existing_file() {
.stderr(predicates::str::contains("already exists"));
assert_eq!(std::fs::read_to_string(&file).unwrap(), "// edited\n");
}
#[test]
fn create_transformer_writes_a_typed_function_and_says_where_it_goes() {
let d = tempdir().unwrap();
seed_module(d.path());
create(d.path(), "transformer", "csv-export")
.success()
.stdout(predicates::str::contains(
"@Transformer(csvExportTransformer)",
));
let file = std::fs::read_to_string(d.path().join("src/transformers/csvexport.transformer.ts"))
.unwrap();
assert!(
file.contains("import type { TransformerFn } from '@green-tea/core'"),
"{file}"
);
assert!(
file.contains("export const csvExportTransformer: TransformerFn"),
"{file}"
);
let module = std::fs::read_to_string(d.path().join("src/app.module.ts")).unwrap();
assert!(
!module.contains("Transformer"),
"a transformer is not a module member:\n{module}"
);
}
+1 -1
View File
@@ -191,7 +191,7 @@ fn package_jsr_writes_the_tree_into_dir() {
);
let deno = std::fs::read_to_string(pkg.join("deno.json")).unwrap();
assert!(deno.contains("\"name\": \"@acme/plugin-algo\""), "{deno}");
assert!(deno.contains("npm:@green-tea/core@26.9.0-beta.2"), "{deno}");
assert!(deno.contains("npm:@green-tea/core@26.11.0-rc.2"), "{deno}");
// Without it `deno test` needs a `deno install` first, and then fails to
// type-check `node:assert` for want of @types/node.
assert!(deno.contains("\"nodeModulesDir\": \"auto\""), "{deno}");