-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-adomd-info.ps1
51 lines (38 loc) · 1.86 KB
/
generate-adomd-info.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#requires -PSEdition Core
$destinationPath = ".\Docs\_data"
$destinationFile = "adomd.json"
########### Check if it's useful to make changes to doc or readme #############
Set-Location ./
$hash = 0
If(Test-Path -LiteralPath $destinationPath\$destinationFile -PathType leaf) {
$hash = Get-FileHash $destinationPath\$destinationFile
Write-Debug "Previous hash for $destinationPath\$destinationFile is $($hash.Hash)"
}
########### Generate JSON file #############
$assemblyPath = "DubUrl.Adomd\bin"
Set-Location $assemblyPath
$dllfile = "net6.0\DubUrl.Adomd.dll"
If ((-not (Test-Path -Path "Release\$dllfile")) -or ("Release\$dllfile".CreationTime -lt "Debug\$dllfile".CreationTime)) {
$directory = "Debug"
} else {
$directory = "Release"
}
Add-Type -Path "$directory\$dllfile"
Set-Location "..\..\"
Write-Host "Generating JSON for ADOMD.NET data providers based on $assemblyPath\$directory\$dllfile"
$elapsed = Measure-Command -Expression {
$introspector = New-Object DubUrl.Adomd.Mapping.AdomdMapperIntrospector
$mappers = $introspector.Locate() | Sort-Object ListingPriority | Select-Object -Property @{label='Class'; expression={$_.MapperType.Name}}, @{label='Database'; expression={$_.DatabaseName}}, Aliases, ProviderInvariantName, Slug, MainColor, SecondaryColor
Write-Host "`t$($mappers.Count) mappers identified"
$mappers | ForEach-Object {Write-Host "`t`t$($_.Class)"}
$mappers | ConvertTo-Json | Out-File "$destinationPath\$destinationFile"
}
Write-Host "File created at $destinationPath\$destinationFile in $($elapsed.TotalSeconds) seconds"
########### Check if it's useful to report a change #############
If ($hash.Hash -eq (Get-FileHash $destinationPath\$destinationFile).Hash) {
Write-Host "No change detected in the list of providers."
Exit 0
} else {
Write-Host "Changes detected in the list of providers."
Exit 1
}