-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[FDC] Provide flutter as an option during init dataconnect
#9084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+53
−37
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
- `firebase emulator:start` use a default project if no project can be found. (#9072) | ||
- `firebase emulator:start` use a default project `demo-no-project` if no project can be found. (#9072) | ||
- `firebase init dataconnect` also supports bootstrapping flutter template. (#9084) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,10 +28,11 @@ | |
logLabeledWarning, | ||
logLabeledBullet, | ||
newUniqueId, | ||
commandExistsSync, | ||
} from "../../../utils"; | ||
import { DataConnectEmulator } from "../../../emulator/dataconnectEmulator"; | ||
import { getGlobalDefaultAccount } from "../../../auth"; | ||
import { createNextApp, createReactApp } from "./create_app"; | ||
import { createFlutterApp, createNextApp, createReactApp } from "./create_app"; | ||
import { trackGA4 } from "../../../track"; | ||
import { dirExistsSync, listFiles } from "../../../fsutils"; | ||
|
||
|
@@ -49,32 +50,39 @@ | |
displayIOSWarning: boolean; | ||
}; | ||
|
||
export async function askQuestions(setup: Setup): Promise<void> { | ||
const info: SdkRequiredInfo = { | ||
apps: [], | ||
}; | ||
|
||
info.apps = await chooseApp(); | ||
if (!info.apps.length) { | ||
// By default, create an React web app. | ||
const existingFilesAndDirs = listFiles(cwd); | ||
const webAppId = newUniqueId("web-app", existingFilesAndDirs); | ||
const npxMissingWarning = commandExistsSync("npx") | ||
? "" | ||
: clc.yellow(" (you need to install Node.js first)"); | ||
const flutterMissingWarning = commandExistsSync("flutter") | ||
? "" | ||
: clc.yellow(" (you need to install Flutter first)"); | ||
|
||
const choice = await select({ | ||
message: `Do you want to create an app template?`, | ||
choices: [ | ||
// TODO: Create template tailored to FDC. | ||
{ name: "React", value: "react" }, | ||
{ name: "Next.JS", value: "next" }, | ||
// TODO: Add flutter here. | ||
{ name: `React${npxMissingWarning}`, value: "react" }, | ||
{ name: `Next.JS${npxMissingWarning}`, value: "next" }, | ||
{ name: `Flutter${flutterMissingWarning}`, value: "flutter" }, | ||
{ name: "no", value: "no" }, | ||
], | ||
}); | ||
switch (choice) { | ||
case "react": | ||
await createReactApp(webAppId); | ||
await createReactApp(newUniqueId("web-app", listFiles(cwd))); | ||
break; | ||
case "next": | ||
await createNextApp(webAppId); | ||
await createNextApp(newUniqueId("web-app", listFiles(cwd))); | ||
break; | ||
case "flutter": | ||
await createFlutterApp(newUniqueId("flutter_app", listFiles(cwd))); | ||
break; | ||
case "no": | ||
break; | ||
|
@@ -141,7 +149,7 @@ | |
return apps; | ||
} | ||
|
||
export async function actuate(setup: Setup, config: Config) { | ||
Check warning on line 152 in src/init/features/dataconnect/sdk.ts
|
||
const fdcInfo = setup.featureInfo?.dataconnect; | ||
const sdkInfo = setup.featureInfo?.dataconnectSdk; | ||
if (!sdkInfo) { | ||
|
@@ -166,7 +174,7 @@ | |
} | ||
} | ||
|
||
async function actuateWithInfo(setup: Setup, config: Config, info: SdkRequiredInfo) { | ||
if (!info.apps.length) { | ||
// If no apps is specified, try to detect it again. | ||
// In `firebase init dataconnect:sdk`, customer may create the app while the command is running. | ||
|
@@ -241,7 +249,7 @@ | |
* and short-circuit the prompt. | ||
* | ||
* `FDC_CONNECTOR` should have the same `<location>/<serviceId>/<connectorId>`. | ||
* @param choices | ||
Check warning on line 252 in src/init/features/dataconnect/sdk.ts
|
||
*/ | ||
async function chooseExistingConnector(setup: Setup, config: Config): Promise<ConnectorInfo> { | ||
const serviceInfos = await loadAll(setup.projectId || "", config); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressing feedback from a different PR #9072 (comment)