From f96c2ad40172d5a5641dfad72bd17c7a1c3e2af6 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sun, 16 Aug 2026 12:47:47 -0500 Subject: [PATCH] test: pin the JSR manifest to package.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit npm and JSR publish from the same tag but read their identity from different files. Bump package.json alone and that tag ships one version to npm and the previous one to JSR, with nothing failing — the drift the deno.json manifest introduced, closed where the other publication-metadata pins already live. Also pins the entry points to npm's, so a docs example importing @green-tea/core/bun keeps working whichever registry the reader installed from. Signed-off-by: Diego Resendez --- test/package-metadata.test.ts | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/test/package-metadata.test.ts b/test/package-metadata.test.ts index a5f1301..f9fbed2 100644 --- a/test/package-metadata.test.ts +++ b/test/package-metadata.test.ts @@ -16,7 +16,25 @@ interface PackageMetadata { readonly author?: string; } -const packageJson = JSON.parse(readFileSync(resolve(process.cwd(), 'package.json'), 'utf8')) as PackageMetadata; +interface DenoManifest { + readonly name?: string; + readonly version?: string; + readonly license?: string; + readonly exports?: Record; +} + +const read = (file: string): string => readFileSync(resolve(process.cwd(), file), 'utf8'); +const packageJson = JSON.parse(read('package.json')) as PackageMetadata & { version: string; license: string }; + +// `deno.json` is JSONC and carries comments. Only whole-line `//` comments are stripped, so this +// can never eat a `//` inside a string value — narrower than a general JSONC parser, and enough, +// versus pulling in a dependency to read one config file. +const denoJson = JSON.parse( + read('deno.json') + .split('\n') + .filter((line) => !line.trim().startsWith('//')) + .join('\n'), +) as DenoManifest; describe('package publication metadata', () => { it('links npm provenance to the public GitHub repository', () => { @@ -40,3 +58,20 @@ describe('package publication metadata', () => { expect(packageJson.author).toBe('green-tea contributors '); }); }); + +// npm and JSR are published from the same tag but read their identity from different files, so the +// two can drift silently: bump package.json alone and the next release ships one version to npm and +// the previous one to JSR, under the same tag. Nothing else notices, which is why this is here. +describe('JSR manifest agrees with package.json', () => { + it('publishes the same package at the same version', () => { + expect(denoJson.name).toBe('@green-tea/core'); + expect(denoJson.version).toBe(packageJson.version); + expect(denoJson.license).toBe(packageJson.license); + }); + + // A reader following a docs example should not have to care which registry they installed from. + it('offers the same entry points npm does', () => { + const npmEntries = Object.keys(JSON.parse(read('package.json')).exports as Record); + expect(Object.keys(denoJson.exports ?? {})).toEqual(npmEntries); + }); +});