Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions DevProxy/Commands/DevProxyCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sealed class DevProxyCommand : RootCommand
private readonly IProxyConfiguration _proxyConfiguration;
private readonly ISet<UrlToWatch> _urlsToWatch;
private readonly UpdateNotification _updateNotification;
private readonly IConfiguration _configuration;
private WebApplication? _app;

internal const string PortOptionName = "--port";
Expand Down Expand Up @@ -59,13 +60,15 @@ public DevProxyCommand(
IProxyConfiguration proxyConfiguration,
IServiceProvider serviceProvider,
UpdateNotification updateNotification,
IConfiguration configuration,
ILogger<DevProxyCommand> logger) : base("Start Dev Proxy")
{
_serviceProvider = serviceProvider;
_plugins = plugins;
_urlsToWatch = urlsToWatch;
_proxyConfiguration = proxyConfiguration;
_updateNotification = updateNotification;
_configuration = configuration;
_logger = logger;

ConfigureCommand();
Expand All @@ -84,6 +87,11 @@ private async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken c
{
throw new InvalidOperationException("WebApplication instance is not set. Please provide it when invoking the command.");
}
if ((_configuration as IConfigurationRoot)?.Providers.Any(p => p is FileConfigurationProvider) != true)
{
_logger.LogError("No configuration file found. Please create a devproxyrc.json file in the current directory.");
return 1;
}
if (!_plugins.Any())
{
_logger.LogError("You haven't configured any plugins. Please add plugins to your configuration file. Dev Proxy will exit.");
Expand Down
2 changes: 1 addition & 1 deletion DevProxy/Extensions/ConfigurationManagerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public static ConfigurationManager ConfigureDevProxyConfig(this ConfigurationMan
}
}

throw new InvalidOperationException("No configuration file found. Please create a devproxyrc.json file in the current directory.");
return configuration;
}
}
3 changes: 2 additions & 1 deletion DevProxy/Plugins/PluginServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public static IServiceCollection AddPlugins(

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

var defaultUrlsToWatch = globallyWatchedUrls.ToHashSet();
Expand Down
74 changes: 0 additions & 74 deletions DevProxy/devproxy-errors.json

This file was deleted.

29 changes: 0 additions & 29 deletions DevProxy/devproxyrc.json

This file was deleted.