make config path customizable
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>ViteProxy</RootNamespace>
|
||||
<AssemblyName>ViteProxy</AssemblyName>
|
||||
<Version>1.1.1</Version>
|
||||
<Version>1.2.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ViteProxyOptions
|
||||
/// <summary>
|
||||
/// Directory where the frontend files are located
|
||||
/// </summary>
|
||||
public string WorkingDirectory { get; set; } = "";
|
||||
public string WorkingDirectory { get; set; } = "App";
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enable the proxy or not
|
||||
|
||||
@@ -81,6 +81,7 @@ public class ViteProxyService : IHostedService
|
||||
ProcessProxy process = new ProcessProxy(_workingDirectory.Path, "npm", _options.ForwardLog)
|
||||
.Argument("run " + _options.ScriptName)
|
||||
.EnvVar("PORT", port.ToString())
|
||||
//.EnvVar("URL_PREFIX", "/@viteproxy/")
|
||||
.Capture(CaptureLog);
|
||||
|
||||
await process.RunAsync(_options.StartupCondition, TimeSpan.FromSeconds(_options.TimeoutInSeconds));
|
||||
|
||||
@@ -8,23 +8,23 @@ namespace ViteProxy;
|
||||
|
||||
public static class ViteProxyServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddViteProxy(this IServiceCollection services)
|
||||
public static IServiceCollection AddViteProxy(this IServiceCollection services, string configSectionPath = "Vite")
|
||||
{
|
||||
services.AddLogging();
|
||||
services.AddOptions();
|
||||
services.AddHostedService<ViteProxyService>();
|
||||
services.AddOptions<ViteProxyOptions>().BindConfiguration("Vite");
|
||||
services.AddOptions<ViteProxyOptions>().BindConfiguration(configSectionPath);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
public static IServiceCollection AddViteProxy(this IServiceCollection services, Action<ViteProxyOptions> configure)
|
||||
public static IServiceCollection AddViteProxy(this IServiceCollection services, Action<ViteProxyOptions> configure, string configSectionPath = "Vite")
|
||||
{
|
||||
services.AddLogging();
|
||||
services.AddOptions();
|
||||
services.AddHostedService<ViteProxyService>();
|
||||
services.AddOptions<ViteProxyOptions>().BindConfiguration("Vite");
|
||||
services.AddOptions<ViteProxyOptions>().BindConfiguration(configSectionPath);
|
||||
services.PostConfigure(configure);
|
||||
|
||||
return services;
|
||||
|
||||
Reference in New Issue
Block a user