33// See the LICENSE file in the project root for more information
44
55using System . IO . Abstractions ;
6+ using System . Reflection ;
67using Documentation . Assembler . Configuration ;
78using Elastic . Markdown . Diagnostics ;
89using Elastic . Markdown . IO ;
@@ -29,8 +30,32 @@ public AssembleContext(DiagnosticsCollector collector, IFileSystem readFileSyste
2930 WriteFileSystem = writeFileSystem ;
3031
3132 var configPath = Path . Combine ( Paths . Root . FullName , "src/docs-assembler/assembler.yml" ) ;
33+ // temporarily fallback to embedded assembler.yml
34+ // This will live in docs-content soon
35+ if ( ! ReadFileSystem . File . Exists ( configPath ) )
36+ ExtractAssemblerConfiguration ( configPath ) ;
37+
3238 ConfigurationPath = ReadFileSystem . FileInfo . New ( configPath ) ;
3339 Configuration = AssemblyConfiguration . Deserialize ( ReadFileSystem . File . ReadAllText ( ConfigurationPath . FullName ) ) ;
3440 OutputDirectory = ReadFileSystem . DirectoryInfo . New ( output ?? ".artifacts/assembly" ) ;
3541 }
42+
43+ private void ExtractAssemblerConfiguration ( string configPath )
44+ {
45+ var embeddedStaticFiles = Assembly . GetExecutingAssembly ( )
46+ . GetManifestResourceNames ( )
47+ . ToList ( ) ;
48+ var configFile = embeddedStaticFiles . First ( f => f . EndsWith ( "assembler.yml" ) ) ;
49+ using var resourceStream = Assembly . GetExecutingAssembly ( ) . GetManifestResourceStream ( configFile ) ;
50+ if ( resourceStream == null )
51+ return ;
52+
53+ var outputFile = WriteFileSystem . FileInfo . New ( configPath ) ;
54+ if ( outputFile . Directory is { Exists : false } )
55+ outputFile . Directory . Create ( ) ;
56+ using var stream = outputFile . OpenWrite ( ) ;
57+ resourceStream . CopyTo ( stream ) ;
58+
59+
60+ }
3661}
0 commit comments