final sourcetree support by kasthack

This commit is contained in:
stam 2021-01-17 02:29:47 +03:00
parent def07345b1
commit 1ed5f22b7c
2 changed files with 38 additions and 2 deletions

View File

@ -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\"", "</scri");
var startIndex = source.IndexOf(startText, System.StringComparison.Ordinal);
var endIndex = source.IndexOf(endText, startIndex, System.StringComparison.Ordinal);
source = source[startIndex..endIndex];
var json = JsonSerializer.Deserialize<Wrap>(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);

View File

@ -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