Skip to content

Commit d64023c

Browse files
tammam-gjoehan
andauthored
Fix second init on spark account not allowing choosing a sql instance (#9504)
* Starting to make billing optional * Finish removing billing requirements * Fixing tests * Clean up * Format * One more usage of removed variable * Improve gating for when to indicate a free trial is avaialbe + format fixes * Fix inversed if statement * improves when messages show about free trial availability * Use expirement flag and make flow identical when flag is disabled * fix formatting * fix tests * cleanup * Fix tests * format fix * Fix init flow to allow choosing a free instance on repeated inits on spark accounts --------- Co-authored-by: Joe Hanley <[email protected]>
1 parent e8cd1ba commit d64023c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/init/features/dataconnect/index.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -703,12 +703,6 @@ async function promptForCloudSQL(setup: Setup, info: RequiredInfo): Promise<void
703703
"dataconnect",
704704
"CloudSQL no cost trial has already been used on this project.",
705705
);
706-
if (!billingEnabled) {
707-
setup.instructions.push(
708-
upgradeInstructions(setup.projectId || "your-firebase-project", true),
709-
);
710-
return;
711-
}
712706
} else if (instrumentlessTrialEnabled || billingEnabled) {
713707
logLabeledSuccess("dataconnect", "CloudSQL no cost trial available!");
714708
}
@@ -729,7 +723,11 @@ async function promptForCloudSQL(setup: Setup, info: RequiredInfo): Promise<void
729723
if (freeTrialAvailable) {
730724
choices.push({ name: "Create a new free trial instance", value: "", location: "" });
731725
} else {
732-
choices.push({ name: "Create a new CloudSQL instance", value: "", location: "" });
726+
choices.push({
727+
name: `Create a new CloudSQL instance${billingEnabled ? "" : " (requires billing account)"}`,
728+
value: "",
729+
location: "",
730+
});
733731
}
734732
info.cloudSqlInstanceId = await select<string>({
735733
message: `Which CloudSQL instance would you like to use?`,
@@ -741,6 +739,12 @@ async function promptForCloudSQL(setup: Setup, info: RequiredInfo): Promise<void
741739
info.locationId = choices.find((c) => c.value === info.cloudSqlInstanceId)!.location;
742740
} else {
743741
info.flow += "_pick_new_csql";
742+
if (!billingEnabled && freeTrialUsed) {
743+
setup.instructions.push(
744+
upgradeInstructions(setup.projectId || "your-firebase-project", true),
745+
);
746+
return;
747+
}
744748
info.cloudSqlInstanceId = await input({
745749
message: `What ID would you like to use for your new CloudSQL instance?`,
746750
default: newUniqueId(

0 commit comments

Comments
 (0)