test: pin the JSR manifest to package.json

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 <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-08-16 12:47:47 -05:00
1 parent a0fd74da34
commit f96c2ad401
1 file changed
+36 -1
+36 -1
View File
@@ -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<string, string>;
}
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 <projects@expressive-tea.io>');
});
});
// 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<string, unknown>);
expect(Object.keys(denoJson.exports ?? {})).toEqual(npmEntries);
});
});