Skip to content

Commit 6d9f886

Browse files
ianmacartneyConvex, Inc.
authored andcommitted
Ian/fix existing codegen (#43587)
GitOrigin-RevId: 71aad18423ba2c95383c031a9d6138c3620fbfee
1 parent d6fe3c5 commit 6d9f886

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

npm-packages/convex/src/cli/configure.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
import { writeConvexUrlToEnvFile } from "./lib/envvars.js";
4242
import path from "path";
4343
import { projectDashboardUrl } from "./lib/dashboard.js";
44-
import { doCodegen, doCodegenForNewProject } from "./lib/codegen.js";
44+
import { doInitialCodegen } from "./lib/codegen.js";
4545
import { handleLocalDeployment } from "./lib/localDeployment/localDeployment.js";
4646
import {
4747
promptOptions,
@@ -587,7 +587,7 @@ async function selectNewProject(
587587
);
588588
}
589589

590-
await doCodegenForNewProject(ctx);
590+
await doInitialCodegen(ctx, { init: true });
591591
return { teamSlug, projectSlug, devDeployment };
592592
}
593593

@@ -641,13 +641,8 @@ async function selectExistingProject(
641641
});
642642

643643
showSpinner(`Reinitializing project ${projectSlug}...\n`);
644-
645-
const { projectConfig: existingProjectConfig } = await readProjectConfig(ctx);
646-
647-
const functionsPath = functionsDir(configName(), existingProjectConfig);
648-
649-
await doCodegen(ctx, functionsPath, "disable");
650-
644+
// TODO: Do we need to do codegen for existing projects? (-Ian)
645+
await doInitialCodegen(ctx, { init: false });
651646
logFinishedStep(`Reinitialized project ${chalk.bold(projectSlug)}`);
652647
return { teamSlug, projectSlug, devDeployment };
653648
}

npm-packages/convex/src/cli/lib/codegen.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,16 @@ export type CodegenOptions = {
6363
codegenOnlyThisComponent?: string | undefined;
6464
};
6565

66-
export async function doCodegenForNewProject(ctx: Context) {
66+
export async function doInitialCodegen(
67+
ctx: Context,
68+
options: { init: boolean },
69+
) {
6770
const { projectConfig: existingProjectConfig } = await readProjectConfig(ctx);
6871
const configPath = await configFilepath(ctx);
6972
const functionsPath = functionsDir(configPath, existingProjectConfig);
70-
await doInitCodegen(ctx, functionsPath, true);
73+
if (options.init) {
74+
await doInitCodegen(ctx, functionsPath, true);
75+
}
7176

7277
const componentDir = isComponentDirectory(ctx, functionsPath, true);
7378
if (componentDir.kind === "err") {

npm-packages/convex/src/cli/lib/localDeployment/anonymous.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { isAnonymousDeployment } from "../deployment.js";
4343
import { createProject } from "../api.js";
4444
import { removeAnonymousPrefix } from "../deployment.js";
4545
import { nodeFs } from "../../../bundler/fs.js";
46-
import { doCodegenForNewProject } from "../codegen.js";
46+
import { doInitialCodegen } from "../codegen.js";
4747

4848
export async function handleAnonymousDeployment(
4949
ctx: Context,
@@ -178,7 +178,7 @@ export async function handleAnonymousDeployment(
178178
});
179179

180180
if (deployment.kind === "new") {
181-
await doCodegenForNewProject(ctx);
181+
await doInitialCodegen(ctx, { init: true });
182182
}
183183
return {
184184
adminKey,

0 commit comments

Comments
 (0)