Table of Contents

Class NpmRegistry

Namespace
Nite.Packages
Assembly
Nite.dll

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

http HttpClient
settings RegistrySettings
cacheDirectory string

The cache root; defaults to the user cache directory.

logger ILogger

Properties

Settings

public RegistrySettings Settings { get; }

Property Value

RegistrySettings

Methods

GetPackumentAsync(string, CancellationToken)

public Task<NpmPackument> GetPackumentAsync(string name, CancellationToken cancellationToken = default)

Parameters

name string
cancellationToken CancellationToken

Returns

Task<NpmPackument>

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

dist NpmDist
cancellationToken CancellationToken

Returns

Task<byte[]>

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

cacheDirectory string

Returns

(int Checked, int Removed)