Skip to content

Commit 6e94350

Browse files
Add support for manifest v1 (#110)
Migrate all entities to be compatible with v1 version of the manifest Add extra options from winget (#110)
1 parent a02b4ac commit 6e94350

24 files changed

+1707
-574
lines changed

src/Otor.MsixHero.App/Modules/Dialogs/Winget/YamlEditor/View/WingetDialogContent.xaml

Lines changed: 91 additions & 30 deletions
Large diffs are not rendered by default.

src/Otor.MsixHero.App/Modules/Dialogs/Winget/YamlEditor/ViewModel/WingetDefinitionViewModel.cs

Lines changed: 89 additions & 62 deletions
Large diffs are not rendered by default.

src/Otor.MsixHero.App/Modules/Dialogs/Winget/YamlEditor/ViewModel/WingetInstallerViewModel.cs

Lines changed: 106 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// https://github.com/marcinotorowski/msix-hero/blob/develop/LICENSE.md
1616

1717
using System;
18+
using System.Collections.Generic;
1819
using System.IO;
1920
using System.Linq;
2021
using System.Threading;
@@ -41,13 +42,19 @@ public WingetInstallerViewModel(YamlUtils yamlUtils, IInteractionService interac
4142
this.interactionService = interactionService;
4243
this.AddChildren(
4344
this.Architecture = new ChangeableProperty<YamlArchitecture>(),
44-
this.SystemAppId = new ValidatedChangeableProperty<string>("System AppId"),
45+
this.PlatformUwp = new ChangeableProperty<bool>(this.Model?.Platform?.Contains(YamlPlatform.WindowsUniversal) == true),
46+
this.PlatformWin32 = new ChangeableProperty<bool>(this.Model?.Platform?.Contains(YamlPlatform.WindowsDesktop) == true),
47+
this.ProductCode = new ValidatedChangeableProperty<string>("Product code", ValidatorFactory.ValidateGuid(false)),
48+
this.PackageFamilyName = new ValidatedChangeableProperty<string>("Package family name", WingetValidators.GetPackageFamilyNameError),
4549
this.SignatureSha256 = new ValidatedChangeableProperty<string>("Signature hash", ValidatorFactory.ValidateSha256(false)),
4650
this.Scope = new ChangeableProperty<YamlScope>(),
47-
this.SilentCommand = new ChangeableProperty<string>(),
48-
this.CustomCommand = new ChangeableProperty<string>(),
49-
this.InstallerType = new ValidatedChangeableProperty<YamlInstallerType>("Installer type", ValidateInstallerType),
50-
this.SilentCommandWithProgress = new ChangeableProperty<string>()
51+
this.SilentCommand = new ValidatedChangeableProperty<string>("Silent command", WingetValidators.GetInstallerSwitchesError),
52+
this.InteractiveCommand = new ValidatedChangeableProperty<string>("Interactive command", WingetValidators.GetInstallerSwitchesError),
53+
this.LogCommand = new ValidatedChangeableProperty<string>("Log command", WingetValidators.GetInstallerSwitchesError),
54+
this.UpgradeCommand = new ValidatedChangeableProperty<string>("Upgrade command", WingetValidators.GetInstallerSwitchesError),
55+
this.CustomCommand = new ValidatedChangeableProperty<string>("Custom command", WingetValidators.GetCustomInstallerSwitchesError),
56+
this.SilentCommandWithProgress = new ValidatedChangeableProperty<string>("Silent command with progress", WingetValidators.GetInstallerSwitchesError),
57+
this.InstallerType = new ValidatedChangeableProperty<YamlInstallerType>("Installer type", ValidateInstallerType)
5158
);
5259

5360
this.InstallerType.ValueChanged += InstallerTypeOnValueChanged;
@@ -57,14 +64,25 @@ public void SetData(YamlInstaller installer, bool useNullValues = true)
5764
{
5865
this.Model = installer;
5966

60-
if (useNullValues || installer.Arch != default)
67+
if (useNullValues || installer.Architecture != default)
6168
{
62-
this.Architecture.CurrentValue = installer?.Arch ?? YamlArchitecture.none;
69+
this.Architecture.CurrentValue = installer?.Architecture ?? YamlArchitecture.None;
6370
}
6471

65-
if (useNullValues || installer.SystemAppId != null)
72+
if (useNullValues || installer.Platform != default)
6673
{
67-
this.SystemAppId.CurrentValue = installer?.SystemAppId;
74+
this.PlatformUwp.CurrentValue = installer?.Platform?.Contains(YamlPlatform.WindowsUniversal) == true;
75+
this.PlatformWin32.CurrentValue = installer?.Platform?.Contains(YamlPlatform.WindowsDesktop) == true;
76+
}
77+
78+
if (useNullValues || installer.ProductCode != null)
79+
{
80+
this.ProductCode.CurrentValue = installer?.ProductCode;
81+
}
82+
83+
if (useNullValues || installer.PackageFamilyName != null)
84+
{
85+
this.PackageFamilyName.CurrentValue = installer?.PackageFamilyName;
6886
}
6987

7088
if (useNullValues || installer.SignatureSha256 != null)
@@ -74,43 +92,70 @@ public void SetData(YamlInstaller installer, bool useNullValues = true)
7492

7593
if (useNullValues || installer.Scope != default)
7694
{
77-
this.Scope.CurrentValue = installer?.Scope ?? YamlScope.none;
95+
this.Scope.CurrentValue = installer?.Scope ?? YamlScope.None;
7896
}
7997

80-
if (useNullValues || installer.Switches?.Silent != null)
98+
if (useNullValues || installer.InstallerSwitches?.Silent != null)
99+
{
100+
this.SilentCommand.CurrentValue = installer?.InstallerSwitches?.Silent;
101+
}
102+
103+
if (useNullValues || installer.InstallerSwitches?.Custom != null)
81104
{
82-
this.SilentCommand.CurrentValue = installer?.Switches?.Silent;
105+
this.CustomCommand.CurrentValue = installer?.InstallerSwitches?.Custom;
83106
}
84107

85-
if (useNullValues || installer.Switches?.Custom != null)
108+
if (useNullValues || installer.InstallerSwitches?.SilentWithProgress != default)
86109
{
87-
this.CustomCommand.CurrentValue = installer?.Switches?.Custom;
110+
this.SilentCommandWithProgress.CurrentValue = installer?.InstallerSwitches?.SilentWithProgress;
111+
}
112+
113+
if (useNullValues || installer.InstallerSwitches?.Interactive != default)
114+
{
115+
this.InteractiveCommand.CurrentValue = installer?.InstallerSwitches?.Interactive;
88116
}
89117

90-
if (useNullValues || installer.InstallerType != default)
118+
if (useNullValues || installer.InstallerSwitches?.Upgrade != default)
119+
{
120+
this.UpgradeCommand.CurrentValue = installer?.InstallerSwitches?.Upgrade;
121+
}
122+
123+
if (useNullValues || installer.InstallerSwitches?.Log != default)
91124
{
92-
this.InstallerType.CurrentValue = installer?.InstallerType ?? YamlInstallerType.none;
125+
this.LogCommand.CurrentValue = installer?.InstallerSwitches?.Log;
93126
}
94127

95-
if (useNullValues || installer.Arch != default)
128+
if (useNullValues || installer.InstallerType != default)
96129
{
97-
this.SilentCommandWithProgress.CurrentValue = installer?.Switches?.SilentWithProgress;
130+
this.InstallerType.CurrentValue = installer?.InstallerType ?? YamlInstallerType.None;
98131
}
99132

100133
this.Commit();
101134
}
102135

103136
public ChangeableProperty<YamlArchitecture> Architecture { get; }
137+
138+
public ChangeableProperty<bool> PlatformUwp { get; }
139+
140+
public ChangeableProperty<bool> PlatformWin32 { get; }
104141

105142
public ChangeableProperty<YamlInstallerType> InstallerType { get; }
106143

107144
public ChangeableProperty<YamlScope> Scope { get; }
108145

109-
public ChangeableProperty<string> SystemAppId { get; }
146+
public ChangeableProperty<string> ProductCode { get; }
147+
148+
public ChangeableProperty<string> PackageFamilyName { get; }
110149

111150
public ValidatedChangeableProperty<string> SignatureSha256 { get; }
112151

113152
public ChangeableProperty<string> SilentCommand { get; }
153+
154+
public ChangeableProperty<string> InteractiveCommand { get; }
155+
156+
public ChangeableProperty<string> LogCommand { get; }
157+
158+
public ChangeableProperty<string> UpgradeCommand { get; }
114159

115160
public ChangeableProperty<string> CustomCommand { get; }
116161

@@ -120,16 +165,16 @@ public void SetData(YamlInstaller installer, bool useNullValues = true)
120165

121166
public string Url { get; set; }
122167

123-
public bool IsMsix => this.InstallerType.CurrentValue == YamlInstallerType.msix || this.InstallerType.CurrentValue == YamlInstallerType.appx;
168+
public bool IsMsix => this.InstallerType.CurrentValue == YamlInstallerType.Msix || this.InstallerType.CurrentValue == YamlInstallerType.Appx;
124169

125170
public bool IsCommand
126171
{
127172
get
128173
{
129174
switch (this.InstallerType.CurrentValue)
130175
{
131-
case YamlInstallerType.none:
132-
case YamlInstallerType.exe:
176+
case YamlInstallerType.None:
177+
case YamlInstallerType.Exe:
133178
return true;
134179
default:
135180
return false;
@@ -229,43 +274,57 @@ public override void Commit()
229274
{
230275
base.Commit();
231276

232-
this.Model.SystemAppId = this.SystemAppId.CurrentValue;
233-
234-
if (this.Architecture.CurrentValue == YamlArchitecture.none)
235-
{
236-
this.Model.Arch = 0;
237-
}
238-
else
239-
{
240-
this.Model.Arch = this.Architecture.CurrentValue;
241-
}
242-
243-
if (this.Scope.CurrentValue == YamlScope.none)
277+
this.Model.PackageFamilyName = this.PackageFamilyName.CurrentValue;
278+
this.Model.ProductCode = this.ProductCode.CurrentValue;
279+
this.Model.Architecture = this.Architecture.CurrentValue;
280+
281+
if (!this.PlatformUwp.CurrentValue && !this.PlatformWin32.CurrentValue)
244282
{
245-
this.Model.Scope = default;
283+
this.Model.Platform = null;
246284
}
247285
else
248286
{
249-
this.Model.Scope = this.Scope.CurrentValue;
287+
this.Model.Platform = new List<YamlPlatform>();
288+
if (this.PlatformWin32.CurrentValue)
289+
{
290+
this.Model.Platform.Add(YamlPlatform.WindowsDesktop);
291+
}
292+
293+
if (this.PlatformUwp.CurrentValue)
294+
{
295+
this.Model.Platform.Add(YamlPlatform.WindowsUniversal);
296+
}
250297
}
251-
252-
if (string.IsNullOrEmpty(this.SilentCommandWithProgress.CurrentValue) && string.IsNullOrEmpty(this.SilentCommand.CurrentValue))
298+
299+
this.Model.Scope = this.Scope.CurrentValue;
300+
301+
if (
302+
string.IsNullOrWhiteSpace(this.SilentCommandWithProgress.CurrentValue) &&
303+
string.IsNullOrWhiteSpace(this.SilentCommand.CurrentValue) &&
304+
string.IsNullOrWhiteSpace(this.UpgradeCommand.CurrentValue) &&
305+
string.IsNullOrWhiteSpace(this.LogCommand.CurrentValue) &&
306+
string.IsNullOrWhiteSpace(this.InteractiveCommand.CurrentValue) &&
307+
string.IsNullOrWhiteSpace(this.CustomCommand.CurrentValue))
253308
{
254-
this.Model.Switches = null;
309+
this.Model.InstallerSwitches = null;
255310
}
256-
else if (this.Model.Switches == null)
311+
else if (this.Model.InstallerSwitches == null)
257312
{
258-
this.Model.Switches = new YamlSwitches();
313+
this.Model.InstallerSwitches = new YamlInstallerSwitches();
259314
}
260315

261-
if (this.Model.Switches != null)
316+
if (this.Model.InstallerSwitches != null)
262317
{
263-
this.Model.Switches.SilentWithProgress = this.SilentCommandWithProgress.CurrentValue;
264-
this.Model.Switches.Silent = this.SilentCommand.CurrentValue;
265-
this.Model.Switches.Custom = this.CustomCommand.CurrentValue;
318+
this.Model.InstallerSwitches.SilentWithProgress = this.SilentCommandWithProgress.CurrentValue;
319+
this.Model.InstallerSwitches.Silent = this.SilentCommand.CurrentValue;
320+
this.Model.InstallerSwitches.Custom = this.CustomCommand.CurrentValue;
321+
this.Model.InstallerSwitches.Interactive = this.InteractiveCommand.CurrentValue;
322+
this.Model.InstallerSwitches.Log = this.LogCommand.CurrentValue;
323+
this.Model.InstallerSwitches.Upgrade = this.UpgradeCommand.CurrentValue;
266324
}
267325

268-
this.Model.SystemAppId = this.SystemAppId.CurrentValue;
326+
this.Model.ProductCode = this.ProductCode.CurrentValue;
327+
this.Model.PackageFamilyName = this.PackageFamilyName.CurrentValue;
269328
this.Model.SignatureSha256 = this.SignatureSha256.CurrentValue;
270329
}
271330

@@ -277,7 +336,7 @@ private void InstallerTypeOnValueChanged(object sender, ValueChangedEventArgs e)
277336

278337
private string ValidateInstallerType(YamlInstallerType value)
279338
{
280-
if (value == YamlInstallerType.none)
339+
if (value == YamlInstallerType.None)
281340
{
282341
return "The installation type must be selected.";
283342
}

src/Otor.MsixHero.Tests/Winget/InstallerTypeDetectorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void TestNsis()
3737
using (var s = typeof(InstallerTypeDetectorTests).Assembly.GetManifestResourceStream(nsis))
3838
{
3939
var detect = sd.DetectSetupType(s).Result;
40-
Assert.AreEqual(YamlInstallerType.nullsoft, detect);
40+
Assert.AreEqual(YamlInstallerType.Nullsoft, detect);
4141
}
4242
}
4343

@@ -51,7 +51,7 @@ public void TestInno()
5151
using (var s = typeof(InstallerTypeDetectorTests).Assembly.GetManifestResourceStream(inno))
5252
{
5353
var detect = sd.DetectSetupType(s).Result;
54-
Assert.AreEqual(YamlInstallerType.inno, detect);
54+
Assert.AreEqual(YamlInstallerType.InnoSetup, detect);
5555
}
5656
}
5757
}

src/Otor.MsixHero.Tests/Winget/TestSerialization.cs

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -58,66 +58,75 @@ public void TestBasic()
5858
}
5959

6060
[Test]
61-
[Ignore("To be investigated")]
6261
public void TestEverNote()
6362
{
64-
var evernote = @"Id: evernote.evernote
65-
Name: Evernote
66-
AppMoniker: evernote
67-
Version: 6.24.2.8919
63+
var evernote = @"PackageIdentifier: evernote.evernote
64+
PackageName: Evernote
65+
Moniker: evernote
66+
PackageVersion: 6.24.2.8919
6867
Publisher: Evernote
6968
Author: Evernote
7069
License: Copyright (c) 2020 Evernote Corporation. All rights reserved.
7170
LicenseUrl: https://evernote.com/legal/terms-of-service
72-
MinOSVersion: 10.0.0.0
73-
Homepage: https://www.evernote.com
74-
Description: Evernote helps you focus on what matters most and have access to your information when you need it. Input typed notes or scan handwritten notes. Add to-do’s, photos, images, web pages, or audio ... and it's all instantly searchable. Organize notes any way you want and share with anyone. And Evernote syncs across your devices so your information is always with you, everywhere you go.
75-
Tags: ""evernote,notes,cloud,online""
71+
MinimumOSVersion: 10.0.0.0
72+
PackageUrl: https://www.evernote.com
73+
ShortDescription: evernote.evernote
74+
Description: Evernote helps you focus on what matters most and have access to your information when you need it. Input typed notes or scan handwritten notes. Add to-do’s, photos, images, web pages, or audio ... and it’s all instantly searchable. Organize notes any way you want and share with anyone. And Evernote syncs across your devices so your information is always with you, everywhere you go.
75+
Tags:
76+
- evernote
77+
- notes
78+
- cloud
79+
- online
7680
InstallerType: exe
77-
Installers:
78-
- Arch: x64
79-
Url: https://cdn1.evernote.com/win6/public/Evernote_6.24.2.8919.exe
80-
Sha256: 4851DBDB36ECEF1D5F2DE092673B4D70223703F6211FD8A1909B2E3E44AED5F9
81-
Language: en-US
82-
Scope: user
83-
Switches:
84-
Silent: /qn
85-
SilentWithProgress: /qn";
81+
Installers:
82+
- Architecture: x64
83+
InstallerUrl: https://cdn1.evernote.com/win6/public/Evernote_6.24.2.8919.exe
84+
InstallerSha256: 4851DBDB36ECEF1D5F2DE092673B4D70223703F6211FD8A1909B2E3E44AED5F9
85+
InstallerLocale: en-US
86+
Scope: user
87+
InstallerSwitches:
88+
Silent: /qn
89+
SilentWithProgress: /qn
90+
PackageLocale: en-US
91+
ManifestType: singleton
92+
ManifestVersion: 1.0.0
93+
";
8694

8795
var reader = new YamlReader();
8896
using TextReader textReader = new StringReader(evernote);
8997
var yaml = reader.Read(textReader);
9098

91-
Assert.AreEqual("evernote.evernote", yaml.Id);
92-
Assert.AreEqual("Evernote", yaml.Name);
99+
Assert.AreEqual("evernote.evernote", yaml.PackageIdentifier);
100+
Assert.AreEqual("Evernote", yaml.PackageName);
93101
Assert.AreEqual("Evernote", yaml.Publisher);
94-
Assert.AreEqual("evernote", yaml.AppMoniker);
102+
Assert.AreEqual("evernote", yaml.Moniker);
95103
Assert.AreEqual("Copyright (c) 2020 Evernote Corporation. All rights reserved.", yaml.License);
96104
Assert.AreEqual("https://evernote.com/legal/terms-of-service", yaml.LicenseUrl);
97-
Assert.AreEqual("6.24.2.8919", yaml.Version);
98-
Assert.AreEqual("10.0.0.0", yaml.MinOperatingSystemVersion.ToString());
99-
Assert.AreEqual("Evernote helps you focus on what matters most and have access to your information when you need it. Input typed notes or scan handwritten notes. Add to-do’s, photos, images, web pages, or audio ... and it's all instantly searchable. Organize notes any way you want and share with anyone. And Evernote syncs across your devices so your information is always with you, everywhere you go.", yaml.Description);
100-
Assert.AreEqual("https://www.evernote.com", yaml.Homepage);
101-
Assert.AreEqual("evernote,notes,cloud,online", yaml.Tags);
105+
Assert.AreEqual("6.24.2.8919", yaml.PackageVersion);
106+
Assert.AreEqual("10.0.0.0", yaml.MinimumOperatingSystemVersion.ToString());
107+
Assert.AreEqual("Evernote helps you focus on what matters most and have access to your information when you need it. Input typed notes or scan handwritten notes. Add to-do’s, photos, images, web pages, or audio ... and it’s all instantly searchable. Organize notes any way you want and share with anyone. And Evernote syncs across your devices so your information is always with you, everywhere you go.", yaml.Description);
108+
Assert.AreEqual("evernote.evernote", yaml.ShortDescription);
109+
Assert.AreEqual("https://www.evernote.com", yaml.PackageUrl);
110+
Assert.AreEqual("evernote,notes,cloud,online", string.Join(",", yaml.Tags));
102111
#pragma warning disable 618
103112
Assert.AreEqual("Evernote", yaml.Author);
104-
Assert.AreEqual(YamlInstallerType.exe, yaml.InstallerType);
113+
Assert.AreEqual(YamlInstallerType.Exe, yaml.InstallerType);
105114
#pragma warning restore 618
106115
Assert.NotNull(yaml.Installers);
107116
Assert.AreEqual(1, yaml.Installers.Count);
108117

109118
var ins = yaml.Installers[0];
110119

111-
Assert.AreEqual(YamlArchitecture.x64, ins.Arch);
112-
Assert.AreEqual("https://cdn1.evernote.com/win6/public/Evernote_6.24.2.8919.exe", ins.Url);
120+
Assert.AreEqual(YamlArchitecture.X64, ins.Architecture);
121+
Assert.AreEqual("https://cdn1.evernote.com/win6/public/Evernote_6.24.2.8919.exe", ins.InstallerUrl);
113122
#pragma warning disable 618
114-
Assert.AreEqual("en-US", ins.Language);
123+
Assert.AreEqual("en-US", ins.InstallerLocale);
115124
#pragma warning restore 618
116-
Assert.AreEqual(YamlScope.user, ins.Scope);
117-
Assert.NotNull(ins.Switches);
125+
Assert.AreEqual(YamlScope.User, ins.Scope);
126+
Assert.NotNull(ins.InstallerSwitches);
118127

119-
Assert.AreEqual("/qn", ins.Switches.Silent);
120-
Assert.AreEqual("/qn", ins.Switches.SilentWithProgress);
128+
Assert.AreEqual("/qn", ins.InstallerSwitches.Silent);
129+
Assert.AreEqual("/qn", ins.InstallerSwitches.SilentWithProgress);
121130
}
122131
}
123132
}

0 commit comments

Comments
 (0)