11using System ;
22using System . IO ;
3+ using System . Linq ;
4+ using System . Runtime . InteropServices ;
5+ using System . Threading . Tasks ;
36using static Bullseye . Targets ;
47using static SimpleExec . Command ;
58
@@ -8,6 +11,7 @@ static class Program
811 private const string ArtifactsDir = "artifacts" ;
912
1013 private const string Clean = nameof ( Clean ) ;
14+ private const string GenerateDocumentation = nameof ( GenerateDocumentation ) ;
1115 private const string Build = nameof ( Build ) ;
1216 private const string RunTests = nameof ( RunTests ) ;
1317 private const string Pack = nameof ( Pack ) ;
@@ -30,38 +34,73 @@ public static void Main(string[] args)
3034 } ) ;
3135
3236 Target (
33- Build ,
37+ GenerateDocumentation ,
38+ ( ) =>
39+ {
40+ var srcDirectory = new DirectoryInfo ( "./src" ) ;
41+
42+ var schemaFiles = srcDirectory . GetFiles ( "*.schema.json" , SearchOption . AllDirectories ) ;
43+
44+ var schemaDirectories = schemaFiles
45+ . Select ( schemaFile => schemaFile . DirectoryName )
46+ . Distinct ( )
47+ . Select ( schemaDirectory =>
48+ schemaDirectory . Replace ( Path . DirectorySeparatorChar ,
49+ '/' ) ) ; // normalize paths; yarn/node can handle forward slashes
50+
51+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
52+ {
53+ Run ( "cmd" , "/c yarn" , "docs" ) ;
54+ }
55+ else
56+ {
57+ Run ( "yarn" , string . Empty , "docs" ) ;
58+ }
59+
60+ foreach ( var schemaDirectory in schemaDirectories )
61+ {
62+ Run (
63+ "node" ,
64+ $ "node_modules/@adobe/jsonschema2md/cli.js -n --input { schemaDirectory } --out { schemaDirectory } --schema-out=-",
65+ "docs" ) ;
66+ }
67+ } ) ;
68+
69+ Target (
70+ Build ,
71+ DependsOn ( GenerateDocumentation ) ,
3472 ( ) => Run (
35- "dotnet" ,
73+ "dotnet" ,
3674 $ "build src/SqlStreamStore.HAL.sln -c Release /p:BuildMetadata={ buildMetadata } ") ) ;
3775
3876 Target (
3977 RunTests ,
4078 DependsOn ( Build ) ,
4179 ( ) => Run (
4280 "dotnet" ,
43- $ "test src/SqlStreamStore.HAL.Tests -c Release -r ../../{ ArtifactsDir } --no-build -l trx;LogFileName=SqlStreamStore.HAL.Tests.xml") ) ;
81+ $ "test src/SqlStreamStore.HAL.Tests -c Release -r ../../{ ArtifactsDir } --verbosity normal -- no-build -l trx;LogFileName=SqlStreamStore.HAL.Tests.xml") ) ;
4482
4583 Target (
4684 Pack ,
47- DependsOn ( Build ) ,
85+ DependsOn ( Build ) ,
4886 ( ) => Run (
4987 "dotnet" ,
5088 $ "pack src/SqlStreamStore.HAL -c Release -o ../../{ ArtifactsDir } --no-build") ) ;
5189
5290 Target (
53- Publish ,
54- DependsOn ( Pack ) ,
55- ( ) => {
91+ Publish ,
92+ DependsOn ( Pack ) ,
93+ ( ) =>
94+ {
5695 var packagesToPush = Directory . GetFiles ( ArtifactsDir , "*.nupkg" , SearchOption . TopDirectoryOnly ) ;
5796 Console . WriteLine ( $ "Found packages to publish: { string . Join ( "; " , packagesToPush ) } ") ;
58-
97+
5998 if ( string . IsNullOrWhiteSpace ( apiKey ) )
6099 {
61100 Console . WriteLine ( "MyGet API key not available. Packages will not be pushed." ) ;
62101 return ;
63102 }
64-
103+
65104 foreach ( var packageToPush in packagesToPush )
66105 {
67106 Run (
@@ -77,15 +116,15 @@ public static void Main(string[] args)
77116
78117 private static string GetBranch ( )
79118 => ( Environment . GetEnvironmentVariable ( "TRAVIS_PULL_REQUEST" ) ? . ToLower ( ) == "false"
80- ? null
81- : $ "pr-{ Environment . GetEnvironmentVariable ( "TRAVIS_PULL_REQUEST" ) } ")
82- ?? Environment . GetEnvironmentVariable ( "TRAVIS_BRANCH" )
83- ?? "none" ;
119+ ? null
120+ : $ "pr-{ Environment . GetEnvironmentVariable ( "TRAVIS_PULL_REQUEST" ) } ")
121+ ?? Environment . GetEnvironmentVariable ( "TRAVIS_BRANCH" )
122+ ?? "none" ;
84123
85- private static string GetCommitHash ( )
124+ private static string GetCommitHash ( )
86125 => Environment . GetEnvironmentVariable ( "TRAVIS_PULL_REQUEST_SHA" )
87- ?? Environment . GetEnvironmentVariable ( "TRAVIS_COMMIT" )
88- ?? "none" ;
126+ ?? Environment . GetEnvironmentVariable ( "TRAVIS_COMMIT" )
127+ ?? "none" ;
89128
90129 private static string GetBuildNumber ( )
91130 => ( Environment . GetEnvironmentVariable ( "TRAVIS_BUILD_NUMBER" ) ?? "0" ) . PadLeft ( 5 , '0' ) ;
0 commit comments