Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit f8aa1e7

Browse files
parallelizing docs generation
1 parent a78bc8f commit f8aa1e7

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

build/Program.cs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.IO;
33
using System.Linq;
44
using System.Runtime.InteropServices;
5-
using System.Threading.Tasks;
65
using static Bullseye.Targets;
76
using static SimpleExec.Command;
87

@@ -12,6 +11,7 @@ static class Program
1211
private const string PublishDir = "publish";
1312

1413
private const string Clean = nameof(Clean);
14+
private const string Init = nameof(Init);
1515
private const string GenerateDocumentation = nameof(GenerateDocumentation);
1616
private const string Build = nameof(Build);
1717
private const string RunTests = nameof(RunTests);
@@ -22,35 +22,25 @@ static class Program
2222
public static void Main(string[] args)
2323
{
2424
var apiKey = Environment.GetEnvironmentVariable("MYGET_API_KEY");
25+
var srcDirectory = new DirectoryInfo("./src");
2526

2627
Target(Clean, () =>
2728
{
2829
if (Directory.Exists(ArtifactsDir))
2930
{
3031
Directory.Delete(ArtifactsDir, true);
3132
}
33+
3234
if (Directory.Exists(PublishDir))
3335
{
3436
Directory.Delete(PublishDir, true);
3537
}
36-
3738
});
3839

3940
Target(
40-
GenerateDocumentation,
41+
Init,
4142
() =>
4243
{
43-
var srcDirectory = new DirectoryInfo("./src");
44-
45-
var schemaFiles = srcDirectory.GetFiles("*.schema.json", SearchOption.AllDirectories);
46-
47-
var schemaDirectories = schemaFiles
48-
.Select(schemaFile => schemaFile.DirectoryName)
49-
.Distinct()
50-
.Select(schemaDirectory =>
51-
schemaDirectory.Replace(Path.DirectorySeparatorChar,
52-
'/')); // normalize paths; yarn/node can handle forward slashes
53-
5444
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
5545
{
5646
Run("cmd", "/c yarn", "docs");
@@ -59,22 +49,24 @@ public static void Main(string[] args)
5949
{
6050
Run("yarn", string.Empty, "docs");
6151
}
62-
63-
foreach (var schemaDirectory in schemaDirectories)
64-
{
65-
Run(
66-
"node",
67-
$"node_modules/@adobe/jsonschema2md/cli.js -n --input {schemaDirectory} --out {schemaDirectory} --schema-out=-",
68-
"docs");
69-
}
7052
});
7153

54+
Target(
55+
GenerateDocumentation,
56+
DependsOn(Init),
57+
ForEach(SchemaDirectories(srcDirectory)),
58+
schemaDirectory =>
59+
RunAsync(
60+
"node",
61+
$"node_modules/@adobe/jsonschema2md/cli.js -n --input {schemaDirectory} --out {schemaDirectory} --schema-out=-",
62+
"docs"));
63+
7264
Target(
7365
Build,
7466
DependsOn(GenerateDocumentation),
7567
() => Run(
7668
"dotnet",
77-
$"build src/SqlStreamStore.HAL.sln -c Release"));
69+
"build src/SqlStreamStore.HAL.sln -c Release"));
7870

7971
Target(
8072
RunTests,
@@ -89,7 +81,7 @@ public static void Main(string[] args)
8981
() => Run(
9082
"dotnet",
9183
$"publish --configuration=Release --output=../../{PublishDir} --runtime=alpine.3.7-x64 /p:ShowLinkerSizeComparison=true src/SqlStreamStore.HAL.DevServer"));
92-
84+
9385
Target(
9486
Pack,
9587
DependsOn(Publish),
@@ -121,6 +113,13 @@ public static void Main(string[] args)
121113

122114
Target("default", DependsOn(Clean, RunTests, Push));
123115

124-
RunTargets(args);
116+
RunTargets(args.Concat(new[] {"--parallel"}));
125117
}
118+
119+
private static string[] SchemaDirectories(DirectoryInfo srcDirectory)
120+
=> srcDirectory.GetFiles("*.schema.json", SearchOption.AllDirectories)
121+
.Select(schemaFile => schemaFile.DirectoryName)
122+
.Distinct()
123+
.Select(schemaDirectory => schemaDirectory.Replace(Path.DirectorySeparatorChar, '/'))
124+
.ToArray();
126125
}

0 commit comments

Comments
 (0)