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