protected virtual async Task <string> GetLatestVersion( JProperty package, string currentVersion, bool includePreviews = false, bool switchToStable = false) { if (_fileVersionStorage.ContainsKey(package.Name)) { return(_fileVersionStorage[package.Name]); } var newVersion = currentVersion; if (includePreviews || (!switchToStable && currentVersion.Contains("-preview"))) { if (_myGetApiResponse == null) { _myGetApiResponse = await _myGetPackageListFinder.GetPackagesAsync(); } var mygetPackage = _myGetApiResponse.Packages.FirstOrDefault(p => p.Id == package.Name); if (mygetPackage != null) { newVersion = mygetPackage.Versions.Last(); } } else { newVersion = CmdHelper.RunCmdAndGetOutput($"npm show {package.Name} version"); } _fileVersionStorage[package.Name] = newVersion; return(newVersion); }
private async Task <string> GetLatestVersionFromMyGet(string packageId) { var myGetPack = await _myGetPackageListFinder.GetPackagesAsync(); return(myGetPack.Packages.FirstOrDefault(p => p.Id == packageId)?.Versions.LastOrDefault()); }