5.9 KiB
matcha — multi-runtime starter (node/deno/bun) · Spec
Date: 2026-07-12
Branch: feature/matcha-multi-runtime (off develop)
Goal: matcha new <name> --runtime <node|deno|bun> scaffolds the starter for the chosen runtime. Shared app files are written once; only main.ts + runtime config + matcha.toml differ per runtime. Default runtime: node (green-tea is developed node-first; Node is the reference implementation. deno/bun via --runtime).
Verified framework facts (from Green-Tea/core)
@green-tea/coreimportsreflect-metadatainternally (src/index.ts:6) — consumers need NO explicit import; it installs transitively with the package.- Serve per runtime: Node
app.listen(3000); DenoDeno.serve({ port }, app.fetch); BunBun.serve({ port, fetch: app.fetch }). Starter has no WebSocket, soapp.fetchis sufficient (noserveDeno/serveBun). @Modulerequiresmountpoint. Package version pin:^26.7.0-beta.0.
New template layout (replaces template/starter/)
template/
shared/
public/index.html
src/app.module.ts
src/controllers/home.controller.ts
runtimes/
deno/ { matcha.toml, deno.json, src/main.ts }
node/ { matcha.toml, package.json, tsconfig.json, src/main.ts }
bun/ { matcha.toml, package.json, tsconfig.json, src/main.ts }
write_starter writes shared then overlays the chosen runtime dir on top (both go into the same project dir; src/main.ts from the overlay lands beside src/app.module.ts from shared). Token substitution {{project_name}} applies to every copied file (now also package.json "name").
Exact file contents
shared/ (moved verbatim from current template/starter/)
public/index.html— unchanged (keep{{project_name}}title +EventSource('/zen')).src/app.module.ts— unchanged (@Module({ mountpoint: '/', controllers: [HomeController] })).src/controllers/home.controller.ts— unchanged (@Route('/'),@Get('/') @Html('public/index.html'),@Sse('/zen')rotating zen every 30s).
runtimes/deno/ (moved from current starter)
matcha.toml:runtime = "deno"deno.json(unchanged from current starter):
{
"compilerOptions": { "experimentalDecorators": true },
"unstable": ["sloppy-imports"],
"imports": { "@green-tea/core": "npm:@green-tea/core@^26.7.0-beta.0" },
"tasks": { "dev": "deno run --watch --allow-net --allow-read --allow-env src/main.ts" }
}
src/main.ts:
import { createApp } from '@green-tea/core';
import { AppModule } from './app.module';
const app = createApp({ modules: [AppModule] });
Deno.serve({ port: 8000 }, app.fetch);
console.log('🍵 green-tea running on http://localhost:8000');
runtimes/node/
matcha.toml:runtime = "node"package.json:
{
"name": "{{project_name}}",
"type": "module",
"private": true,
"scripts": { "dev": "tsx watch src/main.ts" },
"dependencies": { "@green-tea/core": "^26.7.0-beta.0" },
"devDependencies": { "tsx": "^4", "typescript": "^5" }
}
tsconfig.json:
{
"compilerOptions": {
"target": "es2020",
"module": "esnext",
"moduleResolution": "bundler",
"experimentalDecorators": true,
"strict": true,
"skipLibCheck": true
}
}
src/main.ts:
import { createApp } from '@green-tea/core';
import { AppModule } from './app.module';
const app = createApp({ modules: [AppModule] });
app.listen(3000);
console.log('🍵 green-tea running on http://localhost:3000');
runtimes/bun/
matcha.toml:runtime = "bun"package.json:
{
"name": "{{project_name}}",
"type": "module",
"private": true,
"scripts": { "dev": "bun --watch run src/main.ts" },
"dependencies": { "@green-tea/core": "^26.7.0-beta.0" }
}
tsconfig.json:
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "bundler",
"experimentalDecorators": true,
"strict": true,
"skipLibCheck": true
}
}
src/main.ts:
import { createApp } from '@green-tea/core';
import { AppModule } from './app.module';
const app = createApp({ modules: [AppModule] });
Bun.serve({ port: 8000, fetch: app.fetch });
console.log('🍵 green-tea running on http://localhost:8000');
Code changes
src/template.rs
- Replace the single
STARTERembed withSHARED+ three runtime overlays (include_dir!each). pub fn write_starter(dest: &Path, project_name: &str, runtime: Runtime) -> io::Result<()>— writeSHARED, then the overlay forruntime. Keepwrite_dirsubstitution logic.
src/cli.rs
Command::Newgains#[arg(long, default_value = "deno", value_parser = ["node", "deno", "bun"])] runtime: String.
src/cmd_new.rs
run(name, template_url, runtime: &str): parseruntimeviaRuntime::from_str(already inruntime.rs); for the starter (no--template-url) path, callwrite_starter(dest, name, rt).--template-urlpath ignores--runtime.
src/cmd_run.rs
- Change the Bun mapping from
("bun", vec!["--watch", "run", "dev"])to("bun", vec!["run", "dev"])so all three uniformly run theirdevscript (deno.json/package.json define the watch). Update thebun_watchunit test accordingly.
src/main.rs
- Pass the new
runtimearg through theCommand::Newdispatch.
Tests
template.rs: parametrize the write test — assert deno writesdeno.json+src/main.tscontainingDeno.serve; node writespackage.json(with substituted name) +tsconfig.json+main.tscontainingapp.listen; bun writespackage.json+main.tscontainingBun.serve. All three write the sharedsrc/app.module.tsandpublic/index.html.tests/new.rs:matcha new demo --runtime nodeproducespackage.jsonwith"name": "demo"and nodeno.json; default (no flag) producesdeno.json.cmd_run.rs: bun mapping test expects("bun", vec!["run", "dev"]).
Out of scope
Edge starter (deploy target, not run). Per-runtime lockfiles. serveDeno/serveBun (no WS in starter).