feat: add setup wizard and proper seeder
All checks were successful
Update changelog / changelog (push) Successful in 26s

This commit is contained in:
2025-12-16 04:02:42 +01:00
parent eebc5f1d6d
commit defa00d0d3
7 changed files with 212 additions and 42 deletions

View File

@@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi;
using Shadow.Controllers;
using Shadow.Data;
using Shadow.Tools;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
@@ -66,12 +66,13 @@ builder.Services.AddSwaggerGen(options =>
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
});
builder.Services.AddHttpLogging();
var app = builder.Build();
bool shutdown = false;
if (args.FirstOrDefault() is not null)
{
// Handle CLI if arguments have been passed.
bool shutdown = false;
using (IServiceScope scope = app.Services.CreateScope())
{
ApplicationDbContext db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
@@ -87,9 +88,9 @@ using (IServiceScope scope = app.Services.CreateScope())
ApplicationDbContext db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
GeneralUseHelpers guhf = scope.ServiceProvider.GetRequiredService<GeneralUseHelpers>();
Seeder seeder = new(db, guhf);
seeder.Seed();
shutdown = seeder.Seed();
}
if (shutdown) return;
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
@@ -97,6 +98,7 @@ if (app.Environment.IsDevelopment())
app.MapOpenApi();
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpLogging();
}
app.UseHttpsRedirection();