Class NpmRegistry
A minimal npm registry client: abbreviated package metadata plus integrity-checked tarball downloads. Tarballs are cached by integrity hash, so reinstalls and other projects are free; metadata is cached with its ETag and revalidated, so an unchanged package costs a 304. Scoped packages go to their scope's registry, and credentials only go to the hosts they name.
public sealed class NpmRegistry
- Inheritance
-
NpmRegistry
- Inherited Members
Constructors
NpmRegistry(HttpClient, RegistrySettings?, string?, ILogger?)
public NpmRegistry(HttpClient http, RegistrySettings? settings = null, string? cacheDirectory = null, ILogger? logger = null)
Parameters
httpHttpClientsettingsRegistrySettingscacheDirectorystringThe cache root; defaults to the user cache directory.
loggerILogger
Properties
Settings
public RegistrySettings Settings { get; }
Property Value
Methods
GetPackumentAsync(string, CancellationToken)
public Task<NpmPackument> GetPackumentAsync(string name, CancellationToken cancellationToken = default)
Parameters
namestringcancellationTokenCancellationToken
Returns
GetTarballAsync(NpmDist, CancellationToken)
Downloads a tarball (or reads it from the cache) and verifies its integrity.
public Task<byte[]> GetTarballAsync(NpmDist dist, CancellationToken cancellationToken = default)
Parameters
distNpmDistcancellationTokenCancellationToken
Returns
VerifyTarballCache(string)
Checks every cached tarball against the hash in its name and deletes the ones that do not match.
public static (int Checked, int Removed) VerifyTarballCache(string cacheDirectory)
Parameters
cacheDirectorystring