(args: Record<string, unknown>)
| 291 | |
| 292 | // fallow-ignore-next-line complexity |
| 293 | function runDeploy(args: Record<string, unknown>): void { |
| 294 | const project = args.project as string | undefined; |
| 295 | if (!project) { |
| 296 | console.error("[cloudrun deploy] --project <gcp-project-id> is required."); |
| 297 | process.exit(1); |
| 298 | } |
| 299 | const region = (args.region as string | undefined) ?? "us-central1"; |
| 300 | const repo = (args.repo as string | undefined) ?? "hyperframes"; |
| 301 | const tfDir = terraformDir(); |
| 302 | const repoRoot = findRepoRoot(tfDir); |
| 303 | |
| 304 | console.log(`→ Enabling required APIs on ${project}`); |
| 305 | run("gcloud", [ |
| 306 | "services", |
| 307 | "enable", |
| 308 | "run.googleapis.com", |
| 309 | "workflows.googleapis.com", |
| 310 | "workflowexecutions.googleapis.com", |
| 311 | "artifactregistry.googleapis.com", |
| 312 | "cloudbuild.googleapis.com", |
| 313 | "monitoring.googleapis.com", |
| 314 | "--project", |
| 315 | project, |
| 316 | ]); |
| 317 | |
| 318 | let image = args.image as string | undefined; |
| 319 | if (!image) { |
| 320 | if (!repoRoot) { |
| 321 | console.error( |
| 322 | "[cloudrun deploy] --image is required when not running from a hyperframes checkout (no Dockerfile context found).", |
| 323 | ); |
| 324 | process.exit(1); |
| 325 | } |
| 326 | // Ensure the Artifact Registry repo exists. |
| 327 | const exists = |
| 328 | spawnSync("gcloud", [ |
| 329 | "artifacts", |
| 330 | "repositories", |
| 331 | "describe", |
| 332 | repo, |
| 333 | "--location", |
| 334 | region, |
| 335 | "--project", |
| 336 | project, |
| 337 | ]).status === 0; |
| 338 | if (!exists) { |
| 339 | run("gcloud", [ |
| 340 | "artifacts", |
| 341 | "repositories", |
| 342 | "create", |
| 343 | repo, |
| 344 | "--repository-format", |
| 345 | "docker", |
| 346 | "--location", |
| 347 | region, |
| 348 | "--project", |
| 349 | project, |
| 350 | ]); |
no test coverage detected