3
3
// See the LICENSE file in the project root for more information
4
4
5
5
using System . IO . Abstractions ;
6
+ using System . Reflection ;
6
7
using Documentation . Assembler . Configuration ;
7
8
using Elastic . Markdown . Diagnostics ;
8
9
using Elastic . Markdown . IO ;
@@ -29,8 +30,32 @@ public AssembleContext(DiagnosticsCollector collector, IFileSystem readFileSyste
29
30
WriteFileSystem = writeFileSystem ;
30
31
31
32
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
+
32
38
ConfigurationPath = ReadFileSystem . FileInfo . New ( configPath ) ;
33
39
Configuration = AssemblyConfiguration . Deserialize ( ReadFileSystem . File . ReadAllText ( ConfigurationPath . FullName ) ) ;
34
40
OutputDirectory = ReadFileSystem . DirectoryInfo . New ( output ?? ".artifacts/assembly" ) ;
35
41
}
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
+ }
36
61
}
0 commit comments