public UpmVersionList(PackageInfo info, bool isInstalled, bool isUnityPackage) { m_LifecycleVersionString = info.unityLifecycle?.version; m_LifecycleNextVersionString = info.unityLifecycle?.nextVersion; if (m_LifecycleVersionString != null) { SemVersionParser.TryParse(m_LifecycleVersionString, out m_LifecycleVersion); } if (m_LifecycleNextVersionString != null) { SemVersionParser.TryParse(m_LifecycleNextVersionString, out m_LifecycleNextVersion); } var mainVersion = new UpmPackageVersion(info, isInstalled, isUnityPackage); m_Versions = info.versions.compatible.Select(v => { SemVersion?version; SemVersionParser.TryParse(v, out version); return(new UpmPackageVersion(info, false, version, mainVersion.displayName, isUnityPackage)); }).ToList(); AddToSortedVersions(m_Versions, mainVersion); m_InstalledIndex = m_Versions.FindIndex(v => v.isInstalled); }
internal static UpmPackageVersion ToPackageVersion(this AvailableVersion self, UpmPackageVersion baseInfo) { var semver = SemVersionParser.Parse(self.refNameVersion); var newPInfo = JsonUtility.FromJson <UnityEditor.PackageManager.PackageInfo>(JsonUtility.ToJson(baseInfo.packageInfo)); newPInfo.m_Version = self.version; newPInfo.m_Git = new GitInfo("", self.refName); #if UNITY_2020_1_5_OR_NEWER var p = new UpmPackageVersion(newPInfo, false, semver, newPInfo.displayName, false); #else var p = new UpmPackageVersion(newPInfo, false, semver, newPInfo.displayName); #endif // Update tag. PackageTag tag = PackageTag.Git | PackageTag.Installable | PackageTag.Removable; if (semver.Major == 0 || !string.IsNullOrEmpty(semver.Prerelease)) { tag |= PackageTag.Preview; } else if (semver.IsRelease()) { tag |= PackageTag.Release; } p.m_Tag = tag; p.m_IsFullyFetched = true; p.m_PackageId = string.Format("{0}@{1}#{2}", self.packageName, self.repoUrl, self.refName); return(p); }
private List <PackageSizeInfo> GetSizeInfoFromProductDetails(IDictionary <string, object> productDetail) { var result = new List <PackageSizeInfo>(); var uploads = productDetail.GetDictionary("uploads"); if (uploads != null) { foreach (var key in uploads.Keys) { var simpleVersion = Regex.Replace(key, @"(?<major>\d+)\.(?<minor>\d+).(?<patch>\d+)[abfp].+", "${major}.${minor}.${patch}"); SemVersion?version; bool isVersionParsed = SemVersionParser.TryParse(simpleVersion.Trim(), out version); if (isVersionParsed) { var info = uploads.GetDictionary(key); var assetCount = info.GetString("assetCount") ?? string.Empty; var downloadSize = info.GetString("downloadSize") ?? string.Empty; result.Add(new PackageSizeInfo { supportedUnityVersion = (SemVersion)version, assetCount = string.IsNullOrEmpty(assetCount) ? 0 : ulong.Parse(assetCount), downloadSize = string.IsNullOrEmpty(downloadSize) ? 0 : ulong.Parse(downloadSize) }); } } } return(result); }
private static bool IsPreviewInstalled(PackageInfo packageInfo) { SemVersion?packageInfoVersion; bool isPackageInfoVersionParsed = SemVersionParser.TryParse(packageInfo?.version, out packageInfoVersion); return(packageInfo?.isDirectDependency == true && packageInfo.source == PackageSource.Registry && isPackageInfoVersionParsed && !((SemVersion)packageInfoVersion).IsRelease()); }
public UpmPackageVersion(PackageInfo packageInfo, bool isInstalled, bool isUnityPackage) { SemVersionParser.TryParse(packageInfo.version, out m_Version); m_VersionString = m_Version?.ToString(); m_DisplayName = packageInfo.displayName; m_IsInstalled = isInstalled; m_PackageUniqueId = packageInfo.name; UpdatePackageInfo(packageInfo, isUnityPackage); }
private void OnInstalledPreviewPackagesChanged() { if (!PackageManagerPrefs.instance.hasShowPreviewPackagesKey) { PackageManagerPrefs.instance.showPreviewPackagesFromInstalled = UpmCache.instance.installedPackageInfos.Any(p => { SemVersion?version; bool isVersionParsed = SemVersionParser.TryParse(p.version, out version); return(isVersionParsed && !((SemVersion)version).IsRelease()); }); } }
private static bool IsPreviewInstalled(PackageInfo packageInfo) { if (packageInfo == null) { return(false); } SemVersion?packageInfoVersion; return(packageInfo.isDirectDependency && packageInfo.source == PackageSource.Registry && SemVersionParser.TryParse(packageInfo.version, out packageInfoVersion) && !((SemVersion)packageInfoVersion).IsRelease()); }
public UpmPackageVersion(IOProxy ioProxy, PackageInfo packageInfo, bool isInstalled) { ResolveDependencies(ioProxy); SemVersionParser.TryParse(packageInfo.version, out m_Version); m_VersionString = m_Version?.ToString(); m_DisplayName = packageInfo.displayName; m_IsInstalled = isInstalled; m_PackageUniqueId = packageInfo.name; UpdatePackageInfo(packageInfo); }
public UpmVersionList(PackageInfo info, bool isInstalled) { var mainVersion = new UpmPackageVersion(info, isInstalled); m_Versions = info.versions.compatible.Select(v => { SemVersion?version; SemVersionParser.TryParse(v, out version); return(new UpmPackageVersion(info, false, version, mainVersion.displayName)); }).ToList(); AddToSortedVersions(m_Versions, mainVersion); m_InstalledIndex = m_Versions.FindIndex(v => v.isInstalled); }
public UpmVersionList(IEnumerable <UpmPackageVersion> versions = null, string unityLifecycleInfoVersion = null, string unityLifecycleInfoNextVersion = null) { m_Versions = versions?.ToList() ?? new List <UpmPackageVersion>(); m_InstalledIndex = m_Versions.FindIndex(v => v.isInstalled); m_LifecycleVersionString = unityLifecycleInfoVersion; m_LifecycleNextVersionString = unityLifecycleInfoNextVersion; if (m_LifecycleVersionString != null) { SemVersionParser.TryParse(m_LifecycleVersionString, out m_LifecycleVersion); } if (m_LifecycleNextVersionString != null) { SemVersionParser.TryParse(m_LifecycleNextVersionString, out m_LifecycleNextVersion); } }
public void SelectPackageAndFilter(string packageIdOrDisplayName, PackageFilterTab?filterTab = null, bool refresh = false, string searchText = "") { if (!string.IsNullOrEmpty(packageIdOrDisplayName) || filterTab != null) { if (filterTab == null) { m_PackageDatabase.GetPackageAndVersionByIdOrName(packageIdOrDisplayName, out var package, out var version); if (package != null) { filterTab = m_PageManager.FindTab(package, version); } else { var packageIdOrDisplayNameSplit = packageIdOrDisplayName.Split('@'); var versionString = packageIdOrDisplayNameSplit.Length == 2 ? packageIdOrDisplayNameSplit[1] : string.Empty; // Package is not found in PackageDatabase but we can determine if it's a preview package or not with it's version string. SemVersionParser.TryParse(versionString, out var semVersion); if (!m_SettingsProxy.enablePreviewPackages && semVersion.HasValue && (semVersion.Value.Major == 0 || semVersion.Value.Prerelease.StartsWith("preview"))) { Debug.Log("You must check \"Enable Preview Packages\" in Project Settings > Package Manager in order to see this package."); filterTab = m_PackageFiltering.currentFilterTab; packageIdOrDisplayName = null; } else { filterTab = PackageFilterTab.All; } } } m_FilterToSelectAfterLoad = filterTab; m_PackageToSelectOnLoaded = packageIdOrDisplayName; packageManagerToolbar.SetCurrentSearch(searchText); if (refresh || m_PackageDatabase.isEmpty) { DelayRefresh((PackageFilterTab)filterTab); } else { SelectPackageAndFilter(); } } }
private void GetUpmPackageAndVersion(string name, string versionIdentifier, out IPackage package, out IPackageVersion version) { package = GetPackage(name) as UpmPackage; if (package == null) { version = null; return; } // the versionIdentifier could either be SemVersion or file, git or ssh reference // and the two cases are handled differently. if (!string.IsNullOrEmpty(versionIdentifier) && char.IsDigit(versionIdentifier.First())) { SemVersion?parsedVersion; SemVersionParser.TryParse(versionIdentifier, out parsedVersion); version = package.versions.FirstOrDefault(v => v.version == parsedVersion); } else { var packageId = UpmPackageVersion.FormatPackageId(name, versionIdentifier); version = package.versions.FirstOrDefault(v => v.uniqueId == packageId); } }
private void RefreshTags() { // in the case of git/local packages, we always assume that the non-installed versions are from the registry var source = m_PackageInfo.source == PackageSource.BuiltIn || m_IsInstalled ? m_PackageInfo.source : PackageSource.Registry; switch (source) { case PackageSource.BuiltIn: m_Tag = PackageTag.Bundled | PackageTag.VersionLocked; if (m_PackageInfo.type == "module") { m_Tag |= PackageTag.BuiltIn; } break; case PackageSource.Embedded: m_Tag = PackageTag.InDevelopment | PackageTag.VersionLocked; break; case PackageSource.Local: case PackageSource.LocalTarball: m_Tag = PackageTag.Local; break; case PackageSource.Git: m_Tag = PackageTag.Git | PackageTag.VersionLocked; break; case PackageSource.Unknown: case PackageSource.Registry: default: m_Tag = PackageTag.None; break; } m_Tag |= PackageTag.Installable | PackageTag.Removable; if (isInstalled && isDirectDependency && !installedFromPath && !HasTag(PackageTag.BuiltIn)) { m_Tag |= PackageTag.Embeddable; } if (m_Version?.IsRelease() == true) { m_Tag |= PackageTag.Release; SemVersion?verified; bool isVerifiedParsed = SemVersionParser.TryParse(m_PackageInfo.versions.verified, out verified); if (isVerifiedParsed && m_Version == verified && !installedFromPath) { m_Tag |= PackageTag.Verified; } } else { if ((version?.Major == 0 && string.IsNullOrEmpty(version?.Prerelease)) || PackageTag.Preview.ToString().Equals(version?.Prerelease.Split('.')[0], StringComparison.InvariantCultureIgnoreCase)) { m_Tag |= PackageTag.Preview; } } }
public void OnAfterDeserialize() { // m_SupportedUnityVersionString will always be valid because it is set from an existing SemVersion m_SupportedUnityVersion = SemVersionParser.Parse(m_SupportedUnityVersionString); }
public virtual void OnAfterDeserialize() { SemVersionParser.TryParse(m_VersionString, out m_Version); }
public AssetStorePackageVersion(AssetStoreUtils assetStoreUtils, IOProxy ioProxy, AssetStoreProductInfo productInfo, AssetStoreLocalInfo localInfo = null) { if (productInfo == null) { throw new ArgumentNullException(nameof(productInfo)); } ResolveDependencies(assetStoreUtils, ioProxy); m_Errors = new List <UIError>(); m_Tag = PackageTag.Downloadable | PackageTag.Importable; m_PackageUniqueId = productInfo.id; m_Description = productInfo.description; m_Author = productInfo.author; m_PublisherId = productInfo.publisherId; m_Category = productInfo.category; m_PublishNotes = localInfo?.publishNotes ?? productInfo.publishNotes ?? string.Empty; m_VersionString = localInfo?.versionString ?? productInfo.versionString ?? string.Empty; m_VersionId = localInfo?.versionId ?? productInfo.versionId ?? string.Empty; SemVersionParser.TryParse(m_VersionString.Trim(), out m_Version); var publishDateString = localInfo?.publishedDate ?? productInfo.publishedDate ?? string.Empty; m_PublishedDateTicks = !string.IsNullOrEmpty(publishDateString) ? DateTime.Parse(publishDateString).Ticks : 0; m_DisplayName = !string.IsNullOrEmpty(productInfo.displayName) ? productInfo.displayName : $"Package {m_PackageUniqueId}@{m_VersionId}"; m_SupportedUnityVersions = new List <SemVersion>(); if (localInfo != null) { var simpleVersion = Regex.Replace(localInfo.supportedVersion, @"(?<major>\d+)\.(?<minor>\d+).(?<patch>\d+)[abfp].+", "${major}.${minor}.${patch}"); SemVersionParser.TryParse(simpleVersion.Trim(), out m_SupportedUnityVersion); m_SupportedUnityVersionString = m_SupportedUnityVersion?.ToString(); } else if (productInfo.supportedVersions?.Any() ?? false) { foreach (var supportedVersion in productInfo.supportedVersions) { SemVersion?version; bool isVersionParsed = SemVersionParser.TryParse(supportedVersion, out version); if (isVersionParsed) { m_SupportedUnityVersions.Add((SemVersion)version); } } m_SupportedUnityVersions.Sort((left, right) => (left).CompareTo(right)); m_SupportedUnityVersion = m_SupportedUnityVersions.LastOrDefault(); m_SupportedUnityVersionString = m_SupportedUnityVersion?.ToString(); } m_SizeInfos = new List <PackageSizeInfo>(productInfo.sizeInfos); m_SizeInfos.Sort((left, right) => left.supportedUnityVersion.CompareTo(right.supportedUnityVersion)); var state = productInfo.state ?? string.Empty; if (state.Equals("published", StringComparison.InvariantCultureIgnoreCase)) { m_Tag |= PackageTag.Published; } else if (state.Equals("deprecated", StringComparison.InvariantCultureIgnoreCase)) { m_Tag |= PackageTag.Deprecated; } else if (state.Equals("disabled", StringComparison.InvariantCultureIgnoreCase)) { m_Tag |= PackageTag.Disabled; } SetLocalPath(localInfo?.packagePath); }
public override void OnAfterDeserialize() { base.OnAfterDeserialize(); SemVersionParser.TryParse(m_SupportedUnityVersionString, out m_SupportedUnityVersion); }
private void RefreshTags() { // in the case of git/local packages, we always assume that the non-installed versions are from the registry var source = m_PackageInfo.source == PackageSource.BuiltIn || m_IsInstalled ? m_PackageInfo.source : PackageSource.Registry; switch (source) { case PackageSource.BuiltIn: m_Tag = PackageTag.Bundled | PackageTag.VersionLocked; if (m_PackageInfo.type == "module") { m_Tag |= PackageTag.BuiltIn; } else if (m_PackageInfo.type == "feature") { m_Tag |= PackageTag.Feature; } break; case PackageSource.Embedded: m_Tag = PackageTag.Custom | PackageTag.VersionLocked; break; case PackageSource.Local: case PackageSource.LocalTarball: m_Tag = PackageTag.Local; break; case PackageSource.Git: m_Tag = PackageTag.Git | PackageTag.VersionLocked; break; case PackageSource.Unknown: case PackageSource.Registry: default: m_Tag = PackageTag.None; break; } m_Tag |= PackageTag.Installable | PackageTag.Removable; if (isInstalled && isDirectDependency && !installedFromPath && !HasTag(PackageTag.BuiltIn)) { m_Tag |= PackageTag.Embeddable; } // lifecycle tags should not apply to scoped registry packages if (isUnityPackage) { var previewTagString = "Preview"; SemVersion?lifecycleVersionParsed; SemVersionParser.TryParse(packageInfo.unityLifecycle?.version, out lifecycleVersionParsed); if (m_Version?.HasPreReleaseVersionTag() == true) { // must match exactly to be release candidate if (m_VersionString == packageInfo.unityLifecycle?.version) { m_Tag |= PackageTag.ReleaseCandidate; } else { m_Tag |= PackageTag.PreRelease; } } else if (m_Version?.IsNotPreReleaseOrExperimental() == true) { m_Tag |= PackageTag.Release; } else if ((version?.Major == 0 && string.IsNullOrEmpty(version?.Prerelease)) || m_Version?.IsExperimental() == true || previewTagString.Equals(version?.Prerelease.Split('.')[0], StringComparison.InvariantCultureIgnoreCase)) { m_Tag |= PackageTag.Experimental; } } }
public void OnAfterDeserialize() { SemVersionParser.TryParse(m_LifecycleVersionString, out m_LifecycleVersion); SemVersionParser.TryParse(m_LifecycleNextVersionString, out m_LifecycleNextVersion); }