-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate-oledb-provider-info.ps1
55 lines (40 loc) · 2.06 KB
/
generate-oledb-provider-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
52
53
54
55
#requires -PSEdition Core
$destinationPath = ".\Docs\_data"
$destinationFile = "oledb.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.QA\bin"
Set-Location $assemblyPath
$dllfile = "net8.0\DubUrl.OleDb.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\net8.0\Antlr4.StringTemplate.dll"
Add-Type -Path "$directory\$dllfile"
Set-Location "..\..\"
Write-Host "Generating JSON for Oledb provider locators based on $assemblyPath\$directory\$dllfile"
$elapsed = Measure-Command -Expression {
$locator = New-Object DubUrl.OleDb.ProviderLocatorIntrospector
$providerLocators = $locator.Locate() | Sort-Object ListingPriority | Select-Object -Property @{label='Class'; expression={$_.ProviderLocatorType.Name}}, @{label='Database'; expression={$_.DatabaseName}}, Aliases, NamePattern, Slug, MainColor, SecondaryColor, @{label='Options'; expression={$_.Options.Name}}
Write-Host "`t$($providerLocators.Count) locators identified"
$providerLocators | ForEach-Object {Write-Host "`t`t$($_.Class)"}
$providerLocators | 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 OLE DB driver locators."
Exit 0
} else {
Write-Host "Changes detected in the list of OLE DB driver locators."
Exit 1
}
Remove-Type -Path "$directory\$dllfile"