mirror of
https://github.com/dnwSilver/tld.git
synced 2024-11-25 08:32:08 +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
|
||||
|
||||
![](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.Json;
|
||||
using Pastel;
|
||||
@ -44,12 +45,19 @@ public class DependencyDashboard : IControl<Project>
|
||||
|
||||
private string GetDependencies(Source source, IEnumerable<Dependency> conventionDependencies)
|
||||
{
|
||||
var package = DownloadPackage(source);
|
||||
try
|
||||
{
|
||||
var package = DownloadPackage(source);
|
||||
|
||||
return string.Join("",
|
||||
conventionDependencies
|
||||
.Select(package.Dependencies.GetVersion)
|
||||
.Select(GetCurrentVersion));
|
||||
return string.Join("",
|
||||
conventionDependencies
|
||||
.Select(package.Dependencies.GetVersion)
|
||||
.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();
|
||||
@ -62,26 +70,20 @@ public class DependencyDashboard : IControl<Project>
|
||||
}
|
||||
|
||||
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);
|
||||
Packages.Add(source.Repo, package);
|
||||
return package;
|
||||
}
|
||||
|
||||
// private string GetVersions(string title)
|
||||
// {
|
||||
// // var source = sources[index];
|
||||
// // var package = DownloadPackage(source);
|
||||
// // var resultText = package.Dependencies.React;
|
||||
// // resultText = new string(' ', ColumnWidth - resultText.Width()) + resultText;
|
||||
// // if (selectedRowNumber == index + 1)
|
||||
// // {
|
||||
// // resultText = resultText.PastelBg("292928");
|
||||
// // }
|
||||
//
|
||||
// return resultText;
|
||||
// }
|
||||
|
||||
private static string GetGitlabEndpoint(Source source)
|
||||
{
|
||||
var token = Environment.GetEnvironmentVariable("TLD_GITLAB_PAT");
|
||||
return $"{source.Repo}/api/v4/projects/{source.ProjectId}/repository/files/package.json/raw?" +
|
||||
$"private_token={token}&ref=master";
|
||||
}
|
||||
|
||||
private static string GetConventionVersion(Dependency dependency)
|
||||
{
|
||||
return dependency.Icon.Pastel(dependency.Color) + dependency.Version.Primary();
|
||||
|
@ -12,6 +12,10 @@ public class Source
|
||||
[YamlMember]
|
||||
public string Name { get; set; }
|
||||
|
||||
[YamlMember]
|
||||
// [YamlMember(Alias = "project_id")]
|
||||
public int ProjectId { get; set; } = 0;
|
||||
|
||||
[YamlMember]
|
||||
public string Repo { get; set; }
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyVersion>0.1.0</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System.Drawing;
|
||||
using Pastel;
|
||||
|
||||
|
||||
@ -8,6 +9,8 @@ public static class Palette
|
||||
public const string HoverColor = "292928";
|
||||
public const string PrimaryColor = "84BA64";
|
||||
public const string HintColor = "71797E";
|
||||
public const string ErrorColor = "D3B3AC";
|
||||
|
||||
public static string Primary(this string currentText) => currentText.Pastel(PrimaryColor);
|
||||
public static string Hint(this string currentText) => currentText.Pastel(HintColor);
|
||||
}
|
Loading…
Reference in New Issue
Block a user