Compare commits

...
5 Commits
Author SHA1 Message Date
chrnx ea25331631 Merge pull request 'chore(plugins): publish to JSR alone, and drop the npm build' (#5) from chore/jsr-only-plugins into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 10s
CI / build (push) Successful in 14s
CI / runtimes (deno) (push) Successful in 10s
CI / runtimes (edge) (push) Successful in 9s
2026-09-23 16:35:02 +00:00
chrnx 686a4527cf docs(plugins): give each package a header, and stop leaning on a marketplace
CI / dco (pull_request) Successful in 7s
CI / build (pull_request) Successful in 12s
CI / runtimes (bun) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 11s
CI / runtimes (edge) (pull_request) Successful in 10s
Each README now opens the way core's does — logo, name, one line saying what
the package is for. The package README is the page JSR renders, so it is the
first thing anyone sees, and three of them opened with a bare `# @green-tea/x`.

The logo is an absolute URL rather than a relative path, deliberately. Core's
README points at `./assets/logo.png`, and core's `publish.include` does not ship
`assets/` — so that image 404s on core's JSR page today. Repeating the pattern
three more times would have repeated the bug three more times.

Also drops the claim that npmjs.org discovery does not matter "where the
marketplace is the channel anyway". There is no marketplace yet, and a plugin
should stand on its own rather than on a site that has not shipped. The cost is
now stated plainly instead of argued away.

Corrects "their built code never imports it": with JSR publishing the source,
the build is JSR's, not ours. What holds is that a type import leaves nothing
behind, so the published JavaScript never mentions core.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-23 11:24:09 -05:00
chrnx 16f8329794 docs(plugins): say how to install now that npm is not an option
CI / dco (pull_request) Successful in 5s
CI / build (pull_request) Successful in 15s
CI / runtimes (bun) (pull_request) Successful in 11s
CI / runtimes (edge) (pull_request) Successful in 9s
CI / runtimes (deno) (pull_request) Successful in 11s
The READMEs still described a dual publish, and none of them carried an install
command at all — so the instruction a reader would infer, `npm i
@green-tea/jwt`, is the one command that no longer works. Each package README is
also the page JSR renders, which makes it the first thing anyone sees.

Adds `npx jsr add` to all three, with the deno and bun forms, and says plainly
that there is no npmjs.org package rather than letting someone find out from a
404.

Also corrects a claim in the root README that this branch made false: "installing
one never pulls a second copy of core". Measured while deciding this change — a
plugin names an exact core in `deno.json`, and across a minor boundary npm nests
a second copy instead of deduplicating. The copy is inert, since a plugin's built
code never imports core, and that is worth saying precisely: what is guaranteed
is which core *runs*, not how many are on disk.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-23 10:26:10 -05:00
chrnx 8499aaa760 fix(ci): resolve core from npm, not Verdaccio
CI / dco (pull_request) Successful in 6s
CI / runtimes (deno) (pull_request) Successful in 12s
CI / build (pull_request) Successful in 14s
CI / runtimes (bun) (pull_request) Successful in 11s
CI / runtimes (edge) (pull_request) Successful in 9s
`npm ci` has been failing on `develop` with `EINTEGRITY` for `@green-tea/core`,
independently of any branch — verified by running it on a clean clone of
`develop` before touching anything. Every job that installs was red; only `dco`,
which does not, was green.

Verdaccio proxies npmjs.org. When core 26.9.0-beta.2 was published for real on
2026-09-22, the staged tarball under the same version was superseded by the
upstream one, and the integrity recorded in the lockfile stopped matching what
the registry serves. Nothing in this repository changed; the thing it pinned
did.

`.npmrc` existed only because that version lived on Verdaccio alone, which its
own comment said would end at Plan B3. It ended early: core is on npmjs.org, so
the scope line goes and the lockfile now resolves from
`registry.npmjs.org` with the integrity npm published.

The `if:` guards keeping CI on Gitea stay. Their stated reason is gone — a
GitHub runner can reach npm — but turning CI on over there is its own change,
and the repository has no GitHub mirror yet.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-23 10:21:53 -05:00
chrnx 4caf8809df chore(plugins): publish to JSR alone, and drop the npm build
CI / dco (pull_request) Successful in 4s
CI / build (pull_request) Failing after 8s
CI / runtimes (bun) (pull_request) Failing after 7s
CI / runtimes (deno) (pull_request) Failing after 9s
CI / runtimes (edge) (pull_request) Failing after 7s
The second registry was costing a tsup config per package, a dual `exports`
map and a `dist/` that could go stale between a merge and a release — and it
was not buying a reader anything. `npx jsr add @green-tea/<name>` installs
under npm, yarn, pnpm and bun through `npm.jsr.io`: one line in `.npmrc`, and
the import specifier stays `@green-tea/<name>`. The `@jsr/` name only ever
appears in the lockfile.

Nothing is published yet — all three packages are absent from both registries
— so this costs no consumer anything, and it is the reversible direction:
adding npm later breaks nobody, while removing it after a publish would.

JSR is also the only one of the two that can record *where a plugin runs*, per
package, which is not cosmetic for a framework whose claim is one app on four
runtimes. `jwt` needs `node:fs/promises` and cannot serve workerd; `metrics`
imports nothing and runs everywhere. npm has nowhere to put that.

`private: true` stays and becomes the guard: an accidental `npm publish` now
fails rather than shipping entry points that describe a build nobody runs.
`test/workspace.test.ts` pins that invariant instead of the dual-registry one.

The CI job keeps the name `build` deliberately — renaming it would change a
required status check on the protected branches, which is a separate change.
`deno publish --dry-run` in the `runtimes` job now stands in for the build, and
it is the publish path these packages actually take.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-23 10:13:39 -05:00
16 changed files with 235 additions and 1599 deletions

No files matched your search

+3 -4
View File
@@ -55,10 +55,9 @@ jobs:
- run: npm run complexity:check - run: npm run complexity:check
- run: npm run typecheck - run: npm run typecheck
- run: npm test - run: npm test
# The npm tarball is a build artifact, so a broken build is a broken release. `typecheck` will # No build step: JSR publishes `src/` and transpiles it. `deno publish --dry-run`, in the
# not catch it: that runs with `noEmit`, and tsup emits through esbuild, which resolves and # `runtimes` job below, is what stands in for it — that is the publish path these packages
# bundles on its own terms. # actually take.
- run: npm run build
# A fixed matrix, not `fromJSON`: Gitea Actions support for a dynamic matrix was not verified. Each # A fixed matrix, not `fromJSON`: Gitea Actions support for a dynamic matrix was not verified. Each
# entry runs only the packages whose engines name that runtime (scripts/run-runtime.mjs). # entry runs only the packages whose engines name that runtime (scripts/run-runtime.mjs).
-4
View File
@@ -1,4 +0,0 @@
# The @green-tea scope resolves from Verdaccio while core 26.9.0-beta.2 exists only there. The token is
# not here: it comes from ~/.npmrc locally and from the NPM_AUTH secret in CI. Plan B3 removes this line
# when the packages move to a core published on npm.
@green-tea:registry=https://npm.svc.zoit.services/
+26 -9
View File
@@ -18,7 +18,6 @@ npm run typecheck
npm test # Node: every package's contract tests + the workspace checks npm test # Node: every package's contract tests + the workspace checks
npm run test:deno # packages whose engines declare deno npm run test:deno # packages whose engines declare deno
npm run test:bun # packages whose engines declare bun npm run test:bun # packages whose engines declare bun
npm run build # tsup, every package: dist/ as CJS + ESM + declarations, for npm only
``` ```
Run all of them before proposing anything as finished. CI runs each one and each gates a merge. Run all of them before proposing anything as finished. CI runs each one and each gates a merge.
@@ -26,8 +25,10 @@ Run all of them before proposing anything as finished. CI runs each one and each
## Two forges ## Two forges
Gitea `Green-Tea/plugins` is the origin. `develop` and `main` are protected; everything lands through Gitea `Green-Tea/plugins` is the origin. `develop` and `main` are protected; everything lands through
a pull request. Until core is consumed from npm (Plan B3), CI runs on Gitea only, because a pull request. CI still runs on Gitea only, through the `if:` guards in `ci.yml` — but the reason
`@green-tea/core` comes from Verdaccio, which a GitHub runner cannot reach. is gone: `@green-tea/core@26.9.0-beta.2` shipped to npmjs.org on 2026-09-22, so the packages no
longer need Verdaccio and a GitHub runner can now resolve them. Removing those guards and adding the
mirror is Plan B3, and it is unblocked rather than done.
## The plugin convention ## The plugin convention
@@ -49,12 +50,28 @@ a pull request. Until core is consumed from npm (Plan B3), CI runs on Gitea only
beside every one that is not supported. Nobody should have to open an issue to learn where a beside every one that is not supported. Nobody should have to open an issue to learn where a
plugin runs. plugin runs.
10. A breaking change goes under `### Breaking`, first in the package's CHANGELOG. 10. A breaking change goes under `### Breaking`, first in the package's CHANGELOG.
11. **The two registries are served different things.** `deno.json` exports `./src/index.ts`, because 11. **Plugins publish to JSR alone.** `deno.json` exports `./src/index.ts` and there is no build:
JSR transpiles TypeScript itself and hands Node a typed ESM package. `package.json` exports JSR transpiles the TypeScript itself and hands consumers a typed ESM package with generated
`./dist/`, built by tsup as CJS *and* ESM, because npm transpiles nothing and Node refuses to declarations. Every `package.json` here stays `private`, so an accidental `npm publish` fails
strip types under `node_modules` — `--experimental-strip-types` does not lift that, so a package rather than shipping entry points that describe a `dist/` nobody produces. `test/workspace.test.ts`
exporting `.ts` installs cleanly and then throws on the first import, everywhere but Bun. pins that.
`test/workspace.test.ts` pins both halves.
The second registry was dropped because it was not buying a reader anything. `npx jsr add
@green-tea/<name>` installs under npm, yarn, pnpm and bun via `npm.jsr.io` — one line in
`.npmrc`, and the import specifier stays `@green-tea/<name>`; the `@jsr/` name appears only in
the lockfile. What it cost was a tsup config per package, a dual `exports` map, and a `dist/`
that could go stale between a merge and a release.
JSR is also the only one of the two that can say **where a plugin runs**. Its `runtimeCompat` is
per package, which matters for a framework whose claim is one app on four runtimes: `jwt` needs
`node:fs/promises` and cannot serve workerd, while `metrics` imports nothing and runs everywhere.
npm has nowhere to record that difference, so rule 9's `engines`/README pair was the only place
it lived. It is declared in the JSR package settings, not in `deno.json` — the config schema
accepts `name`, `version`, `license`, `exports` and `publish`, and nothing else.
What this gives up, stated plainly rather than argued away: nobody searching npmjs.org will find
these, and a site behind a registry proxy that mirrors npmjs.org and refuses to add a second one
cannot install them at all. Core still can — it publishes to both.
## Conventions ## Conventions
+36 -5
View File
@@ -1,8 +1,31 @@
# green-tea plugins <p align="center">
<img src="https://raw.githubusercontent.com/Expressive-Tea/green-tea/main/assets/logo.png" width="96" alt="Green Tea" />
</p>
<h1 align="center">green&nbsp;tea plugins.</h1>
<p align="center"><b>Each one is a node in the graph, not a link in a chain.</b></p>
<p align="center">
A plugin declares what it provides; your route declares what it needs.<br />
Nothing runs for a route that never asked for it.
</p>
---
Official plugins for [green-tea](https://github.com/Expressive-Tea/green-tea). Each one is its own Official plugins for [green-tea](https://github.com/Expressive-Tea/green-tea). Each one is its own
package under `packages/`, published to npm and JSR, and each README says which runtimes it supports package under `packages/`, published to JSR, and each README says which runtimes it supports and why
and why not the others. not the others.
```bash
npx jsr add @green-tea/jwt # npm, and the same command for yarn and pnpm
deno add jsr:@green-tea/jwt
bunx jsr add @green-tea/jwt
```
That works under every package manager: `jsr add` writes one line to `.npmrc` and installs through
`npm.jsr.io`, so the import stays `@green-tea/jwt` and nothing in your code mentions JSR. A plain
`npm i @green-tea/jwt` will **not** work — these packages are not on npmjs.org.
| Package | What it does | | Package | What it does |
|---|---| |---|---|
@@ -10,5 +33,13 @@ and why not the others.
| [`@green-tea/rate-limit`](packages/rate-limit) | A per-request limiter with a branded `429` and a swept in-memory store | | [`@green-tea/rate-limit`](packages/rate-limit) | A per-request limiter with a branded `429` and a swept in-memory store |
| [`@green-tea/metrics`](packages/metrics) | Counts the lifecycle stream and renders the Prometheus text format | | [`@green-tea/metrics`](packages/metrics) | Counts the lifecycle stream and renders the Prometheus text format |
Plugins import core as types only, so installing one never pulls a second copy of core — and never Plugins import core as types only, and a type import leaves nothing behind when it compiles — the
warns about a version range, which under CalVer no range can express. JavaScript JSR publishes never mentions core. So the core that runs is always your application's,
whatever version a plugin was written against, and nothing warns about a version range, which under
CalVer no range can express.
That is about *loading*, not about disk. A plugin names an exact core in its `deno.json`, and when
your version differs by more than the patch, npm places a second copy under the plugin rather than
deduplicating. Measured, on purpose: it is inert, because nothing ever imports it. What it can do
is make `tsc` resolve a plugin's `Plugin` type against that copy instead of yours, which fails
loudly at compile time rather than quietly at runtime.
+75 -1428
View File
File diff suppressed because it is too large. Load diff
-2
View File
@@ -10,7 +10,6 @@
"node": ">=22" "node": ">=22"
}, },
"scripts": { "scripts": {
"build": "npm run build --workspaces",
"lint": "eslint --no-error-on-unmatched-pattern packages test", "lint": "eslint --no-error-on-unmatched-pattern packages test",
"format": "prettier --write \"packages/*/{src,test}/**/*.ts\" \"test/**/*.ts\"", "format": "prettier --write \"packages/*/{src,test}/**/*.ts\" \"test/**/*.ts\"",
"format:check": "prettier --check \"packages/*/{src,test}/**/*.ts\" \"test/**/*.ts\"", "format:check": "prettier --check \"packages/*/{src,test}/**/*.ts\" \"test/**/*.ts\"",
@@ -29,7 +28,6 @@
"cognitive-complexity-ts": "^0.8.2", "cognitive-complexity-ts": "^0.8.2",
"eslint": "^9.39.5", "eslint": "^9.39.5",
"prettier": "^3.9.6", "prettier": "^3.9.6",
"tsup": "^8.5.1",
"tsx": "^4.23.5", "tsx": "^4.23.5",
"typescript": "^5.5.0", "typescript": "^5.5.0",
"typescript-eslint": "^8.70.0" "typescript-eslint": "^8.70.0"
+24 -1
View File
@@ -1,4 +1,17 @@
# @green-tea/jwt <p align="center">
<img src="https://raw.githubusercontent.com/Expressive-Tea/green-tea/main/assets/logo.png" width="96" alt="Green Tea" />
</p>
<h1 align="center">@green-tea/jwt</h1>
<p align="center"><b>Sign and verify, as one node in the graph.</b></p>
<p align="center">
Keys load once, while providers boot — a bad key fails the deploy,<br />
not the first sign-in of the day.
</p>
---
Loads JWT signing keys at boot and publishes them into the graph as one registry. A handler asks for Loads JWT signing keys at boot and publishes them into the graph as one registry. A handler asks for
it with `@needs('jwt')` and signs or verifies by key name. it with `@needs('jwt')` and signs or verifies by key name.
@@ -12,6 +25,16 @@ it with `@needs('jwt')` and signs or verifies by key name.
| Bun | ✅ | | | Bun | ✅ | |
| workerd (edge) | ❌ | Reads the signing key from a file path, and workerd has no filesystem. | | workerd (edge) | ❌ | Reads the signing key from a file path, and workerd has no filesystem. |
## Install
```bash
npx jsr add @green-tea/jwt
```
Or `deno add jsr:@green-tea/jwt`, or `bunx jsr add @green-tea/jwt`. Under npm, yarn and pnpm
`jsr add` installs through `npm.jsr.io`, so the import below stays `@green-tea/jwt`.
There is no npmjs.org package — `npm i @green-tea/jwt` will not find one.
## Usage ## Usage
```ts ```ts
-24
View File
@@ -16,30 +16,6 @@
"deno": ">=2", "deno": ">=2",
"bun": ">=1.3" "bun": ">=1.3"
}, },
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist",
"README.md",
"CHANGELOG.md"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"scripts": {
"build": "tsup",
"prepublishOnly": "npm run build"
},
"dependencies": { "dependencies": {
"jose": "^6.2.12" "jose": "^6.2.12"
}, },
-17
View File
@@ -1,17 +0,0 @@
import { defineConfig } from 'tsup';
// The npm half of the dual publish. JSR serves `src/` straight from `deno.json` and transpiles it
// itself, so nothing here is JSR's problem — this exists because a plain `npm i` gets none of that
// and Node refuses to strip types under `node_modules`.
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
clean: true,
sourcemap: true,
target: 'node22',
// Convention rule 8 keeps core in `devDependencies`, and tsup bundles devDependencies by default.
// Without this line the emitted declarations would inline core's types rather than import them,
// and every plugin would ship a frozen private copy of a contract core owns.
external: ['@green-tea/core'],
});
+24 -1
View File
@@ -1,4 +1,17 @@
# @green-tea/metrics <p align="center">
<img src="https://raw.githubusercontent.com/Expressive-Tea/green-tea/main/assets/logo.png" width="96" alt="Green Tea" />
</p>
<h1 align="center">@green-tea/metrics</h1>
<p align="center"><b>Count the lifecycle. Render Prometheus.</b></p>
<p align="center">
Reads the event stream green-tea already emits, so nothing in your<br />
handlers has to know it is being measured.
</p>
---
Subscribes to green-tea's lifecycle stream and counts what happened. You expose it on a route you Subscribes to green-tea's lifecycle stream and counts what happened. You expose it on a route you
own, with the transformer this package ships. own, with the transformer this package ships.
@@ -12,6 +25,16 @@ own, with the transformer this package ships.
| Bun | ✅ | | | Bun | ✅ | |
| workerd (edge) | ❌ | Counters live in one isolate, and an edge deployment has many, so a scrape reports whichever isolate answered it. Supported once the counters can be shared. | | workerd (edge) | ❌ | Counters live in one isolate, and an edge deployment has many, so a scrape reports whichever isolate answered it. Supported once the counters can be shared. |
## Install
```bash
npx jsr add @green-tea/metrics
```
Or `deno add jsr:@green-tea/metrics`, or `bunx jsr add @green-tea/metrics`. Under npm, yarn and pnpm
`jsr add` installs through `npm.jsr.io`, so the import below stays `@green-tea/metrics`.
There is no npmjs.org package — `npm i @green-tea/metrics` will not find one.
## Usage ## Usage
```ts ```ts
-24
View File
@@ -16,30 +16,6 @@
"deno": ">=2", "deno": ">=2",
"bun": ">=1.3" "bun": ">=1.3"
}, },
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist",
"README.md",
"CHANGELOG.md"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"scripts": {
"build": "tsup",
"prepublishOnly": "npm run build"
},
"devDependencies": { "devDependencies": {
"@green-tea/core": "26.9.0-beta.2" "@green-tea/core": "26.9.0-beta.2"
} }
-17
View File
@@ -1,17 +0,0 @@
import { defineConfig } from 'tsup';
// The npm half of the dual publish. JSR serves `src/` straight from `deno.json` and transpiles it
// itself, so nothing here is JSR's problem — this exists because a plain `npm i` gets none of that
// and Node refuses to strip types under `node_modules`.
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
clean: true,
sourcemap: true,
target: 'node22',
// Convention rule 8 keeps core in `devDependencies`, and tsup bundles devDependencies by default.
// Without this line the emitted declarations would inline core's types rather than import them,
// and every plugin would ship a frozen private copy of a contract core owns.
external: ['@green-tea/core'],
});
+24 -1
View File
@@ -1,4 +1,17 @@
# @green-tea/rate-limit <p align="center">
<img src="https://raw.githubusercontent.com/Expressive-Tea/green-tea/main/assets/logo.png" width="96" alt="Green Tea" />
</p>
<h1 align="center">@green-tea/rate-limit</h1>
<p align="center"><b>A limit your handler's signature admits to.</b></p>
<p align="center">
The route asks for the limiter by name, so it runs where it is wanted<br />
and nowhere else — and you can see which routes those are.
</p>
---
Publishes a per-request rate limiter into the graph. A handler opts in by asking for it and naming a Publishes a per-request rate limiter into the graph. A handler opts in by asking for it and naming a
rule, so the limit is visible in the handler's signature rather than hidden in a middleware chain — rule, so the limit is visible in the handler's signature rather than hidden in a middleware chain —
@@ -13,6 +26,16 @@ and green-tea runs the step only for the routes that depend on it.
| Bun | ✅ | | | Bun | ✅ | |
| workerd (edge) | ❌ | The default store counts per isolate, and an edge deployment has many, so a shared limit is not one. Supported once a store that shares state ships. | | workerd (edge) | ❌ | The default store counts per isolate, and an edge deployment has many, so a shared limit is not one. Supported once a store that shares state ships. |
## Install
```bash
npx jsr add @green-tea/rate-limit
```
Or `deno add jsr:@green-tea/rate-limit`, or `bunx jsr add @green-tea/rate-limit`. Under npm, yarn and pnpm
`jsr add` installs through `npm.jsr.io`, so the import below stays `@green-tea/rate-limit`.
There is no npmjs.org package — `npm i @green-tea/rate-limit` will not find one.
## Usage ## Usage
```ts ```ts
-24
View File
@@ -16,30 +16,6 @@
"deno": ">=2", "deno": ">=2",
"bun": ">=1.3" "bun": ">=1.3"
}, },
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist",
"README.md",
"CHANGELOG.md"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"scripts": {
"build": "tsup",
"prepublishOnly": "npm run build"
},
"devDependencies": { "devDependencies": {
"@green-tea/core": "26.9.0-beta.2" "@green-tea/core": "26.9.0-beta.2"
} }
-17
View File
@@ -1,17 +0,0 @@
import { defineConfig } from 'tsup';
// The npm half of the dual publish. JSR serves `src/` straight from `deno.json` and transpiles it
// itself, so nothing here is JSR's problem — this exists because a plain `npm i` gets none of that
// and Node refuses to strip types under `node_modules`.
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
clean: true,
sourcemap: true,
target: 'node22',
// Convention rule 8 keeps core in `devDependencies`, and tsup bundles devDependencies by default.
// Without this line the emitted declarations would inline core's types rather than import them,
// and every plugin would ship a frozen private copy of a contract core owns.
external: ['@green-tea/core'],
});
+23 -21
View File
@@ -14,6 +14,7 @@ const README_RUNTIMES: Record<string, string> = { Node: 'node', Deno: 'deno', Bu
interface PackageJson { interface PackageJson {
name: string; name: string;
version: string; version: string;
private?: boolean;
engines?: Record<string, string>; engines?: Record<string, string>;
dependencies?: Record<string, string>; dependencies?: Record<string, string>;
devDependencies?: Record<string, string>; devDependencies?: Record<string, string>;
@@ -105,29 +106,30 @@ for (const dir of packages) {
assert.ok(readJson<DenoJson>('deno.json').workspace?.includes(`./packages/${dir}`)); assert.ok(readJson<DenoJson>('deno.json').workspace?.includes(`./packages/${dir}`));
}); });
test(`${dir}: npm is served the build and JSR the source`, () => { test(`${dir}: JSR is served the source`, () => {
// The two registries are fed different things on purpose. JSR transpiles TypeScript itself, so // JSR transpiles TypeScript itself and hands consumers a typed ESM package, so it gets `src/`
// it gets `src/`. npm does not, and Node refuses to strip types under `node_modules` — a package // and the packages carry no build of their own.
// whose `exports` pointed at a `.ts` file installed fine and then threw on the first import.
assert.equal(deno.exports, './src/index.ts', 'JSR should publish the TypeScript source'); assert.equal(deno.exports, './src/index.ts', 'JSR should publish the TypeScript source');
assert.deepEqual(pkg.exports, {
'.': {
import: { types: './dist/index.d.ts', default: './dist/index.js' },
require: { types: './dist/index.d.cts', default: './dist/index.cjs' },
},
});
assert.equal(pkg.main, './dist/index.cjs');
assert.equal(pkg.module, './dist/index.js');
assert.equal(pkg.types, './dist/index.d.ts');
}); });
test(`${dir}: the tarball ships the build and nothing else`, () => { test(`${dir}: nothing here is publishable to npm`, () => {
// Without `files`, npm packs the whole directory — the first tarball carried `test/` along. // Plugins publish to JSR alone. `npx jsr add` installs them under npm, yarn, pnpm and bun
assert.deepEqual(pkg.files, ['dist', 'README.md', 'CHANGELOG.md']); // through `npm.jsr.io`, which leaves the import specifier intact, so the second registry bought
assert.equal(pkg.scripts?.build, 'tsup'); // a per-package tsup build and a dual `exports` map without buying a reader anything.
// A stale `dist/` is the one packaging failure no static check can see, so the build runs again //
// on the way out rather than trusting whatever CI left behind. // JSR is also the only one of the two that can say *where a plugin runs*, per package. That is
assert.equal(pkg.scripts?.prepublishOnly, 'npm run build'); // not cosmetic for a framework whose claim is one app on four runtimes: `jwt` needs
// `node:fs/promises` and `metrics` imports nothing at all, and npm has nowhere to record the
// difference.
//
// `private` is the guard, not a leftover: it is what makes an accidental `npm publish` fail
// instead of shipping a package whose entry points describe a `dist/` nobody builds.
assert.equal(pkg.private, true, 'a plugin must not be publishable to npm');
for (const field of ['main', 'module', 'types', 'exports', 'files'] as const) {
assert.equal(pkg[field], undefined, `${field} describes an npm tarball that is never built`);
}
assert.equal(pkg.scripts?.build, undefined, 'there is no build to run');
}); });
} }