@@ -48,6 +48,7 @@ private enum ConfigFileFormat
4848 private readonly IProxyConfiguration _proxyConfiguration ;
4949 private readonly HttpClient _httpClient ;
5050 private const string ConfigTemplatesFolder = "config-templates" ;
51+ private static readonly string [ ] configFilePatterns = [ "*.json" , "*.yaml" , "*.yml" ] ;
5152
5253 public ConfigCommand (
5354 HttpClient httpClient ,
@@ -309,6 +310,8 @@ private async Task DownloadConfigAsync(string configId, OutputFormat outputForma
309310 /// these file names. If there are no proxy configs, it'll return
310311 /// an array of all the mock files. If there are no mocks, it'll return
311312 /// an empty array indicating that there's no entry point.
313+ /// Files in the .devproxy subfolder are listed before files in the
314+ /// root folder.
312315 /// </remarks>
313316 /// <param name="configFolder">Full path to the folder with config files</param>
314317 /// <returns>Array of files that can be used to start proxy with</returns>
@@ -318,11 +321,14 @@ private ProxyConfigInfo GetConfigInfo(string configFolder)
318321
319322 _logger . LogDebug ( "Getting list of config files in {ConfigFolder}..." , configFolder ) ;
320323
321- // Get both JSON and YAML files
322- var jsonFiles = Directory . GetFiles ( configFolder , "*.json" ) ;
323- var yamlFiles = Directory . GetFiles ( configFolder , "*.yaml" ) ;
324- var ymlFiles = Directory . GetFiles ( configFolder , "*.yml" ) ;
325- var allConfigFiles = jsonFiles . Concat ( yamlFiles ) . Concat ( ymlFiles ) . ToArray ( ) ;
324+ // Presets in the samples gallery keep their config in a .devproxy
325+ // subfolder, so scan it first, followed by the root folder
326+ var foldersToScan = new [ ] { Path . Combine ( configFolder , ".devproxy" ) , configFolder }
327+ . Where ( Directory . Exists ) ;
328+ var allConfigFiles = foldersToScan
329+ . SelectMany ( folder => configFilePatterns
330+ . SelectMany ( pattern => Directory . GetFiles ( folder , pattern ) ) )
331+ . ToArray ( ) ;
326332
327333 if ( allConfigFiles . Length == 0 )
328334 {
0 commit comments