Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/job implementation #92

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Nox.Cli.Abstractions/Configuration/IJobConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Nox.Cli.Abstractions.Configuration;

public interface IJobConfiguration
{
string Id { get; set; }
string Name { get; set; }
string? If { get; set; }
NoxJobDisplayMessage? Display { get; set; }
List<IActionConfiguration> Steps { get; set; }
}
6 changes: 0 additions & 6 deletions src/Nox.Cli.Abstractions/Configuration/IStepConfiguration.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ public interface IWorkflowConfiguration
string Name { get; set; }
string Description { get; set; }
ICliConfiguration Cli { get; set; }
Dictionary<string, IStepConfiguration> Jobs { get; set; }
List<IJobConfiguration> Jobs { get; set; }
}
2 changes: 1 addition & 1 deletion src/Nox.Cli.Abstractions/INoxAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public interface INoxAction
int Sequence { get; set; }
string Id { get; set; }
string? If { get; set; }
string Job { get; set; }
string JobId { get; set; }
string Name { get; set; }
string Uses { get; set; }

Expand Down
13 changes: 13 additions & 0 deletions src/Nox.Cli.Abstractions/INoxJob.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Nox.Cli.Abstractions;

public interface INoxJob
{
int Sequence { get; set; }
int FirstStepSequence { get; set; }
string Id { get; set; }

string Name { get; set; }
string? If { get; set; }
NoxJobDisplayMessage? Display { get; set; }
IDictionary<string, INoxAction> Steps { get; set; }
}
6 changes: 6 additions & 0 deletions src/Nox.Cli.Abstractions/INoxWorkflow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Nox.Cli.Abstractions;

public interface INoxWorkflow
{
public IDictionary<string, INoxJob> Jobs { get; set; }
}
1 change: 1 addition & 0 deletions src/Nox.Cli.Abstractions/INoxWorkflowContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Nox.Cli.Abstractions.Caching;
using Nox.Secrets.Abstractions;
using Nox.Solution;
using Spectre.Console;

namespace Nox.Cli.Abstractions
{
Expand Down
6 changes: 6 additions & 0 deletions src/Nox.Cli.Abstractions/Nox.Cli.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@
<PackageReference Include="Nox.Secrets" Version="7.0.14" />
<PackageReference Include="Nox.Solution" Version="7.0.15" />
</ItemGroup>

<ItemGroup>
<Reference Include="Spectre.Console">
<HintPath>..\Nox.Cli\bin\Debug\net7.0\Spectre.Console.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions src/Nox.Cli.Abstractions/NoxJobDisplayMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Nox.Cli.Abstractions;

public class NoxJobDisplayMessage
{
public string Success { get; set; } = string.Empty;
public string IfCondition { get; set; } = string.Empty;
}
2 changes: 1 addition & 1 deletion src/Nox.Cli.Caching/NoxCliCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ private IDeserializer BuildDeserializer()
.IgnoreUnmatchedProperties()
.WithTypeMapping<IActionConfiguration, ActionConfiguration>()
.WithTypeMapping<ICliConfiguration, CliConfiguration>()
.WithTypeMapping<IStepConfiguration, StepConfiguration>()
.WithTypeMapping<IJobConfiguration, JobConfiguration>()
.WithTypeMapping<ICliCommandConfiguration, CliCommandConfiguration>()
.WithTypeMapping<ILocalTaskExecutorConfiguration, LocalTaskExecutorConfiguration>()
.WithTypeMapping<ISecretsConfiguration, SecretsConfiguration>()
Expand Down
16 changes: 16 additions & 0 deletions src/Nox.Cli.Configuration/JobConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Nox.Cli.Abstractions;
using Nox.Cli.Abstractions.Configuration;

namespace Nox.Cli.Configuration;

public class JobConfiguration: IJobConfiguration
{
public string Id { get; set; } = string.Empty;

public string Name { get; set; } = string.Empty;

public string? If { get; set; }

public NoxJobDisplayMessage? Display { get; set; }
public List<IActionConfiguration> Steps { get; set; } = new();
}
10 changes: 0 additions & 10 deletions src/Nox.Cli.Configuration/StepConfiguration.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Nox.Cli.Configuration/WorkflowConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public class WorkflowConfiguration: IWorkflowConfiguration
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public ICliConfiguration Cli { get; set; } = null!;
public Dictionary<string, IStepConfiguration> Jobs { get; set; } = new();
public List<IJobConfiguration> Jobs { get; set; } = new();
}

42 changes: 6 additions & 36 deletions src/Nox.Cli.Helpers/ConsoleWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

public interface IConsoleWriter
{
void WriteInfo(string message);
void WriteError(string message);
void WriteWarning(string message);
void WriteHelpHeader(string message);
void WriteHelpText(string message);
void WriteLogMessage(string message);
void WriteRuler(string message);
void WriteInfo(string key, string message);
void WriteHelpText(string key, string message);
}

public class ConsoleWriter : IConsoleWriter
Expand All @@ -22,39 +17,14 @@ public ConsoleWriter(IAnsiConsole console)
_console = console;
}

public void WriteInfo(string message)
public void WriteInfo(string key, string message)
{
_console.MarkupLine($"[bold mediumpurple3_1]{message.EscapeMarkup()}[/]");
_console.MarkupLine($"[bold mediumpurple3_1]{key}: [/]{message.EscapeMarkup()}");
}

public void WriteError(string message)
public void WriteHelpText(string key, string message)
{
_console.MarkupLine($"[bold indianred1]ERROR: {message.EscapeMarkup()}[/]");
}

public void WriteWarning(string message)
{
_console.MarkupLine($"[bold olive]WARNING: {message.EscapeMarkup()}[/]");
}

public void WriteHelpHeader(string message)
{
_console.MarkupLine($"[bold olive]{message.EscapeMarkup()}[/]");
}

public void WriteHelpText(string message)
{
_console.MarkupLine($"[bold seagreen1]{message.EscapeMarkup()}[/]");
}

public void WriteLogMessage(string message)
{
_console.MarkupLine($"[grey]{message}.[/]");
}

public void WriteRuler(string message)
{
_console.Write(new Rule($"[bold mediumpurple3_1]{message.EscapeMarkup()}[/]") { Justification = Justify.Left });
_console.MarkupLine($"[bold seagreen1]{key}: [/]{message.EscapeMarkup()}");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Nox.Cli.Abstractions;
using Nox.Cli.Abstractions.Exceptions;
using Nox.Cli.Abstractions.Extensions;
using Nox.Cli.Abstractions.Helpers;
using Nox.Cli.Helpers;
using Nox.Cli.Plugin.Console.JsonSchema;
using RestSharp;
Expand Down Expand Up @@ -217,8 +216,8 @@ public async Task<IDictionary<string, object>> ProcessAsync(INoxWorkflowContext
await File.WriteAllTextAsync(outputFilePath, _yaml.ToString());
outputs["file-path"] = outputFilePath;

AnsiConsole.WriteLine();
AnsiConsole.MarkupLine($"[bold mediumpurple3_1]Created {_fileOptions["filename"].EscapeMarkup()}[/]");
//AnsiConsole.WriteLine();
//AnsiConsole.MarkupLine($"[bold mediumpurple3_1]Created {_fileOptions["filename"].EscapeMarkup()}[/]");
}

ctx.SetState(ActionState.Success);
Expand Down
2 changes: 1 addition & 1 deletion src/Nox.Cli.Shared.DTO/Task/Request/ServerAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class ServerAction: INoxAction
public int Sequence { get; set; }
public string Id { get; set; } = string.Empty;
public string? If { get; set; }
public string Job { get; set; } = string.Empty;
public string JobId { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string Uses { get; set; } = string.Empty;
public bool? RunAtServer { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Nox.Cli/Actions/NoxAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class NoxAction: INoxAction
public int Sequence { get; set; } = 0;
public string Id { get; set; } = string.Empty;
public string? If { get; set; } = string.Empty;
public string Job { get; set; } = string.Empty;
public string JobId { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string Uses { get; set; } = string.Empty;
public bool? RunAtServer { get; set; } = false;
Expand Down
16 changes: 16 additions & 0 deletions src/Nox.Cli/Actions/NoxJob.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Nox.Cli.Abstractions;

namespace Nox.Cli.Actions;

public class NoxJob: INoxJob
{
public int Sequence { get; set; }
public int FirstStepSequence { get; set; } = 0;
public string Id { get; set; } = string.Empty;

public string Name { get; set; } = string.Empty;
public string? If { get; set; }

public NoxJobDisplayMessage? Display { get; set; } = new();
public IDictionary<string, INoxAction> Steps { get; set; } = new Dictionary<string, INoxAction>();
}
Loading
Loading