Skip to content

Commit

Permalink
VCI-156: Add ability to update only platform (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
krankenbro authored Sep 22, 2021
1 parent 12d2f39 commit a31f30f
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions PlatformTools/Build.PackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal partial class Build
public static bool SkipDependencySolving { get; set; }

[Parameter("Install the platform", Name = "Platform")]
public static bool InstallPlatformParam { get; set; }
public static bool PlatformParameter { get; set; }

public Target Init => _ => _
.Executes(async () =>
Expand All @@ -47,7 +47,7 @@ internal partial class Build
var localModuleCatalog = LocalModuleCatalog.GetCatalog(GetDiscoveryPath(), ProbingPath);
var externalModuleCatalog = ExtModuleCatalog.GetCatalog(GitHubToken, localModuleCatalog, packageManifest.ModuleSources);

if (Module?.Length > 0 && !InstallPlatformParam)
if (Module?.Length > 0 && !PlatformParameter)
{
foreach (var module in ParseModuleParameter(Module))
{
Expand Down Expand Up @@ -88,13 +88,13 @@ internal partial class Build
}
}
}
else if (!InstallPlatformParam && !packageManifest.Modules.Any())
else if (!PlatformParameter && !packageManifest.Modules.Any())
{
Logger.Info("Add group: commerce");
var commerceModules = externalModuleCatalog.Modules.OfType<ManifestModuleInfo>().Where(m => m.Groups.Contains("commerce")).Select(m => new ModuleItem(m.Id, m.Version.ToString()));
packageManifest.Modules.AddRange(commerceModules);
}
else if (InstallPlatformParam)
else if (PlatformParameter)
{
var platformRelease = await GithubManager.GetPlatformRelease(GitHubToken, VersionToInstall);
packageManifest.PlatformVersion = platformRelease.TagName;
Expand Down Expand Up @@ -291,19 +291,23 @@ private bool NeedToInstallPlatform(string version)
var platformRelease = await GithubManager.GetPlatformRelease(GitHubToken, VersionToInstall);
packageManifest.PlatformVersion = platformRelease.TagName;
packageManifest.PlatformAssetUrl = platformRelease.Assets.First().BrowserDownloadUrl;
var localModuleCatalog = LocalModuleCatalog.GetCatalog(GetDiscoveryPath(), ProbingPath);
var externalModuleCatalog = ExtModuleCatalog.GetCatalog(GitHubToken, localModuleCatalog, packageManifest.ModuleSources);

foreach (var module in packageManifest.Modules)
if (!PlatformParameter)
{
var externalModule = externalModuleCatalog.Modules.OfType<ManifestModuleInfo>().Where(m => m.Id == module.Id).FirstOrDefault(m => m.Ref.Contains("github.com"));
var localModuleCatalog = LocalModuleCatalog.GetCatalog(GetDiscoveryPath(), ProbingPath);
var externalModuleCatalog = ExtModuleCatalog.GetCatalog(GitHubToken, localModuleCatalog, packageManifest.ModuleSources);

if (externalModule == null)
foreach (var module in packageManifest.Modules)
{
ControlFlow.Fail($"No module {module.Id} found");
}
var externalModule = externalModuleCatalog.Modules.OfType<ManifestModuleInfo>().Where(m => m.Id == module.Id).FirstOrDefault(m => m.Ref.Contains("github.com"));

module.Version = externalModule.Version.ToString();
if (externalModule == null)
{
ControlFlow.Fail($"No module {module.Id} found");
}

module.Version = externalModule.Version.ToString();
}
}

PackageManager.ToFile(packageManifest);
Expand Down

0 comments on commit a31f30f

Please sign in to comment.