mirror of
https://github.com/dnwSilver/tld.git
synced 2024-11-25 16:42:07 +00:00
✨ Add render for legacy project.
This commit is contained in:
parent
a06f5c541e
commit
92e3e37bd1
@ -7,6 +7,9 @@ namespace TUI.Engine.Nodes;
|
|||||||
public interface INode : IResizable
|
public interface INode : IResizable
|
||||||
{
|
{
|
||||||
DrawContext DrawContext { get; set; }
|
DrawContext DrawContext { get; set; }
|
||||||
|
StyleContext StyleContext { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public record DrawContext(ICanvas Canvas, Position Pencil, Size MaxSize);
|
public record DrawContext(ICanvas Canvas, Position Pencil, Size MaxSize);
|
||||||
|
|
||||||
|
public record StyleContext(string? Foreground, string? Background = null);
|
@ -57,4 +57,6 @@ public abstract class NodeBase : INode
|
|||||||
#endregion Resizing
|
#endregion Resizing
|
||||||
|
|
||||||
public DrawContext? DrawContext { get; set; }
|
public DrawContext? DrawContext { get; set; }
|
||||||
|
|
||||||
|
public StyleContext? StyleContext { get; set; }
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
using Pastel;
|
||||||
using TUI.Engine.Attributes;
|
using TUI.Engine.Attributes;
|
||||||
using TUI.Engine.Components;
|
using TUI.Engine.Components;
|
||||||
using TUI.Engine.Nodes;
|
using TUI.Engine.Nodes;
|
||||||
@ -8,31 +9,34 @@ namespace TUI.Engine.Rendering;
|
|||||||
internal sealed class ComponentCraftsman : CraftsmanBase, IDrawable<IComponent>
|
internal sealed class ComponentCraftsman : CraftsmanBase, IDrawable<IComponent>
|
||||||
{
|
{
|
||||||
private readonly ICanvas _canvas;
|
private readonly ICanvas _canvas;
|
||||||
|
|
||||||
public ComponentCraftsman(ICanvas canvas)
|
public ComponentCraftsman(ICanvas canvas)
|
||||||
{
|
{
|
||||||
_canvas = canvas;
|
_canvas = canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Size Draw(IComponent component, Position pencil, Size maxSize)
|
public Size Draw(IComponent component, Position pencil, Size maxSize)
|
||||||
{
|
{
|
||||||
var sketch = component.MakeSketch(maxSize);
|
var sketch = component.MakeSketch(maxSize);
|
||||||
var sketchSize = sketch.GetSize();
|
var sketchSize = sketch.GetSize();
|
||||||
|
|
||||||
var correctedPencil = component.CorrectContentPosition(pencil, maxSize, sketchSize);
|
var correctedPencil = component.CorrectContentPosition(pencil, maxSize, sketchSize);
|
||||||
|
|
||||||
Debug(pencil, maxSize);
|
Debug(pencil, maxSize);
|
||||||
|
|
||||||
foreach (var line in sketch.Crop(maxSize))
|
foreach (var line in sketch.Crop(maxSize))
|
||||||
{
|
{
|
||||||
component.DrawContext = new DrawContext(_canvas, pencil, maxSize);
|
component.DrawContext = new DrawContext(_canvas, pencil, maxSize);
|
||||||
|
|
||||||
_canvas.SetPencil(correctedPencil);
|
_canvas.SetPencil(correctedPencil);
|
||||||
_canvas.Paint(line);
|
_canvas.Paint(component.StyleContext is not null
|
||||||
|
? line.RemoveColors().Pastel(component.StyleContext.Foreground)
|
||||||
|
: line);
|
||||||
|
|
||||||
|
|
||||||
correctedPencil = correctedPencil with { Top = correctedPencil.Top + 1 };
|
correctedPencil = correctedPencil with { Top = correctedPencil.Top + 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
return sketchSize;
|
return sketchSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,31 +4,32 @@ namespace TUI.Engine.Theme;
|
|||||||
|
|
||||||
public static class Palette
|
public static class Palette
|
||||||
{
|
{
|
||||||
private const string HoverColor = "292928";
|
public const string HoverColor = "292928";
|
||||||
private const string PrimaryColor = "84BA64";
|
public const string PrimaryColor = "84BA64";
|
||||||
private const string HintColor = "71797E";
|
public const string HintColor = "71797E";
|
||||||
private const string ErrorColor = "CA3433";
|
public const string DisableColor = "303030";
|
||||||
private const string WarningColor = "EC9706";
|
public const string ErrorColor = "CA3433";
|
||||||
private const string InfoColor = "25799F";
|
public const string WarningColor = "EC9706";
|
||||||
|
public const string InfoColor = "25799F";
|
||||||
|
|
||||||
public static string Main(this string currentText, bool isFocused = true) =>
|
public static string Main(this string currentText, bool isFocused = true) =>
|
||||||
isFocused
|
isFocused
|
||||||
? currentText.Pastel(PrimaryColor)
|
? currentText.Pastel(PrimaryColor)
|
||||||
: Hint(currentText);
|
: Hint(currentText);
|
||||||
|
|
||||||
public static string Hint(this string currentText) => currentText.Pastel(HintColor);
|
public static string Hint(this string currentText) => currentText.Pastel(HintColor);
|
||||||
|
|
||||||
public static string Hint(this char currentText) => currentText.ToString().Pastel(HintColor);
|
public static string Hint(this char currentText) => currentText.ToString().Pastel(HintColor);
|
||||||
|
|
||||||
public static string Disable(this string currentText) => currentText.RemoveColors().Pastel(HintColor);
|
public static string Disable(this string currentText) => currentText.RemoveColors().Pastel(HintColor);
|
||||||
|
|
||||||
public static string Warning(this string currentText) => currentText.Pastel(WarningColor);
|
public static string Warning(this string currentText) => currentText.Pastel(WarningColor);
|
||||||
|
|
||||||
public static string Error(this string currentText) => currentText.Pastel(ErrorColor);
|
public static string Error(this string currentText) => currentText.Pastel(ErrorColor);
|
||||||
|
|
||||||
public static string Info(this string currentText) => currentText.Pastel(InfoColor);
|
public static string Info(this string currentText) => currentText.Pastel(InfoColor);
|
||||||
|
|
||||||
public static string Info(this char currentText) => currentText.ToString().Pastel(InfoColor);
|
public static string Info(this char currentText) => currentText.ToString().Pastel(InfoColor);
|
||||||
|
|
||||||
public static string Info(this int currentText) => currentText.ToString().Pastel(InfoColor);
|
public static string Info(this int currentText) => currentText.ToString().Pastel(InfoColor);
|
||||||
}
|
}
|
@ -9,25 +9,32 @@ namespace TUI.Controls.Common;
|
|||||||
public class StubComponent : ComponentBase
|
public class StubComponent : ComponentBase
|
||||||
{
|
{
|
||||||
private readonly Size _size;
|
private readonly Size _size;
|
||||||
|
private readonly string? _text;
|
||||||
public StubComponent(Size size)
|
|
||||||
|
public StubComponent(Size size, string? text = null)
|
||||||
{
|
{
|
||||||
_size = size;
|
_size = size;
|
||||||
|
_text = text;
|
||||||
SetFixed(Orientation.Horizontal, size.Width);
|
SetFixed(Orientation.Horizontal, size.Width);
|
||||||
SetFixed(Orientation.Vertical, size.Height);
|
SetFixed(Orientation.Vertical, size.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Sketch DrawComponent(Size minSize)
|
protected override Sketch DrawComponent(Size minSize)
|
||||||
{
|
{
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
var height = 0;
|
var height = 0;
|
||||||
|
|
||||||
|
|
||||||
while (_size.Height > height)
|
while (_size.Height > height)
|
||||||
{
|
{
|
||||||
builder.Append(Symbols.Space.Repeat(_size.Width));
|
builder.Append(Symbols.Space.Repeat(_size.Width - (_text?.GetWidth() ?? 0)));
|
||||||
height++;
|
height++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_text is not null)
|
||||||
|
{
|
||||||
|
builder.Append(_text);
|
||||||
|
}
|
||||||
return new Sketch(builder.ToString());
|
return new Sketch(builder.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,12 +12,12 @@ namespace TUI.Controls.Components;
|
|||||||
public class ProjectTitle : ComponentBase
|
public class ProjectTitle : ComponentBase
|
||||||
{
|
{
|
||||||
private readonly Project _project;
|
private readonly Project _project;
|
||||||
|
|
||||||
public ProjectTitle(Project project)
|
public ProjectTitle(Project project)
|
||||||
{
|
{
|
||||||
_project = project;
|
_project = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Sketch DrawComponent(Size minSize)
|
protected override Sketch DrawComponent(Size minSize)
|
||||||
{
|
{
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
@ -34,14 +34,14 @@ public class ProjectTitle : ComponentBase
|
|||||||
builder.Append(_project.Name.Disable());
|
builder.Append(_project.Name.Disable());
|
||||||
return new Sketch(builder);
|
return new Sketch(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetHub() => _project.Hub == "gitlab" ? GitLab : GitHub;
|
private string GetHub() => _project.Hub.Type == "gitlab" ? GitLab : GitHub;
|
||||||
|
|
||||||
private string GetApplicationType()
|
private string GetApplicationType()
|
||||||
{
|
{
|
||||||
foreach (var application in Icons.Applications.Where(application => _project.Tags.Have(application.Value)))
|
foreach (var application in Icons.Applications.Where(application => _project.Tags.Have(application.Value)))
|
||||||
return application.Key;
|
return application.Key;
|
||||||
|
|
||||||
return Undefined.Hint();
|
return Undefined.Hint();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
|
using TUI.Domain;
|
||||||
using TUI.Engine.Attributes;
|
using TUI.Engine.Attributes;
|
||||||
using TUI.Engine.Components;
|
using TUI.Engine.Components;
|
||||||
|
|
||||||
@ -9,26 +10,31 @@ public class VersionComponent : ComponentBase
|
|||||||
private readonly VersionType _type;
|
private readonly VersionType _type;
|
||||||
private readonly string _version;
|
private readonly string _version;
|
||||||
private readonly Brand? _brand;
|
private readonly Brand? _brand;
|
||||||
|
private readonly VersionStatus _status;
|
||||||
public VersionComponent(VersionType type, string version, Brand? brand)
|
|
||||||
|
public VersionComponent(string version, Brand brand, VersionStatus status = VersionStatus.SoGood,
|
||||||
|
VersionType type = VersionType.Release)
|
||||||
{
|
{
|
||||||
_type = type;
|
|
||||||
_version = version;
|
_version = version;
|
||||||
_brand = brand;
|
_brand = brand;
|
||||||
|
_status = status;
|
||||||
|
_type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Sketch DrawComponent(Size minSize)
|
protected override Sketch DrawComponent(Size minSize)
|
||||||
{
|
{
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
|
|
||||||
|
// builder.Append(_type.ToString());
|
||||||
|
|
||||||
if (_brand is not null)
|
if (_brand is not null)
|
||||||
{
|
{
|
||||||
builder.Append(_brand.ColorLogo());
|
builder.Append(_brand.ColorLogo());
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.Append(_version);
|
builder.Append(_version);
|
||||||
var sketch = builder.ToString();
|
var sketch = builder.ToString();
|
||||||
|
|
||||||
return new Sketch(_type.Colorize(sketch));
|
return new Sketch(_status.Colorize(sketch));
|
||||||
}
|
}
|
||||||
}
|
}
|
10
src/TUI/Controls/Components/VersionStatus.cs
Normal file
10
src/TUI/Controls/Components/VersionStatus.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace TUI.Controls.Components;
|
||||||
|
|
||||||
|
public enum VersionStatus
|
||||||
|
{
|
||||||
|
NotFound,
|
||||||
|
ToNew,
|
||||||
|
SoGood,
|
||||||
|
BeNice,
|
||||||
|
TooOld,
|
||||||
|
}
|
@ -3,8 +3,10 @@ namespace TUI.Controls.Components;
|
|||||||
public enum VersionType
|
public enum VersionType
|
||||||
{
|
{
|
||||||
Convention,
|
Convention,
|
||||||
ToNew,
|
Release,
|
||||||
SoGood,
|
Candidate,
|
||||||
BeNice,
|
Canary,
|
||||||
TooOld,
|
Alpha,
|
||||||
|
Beta,
|
||||||
|
Next,
|
||||||
}
|
}
|
@ -4,14 +4,13 @@ namespace TUI.Controls.Components;
|
|||||||
|
|
||||||
public static class VersionTypeExtensions
|
public static class VersionTypeExtensions
|
||||||
{
|
{
|
||||||
public static string Colorize(this VersionType versionType, string value) =>
|
public static string Colorize(this VersionStatus versionStatus, string value) =>
|
||||||
versionType switch
|
versionStatus switch
|
||||||
{
|
{
|
||||||
VersionType.TooOld => value.Warning(),
|
VersionStatus.TooOld => value.Warning(),
|
||||||
VersionType.ToNew => value.Info(),
|
VersionStatus.ToNew => value.Info(),
|
||||||
VersionType.SoGood => value.Hint(),
|
VersionStatus.SoGood => value.Hint(),
|
||||||
VersionType.BeNice => value.Main(),
|
VersionStatus.BeNice => value.Main(),
|
||||||
VersionType.Convention => value.Main(),
|
|
||||||
_ => value
|
_ => value
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -29,4 +29,6 @@ public class DashboardContainer : ContainerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override Nodes GetNodes() => _children;
|
public override Nodes GetNodes() => _children;
|
||||||
|
|
||||||
|
public Nodes GetContent() => _content.GetNodes();
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using TUI.Controls.Common;
|
using TUI.Controls.Common;
|
||||||
using TUI.Controls.Components;
|
using TUI.Controls.Components;
|
||||||
using TUI.Domain;
|
using TUI.Domain;
|
||||||
|
using TUI.Engine;
|
||||||
using TUI.Engine.Attributes;
|
using TUI.Engine.Attributes;
|
||||||
using TUI.Engine.Attributes.Alignments;
|
using TUI.Engine.Attributes.Alignments;
|
||||||
using TUI.Engine.Attributes.Orientations;
|
using TUI.Engine.Attributes.Orientations;
|
||||||
@ -13,38 +14,76 @@ namespace TUI.Controls.Containers;
|
|||||||
|
|
||||||
public class DependenciesContainer : ContainerBase
|
public class DependenciesContainer : ContainerBase
|
||||||
{
|
{
|
||||||
|
public readonly Project? Project;
|
||||||
|
|
||||||
private const int VersionColumnWidth = 10;
|
private const int VersionColumnWidth = 10;
|
||||||
|
|
||||||
private const int TitleColumnWidth = 25;
|
private const int TitleColumnWidth = 25;
|
||||||
|
|
||||||
private readonly Nodes _dependencies = new();
|
private readonly Nodes _dependencies = new();
|
||||||
|
|
||||||
|
public DependenciesContainer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public DependenciesContainer(Project project)
|
||||||
|
{
|
||||||
|
Project = project;
|
||||||
|
}
|
||||||
|
|
||||||
public void AddTitleStub()
|
public void AddTitleStub()
|
||||||
{
|
{
|
||||||
var size = new Size(TitleColumnWidth, 1);
|
var size = new Size(TitleColumnWidth, 1);
|
||||||
var title = new StubComponent(size);
|
var title = new StubComponent(size);
|
||||||
title.SetPadding(Level.Normal);
|
title.SetPadding(Level.Normal);
|
||||||
|
|
||||||
_dependencies.Add(title);
|
_dependencies.Add(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTitle(IComponent title)
|
public void AddTitle(IComponent title)
|
||||||
{
|
{
|
||||||
title.SetPadding(Level.Normal);
|
title.SetPadding(Level.Normal);
|
||||||
title.SetFixed(Orientation.Horizontal, TitleColumnWidth);
|
title.SetFixed(Orientation.Horizontal, TitleColumnWidth);
|
||||||
title.SetAlignment(Horizontal.Left);
|
title.SetAlignment(Horizontal.Left);
|
||||||
|
|
||||||
|
if (Project is not null && Project.Legacy)
|
||||||
|
{
|
||||||
|
title.StyleContext = new StyleContext(Palette.DisableColor);
|
||||||
|
}
|
||||||
|
|
||||||
_dependencies.Add(title);
|
_dependencies.Add(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddDependency(Dependency dependency)
|
public void AddDependencyStub()
|
||||||
{
|
{
|
||||||
var version = new VersionComponent(VersionType.Convention, dependency.Version, dependency.Brand);
|
var size = new Size(VersionColumnWidth, 1);
|
||||||
|
var stub = new StubComponent(size, Symbols.NotFound.Hint());
|
||||||
|
stub.SetPadding(Level.Normal);
|
||||||
|
stub.SetAlignment(Horizontal.Right);
|
||||||
|
stub.SetFixed(Orientation.Horizontal, VersionColumnWidth);
|
||||||
|
|
||||||
|
if (Project is not null && Project.Legacy)
|
||||||
|
{
|
||||||
|
stub.StyleContext = new StyleContext(Palette.DisableColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
_dependencies.Add(stub);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddDependency(Dependency dependency, VersionStatus status = VersionStatus.BeNice)
|
||||||
|
{
|
||||||
|
var version = new VersionComponent(dependency.Version, dependency.Brand, status, dependency.Type);
|
||||||
version.SetPadding(Level.Normal);
|
version.SetPadding(Level.Normal);
|
||||||
version.SetAlignment(Horizontal.Right);
|
version.SetAlignment(Horizontal.Right);
|
||||||
version.SetFixed(Orientation.Horizontal, VersionColumnWidth);
|
version.SetFixed(Orientation.Horizontal, VersionColumnWidth);
|
||||||
|
|
||||||
|
if (Project is not null && Project.Legacy)
|
||||||
|
{
|
||||||
|
version.StyleContext = new StyleContext(Palette.DisableColor);
|
||||||
|
}
|
||||||
|
|
||||||
_dependencies.Add(version);
|
_dependencies.Add(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Nodes GetNodes() => _dependencies;
|
public override Nodes GetNodes() => _dependencies;
|
||||||
}
|
}
|
@ -10,10 +10,10 @@ public class VersionHints : StaticComponentBase
|
|||||||
{
|
{
|
||||||
private readonly Dictionary<string, string> _hints = new()
|
private readonly Dictionary<string, string> _hints = new()
|
||||||
{
|
{
|
||||||
{ "", VersionType.ToNew.Colorize("too new") },
|
{ "", VersionStatus.ToNew.Colorize("too new") },
|
||||||
{ "", VersionType.SoGood.Colorize("so good") },
|
{ "", VersionStatus.SoGood.Colorize("so good") },
|
||||||
{ "", VersionType.BeNice.Colorize("be nice") },
|
{ "", VersionStatus.BeNice.Colorize("be nice") },
|
||||||
{ "", VersionType.TooOld.Colorize("too old") }
|
{ "", VersionStatus.TooOld.Colorize("too old") }
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override void RenderWithCache(StringBuilder builder)
|
protected override void RenderWithCache(StringBuilder builder)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using Pastel;
|
using Pastel;
|
||||||
|
|
||||||
namespace TUI.Controls.Components;
|
namespace TUI.Domain;
|
||||||
|
|
||||||
public record Brand(string Name, string Logo, string Color)
|
public record Brand(string Name, string? Logo = null, string? Color = null)
|
||||||
{
|
{
|
||||||
public string ColorLogo() => Logo.Pastel(Color);
|
public string ColorLogo() => Logo?.Pastel(Color) ?? string.Empty;
|
||||||
};
|
};
|
@ -2,4 +2,66 @@ using TUI.Controls.Components;
|
|||||||
|
|
||||||
namespace TUI.Domain;
|
namespace TUI.Domain;
|
||||||
|
|
||||||
public record Dependency(string Version, Brand Brand);
|
public record Dependency()
|
||||||
|
{
|
||||||
|
private readonly Version _current;
|
||||||
|
public readonly Brand Brand;
|
||||||
|
public VersionType Type { get; private set; }
|
||||||
|
|
||||||
|
public string Version => $"{_current.Major}.{_current.Minor}.{_current.Patch}";
|
||||||
|
|
||||||
|
public Dependency(string version, Brand brand) : this()
|
||||||
|
{
|
||||||
|
_current = new Version(version);
|
||||||
|
Brand = brand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersionStatus Comparison(Dependency outerDependency)
|
||||||
|
{
|
||||||
|
// if (string.IsNullOrEmpty(Version) || string.IsNullOrEmpty(outerDependency.Version))
|
||||||
|
// {
|
||||||
|
// return VersionStatus.NotFound;
|
||||||
|
// }
|
||||||
|
|
||||||
|
var outer = outerDependency._current;
|
||||||
|
|
||||||
|
Type = _current.Type;
|
||||||
|
|
||||||
|
if (_current.Major < outer.Major)
|
||||||
|
{
|
||||||
|
return VersionStatus.TooOld;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_current.Major > outer.Major)
|
||||||
|
{
|
||||||
|
return VersionStatus.ToNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_current.Minor < outer.Minor)
|
||||||
|
{
|
||||||
|
return VersionStatus.BeNice;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_current.Minor > outer.Minor)
|
||||||
|
{
|
||||||
|
return VersionStatus.ToNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_current.Patch < outer.Patch)
|
||||||
|
{
|
||||||
|
return VersionStatus.BeNice;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_current.Patch > outer.Patch)
|
||||||
|
{
|
||||||
|
return VersionStatus.ToNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outer.Type != VersionType.Release)
|
||||||
|
{
|
||||||
|
return VersionStatus.ToNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
return VersionStatus.SoGood;
|
||||||
|
}
|
||||||
|
};
|
@ -1,6 +1,3 @@
|
|||||||
namespace TUI.Domain;
|
namespace TUI.Domain;
|
||||||
|
|
||||||
public record Hub
|
public record Hub(string Origin, string Type);
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -1,12 +1,14 @@
|
|||||||
namespace TUI.Domain;
|
namespace TUI.Domain;
|
||||||
|
|
||||||
public record Project(int Id, string Name, IEnumerable<string> Tags, string Hub)
|
public record Project(int Id, string Name, IEnumerable<string> Tags, Hub Hub)
|
||||||
{
|
{
|
||||||
private IEnumerable<Dependency> Dependencies => new List<Dependency>();
|
private IEnumerable<Dependency> Dependencies => new List<Dependency>();
|
||||||
|
|
||||||
public bool IsPublicNetwork => Tags.Contains("public");
|
public bool IsPublicNetwork => Tags.Contains("public");
|
||||||
|
|
||||||
public bool HasAuth => Tags.Contains("auth");
|
public bool HasAuth => Tags.Contains("auth");
|
||||||
|
|
||||||
public bool SeoDependent => Tags.Contains("seo");
|
public bool SeoDependent => Tags.Contains("seo");
|
||||||
|
|
||||||
|
public bool Legacy => Tags.Contains("legacy");
|
||||||
}
|
}
|
32
src/TUI/Domain/Version.cs
Normal file
32
src/TUI/Domain/Version.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using TUI.Controls.Components;
|
||||||
|
|
||||||
|
namespace TUI.Domain;
|
||||||
|
|
||||||
|
public class Version
|
||||||
|
{
|
||||||
|
public readonly int Major;
|
||||||
|
public readonly int Minor;
|
||||||
|
public readonly int Patch;
|
||||||
|
public readonly VersionType Type;
|
||||||
|
|
||||||
|
public Version(string version)
|
||||||
|
{
|
||||||
|
var parts = version.Split('.');
|
||||||
|
|
||||||
|
Major = Convert.ToInt32(parts[0].Replace("^", "").Replace("~", ""));
|
||||||
|
Minor = Convert.ToInt32(parts[1]);
|
||||||
|
Patch = Convert.ToInt32(string.Join("", parts[2].TakeWhile(char.IsDigit)));
|
||||||
|
|
||||||
|
var extension = parts[2].Replace(Patch.ToString(), "");
|
||||||
|
|
||||||
|
Type = extension switch
|
||||||
|
{
|
||||||
|
not null when extension.Contains("rc") => VersionType.Candidate,
|
||||||
|
not null when extension.Contains("beta") => VersionType.Beta,
|
||||||
|
not null when extension.Contains("alpha") => VersionType.Alpha,
|
||||||
|
not null when extension.Contains("canary") => VersionType.Canary,
|
||||||
|
not null when extension.Contains("next") => VersionType.Next,
|
||||||
|
_ => VersionType.Release
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -6,57 +6,97 @@ using TUI.Store;
|
|||||||
|
|
||||||
namespace TUI.Pages;
|
namespace TUI.Pages;
|
||||||
|
|
||||||
|
public record DependenciesState(HeaderContainer Header, DashboardContainer Dashboard, FooterContainer Footer);
|
||||||
|
|
||||||
public class DependenciesPage : PageBase
|
public class DependenciesPage : PageBase
|
||||||
{
|
{
|
||||||
private DependenciesStore _store;
|
private DependenciesStore _store;
|
||||||
|
|
||||||
public override void Render()
|
private DependenciesState _state;
|
||||||
|
|
||||||
|
public override void Initial()
|
||||||
{
|
{
|
||||||
ICanvas canvas = new ConsoleCanvas();
|
|
||||||
|
|
||||||
var header = new HeaderContainer();
|
var header = new HeaderContainer();
|
||||||
var dashboard = new DashboardContainer();
|
var dashboard = new DashboardContainer();
|
||||||
var dependenciesHeader = new DependenciesContainer();
|
var dependenciesHeader = new DependenciesContainer();
|
||||||
dependenciesHeader.AddTitleStub();
|
dependenciesHeader.AddTitleStub();
|
||||||
|
|
||||||
foreach (var conventionDependency in _store.ConventionDependencies)
|
foreach (var conventionDependency in _store.ConventionDependencies)
|
||||||
{
|
{
|
||||||
dependenciesHeader.AddDependency(conventionDependency);
|
dependenciesHeader.AddDependency(conventionDependency);
|
||||||
}
|
}
|
||||||
|
|
||||||
dashboard.AddChildren(dependenciesHeader);
|
dashboard.AddChildren(dependenciesHeader);
|
||||||
|
|
||||||
foreach (var project in _store.Projects)
|
foreach (var project in _store.Projects)
|
||||||
{
|
{
|
||||||
var projectDependencies = new DependenciesContainer();
|
var projectDependencies = new DependenciesContainer(project);
|
||||||
projectDependencies.AddTitle(new ProjectTitle(project));
|
projectDependencies.AddTitle(new ProjectTitle(project));
|
||||||
dashboard.AddChildren(projectDependencies);
|
dashboard.AddChildren(projectDependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
var breadCrumbs = new BreadCrumbsComponent(" Dependencies", "JavaScript");
|
var breadCrumbs = new BreadCrumbsComponent(" Dependencies", "JavaScript");
|
||||||
var footer = new FooterContainer(breadCrumbs);
|
var footer = new FooterContainer(breadCrumbs);
|
||||||
var layout = new DashboardLayout(header, dashboard, footer);
|
|
||||||
canvas.Draw(layout);
|
_state = new DependenciesState(header, dashboard, footer);
|
||||||
|
|
||||||
// CommandLine = new CommandLine();
|
|
||||||
// DependenciesView = new DependenciesView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Render()
|
||||||
|
{
|
||||||
|
ICanvas canvas = new ConsoleCanvas();
|
||||||
|
var layout = new DashboardLayout(_state.Header, _state.Dashboard, _state.Footer);
|
||||||
|
canvas.Draw(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadDependencies()
|
||||||
|
{
|
||||||
|
Initial();
|
||||||
|
var projects = _state.Dashboard.GetContent();
|
||||||
|
foreach (var projectDependencies in projects.Cast<DependenciesContainer?>().Skip(1))
|
||||||
|
{
|
||||||
|
if (projectDependencies is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var project = projectDependencies.Project;
|
||||||
|
var actualDependencies = _store.ActualDependencies(project).ToArray();
|
||||||
|
|
||||||
|
foreach (var conventionDependency in _store.ConventionDependencies)
|
||||||
|
{
|
||||||
|
var actualDependency = actualDependencies.SingleOrDefault(
|
||||||
|
dependency => string.Equals(dependency.Brand.Name, conventionDependency.Brand.Name,
|
||||||
|
StringComparison.CurrentCultureIgnoreCase));
|
||||||
|
|
||||||
|
if (actualDependency is null)
|
||||||
|
{
|
||||||
|
projectDependencies.AddDependencyStub();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var versionType = actualDependency.Comparison(conventionDependency);
|
||||||
|
projectDependencies.AddDependency(actualDependency, versionType);
|
||||||
|
}
|
||||||
|
|
||||||
|
Render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void Bind()
|
public override void Bind()
|
||||||
{
|
{
|
||||||
_store = new DependenciesStore();
|
_store = new DependenciesStore();
|
||||||
_store.Bind();
|
_store.Bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
// private bool _commandLineInDisplay;
|
// private bool _commandLineInDisplay;
|
||||||
|
|
||||||
// private ProjectDto _currentProjectDto;
|
// private ProjectDto _currentProjectDto;
|
||||||
|
|
||||||
// private bool _headerInDisplay = true;
|
// private bool _headerInDisplay = true;
|
||||||
|
|
||||||
|
|
||||||
// public string FocusedElement { get; set; } = "";
|
// public string FocusedElement { get; set; } = "";
|
||||||
|
|
||||||
// public void OpenDeps(ProjectDto projectDto)
|
// public void OpenDeps(ProjectDto projectDto)
|
||||||
// {
|
// {
|
||||||
// _currentProjectDto = projectDto;
|
// _currentProjectDto = projectDto;
|
||||||
|
@ -3,6 +3,7 @@ namespace TUI.Pages;
|
|||||||
interface IPage
|
interface IPage
|
||||||
{
|
{
|
||||||
void Open();
|
void Open();
|
||||||
|
void Initial();
|
||||||
void Render();
|
void Render();
|
||||||
void Bind();
|
void Bind();
|
||||||
}
|
}
|
@ -8,10 +8,13 @@ public abstract class PageBase : IPage
|
|||||||
{
|
{
|
||||||
Debugger.Log(0, "Event", $"Open page ${GetType().UnderlyingSystemType.Name}\n");
|
Debugger.Log(0, "Event", $"Open page ${GetType().UnderlyingSystemType.Name}\n");
|
||||||
Bind();
|
Bind();
|
||||||
|
Initial();
|
||||||
Render();
|
Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void Initial();
|
||||||
|
|
||||||
public abstract void Render();
|
public abstract void Render();
|
||||||
|
|
||||||
public abstract void Bind();
|
public abstract void Bind();
|
||||||
}
|
}
|
@ -10,6 +10,10 @@ namespace TUI.Pages;
|
|||||||
|
|
||||||
public class WelcomePage : PageBase
|
public class WelcomePage : PageBase
|
||||||
{
|
{
|
||||||
|
public override void Initial()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public override void Render()
|
public override void Render()
|
||||||
{
|
{
|
||||||
ICanvas canvas = new ConsoleCanvas();
|
ICanvas canvas = new ConsoleCanvas();
|
||||||
|
@ -13,15 +13,24 @@ Thread.Sleep(500);
|
|||||||
var dependenciesPage = new DependenciesPage();
|
var dependenciesPage = new DependenciesPage();
|
||||||
dependenciesPage.Open();
|
dependenciesPage.Open();
|
||||||
|
|
||||||
var key = new ConsoleKeyInfo('1', ConsoleKey.NoName, false, false, false);
|
|
||||||
|
ConsoleKeyInfo? key = null;
|
||||||
|
|
||||||
var waitCommand = true;
|
var waitCommand = true;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// if (key.Key == ConsoleKey.Q && !display.CommandLine.IsFocused)
|
if (key?.Key == ConsoleKey.Q)
|
||||||
// {
|
{
|
||||||
// waitCommand = false;
|
waitCommand = false;
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
if (key?.Key == ConsoleKey.R)
|
||||||
|
{
|
||||||
|
dependenciesPage.LoadDependencies();
|
||||||
|
key = null;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// if (display.CommandLine.IsFocused)
|
// if (display.CommandLine.IsFocused)
|
||||||
// {
|
// {
|
||||||
@ -58,7 +67,7 @@ do
|
|||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
key = Console.ReadKey(true);
|
key = Console.ReadKey(true);
|
||||||
} while (waitCommand);
|
} while (waitCommand);
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
using TUI.Controls.Components;
|
using TUI.Controls.Components;
|
||||||
using TUI.Domain;
|
using TUI.Domain;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
@ -8,7 +10,7 @@ namespace TUI.Providers.Dependencies;
|
|||||||
public class DependencyRepository
|
public class DependencyRepository
|
||||||
{
|
{
|
||||||
private DependenciesDto? _dependenciesDto;
|
private DependenciesDto? _dependenciesDto;
|
||||||
|
|
||||||
private DependenciesDto DependenciesDto
|
private DependenciesDto DependenciesDto
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -17,18 +19,18 @@ public class DependencyRepository
|
|||||||
{
|
{
|
||||||
return _dependenciesDto;
|
return _dependenciesDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
var deserializer = new DeserializerBuilder()
|
var deserializer = new DeserializerBuilder()
|
||||||
.WithNamingConvention(UnderscoredNamingConvention.Instance)
|
.WithNamingConvention(UnderscoredNamingConvention.Instance)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
using var sr = new StreamReader("dependencies.yaml");
|
using var sr = new StreamReader("dependencies.yaml");
|
||||||
_dependenciesDto = deserializer.Deserialize<DependenciesDto>(sr.ReadToEnd());
|
_dependenciesDto = deserializer.Deserialize<DependenciesDto>(sr.ReadToEnd());
|
||||||
|
|
||||||
return _dependenciesDto;
|
return _dependenciesDto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Dependency> ReadConventions(string stackName)
|
public IEnumerable<Dependency> ReadConventions(string stackName)
|
||||||
{
|
{
|
||||||
return DependenciesDto.Stacks
|
return DependenciesDto.Stacks
|
||||||
@ -40,22 +42,86 @@ public class DependencyRepository
|
|||||||
return new Dependency(convention.Version, brand);
|
return new Dependency(convention.Version, brand);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Project> ReadProjects(string stackName)
|
public IEnumerable<Project> ReadProjects(string stackName)
|
||||||
{
|
{
|
||||||
var projects = new List<Project>();
|
var projects = new List<Project>();
|
||||||
|
|
||||||
var hubs = DependenciesDto.Stacks
|
var hubs = DependenciesDto.Stacks
|
||||||
.Single(stack => stack.Name == stackName)
|
.Single(stack => stack.Name == stackName)
|
||||||
.Hubs;
|
.Hubs;
|
||||||
|
|
||||||
foreach (var hub in hubs)
|
foreach (var hub in hubs)
|
||||||
{
|
{
|
||||||
projects.AddRange(hub
|
projects.AddRange(hub
|
||||||
.Projects
|
.Projects
|
||||||
.Select(proj => new Project(proj.Id, proj.Name, proj.Tags, hub.Type)));
|
.Select(proj => new Project(proj.Id, proj.Name, proj.Tags, new Hub(hub.Origin, hub.Type))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return projects;
|
return projects;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public IEnumerable<Dependency> ReadActual(Project project)
|
||||||
|
{
|
||||||
|
var dependencies = new List<Dependency>();
|
||||||
|
|
||||||
|
if (project.Hub.Type == "gitlab")
|
||||||
|
{
|
||||||
|
var endpoint = GetGitlabEndpoint(project.Hub.Origin, project.Id);
|
||||||
|
using HttpClient client = new();
|
||||||
|
var json = client.GetStringAsync(endpoint).GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
var packageJson = JsonSerializer.Deserialize<PackageJson>(json);
|
||||||
|
|
||||||
|
dependencies.AddRange(Map(packageJson?.Dependencies));
|
||||||
|
dependencies.AddRange(Map(packageJson?.DevDependencies));
|
||||||
|
dependencies.AddRange(Map(packageJson?.Engines));
|
||||||
|
}
|
||||||
|
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetGitlabEndpoint(string origin, int projectId)
|
||||||
|
{
|
||||||
|
var token = Environment.GetEnvironmentVariable("TLD_GITLAB_PAT");
|
||||||
|
return $"{origin}/api/v4/projects/{projectId}/repository/files/package.json/raw?" +
|
||||||
|
$"private_token={token}&ref=dev";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<Dependency> Map(JsonObject? dependencies)
|
||||||
|
{
|
||||||
|
if (dependencies is null)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var dependency in dependencies)
|
||||||
|
{
|
||||||
|
var actualVersion = dependency.Value?.ToString();
|
||||||
|
var brand = new Brand(dependency.Key);
|
||||||
|
|
||||||
|
if (actualVersion is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return new Dependency(actualVersion, brand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// private static Package DownloadPackage(ProjectDto project)
|
||||||
|
// {
|
||||||
|
// // var endpoint = projectDto.Tags.Have("gitlab") ? GetGitlabEndpoint(projectDto) : projectDto.Repo;
|
||||||
|
// var endpoint = "";
|
||||||
|
// if (Packages.TryGetValue(endpoint, out var downloadPackage)) return downloadPackage;
|
||||||
|
//
|
||||||
|
// using HttpClient client = new();
|
||||||
|
// var json = client.GetStringAsync(endpoint).GetAwaiter().GetResult();
|
||||||
|
//
|
||||||
|
// Packages.Add(endpoint, package);
|
||||||
|
// return package;
|
||||||
|
// }
|
||||||
|
//
|
@ -4,7 +4,7 @@ using TUI.Engine;
|
|||||||
|
|
||||||
namespace TUI.Providers.Dependencies;
|
namespace TUI.Providers.Dependencies;
|
||||||
|
|
||||||
public class Package
|
public class PackageJson
|
||||||
{
|
{
|
||||||
[JsonPropertyName("dependencies")]
|
[JsonPropertyName("dependencies")]
|
||||||
public JsonObject? Dependencies { get; set; }
|
public JsonObject? Dependencies { get; set; }
|
||||||
@ -14,20 +14,20 @@ public class Package
|
|||||||
|
|
||||||
[JsonPropertyName("engines")]
|
[JsonPropertyName("engines")]
|
||||||
public JsonObject? Engines { get; set; }
|
public JsonObject? Engines { get; set; }
|
||||||
|
|
||||||
public Version? ParseVersion(string? dependencyName)
|
public Version? ParseVersion(string? dependencyName)
|
||||||
{
|
{
|
||||||
if (dependencyName == null) return null;
|
if (dependencyName == null) return null;
|
||||||
|
|
||||||
JsonNode? version = null;
|
JsonNode? version = null;
|
||||||
|
|
||||||
var lowerDependencyName = dependencyName.ToLower();
|
var lowerDependencyName = dependencyName.ToLower();
|
||||||
Dependencies?.TryGetPropertyValue(lowerDependencyName, out version);
|
Dependencies?.TryGetPropertyValue(lowerDependencyName, out version);
|
||||||
|
|
||||||
if (version == null) Engines?.TryGetPropertyValue(lowerDependencyName, out version);
|
if (version == null) Engines?.TryGetPropertyValue(lowerDependencyName, out version);
|
||||||
|
|
||||||
if (version == null) DevDependencies?.TryGetPropertyValue(lowerDependencyName, out version);
|
if (version == null) DevDependencies?.TryGetPropertyValue(lowerDependencyName, out version);
|
||||||
|
|
||||||
return version?.GetValue<string>().ToVersion();
|
return version?.GetValue<string>().ToVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using TUI.Controls.Components;
|
using TUI.Controls.Components;
|
||||||
using TUI.Domain;
|
using TUI.Domain;
|
||||||
|
using TUI.Engine.Theme;
|
||||||
using TUI.Providers.Dependencies;
|
using TUI.Providers.Dependencies;
|
||||||
|
|
||||||
namespace TUI.Store;
|
namespace TUI.Store;
|
||||||
@ -7,40 +8,31 @@ namespace TUI.Store;
|
|||||||
public class DependenciesStore
|
public class DependenciesStore
|
||||||
{
|
{
|
||||||
public IEnumerable<Dependency> ConventionDependencies;
|
public IEnumerable<Dependency> ConventionDependencies;
|
||||||
|
|
||||||
public IEnumerable<Project> Projects;
|
public IEnumerable<Project> Projects;
|
||||||
|
|
||||||
|
private DependencyRepository Repository = new();
|
||||||
|
|
||||||
|
public IEnumerable<Dependency> ActualDependencies(Project project)
|
||||||
|
{
|
||||||
|
SpeakerComponent.Instance.Shout("", $"Fetch actual dependencies for project {project.Name.Main()}");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Repository.ReadActual(project);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
SpeakerComponent.Instance.Shout("", $"Fetch failed for project{project.Name}");
|
||||||
|
return new List<Dependency>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Bind()
|
public void Bind()
|
||||||
{
|
{
|
||||||
var repo = new DependencyRepository();
|
|
||||||
|
|
||||||
ConventionDependencies = repo.ReadConventions("javascript");
|
|
||||||
SpeakerComponent.Instance.Shout("🤔", "Prepare javascript conventions");
|
SpeakerComponent.Instance.Shout("🤔", "Prepare javascript conventions");
|
||||||
|
ConventionDependencies = Repository.ReadConventions("javascript");
|
||||||
Projects = repo.ReadProjects("javascript");
|
|
||||||
SpeakerComponent.Instance.Shout("🤩", "Prepare javascript projects");
|
SpeakerComponent.Instance.Shout("🤩", "Prepare javascript projects");
|
||||||
|
Projects = Repository.ReadProjects("javascript");
|
||||||
}
|
}
|
||||||
|
|
||||||
// private readonly static Dictionary<string, Package> Packages = new();
|
|
||||||
//
|
|
||||||
// private static Package DownloadPackage(ProjectDto projectDto)
|
|
||||||
// {
|
|
||||||
// // var endpoint = projectDto.Tags.Have("gitlab") ? GetGitlabEndpoint(projectDto) : projectDto.Repo;
|
|
||||||
// var endpoint = "";
|
|
||||||
// if (Packages.TryGetValue(endpoint, out var downloadPackage)) return downloadPackage;
|
|
||||||
//
|
|
||||||
// using HttpClient client = new();
|
|
||||||
// var json = client.GetStringAsync(endpoint).GetAwaiter().GetResult();
|
|
||||||
// var package = JsonSerializer.Deserialize<Package>(json);
|
|
||||||
// Packages.Add(endpoint, package);
|
|
||||||
// return package;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static string GetGitlabEndpoint(ProjectDto projectDto)
|
|
||||||
// {
|
|
||||||
// var token = Environment.GetEnvironmentVariable("TLD_GITLAB_PAT");
|
|
||||||
// // return $"{projectDto.Repo}/api/v4/projects/{projectDto.ProjectId}/repository/files/package.json/raw?" +
|
|
||||||
// // $"private_token={token}&ref=dev";
|
|
||||||
// return "";
|
|
||||||
// }
|
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using TUI.Controls.Components;
|
using TUI.Controls.Components;
|
||||||
|
using TUI.Domain;
|
||||||
using TUI.Engine.Attributes;
|
using TUI.Engine.Attributes;
|
||||||
using TUI.Engine.Components;
|
using TUI.Engine.Components;
|
||||||
|
|
||||||
@ -9,19 +10,45 @@ namespace TUI.Engine.Tests
|
|||||||
{
|
{
|
||||||
[Theory]
|
[Theory]
|
||||||
[Trait("Category", nameof(Sketch))]
|
[Trait("Category", nameof(Sketch))]
|
||||||
[InlineData(VersionType.Convention, "\u001b[38;2;132;186;100m10.12.33\u001b[0m")]
|
[InlineData(VersionStatus.BeNice, "\u001b[38;2;132;186;100m10.12.33\u001b[0m")]
|
||||||
[InlineData(VersionType.BeNice, "\u001b[38;2;132;186;100m10.12.33\u001b[0m")]
|
[InlineData(VersionStatus.SoGood, "\u001b[38;2;113;121;126m10.12.33\u001b[0m")]
|
||||||
[InlineData(VersionType.SoGood, "\u001b[38;2;113;121;126m10.12.33\u001b[0m")]
|
[InlineData(VersionStatus.ToNew, "\u001b[38;2;37;121;159m10.12.33\u001b[0m")]
|
||||||
[InlineData(VersionType.ToNew, "\u001b[38;2;37;121;159m10.12.33\u001b[0m")]
|
[InlineData(VersionStatus.TooOld, "\u001b[38;2;236;151;6m10.12.33\u001b[0m")]
|
||||||
[InlineData(VersionType.TooOld, "\u001b[38;2;236;151;6m10.12.33\u001b[0m")]
|
public void DrawSketchVersionTypes(VersionStatus versionStatus, string expected)
|
||||||
public void DrawSketchVersionTypes(VersionType versionType, string expected)
|
|
||||||
{
|
{
|
||||||
var brand = new Brand("Docker", "", "#1d63ed");
|
var brand = new Brand("Docker", "", "#1d63ed");
|
||||||
var version = new VersionComponent(versionType, "10.12.33", brand);
|
var version = new VersionComponent("10.12.33", brand, versionStatus);
|
||||||
|
|
||||||
var sketch = (version as IComponent).MakeSketch(new Size(10, 2));
|
var sketch = (version as IComponent).MakeSketch(new Size(10, 2));
|
||||||
|
|
||||||
sketch.ToString().Should().Be(expected);
|
sketch.ToString().Should().Be(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[Trait("Category", nameof(Dependency))]
|
||||||
|
[InlineData("1.0.0", "0.0.1", VersionStatus.ToNew)]
|
||||||
|
[InlineData("1.0.0", "0.1.1", VersionStatus.ToNew)]
|
||||||
|
[InlineData("1.0.0", "0.1.0", VersionStatus.ToNew)]
|
||||||
|
[InlineData("1.2.0", "1.0.0", VersionStatus.ToNew)]
|
||||||
|
[InlineData("1.2.0", "1.0.1", VersionStatus.ToNew)]
|
||||||
|
[InlineData("1.2.0", "1.1.0", VersionStatus.ToNew)]
|
||||||
|
[InlineData("1.0.0", "1.0.0-rc", VersionStatus.ToNew)]
|
||||||
|
[InlineData("1.0.0", "1.0.0", VersionStatus.SoGood)]
|
||||||
|
[InlineData("^1.0.0", "1.0.0", VersionStatus.SoGood)]
|
||||||
|
[InlineData("1.2.0", "1.3.0", VersionStatus.BeNice)]
|
||||||
|
[InlineData("1.3.1", "1.3.3", VersionStatus.BeNice)]
|
||||||
|
[InlineData("1.2.0", "2.1.0", VersionStatus.TooOld)]
|
||||||
|
[InlineData("1.2.0", "2.0.1", VersionStatus.TooOld)]
|
||||||
|
[InlineData("1.2.0", "2.3.1", VersionStatus.TooOld)]
|
||||||
|
public void ComparisonDependencies(string actual, string convention, VersionStatus expectedType)
|
||||||
|
{
|
||||||
|
var brand = new Brand("Poker", "", "#1d63ed");
|
||||||
|
var actualDependency = new Dependency(actual, brand);
|
||||||
|
var conventionDependency = new Dependency(convention, brand);
|
||||||
|
|
||||||
|
var status = actualDependency.Comparison(conventionDependency);
|
||||||
|
|
||||||
|
status.Should().Be(expectedType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user