From 85ed4edcce76f3a2ae4ee808aa40249db96093ae Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Wed, 27 Jul 2016 18:08:31 -0700 Subject: [PATCH] More fixups --- src/Tools/RepoUtil/ChangeCommand.cs | 3 +++ src/Tools/RepoUtil/ProjectJsonUtil.cs | 2 +- src/Tools/RepoUtil/VerifyCommand.cs | 21 ++++++++++----------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Tools/RepoUtil/ChangeCommand.cs b/src/Tools/RepoUtil/ChangeCommand.cs index b296c3b95c7..90a7a34e515 100644 --- a/src/Tools/RepoUtil/ChangeCommand.cs +++ b/src/Tools/RepoUtil/ChangeCommand.cs @@ -13,6 +13,9 @@ namespace RepoUtil { /// /// Responsible for changing the repo to use a new set of NuGet packages. + /// + /// TODO: change needs to be concious of version. Can only upgrade the items that have the old + /// version. Needed to support static packages. /// internal sealed class ChangeCommand : ICommand { diff --git a/src/Tools/RepoUtil/ProjectJsonUtil.cs b/src/Tools/RepoUtil/ProjectJsonUtil.cs index df2599e8223..8d5e5fdbeb9 100644 --- a/src/Tools/RepoUtil/ProjectJsonUtil.cs +++ b/src/Tools/RepoUtil/ProjectJsonUtil.cs @@ -44,7 +44,7 @@ internal static ImmutableArray GetDependencies(string filePath) /// internal static bool ChangeDependencies(string filePath, ImmutableDictionary changeMap) { - var obj = JObject.Parse(File.ReadAllText(filePath)); + var obj = JObject.Parse(File.ReadAllText(filePath), new JsonLoadSettings() { CommentHandling = CommentHandling.Load }); var dependencies = (JObject)obj["dependencies"]; if (dependencies == null) { diff --git a/src/Tools/RepoUtil/VerifyCommand.cs b/src/Tools/RepoUtil/VerifyCommand.cs index e151e797bef..330c67fecba 100644 --- a/src/Tools/RepoUtil/VerifyCommand.cs +++ b/src/Tools/RepoUtil/VerifyCommand.cs @@ -36,13 +36,12 @@ internal VerifyCommand(RepoConfig repoConfig, string sourcesPath) _sourcesPath = sourcesPath; } - // TODO: stop using Console.WriteLine public bool Run(TextWriter writer, string[] args) { - return VerifyPackages(); + return VerifyPackages(writer); } - private bool VerifyPackages() + private bool VerifyPackages(TextWriter writer) { var allGood = false; foreach (var filePath in ProjectJsonUtil.GetProjectJsonFiles(_sourcesPath)) @@ -52,14 +51,14 @@ private bool VerifyPackages() { if (_repoConfig.StaticPackages.Any(x => x.Name == nugetRef.Name)) { - if (!VerifyStaticPackage(nugetRef, fileName)) + if (!VerifyStaticPackage(writer, nugetRef, fileName)) { allGood = false; } } else { - if (!VerifyFloatingPackage(nugetRef, fileName)) + if (!VerifyFloatingPackage(writer, nugetRef, fileName)) { allGood = false; } @@ -70,7 +69,7 @@ private bool VerifyPackages() return allGood; } - private bool VerifyFloatingPackage(NuGetPackage nugetRef, FileName fileName) + private bool VerifyFloatingPackage(TextWriter writer, NuGetPackage nugetRef, FileName fileName) { NuGetReferenceSource source; if (_floatingPackageMap.TryGetValue(nugetRef.Name, out source)) @@ -80,9 +79,9 @@ private bool VerifyFloatingPackage(NuGetPackage nugetRef, FileName fileName) return true; } - Console.WriteLine($"Package {nugetRef.Name} version differs in:"); - Console.WriteLine($"\t{fileName} at {nugetRef.Version}"); - Console.WriteLine($"\t{source.FileName} at {source.NuGetReference.Version}"); + writer.WriteLine($"Package {nugetRef.Name} version differs in:"); + writer.WriteLine($"\t{fileName} at {nugetRef.Version}"); + writer.WriteLine($"\t{source.FileName} at {source.NuGetReference.Version}"); return false; } @@ -90,13 +89,13 @@ private bool VerifyFloatingPackage(NuGetPackage nugetRef, FileName fileName) return true; } - private bool VerifyStaticPackage(NuGetPackage nugetRef, FileName fileName) + private bool VerifyStaticPackage(TextWriter writer, NuGetPackage nugetRef, FileName fileName) { Debug.Assert(_repoConfig.StaticPackagesMap.ContainsKey(nugetRef.Name)); var versions = _repoConfig.StaticPackagesMap[nugetRef.Name]; if (!versions.Contains(nugetRef.Version)) { - Console.WriteLine($"Package {nugetRef.Name} at version {nugetRef.Version} in {fileName} is not a valid version"); + writer.WriteLine($"Package {nugetRef.Name} at version {nugetRef.Version} in {fileName} is not a valid version"); return false; } -- GitLab