Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/commands/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})

Expand Down
11 changes: 6 additions & 5 deletions src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ export async function fetchLatestVersion(args: {
registryUrl?: string
}): Promise<string> {
const base = args.registryUrl ?? DEFAULT_REGISTRY_URL
// Hit the dist-tag endpoint (`/<package>/<tag>`) 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 (`/<package>`), 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})`)
}
Expand Down
Loading