firebase-tools-with-isolate 13.29.1-2 → 14.10.1-0
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 +5 -3
- 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 +50 -17
- 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 +2 -3
- 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/lib/apphosting/config.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.suggestedTestKeyName = exports.overrideChosenEnv = exports.maybeGenerateEmulatorYaml = exports.maybeAddSecretToYaml = exports.upsertEnv = exports.findEnv = exports.store = exports.load = exports.listAppHostingFilesInPath = exports.discoverBackendRoot = exports.APPHOSTING_YAML_FILE_REGEX = exports.APPHOSTING_LOCAL_YAML_FILE = exports.APPHOSTING_EMULATORS_YAML_FILE = exports.APPHOSTING_BASE_YAML_FILE = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const yaml = require("yaml");
|
|
7
|
+
const clc = require("colorette");
|
|
7
8
|
const fs = require("../fsutils");
|
|
8
9
|
const prompt = require("../prompt");
|
|
9
10
|
const dialogs = require("./secrets/dialogs");
|
|
10
11
|
const yaml_1 = require("./yaml");
|
|
11
|
-
const error_1 = require("../error");
|
|
12
|
-
const utils_1 = require("./utils");
|
|
13
|
-
const secrets_1 = require("./secrets");
|
|
14
12
|
const logger_1 = require("../logger");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
13
|
+
const csm = require("../gcp/secretManager");
|
|
14
|
+
const error_1 = require("../error");
|
|
17
15
|
exports.APPHOSTING_BASE_YAML_FILE = "apphosting.yaml";
|
|
16
|
+
exports.APPHOSTING_EMULATORS_YAML_FILE = "apphosting.emulator.yaml";
|
|
18
17
|
exports.APPHOSTING_LOCAL_YAML_FILE = "apphosting.local.yaml";
|
|
19
18
|
exports.APPHOSTING_YAML_FILE_REGEX = /^apphosting(\.[a-z0-9_]+)?\.yaml$/;
|
|
20
|
-
const SECRET_CONFIG = "Secret";
|
|
21
|
-
const EXPORTABLE_CONFIG = [SECRET_CONFIG];
|
|
22
19
|
function discoverBackendRoot(cwd) {
|
|
23
20
|
let dir = cwd;
|
|
24
|
-
while (
|
|
25
|
-
|
|
21
|
+
while (true) {
|
|
22
|
+
const files = fs.listFiles(dir);
|
|
23
|
+
if (files.some((file) => exports.APPHOSTING_YAML_FILE_REGEX.test(file))) {
|
|
24
|
+
return dir;
|
|
25
|
+
}
|
|
26
|
+
if (files.includes("firebase.json")) {
|
|
26
27
|
return null;
|
|
27
28
|
}
|
|
28
29
|
const parent = (0, path_1.dirname)(dir);
|
|
@@ -31,7 +32,6 @@ function discoverBackendRoot(cwd) {
|
|
|
31
32
|
}
|
|
32
33
|
dir = parent;
|
|
33
34
|
}
|
|
34
|
-
return dir;
|
|
35
35
|
}
|
|
36
36
|
exports.discoverBackendRoot = discoverBackendRoot;
|
|
37
37
|
function listAppHostingFilesInPath(path) {
|
|
@@ -42,7 +42,18 @@ function listAppHostingFilesInPath(path) {
|
|
|
42
42
|
}
|
|
43
43
|
exports.listAppHostingFilesInPath = listAppHostingFilesInPath;
|
|
44
44
|
function load(yamlPath) {
|
|
45
|
-
|
|
45
|
+
let raw;
|
|
46
|
+
try {
|
|
47
|
+
raw = fs.readFile(yamlPath);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
if (err.code !== "ENOENT") {
|
|
51
|
+
throw new error_1.FirebaseError(`Unexpected error trying to load ${yamlPath}`, {
|
|
52
|
+
original: (0, error_1.getError)(err),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return new yaml.Document();
|
|
56
|
+
}
|
|
46
57
|
return yaml.parseDocument(raw);
|
|
47
58
|
}
|
|
48
59
|
exports.load = load;
|
|
@@ -79,13 +90,13 @@ function upsertEnv(document, env) {
|
|
|
79
90
|
envs.add(envYaml);
|
|
80
91
|
}
|
|
81
92
|
exports.upsertEnv = upsertEnv;
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
const dynamicDispatch = exports;
|
|
94
|
+
async function maybeAddSecretToYaml(secretName, fileName = exports.APPHOSTING_BASE_YAML_FILE) {
|
|
84
95
|
const backendRoot = dynamicDispatch.discoverBackendRoot(process.cwd());
|
|
85
96
|
let path;
|
|
86
97
|
let projectYaml;
|
|
87
98
|
if (backendRoot) {
|
|
88
|
-
path = (0, path_1.join)(backendRoot,
|
|
99
|
+
path = (0, path_1.join)(backendRoot, fileName);
|
|
89
100
|
projectYaml = dynamicDispatch.load(path);
|
|
90
101
|
}
|
|
91
102
|
else {
|
|
@@ -95,20 +106,20 @@ async function maybeAddSecretToYaml(secretName) {
|
|
|
95
106
|
return;
|
|
96
107
|
}
|
|
97
108
|
const addToYaml = await prompt.confirm({
|
|
98
|
-
message:
|
|
109
|
+
message: `Would you like to add this secret to ${fileName}?`,
|
|
99
110
|
default: true,
|
|
100
111
|
});
|
|
101
112
|
if (!addToYaml) {
|
|
102
113
|
return;
|
|
103
114
|
}
|
|
104
115
|
if (!path) {
|
|
105
|
-
path = await prompt.
|
|
106
|
-
message:
|
|
116
|
+
path = await prompt.input({
|
|
117
|
+
message: `It looks like you don't have an ${fileName} yet. Where would you like to store it?`,
|
|
107
118
|
default: process.cwd(),
|
|
108
119
|
});
|
|
109
|
-
path = (0, path_1.join)(path,
|
|
120
|
+
path = (0, path_1.join)(path, fileName);
|
|
110
121
|
}
|
|
111
|
-
const envName = await dialogs.envVarForSecret(secretName);
|
|
122
|
+
const envName = await dialogs.envVarForSecret(secretName, fileName === exports.APPHOSTING_EMULATORS_YAML_FILE);
|
|
112
123
|
dynamicDispatch.upsertEnv(projectYaml, {
|
|
113
124
|
variable: envName,
|
|
114
125
|
secret: secretName,
|
|
@@ -116,90 +127,99 @@ async function maybeAddSecretToYaml(secretName) {
|
|
|
116
127
|
dynamicDispatch.store(path, projectYaml);
|
|
117
128
|
}
|
|
118
129
|
exports.maybeAddSecretToYaml = maybeAddSecretToYaml;
|
|
119
|
-
async function
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const secretMaterial = await (0, secrets_1.fetchSecrets)(projectId, secretsToExport);
|
|
148
|
-
for (const [key, value] of secretMaterial) {
|
|
149
|
-
localAppHostingConfig.addEnvironmentVariable({
|
|
150
|
-
variable: key,
|
|
151
|
-
value: value,
|
|
152
|
-
availability: ["RUNTIME"],
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
localAppHostingConfig.clearSecrets();
|
|
156
|
-
localAppHostingConfig.upsertFile(localAppHostingConfigPath);
|
|
157
|
-
logger_1.logger.info(`Wrote secrets as environment variables to ${exports.APPHOSTING_LOCAL_YAML_FILE}.`);
|
|
158
|
-
(0, utils_2.updateOrCreateGitignore)(projectRoot, [exports.APPHOSTING_LOCAL_YAML_FILE]);
|
|
159
|
-
logger_1.logger.info(`${exports.APPHOSTING_LOCAL_YAML_FILE} has been automatically added to your .gitignore.`);
|
|
160
|
-
}
|
|
161
|
-
exports.exportConfig = exportConfig;
|
|
162
|
-
async function loadConfigForEnvironment(envYamlPath, baseYamlPath) {
|
|
163
|
-
const envYamlConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(envYamlPath);
|
|
164
|
-
if (baseYamlPath) {
|
|
165
|
-
const baseConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(baseYamlPath);
|
|
166
|
-
baseConfig.merge(envYamlConfig);
|
|
167
|
-
return baseConfig;
|
|
168
|
-
}
|
|
169
|
-
return envYamlConfig;
|
|
170
|
-
}
|
|
171
|
-
exports.loadConfigForEnvironment = loadConfigForEnvironment;
|
|
172
|
-
async function loadConfigToExportSecrets(cwd, userGivenConfigFile) {
|
|
173
|
-
if (userGivenConfigFile && !exports.APPHOSTING_YAML_FILE_REGEX.test(userGivenConfigFile)) {
|
|
174
|
-
throw new error_1.FirebaseError("Invalid apphosting yaml config file provided. File must be in format: 'apphosting.yaml' or 'apphosting.<environment>.yaml'");
|
|
175
|
-
}
|
|
176
|
-
const allConfigs = getValidConfigs(cwd);
|
|
177
|
-
let userGivenConfigFilePath;
|
|
178
|
-
if (userGivenConfigFile) {
|
|
179
|
-
if (!allConfigs.has(userGivenConfigFile)) {
|
|
180
|
-
throw new error_1.FirebaseError(`The provided app hosting config file "${userGivenConfigFile}" does not exist`);
|
|
130
|
+
async function maybeGenerateEmulatorYaml(projectId, backendRoot) {
|
|
131
|
+
const basePath = dynamicDispatch.discoverBackendRoot(backendRoot) || backendRoot;
|
|
132
|
+
if (fs.fileExistsSync((0, path_1.join)(basePath, exports.APPHOSTING_EMULATORS_YAML_FILE))) {
|
|
133
|
+
logger_1.logger.debug("apphosting.emulator.yaml already exists, skipping generation and secrets access prompt");
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
let baseConfig;
|
|
137
|
+
try {
|
|
138
|
+
baseConfig = await yaml_1.AppHostingYamlConfig.loadFromFile((0, path_1.join)(basePath, exports.APPHOSTING_BASE_YAML_FILE));
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
baseConfig = yaml_1.AppHostingYamlConfig.empty();
|
|
142
|
+
}
|
|
143
|
+
const createFile = await prompt.confirm({
|
|
144
|
+
message: "The App Hosting emulator uses a file called apphosting.emulator.yaml to override " +
|
|
145
|
+
"values in apphosting.yaml for local testing. This codebase does not have one, would you like " +
|
|
146
|
+
"to create it?",
|
|
147
|
+
default: true,
|
|
148
|
+
});
|
|
149
|
+
if (!createFile) {
|
|
150
|
+
return (0, yaml_1.toEnvList)(baseConfig.env);
|
|
151
|
+
}
|
|
152
|
+
const newEnv = await dynamicDispatch.overrideChosenEnv(projectId, baseConfig.env || {});
|
|
153
|
+
const envList = Object.entries(newEnv);
|
|
154
|
+
if (envList.length) {
|
|
155
|
+
const newYaml = new yaml.Document();
|
|
156
|
+
for (const [variable, env] of envList) {
|
|
157
|
+
dynamicDispatch.upsertEnv(newYaml, { variable, ...env });
|
|
181
158
|
}
|
|
182
|
-
|
|
159
|
+
dynamicDispatch.store((0, path_1.join)(basePath, exports.APPHOSTING_EMULATORS_YAML_FILE), newYaml);
|
|
183
160
|
}
|
|
184
161
|
else {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
162
|
+
const sample = "env:\n" +
|
|
163
|
+
"#- variable: ENV_VAR_NAME\n" +
|
|
164
|
+
"# value: plaintext value\n" +
|
|
165
|
+
"#- variable: SECRET_ENV_VAR_NAME\n" +
|
|
166
|
+
"# secret: cloud-secret-manager-id\n";
|
|
167
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(basePath, exports.APPHOSTING_EMULATORS_YAML_FILE), sample);
|
|
168
|
+
}
|
|
169
|
+
return (0, yaml_1.toEnvList)({ ...baseConfig.env, ...newEnv });
|
|
170
|
+
}
|
|
171
|
+
exports.maybeGenerateEmulatorYaml = maybeGenerateEmulatorYaml;
|
|
172
|
+
async function overrideChosenEnv(projectId, env) {
|
|
173
|
+
const names = Object.keys(env);
|
|
174
|
+
if (!names.length) {
|
|
175
|
+
return {};
|
|
176
|
+
}
|
|
177
|
+
const toOverwrite = await prompt.checkbox({
|
|
178
|
+
message: "Which environment variables would you like to override?",
|
|
179
|
+
choices: names,
|
|
180
|
+
});
|
|
181
|
+
if (!projectId && toOverwrite.some((name) => "secret" in env[name])) {
|
|
182
|
+
throw new error_1.FirebaseError(`Need a project ID to overwrite a secret. Either use ${clc.bold("firebase use")} or pass the ${clc.bold("--project")} flag`);
|
|
183
|
+
}
|
|
184
|
+
const newEnv = {};
|
|
185
|
+
for (const name of toOverwrite) {
|
|
186
|
+
if ("value" in env[name]) {
|
|
187
|
+
const newValue = await prompt.input(`What new value would you like for plaintext ${name}?`);
|
|
188
|
+
newEnv[name] = { variable: name, value: newValue };
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
let secretRef;
|
|
192
|
+
let action = "pick-new";
|
|
193
|
+
while (action === "pick-new") {
|
|
194
|
+
secretRef = await prompt.input({
|
|
195
|
+
message: `What would you like to name the secret reference for ${name}?`,
|
|
196
|
+
default: suggestedTestKeyName(name),
|
|
197
|
+
});
|
|
198
|
+
if (await csm.secretExists(projectId, secretRef)) {
|
|
199
|
+
action = await prompt.select({
|
|
200
|
+
message: "This secret reference already exists, would you like to reuse it or create a new one?",
|
|
201
|
+
choices: [
|
|
202
|
+
{ name: "Reuse it", value: "reuse" },
|
|
203
|
+
{ name: "Create a new one", value: "pick-new" },
|
|
204
|
+
],
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
action = "create";
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
newEnv[name] = { variable: name, secret: secretRef };
|
|
212
|
+
if (action === "reuse") {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const secretValue = await prompt.password(`What new value would you like for secret ${name} [input is hidden]?`);
|
|
216
|
+
await csm.createSecret(projectId, secretRef, { [csm.FIREBASE_MANAGED]: "apphosting" });
|
|
217
|
+
await csm.addVersion(projectId, secretRef, secretValue);
|
|
189
218
|
}
|
|
190
|
-
|
|
191
|
-
return await loadConfigForEnvironment(userGivenConfigFilePath, baseFilePath);
|
|
219
|
+
return newEnv;
|
|
192
220
|
}
|
|
193
|
-
exports.
|
|
194
|
-
function
|
|
195
|
-
|
|
196
|
-
if (appHostingConfigPaths.length === 0) {
|
|
197
|
-
throw new error_1.FirebaseError("No apphosting.*.yaml configs found");
|
|
198
|
-
}
|
|
199
|
-
const fileNameToPathMap = new Map();
|
|
200
|
-
for (const path of appHostingConfigPaths) {
|
|
201
|
-
const fileName = (0, path_1.basename)(path);
|
|
202
|
-
fileNameToPathMap.set(fileName, path);
|
|
203
|
-
}
|
|
204
|
-
return fileNameToPathMap;
|
|
221
|
+
exports.overrideChosenEnv = overrideChosenEnv;
|
|
222
|
+
function suggestedTestKeyName(variable) {
|
|
223
|
+
return "test-" + variable.replace(/_/g, "-").toLowerCase();
|
|
205
224
|
}
|
|
225
|
+
exports.suggestedTestKeyName = suggestedTestKeyName;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGitHubCommit = exports.getGitHubBranch = exports.fetchRepositoryCloneUris = exports.listAppHostingConnections = exports.getOrCreateRepository = exports.getOrCreateConnection = exports.createConnection = exports.ensureSecretManagerAdminGrant = exports.promptGitHubBranch = exports.getOrCreateOauthConnection = exports.listValidInstallations = exports.promptGitHubInstallation = exports.getConnectionForInstallation = exports.linkGitHubRepository = exports.
|
|
3
|
+
exports.getGitHubCommit = exports.getGitHubBranch = exports.fetchRepositoryCloneUris = exports.listAppHostingConnections = exports.getOrCreateRepository = exports.getOrCreateConnection = exports.createConnection = exports.ensureSecretManagerAdminGrant = exports.promptGitHubBranch = exports.getOrCreateOauthConnection = exports.listValidInstallations = exports.promptGitHubInstallation = exports.getConnectionForInstallation = exports.linkGitHubRepository = exports.getOrCreateFullyInstalledGithubConnection = exports.generateConnectionId = exports.generateRepositoryId = exports.extractRepoSlugFromUri = exports.parseConnectionName = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const devConnect = require("../gcp/devConnect");
|
|
6
6
|
const rm = require("../gcp/resourceManager");
|
|
@@ -11,11 +11,9 @@ const prompt_1 = require("../prompt");
|
|
|
11
11
|
const getProjectNumber_1 = require("../getProjectNumber");
|
|
12
12
|
const api_1 = require("../api");
|
|
13
13
|
const fuzzy = require("fuzzy");
|
|
14
|
-
const inquirer = require("inquirer");
|
|
15
14
|
const apiv2_1 = require("../apiv2");
|
|
16
15
|
const githubApiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.githubApiOrigin)(), auth: false });
|
|
17
16
|
const APPHOSTING_CONN_PATTERN = /.+\/apphosting-github-conn-.+$/;
|
|
18
|
-
const APPHOSTING_OAUTH_CONN_NAME = "firebase-app-hosting-github-oauth";
|
|
19
17
|
const CONNECTION_NAME_REGEX = /^projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/connections\/(?<id>[^\/]+)$/;
|
|
20
18
|
function parseConnectionName(name) {
|
|
21
19
|
const match = CONNECTION_NAME_REGEX.exec(name);
|
|
@@ -48,13 +46,14 @@ function generateRepositoryId(remoteUri) {
|
|
|
48
46
|
return extractRepoSlugFromUri(remoteUri)?.replaceAll("/", "-");
|
|
49
47
|
}
|
|
50
48
|
exports.generateRepositoryId = generateRepositoryId;
|
|
51
|
-
|
|
49
|
+
const generateConnectionId = () => {
|
|
52
50
|
const randomHash = Math.random().toString(36).slice(6);
|
|
53
51
|
return `apphosting-github-conn-${randomHash}`;
|
|
54
|
-
}
|
|
52
|
+
};
|
|
53
|
+
exports.generateConnectionId = generateConnectionId;
|
|
55
54
|
const ADD_ACCOUNT_CHOICE = "@ADD_ACCOUNT";
|
|
56
55
|
const MANAGE_INSTALLATION_CHOICE = "@MANAGE_INSTALLATION";
|
|
57
|
-
async function
|
|
56
|
+
async function getOrCreateFullyInstalledGithubConnection(projectId, location, createConnectionId) {
|
|
58
57
|
utils.logBullet(clc.bold(`${clc.yellow("===")} Import a GitHub repository`));
|
|
59
58
|
if (createConnectionId) {
|
|
60
59
|
try {
|
|
@@ -75,10 +74,7 @@ async function getOrCreateGithubConnectionWithSentinel(projectId, location, crea
|
|
|
75
74
|
const apphostingGitHubInstallationURL = (0, api_1.apphostingGitHubAppInstallationURL)();
|
|
76
75
|
utils.logBullet(apphostingGitHubInstallationURL);
|
|
77
76
|
await utils.openInBrowser(apphostingGitHubInstallationURL);
|
|
78
|
-
await (0, prompt_1.
|
|
79
|
-
type: "input",
|
|
80
|
-
message: "Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.",
|
|
81
|
-
});
|
|
77
|
+
await (0, prompt_1.input)("Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.");
|
|
82
78
|
installationId = await promptGitHubInstallation(projectId, location, oauthConn);
|
|
83
79
|
}
|
|
84
80
|
const connectionMatchingInstallation = await getConnectionForInstallation(projectId, location, installationId);
|
|
@@ -90,14 +86,14 @@ async function getOrCreateGithubConnectionWithSentinel(projectId, location, crea
|
|
|
90
86
|
}
|
|
91
87
|
}
|
|
92
88
|
if (!createConnectionId) {
|
|
93
|
-
createConnectionId = generateConnectionId();
|
|
89
|
+
createConnectionId = (0, exports.generateConnectionId)();
|
|
94
90
|
}
|
|
95
91
|
const connection = await createFullyInstalledConnection(projectId, location, createConnectionId, oauthConn, installationId);
|
|
96
92
|
return connection;
|
|
97
93
|
}
|
|
98
|
-
exports.
|
|
94
|
+
exports.getOrCreateFullyInstalledGithubConnection = getOrCreateFullyInstalledGithubConnection;
|
|
99
95
|
async function linkGitHubRepository(projectId, location, createConnectionId) {
|
|
100
|
-
const connection = await
|
|
96
|
+
const connection = await getOrCreateFullyInstalledGithubConnection(projectId, location, createConnectionId);
|
|
101
97
|
let repoCloneUri;
|
|
102
98
|
do {
|
|
103
99
|
if (repoCloneUri === MANAGE_INSTALLATION_CHOICE) {
|
|
@@ -124,10 +120,7 @@ async function createFullyInstalledConnection(projectId, location, connectionId,
|
|
|
124
120
|
const targetUri = conn.installationState.actionUri;
|
|
125
121
|
utils.logBullet(targetUri);
|
|
126
122
|
await utils.openInBrowser(targetUri);
|
|
127
|
-
await (0, prompt_1.
|
|
128
|
-
type: "input",
|
|
129
|
-
message: "Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.",
|
|
130
|
-
});
|
|
123
|
+
await (0, prompt_1.input)("Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.");
|
|
131
124
|
conn = await devConnect.getConnection(projectId, location, connectionId);
|
|
132
125
|
}
|
|
133
126
|
return conn;
|
|
@@ -140,10 +133,7 @@ async function manageInstallation(connection) {
|
|
|
140
133
|
}
|
|
141
134
|
utils.logBullet(targetUri);
|
|
142
135
|
await utils.openInBrowser(targetUri);
|
|
143
|
-
await (0, prompt_1.
|
|
144
|
-
type: "input",
|
|
145
|
-
message: "Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.",
|
|
146
|
-
});
|
|
136
|
+
await (0, prompt_1.input)("Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.");
|
|
147
137
|
}
|
|
148
138
|
async function getConnectionForInstallation(projectId, location, installationId) {
|
|
149
139
|
const connections = await listAppHostingConnections(projectId, location);
|
|
@@ -160,30 +150,26 @@ async function getConnectionForInstallation(projectId, location, installationId)
|
|
|
160
150
|
exports.getConnectionForInstallation = getConnectionForInstallation;
|
|
161
151
|
async function promptGitHubInstallation(projectId, location, connection) {
|
|
162
152
|
const installations = await listValidInstallations(projectId, location, connection);
|
|
163
|
-
const installationName = await (0, prompt_1.
|
|
164
|
-
type: "autocomplete",
|
|
165
|
-
name: "installation",
|
|
153
|
+
const installationName = await (0, prompt_1.search)({
|
|
166
154
|
message: "Which GitHub account do you want to use?",
|
|
167
|
-
source: (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
]));
|
|
186
|
-
},
|
|
155
|
+
source: (input = "") => [
|
|
156
|
+
new prompt_1.Separator(),
|
|
157
|
+
{
|
|
158
|
+
name: "Missing an account? Select this option to add a GitHub account",
|
|
159
|
+
value: ADD_ACCOUNT_CHOICE,
|
|
160
|
+
},
|
|
161
|
+
new prompt_1.Separator(),
|
|
162
|
+
...fuzzy
|
|
163
|
+
.filter(input, installations, {
|
|
164
|
+
extract: (installation) => installation.name || "",
|
|
165
|
+
})
|
|
166
|
+
.map((result) => {
|
|
167
|
+
return {
|
|
168
|
+
name: result.original.name || "",
|
|
169
|
+
value: result.original.id,
|
|
170
|
+
};
|
|
171
|
+
}),
|
|
172
|
+
],
|
|
187
173
|
});
|
|
188
174
|
return installationName;
|
|
189
175
|
}
|
|
@@ -201,26 +187,17 @@ async function listValidInstallations(projectId, location, connection) {
|
|
|
201
187
|
exports.listValidInstallations = listValidInstallations;
|
|
202
188
|
async function getOrCreateOauthConnection(projectId, location) {
|
|
203
189
|
let conn;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
catch (err) {
|
|
208
|
-
if (err.status === 404) {
|
|
209
|
-
await ensureSecretManagerAdminGrant(projectId);
|
|
210
|
-
conn = await createConnection(projectId, location, APPHOSTING_OAUTH_CONN_NAME);
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
throw err;
|
|
214
|
-
}
|
|
190
|
+
const completedConnections = await listAppHostingConnections(projectId, location);
|
|
191
|
+
if (completedConnections.length > 0) {
|
|
192
|
+
return completedConnections[0];
|
|
215
193
|
}
|
|
194
|
+
await ensureSecretManagerAdminGrant(projectId);
|
|
195
|
+
conn = await createConnection(projectId, location, (0, exports.generateConnectionId)());
|
|
216
196
|
while (conn.installationState.stage === "PENDING_USER_OAUTH") {
|
|
217
197
|
utils.logBullet("Please authorize the Firebase GitHub app by visiting this url:");
|
|
218
198
|
const { url, cleanup } = await utils.openInBrowserPopup(conn.installationState.actionUri, "Authorize the GitHub app");
|
|
219
199
|
utils.logBullet(`\t${url}`);
|
|
220
|
-
await (0, prompt_1.
|
|
221
|
-
type: "input",
|
|
222
|
-
message: "Press Enter once you have authorized the GitHub App.",
|
|
223
|
-
});
|
|
200
|
+
await (0, prompt_1.input)("Press Enter once you have authorized the GitHub App.");
|
|
224
201
|
cleanup();
|
|
225
202
|
const { projectId, location, id } = parseConnectionName(conn.name);
|
|
226
203
|
conn = await devConnect.getConnection(projectId, location, id);
|
|
@@ -231,51 +208,42 @@ async function getOrCreateOauthConnection(projectId, location) {
|
|
|
231
208
|
exports.getOrCreateOauthConnection = getOrCreateOauthConnection;
|
|
232
209
|
async function promptCloneUri(projectId, connection) {
|
|
233
210
|
const cloneUris = await fetchRepositoryCloneUris(projectId, connection);
|
|
234
|
-
const cloneUri = await (0, prompt_1.
|
|
235
|
-
type: "autocomplete",
|
|
236
|
-
name: "cloneUri",
|
|
211
|
+
const cloneUri = await (0, prompt_1.search)({
|
|
237
212
|
message: "Which GitHub repo do you want to deploy?",
|
|
238
|
-
source: (
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
]));
|
|
257
|
-
},
|
|
213
|
+
source: (input = "") => [
|
|
214
|
+
new prompt_1.Separator(),
|
|
215
|
+
{
|
|
216
|
+
name: "Missing a repo? Select this option to configure your GitHub connection settings",
|
|
217
|
+
value: MANAGE_INSTALLATION_CHOICE,
|
|
218
|
+
},
|
|
219
|
+
new prompt_1.Separator(),
|
|
220
|
+
...fuzzy
|
|
221
|
+
.filter(input, cloneUris, {
|
|
222
|
+
extract: (uri) => extractRepoSlugFromUri(uri) || "",
|
|
223
|
+
})
|
|
224
|
+
.map((result) => {
|
|
225
|
+
return {
|
|
226
|
+
name: extractRepoSlugFromUri(result.original) || "",
|
|
227
|
+
value: result.original,
|
|
228
|
+
};
|
|
229
|
+
}),
|
|
230
|
+
],
|
|
258
231
|
});
|
|
259
232
|
return cloneUri;
|
|
260
233
|
}
|
|
261
234
|
async function promptGitHubBranch(repoLink) {
|
|
262
235
|
const branches = await devConnect.listAllBranches(repoLink.name);
|
|
263
|
-
const branch = await (0, prompt_1.
|
|
264
|
-
type: "autocomplete",
|
|
265
|
-
name: "branch",
|
|
236
|
+
const branch = await (0, prompt_1.search)({
|
|
266
237
|
message: "Pick a branch for continuous deployment",
|
|
267
|
-
source: (
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
]));
|
|
276
|
-
},
|
|
238
|
+
source: (input = "") => [
|
|
239
|
+
...fuzzy.filter(input, Array.from(branches)).map((result) => {
|
|
240
|
+
return {
|
|
241
|
+
name: result.original,
|
|
242
|
+
value: result.original,
|
|
243
|
+
};
|
|
244
|
+
}),
|
|
245
|
+
],
|
|
277
246
|
});
|
|
278
|
-
utils.logWarning(`The branch "${branch}" does not exist on "${extractRepoSlugFromUri(repoLink.cloneUri) ?? ""}". Please enter a valid branch for this repo.`);
|
|
279
247
|
return branch;
|
|
280
248
|
}
|
|
281
249
|
exports.promptGitHubBranch = promptGitHubBranch;
|
|
@@ -288,10 +256,7 @@ async function ensureSecretManagerAdminGrant(projectId) {
|
|
|
288
256
|
return;
|
|
289
257
|
}
|
|
290
258
|
utils.logBullet("To create a new GitHub connection, Secret Manager Admin role (roles/secretmanager.admin) is required on the Developer Connect Service Agent.");
|
|
291
|
-
const grant = await (0, prompt_1.
|
|
292
|
-
type: "confirm",
|
|
293
|
-
message: "Grant the required role to the Developer Connect Service Agent?",
|
|
294
|
-
});
|
|
259
|
+
const grant = await (0, prompt_1.confirm)("Grant the required role to the Developer Connect Service Agent?");
|
|
295
260
|
if (!grant) {
|
|
296
261
|
utils.logBullet("You, or your project administrator, should run the following command to grant the required role:\n\n" +
|
|
297
262
|
"You, or your project adminstrator, can run the following command to grant the required role manually:\n\n" +
|
package/lib/apphosting/repo.js
CHANGED
|
@@ -11,7 +11,6 @@ const error_1 = require("../error");
|
|
|
11
11
|
const prompt_1 = require("../prompt");
|
|
12
12
|
const getProjectNumber_1 = require("../getProjectNumber");
|
|
13
13
|
const fuzzy = require("fuzzy");
|
|
14
|
-
const inquirer = require("inquirer");
|
|
15
14
|
const APPHOSTING_CONN_PATTERN = /.+\/apphosting-github-conn-.+$/;
|
|
16
15
|
const APPHOSTING_OAUTH_CONN_NAME = "apphosting-github-oauth";
|
|
17
16
|
const CONNECTION_NAME_REGEX = /^projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/connections\/(?<id>[^\/]+)$/;
|
|
@@ -86,10 +85,7 @@ async function createFullyInstalledConnection(projectId, location, connectionId,
|
|
|
86
85
|
const targetUri = conn.installationState.actionUri;
|
|
87
86
|
utils.logBullet(targetUri);
|
|
88
87
|
await utils.openInBrowser(targetUri);
|
|
89
|
-
await (0, prompt_1.
|
|
90
|
-
type: "input",
|
|
91
|
-
message: "Press Enter once you have installed or configured the Cloud Build GitHub app to access your GitHub repo.",
|
|
92
|
-
});
|
|
88
|
+
await (0, prompt_1.input)("Press Enter once you have installed or configured the Cloud Build GitHub app to access your GitHub repo.");
|
|
93
89
|
conn = await gcb.getConnection(projectId, location, connectionId);
|
|
94
90
|
}
|
|
95
91
|
return conn;
|
|
@@ -113,10 +109,7 @@ async function getOrCreateOauthConnection(projectId, location) {
|
|
|
113
109
|
utils.logBullet("Sign in to GitHub and authorize Cloud Build GitHub app:");
|
|
114
110
|
const { url, cleanup } = await utils.openInBrowserPopup(conn.installationState.actionUri, "Authorize the GitHub app");
|
|
115
111
|
utils.logBullet(`\t${url}`);
|
|
116
|
-
await (0, prompt_1.
|
|
117
|
-
type: "input",
|
|
118
|
-
message: "Press Enter once you have authorized the app",
|
|
119
|
-
});
|
|
112
|
+
await (0, prompt_1.input)("Press Enter once you have authorized the app");
|
|
120
113
|
cleanup();
|
|
121
114
|
const { projectId, location, id } = parseConnectionName(conn.name);
|
|
122
115
|
conn = await gcb.getConnection(projectId, location, id);
|
|
@@ -126,30 +119,26 @@ async function getOrCreateOauthConnection(projectId, location) {
|
|
|
126
119
|
exports.getOrCreateOauthConnection = getOrCreateOauthConnection;
|
|
127
120
|
async function promptRepositoryUri(projectId, connections) {
|
|
128
121
|
const { repos, remoteUriToConnection } = await fetchAllRepositories(projectId, connections);
|
|
129
|
-
const remoteUri = await (0, prompt_1.
|
|
130
|
-
type: "autocomplete",
|
|
131
|
-
name: "remoteUri",
|
|
122
|
+
const remoteUri = await (0, prompt_1.search)({
|
|
132
123
|
message: "Which GitHub repo do you want to deploy?",
|
|
133
|
-
source: (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
]));
|
|
152
|
-
},
|
|
124
|
+
source: (input) => [
|
|
125
|
+
new prompt_1.Separator(),
|
|
126
|
+
{
|
|
127
|
+
name: "Missing a repo? Select this option to configure your GitHub connection settings",
|
|
128
|
+
value: ADD_CONN_CHOICE,
|
|
129
|
+
},
|
|
130
|
+
new prompt_1.Separator(),
|
|
131
|
+
...fuzzy
|
|
132
|
+
.filter(input ?? "", repos, {
|
|
133
|
+
extract: (repo) => extractRepoSlugFromUri(repo.remoteUri) || "",
|
|
134
|
+
})
|
|
135
|
+
.map((result) => {
|
|
136
|
+
return {
|
|
137
|
+
name: extractRepoSlugFromUri(result.original.remoteUri) || "",
|
|
138
|
+
value: result.original.remoteUri,
|
|
139
|
+
};
|
|
140
|
+
}),
|
|
141
|
+
],
|
|
153
142
|
});
|
|
154
143
|
return { remoteUri, connection: remoteUriToConnection[remoteUri] };
|
|
155
144
|
}
|
|
@@ -161,10 +150,7 @@ async function ensureSecretManagerAdminGrant(projectId) {
|
|
|
161
150
|
return;
|
|
162
151
|
}
|
|
163
152
|
utils.logBullet("To create a new GitHub connection, Secret Manager Admin role (roles/secretmanager.admin) is required on the Cloud Build Service Agent.");
|
|
164
|
-
const grant = await (0, prompt_1.
|
|
165
|
-
type: "confirm",
|
|
166
|
-
message: "Grant the required role to the Cloud Build Service Agent?",
|
|
167
|
-
});
|
|
153
|
+
const grant = await (0, prompt_1.confirm)("Grant the required role to the Cloud Build Service Agent?");
|
|
168
154
|
if (!grant) {
|
|
169
155
|
utils.logBullet("You, or your project administrator, should run the following command to grant the required role:\n\n" +
|
|
170
156
|
"You, or your project adminstrator, can run the following command to grant the required role manually:\n\n" +
|