private static string GetOfflineChangelogUrl(UpmPackageVersion version)
 {
     if (version?.isAvailableOnDisk ?? false)
     {
         var changelogFile = Path.Combine(version.packageInfo.resolvedPath, "CHANGELOG.md");
         return(File.Exists(changelogFile) ? new Uri(changelogFile).AbsoluteUri : string.Empty);
     }
     return(string.Empty);
 }
Exemplo n.º 2
0
        public UpmVersionList(PackageInfo info, bool isInstalled)
        {
            var mainVersion = new UpmPackageVersion(info, isInstalled);

            m_Versions = info.versions.compatible.Select(v => new UpmPackageVersion(info, false, v, mainVersion.displayName)).ToList();
            AddToSortedVersions(m_Versions, mainVersion);

            m_InstalledIndex = m_Versions.FindIndex(v => v.isInstalled);
        }
 private static string GetOfflineLicensesUrl(UpmPackageVersion version)
 {
     if (version?.isAvailableOnDisk ?? false)
     {
         var licenseFile = Path.Combine(version.packageInfo.resolvedPath, "LICENSE.md");
         return(File.Exists(licenseFile) ? new Uri(licenseFile).AbsoluteUri : string.Empty);
     }
     return(string.Empty);
 }
Exemplo n.º 4
0
        public UpmPackage(PackageInfo info, bool isInstalled, bool isDiscoverable)
        {
            var mainVersion = new UpmPackageVersion(info, isInstalled);

            var versions = info.versions.compatible.Select(v => new UpmPackageVersion(info, false, v, mainVersion.displayName)).ToList();

            AddToSortedVersions(versions, mainVersion);
            Initialize(info.name, versions, isDiscoverable);
        }
 public static string[] SplitBuiltinDescription(UpmPackageVersion version)
 {
     if (string.IsNullOrEmpty(version?.packageInfo?.description))
     {
         return new string[] { $"This built in package controls the presence of the {version.displayName} module." }
     }
     ;
     else
     {
         return(version.packageInfo.description.Split(new[] { k_BuiltinPackageDocsUrlKey }, StringSplitOptions.None));
     }
 }
Exemplo n.º 6
0
 public static string[] SplitBuiltinDescription(UpmPackageVersion version)
 {
     if (string.IsNullOrEmpty(version?.packageInfo?.description))
     {
         return new string[] { string.Format(ApplicationUtil.instance.GetTranslationForText("This built in package controls the presence of the {0} module."), version.displayName) }
     }
     ;
     else
     {
         return(version.packageInfo.description.Split(new[] { k_BuiltinPackageDocsUrlKey }, StringSplitOptions.None));
     }
 }
Exemplo n.º 7
0
 internal void UpdateVersion(UpmPackageVersion version)
 {
     for (var i = 0; i < m_Versions.Count; ++i)
     {
         if (m_Versions[i].uniqueId != version.uniqueId)
         {
             continue;
         }
         m_Versions[i] = version;
         return;
     }
 }
Exemplo n.º 8
0
 // This function is only used to update the object, not to actually perform the add operation
 public void AddInstalledVersion(UpmPackageVersion newVersion)
 {
     if (m_InstalledIndex >= 0)
     {
         m_Versions[m_InstalledIndex].isInstalled = false;
         if (m_Versions[m_InstalledIndex].HasTag(PackageTag.Git | PackageTag.Local | PackageTag.InDevelopment))
         {
             m_Versions.RemoveAt(m_InstalledIndex);
         }
     }
     newVersion.isInstalled = true;
     SetInstalledVersion(AddToSortedVersions(m_Versions, newVersion));
 }
Exemplo n.º 9
0
 // This function is only used to update the object, not to actually perform the add operation
 public void AddInstalledVersion(UpmPackageVersion newVersion)
 {
     if (m_InstalledIndex >= 0)
     {
         m_Versions[m_InstalledIndex].SetInstalled(false);
         if (m_Versions[m_InstalledIndex].installedFromPath)
         {
             m_Versions.RemoveAt(m_InstalledIndex);
         }
     }
     newVersion.SetInstalled(true);
     m_InstalledIndex = AddToSortedVersions(m_Versions, newVersion);
 }
Exemplo n.º 10
0
        internal static PackageInfo ToPackageVersion(this AvailableVersion self, PackageInfo baseInfo)
        {
            var newPInfo = JsonUtility.FromJson <PackageInfo>(JsonUtility.ToJson(baseInfo));

            newPInfo.Version = SemVersion.Parse(self.refNameVersion);
#if UNITY_2019_2_OR_NEWER
            newPInfo.IsInstalled = false;
#else
            newPInfo.IsCurrent = false;
#endif
            newPInfo.Info      = baseInfo.Info;
            newPInfo.PackageId = string.Format("{0}@{1}", newPInfo.Name, self.refNameVersion);
            return(newPInfo);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
 private static string GetOfflineDocumentationUrl(UpmPackageVersion version)
 {
     if (version?.isAvailableOnDisk ?? false)
     {
         var docsFolder = Path.Combine(version.packageInfo.resolvedPath, "Documentation~");
         if (!Directory.Exists(docsFolder))
         {
             docsFolder = Path.Combine(version.packageInfo.resolvedPath, "Documentation");
         }
         if (Directory.Exists(docsFolder))
         {
             var docsMd = Directory.GetFiles(docsFolder, "*.md", SearchOption.TopDirectoryOnly).FirstOrDefault();
             if (!string.IsNullOrEmpty(docsMd))
             {
                 return(new Uri(docsMd).AbsoluteUri);
             }
         }
     }
     return(string.Empty);
 }
Exemplo n.º 13
0
 private static int AddToSortedVersions(List <UpmPackageVersion> sortedVersions, UpmPackageVersion versionToAdd)
 {
     for (var i = 0; i < sortedVersions.Count; ++i)
     {
         if (versionToAdd.version != null && (sortedVersions[i].version?.CompareTo(versionToAdd.version) ?? -1) < 0)
         {
             continue;
         }
         // note that the difference between this and the previous function is that
         // two upm package versions could have the the same version but different package id
         if (sortedVersions[i].uniqueId == versionToAdd.uniqueId)
         {
             sortedVersions[i] = versionToAdd;
             return(i);
         }
         sortedVersions.Insert(i, versionToAdd);
         return(i);
     }
     sortedVersions.Add(versionToAdd);
     return(sortedVersions.Count - 1);
 }
Exemplo n.º 14
0
 private static string GetOfflineDocumentationUrl(IOProxy IOProxy, UpmPackageVersion version)
 {
     if (version?.isAvailableOnDisk ?? false)
     {
         var docsFolder = Path.Combine(version.packageInfo.resolvedPath, "Documentation~");
         if (!IOProxy.DirectoryExists(docsFolder))
         {
             docsFolder = Path.Combine(version.packageInfo.resolvedPath, "Documentation");
         }
         if (IOProxy.DirectoryExists(docsFolder))
         {
             var mdFiles = IOProxy.DirectoryGetFiles(docsFolder, "*.md", SearchOption.TopDirectoryOnly);
             var docsMd  = mdFiles.FirstOrDefault(d => Path.GetFileName(d).ToLower() == "index.md")
                           ?? mdFiles.FirstOrDefault(d => Path.GetFileName(d).ToLower() == "tableofcontents.md") ?? mdFiles.FirstOrDefault();
             if (!string.IsNullOrEmpty(docsMd))
             {
                 return(new Uri(docsMd).AbsoluteUri);
             }
         }
     }
     return(string.Empty);
 }
            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 = versionIdentifier;
                    version = package.versions.FirstOrDefault(v => v.version == parsedVersion);
                }
                else
                {
                    var packageId = UpmPackageVersion.FormatPackageId(name, versionIdentifier);
                    version = package.versions.FirstOrDefault(v => v.uniqueId == packageId);
                }
            }
Exemplo n.º 16
0
 internal static SemVersion GetVersion(this PackageInfo self)
 {
     return(self.Version);
 }
Exemplo n.º 17
0
        private static string GetNameText(DependencyInfo dependency)
        {
            var packageVersion = PackageDatabase.instance.GetPackageVersion(dependency);

            return(packageVersion != null ? packageVersion.displayName : UpmPackageVersion.ExtractDisplayName(dependency.name));
        }
Exemplo n.º 18
0
 internal static void UnlockVersion(this PackageInfo self)
 {
     self.Origin   = (PackageSource)99;
     self.IsLatest = false;
 }
Exemplo n.º 19
0
 // This function is only used to update the object, not to actually perform the add operation
 public void AddInstalledVersion(UpmPackageVersion newVersion)
 {
     m_VersionList.AddInstalledVersion(newVersion);
 }
Exemplo n.º 20
0
 internal static UnityEditor.PackageManager.PackageInfo GetPackageInfo(this PackageInfo self)
 {
     return(self.Info);
 }