Writing extended update metadata to the query result JSON is now optional. This greatly reduces the JSON size when update applicability rules not required in the output.

This commit is contained in:
Cristian Petruta 2022-09-26 15:02:31 -07:00
Родитель f46d325f47
Коммит 576d0ef056
3 изменённых файлов: 27 добавлений и 15 удалений

Просмотреть файл

@ -283,6 +283,9 @@ namespace Microsoft.PackageGraph.Utilitites.Upsync
[Option("json-out-path", Required = false, HelpText = "Save results as JSON to the specified path")]
public string JsonOutPath { get; set; }
[Option("include-extended-metadata", Required = false, Default = false, HelpText = "Include extended metadata when saving to JSON query result.")]
public bool IncludeExtendedMetadata { get; set; }
}
[Verb("match-driver", HelpText = "Find drivers")]

Просмотреть файл

@ -65,23 +65,32 @@ namespace Microsoft.PackageGraph.Utilitites.Upsync
{
var packagesList = filteredPackages.ToList();
if (!options.IncludeExtendedMetadata)
{
// Remove extended metadata unless explicitly requested.
// Applicability rules can be very large but of little interest
packagesList.ForEach(p => p.ApplicabilityRules.Clear());
}
Console.WriteLine("-----------------------------");
Console.WriteLine($"Query returned {packagesList.Count} entries.");
Console.WriteLine($"Writing results to {options.JsonOutPath}.");
using (var targetJsonFile = File.Create(options.JsonOutPath))
if (!options.CountOnly)
{
var serializer = JsonSerializer.Create(new JsonSerializerSettings() { Formatting = Formatting.Indented });
using (var jsonWriter = new StreamWriter(targetJsonFile))
{
serializer.Serialize(jsonWriter, packagesList);
}
}
Console.WriteLine($"Writing results to {options.JsonOutPath}.");
Console.WriteLine($"Query result saved to {options.JsonOutPath}.");
using (var targetJsonFile = File.Create(options.JsonOutPath))
{
var serializer = JsonSerializer.Create(new JsonSerializerSettings() { Formatting = Formatting.Indented });
using (var jsonWriter = new StreamWriter(targetJsonFile))
{
serializer.Serialize(jsonWriter, packagesList);
}
}
Console.WriteLine($"Query result saved to {options.JsonOutPath}.");
}
}
else
{

Просмотреть файл

@ -10,9 +10,9 @@
<Description></Description>
<BaseOutputPath>..\..\..\out\upsync</BaseOutputPath>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<FileVersion>3.0.2.0</FileVersion>
<AssemblyVersion>3.0.2.0</AssemblyVersion>
<ProductVersion>3.0.2.0</ProductVersion>
<FileVersion>3.0.3.0</FileVersion>
<AssemblyVersion>3.0.3.0</AssemblyVersion>
<ProductVersion>3.0.3.0</ProductVersion>
</PropertyGroup>
<ItemGroup>