Skip to content

Commit 6e92b40

Browse files
sshaderConvex, Inc.
authored and
Convex, Inc.
committed
Enable anonymous development (#36215)
The main change is having `shouldAllowAnonymousDevelopment` default to returning true! `CONVEX_ALLOW_ANONYMOUS=false` will function as an opt out (as will `npx convex dev --configure` since it'll ask you if you want to log in and create an account instead). Also updated some copy to say "project" instead of "deployment". GitOrigin-RevId: 9addd1796a3e5c18bd8902c9d75622a3dd0dd59a
1 parent 4e331c8 commit 6e92b40

File tree

4 files changed

+36
-27
lines changed

4 files changed

+36
-27
lines changed

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

+17-15
Original file line numberDiff line numberDiff line change
@@ -261,21 +261,23 @@ export async function _deploymentCredentialsOrConfigure(
261261
cmdOptions,
262262
);
263263
}
264-
const shouldPromptForLogin =
265-
deploymentSelection.deploymentName !== null
266-
? "no"
267-
: await promptOptions(ctx, {
268-
message:
269-
"Welcome to Convex! Would you like to login to your account?",
270-
choices: [
271-
{
272-
name: "Start without an account (run Convex locally)",
273-
value: "no",
274-
},
275-
{ name: "Login or create an account", value: "yes" },
276-
],
277-
default: "no",
278-
});
264+
const alreadyHasConfiguredAnonymousDeployment =
265+
deploymentSelection.deploymentName !== null &&
266+
chosenConfiguration === null;
267+
const shouldPromptForLogin = alreadyHasConfiguredAnonymousDeployment
268+
? "no"
269+
: await promptOptions(ctx, {
270+
message:
271+
"Welcome to Convex! Would you like to login to your account?",
272+
choices: [
273+
{
274+
name: "Start without an account (run Convex locally)",
275+
value: "no",
276+
},
277+
{ name: "Login or create an account", value: "yes" },
278+
],
279+
default: "no",
280+
});
279281
if (shouldPromptForLogin === "no") {
280282
const result = await handleAnonymousDeployment(ctx, {
281283
chosenConfiguration,

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ Same format as .env.local or .env files, and overrides them.`,
109109
"To deploy your Convex app to the cloud, log in by running `npx convex login`.\n" +
110110
"See https://docs.convex.dev/production for more information on how Convex cloud works and instructions on how to set up hosting.",
111111
);
112-
return;
112+
return await ctx.crash({
113+
exitCode: 1,
114+
errorType: "fatal",
115+
printedMessage: null,
116+
});
113117
}
114118

115119
if (deploymentSelection.kind === "preview") {

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ export const deploymentNameAndTypeFromSelection = (
620620
};
621621

622622
export const shouldAllowAnonymousDevelopment = (): boolean => {
623-
// Temporary flag while we build out this flow
624-
return process.env.CONVEX_ALLOW_ANONYMOUS !== undefined;
623+
// Kill switch / temporary opt out
624+
if (process.env.CONVEX_ALLOW_ANONYMOUS === "false") {
625+
return false;
626+
}
627+
return true;
625628
};

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ export async function handleAnonymousDeployment(
7373
if (deployment.kind === "first") {
7474
logMessage(
7575
ctx,
76-
"This command, `npx convex dev`, will run your deployment and update it with the function you write in the `convex/` directory.",
76+
"This command, `npx convex dev`, will run your Convex backend locally and update it with the function you write in the `convex/` directory.",
7777
);
7878
logMessage(
7979
ctx,
80-
"Use `npx convex dashboard` to view and interact with your deployment from a web UI.",
80+
"Use `npx convex dashboard` to view and interact with your project from a web UI.",
8181
);
8282
logMessage(
8383
ctx,
@@ -86,7 +86,7 @@ export async function handleAnonymousDeployment(
8686
ensureUuidForAnonymousUser(ctx);
8787
if (process.stdin.isTTY) {
8888
const result = await promptYesNo(ctx, {
89-
message: "Got it? Let's get started!",
89+
message: "Continue?",
9090
default: true,
9191
});
9292
if (!result) {
@@ -249,7 +249,7 @@ async function chooseDeployment(
249249
if (existing === undefined) {
250250
logWarning(
251251
ctx,
252-
`Could not find deployment with name ${options.deploymentName}!`,
252+
`Could not find project with name ${options.deploymentName}!`,
253253
);
254254
} else {
255255
return {
@@ -260,13 +260,13 @@ async function chooseDeployment(
260260
}
261261
}
262262
if (deployments.length === 0) {
263-
logMessage(ctx, "Let's set up your first deployment.");
263+
logMessage(ctx, "Let's set up your first project.");
264264
return await promptForNewDeployment(ctx, []);
265265
}
266266

267267
if (options.chosenConfiguration === "new") {
268268
const deploymentName = await promptString(ctx, {
269-
message: "Choose a name for your new deployment:",
269+
message: "Choose a name for your new project:",
270270
default: path.basename(process.cwd()),
271271
});
272272
const uniqueName = await getUniqueName(
@@ -282,7 +282,7 @@ async function chooseDeployment(
282282
}
283283

284284
const newOrExisting = await promptSearch(ctx, {
285-
message: "Which deployment would you like to use?",
285+
message: "Which project would you like to use?",
286286
choices: [
287287
...(options.chosenConfiguration === "existing"
288288
? []
@@ -307,7 +307,7 @@ async function chooseDeployment(
307307
return ctx.crash({
308308
exitCode: 1,
309309
errorType: "fatal",
310-
printedMessage: `Could not find deployment with name ${newOrExisting}!`,
310+
printedMessage: `Could not find project with name ${newOrExisting}!`,
311311
});
312312
}
313313
return {
@@ -381,7 +381,7 @@ async function getUniqueName(
381381
return ctx.crash({
382382
exitCode: 1,
383383
errorType: "fatal",
384-
printedMessage: `Could not generate a unique name for your deployment, please choose a different name`,
384+
printedMessage: `Could not generate a unique name for your project, please choose a different name`,
385385
});
386386
}
387387
/**

0 commit comments

Comments
 (0)