Example #1
0
        public void ListDownloadables(string[] args)
        {
            var shc = GithubSchemeDecoder.DecodeShort(args[1]);

            var host = new DownloadablesHost()
            {
                AuthorName     = shc.Owner,
                RepositoryName = shc.Name
            };

            host.FetchDownloadables();

            foreach (var downloadable in host.Downloadables)
            {
                Terminal.Log(downloadable.ToString());
            }
        }
Example #2
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);
        }
Example #3
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);
        }