publish.ps1 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. param(
  2. [switch]$SkipVerify
  3. )
  4. $ErrorActionPreference = "Stop"
  5. $Root = Resolve-Path (Join-Path $PSScriptRoot "..\..\..")
  6. $LocalEnvPath = Join-Path $PSScriptRoot ".env.local"
  7. if (Test-Path $LocalEnvPath) {
  8. Get-Content $LocalEnvPath | ForEach-Object {
  9. $line = $_.Trim()
  10. if (-not $line -or $line.StartsWith("#") -or -not $line.Contains("=")) {
  11. return
  12. }
  13. $parts = $line.Split("=", 2)
  14. $name = $parts[0].Trim()
  15. $value = $parts[1].Trim()
  16. if ($name -and -not [Environment]::GetEnvironmentVariable($name, "Process")) {
  17. [Environment]::SetEnvironmentVariable($name, $value, "Process")
  18. }
  19. }
  20. }
  21. Push-Location $Root
  22. try {
  23. if (-not $SkipVerify) {
  24. Write-Host "[verify] npm pack + install smoke + npx smoke" -ForegroundColor Cyan
  25. npm run claude-voc:npm-pack
  26. if ($LASTEXITCODE -ne 0) {
  27. throw "npm package verification failed."
  28. }
  29. }
  30. Write-Host "[auth] checking npm auth" -ForegroundColor Cyan
  31. cmd /c "npm whoami >nul 2>nul"
  32. if ($LASTEXITCODE -ne 0 -and -not $env:NPM_TOKEN -and -not $env:NODE_AUTH_TOKEN) {
  33. throw 'npm auth missing. Run npm login, or set NPM_TOKEN/NODE_AUTH_TOKEN and retry.'
  34. }
  35. Write-Host "[publish] npm publish" -ForegroundColor Cyan
  36. npm run claude-voc:npm-publish
  37. if ($LASTEXITCODE -ne 0) {
  38. throw "npm publish failed."
  39. }
  40. Write-Host "[done] published @vocmarket/voc-skill" -ForegroundColor Green
  41. }
  42. finally {
  43. Pop-Location
  44. }