Home / Function/ fetchPackageVersions() — astro Function Reference

fetchPackageVersions() — astro Function Reference

Architecture documentation for the fetchPackageVersions() function in install-package.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  9ed452f5_f41a_0501_14f9_7f6cb61914a3["fetchPackageVersions()"]
  ba36b72c_5f3d_f082_9365_52233650426e["install-package.ts"]
  9ed452f5_f41a_0501_14f9_7f6cb61914a3 -->|defined in| ba36b72c_5f3d_f082_9365_52233650426e
  d2af8925_8fc5_eccf_dd65_3fc6954dc796["getRegistry()"]
  9ed452f5_f41a_0501_14f9_7f6cb61914a3 -->|calls| d2af8925_8fc5_eccf_dd65_3fc6954dc796
  style 9ed452f5_f41a_0501_14f9_7f6cb61914a3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/cli/install-package.ts lines 147–160

export async function fetchPackageVersions(packageName: string): Promise<string[] | Error> {
	const registry = await getRegistry();
	const res = await fetch(`${registry}/${packageName}`, {
		headers: { accept: 'application/vnd.npm.install-v1+json' },
	});
	if (res.status >= 200 && res.status < 300) {
		return await res.json().then((data) => Object.keys(data.versions));
	} else if (res.status === 404) {
		// 404 means the package doesn't exist, so we don't need an error message here
		return new Error();
	} else {
		return new Error(`Failed to fetch ${registry}/${packageName} - GET ${res.status}`);
	}
}

Domain

Subdomains

Frequently Asked Questions

What does fetchPackageVersions() do?
fetchPackageVersions() is a function in the astro codebase, defined in packages/astro/src/cli/install-package.ts.
Where is fetchPackageVersions() defined?
fetchPackageVersions() is defined in packages/astro/src/cli/install-package.ts at line 147.
What does fetchPackageVersions() call?
fetchPackageVersions() calls 1 function(s): getRegistry.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free