Allow apphosting:backend:create to work with source deploy backends#10094
Allow apphosting:backend:create to work with source deploy backends#10094
Conversation
…s well. The current flow frustratingly forces you to set up Github connections.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable improvement by allowing apphosting:backend:create to support source-based deployments, removing the previous requirement to connect a GitHub repository. The changes are logical and well-implemented. The accompanying tests have been updated to cover both the new source deployment flow and the existing GitHub flow, ensuring good test coverage. I have one minor suggestion to remove a redundant log message to improve the command's output clarity for users.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request extends the apphosting:backend:create command to support creating backends for local source deployments, in addition to the existing GitHub-based deployments. This is a great improvement for user experience. The changes involve adding a prompt to select the deployment method and adjusting the logic accordingly. New tests have been added to cover these new code paths.
I have a couple of points of feedback regarding the user interaction flow and a potentially unused variable for source deployments. Please see my detailed comments.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a choice between 'GitHub' and 'Local Source' deployment methods in the doSetup function for App Hosting. It updates the setup flow to conditionally prompt for repository details only when the GitHub method is selected and adjusts the post-creation logic to skip traffic policy configuration for local source deployments. A suggestion was made to extract the GitHub-specific setup logic into a helper function to reduce nesting and improve readability, adhering to the repository's style guide.
| if (deployMethod === "github") { | ||
| if (!rootDir) { | ||
| rootDir = await input({ | ||
| default: "/", | ||
| message: "Specify your app's root directory relative to your repository", | ||
| }); | ||
| } | ||
|
|
||
| gitRepositoryLink = await githubConnections.linkGitHubRepository(projectId, location); | ||
| // TODO: Once tag patterns are implemented, prompt which method the user | ||
| // prefers. We could reduce the number of questions asked by letting people | ||
| // enter tag:<pattern>? | ||
| branch = await githubConnections.promptGitHubBranch(gitRepositoryLink); | ||
| logSuccess(`Repo linked successfully!\n`); | ||
| } |
There was a problem hiding this comment.
To improve readability and reduce nesting in the doSetup function, consider extracting the GitHub setup logic into a new helper function. This aligns with the style guide's recommendation to "Reduce nesting as much as possible" (line 33).
You could define a new helper function like this:
async function setupGithubDeployment(
projectId: string,
location: string,
currentRootDir: string | undefined,
): Promise<{
rootDir: string;
gitRepositoryLink: GitRepositoryLink;
branch: string;
}> {
let rootDir = currentRootDir;
if (!rootDir) {
rootDir = await input({
default: "/",
message: "Specify your app's root directory relative to your repository",
});
}
const gitRepositoryLink = await githubConnections.linkGitHubRepository(projectId, location);
const branch = await githubConnections.promptGitHubBranch(gitRepositoryLink);
logSuccess(`Repo linked successfully!\n`);
return { rootDir: rootDir!, gitRepositoryLink, branch };
}And then call it from doSetup.
if (deployMethod === "github") {
const githubSettings = await setupGithubDeployment(projectId, location, rootDir);
rootDir = githubSettings.rootDir;
gitRepositoryLink = githubSettings.gitRepositoryLink;
branch = githubSettings.branch;
}References
- The style guide recommends reducing code nesting as much as possible to improve readability and maintainability. Extracting this block of logic into a helper function would follow this best practice. (link)
The current flow frustratingly forces you to set up Github connections.
Description
This just allows the interactive flow for backends:create to be able to skip Github connections. This is already possible with firebase init and the non-interactive mode of backend:create.
Scenarios Tested
Interactive flow:
Sample Commands
firebase apphosting:backend:create