public void Check() { var installedNpmPackages = NpmHelper.GetInstalledNpmPackages(); if (!installedNpmPackages.Contains(" yarn@")) { NpmHelper.InstallYarn(); } }
public async Task UpsertPackageAsync(ILocalPackage package) { Console.WriteLine("Upserting package " + package.PublishName + " version " + package.Version + " to remote package repository."); await NpmHelper.PublishAsync( package.FolderPath, _npmSettings.AuthToken); package.PublishUrl = $"https://www.npmjs.com/package/{package.PublishName}/v/{package.Version}"; }
public static string GetAutoRestPath(bool withoutPath = false) { if (Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix || withoutPath) { return("autorest"); } return(Path.Combine( NpmHelper.GetPrefixPath(), "autorest.cmd")); }
public void TryGetNpmPrefixPathFromNpmConfig_Returns_Null_Upon_Exception(IProcessLauncher process) { Mock.Get(process) .Setup( c => c.Start( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Action <string> >(), It.IsAny <Action <string> >(), It.IsAny <string>())) .Throws <Exception>(); NpmHelper.TryGetNpmPrefixPathFromNpmConfig(process) .Should() .BeNull(); }
public void TryGetNpmPrefixPathFromNpmConfig() { var mock = new Mock <IProcessLauncher>(); mock.Setup( c => c.Start( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Action <string> >(), It.IsAny <Action <string> >(), It.IsAny <string>())) .Throws(new Exception()); NpmHelper.TryGetNpmPrefixPathFromNpmConfig(mock.Object) .Should() .BeNullOrEmpty(); }
private void AddPackage(List <string> packageJsonFilePaths, string package, string version) { if (!packageJsonFilePaths.Any() || string.IsNullOrWhiteSpace(package)) { return; } var yarnAvailable = NpmHelper.IsYarnAvailable(); foreach (var packageJsonFilePath in packageJsonFilePaths) { var directory = Path.GetDirectoryName(packageJsonFilePath).EnsureEndsWith(Path.DirectorySeparatorChar); if (yarnAvailable) { NpmHelper.YarnAddPackage(package, version, directory); } else { NpmHelper.NpmInstallPackage(package, version, directory); } } }
public void TryGetNpmPrefixPathFromNpmConfig_Returns_NotNull() { NpmHelper.TryGetNpmPrefixPathFromNpmConfig() .Should() .NotBeNull(); }
public ThemePackageAdder(NpmHelper npmHelper, PackageJsonFileFinder packageJsonFileFinder) { NpmHelper = npmHelper; PackageJsonFileFinder = packageJsonFileFinder; }
public NpmGlobalPackagesChecker(NpmHelper npmHelper) { NpmHelper = npmHelper; Logger = NullLogger <NpmGlobalPackagesChecker> .Instance; }
public void DirectoryExists_GetNpmPrefixPath() => Directory.Exists(NpmHelper.GetPrefixPath()) .Should() .BeTrue();
public void Can_GetNpmPrefixPath() => NpmHelper.GetPrefixPath() .Should() .NotBeNullOrWhiteSpace();
public void FileExists_GetNpmPath() => File.Exists(NpmHelper.GetNpmPath()) .Should() .BeTrue();
public void GetNpmPath_IgnorePath_Returns_Npm() => NpmHelper.GetNpmPath(true) .Should() .Be("npm");
public async Task InstallLibsAsync(string directory) { var projectPaths = FindAllProjects(directory); if (!projectPaths.Any()) { Logger.LogError("No project found in the directory."); return; } if (!NpmHelper.IsNpmInstalled()) { Logger.LogWarning("NPM is not installed, visit https://nodejs.org/en/download/ and install NPM"); return; } if (!NpmHelper.IsYarnAvailable()) { Logger.LogWarning("YARN is not installed, which may cause package inconsistency, please use YARN instead of NPM. visit https://classic.yarnpkg.com/lang/en/docs/install/ and install YARN"); } Logger.LogInformation($"Found {projectPaths.Count} projects."); foreach (var projectPath in projectPaths) { Logger.LogInformation($"{Path.GetDirectoryName(projectPath)}"); } foreach (var projectPath in projectPaths) { var projectDirectory = Path.GetDirectoryName(projectPath); // angular if (projectPath.EndsWith("angular.json")) { if (NpmHelper.IsYarnAvailable()) { NpmHelper.RunYarn(projectDirectory); } else { NpmHelper.RunNpmInstall(projectDirectory); } } // MVC or BLAZOR SERVER if (projectPath.EndsWith(".csproj")) { var packageJsonFilePath = Path.Combine(Path.GetDirectoryName(projectPath), "package.json"); if (!File.Exists(packageJsonFilePath)) { continue; } if (NpmHelper.IsYarnAvailable()) { NpmHelper.RunYarn(projectDirectory); } else { NpmHelper.RunNpmInstall(projectDirectory); } await CleanAndCopyResources(projectDirectory); } } }
public InstallLibsService(IJsonSerializer jsonSerializer, NpmHelper npmHelper) { NpmHelper = npmHelper; _jsonSerializer = jsonSerializer; }