diff --git a/src/commands/deployments/deploy.ts b/src/commands/deployments/deploy.ts index 150d38b..648511b 100644 --- a/src/commands/deployments/deploy.ts +++ b/src/commands/deployments/deploy.ts @@ -8,7 +8,7 @@ import { getProjectConfig } from '../../lib/config.js'; import { requireAuth } from '../../lib/credentials.js'; import { handleError, getRootOpts, CLIError, ProjectNotLinkedError } from '../../lib/errors.js'; import { outputJson } from '../../lib/output.js'; -import type { CreateDeploymentResponse, StartDeploymentRequest, SiteDeployment } from '../../types.js'; +import type { CreateDeploymentResponse, StartDeploymentRequest, DeploymentSchema } from '../../types.js'; import { reportCliUsage } from '../../lib/skills.js'; const POLL_INTERVAL_MS = 5_000; @@ -68,7 +68,7 @@ export interface DeployProjectOptions { export interface DeployProjectResult { deploymentId: string; - deployment: SiteDeployment | null; + deployment: DeploymentSchema | null; isReady: boolean; liveUrl: string | null; } @@ -119,20 +119,21 @@ export async function deployProject(opts: DeployProjectOptions): Promise setTimeout(r, POLL_INTERVAL_MS)); try { const statusRes = await ossFetch(`/api/deployments/${deploymentId}`); - deployment = (await statusRes.json()) as SiteDeployment; + deployment = (await statusRes.json()) as DeploymentSchema; - if (deployment.status === 'ready' || deployment.status === 'READY') { + if (deployment.status === 'READY') { break; } - if (deployment.status === 'error' || deployment.status === 'ERROR' || deployment.status === 'canceled') { + if (deployment.status === 'ERROR' || deployment.status === 'CANCELED') { s?.stop('Deployment failed'); - throw new CLIError(deployment.error ?? `Deployment failed with status: ${deployment.status}`); + const errorMsg = (deployment.metadata as Record | null)?.error as { errorMessage?: string } | undefined; + throw new CLIError(errorMsg?.errorMessage ?? `Deployment failed with status: ${deployment.status}`); } const elapsed = Math.round((Date.now() - startTime) / 1000); @@ -143,8 +144,8 @@ export async function deployProject(opts: DeployProjectOptions): Promise | null)?.error ? [['Error', ((d.metadata as Record).error as { errorMessage?: string })?.errorMessage ?? 'Unknown error']] : []), ], ); } diff --git a/src/types.ts b/src/types.ts index f5e6d12..ed468be 100644 --- a/src/types.ts +++ b/src/types.ts @@ -107,7 +107,8 @@ export interface ApiError { export type { ListFunctionsResponse, StorageBucketSchema, ListDeploymentsResponse, DatabaseFunctionsResponse, DatabaseIndexesResponse, DatabasePoliciesResponse, DatabaseTriggersResponse, CreateScheduleResponse, ListSchedulesResponse, GetScheduleResponse, ListExecutionLogsResponse, - ListSecretsResponse, GetSecretValueResponse, CreateSecretResponse, DeleteSecretResponse, UpdateSecretResponse + ListSecretsResponse, GetSecretValueResponse, CreateSecretResponse, DeleteSecretResponse, UpdateSecretResponse, + CreateDeploymentResponse, StartDeploymentRequest, DeploymentSchema } from '@insforge/shared-schemas'; // Function deploy/update response types @@ -138,41 +139,9 @@ export interface FunctionResponse { // Deployment types (OSS - Vercel deployment) -export interface CreateDeploymentResponse { - id: string; - uploadUrl: string; - uploadFields: Record; -} - -export interface SiteDeployment { - id: string; - status: string; - provider: string; - providerDeploymentId: string | null; - // API returns "url"; some endpoints may use "deploymentUrl" - url: string | null; - deploymentUrl?: string | null; - error: string | null; - metadata: Record | null; - createdAt: string; - updatedAt: string; -} - export interface DeploymentMetadata { currentDeploymentId: string | null; domain: string | null; slug: string | null; deploymentUrl: string | null; } - -export interface StartDeploymentRequest { - projectSettings?: { - buildCommand?: string | null; - outputDirectory?: string | null; - installCommand?: string | null; - devCommand?: string | null; - rootDirectory?: string | null; - }; - envVars?: { key: string; value: string }[]; - meta?: Record; -}