mirror of
https://github.com/dnwSilver/tld.git
synced 2024-11-25 16:42:07 +00:00
✨ Added request to gitlab to get the package.json
This commit is contained in:
parent
0bcfa26d26
commit
5c8f6dd76c
@ -4,4 +4,10 @@ Team Lead Dashboard CLI To Manage Your Work In Style!
|
|||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
![](docs/Dependencies.png)
|
![](docs/Dependencies.png)
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
### Environments
|
||||||
|
|
||||||
|
- TLD_GITLAB_PAT personal access token to gitlab
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Drawing;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using Pastel;
|
using Pastel;
|
||||||
@ -44,12 +45,19 @@ public class DependencyDashboard : IControl<Project>
|
|||||||
|
|
||||||
private string GetDependencies(Source source, IEnumerable<Dependency> conventionDependencies)
|
private string GetDependencies(Source source, IEnumerable<Dependency> conventionDependencies)
|
||||||
{
|
{
|
||||||
var package = DownloadPackage(source);
|
try
|
||||||
|
{
|
||||||
|
var package = DownloadPackage(source);
|
||||||
|
|
||||||
return string.Join("",
|
return string.Join("",
|
||||||
conventionDependencies
|
conventionDependencies
|
||||||
.Select(package.Dependencies.GetVersion)
|
.Select(package.Dependencies.GetVersion)
|
||||||
.Select(GetCurrentVersion));
|
.Select(GetCurrentVersion));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return " We tried to send a request but couldn't. Check your configuration.".Pastel(Palette.ErrorColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly static Dictionary<string, Package> Packages = new();
|
private readonly static Dictionary<string, Package> Packages = new();
|
||||||
@ -62,26 +70,20 @@ public class DependencyDashboard : IControl<Project>
|
|||||||
}
|
}
|
||||||
|
|
||||||
using HttpClient client = new();
|
using HttpClient client = new();
|
||||||
var json = client.GetStringAsync(source.Repo).GetAwaiter().GetResult();
|
var endpoint = source.Tags.Have("gitlab") ? GetGitlabEndpoint(source) : source.Repo;
|
||||||
|
var json = client.GetStringAsync(endpoint).GetAwaiter().GetResult();
|
||||||
var package = JsonSerializer.Deserialize<Package>(json);
|
var package = JsonSerializer.Deserialize<Package>(json);
|
||||||
Packages.Add(source.Repo, package);
|
Packages.Add(source.Repo, package);
|
||||||
return package;
|
return package;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private string GetVersions(string title)
|
private static string GetGitlabEndpoint(Source source)
|
||||||
// {
|
{
|
||||||
// // var source = sources[index];
|
var token = Environment.GetEnvironmentVariable("TLD_GITLAB_PAT");
|
||||||
// // var package = DownloadPackage(source);
|
return $"{source.Repo}/api/v4/projects/{source.ProjectId}/repository/files/package.json/raw?" +
|
||||||
// // var resultText = package.Dependencies.React;
|
$"private_token={token}&ref=master";
|
||||||
// // resultText = new string(' ', ColumnWidth - resultText.Width()) + resultText;
|
}
|
||||||
// // if (selectedRowNumber == index + 1)
|
|
||||||
// // {
|
|
||||||
// // resultText = resultText.PastelBg("292928");
|
|
||||||
// // }
|
|
||||||
//
|
|
||||||
// return resultText;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private static string GetConventionVersion(Dependency dependency)
|
private static string GetConventionVersion(Dependency dependency)
|
||||||
{
|
{
|
||||||
return dependency.Icon.Pastel(dependency.Color) + dependency.Version.Primary();
|
return dependency.Icon.Pastel(dependency.Color) + dependency.Version.Primary();
|
||||||
|
@ -12,6 +12,10 @@ public class Source
|
|||||||
[YamlMember]
|
[YamlMember]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[YamlMember]
|
||||||
|
// [YamlMember(Alias = "project_id")]
|
||||||
|
public int ProjectId { get; set; } = 0;
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember]
|
||||||
public string Repo { get; set; }
|
public string Repo { get; set; }
|
||||||
}
|
}
|
@ -5,6 +5,7 @@
|
|||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<AssemblyVersion>0.1.0</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Drawing;
|
||||||
using Pastel;
|
using Pastel;
|
||||||
|
|
||||||
|
|
||||||
@ -8,6 +9,8 @@ public static class Palette
|
|||||||
public const string HoverColor = "292928";
|
public const string HoverColor = "292928";
|
||||||
public const string PrimaryColor = "84BA64";
|
public const string PrimaryColor = "84BA64";
|
||||||
public const string HintColor = "71797E";
|
public const string HintColor = "71797E";
|
||||||
|
public const string ErrorColor = "D3B3AC";
|
||||||
|
|
||||||
public static string Primary(this string currentText) => currentText.Pastel(PrimaryColor);
|
public static string Primary(this string currentText) => currentText.Pastel(PrimaryColor);
|
||||||
public static string Hint(this string currentText) => currentText.Pastel(HintColor);
|
public static string Hint(this string currentText) => currentText.Pastel(HintColor);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user