public static FeedzClient Create(string pat, string region) { var useXyz = !string.IsNullOrEmpty(region) && region.StartsWith("xyz"); if (useXyz) region = region.Substring(3); return useXyz ? FeedzClient.Create(pat, "https://feedz.xyz/", "https://f.feedz.xyz/") : FeedzClient.Create(pat); }
private static async Task UploadPackagesAsync() { try { var client = FeedzClient.Create(_apiKey); RepositoryScope repositoryScope = client.ScopeToRepository(_organization, _repository); // Load *ALL* the New Packages var files = Directory.GetFiles(_path); var numberOfFiles = files.Count(); var counterFiles = 1; Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine($"{numberOfFiles} (*.nupkg) file(s) found!"); Console.WriteLine(); foreach (var file in files) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine($"[{counterFiles}] Uploading {file}..."); try { await repositoryScope.PackageFeed.Upload(file); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"{file} correctly uploaded!"); Console.WriteLine(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); if (ex.Message == "Forbidden") { Console.WriteLine("Please, check the API Key to access and write into your own repo"); } Console.WriteLine(); Console.ResetColor(); } counterFiles += 1; } Console.ResetColor(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("An error ocurred!"); Console.WriteLine(ex.Message); Console.WriteLine(); Console.ResetColor(); } }