-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
44 changed files
with
1,380 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/Confix.Tool/src/Confix.Tool/Common/Execution/ConfigurationFileCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Collections; | ||
using Confix.Extensions; | ||
using Confix.Tool.Abstractions; | ||
using Confix.Tool.Abstractions.Configuration; | ||
|
||
namespace Confix.Tool.Middlewares; | ||
|
||
public sealed class ConfigurationFileCollection | ||
: IConfigurationFileCollection | ||
{ | ||
private readonly IReadOnlyList<JsonFile> _collection; | ||
|
||
public ConfigurationFileCollection( | ||
RuntimeConfiguration? configuration, | ||
SolutionConfiguration? solutionConfiguration, | ||
ProjectConfiguration? projectConfiguration, | ||
ComponentConfiguration? componentConfiguration, | ||
IReadOnlyList<JsonFile> collection) | ||
{ | ||
RuntimeConfiguration = configuration; | ||
Solution = solutionConfiguration; | ||
Project = projectConfiguration; | ||
Component = componentConfiguration; | ||
_collection = collection; | ||
} | ||
|
||
public RuntimeConfiguration? RuntimeConfiguration { get; } | ||
|
||
public SolutionConfiguration? Solution { get; } | ||
|
||
public ProjectConfiguration? Project { get; } | ||
|
||
public ComponentConfiguration? Component { get; } | ||
|
||
/// <inheritdoc /> | ||
public IEnumerator<JsonFile> GetEnumerator() | ||
=> _collection.GetEnumerator(); | ||
|
||
/// <inheritdoc /> | ||
IEnumerator IEnumerable.GetEnumerator() | ||
=> GetEnumerator(); | ||
|
||
/// <inheritdoc /> | ||
public int Count => _collection.Count; | ||
|
||
/// <inheritdoc /> | ||
public JsonFile this[int index] => _collection[index]; | ||
} |
1 change: 1 addition & 0 deletions
1
src/Confix.Tool/src/Confix.Tool/Common/Execution/IConfigurationFileCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/Confix.Tool/src/Confix.Tool/Entities/Component/Inputs/GraphQL/DotnetComponentInput.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using Confix.Tool.Commands.Logging; | ||
using Confix.Tool.Commands.Temp; | ||
using Confix.Tool.Common.Pipelines; | ||
using Confix.Tool.Middlewares; | ||
using Confix.Tool.Schema; | ||
using Confix.Utilities.FileSystem; | ||
|
||
namespace Confix.Tool.Entities.Components; | ||
|
||
public sealed class DotnetComponentInput : IComponentInput | ||
{ | ||
private const string _embeddedResourcePath = | ||
$"$(MSBuildProjectDirectory)/{FolderNames.Components}/**/*.*"; | ||
|
||
public static string Type => "dotnet"; | ||
|
||
/// <inheritdoc /> | ||
public async Task ExecuteAsync(IMiddlewareContext context) | ||
{ | ||
var configuration = context.Features.Get<ConfigurationFeature>(); | ||
|
||
if (configuration.Scope is not ConfigurationScope.Component || | ||
configuration.ConfigurationFiles.Component is null) | ||
{ | ||
throw new ExitException("Component input has to be executed in a component directory"); | ||
} | ||
|
||
if (configuration.Project?.Directory is not { } projectDirectory) | ||
{ | ||
context.Logger.DotnetComponentProviderNeedsToBeRunInsideAConfixProject(); | ||
return; | ||
} | ||
|
||
var csproj = DotnetHelpers.FindProjectFileInPath(projectDirectory); | ||
|
||
if (csproj is null) | ||
{ | ||
context.Logger.ProjectNotFoundInDirectory(projectDirectory); | ||
context.Logger.DotnetProjectWasNotDetected(); | ||
return; | ||
} | ||
|
||
context.Logger.FoundDotnetProject(csproj); | ||
|
||
try | ||
{ | ||
DotnetHelpers.EnsureEmbeddedResource(csproj, _embeddedResourcePath); | ||
} | ||
catch | ||
{ | ||
context.Logger.CouldNotParseProjectFile(csproj); | ||
} | ||
} | ||
} | ||
|
||
file static class Log | ||
{ | ||
public static void DotnetComponentProviderNeedsToBeRunInsideAConfixProject( | ||
this IConsoleLogger console) | ||
{ | ||
console.Error( | ||
"Dotnet component provider needs to be run inside a confix project. No project was found"); | ||
} | ||
|
||
public static void ProjectNotFoundInDirectory( | ||
this IConsoleLogger logger, | ||
DirectoryInfo directory) | ||
{ | ||
logger.Debug($"Could not find project in directory: {directory}"); | ||
} | ||
|
||
public static void DotnetProjectWasNotDetected(this IConsoleLogger logger) | ||
{ | ||
logger.Information("Dotnet project was not detected. Skipping dotnet component input"); | ||
} | ||
|
||
public static void FoundDotnetProject(this IConsoleLogger logger, FileSystemInfo csproj) | ||
{ | ||
logger.Information($"Found .NET project:{csproj.ToLink()} [dim]{csproj.FullName}[/]"); | ||
} | ||
|
||
public static void CouldNotParseProjectFile(this IConsoleLogger logger, FileSystemInfo csproj) | ||
{ | ||
logger.Error($"Could not parse project file: {csproj.ToLink()} [dim]{csproj.FullName}[/]"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
src/Confix.Tool/src/Confix.Tool/Entities/Encryption/EncryptionDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
namespace Confix.Tool.Abstractions; | ||
|
||
public record EncryptionDefinition( | ||
EncryptionProviderDefinition Provider | ||
) | ||
public record EncryptionDefinition(EncryptionProviderDefinition Provider) | ||
{ | ||
public static EncryptionDefinition From(EncryptionConfiguration configuration) | ||
{ | ||
if (configuration.Provider is null) | ||
{ | ||
throw new ValidationException("Encryption configuration is invalid.") | ||
{ | ||
Errors = new[]{"Provider is required."} | ||
Errors = new[] { "Provider is required." } | ||
}; | ||
} | ||
|
||
var provider = EncryptionProviderDefinition.From(configuration.Provider!); | ||
|
||
return new EncryptionDefinition(provider); | ||
} | ||
}; | ||
}; |
Oops, something went wrong.