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,9 +65,18 @@ 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.");
if (!options.CountOnly)
{
Console.WriteLine($"Writing results to {options.JsonOutPath}."); Console.WriteLine($"Writing results to {options.JsonOutPath}.");
using (var targetJsonFile = File.Create(options.JsonOutPath)) using (var targetJsonFile = File.Create(options.JsonOutPath))
@ -80,9 +89,9 @@ namespace Microsoft.PackageGraph.Utilitites.Upsync
} }
Console.WriteLine($"Query result saved to {options.JsonOutPath}."); Console.WriteLine($"Query result saved to {options.JsonOutPath}.");
} }
}
else else
{ {
var categoriesLookup = allCategories.ToLookup(package => package.Id.ID); var categoriesLookup = allCategories.ToLookup(package => package.Id.ID);

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

@ -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>