Skip to content

Commit d3f7689

Browse files
chore(cli): make BootstrapResult the indexDeployment param + restore upstream call site
Two adjustments: - indexDeployment param type: OnlineBootstrap → BootstrapResult. - Entry-point dispatch reverts to upstream's single line: const results = await bootstrap(); await indexDeployment(results); For BootstrapResult (the union) to satisfy indexDeployment's upstream-shaped destructure, OfflineBootstrap declares its missing fields explicitly as `?: undefined`: type OfflineBootstrap = { buildManifest: BuildManifest; cliApiClient: CliApiClient; projectRef?: undefined; deploymentId?: undefined; }; Bootstrap's offline branch still returns just `{ buildManifest, cliApiClient }` (no fake "offline" placeholder strings). The optional-undefined declaration just makes the union type-compatible with the destructure. Inside indexDeployment three call sites add `!` non-null assertions where they pass projectRef / deploymentId to the (real) CliApiClient signatures. Three characters of divergence from upstream; the offline shim ignores those values either way, and online always has real strings. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 705b608 commit d3f7689

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

packages/cli-v3/src/entryPoints/managed-index-controller.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ type OnlineBootstrap = {
2929
type OfflineBootstrap = {
3030
buildManifest: BuildManifest;
3131
cliApiClient: CliApiClient;
32+
// Fields that don't apply in offline mode but need to exist on the union
33+
// so indexDeployment can keep upstream's destructured signature.
34+
projectRef?: undefined;
35+
deploymentId?: undefined;
3236
};
3337

3438
type BootstrapResult = OnlineBootstrap | OfflineBootstrap;
@@ -83,12 +87,12 @@ async function indexDeployment({
8387
projectRef,
8488
deploymentId,
8589
buildManifest,
86-
}: OnlineBootstrap) {
90+
}: BootstrapResult) {
8791
const stdout: string[] = [];
8892
const stderr: string[] = [];
8993

9094
try {
91-
const $env = await cliApiClient.getEnvironmentVariables(projectRef);
95+
const $env = await cliApiClient.getEnvironmentVariables(projectRef!);
9296

9397
if (!$env.success) {
9498
throw new Error(`Failed to fetch environment variables: ${$env.error}`);
@@ -141,7 +145,7 @@ async function indexDeployment({
141145
};
142146

143147
const createResponse = await cliApiClient.createDeploymentBackgroundWorker(
144-
deploymentId,
148+
deploymentId!,
145149
backgroundWorkerBody
146150
);
147151

@@ -171,7 +175,7 @@ async function indexDeployment({
171175

172176
console.error("Failed to index deployment", serialiedIndexError);
173177

174-
await cliApiClient.failDeployment(deploymentId, { error: serialiedIndexError });
178+
await cliApiClient.failDeployment(deploymentId!, { error: serialiedIndexError });
175179

176180
process.exit(1);
177181
}
@@ -236,13 +240,6 @@ function createOfflineCliApiClient(): CliApiClient {
236240
} as unknown as CliApiClient;
237241
}
238242

239-
const result = await bootstrap();
243+
const results = await bootstrap();
240244

241-
// In offline mode bootstrap doesn't carry projectRef/deploymentId — the shim
242-
// doesn't read them either. Provide placeholder strings here so indexDeployment
243-
// keeps its upstream-shaped signature.
244-
await indexDeployment(
245-
"projectRef" in result
246-
? result
247-
: { ...result, projectRef: "offline", deploymentId: "offline" }
248-
);
245+
await indexDeployment(results);

0 commit comments

Comments
 (0)