Esempio n. 1
0
        public void InstallNode(Downloadable downloadable)
        {
            var installation = new Installation(this, this, GithubApi, Logger);
            var result       = installation.Install(downloadable);

            if (result.Success)
            {
                var reimports = Installs.Where(i => i.ConfigData.RequiresFullReimport && !i.InstallFinalized).ToArray();

                if (reimports.Any())
                {
                    var msg = "Following packages require full reimport to function properly:\n";
                    foreach (var reimport in reimports)
                    {
                        msg += reimport.ToShortString() + "\n";
                    }

                    ThreadingUtils.DispatchOnMainThread(() =>
                    {
                        if (EditorUtility.DisplayDialog("Koinonia", msg, "Ok", "No, I'll do it myself"))
                        {
                            EditorApplication.ExecuteMenuItem("Assets/Reimport All");
                        }
                        else
                        {
                            AssetDatabase.Refresh();
                        }
                    });
                }
                else
                {
                    ThreadingUtils.DispatchOnMainThread(AssetDatabase.Refresh);
                }
            }
        }
Esempio n. 2
0
        public static Downloadable FetchConfigData(this Downloadable downloadable, bool force = false)
        {
            if (downloadable.ConfigData != null && !force)
            {
                return(downloadable);
            }

            var configString = GithubApiManager.GetConfigDataString(downloadable.AuthorName, downloadable.RepositoryName,
                                                                    downloadable.CommitSha);

            downloadable.ConfigData = ConfigData.FromJsonString(configString);

            return(downloadable);
        }
Esempio n. 3
0
        private void Install_Internal(Downloadable downloadable)
        {
            try
            {
                Add(downloadable);

                AllocateTmp();
                foreach (var entry in PlanInstall.ToArray())
                {
                    AnalyzePackage(entry);
                }

                foreach (var entry in PlanInstall.ToArray())
                {
                    ExtractPackage(entry);
                }

                foreach (var entry in PlanInstall.ToArray())
                {
                    Commit(entry);
                }

                foreach (var entry in PlanInstall.ToArray())
                {
                    RegisterInstall(entry);
                }

                _installsRegistry.Commit();

                foreach (var entry in PlanInstall)
                {
                    _logger.Log("Installed " + entry.RepositoryName + " @ " + entry.Name);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ReleaseTmp();
            }
        }
Esempio n. 4
0
 public InstallationResult Install(Downloadable downloadable)
 {
     try
     {
         Install_Internal(downloadable);
     }
     catch (ConfigDataNotFoundException ex)
     {
         _logger.LogProblem(ex.Message);
         return(new InstallationResult()
         {
             Success = false
         });
     }
     return(new InstallationResult()
     {
         Success = true
     });
 }
Esempio n. 5
0
        private InstallPlanEntry Add(Downloadable downloadable)
        {
            _logger.Log("Adding " + downloadable + " to the queue");

            if (downloadable.ConfigData == null)
            {
                _logger.Log("Fetching config file for " + downloadable);
                downloadable.FetchConfigData();
            }

            if (downloadable.ConfigData == null)
            {
                throw new ConfigDataNotFoundException(downloadable);
            }

            var installationEntry = new InstallPlanEntry()
            {
                AuthorName = downloadable.AuthorName, RepositoryName = downloadable.RepositoryName, CommitSha = downloadable.CommitSha, Name = downloadable.Name, Type = downloadable.Type, ConfigData = downloadable.ConfigData, AssociatedDate = downloadable.AssociatedDate
            };

            PlanInstall.Add(installationEntry);

            return(installationEntry);
        }
Esempio n. 6
0
        public void Install(string[] args)
        {
            GithubRepositoryEntry dec = GithubSchemeDecoder.Decode(args[1]);

            Terminal.Log(string.Format("Will install {0} from {1} at {2}", dec.Name, dec.Owner, dec.Tag));

            var downloadableHost = new DownloadablesHost()
            {
                AuthorName     = dec.Owner,
                RepositoryName = dec.Name
            };

            Terminal.Log("Fetching downloadables...");

            downloadableHost.FetchDownloadables();

            Terminal.Log(string.Format("{0}/{1} contains {2} downloadable entries...", dec.Owner, dec.Name, downloadableHost.Downloadables.Count));


            Downloadable d = downloadableHost.Downloadables.FirstOrDefault();

            if (!string.IsNullOrEmpty(dec.Tag))
            {
                d = downloadableHost.Downloadables.FirstOrDefault(_ => _.Name == dec.Tag);
            }

            if (d == null)
            {
                throw new Exception("Downloadable Entry not found");
            }

            Terminal.Log(string.Format("Installing {0}/{1} @ {2} # {3}...", d.AuthorName, d.RepositoryName, d.Name, d.CommitSha));


            KoinoniaApplication.Instance.InstallNode(d);
        }
Esempio n. 7
0
 public bool IsInstallOf(Downloadable host)
 {
     return(host.AuthorName == AuthorName && host.RepositoryName == RepositoryName && host.Name == Name);
 }
Esempio n. 8
0
        public bool Update(Install install)
        {
            var host = new DownloadablesHost()
            {
                AuthorName     = install.AuthorName,
                RepositoryName = install.RepositoryName
            };

            host.FetchDownloadables();

            Downloadable update = null;

            switch (install.Type)
            {
            case DownloadableType.Branch:
                var newsetCommit = host.Downloadables.FirstOrDefault(s => s.Type == DownloadableType.Branch && s.Name == install.Name);
                if (newsetCommit == null)
                {
                    _logger.LogProblem("No commits found for branch " + install.Name);
                    return(false);
                }
                if (newsetCommit.CommitSha != install.CommitSha)
                {
                    update = newsetCommit;
                }
                else
                {
                    _logger.Log("Nothing to update");
                }
                break;

            case DownloadableType.Tag:
                _logger.LogProblem("Updating Tags is not supported. Install release instead.");
                return(false);

            case DownloadableType.Release:
                var release = host.Downloadables.FirstOrDefault(s => s.Type == DownloadableType.Release && s.AssociatedDate > install.AssociatedDate);
                if (release == null)
                {
                    _logger.Log("Nothing to update");
                    return(false);
                }
                else
                {
                    update = release;
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (update == null)
            {
                return(false);
            }
            _logger.Log("Will replace " + install.AssociatedDate + " with " + update.AssociatedDate);

            var uninstall = new Uninstallation(_hostsRegistry, _installsRegistry, _githubApi, _logger);

            uninstall.Uninstall(install);

            var installation = new Installation(_hostsRegistry, _installsRegistry, _githubApi, _logger);

            installation.Install(update);

            return(true);
        }
Esempio n. 9
0
 public ConfigDataNotFoundException(Downloadable target)
 {
     Target = target;
 }