Exemple #1
0
        public async Task Update(Config config, ILogger logger)
        {
            _packageManager.Connect("TheEadie", "WormsLeague", "schemes/v", config.GitHubPersonalAccessToken);

            var versions = (await _packageManager.GetAvailableVersions().ConfigureAwait(false)).ToList();

            logger.Verbose($"Available versions: {string.Join(", ", versions)}");

            var latestVersion = versions.OrderByDescending(x => x).FirstOrDefault();

            logger.Verbose($"Latest version: {latestVersion}");

            logger.Information($"Downloading Schemes: {latestVersion}");

            var schemesFolder = _wormsLocator.Find().SchemesFolder;

            await _packageManager.DownloadVersion(latestVersion, schemesFolder).ConfigureAwait(false);
        }
Exemple #2
0
        public async Task DownloadLatestUpdate(Config config, ILogger logger)
        {
            logger.Verbose("Starting update");

            var cliInfo = _cliInfoRetriever.Get();

            logger.Verbose(cliInfo.ToString());

            _packageManager.Connect("TheEadie", "WormsLeague", "cli/v", config.GitHubPersonalAccessToken);

            var versions = (await _packageManager.GetAvailableVersions().ConfigureAwait(false)).ToList();

            logger.Verbose($"Available versions: {string.Join(", ", versions)}");

            var latestVersion = versions.OrderByDescending(x => x).FirstOrDefault();

            logger.Verbose($"Latest version: {latestVersion}");

            if (cliInfo.Version > latestVersion)
            {
                logger.Information("Worms CLI is up to date");
                return;
            }

            logger.Information($"Downloading Worms CLI {latestVersion}");

            var updateFolder = _fileSystem.Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                "Programs",
                "Worms",
                ".update");

            EnsureFolderExistsAndIsEmpty(updateFolder);

            await _packageManager.DownloadVersion(latestVersion, updateFolder).ConfigureAwait(false);

            logger.Warning("Update available - To install the update run Install-WormsCli");
        }