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
@@ -29,16 +32,45 @@ public static void Main(string[] args)
2932 Directory . Delete ( ArtifactsDir , true ) ;
3033 }
3134 } ) ;
32-
35+
3336 Target (
3437 GenerateDocumentation ,
35- ( ) => Run ( "dotnet" , "build docs/docs.csproj --verbosity normal" ) ) ;
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+ } ) ;
3668
3769 Target (
38- Build ,
70+ Build ,
3971 DependsOn ( GenerateDocumentation ) ,
4072 ( ) => Run (
41- "dotnet" ,
73+ "dotnet" ,
4274 $ "build src/SqlStreamStore.HAL.sln -c Release /p:BuildMetadata={ buildMetadata } ") ) ;
4375
4476 Target (
@@ -50,24 +82,25 @@ public static void Main(string[] args)
5082
5183 Target (
5284 Pack ,
53- DependsOn ( Build ) ,
85+ DependsOn ( Build ) ,
5486 ( ) => Run (
5587 "dotnet" ,
5688 $ "pack src/SqlStreamStore.HAL -c Release -o ../../{ ArtifactsDir } --no-build") ) ;
5789
5890 Target (
59- Publish ,
60- DependsOn ( Pack ) ,
61- ( ) => {
91+ Publish ,
92+ DependsOn ( Pack ) ,
93+ ( ) =>
94+ {
6295 var packagesToPush = Directory . GetFiles ( ArtifactsDir , "*.nupkg" , SearchOption . TopDirectoryOnly ) ;
6396 Console . WriteLine ( $ "Found packages to publish: { string . Join ( "; " , packagesToPush ) } ") ;
64-
97+
6598 if ( string . IsNullOrWhiteSpace ( apiKey ) )
6699 {
67100 Console . WriteLine ( "MyGet API key not available. Packages will not be pushed." ) ;
68101 return ;
69102 }
70-
103+
71104 foreach ( var packageToPush in packagesToPush )
72105 {
73106 Run (
@@ -83,15 +116,15 @@ public static void Main(string[] args)
83116
84117 private static string GetBranch ( )
85118 => ( Environment . GetEnvironmentVariable ( "TRAVIS_PULL_REQUEST" ) ? . ToLower ( ) == "false"
86- ? null
87- : $ "pr-{ Environment . GetEnvironmentVariable ( "TRAVIS_PULL_REQUEST" ) } ")
88- ?? Environment . GetEnvironmentVariable ( "TRAVIS_BRANCH" )
89- ?? "none" ;
119+ ? null
120+ : $ "pr-{ Environment . GetEnvironmentVariable ( "TRAVIS_PULL_REQUEST" ) } ")
121+ ?? Environment . GetEnvironmentVariable ( "TRAVIS_BRANCH" )
122+ ?? "none" ;
90123
91- private static string GetCommitHash ( )
124+ private static string GetCommitHash ( )
92125 => Environment . GetEnvironmentVariable ( "TRAVIS_PULL_REQUEST_SHA" )
93- ?? Environment . GetEnvironmentVariable ( "TRAVIS_COMMIT" )
94- ?? "none" ;
126+ ?? Environment . GetEnvironmentVariable ( "TRAVIS_COMMIT" )
127+ ?? "none" ;
95128
96129 private static string GetBuildNumber ( )
97130 => ( Environment . GetEnvironmentVariable ( "TRAVIS_BUILD_NUMBER" ) ?? "0" ) . PadLeft ( 5 , '0' ) ;
0 commit comments