Skip to content

Commit 1834248

Browse files
committed
add configuration exporter back
1 parent 3cc8a86 commit 1834248

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

src/tooling/docs-assembler/Building/AssemblerBuilder.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Text.Json;
77
using Documentation.Assembler.Exporters;
88
using Documentation.Assembler.Navigation;
9-
using Elastic.Documentation.Configuration;
109
using Elastic.Documentation.Legacy;
1110
using Elastic.Documentation.Links;
1211
using Elastic.Documentation.Serialization;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
using System.IO.Abstractions;
6+
using Elastic.Markdown.Exporters;
7+
using Microsoft.Extensions.Logging;
8+
9+
namespace Documentation.Assembler.Exporters;
10+
11+
public class ConfigurationExporter(ILoggerFactory logFactory, AssembleContext context) : IMarkdownExporter
12+
{
13+
private readonly ILogger<ConfigurationExporter> _logger = logFactory.CreateLogger<ConfigurationExporter>();
14+
15+
/// <inheritdoc />
16+
public ValueTask StartAsync(CancellationToken ctx = default) => default;
17+
18+
/// <inheritdoc />
19+
public ValueTask StopAsync(CancellationToken ctx = default) => default;
20+
21+
/// <inheritdoc />
22+
public ValueTask<bool> ExportAsync(MarkdownExportFileContext fileContext, CancellationToken ctx) => default;
23+
24+
/// <inheritdoc />
25+
public ValueTask<bool> FinishExportAsync(IDirectoryInfo outputFolder, CancellationToken ctx)
26+
{
27+
var fs = context.WriteFileSystem;
28+
var configFolder = fs.DirectoryInfo.New(Path.Combine(context.OutputDirectory.FullName, "config"));
29+
if (!configFolder.Exists)
30+
configFolder.Create();
31+
32+
_logger.LogInformation("Exporting configuration");
33+
34+
var assemblerConfig = context.ConfigurationFileProvider.AssemblerFile;
35+
_logger.LogInformation("Exporting {Name} to {ConfigFolder}", assemblerConfig.Name, configFolder.FullName);
36+
context.WriteFileSystem.File.Copy(assemblerConfig.FullName, Path.Combine(configFolder.FullName, assemblerConfig.Name), true);
37+
38+
var navigationConfig = context.ConfigurationFileProvider.NavigationFile;
39+
_logger.LogInformation("Exporting {Name} to {ConfigFolder}", navigationConfig.Name, configFolder.FullName);
40+
context.WriteFileSystem.File.Copy(navigationConfig.FullName, Path.Combine(configFolder.FullName, navigationConfig.Name), true);
41+
42+
var legacyUrlMappingsConfig = context.ConfigurationFileProvider.LegacyUrlMappingsFile;
43+
_logger.LogInformation("Exporting {Name} to {ConfigFolder}", legacyUrlMappingsConfig.Name, configFolder.FullName);
44+
context.WriteFileSystem.File.Copy(legacyUrlMappingsConfig.FullName, Path.Combine(configFolder.FullName, legacyUrlMappingsConfig.Name), true);
45+
46+
var versionsConfig = context.ConfigurationFileProvider.VersionFile;
47+
_logger.LogInformation("Exporting {Name} to {ConfigFolder}", versionsConfig.Name, configFolder.FullName);
48+
context.WriteFileSystem.File.Copy(versionsConfig.FullName, Path.Combine(configFolder.FullName, versionsConfig.Name), true);
49+
50+
return default;
51+
}
52+
}

0 commit comments

Comments
 (0)