Skip to content

Commit 8389319

Browse files
authored
Bump manifest schema version to 1.10.0 (#593)
1 parent f26390d commit 8389319

28 files changed

+670
-76
lines changed

src/WingetCreateCLI/Commands/BaseCommand.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ protected static string SaveManifestDirToLocalPath(
216216
/// Saves the manifests to a randomly generated directory in the %TEMP% folder and validates them, printing the results to console.
217217
/// </summary>
218218
/// <param name="manifests">Manifests object model.</param>
219+
/// <param name="format">Format of the serialized manifest. </param>
219220
/// <returns>A boolean value indicating whether validation of the manifests was successful.</returns>
220-
protected static bool ValidateManifestsInTempDir(Manifests manifests)
221+
protected static bool ValidateManifestsInTempDir(Manifests manifests, ManifestFormat format)
221222
{
222223
string versionManifestFileName = Manifests.GetFileName(manifests.VersionManifest, Extension);
223224
string installerManifestFileName = Manifests.GetFileName(manifests.InstallerManifest, Extension);
@@ -236,7 +237,7 @@ protected static bool ValidateManifestsInTempDir(Manifests manifests)
236237
File.WriteAllText(Path.Combine(randomDirPath, localeManifestFileName), localeManifest.ToManifestString());
237238
}
238239

239-
bool result = ValidateManifest(randomDirPath);
240+
bool result = ValidateManifest(randomDirPath, format);
240241
Directory.Delete(randomDirPath, true);
241242
return result;
242243
}
@@ -382,9 +383,20 @@ protected static async Task<string> DownloadPackageFile(string installerUrl)
382383
/// Utilizes WingetUtil to validate a specified manifest.
383384
/// </summary>
384385
/// <param name="manifestPath"> Path to the manifest file to be validated. </param>
386+
/// <param name="format"> Format of the manifest file. </param>"
385387
/// <returns>Bool indicating the validity of the manifest file. </returns>
386-
protected static bool ValidateManifest(string manifestPath)
388+
protected static bool ValidateManifest(string manifestPath, ManifestFormat format)
387389
{
390+
bool skipValidation = format != ManifestFormat.Yaml;
391+
392+
// Skip validation because of https://github.com/microsoft/winget-cli/issues/5336
393+
// More discussion in the PR https://github.com/microsoft/winget-create/pull/593
394+
if (skipValidation)
395+
{
396+
Logger.WarnLocalized(nameof(Resources.SkippingManifestValidation_Message));
397+
return true;
398+
}
399+
388400
(bool success, string message) = WinGetUtil.ValidateManifest(manifestPath);
389401

390402
if (success)

src/WingetCreateCLI/Commands/NewCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public override async Task<bool> Execute()
261261
ShiftInstallerFieldsToRootLevel(manifests.InstallerManifest);
262262
RemoveEmptyStringAndListFieldsInManifests(manifests);
263263
DisplayManifestPreview(manifests);
264-
isManifestValid = ValidateManifestsInTempDir(manifests);
264+
isManifestValid = ValidateManifestsInTempDir(manifests, this.Format);
265265
}
266266
while (Prompt.Confirm(Resources.ConfirmManifestCreation_Message));
267267

src/WingetCreateCLI/Commands/NewLocaleCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public override async Task<bool> Execute()
224224
{
225225
LocaleManifest newlocale = this.GenerateLocaleManifest(originalManifests, referenceLocaleManifest);
226226
Console.WriteLine();
227-
ValidateManifestsInTempDir(originalManifests);
227+
ValidateManifestsInTempDir(originalManifests, this.Format);
228228
originalManifests.LocaleManifests.Add(newlocale);
229229
newLocales.Add(newlocale);
230230
}
@@ -241,7 +241,7 @@ public override async Task<bool> Execute()
241241

242242
string manifestDirectoryPath = SaveManifestDirToLocalPath(originalManifests, this.OutputDir);
243243

244-
if (ValidateManifest(manifestDirectoryPath))
244+
if (ValidateManifest(manifestDirectoryPath, this.Format))
245245
{
246246
if (Prompt.Confirm(Resources.ConfirmGitHubSubmitManifest_Message))
247247
{

src/WingetCreateCLI/Commands/SubmitCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private async Task<bool> SubmitManifest()
112112
string expandedPath = System.Environment.ExpandEnvironmentVariables(this.Path);
113113

114114
// TODO: Remove singleton support.
115-
if (File.Exists(expandedPath) && ValidateManifest(expandedPath))
115+
if (File.Exists(expandedPath) && ValidateManifest(expandedPath, this.Format))
116116
{
117117
Manifests manifests = new Manifests();
118118
manifests.SingletonManifest = Serialization.DeserializeFromPath<SingletonManifest>(expandedPath);
@@ -124,7 +124,7 @@ private async Task<bool> SubmitManifest()
124124

125125
return await this.GitHubSubmitManifests(manifests, this.PRTitle, this.Replace, this.ReplaceVersion);
126126
}
127-
else if (Directory.Exists(expandedPath) && ValidateManifest(expandedPath))
127+
else if (Directory.Exists(expandedPath) && ValidateManifest(expandedPath, this.Format))
128128
{
129129
List<string> manifestContents = Directory.GetFiles(expandedPath).Select(f => File.ReadAllText(f)).ToList();
130130
Manifests manifests = Serialization.DeserializeManifestContents(manifestContents);

src/WingetCreateCLI/Commands/UpdateCommand.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ await this.UpdateManifestsInteractively(initialManifests) :
274274

275275
string manifestDirectoryPath = SaveManifestDirToLocalPath(updatedManifests, this.OutputDir);
276276

277-
if (ValidateManifest(manifestDirectoryPath))
277+
if (ValidateManifest(manifestDirectoryPath, this.Format))
278278
{
279279
if (this.SubmitToGitHub)
280280
{
@@ -617,6 +617,7 @@ private static Manifests ConvertSingletonToMultifileManifest(WingetCreateCore.Mo
617617
cfg.CreateMap<WingetCreateCore.Models.Singleton.Files, WingetCreateCore.Models.Installer.Files>();
618618
cfg.CreateMap<WingetCreateCore.Models.Singleton.InstallationMetadata, WingetCreateCore.Models.Installer.InstallationMetadata>();
619619
cfg.CreateMap<WingetCreateCore.Models.Singleton.Icon, WingetCreateCore.Models.DefaultLocale.Icon>();
620+
cfg.CreateMap<WingetCreateCore.Models.Singleton.Authentication, WingetCreateCore.Models.Installer.Authentication>();
620621
});
621622
var mapper = config.CreateMapper();
622623

@@ -686,7 +687,7 @@ private static bool VerifyUpdatedInstallerHash(Manifests oldManifest, InstallerM
686687
return newHashes.Except(oldHashes).Any();
687688
}
688689

689-
private static void DisplayManifestsAsMenuSelection(Manifests manifests)
690+
private static void DisplayManifestsAsMenuSelection(Manifests manifests, ManifestFormat format)
690691
{
691692
Console.Clear();
692693
string versionFileName = Manifests.GetFileName(manifests.VersionManifest, Extension);
@@ -708,7 +709,7 @@ private static void DisplayManifestsAsMenuSelection(Manifests manifests)
708709
}
709710

710711
selectionList.Add(Resources.Done_MenuItem);
711-
ValidateManifestsInTempDir(manifests);
712+
ValidateManifestsInTempDir(manifests, format);
712713
var selectedItem = Prompt.Select(Resources.SelectManifestToEdit_Message, selectionList);
713714

714715
if (selectedItem == versionManifestMenuItem)
@@ -955,13 +956,13 @@ private async Task<Manifests> UpdateManifestsInteractively(Manifests manifests)
955956

956957
this.AddVersionSpecificMetadata(manifests);
957958
DisplayManifestPreview(manifests);
958-
ValidateManifestsInTempDir(manifests);
959+
ValidateManifestsInTempDir(manifests, this.Format);
959960
}
960961
while (Prompt.Confirm(Resources.DiscardUpdateAndStartOver_Message));
961962

962963
if (Prompt.Confirm(Resources.EditManifests_Message))
963964
{
964-
DisplayManifestsAsMenuSelection(manifests);
965+
DisplayManifestsAsMenuSelection(manifests, this.Format);
965966
}
966967

967968
if (!this.SubmitToGitHub)

src/WingetCreateCLI/Commands/UpdateLocaleCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public override async Task<bool> Execute()
172172

173173
string manifestDirectoryPath = SaveManifestDirToLocalPath(originalManifests, this.OutputDir);
174174

175-
if (ValidateManifest(manifestDirectoryPath))
175+
if (ValidateManifest(manifestDirectoryPath, this.Format))
176176
{
177177
if (Prompt.Confirm(Resources.ConfirmGitHubSubmitManifest_Message))
178178
{
@@ -281,7 +281,7 @@ private Tuple<DefaultLocaleManifest, List<LocaleManifest>> PromptAndUpdateExisti
281281
}
282282

283283
Console.WriteLine();
284-
ValidateManifestsInTempDir(manifests);
284+
ValidateManifestsInTempDir(manifests, this.Format);
285285
}
286286
while (Prompt.Confirm(Resources.UpdateAnotherLocale_Message));
287287

src/WingetCreateCLI/PromptHelper.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,20 @@ public static void PromptPropertyAndSetValue<T>(object model, string memberName,
240240
{
241241
Type instanceType = typeof(T);
242242
string message = string.Format(Resources.FieldValueIs_Message, memberName);
243-
Console.WriteLine(Resources.ResourceManager.GetString($"{memberName}_KeywordDescription"));
243+
244+
// TODO: Remove when updating the code to handle property name collisions.
245+
// The proper way to handle this may be to append the model information
246+
// something like "{modelName}_{propertyName}_KeywordDescription" e.g. "Installers_Scope_KeywordDescription" &
247+
// "Installers_Authentication_MicrosoftEntraIdAuthenticationInfo_Scope_KeywordDescription" and updating all resource
248+
// strings to follow this convention.
249+
if (model.GetType() == typeof(MicrosoftEntraIdAuthenticationInfo) && memberName == "Scope")
250+
{
251+
Console.WriteLine(Resources.MicrosoftEntraIdAuthenticationInfo_Scope_KeywordDescription);
252+
}
253+
else
254+
{
255+
Console.WriteLine(Resources.ResourceManager.GetString($"{memberName}_KeywordDescription"));
256+
}
244257

245258
if (instanceType == typeof(object))
246259
{

src/WingetCreateCLI/Properties/Resources.Designer.cs

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/WingetCreateCLI/Properties/Resources.resx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,4 +1406,22 @@ Warning: Using this argument may result in the token being logged. Consider an a
14061406
<data name="BranchMergeConflict_Message" xml:space="preserve">
14071407
<value>The forked repository could not be synced with the upstream commits due to a merge conflict. Resolve conflicts manually and try again.</value>
14081408
</data>
1409+
<data name="AuthenticationType_KeywordDescription" xml:space="preserve">
1410+
<value>The type of authentication to use</value>
1411+
</data>
1412+
<data name="Resource_KeywordDescription" xml:space="preserve">
1413+
<value>The resource to use for Microsoft Entra Id authentication</value>
1414+
</data>
1415+
<data name="MicrosoftEntraIdAuthenticationInfo_KeywordDescription" xml:space="preserve">
1416+
<value>Information required for Microsoft Entra Id authentication</value>
1417+
</data>
1418+
<data name="Authentication_KeywordDescription" xml:space="preserve">
1419+
<value>Authentication information for secured private sources</value>
1420+
</data>
1421+
<data name="SkippingManifestValidation_Message" xml:space="preserve">
1422+
<value>Skipping manifest validation. The CLI can only validate YAML format. Validate output manually before submission.</value>
1423+
</data>
1424+
<data name="MicrosoftEntraIdAuthenticationInfo_Scope_KeywordDescription" xml:space="preserve">
1425+
<value>The scope value for Microsoft Entra Id authentication</value>
1426+
</data>
14091427
</root>

src/WingetCreateCLI/WingetCreateCLI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFramework>net8.0-windows10.0.22000.0</TargetFramework>
66
<AssemblyName>WingetCreateCLI</AssemblyName>
77
<RootNamespace>Microsoft.WingetCreateCLI</RootNamespace>
8-
<Version>1.9</Version>
8+
<Version>1.10</Version>
99
<Platforms>x64;x86</Platforms>
1010
<RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>

0 commit comments

Comments
 (0)