Skip to content

.NET library that provides an API for NPM

License

Notifications You must be signed in to change notification settings

atata-framework/atata-cli-npm

Repository files navigation

Atata.Cli.Npm

NuGet GitHub release Build status Slack Atata docs Twitter

Atata.Cli.Npm is a .NET library that provides an API for NPM.

The package targets .NET Standard 2.0, which supports .NET 5+, .NET Framework 4.6.1+ and .NET Core/Standard 2.0+.

Table of Contents

Features

  • Checks whether NPM is installed.
  • Checks whether package is installed.
  • Gets installed package version.
  • Installs package.
  • Uninstalls package.

Installation

Install Atata.Cli.Npm NuGet package.

  • Package Manager:

    Install-Package Atata.Cli.Npm
    
  • .NET CLI:

    dotnet add package Atata.Cli.Npm
    

Usage

The main class is NpmCli located in Atata.Cli.Npm namespace.

There is also GlobalNpmPackageCli<TCli>, which can be used as a base class of specific NPM package CLI.

Check NPM is Installed

bool isNpmInstalled = new NpmCli()
    .IsItInstalled();

Ensure NPM is Installed

new NpmCli()
    .EnsureItIsInstalled();

If NPM isn't installed, throws NpmNotFoundException.

Install Package Into Directory

NpmCli.InDirectory("some/dir")
    .Install("npm-package-name-1")
    .Install("npm-package-name-2", "1.2.3");

Install Package Globally

new NpmCli()
    .Install("html-validate", global: true);

Install Package If Missing

NpmCli.InBaseDirectory()
    .InstallIfMissing("html-validate", global: true);

Check Package is Installed

bool isPackageInstalled = new NpmCli()
    .IsInstalled("html-validate", global: true);

Check Specific Package Version is Installed

bool isPackageVersionInstalled = new NpmCli()
    .IsInstalled("html-validate", "5.0.0", global: true);

Get Installed Package Version

string packageVersion = new NpmCli()
    .GetInstalledVersion("html-validate", global: true);

Uninstall Package

new NpmCli()
    .Uninstall("html-validate", global: true);

Feedback

Any feedback, issues and feature requests are welcome.

If you faced an issue please report it to Atata.Cli.Npm Issues, ask a question on Stack Overflow using atata tag or use another Atata Contact way.

SemVer

Atata Framework follows Semantic Versioning 2.0. Thus backward compatibility is followed and updates within the same major version (e.g. from 1.3 to 1.4) should not require code changes.

License

Atata is an open source software, licensed under the Apache License 2.0. See LICENSE for details.