(name: string, registry?: string)
| 48 | |
| 49 | /** Fetch all published versions of a package from the registry */ |
| 50 | export async function fetchPublishedVersions(name: string, registry?: string): Promise<string[]> { |
| 51 | const args = ['npm', 'info', name, 'versions', '--json']; |
| 52 | if (registry) args.push('--registry', registry); |
| 53 | try { |
| 54 | const raw = await runArgsAsync(args); |
| 55 | const parsed = JSON.parse(raw); |
| 56 | if (Array.isArray(parsed)) return parsed.filter((v) => typeof v === 'string'); |
| 57 | if (typeof parsed === 'string') return [parsed]; // single-version packages |
| 58 | return []; |
| 59 | } catch { |
| 60 | // Package doesn't exist yet (first prerelease ever) or registry unreachable |
| 61 | return []; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /** Fetch the gitHead recorded for a published version (set by npm publish from a git checkout) */ |
| 66 | async function fetchGitHead(name: string, version: string, registry?: string): Promise<string | null> { |
no test coverage detected
searching dependent graphs…