firebase-tools-with-isolate 13.29.1 → 14.10.1-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -4
- package/lib/api.js +10 -2
- package/lib/appdistribution/client.js +2 -2
- package/lib/apphosting/backend.js +157 -55
- package/lib/apphosting/config.js +121 -101
- package/lib/apphosting/githubConnections.js +65 -100
- package/lib/apphosting/repo.js +22 -36
- package/lib/apphosting/rollout.js +5 -11
- package/lib/apphosting/secrets/dialogs.js +13 -11
- package/lib/apphosting/secrets/index.js +47 -5
- package/lib/apphosting/utils.js +1 -3
- package/lib/apphosting/yaml.js +35 -49
- package/lib/auth.js +23 -6
- package/lib/bin/cli.js +99 -0
- package/lib/bin/firebase.js +7 -123
- package/lib/bin/mcp.js +49 -0
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +3 -2
- package/lib/commands/appdistribution-distribute.js +1 -1
- package/lib/commands/appdistribution-groups-create.js +1 -1
- package/lib/commands/appdistribution-groups-delete.js +1 -1
- package/lib/commands/appdistribution-groups-list.js +2 -2
- package/lib/commands/appdistribution-testers-add.js +1 -1
- package/lib/commands/appdistribution-testers-list.js +3 -3
- package/lib/commands/appdistribution-testers-remove.js +1 -1
- package/lib/commands/apphosting-backends-create.js +3 -3
- package/lib/commands/apphosting-backends-delete.js +23 -27
- package/lib/commands/apphosting-backends-get.js +12 -12
- package/lib/commands/apphosting-backends-list.js +5 -5
- package/lib/commands/apphosting-builds-create.js +8 -2
- package/lib/commands/apphosting-builds-get.js +8 -1
- package/lib/commands/apphosting-rollouts-create.js +3 -3
- package/lib/commands/apphosting-rollouts-list.js +8 -2
- package/lib/commands/apphosting-secrets-access.js +1 -1
- package/lib/commands/apphosting-secrets-describe.js +2 -2
- package/lib/commands/apphosting-secrets-grantaccess.js +20 -10
- package/lib/commands/apphosting-secrets-set.js +27 -1
- package/lib/commands/apps-android-sha-create.js +1 -1
- package/lib/commands/apps-android-sha-delete.js +1 -1
- package/lib/commands/apps-android-sha-list.js +2 -2
- package/lib/commands/apps-create.js +4 -108
- package/lib/commands/apps-init.js +94 -0
- package/lib/commands/apps-list.js +1 -1
- package/lib/commands/apps-sdkconfig.js +5 -10
- package/lib/commands/auth-export.js +1 -1
- package/lib/commands/auth-import.js +1 -1
- package/lib/commands/database-import.js +4 -6
- package/lib/commands/database-instances-create.js +1 -1
- package/lib/commands/database-instances-list.js +1 -1
- package/lib/commands/database-profile.js +1 -2
- package/lib/commands/database-remove.js +4 -6
- package/lib/commands/database-set.js +6 -6
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/database-update.js +6 -6
- package/lib/commands/dataconnect-sdk-generate.js +5 -2
- package/lib/commands/dataconnect-services-list.js +2 -2
- package/lib/commands/dataconnect-sql-diff.js +2 -2
- package/lib/commands/dataconnect-sql-grant.js +3 -3
- package/lib/commands/dataconnect-sql-migrate.js +2 -2
- package/lib/commands/dataconnect-sql-setup.js +39 -0
- package/lib/commands/dataconnect-sql-shell.js +5 -7
- package/lib/commands/deploy.js +4 -3
- package/lib/commands/emulators-exec.js +1 -1
- package/lib/commands/emulators-start.js +4 -3
- package/lib/commands/experiments-list.js +1 -1
- package/lib/commands/ext-dev-deprecate.js +1 -0
- package/lib/commands/ext-dev-init.js +3 -12
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-register.js +3 -5
- package/lib/commands/ext-dev-undeprecate.js +1 -2
- package/lib/commands/ext-dev-usage.js +4 -6
- package/lib/commands/ext-export.js +1 -2
- package/lib/commands/ext-install.js +3 -3
- package/lib/commands/ext-sdk-install.js +1 -0
- package/lib/commands/ext-update.js +1 -0
- package/lib/commands/firestore-backups-delete.js +3 -4
- package/lib/commands/firestore-backups-get.js +1 -1
- package/lib/commands/firestore-backups-list.js +2 -2
- package/lib/commands/firestore-backups-schedules-create.js +4 -4
- package/lib/commands/firestore-backups-schedules-delete.js +3 -4
- package/lib/commands/firestore-backups-schedules-list.js +2 -2
- package/lib/commands/firestore-backups-schedules-update.js +1 -1
- package/lib/commands/firestore-databases-create.js +6 -6
- package/lib/commands/firestore-databases-delete.js +3 -7
- package/lib/commands/firestore-databases-get.js +1 -1
- package/lib/commands/firestore-databases-list.js +1 -1
- package/lib/commands/firestore-databases-restore.js +5 -5
- package/lib/commands/firestore-databases-update.js +4 -4
- package/lib/commands/firestore-delete.js +13 -14
- package/lib/commands/firestore-indexes-list.js +4 -4
- package/lib/commands/firestore-locations.js +1 -1
- package/lib/commands/functions-artifacts-setpolicy.js +132 -0
- package/lib/commands/functions-config-export.js +6 -10
- package/lib/commands/functions-delete.js +5 -7
- package/lib/commands/functions-deletegcfartifacts.js +5 -5
- package/lib/commands/functions-list.js +24 -33
- package/lib/commands/functions-secrets-access.js +1 -1
- package/lib/commands/functions-secrets-describe.js +1 -1
- package/lib/commands/functions-secrets-destroy.js +10 -12
- package/lib/commands/functions-secrets-get.js +1 -1
- package/lib/commands/functions-secrets-prune.js +14 -15
- package/lib/commands/functions-secrets-set.js +14 -18
- package/lib/commands/hosting-channel-create.js +1 -2
- package/lib/commands/hosting-channel-delete.js +4 -4
- package/lib/commands/hosting-channel-list.js +1 -1
- package/lib/commands/hosting-channel-open.js +2 -3
- package/lib/commands/hosting-disable.js +5 -5
- package/lib/commands/hosting-sites-delete.js +4 -4
- package/lib/commands/hosting-sites-get.js +1 -1
- package/lib/commands/hosting-sites-list.js +1 -1
- package/lib/commands/index.js +7 -4
- package/lib/commands/init.js +54 -60
- package/lib/commands/internaltesting-frameworks-compose.js +1 -1
- package/lib/commands/login-use.js +2 -11
- package/lib/commands/login.js +10 -8
- package/lib/commands/logout.js +2 -3
- package/lib/commands/mcp.js +11 -0
- package/lib/commands/open.js +4 -2
- package/lib/commands/projects-create.js +1 -2
- package/lib/commands/projects-list.js +1 -1
- package/lib/commands/remoteconfig-get.js +1 -1
- package/lib/commands/remoteconfig-rollback.js +5 -5
- package/lib/commands/remoteconfig-versions-list.js +2 -2
- package/lib/commands/setup-emulators-database.js +1 -1
- package/lib/commands/setup-emulators-dataconnect.js +1 -1
- package/lib/commands/setup-emulators-firestore.js +1 -1
- package/lib/commands/setup-emulators-pubsub.js +1 -1
- package/lib/commands/setup-emulators-storage.js +1 -1
- package/lib/commands/setup-emulators-ui.js +1 -1
- package/lib/commands/use.js +115 -111
- package/lib/config.js +49 -33
- package/lib/crashlytics/buildToolsJarHelper.js +1 -1
- package/lib/crashlytics/listTopIssues.js +45 -0
- package/lib/dataconnect/build.js +61 -4
- package/lib/dataconnect/client.js +26 -17
- package/lib/dataconnect/cloudAICompanionClient.js +72 -0
- package/lib/dataconnect/dataplaneClient.js +19 -2
- package/lib/dataconnect/ensureApis.js +6 -3
- package/lib/dataconnect/fileUtils.js +39 -6
- package/lib/dataconnect/freeTrial.js +21 -9
- package/lib/dataconnect/graphqlError.js +56 -2
- package/lib/dataconnect/provisionCloudSql.js +23 -12
- package/lib/dataconnect/schemaMigration.js +46 -26
- package/lib/dataconnect/types.js +5 -1
- package/lib/defaultCredentials.js +12 -1
- package/lib/deploy/apphosting/args.js +2 -0
- package/lib/deploy/apphosting/deploy.js +77 -0
- package/lib/deploy/apphosting/index.js +9 -0
- package/lib/deploy/apphosting/prepare.js +138 -0
- package/lib/deploy/apphosting/release.js +56 -0
- package/lib/deploy/apphosting/util.js +65 -0
- package/lib/deploy/dataconnect/deploy.js +14 -7
- package/lib/deploy/dataconnect/prepare.js +3 -5
- package/lib/deploy/extensions/v2FunctionHelper.js +2 -1
- package/lib/deploy/firestore/deploy.js +50 -4
- package/lib/deploy/functions/build.js +1 -0
- package/lib/deploy/functions/checkIam.js +41 -6
- package/lib/deploy/functions/containerCleaner.js +17 -2
- package/lib/deploy/functions/ensure.js +2 -1
- package/lib/deploy/functions/params.js +10 -17
- package/lib/deploy/functions/prepare.js +51 -18
- package/lib/deploy/functions/prepareFunctionsUpload.js +9 -5
- package/lib/deploy/functions/prompts.js +24 -17
- package/lib/deploy/functions/release/fabricator.js +4 -4
- package/lib/deploy/functions/release/index.js +27 -9
- package/lib/deploy/functions/release/planner.js +1 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +13 -5
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +4 -4
- package/lib/deploy/functions/runtimes/python/index.js +4 -1
- package/lib/deploy/functions/runtimes/supported/types.js +17 -11
- package/lib/deploy/functions/services/firestore.js +23 -4
- package/lib/deploy/index.js +29 -10
- package/lib/deploy/lifecycleHooks.js +6 -12
- package/lib/emulator/ExpressBasedEmulator.js +1 -1
- package/lib/emulator/apphosting/config.js +15 -14
- package/lib/emulator/apphosting/index.js +2 -0
- package/lib/emulator/apphosting/serve.js +147 -10
- package/lib/emulator/auth/cloudFunctions.js +13 -1
- package/lib/emulator/auth/operations.js +2 -1
- package/lib/emulator/auth/widget_ui.js +2 -1
- package/lib/emulator/commandUtils.js +14 -20
- package/lib/emulator/constants.js +2 -0
- package/lib/emulator/controller.js +24 -9
- package/lib/emulator/dataconnect/pgliteServer.js +136 -45
- package/lib/emulator/dataconnectEmulator.js +34 -6
- package/lib/emulator/dataconnectToolkitController.js +5 -0
- package/lib/emulator/downloadableEmulatorInfo.json +81 -0
- package/lib/emulator/downloadableEmulators.js +28 -80
- package/lib/emulator/env.js +47 -1
- package/lib/emulator/extensionsEmulator.js +5 -3
- package/lib/emulator/functionsEmulator.js +6 -26
- package/lib/emulator/hub.js +5 -4
- package/lib/emulator/hubClient.js +5 -0
- package/lib/emulator/initEmulators.js +29 -15
- package/lib/emulator/ui.js +4 -8
- package/lib/ensureApiEnabled.js +32 -1
- package/lib/experiments.js +11 -12
- package/lib/extensions/askUserForEventsConfig.js +6 -15
- package/lib/extensions/askUserForParam.js +23 -52
- package/lib/extensions/change-log.js +1 -25
- package/lib/extensions/checkProjectBilling.js +3 -9
- package/lib/extensions/diagnose.js +3 -6
- package/lib/extensions/emulator/triggerHelper.js +4 -0
- package/lib/extensions/extensionsHelper.js +25 -31
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/manifest.js +3 -7
- package/lib/extensions/paramHelper.js +11 -2
- package/lib/extensions/provisioningHelper.js +1 -1
- package/lib/extensions/tos.js +4 -2
- package/lib/extensions/utils.js +1 -10
- package/lib/firebaseConfigValidate.js +7 -5
- package/lib/firestore/delete.js +5 -4
- package/lib/firestore/pretty-print.js +1 -1
- package/lib/frameworks/angular/index.js +11 -6
- package/lib/frameworks/angular/utils.js +76 -47
- package/lib/frameworks/constants.js +1 -1
- package/lib/frameworks/index.js +6 -4
- package/lib/frameworks/next/index.js +7 -4
- package/lib/frameworks/utils.js +11 -3
- package/lib/frameworks/vite/index.js +2 -3
- package/lib/fsAsync.js +9 -2
- package/lib/fsutils.js +16 -1
- package/lib/functions/artifacts.js +196 -0
- package/lib/functions/secrets.js +15 -16
- package/lib/gcp/apphosting.js +13 -1
- package/lib/gcp/artifactregistry.js +27 -2
- package/lib/gcp/auth.js +113 -1
- package/lib/gcp/cloudbilling.js +12 -1
- package/lib/gcp/cloudfunctions.js +32 -4
- package/lib/gcp/cloudfunctionsv2.js +15 -9
- package/lib/gcp/cloudscheduler.js +2 -2
- package/lib/gcp/cloudsql/cloudsqladmin.js +32 -11
- package/lib/gcp/cloudsql/connect.js +21 -14
- package/lib/gcp/cloudsql/interactive.js +1 -1
- package/lib/gcp/cloudsql/permissions.js +46 -99
- package/lib/gcp/cloudsql/permissionsSetup.js +224 -0
- package/lib/gcp/computeEngine.js +19 -2
- package/lib/gcp/devConnect.js +6 -1
- package/lib/gcp/firestore.js +55 -16
- package/lib/gcp/iam.js +1 -5
- package/lib/gcp/proto.js +4 -3
- package/lib/gcp/run.js +18 -1
- package/lib/gcp/serviceusage.js +2 -1
- package/lib/gcp/storage.js +47 -1
- package/lib/gemini/fdcExperience.js +56 -0
- package/lib/gemini/types.js +2 -0
- package/lib/hosting/api.js +4 -0
- package/lib/hosting/implicitInit.js +7 -3
- package/lib/hosting/interactive.js +2 -3
- package/lib/index.js +1 -2
- package/lib/init/features/account.js +2 -4
- package/lib/init/features/apphosting.js +75 -6
- package/lib/init/features/database.js +63 -62
- package/lib/init/features/dataconnect/index.js +131 -85
- package/lib/init/features/dataconnect/sdk.js +73 -18
- package/lib/init/features/emulators.js +29 -46
- package/lib/init/features/firestore/index.js +79 -43
- package/lib/init/features/firestore/indexes.js +30 -45
- package/lib/init/features/firestore/rules.js +36 -62
- package/lib/init/features/functions/index.js +11 -16
- package/lib/init/features/functions/javascript.js +17 -30
- package/lib/init/features/functions/npm-dependencies.js +4 -8
- package/lib/init/features/functions/python.js +1 -3
- package/lib/init/features/functions/typescript.js +25 -43
- package/lib/init/features/genkit/index.js +111 -106
- package/lib/init/features/hosting/github.js +22 -52
- package/lib/init/features/hosting/index.js +37 -57
- package/lib/init/features/index.js +10 -5
- package/lib/init/features/project.js +18 -21
- package/lib/init/features/remoteconfig.js +5 -10
- package/lib/init/features/storage.js +30 -10
- package/lib/init/index.js +79 -24
- package/lib/logger.js +76 -3
- package/lib/management/apps.js +292 -7
- package/lib/management/projects.js +100 -52
- package/lib/mcp/errors.js +20 -0
- package/lib/mcp/index.js +227 -0
- package/lib/mcp/tool.js +12 -0
- package/lib/mcp/tools/apphosting/fetch_logs.js +68 -0
- package/lib/mcp/tools/apphosting/index.js +6 -0
- package/lib/mcp/tools/apphosting/list_backends.js +51 -0
- package/lib/mcp/tools/auth/disable_user.js +30 -0
- package/lib/mcp/tools/auth/get_user.js +38 -0
- package/lib/mcp/tools/auth/index.js +15 -0
- package/lib/mcp/tools/auth/list_users.js +36 -0
- package/lib/mcp/tools/auth/set_claims.js +43 -0
- package/lib/mcp/tools/auth/set_sms_region_policy.js +36 -0
- package/lib/mcp/tools/core/consult_assistant.js +28 -0
- package/lib/mcp/tools/core/create_android_sha.js +43 -0
- package/lib/mcp/tools/core/create_app.js +90 -0
- package/lib/mcp/tools/core/create_project.js +68 -0
- package/lib/mcp/tools/core/get_admin_sdk_config.js +26 -0
- package/lib/mcp/tools/core/get_environment.js +51 -0
- package/lib/mcp/tools/core/get_project.js +22 -0
- package/lib/mcp/tools/core/get_sdk_config.js +40 -0
- package/lib/mcp/tools/core/index.js +29 -0
- package/lib/mcp/tools/core/init.js +153 -0
- package/lib/mcp/tools/core/list_apps.js +34 -0
- package/lib/mcp/tools/core/list_projects.js +45 -0
- package/lib/mcp/tools/core/update_environment.js +55 -0
- package/lib/mcp/tools/crashlytics/index.js +5 -0
- package/lib/mcp/tools/crashlytics/list_top_issues.js +39 -0
- package/lib/mcp/tools/dataconnect/converter.js +60 -0
- package/lib/mcp/tools/dataconnect/emulator.js +16 -0
- package/lib/mcp/tools/dataconnect/execute_graphql.js +48 -0
- package/lib/mcp/tools/dataconnect/execute_graphql_read.js +48 -0
- package/lib/mcp/tools/dataconnect/execute_mutation.js +62 -0
- package/lib/mcp/tools/dataconnect/execute_query.js +62 -0
- package/lib/mcp/tools/dataconnect/generate_operation.js +34 -0
- package/lib/mcp/tools/dataconnect/generate_schema.js +26 -0
- package/lib/mcp/tools/dataconnect/get_connector.js +31 -0
- package/lib/mcp/tools/dataconnect/get_schema.js +31 -0
- package/lib/mcp/tools/dataconnect/index.js +23 -0
- package/lib/mcp/tools/dataconnect/list_services.js +23 -0
- package/lib/mcp/tools/firestore/converter.js +102 -0
- package/lib/mcp/tools/firestore/delete_document.js +50 -0
- package/lib/mcp/tools/firestore/get_documents.js +58 -0
- package/lib/mcp/tools/firestore/index.js +17 -0
- package/lib/mcp/tools/firestore/list_collections.js +36 -0
- package/lib/mcp/tools/firestore/query_collection.js +132 -0
- package/lib/mcp/tools/index.js +62 -0
- package/lib/mcp/tools/messaging/index.js +5 -0
- package/lib/mcp/tools/messaging/send_message.js +42 -0
- package/lib/mcp/tools/remoteconfig/get_template.js +27 -0
- package/lib/mcp/tools/remoteconfig/index.js +7 -0
- package/lib/mcp/tools/remoteconfig/publish_template.js +34 -0
- package/lib/mcp/tools/remoteconfig/rollback_template.js +29 -0
- package/lib/mcp/tools/rules/get_rules.js +29 -0
- package/lib/mcp/tools/rules/validate_rules.js +97 -0
- package/lib/mcp/tools/storage/get_download_url.js +40 -0
- package/lib/mcp/tools/storage/get_rules.js +26 -0
- package/lib/mcp/tools/storage/index.js +11 -0
- package/lib/mcp/types.js +13 -0
- package/lib/mcp/util.js +214 -0
- package/lib/mcp/util.test.js +468 -0
- package/lib/messaging/interfaces.js +2 -0
- package/lib/messaging/sendMessage.js +48 -0
- package/lib/operation-poller.js +3 -1
- package/lib/profileReport.js +1 -1
- package/lib/prompt.js +86 -54
- package/lib/remoteconfig/publish.js +39 -0
- package/lib/requireAuth.js +2 -2
- package/lib/requireTosAcceptance.js +4 -0
- package/lib/rulesDeploy.js +10 -15
- package/lib/track.js +7 -37
- package/lib/utils.js +28 -41
- package/lib/vsCodeUtils.js +7 -3
- package/package.json +31 -15
- package/schema/connector-yaml.json +12 -0
- package/schema/dataconnect-yaml.json +5 -0
- package/schema/extension-yaml.json +17 -4
- package/schema/firebase-config.json +1117 -2121
- package/standalone/package-lock.json +1255 -992
- package/standalone/package.json +1 -1
- package/templates/dataconnect-prompts/operation-generation-cursor-windsurf-rule.txt +273 -0
- package/templates/dataconnect-prompts/schema-generation-cursor-windsurf-rule.txt +653 -0
- package/templates/genkit/firebase.0.9.0.template +1 -1
- package/templates/genkit/firebase.1.0.0.template +71 -0
- package/templates/init/dataconnect/connector.yaml +4 -1
- package/templates/init/dataconnect/dataconnect.yaml +1 -1
- package/templates/init/dataconnect/mutations.gql +9 -26
- package/templates/init/dataconnect/queries.gql +9 -14
- package/templates/init/dataconnect/schema.gql +28 -21
- package/templates/init/firestore/firestore.rules +2 -0
- package/templates/init/functions/javascript/index.js +14 -1
- package/templates/init/functions/javascript/package.lint.json +1 -1
- package/templates/init/functions/javascript/package.nolint.json +1 -1
- package/templates/init/functions/python/_gitignore +6 -1
- package/templates/init/functions/python/main.py +8 -0
- package/templates/init/functions/typescript/index.ts +14 -1
- package/templates/init/functions/typescript/package.lint.json +2 -2
- package/templates/init/functions/typescript/package.nolint.json +3 -3
- package/lib/commands/apphosting-config-export.js +0 -28
- package/lib/commands/experimental-functions-shell.js +0 -13
- package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +0 -11
- package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +0 -58
- package/lib/emulator/dataconnect/pg-gateway/auth/index.js +0 -22
- package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +0 -124
- package/lib/emulator/dataconnect/pg-gateway/auth/password.js +0 -54
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +0 -34
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +0 -270
- package/lib/emulator/dataconnect/pg-gateway/backend-error.js +0 -75
- package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +0 -54
- package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +0 -79
- package/lib/emulator/dataconnect/pg-gateway/connection.js +0 -315
- package/lib/emulator/dataconnect/pg-gateway/connection.types.js +0 -8
- package/lib/emulator/dataconnect/pg-gateway/crypto.js +0 -40
- package/lib/emulator/dataconnect/pg-gateway/duplex.js +0 -53
- package/lib/emulator/dataconnect/pg-gateway/index.js +0 -27
- package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +0 -82
- package/lib/emulator/dataconnect/pg-gateway/message-codes.js +0 -52
- package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +0 -16
- package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +0 -35
- package/lib/emulator/dataconnect/pg-gateway/utils.js +0 -40
- package/templates/setup/web.js +0 -5
- /package/lib/{emulator/dataconnect/pg-gateway/auth/trust.js → dataconnect/cloudAICompanionTypes.js} +0 -0
package/README.md
CHANGED
|
@@ -14,14 +14,14 @@ clarity.
|
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Add this dependency to the root of your monorepo, and co-locate all off your Firebase configurations there as well, as described in the docs.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
I encourage you to use `pnpm` over `npm` or `yarn`. Apart from being fast and
|
|
20
20
|
efficient, PNPM has better support for monorepos, and the the lockfile isolation
|
|
21
21
|
code is solid and works in parallel for multiple packages, [unlike NPM](https://github.com/0x80/isolate-package/README.md#npm)
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
pnpm add firebase-tools-with-isolate -D
|
|
24
|
+
pnpm add firebase-tools-with-isolate -D -w
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Or run the equivalent for NPM or Yarn.
|
|
@@ -49,7 +49,56 @@ You have to opt-in to the functions isolate process by setting `functions.isolat
|
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
If you
|
|
52
|
+
If you have a monorepo, your firebase.json file should be located in the root listing all of the packages, emulator settings and other firebase related files. It would look something like this:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"functions": [
|
|
57
|
+
{
|
|
58
|
+
"source": "services/api",
|
|
59
|
+
"predeploy": ["pnpm build:api"],
|
|
60
|
+
"runtime": "nodejs22",
|
|
61
|
+
"codebase": "api",
|
|
62
|
+
"isolate": true
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"source": "services/fns",
|
|
66
|
+
"predeploy": ["pnpm build:fns"],
|
|
67
|
+
"runtime": "nodejs22",
|
|
68
|
+
"codebase": "fns",
|
|
69
|
+
"isolate": true
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"firestore": {
|
|
73
|
+
"rules": "firestore.rules",
|
|
74
|
+
"indexes": "firestore.indexes.json"
|
|
75
|
+
},
|
|
76
|
+
"storage": {
|
|
77
|
+
"rules": "storage.rules"
|
|
78
|
+
},
|
|
79
|
+
"emulators": {
|
|
80
|
+
"ui": {
|
|
81
|
+
"enabled": true
|
|
82
|
+
},
|
|
83
|
+
"auth": {
|
|
84
|
+
"port": 9099
|
|
85
|
+
},
|
|
86
|
+
"functions": {
|
|
87
|
+
"port": 5001
|
|
88
|
+
},
|
|
89
|
+
"firestore": {
|
|
90
|
+
"port": 8080
|
|
91
|
+
},
|
|
92
|
+
"pubsub": {
|
|
93
|
+
"port": 8085
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
At the time of writing, firebase-tools has an seemingly odd limitation that prevents it from running predeploy commands with "=" in them. So `"turbo build --filter=@repo/api"` doesn't work. A workaround is to use `"pnpm build:api"` instead, and put `"build:api": "turbo build --filter=@repo/api"` in your root package.json.
|
|
100
|
+
|
|
101
|
+
If you would like to see a complete working example of a modern monorepo setup check out [mono-ts](https://github.com/0x80/mono-ts)
|
|
53
102
|
|
|
54
103
|
## Documentation
|
|
55
104
|
|
package/lib/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.setScopes = exports.getScopes = exports.vertexAIOrigin = exports.cloudSQLAdminOrigin = exports.dataConnectLocalConnString = exports.dataconnectP4SADomain = exports.dataconnectOrigin = exports.githubClientSecret = exports.githubClientId = exports.computeOrigin = exports.secretManagerOrigin = exports.githubApiOrigin = exports.githubOrigin = exports.serviceUsageOrigin = void 0;
|
|
3
|
+
exports.storageOrigin = exports.runtimeconfigOrigin = exports.rulesOrigin = exports.resourceManagerOrigin = exports.crashlyticsApiOrigin = exports.messagingApiOrigin = exports.remoteConfigApiOrigin = exports.rtdbMetadataOrigin = exports.rtdbManagementOrigin = exports.realtimeOrigin = exports.extensionsTOSOrigin = exports.extensionsPublisherOrigin = exports.extensionsOrigin = exports.iamOrigin = exports.identityOrigin = exports.hostingOrigin = exports.googleOrigin = exports.pubsubOrigin = exports.cloudTasksOrigin = exports.cloudschedulerOrigin = exports.cloudbuildOrigin = exports.functionsDefaultRegion = exports.runOrigin = exports.functionsV2Origin = exports.functionsOrigin = exports.firestoreOrigin = exports.firestoreOriginOrEmulator = exports.firedataOrigin = exports.firebaseExtensionsRegistryOrigin = exports.firebaseApiOrigin = exports.eventarcOrigin = exports.dynamicLinksKey = exports.dynamicLinksOrigin = exports.consoleOrigin = exports.authManagementOrigin = exports.authOrigin = exports.apphostingGitHubAppInstallationURL = exports.apphostingP4SADomain = exports.apphostingOrigin = exports.appDistributionOrigin = exports.artifactRegistryDomain = exports.developerConnectP4SADomain = exports.developerConnectOrigin = exports.containerRegistryDomain = exports.cloudMonitoringOrigin = exports.cloudloggingOrigin = exports.cloudbillingOrigin = exports.clientSecret = exports.clientId = exports.authProxyOrigin = void 0;
|
|
4
|
+
exports.setScopes = exports.getScopes = exports.cloudAiCompanionOrigin = exports.vertexAIOrigin = exports.cloudSQLAdminOrigin = exports.dataConnectLocalConnString = exports.dataconnectP4SADomain = exports.dataconnectOrigin = exports.githubClientSecret = exports.githubClientId = exports.computeOrigin = exports.secretManagerOrigin = exports.githubApiOrigin = exports.githubOrigin = exports.serviceUsageOrigin = exports.cloudRunApiOrigin = exports.hostingApiOrigin = exports.firebaseStorageOrigin = void 0;
|
|
5
5
|
const constants_1 = require("./emulator/constants");
|
|
6
6
|
const logger_1 = require("./logger");
|
|
7
7
|
const scopes = require("./scopes");
|
|
@@ -37,6 +37,8 @@ const apphostingGitHubAppInstallationURL = () => utils.envOverride("FIREBASE_APP
|
|
|
37
37
|
exports.apphostingGitHubAppInstallationURL = apphostingGitHubAppInstallationURL;
|
|
38
38
|
const authOrigin = () => utils.envOverride("FIREBASE_AUTH_URL", "https://accounts.google.com");
|
|
39
39
|
exports.authOrigin = authOrigin;
|
|
40
|
+
const authManagementOrigin = () => utils.envOverride("FIREBASE_AUTH_MANAGEMENT_URL", "https://identitytoolkit.googleapis.com");
|
|
41
|
+
exports.authManagementOrigin = authManagementOrigin;
|
|
40
42
|
const consoleOrigin = () => utils.envOverride("FIREBASE_CONSOLE_URL", "https://console.firebase.google.com");
|
|
41
43
|
exports.consoleOrigin = consoleOrigin;
|
|
42
44
|
const dynamicLinksOrigin = () => utils.envOverride("FIREBASE_DYNAMIC_LINKS_URL", "https://firebasedynamiclinks.googleapis.com");
|
|
@@ -98,6 +100,10 @@ const rtdbMetadataOrigin = () => utils.envOverride("FIREBASE_RTDB_METADATA_URL",
|
|
|
98
100
|
exports.rtdbMetadataOrigin = rtdbMetadataOrigin;
|
|
99
101
|
const remoteConfigApiOrigin = () => utils.envOverride("FIREBASE_REMOTE_CONFIG_URL", "https://firebaseremoteconfig.googleapis.com");
|
|
100
102
|
exports.remoteConfigApiOrigin = remoteConfigApiOrigin;
|
|
103
|
+
const messagingApiOrigin = () => utils.envOverride("FIREBASE_MESSAGING_CONFIG_URL", "https://fcm.googleapis.com");
|
|
104
|
+
exports.messagingApiOrigin = messagingApiOrigin;
|
|
105
|
+
const crashlyticsApiOrigin = () => utils.envOverride("FIREBASE_CRASHLYTICS_URL", "https://firebasecrashlytics.googleapis.com");
|
|
106
|
+
exports.crashlyticsApiOrigin = crashlyticsApiOrigin;
|
|
101
107
|
const resourceManagerOrigin = () => utils.envOverride("FIREBASE_RESOURCEMANAGER_URL", "https://cloudresourcemanager.googleapis.com");
|
|
102
108
|
exports.resourceManagerOrigin = resourceManagerOrigin;
|
|
103
109
|
const rulesOrigin = () => utils.envOverride("FIREBASE_RULES_URL", "https://firebaserules.googleapis.com");
|
|
@@ -136,6 +142,8 @@ const cloudSQLAdminOrigin = () => utils.envOverride("CLOUD_SQL_URL", "https://sq
|
|
|
136
142
|
exports.cloudSQLAdminOrigin = cloudSQLAdminOrigin;
|
|
137
143
|
const vertexAIOrigin = () => utils.envOverride("VERTEX_AI_URL", "https://aiplatform.googleapis.com");
|
|
138
144
|
exports.vertexAIOrigin = vertexAIOrigin;
|
|
145
|
+
const cloudAiCompanionOrigin = () => utils.envOverride("CLOUD_AI_COMPANION_URL", "https://cloudaicompanion.googleapis.com");
|
|
146
|
+
exports.cloudAiCompanionOrigin = cloudAiCompanionOrigin;
|
|
139
147
|
function getScopes() {
|
|
140
148
|
return Array.from(commandScopes);
|
|
141
149
|
}
|
|
@@ -118,7 +118,7 @@ class AppDistributionClient {
|
|
|
118
118
|
catch (err) {
|
|
119
119
|
throw new error_1.FirebaseError(`Client request failed to list testers ${err}`);
|
|
120
120
|
}
|
|
121
|
-
for (const t of apiResponse.body.testers) {
|
|
121
|
+
for (const t of apiResponse.body.testers ?? []) {
|
|
122
122
|
listTestersResponse.testers.push({
|
|
123
123
|
name: t.name,
|
|
124
124
|
displayName: t.displayName,
|
|
@@ -169,7 +169,7 @@ class AppDistributionClient {
|
|
|
169
169
|
const apiResponse = await client.get(`${projectName}/groups`, {
|
|
170
170
|
queryParams,
|
|
171
171
|
});
|
|
172
|
-
listGroupsResponse.groups.push(...(apiResponse.body.groups
|
|
172
|
+
listGroupsResponse.groups.push(...(apiResponse.body.groups ?? []));
|
|
173
173
|
pageToken = apiResponse.body.nextPageToken;
|
|
174
174
|
}
|
|
175
175
|
catch (err) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBackendForAmbiguousLocation = exports.getBackendForLocation = exports.promptLocation = exports.deleteBackendAndPoll = exports.setDefaultTrafficPolicy = exports.createBackend = exports.ensureAppHostingComputeServiceAccount = exports.createGitRepoLink = exports.doSetup = void 0;
|
|
3
|
+
exports.getBackend = exports.getBackendForAmbiguousLocation = exports.chooseBackends = exports.promptExistingBackend = exports.getBackendForLocation = exports.promptLocation = exports.deleteBackendAndPoll = exports.setDefaultTrafficPolicy = exports.createBackend = exports.promptNewBackendId = exports.ensureAppHostingComputeServiceAccount = exports.createGitRepoLink = exports.ensureRequiredApisEnabled = exports.doSetupSourceDeploy = exports.doSetup = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const poller = require("../operation-poller");
|
|
6
6
|
const apphosting = require("../gcp/apphosting");
|
|
@@ -19,6 +19,7 @@ const app_1 = require("./app");
|
|
|
19
19
|
const ora = require("ora");
|
|
20
20
|
const node_fetch_1 = require("node-fetch");
|
|
21
21
|
const rollout_1 = require("./rollout");
|
|
22
|
+
const fuzzy = require("fuzzy");
|
|
22
23
|
const DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME = "firebase-app-hosting-compute";
|
|
23
24
|
const apphostingPollerOptions = {
|
|
24
25
|
apiOrigin: (0, api_1.apphostingOrigin)(),
|
|
@@ -49,52 +50,29 @@ async function awaitTlsReady(url) {
|
|
|
49
50
|
}
|
|
50
51
|
} while (!ready);
|
|
51
52
|
}
|
|
52
|
-
async function doSetup(projectId, webAppName,
|
|
53
|
-
await
|
|
54
|
-
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.developerConnectOrigin)(), "apphosting", true),
|
|
55
|
-
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.cloudbuildOrigin)(), "apphosting", true),
|
|
56
|
-
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.secretManagerOrigin)(), "apphosting", true),
|
|
57
|
-
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.cloudRunApiOrigin)(), "apphosting", true),
|
|
58
|
-
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.artifactRegistryDomain)(), "apphosting", true),
|
|
59
|
-
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.iamOrigin)(), "apphosting", true),
|
|
60
|
-
]);
|
|
53
|
+
async function doSetup(projectId, webAppName, serviceAccount) {
|
|
54
|
+
await ensureRequiredApisEnabled(projectId);
|
|
61
55
|
await ensureAppHostingComputeServiceAccount(projectId, serviceAccount);
|
|
62
|
-
const
|
|
63
|
-
if (location) {
|
|
64
|
-
if (!allowedLocations.includes(location)) {
|
|
65
|
-
throw new error_1.FirebaseError(`Invalid location ${location}. Valid choices are ${allowedLocations.join(", ")}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
location =
|
|
69
|
-
location || (await promptLocation(projectId, "Select a location to host your backend:\n"));
|
|
56
|
+
const location = await promptLocation(projectId, "Select a primary region to host your backend:\n");
|
|
70
57
|
const gitRepositoryLink = await githubConnections.linkGitHubRepository(projectId, location);
|
|
71
|
-
const rootDir = await (0, prompt_1.
|
|
72
|
-
name: "rootDir",
|
|
73
|
-
type: "input",
|
|
58
|
+
const rootDir = await (0, prompt_1.input)({
|
|
74
59
|
default: "/",
|
|
75
60
|
message: "Specify your app's root directory relative to your repository",
|
|
76
61
|
});
|
|
77
62
|
const branch = await githubConnections.promptGitHubBranch(gitRepositoryLink);
|
|
78
63
|
(0, utils_1.logSuccess)(`Repo linked successfully!\n`);
|
|
79
64
|
(0, utils_1.logBullet)(`${clc.yellow("===")} Set up your backend`);
|
|
80
|
-
const backendId = await promptNewBackendId(projectId, location
|
|
81
|
-
name: "backendId",
|
|
82
|
-
type: "input",
|
|
83
|
-
default: "my-web-app",
|
|
84
|
-
message: "Provide a name for your backend [1-30 characters]",
|
|
85
|
-
});
|
|
65
|
+
const backendId = await promptNewBackendId(projectId, location);
|
|
86
66
|
(0, utils_1.logSuccess)(`Name set to ${backendId}\n`);
|
|
87
67
|
const webApp = await app_1.webApps.getOrCreateWebApp(projectId, webAppName, backendId);
|
|
88
68
|
if (!webApp) {
|
|
89
69
|
(0, utils_1.logWarning)(`Firebase web app not set`);
|
|
90
70
|
}
|
|
91
71
|
const createBackendSpinner = ora("Creating your new backend...").start();
|
|
92
|
-
const backend = await createBackend(projectId, location, backendId,
|
|
72
|
+
const backend = await createBackend(projectId, location, backendId, serviceAccount, gitRepositoryLink, webApp?.id, rootDir);
|
|
93
73
|
createBackendSpinner.succeed(`Successfully created backend!\n\t${backend.name}\n`);
|
|
94
74
|
await setDefaultTrafficPolicy(projectId, location, backendId, branch);
|
|
95
|
-
const confirmRollout = await (0, prompt_1.
|
|
96
|
-
type: "confirm",
|
|
97
|
-
name: "rollout",
|
|
75
|
+
const confirmRollout = await (0, prompt_1.confirm)({
|
|
98
76
|
default: true,
|
|
99
77
|
message: "Do you want to deploy now?",
|
|
100
78
|
});
|
|
@@ -127,6 +105,34 @@ async function doSetup(projectId, webAppName, location, serviceAccount) {
|
|
|
127
105
|
(0, utils_1.logSuccess)(`Your backend is now deployed at:\n\thttps://${backend.uri}`);
|
|
128
106
|
}
|
|
129
107
|
exports.doSetup = doSetup;
|
|
108
|
+
async function doSetupSourceDeploy(projectId, backendId) {
|
|
109
|
+
const location = await promptLocation(projectId, "Select a primary region to host your backend:\n");
|
|
110
|
+
const webAppSpinner = ora("Creating a new web app...\n").start();
|
|
111
|
+
const webApp = await app_1.webApps.getOrCreateWebApp(projectId, null, backendId);
|
|
112
|
+
if (!webApp) {
|
|
113
|
+
(0, utils_1.logWarning)(`Firebase web app not set`);
|
|
114
|
+
}
|
|
115
|
+
webAppSpinner.stop();
|
|
116
|
+
const createBackendSpinner = ora("Creating your new backend...").start();
|
|
117
|
+
const backend = await createBackend(projectId, location, backendId, null, undefined, webApp?.id);
|
|
118
|
+
createBackendSpinner.succeed(`Successfully created backend!\n\t${backend.name}\n`);
|
|
119
|
+
return {
|
|
120
|
+
backend,
|
|
121
|
+
location,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
exports.doSetupSourceDeploy = doSetupSourceDeploy;
|
|
125
|
+
async function ensureRequiredApisEnabled(projectId) {
|
|
126
|
+
await Promise.all([
|
|
127
|
+
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.developerConnectOrigin)(), "apphosting", true),
|
|
128
|
+
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.cloudbuildOrigin)(), "apphosting", true),
|
|
129
|
+
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.secretManagerOrigin)(), "apphosting", true),
|
|
130
|
+
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.cloudRunApiOrigin)(), "apphosting", true),
|
|
131
|
+
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.artifactRegistryDomain)(), "apphosting", true),
|
|
132
|
+
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.iamOrigin)(), "apphosting", true),
|
|
133
|
+
]);
|
|
134
|
+
}
|
|
135
|
+
exports.ensureRequiredApisEnabled = ensureRequiredApisEnabled;
|
|
130
136
|
async function createGitRepoLink(projectId, location, connectionId) {
|
|
131
137
|
await Promise.all([
|
|
132
138
|
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.developerConnectOrigin)(), "apphosting", true),
|
|
@@ -155,18 +161,23 @@ async function ensureAppHostingComputeServiceAccount(projectId, serviceAccount)
|
|
|
155
161
|
if (!(err instanceof error_1.FirebaseError)) {
|
|
156
162
|
throw err;
|
|
157
163
|
}
|
|
158
|
-
if (err.status ===
|
|
159
|
-
await provisionDefaultComputeServiceAccount(projectId);
|
|
160
|
-
}
|
|
161
|
-
else if (err.status === 403) {
|
|
164
|
+
if (err.status === 403) {
|
|
162
165
|
throw new error_1.FirebaseError(`Failed to create backend due to missing delegation permissions for ${sa}. Make sure you have the iam.serviceAccounts.actAs permission.`, { original: err });
|
|
163
166
|
}
|
|
167
|
+
else if (err.status !== 404) {
|
|
168
|
+
throw new error_1.FirebaseError("Unexpected error occurred while testing for IAM service account permissions", { original: err });
|
|
169
|
+
}
|
|
164
170
|
}
|
|
171
|
+
await provisionDefaultComputeServiceAccount(projectId);
|
|
165
172
|
}
|
|
166
173
|
exports.ensureAppHostingComputeServiceAccount = ensureAppHostingComputeServiceAccount;
|
|
167
|
-
async function promptNewBackendId(projectId, location
|
|
174
|
+
async function promptNewBackendId(projectId, location) {
|
|
168
175
|
while (true) {
|
|
169
|
-
const backendId = await (0, prompt_1.
|
|
176
|
+
const backendId = await (0, prompt_1.input)({
|
|
177
|
+
default: "my-web-app",
|
|
178
|
+
message: "Provide a name for your backend [1-30 characters]",
|
|
179
|
+
validate: (s) => s.length >= 1 && s.length <= 30,
|
|
180
|
+
});
|
|
170
181
|
try {
|
|
171
182
|
await apphosting.getBackend(projectId, location, backendId);
|
|
172
183
|
}
|
|
@@ -179,17 +190,20 @@ async function promptNewBackendId(projectId, location, prompt) {
|
|
|
179
190
|
(0, utils_1.logWarning)(`Backend with id ${backendId} already exists in ${location}`);
|
|
180
191
|
}
|
|
181
192
|
}
|
|
193
|
+
exports.promptNewBackendId = promptNewBackendId;
|
|
182
194
|
function defaultComputeServiceAccountEmail(projectId) {
|
|
183
195
|
return `${DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME}@${projectId}.iam.gserviceaccount.com`;
|
|
184
196
|
}
|
|
185
|
-
async function createBackend(projectId, location, backendId,
|
|
197
|
+
async function createBackend(projectId, location, backendId, serviceAccount, repository, webAppId, rootDir = "/") {
|
|
186
198
|
const defaultServiceAccount = defaultComputeServiceAccountEmail(projectId);
|
|
187
199
|
const backendReqBody = {
|
|
188
200
|
servingLocality: "GLOBAL_ACCESS",
|
|
189
|
-
codebase:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
201
|
+
codebase: repository
|
|
202
|
+
? {
|
|
203
|
+
repository: `${repository.name}`,
|
|
204
|
+
rootDirectory: rootDir,
|
|
205
|
+
}
|
|
206
|
+
: undefined,
|
|
193
207
|
labels: deploymentTool.labels(),
|
|
194
208
|
serviceAccount: serviceAccount || defaultServiceAccount,
|
|
195
209
|
appId: webAppId,
|
|
@@ -214,11 +228,22 @@ async function provisionDefaultComputeServiceAccount(projectId) {
|
|
|
214
228
|
throw err;
|
|
215
229
|
}
|
|
216
230
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
231
|
+
try {
|
|
232
|
+
await (0, resourceManager_1.addServiceAccountToRoles)(projectId, defaultComputeServiceAccountEmail(projectId), [
|
|
233
|
+
"roles/firebaseapphosting.computeRunner",
|
|
234
|
+
"roles/firebase.sdkAdminServiceAgent",
|
|
235
|
+
"roles/developerconnect.readTokenAccessor",
|
|
236
|
+
"roles/storage.objectViewer",
|
|
237
|
+
], true);
|
|
238
|
+
}
|
|
239
|
+
catch (err) {
|
|
240
|
+
if ((0, error_1.getErrStatus)(err) === 400) {
|
|
241
|
+
(0, utils_1.logWarning)("Your App Hosting compute service account is still being provisioned in the background. If you encounter an error, please try again after a few moments.");
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
throw err;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
222
247
|
}
|
|
223
248
|
async function setDefaultTrafficPolicy(projectId, location, backendId, codebaseBranch) {
|
|
224
249
|
const traffic = {
|
|
@@ -248,13 +273,11 @@ async function promptLocation(projectId, prompt = "Please select a location:") {
|
|
|
248
273
|
if (allowedLocations.length === 1) {
|
|
249
274
|
return allowedLocations[0];
|
|
250
275
|
}
|
|
251
|
-
const location =
|
|
252
|
-
name: "location",
|
|
253
|
-
type: "list",
|
|
276
|
+
const location = await (0, prompt_1.select)({
|
|
254
277
|
default: constants_1.DEFAULT_LOCATION,
|
|
255
278
|
message: prompt,
|
|
256
279
|
choices: allowedLocations,
|
|
257
|
-
})
|
|
280
|
+
});
|
|
258
281
|
(0, utils_1.logSuccess)(`Location set to ${location}.\n`);
|
|
259
282
|
return location;
|
|
260
283
|
}
|
|
@@ -270,10 +293,73 @@ async function getBackendForLocation(projectId, location, backendId) {
|
|
|
270
293
|
}
|
|
271
294
|
}
|
|
272
295
|
exports.getBackendForLocation = getBackendForLocation;
|
|
296
|
+
async function promptExistingBackend(projectId, promptMessage) {
|
|
297
|
+
const { backends } = await apphosting.listBackends(projectId, "-");
|
|
298
|
+
const backendId = await (0, prompt_1.search)({
|
|
299
|
+
message: promptMessage,
|
|
300
|
+
source: (input = "") => {
|
|
301
|
+
return new Promise((resolve) => resolve([
|
|
302
|
+
...fuzzy
|
|
303
|
+
.filter(input, backends, {
|
|
304
|
+
extract: (backend) => apphosting.parseBackendName(backend.name).id,
|
|
305
|
+
})
|
|
306
|
+
.map((result) => {
|
|
307
|
+
return {
|
|
308
|
+
name: apphosting.parseBackendName(result.original.name).id,
|
|
309
|
+
value: apphosting.parseBackendName(result.original.name).id,
|
|
310
|
+
};
|
|
311
|
+
}),
|
|
312
|
+
]));
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
return backendId;
|
|
316
|
+
}
|
|
317
|
+
exports.promptExistingBackend = promptExistingBackend;
|
|
318
|
+
async function chooseBackends(projectId, backendId, chooseBackendPrompt, force) {
|
|
319
|
+
let { unreachable, backends } = await apphosting.listBackends(projectId, "-");
|
|
320
|
+
if (unreachable && unreachable.length !== 0) {
|
|
321
|
+
(0, utils_1.logWarning)(`The following locations are currently unreachable: ${unreachable.join(",")}.\n` +
|
|
322
|
+
"If your backend is in one of these regions, please try again later.");
|
|
323
|
+
}
|
|
324
|
+
backends = backends.filter((backend) => apphosting.parseBackendName(backend.name).id === backendId);
|
|
325
|
+
if (backends.length === 0) {
|
|
326
|
+
throw new error_1.FirebaseError(`No backend named "${backendId}" found.`);
|
|
327
|
+
}
|
|
328
|
+
if (backends.length === 1) {
|
|
329
|
+
return backends;
|
|
330
|
+
}
|
|
331
|
+
if (force) {
|
|
332
|
+
throw new error_1.FirebaseError(`Force cannot be used because multiple backends were found with ID ${backendId}.`);
|
|
333
|
+
}
|
|
334
|
+
const backendsByDisplay = new Map();
|
|
335
|
+
backends.forEach((backend) => {
|
|
336
|
+
const { location, id } = apphosting.parseBackendName(backend.name);
|
|
337
|
+
backendsByDisplay.set(`${id}(${location})`, backend);
|
|
338
|
+
});
|
|
339
|
+
const chosenBackendDisplays = await (0, prompt_1.checkbox)({
|
|
340
|
+
message: chooseBackendPrompt,
|
|
341
|
+
choices: Array.from(backendsByDisplay.keys(), (name) => {
|
|
342
|
+
return {
|
|
343
|
+
checked: false,
|
|
344
|
+
name: name,
|
|
345
|
+
value: name,
|
|
346
|
+
};
|
|
347
|
+
}),
|
|
348
|
+
});
|
|
349
|
+
const chosenBackends = [];
|
|
350
|
+
chosenBackendDisplays.forEach((backendDisplay) => {
|
|
351
|
+
const backend = backendsByDisplay.get(backendDisplay);
|
|
352
|
+
if (backend !== undefined) {
|
|
353
|
+
chosenBackends.push(backend);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
return chosenBackends;
|
|
357
|
+
}
|
|
358
|
+
exports.chooseBackends = chooseBackends;
|
|
273
359
|
async function getBackendForAmbiguousLocation(projectId, backendId, locationDisambugationPrompt, force) {
|
|
274
360
|
let { unreachable, backends } = await apphosting.listBackends(projectId, "-");
|
|
275
361
|
if (unreachable && unreachable.length !== 0) {
|
|
276
|
-
(0, utils_1.logWarning)(`The following locations are currently unreachable: ${unreachable}.\n` +
|
|
362
|
+
(0, utils_1.logWarning)(`The following locations are currently unreachable: ${unreachable.join(", ")}.\n` +
|
|
277
363
|
"If your backend is in one of these regions, please try again later.");
|
|
278
364
|
}
|
|
279
365
|
backends = backends.filter((backend) => apphosting.parseBackendName(backend.name).id === backendId);
|
|
@@ -288,12 +374,28 @@ async function getBackendForAmbiguousLocation(projectId, backendId, locationDisa
|
|
|
288
374
|
}
|
|
289
375
|
const backendsByLocation = new Map();
|
|
290
376
|
backends.forEach((backend) => backendsByLocation.set(apphosting.parseBackendName(backend.name).location, backend));
|
|
291
|
-
const location = await (0, prompt_1.
|
|
292
|
-
name: "location",
|
|
293
|
-
type: "list",
|
|
377
|
+
const location = await (0, prompt_1.select)({
|
|
294
378
|
message: locationDisambugationPrompt,
|
|
295
379
|
choices: [...backendsByLocation.keys()],
|
|
296
380
|
});
|
|
297
381
|
return backendsByLocation.get(location);
|
|
298
382
|
}
|
|
299
383
|
exports.getBackendForAmbiguousLocation = getBackendForAmbiguousLocation;
|
|
384
|
+
async function getBackend(projectId, backendId) {
|
|
385
|
+
let { unreachable, backends } = await apphosting.listBackends(projectId, "-");
|
|
386
|
+
backends = backends.filter((backend) => apphosting.parseBackendName(backend.name).id === backendId);
|
|
387
|
+
if (backends.length > 1) {
|
|
388
|
+
const locations = backends.map((b) => apphosting.parseBackendName(b.name).location);
|
|
389
|
+
throw new error_1.FirebaseError(`You have multiple backends with the same ${backendId} ID in regions: ${locations.join(", ")}. This is not allowed until we can support more locations. ` +
|
|
390
|
+
"Please delete and recreate any backends that share an ID with another backend.");
|
|
391
|
+
}
|
|
392
|
+
if (backends.length === 1) {
|
|
393
|
+
return backends[0];
|
|
394
|
+
}
|
|
395
|
+
if (unreachable && unreachable.length !== 0) {
|
|
396
|
+
(0, utils_1.logWarning)(`Backends with the following primary regions are unreachable: ${unreachable.join(", ")}.\n` +
|
|
397
|
+
"If your backend is in one of these regions, please try again later.");
|
|
398
|
+
}
|
|
399
|
+
throw new error_1.FirebaseError(`No backend named ${backendId} found.`);
|
|
400
|
+
}
|
|
401
|
+
exports.getBackend = getBackend;
|