Skip to content

Commit fd9fcdb

Browse files
committed
add dependency listing to scoop
1 parent e01b40c commit fd9fcdb

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

src/UniGetUI.PackageEngine.Managers.Scoop/Helpers/ScoopPkgDetailsHelper.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,63 @@ protected override void GetDetails_UnSafe(IPackageDetails details)
157157
out var releaseNotesUrl))
158158
details.ReleaseNotesUrl = releaseNotesUrl;
159159

160+
_getDepends(details, contents);
161+
_getSuggests(details, contents);
162+
160163
logger.Close(0);
161164
}
162165

166+
private static void _getSuggests(IPackageDetails details, JsonObject? contents)
167+
{
168+
foreach (var rawDep in (contents?["suggest"]?.AsObject() ?? []))
169+
{
170+
List<string> innerDeps = [];
171+
172+
if(rawDep.Value is JsonValue value) innerDeps.Add(value.GetValue<string>());
173+
else
174+
{
175+
foreach (var iDep in rawDep.Value?.AsArray() ?? [])
176+
{
177+
string? val = iDep?.GetValue<string>();
178+
if(val is not null) innerDeps.Add(val);
179+
}
180+
}
181+
182+
foreach(var val in innerDeps)
183+
details.Dependencies.Add(new()
184+
{
185+
Name = val,
186+
Version = "",
187+
Mandatory = false,
188+
});
189+
}
190+
}
191+
192+
private static void _getDepends(IPackageDetails details, JsonObject? contents)
193+
{
194+
var node = contents?["depends"];
195+
List<string> innerDeps = [];
196+
197+
198+
if(node is JsonValue value) innerDeps.Add(value.GetValue<string>());
199+
else
200+
{
201+
foreach (var iDep in node?.AsArray() ?? [])
202+
{
203+
string? val = iDep?.GetValue<string>();
204+
if(val is not null) innerDeps.Add(val);
205+
}
206+
}
207+
208+
foreach(var val in innerDeps)
209+
details.Dependencies.Add(new()
210+
{
211+
Name = val,
212+
Version = "",
213+
Mandatory = true,
214+
});
215+
}
216+
163217
protected override CacheableIcon? GetIcon_UnSafe(IPackage package)
164218
{
165219
throw new NotImplementedException();

src/UniGetUI.PackageEngine.Managers.Scoop/Scoop.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public Scoop()
5151
CanRunAsAdmin = true,
5252
CanSkipIntegrityChecks = true,
5353
CanDownloadInstaller = true,
54+
CanListDependencies = true,
5455
CanRemoveDataOnUninstall = true,
5556
SupportsCustomArchitectures = true,
5657
SupportedCustomArchitectures = [Architecture.x86, Architecture.x64, Architecture.arm64],

0 commit comments

Comments
 (0)