Class PackageInstaller
Installs nite.json dependencies into a regular node_modules folder, so esbuild,
TypeScript and editors all find packages the usual way. Resolution is recorded in
nite.lock.json; with a current lockfile an install never asks the registry for metadata.
public sealed class PackageInstaller
- Inheritance
-
PackageInstaller
- Inherited Members
Remarks
Deliberately small: registry packages only (no git, file: or npm: aliases), optional dependencies are skipped, install scripts never run (packages that have one get a warning when they are resolved), and hoisting is "top level unless that would conflict, otherwise nested under the dependent".
Constructors
PackageInstaller(HttpClient, ILogger<PackageInstaller>?)
public PackageInstaller(HttpClient http, ILogger<PackageInstaller>? logger = null)
Parameters
httpHttpClientloggerILogger<PackageInstaller>
Fields
LockFileName
public const string LockFileName = "nite.lock.json"
Field Value
Methods
InstallAsync(string, NiteConfig, CancellationToken, IReadOnlyCollection<string>?, IReadOnlyDictionary<string, HashSet<string>>?)
Makes node_modules match the lockfile, resolving a new lockfile if needed.
public Task<NiteLockFile> InstallAsync(string projectDirectory, NiteConfig config, CancellationToken cancellationToken = default, IReadOnlyCollection<string>? update = null, IReadOnlyDictionary<string, HashSet<string>>? seedVersions = null)
Parameters
projectDirectorystringconfigNiteConfigcancellationTokenCancellationTokenupdateIReadOnlyCollection<string>Packages to move to the newest versions their ranges allow (
nite update); an empty collection means all of them. When null, versions already in the lockfile are kept wherever they still satisfy their ranges, and the lockfile is only re-resolved if nite.json changed.seedVersionsIReadOnlyDictionary<string, HashSet<string>>Versions to prefer on top of the lockfile's, such as those an imported project's own lockfile (package-lock.json, yarn.lock…) recorded.
Returns
- Task<NiteLockFile>
The lockfile that is now installed.