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")] [Option("json-out-path", Required = false, HelpText = "Save results as JSON to the specified path")]
public string JsonOutPath { get; set; } 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")] [Verb("match-driver", HelpText = "Find drivers")]

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

@ -65,23 +65,32 @@ namespace Microsoft.PackageGraph.Utilitites.Upsync
{ {
var packagesList = filteredPackages.ToList(); 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("-----------------------------");
Console.WriteLine($"Query returned {packagesList.Count} entries."); Console.WriteLine($"Query returned {packagesList.Count} entries.");
Console.WriteLine($"Writing results to {options.JsonOutPath}."); if (!options.CountOnly)
using (var targetJsonFile = File.Create(options.JsonOutPath))
{ {
var serializer = JsonSerializer.Create(new JsonSerializerSettings() { Formatting = Formatting.Indented }); Console.WriteLine($"Writing results to {options.JsonOutPath}.");
using (var jsonWriter = new StreamWriter(targetJsonFile))
{
serializer.Serialize(jsonWriter, packagesList);
}
}
using (var targetJsonFile = File.Create(options.JsonOutPath))
Console.WriteLine($"Query result saved to {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 else
{ {

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

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