public Updater(GithubRelease updateToVersion) { InitializeComponent(); backgroundWorker.DoWork += UpdateTool; backgroundWorker.ProgressChanged += UpdateProgress; backgroundWorker.RunWorkerCompleted += OnDone; backgroundWorker.WorkerReportsProgress = true; // bit of a hack to check if we're using the self-contained binary or not var isSelfContained = File.Exists("System.dll"); foreach (var asset in updateToVersion.assets) { if ((isSelfContained && asset.name.Contains("sc")) || !(isSelfContained || asset.name.Contains("sc"))) { releaseAsset = asset; break; } } }
private Metadata TransformOne( Metadata metadata, JObject json, GithubRef ghRef, GithubRepo ghRepo, GithubRelease ghRelease, GithubReleaseAsset ghAsset, String version ) { if (!string.IsNullOrWhiteSpace(ghRepo.Description)) { json.SafeAdd("abstract", ghRepo.Description); } // GitHub says NOASSERTION if it can't figure out the repo's license if (!string.IsNullOrWhiteSpace(ghRepo.License?.Id) && ghRepo.License.Id != "NOASSERTION") { json.SafeAdd("license", ghRepo.License.Id); } // Make sure resources exist. if (json["resources"] == null) { json["resources"] = new JObject(); } var resourcesJson = (JObject)json["resources"]; if (!string.IsNullOrWhiteSpace(ghRepo.Homepage)) { resourcesJson.SafeAdd("homepage", ghRepo.Homepage); } resourcesJson.SafeAdd("repository", ghRepo.HtmlUrl); if (ghRepo.HasIssues) { resourcesJson.SafeAdd("bugtracker", $"{ghRepo.HtmlUrl}/issues"); } if (ghRelease != null) { json.SafeAdd("version", version); json.SafeAdd("author", () => getAuthors(ghRepo, ghRelease)); json.Remove("$kref"); json.SafeAdd("download", ghAsset.Download.ToString()); json.SafeAdd(Metadata.UpdatedPropertyName, ghAsset.Updated); if (ghRef.Project.Contains("_")) { json.SafeAdd("name", ghRef.Project.Replace("_", " ")); } else if (ghRef.Project.Contains("-")) { json.SafeAdd("name", ghRef.Project.Replace("-", " ")); } else if (ghRef.Project.Contains(".")) { json.SafeAdd("name", ghRef.Project.Replace(".", " ")); } else { var repoName = ghRef.Project; for (var i = 1; i < repoName.Length - 1; ++i) { if (char.IsLower(repoName[i - 1]) && char.IsUpper(repoName[i]) || repoName[i - 1] != ' ' && char.IsUpper(repoName[i]) && char.IsLower(repoName[i + 1])) { repoName = repoName.Insert(i, " "); } } json.SafeAdd("name", repoName); } json.SafeMerge( "x_netkan_version_pieces", JObject.FromObject(new Dictionary <string, string> { { "tag", ghRelease.Tag.ToString() } }) ); Log.DebugFormat("Transformed metadata:{0}{1}", Environment.NewLine, json); return(new Metadata(json)); } else { Log.WarnFormat("No releases found for {0}", ghRef.Repository); return(metadata); } }