Skip to content

Commit a8fcde8

Browse files
Removes default config. Closes #1355
1 parent d554049 commit a8fcde8

File tree

5 files changed

+11
-105
lines changed

5 files changed

+11
-105
lines changed

DevProxy/Commands/DevProxyCommand.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ sealed class DevProxyCommand : RootCommand
1414
private readonly IProxyConfiguration _proxyConfiguration;
1515
private readonly ISet<UrlToWatch> _urlsToWatch;
1616
private readonly UpdateNotification _updateNotification;
17+
private readonly IConfiguration _configuration;
1718
private WebApplication? _app;
1819

1920
internal const string PortOptionName = "--port";
@@ -59,13 +60,15 @@ public DevProxyCommand(
5960
IProxyConfiguration proxyConfiguration,
6061
IServiceProvider serviceProvider,
6162
UpdateNotification updateNotification,
63+
IConfiguration configuration,
6264
ILogger<DevProxyCommand> logger) : base("Start Dev Proxy")
6365
{
6466
_serviceProvider = serviceProvider;
6567
_plugins = plugins;
6668
_urlsToWatch = urlsToWatch;
6769
_proxyConfiguration = proxyConfiguration;
6870
_updateNotification = updateNotification;
71+
_configuration = configuration;
6972
_logger = logger;
7073

7174
ConfigureCommand();
@@ -84,6 +87,11 @@ private async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken c
8487
{
8588
throw new InvalidOperationException("WebApplication instance is not set. Please provide it when invoking the command.");
8689
}
90+
if ((_configuration as IConfigurationRoot)?.Providers.Any(p => p is FileConfigurationProvider) != true)
91+
{
92+
_logger.LogError("No configuration file found. Please create a devproxyrc.json file in the current directory.");
93+
return 1;
94+
}
8795
if (!_plugins.Any())
8896
{
8997
_logger.LogError("You haven't configured any plugins. Please add plugins to your configuration file. Dev Proxy will exit.");

DevProxy/Extensions/ConfigurationManagerExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ public static ConfigurationManager ConfigureDevProxyConfig(this ConfigurationMan
3838
}
3939
}
4040

41-
throw new InvalidOperationException("No configuration file found. Please create a devproxyrc.json file in the current directory.");
41+
return configuration;
4242
}
4343
}

DevProxy/Plugins/PluginServiceExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public static IServiceCollection AddPlugins(
6868

6969
if (pluginReferences is null || !pluginReferences.Any(p => p.Enabled))
7070
{
71-
throw new InvalidOperationException("No plugins configured or enabled. Please add a plugin to the configuration file.");
71+
_ = services.AddSingleton<ISet<UrlToWatch>>(globallyWatchedUrls.ToHashSet());
72+
return services;
7273
}
7374

7475
var defaultUrlsToWatch = globallyWatchedUrls.ToHashSet();

DevProxy/devproxy-errors.json

Lines changed: 0 additions & 74 deletions
This file was deleted.

DevProxy/devproxyrc.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)