diff --git a/src/commands/update.test.ts b/src/commands/update.test.ts index 821c423..9efc250 100644 --- a/src/commands/update.test.ts +++ b/src/commands/update.test.ts @@ -165,9 +165,7 @@ describe('update --check', () => { mockReadConfigOrThrow.mockResolvedValue({ update_channel: 'pre-release' }) mockFetchOk('1.36.0-next.1') await createProgram().parseAsync(['node', 'td', 'update', '--check']) - expect(fetch).toHaveBeenCalledWith('https://registry.npmjs.org/@doist/todoist-cli/next', { - headers: { Accept: 'application/vnd.npm.install-v1+json' }, - }) + expect(fetch).toHaveBeenCalledWith('https://registry.npmjs.org/@doist/todoist-cli/next') }) }) diff --git a/src/commands/update.ts b/src/commands/update.ts index a24cb65..2b23286 100644 --- a/src/commands/update.ts +++ b/src/commands/update.ts @@ -91,12 +91,13 @@ export async function fetchLatestVersion(args: { registryUrl?: string }): Promise { const base = args.registryUrl ?? DEFAULT_REGISTRY_URL + // Hit the dist-tag endpoint (`//`) directly — it returns a + // single resolved version document, much smaller than the full package + // metadata. The abbreviated `application/vnd.npm.install-v1+json` format + // is rejected here with HTTP 406 — it only applies to the package-doc + // endpoint (`/`), not dist-tag resolutions. const url = `${base}/${args.packageName}/${getInstallTag(args.channel)}` - // The abbreviated metadata format skips `readme`, dependency trees, etc. - // (~50× smaller than the default response on a typical package). - const response = await fetch(url, { - headers: { Accept: 'application/vnd.npm.install-v1+json' }, - }) + const response = await fetch(url) if (!response.ok) { throw new Error(`Registry request failed (HTTP ${response.status})`) }