@@ -9,6 +9,7 @@ class ImodSpecInfo {
9
9
[Boolean ]$IsObsolete
10
10
[Dependency []]$Dependencies
11
11
[string ]$ReleaseNotes
12
+ [string ]$Tags
12
13
13
14
ImodSpecInfo([string ]$filePath , [xml ]$content ) {
14
15
$this.FilePath = $filePath
@@ -21,6 +22,7 @@ class ImodSpecInfo {
21
22
$this.IsObsolete = $this.Description.ToLower ().Contains(" obsolete" )
22
23
$this.Dependencies = $content.package.dependencies.dependency | Where-Object { $null -ne $_.Id } | ForEach-Object { [Dependency ]::new($_.id , $_.version ) }
23
24
$this.ReleaseNotes = $content.package.releaseNotes
25
+ $this.Tags = $content.package.tags
24
26
}
25
27
}
26
28
@@ -73,7 +75,44 @@ class VersionInfo {
73
75
}
74
76
}
75
77
78
+ function PrintError {
79
+ param (
80
+ [string ]$Message ,
81
+ [Boolean ]$DevOps
82
+ )
83
+ if ($DevOps ) {
84
+ Write-Host " ##vso[task.logissue type=error;]$ ( $Message ) "
85
+ } else {
86
+ Write-Host " $ ( $Message ) " - ForegroundColor Red
87
+ }
88
+ }
89
+
90
+ function PrintWarning {
91
+ param (
92
+ [string ]$Message ,
93
+ [Boolean ]$DevOps
94
+ )
95
+ if ($DevOps ) {
96
+ Write-Host " ##vso[task.logissue type=warning;]$ ( $Message ) "
97
+ } else {
98
+ Write-Host " $ ( $Message ) " - ForegroundColor DarkYellow
99
+ }
100
+ }
101
+
102
+ function PrintAffectedFileName {
103
+ param (
104
+ [string ]$Name ,
105
+ [Boolean ]$DevOps
106
+ )
107
+ if ($DevOps ) {
108
+ Write-Host " ##[section]$ ( $Name ) "
109
+ } else {
110
+ Write-Host " # $ ( $Name ) " - ForegroundColor Green
111
+ }
112
+ }
113
+
76
114
$projectName = $args [0 ]
115
+ $DevOps = [bool ]$args [1 ]
77
116
$imodSpecInfos = New-Object ' System.Collections.Generic.Dictionary[string, ImodSpecInfo]'
78
117
$global :hasError = $false
79
118
@@ -89,7 +128,7 @@ Get-ChildItem -Path Modules -Filter *.imodspec -Recurse -Depth 2 | ForEach-Objec
89
128
90
129
$spec = [ImodSpecInfo ]::new($_.FullName , $content )
91
130
if ($imodSpecInfos.ContainsKey ($spec.Id )) {
92
- Write-Host " There is a duplicate Module Id found: $ ( $spec.Id ) "
131
+ PrintError " There is a duplicate Module Id found: $ ( $spec.Id ) " $DevOps
93
132
Write-Host " - $ ( $file ) "
94
133
Write-Host " - $ ( $imodSpecInfos [$spec.Id ].FilePath) "
95
134
$global :hasError = $true
@@ -164,20 +203,40 @@ $validationRules = @{
164
203
}
165
204
}
166
205
206
+ $validationWarnings = @ {
207
+ Tags = {
208
+ param ([ImodSpecInfo ]$info )
209
+ if (-not [System.String ]::IsNullOrWhiteSpace($info.Tags )) {
210
+ return " No tags specified"
211
+ }
212
+ }
213
+ }
214
+
167
215
foreach ($info in $imodSpecInfos.Values ) {
168
216
$reportedFileName = $false
169
217
170
- foreach ($rule in $validationRules.GetEnumerator ()) {
171
- $result = & $rule .Value $info
218
+ foreach ($validation in $validationRules.GetEnumerator ()) {
219
+ $result = & $validation .Value $info
172
220
if ($result ) {
173
221
if (-not $reportedFileName ) {
174
- Write-Host " # $ ( $info.FilePath ) "
222
+ PrintAffectedFileName " $ ( $info.FilePath ) " $DevOps
175
223
$reportedFileName = $true
176
224
}
177
- Write-Host " - $ ( $result ) "
225
+ PrintError " - $ ( $result ) " $DevOps
178
226
$global :hasError = $true
179
227
}
180
228
}
229
+
230
+ foreach ($validation in $validationWarnings.GetEnumerator ()) {
231
+ $result = & $validation.Value $info
232
+ if ($result ) {
233
+ if (-not $reportedFileName ) {
234
+ PrintAffectedFileName " $ ( $info.FilePath ) " $DevOps
235
+ $reportedFileName = $true
236
+ }
237
+ PrintWarning " - $ ( $result ) " $DevOps
238
+ }
239
+ }
181
240
}
182
241
183
242
if ($global :hasError ) {
0 commit comments