public void PublishNewVersion(ModuleManifest manifest) { var version = ExternalModuleManifestVersion.FromManifest(manifest); Versions.Add(version); var byPlatformMajorGroups = Versions.GroupBy(x => x.PlatformSemanticVersion.Major).OrderByDescending(x => x.Key).ToList(); Versions.Clear(); foreach (var byPlatformGroup in byPlatformMajorGroups) { var latestReleaseVersion = byPlatformGroup.Where(x => string.IsNullOrEmpty(x.VersionTag)) .OrderByDescending(x => x.SemanticVersion).FirstOrDefault(); if (latestReleaseVersion != null) { Versions.Add(latestReleaseVersion); } var latestPreReleaseVersion = byPlatformGroup.Where(x => !string.IsNullOrEmpty(x.VersionTag)) .OrderByDescending(x => x.SemanticVersion) .ThenByDescending(x => x.VersionTag).FirstOrDefault(); var addPreRelease = latestPreReleaseVersion != null; if (addPreRelease) { addPreRelease = latestReleaseVersion == null || (!latestPreReleaseVersion.SemanticVersion.Equals(latestReleaseVersion.SemanticVersion) && latestReleaseVersion.SemanticVersion.IsCompatibleWithBySemVer(latestPreReleaseVersion.SemanticVersion)); } if (addPreRelease) { Versions.Add(latestPreReleaseVersion); } } }
public static ExternalModuleManifestVersion FromManifest(ModuleManifest manifest) { var result = new ExternalModuleManifestVersion { Dependencies = manifest.Dependencies, Incompatibilities = manifest.Incompatibilities, PackageUrl = manifest.PackageUrl, PlatformVersion = manifest.PlatformVersion, ReleaseNotes = manifest.ReleaseNotes, Version = manifest.Version, VersionTag = manifest.VersionTag }; return(result); }
public static ExternalModuleManifest FromManifest(ModuleManifest manifest) { var result = new ExternalModuleManifest { Title = manifest.Title, Description = manifest.Description, Authors = manifest.Authors, Copyright = manifest.Copyright, Groups = manifest.Groups, IconUrl = manifest.IconUrl, Id = manifest.Id, LicenseUrl = manifest.LicenseUrl, Owners = manifest.Owners, ProjectUrl = manifest.ProjectUrl, RequireLicenseAcceptance = manifest.RequireLicenseAcceptance, Tags = manifest.Tags }; result.Versions.Add(ExternalModuleManifestVersion.FromManifest(manifest)); return(result); }
public virtual ManifestModuleInfo LoadFromExternalManifest(ExternalModuleManifest manifest, ExternalModuleManifestVersion version) { if (manifest == null) { throw new ArgumentNullException(nameof(manifest)); } ModuleName = manifest.Id; if (version.Dependencies != null) { foreach (var dependency in version.Dependencies) { DependsOn.Add(dependency.Id); } } Id = manifest.Id; Version = version.SemanticVersion; VersionTag = version.VersionTag; PlatformVersion = version.PlatformSemanticVersion; ReleaseNotes = version.ReleaseNotes; Ref = version.PackageUrl; if (version.Dependencies != null) { Dependencies.AddRange(version.Dependencies.Select(x => new ModuleIdentity(x.Id, SemanticVersion.Parse(x.Version)))); } if (version.Incompatibilities != null) { Incompatibilities.AddRange(version.Incompatibilities.Select(x => new ModuleIdentity(x.Id, SemanticVersion.Parse(x.Version)))); } Title = manifest.Title; Description = manifest.Description; Authors = manifest.Authors; Owners = manifest.Owners; LicenseUrl = manifest.LicenseUrl; ProjectUrl = manifest.ProjectUrl; IconUrl = manifest.IconUrl; RequireLicenseAcceptance = manifest.RequireLicenseAcceptance; Copyright = manifest.Copyright; Tags = manifest.Tags; Identity = new ModuleIdentity(Id, Version); if (manifest.Groups != null) { Groups.AddRange(manifest.Groups); } return(this); }