fix: kits:install prompts if some configurations are missing - #11009
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the Firebase functions kit installation process to track and handle unconfigured instances on a per-project basis. It introduces getUnconfiguredInstancesForProject, updates isKitConfiguredForProject to ensure all instances are configured, and refactors prompting logic to restrict choices to unconfigured instances. The reviewer identified a critical issue in non-interactive mode where specifying an existing but unconfigured instanceId incorrectly defaults to adding a new instance instead of configuring the environment, which would cause a FirebaseError in CI/CD environments, and provided a code suggestion to resolve it.
…g and config checks - Routes options.instanceId in addKitInstanceOrConfigureProject to properly support configuring existing unconfigured instances or creating net-new instances non-interactively. - Renames isKitConfiguredForProject to isKitFullyConfiguredForProject, reuses getUnconfiguredInstancesForProject, and documents 0-instance behavior. - Derives isConfiguredForProject in memory from unconfiguredInstances to avoid redundant disk reads. - Clarifies error message when an instance ID does not exist in a kit. - Types unconfiguredInstanceIds as readonly string[]. - Fixes ExistingFunctionsInfo mock types to use arrays following #11008.
| projectId, | ||
| projectAlias, | ||
| ); | ||
| const isConfiguredForProject = |
There was a problem hiding this comment.
still think naming this like isFullyConfigured or something would better convey the intent (just now the var name instead of the function name)
Description
Updates function kit installation logic to properly handle and prompt for unconfigured instances when some configurations are missing for a project, rather than evaluating the entire kit as a whole.
getUnconfiguredInstancesForProjectto identify specific kit instances lacking a.envor configuration file for the current project.promptExistingInstanceForProjectandaddKitInstanceOrConfigureProjectto filter choices exclusively to unconfigured instances and handle interactive/non-interactive workflows appropriately.addKitInstanceOrConfigureProjectto properly routeoptions.instanceId:addEnv) without prompting.FirebaseError.addInstance) without prompting.FirebaseError.Scenarios Tested
instanceIdconfigures that instance directly without prompting or duplicate ID collision errors.instanceIdadds the instance directly without prompting.instanceIdbelongs to another kit or codebase.