mastra
Version:
cli for mastra
78 lines • 3.89 kB
TypeScript
export type PreflightIssueCode = 'MISSING_ENV_VAR' | 'LOCAL_STORAGE_PATH';
export interface PreflightIssue {
code: PreflightIssueCode;
severity: 'error' | 'warning';
message: string;
fix: string;
}
/**
* Inspect a built `.mastra/output` directory plus the env vars about to be
* uploaded and return a list of issues that are likely to cause the deploy
* to fail with a USER-attributable error.
*
* Returns an empty array when no build output is found — the caller is
* responsible for surfacing the missing-output error.
*/
export declare function preflightBuildOutput(targetDir: string, envVars: Record<string, string>, options?: {
/**
* Whether the CLI has the full env picture for this deploy (an explicit
* `--env-file` or an ambient `.env*` file). When false, env vars may be
* stored on the platform and invisible to the CLI, so env-guarded local
* paths are surfaced as warnings instead of errors. Defaults to true.
*/
hasEnvFile?: boolean;
/**
* Env var names the platform injects at deploy time (e.g. TURSO_DATABASE_URL
* from an attached managed database) — names only, values are platform-side
* secrets. Three states:
* - `string[]` — platform env context fetched and the field was present:
* the env picture is complete, so guarded local paths whose var is
* neither provided nor managed are trustworthy hard errors.
* - `null` — platform env context fetched but the field was absent (older
* platform, or an endpoint that doesn't expose names): the picture is
* incomplete, so guarded misses soften to warnings.
* - `undefined` — no platform context at all (lint, studio deploy):
* severity falls back to `hasEnvFile`.
*/
managedEnvVarNames?: string[] | null;
}): Promise<PreflightIssue[]>;
/**
* Mirror the platform's deploy-time env merge: local/request env vars are
* applied over the vars already stored on the target environment or server
* project (request wins). Preflight should see this merged picture so vars
* stored only on the platform don't produce false MISSING_ENV_VAR /
* LOCAL_STORAGE_PATH alarms.
*/
export declare function mergePreflightEnvVars(stored: Record<string, string> | null | undefined, local: Record<string, string>): Record<string, string>;
export type PreflightOutcome = 'ok' | 'blocked' | 'cancelled';
/**
* Print preflight issues and decide whether the deploy should proceed.
*
* Returns:
* - `'ok'` — no issues, or warnings the caller has accepted.
* - `'blocked'`— at least one error-severity issue. Errors always block,
* regardless of `autoAccept` / headless mode. Caller should
* exit non-zero so CI surfaces the failure.
* - `'cancelled'` — warnings only, but the user explicitly declined the
* confirmation prompt. Caller should exit zero (normal
* user-initiated cancel).
*
* `--skip-preflight` is the escape hatch when a check is a false positive.
*/
export declare function printPreflightIssues(issues: PreflightIssue[], options: {
autoAccept: boolean;
}): Promise<PreflightOutcome>;
/**
* Check detections written by the `mastra-local-storage-detector` Rollup
* plugin. Prefers the unified metadata (which carries `guardedBy` env
* context); falls back to the legacy `preflight-local-paths.json`. If both
* are absent (e.g. older build, or the plugin wasn't active) the check is
* silently skipped — no false positives.
*/
/**
* The exact command that unblocks a missing database env var. Kind-specific
* when the guarded var maps to a known provider (issue 35-B: the remediation
* previously said "attach a managed database" without ever naming the command).
*/
export declare function dbCreateCommandFor(envVarName: string): string;
//# sourceMappingURL=deploy-preflight.d.ts.map