Add shared ERP sync core and Optima adapter
This commit is contained in:
69
publish-enova.ps1
Normal file
69
publish-enova.ps1
Normal file
@@ -0,0 +1,69 @@
|
||||
param(
|
||||
[string]$OutputPath = (Join-Path $PSScriptRoot "release-enova"),
|
||||
[ValidateSet("Debug", "Release")]
|
||||
[string]$Configuration = "Release"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$env:DOTNET_CLI_HOME = $PSScriptRoot
|
||||
$env:APPDATA = $PSScriptRoot
|
||||
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = "1"
|
||||
$env:DOTNET_CLI_TELEMETRY_OPTOUT = "1"
|
||||
|
||||
$dotnet = (Get-Command dotnet -ErrorAction Stop).Source
|
||||
$project = Join-Path $PSScriptRoot "src\SmartB2B.Enova.Service\SmartB2B.Enova.Service.csproj"
|
||||
$adapterProject = Join-Path $PSScriptRoot "src\SmartB2B.Enova.Adapter\SmartB2B.Enova.Adapter.csproj"
|
||||
$daemonSource = Join-Path $PSScriptRoot "daemon-enova"
|
||||
$winSwSource = Resolve-Path (Join-Path $daemonSource "smartb2bsync-enova.exe")
|
||||
$output = [System.IO.Path]::GetFullPath($OutputPath)
|
||||
$workspace = [System.IO.Path]::GetFullPath($PSScriptRoot)
|
||||
$daemonOutput = Join-Path $output "daemon"
|
||||
|
||||
if (-not $output.StartsWith($workspace, [StringComparison]::OrdinalIgnoreCase) -or
|
||||
$output -eq $workspace -or
|
||||
$output.Length -lt 10) {
|
||||
throw "Niebezpieczna ścieżka wyjściowa: $output"
|
||||
}
|
||||
|
||||
if (Test-Path -LiteralPath $output) {
|
||||
Remove-Item -LiteralPath $output -Recurse -Force
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $output | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path $daemonOutput | Out-Null
|
||||
|
||||
& $dotnet restore $adapterProject
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Przywracanie pakietów adaptera Enovy nie powiodło się."
|
||||
}
|
||||
|
||||
& $dotnet publish $project -c $Configuration -o $output
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Publikowanie usługi nie powiodło się."
|
||||
}
|
||||
|
||||
Copy-Item $winSwSource (Join-Path $daemonOutput "smartb2bsync-enova.exe") -Force
|
||||
Copy-Item (Join-Path $daemonSource "smartb2bsync-enova.xml") $daemonOutput -Force
|
||||
Copy-Item (Join-Path $daemonSource "install.cmd") $daemonOutput -Force
|
||||
Copy-Item (Join-Path $daemonSource "uninstall.cmd") $daemonOutput -Force
|
||||
|
||||
$downloadBaseUrl = "https://demo.smartb2b.eu/files/smartb2b-sync-enova/"
|
||||
[xml]$manifest = Get-Content -Raw (Join-Path $daemonOutput "smartb2bsync-enova.xml")
|
||||
$downloadedFiles = @(
|
||||
$manifest.service.download |
|
||||
ForEach-Object { $_.from.Substring($downloadBaseUrl.Length).Replace('/', '\') } |
|
||||
Sort-Object
|
||||
)
|
||||
$packagedFiles = @(
|
||||
Get-ChildItem -Recurse -File $output |
|
||||
ForEach-Object { $_.FullName.Substring($output.Length).TrimStart('\') } |
|
||||
Where-Object { $_ -ne "daemon\smartb2bsync-enova.exe" } |
|
||||
Sort-Object
|
||||
)
|
||||
$manifestDifferences = @(Compare-Object $packagedFiles $downloadedFiles)
|
||||
if ($manifestDifferences.Count -ne 0) {
|
||||
$details = $manifestDifferences | ForEach-Object { "$($_.SideIndicator) $($_.InputObject)" }
|
||||
throw "Lista plików <download> nie odpowiada paczce:`n$($details -join "`n")"
|
||||
}
|
||||
|
||||
Write-Host "Gotowa usługa: $output"
|
||||
Reference in New Issue
Block a user