@@ -10,16 +10,18 @@ namespace Elastic.Documentation.Configuration;
1010public class ConfigurationFileProvider
1111{
1212 private readonly IFileSystem _fileSystem ;
13+ private readonly string _assemblyName ;
1314
1415 public ConfigurationFileProvider ( IFileSystem fileSystem )
1516 {
1617 _fileSystem = fileSystem ;
18+ _assemblyName = typeof ( ConfigurationFileProvider ) . Assembly . GetName ( ) . Name ! ;
1719 TemporaryDirectory = fileSystem . Directory . CreateTempSubdirectory ( "docs-builder-config" ) ;
1820
19- VersionFile = CreateTemporaryConfigurationFile ( EmbeddedResource . ______config_versions_yml ) ;
20- AssemblerFile = CreateTemporaryConfigurationFile ( EmbeddedResource . ______config_assembler_yml ) ;
21- NavigationFile = CreateTemporaryConfigurationFile ( EmbeddedResource . ______config_navigation_yml ) ;
22- LegacyUrlMappingsFile = CreateTemporaryConfigurationFile ( EmbeddedResource . ______config_legacy_url_mappings_yml ) ;
21+ VersionFile = CreateTemporaryConfigurationFile ( "versions.yml" ) ;
22+ AssemblerFile = CreateTemporaryConfigurationFile ( "assembler.yml" ) ;
23+ NavigationFile = CreateTemporaryConfigurationFile ( "navigation.yml" ) ;
24+ LegacyUrlMappingsFile = CreateTemporaryConfigurationFile ( "legacy-url-mappings.yml" ) ;
2325 }
2426
2527 private IDirectoryInfo TemporaryDirectory { get ; }
@@ -32,30 +34,28 @@ public ConfigurationFileProvider(IFileSystem fileSystem)
3234
3335 public IFileInfo LegacyUrlMappingsFile { get ; }
3436
35- private IFileInfo CreateTemporaryConfigurationFile ( EmbeddedResource resource )
37+ private IFileInfo CreateTemporaryConfigurationFile ( string fileName )
3638 {
37- var fileName = string . Join ( "." , resource . GetResourceName ( ) . Split ( '.' ) [ ^ 2 ..] ) ;
38- using var stream = GetLocalOrEmbedded ( resource ) ;
39+ using var stream = GetLocalOrEmbedded ( fileName ) ;
3940 var context = stream . ReadToEnd ( ) ;
4041 var fi = _fileSystem . FileInfo . New ( Path . Combine ( TemporaryDirectory . FullName , fileName ) ) ;
4142 _fileSystem . File . WriteAllText ( fi . FullName , context ) ;
4243 return fi ;
4344 }
4445
45- private StreamReader GetLocalOrEmbedded ( EmbeddedResource resource )
46+ private StreamReader GetLocalOrEmbedded ( string fileName )
4647 {
47- var fileName = string . Join ( "." , resource . GetResourceName ( ) . Split ( '.' ) [ ^ 2 ..] ) ;
4848 var configPath = GetLocalPath ( fileName ) ;
4949 if ( ! _fileSystem . File . Exists ( configPath ) )
50- return GetEmbeddedStream ( resource ) ;
50+ return GetEmbeddedStream ( fileName ) ;
5151 var reader = _fileSystem . File . OpenText ( configPath ) ;
5252 return reader ;
5353 }
5454
55- private static StreamReader GetEmbeddedStream ( EmbeddedResource resource )
55+ private StreamReader GetEmbeddedStream ( string fileName )
5656 {
57- var name = resource . GetResourceName ( ) . Replace ( ".......config." , "." ) ;
58- var resourceStream = typeof ( EmbeddedResource ) . Assembly . GetManifestResourceStream ( name ) ! ;
57+ var resourceName = $ " { _assemblyName } . { fileName } " ;
58+ var resourceStream = typeof ( ConfigurationFileProvider ) . Assembly . GetManifestResourceStream ( resourceName ) ! ;
5959 var reader = new StreamReader ( resourceStream , leaveOpen : false ) ;
6060 return reader ;
6161 }
0 commit comments