Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add a confirmation in `firebase init dataconnect` before asking for app idea description. (#9282)
14 changes: 11 additions & 3 deletions src/init/features/dataconnect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
} from "../../../gemini/fdcExperience";
import { configstore } from "../../../configstore";
import { trackGA4 } from "../../../track";
import { cwd } from "process";

// Default GCP region for Data Connect
export const FDC_DEFAULT_REGION = "us-east4";
Expand Down Expand Up @@ -97,7 +98,7 @@

// askQuestions prompts the user about the Data Connect service they want to init. Any prompting
// logic should live here, and _no_ actuation logic should live here.
export async function askQuestions(setup: Setup): Promise<void> {

Check warning on line 101 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const info: RequiredInfo = {
analyticsFlow: "cli",
appDescription: "",
Expand All @@ -118,12 +119,19 @@
"Learn more about Gemini in Firebase and how it uses your data: https://firebase.google.com/docs/gemini-in-firebase#how-gemini-in-firebase-uses-your-data",
);
}
info.appDescription = await input({
message: `Describe your app to automatically generate a schema with Gemini [Enter to use a template]:`,
const wantToGenerate = await confirm({
message: "Do you want to generate schema and example queries with Gemini?",
default: false,
});
if (info.appDescription) {
if (wantToGenerate) {
configstore.set("gemini", true);
await ensureGIFApiTos(setup.projectId);
info.appDescription = await input({
message: `Describe your app ideas [leave blank to be creative]:`,
});
if (!info.appDescription) {
info.appDescription = `You are an expert of Firebase Data Connect. Let's create a creative, fun and inspiring example app for project ${setup.projectId} in this folder ${cwd()}.`;
}
}
}
if (hasBilling) {
Expand All @@ -140,10 +148,10 @@

// actuate writes product specific files and makes product specifc API calls.
// It does not handle writing firebase.json and .firebaserc
export async function actuate(setup: Setup, config: Config, options: any): Promise<void> {

Check warning on line 151 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 151 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
// Most users will want to persist data between emulator runs, so set this to a reasonable default.
const dir: string = config.get("dataconnect.source", "dataconnect");

Check warning on line 153 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
const dataDir = config.get("emulators.dataconnect.dataDir", `${dir}/.dataconnect/pgliteData`);

Check warning on line 154 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
config.set("emulators.dataconnect.dataDir", dataDir);

const info = setup.featureInfo?.dataconnect;
Expand Down Expand Up @@ -171,7 +179,7 @@
setup.instructions.push(
`You can visualize the Data Connect Schema in Firebase Console:

https://console.firebase.google.com/project/${setup.projectId!}/dataconnect/locations/${info.locationId}/services/${info.serviceId}/schema`,

Check warning on line 182 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Forbidden non-null assertion
);
}
if (!setup.isBillingEnabled) {
Expand All @@ -186,7 +194,7 @@
setup: Setup,
config: Config,
info: RequiredInfo,
options: any,

Check warning on line 197 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
): Promise<void> {
const projectId = setup.projectId;
if (!projectId) {
Expand Down Expand Up @@ -292,7 +300,7 @@
{ schemaGql: schemaFiles, connectors: connectors, seedDataGql: seedDataGql },
options,
);
} catch (err: any) {

Check warning on line 303 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
logLabeledError("dataconnect", `Operation Generation failed...`);
// GiF generate operation API has stability concerns.
// Fallback to save only the generated schema.
Expand Down Expand Up @@ -366,9 +374,9 @@
config: Config,
info: RequiredInfo,
serviceGql: ServiceGQL,
options: any,

Check warning on line 377 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
): Promise<void> {
const dir: string = config.get("dataconnect.source") || "dataconnect";

Check warning on line 379 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
const subbedDataconnectYaml = subDataconnectYamlValues({
...info,
connectorDirs: serviceGql.connectors.map((c) => c.path),
Expand Down
Loading