From 1ed5f22b7c2be8bbf6f06e837f33ebda35014531 Mon Sep 17 00:00:00 2001 From: stam Date: Sun, 17 Jan 2021 02:29:47 +0300 Subject: [PATCH] final sourcetree support by kasthack --- json-backups/sourcetreeapp.csx | 36 ++++++++++++++++++++++++++++++++++ json-backups/update.sh | 4 ++-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 json-backups/sourcetreeapp.csx diff --git a/json-backups/sourcetreeapp.csx b/json-backups/sourcetreeapp.csx new file mode 100644 index 0000000..02ce95a --- /dev/null +++ b/json-backups/sourcetreeapp.csx @@ -0,0 +1,36 @@ +#r "nuget: AngleSharp, 1.0.0-alpha-844" + +using System; +using System.IO; +using System.Linq; +using System.Text.Json; + +var source = await new System.Net.Http.HttpClient() + .GetStringAsync("https://www.sourcetreeapp.com") + .ConfigureAwait(false); + +var (startText, endText) = ("{ \"type\":\"imkt.components.SourcetreeDownload\"", "(source, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); +var (a, b, c) = json.Params; +var urls = new[] { a, b, c }; + +Console.Out.WriteLine( + "download(" + + JsonSerializer.Serialize( + urls + .Select(a => new Uri(a)) + .Select(a => new + { + ZipFile = a.ToString(), + Version = new[] { "sourcetree", "enterprise", "setup", } + .Aggregate(Path.GetFileNameWithoutExtension(a.AbsolutePath), (s, ptr) => s.Replace(ptr, "", StringComparison.OrdinalIgnoreCase)) + .TrimStart('-', '_') + }) + .ToArray())+ ")"); + +public record Wrap(Params Params); +public record Params(string MacUrl, string WindowsUrl, string EnterpriseUrl); \ No newline at end of file diff --git a/json-backups/update.sh b/json-backups/update.sh index 581ff45..2a093b8 100755 --- a/json-backups/update.sh +++ b/json-backups/update.sh @@ -33,7 +33,7 @@ wget -c -nv --random-wait -P $PWD/current/ https://my.atlassian.com/download/fee wget -c -nv --random-wait -P $PWD/current/ https://my.atlassian.com/download/feeds/current/jira-servicedesk.json # SourceTree -dotnet-script sourcetreeapp-archive.csx > $PWD/current/sourcetree.json +dotnet script sourcetreeapp-archive.csx > $PWD/current/sourcetree.json ################################################################################################### # Archived links @@ -64,7 +64,7 @@ wget -c -nv --random-wait -P $PWD/archived/ https://my.atlassian.com/download/fe wget -c -nv --random-wait -P $PWD/archived/ https://my.atlassian.com/download/feeds/archived/jira-servicedesk.json # SourceTree -dotnet-script sourcetreeapp-archive.csx > $PWD/archived/sourcetree.json +dotnet script sourcetreeapp-archive.csx > $PWD/archived/sourcetree.json ################################################################################################### # EAP links