package_magnet_arc_v2.ps1 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. $ErrorActionPreference = 'Stop'
  2. Set-Location -LiteralPath $PSScriptRoot
  3. $safeDir = $PSScriptRoot.Replace('\', '/')
  4. $commit = git -c "safe.directory=$safeDir" rev-parse --short HEAD
  5. if ($LASTEXITCODE -ne 0) {
  6. throw 'No Git commit exists.'
  7. }
  8. $dirty = git -c "safe.directory=$safeDir" status --porcelain --untracked-files=no
  9. if ($dirty) {
  10. throw 'Tracked files have uncommitted changes. Commit before packaging.'
  11. }
  12. $sourceDir = Join-Path $PSScriptRoot 'dist\MotorCADParameterScanV2'
  13. $targetDir = Join-Path $PSScriptRoot 'dist\MotorCADMagnetArcScan'
  14. $sourceExe = Join-Path $sourceDir 'MotorCADParameterScanV2.exe'
  15. $targetExe = Join-Path $targetDir 'MotorCADMagnetArcScan.exe'
  16. if (-not (Test-Path -LiteralPath $sourceExe)) {
  17. throw "V2 executable not found: $sourceExe"
  18. }
  19. if (Test-Path -LiteralPath $targetDir) {
  20. throw "Target already exists: $targetDir"
  21. }
  22. Copy-Item -LiteralPath $sourceDir -Destination $targetDir -Recurse
  23. Rename-Item -LiteralPath (Join-Path $targetDir 'MotorCADParameterScanV2.exe') -NewName 'MotorCADMagnetArcScan.exe'
  24. Copy-Item -LiteralPath '.\scan_parameters_magnet_arc.json' -Destination (Join-Path $targetDir 'scan_parameters.json') -Force
  25. Write-Host "Git commit: $commit"
  26. Write-Host "Package complete: $targetExe"