62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using Matrix42.Extensions.Scaffolder.Core;
|
|
using Matrix42.Extensions.Scaffolder.Core.Project;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace Matrix42.Extensions.Scaffolder.ConsoleApp
|
|
{
|
|
internal class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
var config = new ConfigurationBuilder()
|
|
.SetBasePath(Directory.GetCurrentDirectory()) // required for appsettings.json
|
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
|
.Build();
|
|
|
|
var extensionPath = config["Scaffolder:ExtensionPath"];
|
|
var extensionIdStr = config["Scaffolder:ExtensionId"];
|
|
var extensionNamespace = config["Scaffolder:ExtensionNamespace"];
|
|
|
|
if (string.IsNullOrWhiteSpace(extensionPath))
|
|
throw new Exception("Scaffolder:ExtensionPath is missing in appsettings.json");
|
|
|
|
var extensionId = Guid.TryParse(extensionIdStr, out var gid) ? gid : Guid.NewGuid();
|
|
|
|
var options = new ExtensionScaffoldingOptions
|
|
{
|
|
ExtensionPath = extensionPath,
|
|
ExtensionId = extensionId,
|
|
ExtensionNamespace = extensionNamespace,
|
|
Projects = [
|
|
new ProjectDefinition
|
|
{
|
|
Prefix = "Services",
|
|
Runtimes = RuntimeTargets.WinCore | RuntimeTargets.LinuxCore,
|
|
Functionality = ProjectFunctionality.WebApi
|
|
},
|
|
|
|
new ProjectDefinition
|
|
{
|
|
Prefix = "Contracts",
|
|
Runtimes = RuntimeTargets.All,
|
|
Functionality = ProjectFunctionality.Custom
|
|
},
|
|
new ProjectDefinition
|
|
{
|
|
Prefix = "BizLogic",
|
|
Runtimes = RuntimeTargets.All,
|
|
Functionality = ProjectFunctionality.Custom
|
|
}
|
|
]
|
|
};
|
|
|
|
var scaffolder = new ExtensionScaffolder();
|
|
var projects = scaffolder.Generate(options);
|
|
|
|
Console.WriteLine("Generated projects:");
|
|
foreach (var p in projects)
|
|
Console.WriteLine(" - " + p);
|
|
}
|
|
}
|
|
}
|