1
1
using System ;
2
2
using System . IO ;
3
+ using System . Linq ;
4
+ using System . Runtime . InteropServices ;
5
+ using System . Threading . Tasks ;
3
6
using static Bullseye . Targets ;
4
7
using static SimpleExec . Command ;
5
8
@@ -29,16 +32,45 @@ public static void Main(string[] args)
29
32
Directory . Delete ( ArtifactsDir , true ) ;
30
33
}
31
34
} ) ;
32
-
35
+
33
36
Target (
34
37
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
+ } ) ;
36
68
37
69
Target (
38
- Build ,
70
+ Build ,
39
71
DependsOn ( GenerateDocumentation ) ,
40
72
( ) => Run (
41
- "dotnet" ,
73
+ "dotnet" ,
42
74
$ "build src/SqlStreamStore.HAL.sln -c Release /p:BuildMetadata={ buildMetadata } ") ) ;
43
75
44
76
Target (
@@ -50,24 +82,25 @@ public static void Main(string[] args)
50
82
51
83
Target (
52
84
Pack ,
53
- DependsOn ( Build ) ,
85
+ DependsOn ( Build ) ,
54
86
( ) => Run (
55
87
"dotnet" ,
56
88
$ "pack src/SqlStreamStore.HAL -c Release -o ../../{ ArtifactsDir } --no-build") ) ;
57
89
58
90
Target (
59
- Publish ,
60
- DependsOn ( Pack ) ,
61
- ( ) => {
91
+ Publish ,
92
+ DependsOn ( Pack ) ,
93
+ ( ) =>
94
+ {
62
95
var packagesToPush = Directory . GetFiles ( ArtifactsDir , "*.nupkg" , SearchOption . TopDirectoryOnly ) ;
63
96
Console . WriteLine ( $ "Found packages to publish: { string . Join ( "; " , packagesToPush ) } ") ;
64
-
97
+
65
98
if ( string . IsNullOrWhiteSpace ( apiKey ) )
66
99
{
67
100
Console . WriteLine ( "MyGet API key not available. Packages will not be pushed." ) ;
68
101
return ;
69
102
}
70
-
103
+
71
104
foreach ( var packageToPush in packagesToPush )
72
105
{
73
106
Run (
@@ -83,15 +116,15 @@ public static void Main(string[] args)
83
116
84
117
private static string GetBranch ( )
85
118
=> ( 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" ;
90
123
91
- private static string GetCommitHash ( )
124
+ private static string GetCommitHash ( )
92
125
=> Environment . GetEnvironmentVariable ( "TRAVIS_PULL_REQUEST_SHA" )
93
- ?? Environment . GetEnvironmentVariable ( "TRAVIS_COMMIT" )
94
- ?? "none" ;
126
+ ?? Environment . GetEnvironmentVariable ( "TRAVIS_COMMIT" )
127
+ ?? "none" ;
95
128
96
129
private static string GetBuildNumber ( )
97
130
=> ( Environment . GetEnvironmentVariable ( "TRAVIS_BUILD_NUMBER" ) ?? "0" ) . PadLeft ( 5 , '0' ) ;
0 commit comments