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
|
@@ -17,18 +17,12 @@ const apphostingPollerOptions = {
|
|
|
17
17
|
maxBackoff: 10000,
|
|
18
18
|
};
|
|
19
19
|
const GIT_COMMIT_SHA_REGEX = /^(?:[0-9a-f]{40}|[0-9a-f]{7})$/;
|
|
20
|
-
async function createRollout(backendId, projectId,
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
location = apphosting.parseBackendName(backend.name).location;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
backend = await (0, backend_1.getBackendForLocation)(projectId, location, backendId);
|
|
28
|
-
}
|
|
29
|
-
if (!backend.codebase.repository) {
|
|
30
|
-
throw new error_1.FirebaseError(`Backend ${backendId} is misconfigured due to missing a connected repository. You can delete and recreate your backend using 'firebase apphosting:backends:delete' and 'firebase apphosting:backends:create'.`);
|
|
20
|
+
async function createRollout(backendId, projectId, branch, commit, force) {
|
|
21
|
+
const backend = await (0, backend_1.getBackend)(projectId, backendId);
|
|
22
|
+
if (!backend.codebase || !backend.codebase.repository) {
|
|
23
|
+
throw new error_1.FirebaseError(`Backend ${backendId} is missing a connected repository. If you would like to deploy from a branch or commit of a GitHub repository, you can connect one through the Firebase Console. If you would like to deploy from local source, run 'firebase deploy'.`);
|
|
31
24
|
}
|
|
25
|
+
const { location } = apphosting.parseBackendName(backend.name);
|
|
32
26
|
const { repoLink, owner, repo, readToken } = await (0, devConnect_1.getRepoDetailsFromBackend)(projectId, location, backend.codebase.repository);
|
|
33
27
|
let targetCommit;
|
|
34
28
|
if (branch) {
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.envVarForSecret = exports.selectBackendServiceAccounts = exports.GRANT_ACCESS_IN_FUTURE = exports.WARN_NO_BACKENDS = exports.selectFromMetadata = exports.tableForBackends = exports.serviceAccountDisplay = exports.toMetadata = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
|
-
const Table = require("cli-
|
|
5
|
+
const Table = require("cli-table3");
|
|
6
6
|
const _1 = require(".");
|
|
7
7
|
const apphosting = require("../../gcp/apphosting");
|
|
8
8
|
const prompt = require("../../prompt");
|
|
9
9
|
const utils = require("../../utils");
|
|
10
10
|
const logger_1 = require("../../logger");
|
|
11
11
|
const env = require("../../functions/env");
|
|
12
|
-
function toMetadata(projectNumber, backends) {
|
|
12
|
+
async function toMetadata(projectNumber, backends) {
|
|
13
13
|
const metadata = [];
|
|
14
14
|
for (const backend of backends) {
|
|
15
15
|
const [, , , location, , id] = backend.name.split("/");
|
|
16
|
-
metadata.push({ location, id, ...(0, _1.serviceAccountsForBackend)(projectNumber, backend) });
|
|
16
|
+
metadata.push({ location, id, ...(await (0, _1.serviceAccountsForBackend)(projectNumber, backend)) });
|
|
17
17
|
}
|
|
18
18
|
return metadata.sort((left, right) => {
|
|
19
19
|
const cmplocation = left.location.localeCompare(right.location);
|
|
@@ -86,12 +86,12 @@ async function selectBackendServiceAccounts(projectNumber, projectId, options) {
|
|
|
86
86
|
message: "To use this secret, your backend's service account must be granted access. Would you like to grant access now?",
|
|
87
87
|
});
|
|
88
88
|
if (grant) {
|
|
89
|
-
return (0, _1.toMulti)((0, _1.serviceAccountsForBackend)(projectNumber, listBackends.backends[0]));
|
|
89
|
+
return (0, _1.toMulti)(await (0, _1.serviceAccountsForBackend)(projectNumber, listBackends.backends[0]));
|
|
90
90
|
}
|
|
91
91
|
utils.logBullet(exports.GRANT_ACCESS_IN_FUTURE);
|
|
92
92
|
return { buildServiceAccounts: [], runServiceAccounts: [] };
|
|
93
93
|
}
|
|
94
|
-
const metadata = toMetadata(projectNumber, listBackends.backends);
|
|
94
|
+
const metadata = await toMetadata(projectNumber, listBackends.backends);
|
|
95
95
|
if (metadata.every(matchesServiceAccounts(metadata[0]))) {
|
|
96
96
|
utils.logBullet("To use this secret, your backend's service account must be granted access.");
|
|
97
97
|
utils.logBullet("All of your backends share the following " +
|
|
@@ -117,16 +117,15 @@ async function selectBackendServiceAccounts(projectNumber, projectId, options) {
|
|
|
117
117
|
const table = new Table({
|
|
118
118
|
head: tableData[0],
|
|
119
119
|
style: { head: ["green"] },
|
|
120
|
-
rows: tableData[1],
|
|
121
120
|
});
|
|
121
|
+
table.push(...tableData[1]);
|
|
122
122
|
logger_1.logger.info(table.toString());
|
|
123
123
|
const allAccounts = metadata.reduce((accum, row) => {
|
|
124
124
|
accum.add(row.buildServiceAccount);
|
|
125
125
|
accum.add(row.runServiceAccount);
|
|
126
126
|
return accum;
|
|
127
127
|
}, new Set());
|
|
128
|
-
const chosen = await prompt.
|
|
129
|
-
type: "checkbox",
|
|
128
|
+
const chosen = await prompt.checkbox({
|
|
130
129
|
message: "Which service accounts would you like to grant access? " +
|
|
131
130
|
"Press Space to select accounts, then Enter to confirm your choices.",
|
|
132
131
|
choices: [...allAccounts.values()].sort(),
|
|
@@ -143,8 +142,11 @@ function toUpperSnakeCase(key) {
|
|
|
143
142
|
.replace(/([a-z])([A-Z])/g, "$1_$2")
|
|
144
143
|
.toUpperCase();
|
|
145
144
|
}
|
|
146
|
-
async function envVarForSecret(secret) {
|
|
147
|
-
|
|
145
|
+
async function envVarForSecret(secret, trimTestPrefix = false) {
|
|
146
|
+
let upper = toUpperSnakeCase(secret);
|
|
147
|
+
if (trimTestPrefix && upper.startsWith("TEST_")) {
|
|
148
|
+
upper = upper.substring("TEST_".length);
|
|
149
|
+
}
|
|
148
150
|
if (upper === secret) {
|
|
149
151
|
try {
|
|
150
152
|
env.validateKey(secret);
|
|
@@ -154,7 +156,7 @@ async function envVarForSecret(secret) {
|
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
158
|
do {
|
|
157
|
-
const test = await prompt.
|
|
159
|
+
const test = await prompt.input({
|
|
158
160
|
message: "What environment variable name would you like to use?",
|
|
159
161
|
default: upper,
|
|
160
162
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSecretNameParts = exports.fetchSecrets = exports.upsertSecret = exports.grantSecretAccess = exports.serviceAccountsForBackend = exports.toMulti = void 0;
|
|
3
|
+
exports.getSecretNameParts = exports.fetchSecrets = exports.upsertSecret = exports.grantEmailsSecretAccess = exports.grantSecretAccess = exports.serviceAccountsForBackend = exports.toMulti = void 0;
|
|
4
4
|
const error_1 = require("../../error");
|
|
5
5
|
const gcsm = require("../../gcp/secretManager");
|
|
6
6
|
const gcb = require("../../gcp/cloudbuild");
|
|
@@ -21,7 +21,7 @@ function toMulti(accounts) {
|
|
|
21
21
|
return m;
|
|
22
22
|
}
|
|
23
23
|
exports.toMulti = toMulti;
|
|
24
|
-
function serviceAccountsForBackend(projectNumber, backend) {
|
|
24
|
+
async function serviceAccountsForBackend(projectNumber, backend) {
|
|
25
25
|
if (backend.serviceAccount) {
|
|
26
26
|
return {
|
|
27
27
|
buildServiceAccount: backend.serviceAccount,
|
|
@@ -30,7 +30,7 @@ function serviceAccountsForBackend(projectNumber, backend) {
|
|
|
30
30
|
}
|
|
31
31
|
return {
|
|
32
32
|
buildServiceAccount: gcb.getDefaultServiceAccount(projectNumber),
|
|
33
|
-
runServiceAccount: gce.getDefaultServiceAccount(projectNumber),
|
|
33
|
+
runServiceAccount: await gce.getDefaultServiceAccount(projectNumber),
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
exports.serviceAccountsForBackend = serviceAccountsForBackend;
|
|
@@ -57,16 +57,58 @@ async function grantSecretAccess(projectId, projectNumber, secretName, accounts)
|
|
|
57
57
|
catch (err) {
|
|
58
58
|
throw new error_1.FirebaseError(`Failed to get IAM bindings on secret: ${secretName}. Ensure you have the permissions to do so and try again.`, { original: (0, error_1.getError)(err) });
|
|
59
59
|
}
|
|
60
|
+
const updatedBindings = existingBindings.concat(newBindings);
|
|
60
61
|
try {
|
|
61
|
-
const updatedBindings = existingBindings.concat(newBindings);
|
|
62
62
|
await gcsm.setIamPolicy({ projectId, name: secretName }, updatedBindings);
|
|
63
63
|
}
|
|
64
64
|
catch (err) {
|
|
65
|
-
throw new error_1.FirebaseError(`Failed to set IAM bindings ${JSON.stringify(newBindings)} on secret: ${secretName}. Ensure you have the permissions to do so and try again
|
|
65
|
+
throw new error_1.FirebaseError(`Failed to set IAM bindings ${JSON.stringify(newBindings)} on secret: ${secretName}. Ensure you have the permissions to do so and try again. ` +
|
|
66
|
+
"For more information visit https://cloud.google.com/secret-manager/docs/manage-access-to-secrets#required-roles", { original: (0, error_1.getError)(err) });
|
|
66
67
|
}
|
|
67
68
|
utils.logSuccess(`Successfully set IAM bindings on secret ${secretName}.\n`);
|
|
68
69
|
}
|
|
69
70
|
exports.grantSecretAccess = grantSecretAccess;
|
|
71
|
+
async function grantEmailsSecretAccess(projectId, secretNames, emails) {
|
|
72
|
+
const typeGuesses = Object.fromEntries(emails.map((email) => [email, "user"]));
|
|
73
|
+
for (const secretName of secretNames) {
|
|
74
|
+
let existingBindings;
|
|
75
|
+
try {
|
|
76
|
+
existingBindings = (await gcsm.getIamPolicy({ projectId, name: secretName })).bindings || [];
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
throw new error_1.FirebaseError(`Failed to get IAM bindings on secret: ${secretName}. Ensure you have the permissions to do so and try again. ` +
|
|
80
|
+
"For more information visit https://cloud.google.com/secret-manager/docs/manage-access-to-secrets#required-roles", { original: (0, error_1.getError)(err) });
|
|
81
|
+
}
|
|
82
|
+
do {
|
|
83
|
+
try {
|
|
84
|
+
const newBindings = [
|
|
85
|
+
{
|
|
86
|
+
role: "roles/secretmanager.secretAccessor",
|
|
87
|
+
members: Object.entries(typeGuesses).map(([email, type]) => `${type}:${email}`),
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
const updatedBindings = existingBindings.concat(newBindings);
|
|
91
|
+
await gcsm.setIamPolicy({ projectId, name: secretName }, updatedBindings);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
if (!(err instanceof error_1.FirebaseError)) {
|
|
96
|
+
throw new error_1.FirebaseError(`Unexpected error updating IAM bindings on secret: ${secretName}`, {
|
|
97
|
+
original: (0, error_1.getError)(err),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const match = /Principal (.*) is of type "([^"]+)"/.exec(err.message);
|
|
101
|
+
if (!match) {
|
|
102
|
+
throw new error_1.FirebaseError(`Failed to set IAM bindings on secret: ${secretName}. Ensure you have the permissions to do so and try again.`, { original: (0, error_1.getError)(err) });
|
|
103
|
+
}
|
|
104
|
+
typeGuesses[match[1]] = match[2];
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
} while (true);
|
|
108
|
+
utils.logSuccess(`Successfully set IAM bindings on secret ${secretName}.\n`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.grantEmailsSecretAccess = grantEmailsSecretAccess;
|
|
70
112
|
async function upsertSecret(project, secret, location) {
|
|
71
113
|
let existing;
|
|
72
114
|
try {
|
package/lib/apphosting/utils.js
CHANGED
|
@@ -30,9 +30,7 @@ async function promptForAppHostingYaml(apphostingFileNameToPathMap, promptMessag
|
|
|
30
30
|
value: apphostingFileNameToPathMap.get(fileName),
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
|
-
const fileToExportPath = await prompt.
|
|
34
|
-
name: "apphosting-yaml",
|
|
35
|
-
type: "list",
|
|
33
|
+
const fileToExportPath = await prompt.select({
|
|
36
34
|
message: promptMessage,
|
|
37
35
|
choices: listOptions,
|
|
38
36
|
});
|
package/lib/apphosting/yaml.js
CHANGED
|
@@ -1,57 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppHostingYamlConfig = void 0;
|
|
3
|
+
exports.toEnvList = exports.toEnvMap = exports.AppHostingYamlConfig = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const config_1 = require("./config");
|
|
7
7
|
const yaml = require("yaml");
|
|
8
8
|
const jsYaml = require("js-yaml");
|
|
9
|
+
const path = require("path");
|
|
9
10
|
const fsutils_1 = require("../fsutils");
|
|
10
11
|
const error_1 = require("../error");
|
|
11
12
|
class AppHostingYamlConfig {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.env = {};
|
|
15
|
+
}
|
|
12
16
|
static async loadFromFile(filePath) {
|
|
13
|
-
const config = new AppHostingYamlConfig();
|
|
14
17
|
if (!(0, fsutils_1.fileExistsSync)(filePath)) {
|
|
15
|
-
throw new error_1.FirebaseError(
|
|
18
|
+
throw new error_1.FirebaseError(`Cannot load ${filePath} from given path, it doesn't exist`);
|
|
16
19
|
}
|
|
20
|
+
const config = new AppHostingYamlConfig();
|
|
17
21
|
const file = await (0, utils_1.readFileFromDirectory)((0, path_1.dirname)(filePath), (0, path_1.basename)(filePath));
|
|
22
|
+
config.filename = path.basename(filePath);
|
|
18
23
|
const loadedAppHostingYaml = (await (0, utils_1.wrappedSafeLoad)(file.source)) ?? {};
|
|
19
24
|
if (loadedAppHostingYaml.env) {
|
|
20
|
-
|
|
21
|
-
config._environmentVariables = parsedEnvs.environmentVariables;
|
|
22
|
-
config._secrets = parsedEnvs.secrets;
|
|
25
|
+
config.env = toEnvMap(loadedAppHostingYaml.env);
|
|
23
26
|
}
|
|
24
27
|
return config;
|
|
25
28
|
}
|
|
26
29
|
static empty() {
|
|
27
30
|
return new AppHostingYamlConfig();
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return mapToArray(this._secrets);
|
|
38
|
-
}
|
|
39
|
-
addEnvironmentVariable(env) {
|
|
40
|
-
this._environmentVariables.set(env.variable, env);
|
|
41
|
-
}
|
|
42
|
-
addSecret(secret) {
|
|
43
|
-
this._secrets.set(secret.variable, secret);
|
|
44
|
-
}
|
|
45
|
-
clearSecrets() {
|
|
46
|
-
this._secrets.clear();
|
|
47
|
-
}
|
|
48
|
-
merge(other) {
|
|
49
|
-
for (const [key, value] of other._environmentVariables) {
|
|
50
|
-
this._environmentVariables.set(key, value);
|
|
51
|
-
}
|
|
52
|
-
for (const [key, value] of other._secrets) {
|
|
53
|
-
this._secrets.set(key, value);
|
|
32
|
+
merge(other, allowSecretsToBecomePlaintext = true) {
|
|
33
|
+
if (!allowSecretsToBecomePlaintext) {
|
|
34
|
+
const wereSecrets = Object.entries(this.env)
|
|
35
|
+
.filter(([, env]) => env.secret)
|
|
36
|
+
.map(([key]) => key);
|
|
37
|
+
if (wereSecrets.some((key) => other.env[key]?.value)) {
|
|
38
|
+
throw new error_1.FirebaseError(`Cannot convert secret to plaintext in ${other.filename ?? "apphosting yaml"}`);
|
|
39
|
+
}
|
|
54
40
|
}
|
|
41
|
+
this.env = {
|
|
42
|
+
...this.env,
|
|
43
|
+
...other.env,
|
|
44
|
+
};
|
|
55
45
|
}
|
|
56
46
|
async upsertFile(filePath) {
|
|
57
47
|
let yamlConfigToWrite = {};
|
|
@@ -59,27 +49,23 @@ class AppHostingYamlConfig {
|
|
|
59
49
|
const file = await (0, utils_1.readFileFromDirectory)((0, path_1.dirname)(filePath), (0, path_1.basename)(filePath));
|
|
60
50
|
yamlConfigToWrite = await (0, utils_1.wrappedSafeLoad)(file.source);
|
|
61
51
|
}
|
|
62
|
-
yamlConfigToWrite.env =
|
|
52
|
+
yamlConfigToWrite.env = toEnvList(this.env);
|
|
63
53
|
(0, config_1.store)(filePath, yaml.parseDocument(jsYaml.dump(yamlConfigToWrite)));
|
|
64
54
|
}
|
|
65
55
|
}
|
|
66
56
|
exports.AppHostingYamlConfig = AppHostingYamlConfig;
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (env.secret) {
|
|
75
|
-
secrets.set(env.variable, env);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
environmentVariables,
|
|
80
|
-
secrets,
|
|
81
|
-
};
|
|
57
|
+
function toEnvMap(envs) {
|
|
58
|
+
return Object.fromEntries(envs.map((env) => {
|
|
59
|
+
const variable = env.variable;
|
|
60
|
+
const tmp = { ...env };
|
|
61
|
+
delete env.variable;
|
|
62
|
+
return [variable, tmp];
|
|
63
|
+
}));
|
|
82
64
|
}
|
|
83
|
-
|
|
84
|
-
|
|
65
|
+
exports.toEnvMap = toEnvMap;
|
|
66
|
+
function toEnvList(envs) {
|
|
67
|
+
return Object.entries(envs).map(([variable, env]) => {
|
|
68
|
+
return { ...env, variable };
|
|
69
|
+
});
|
|
85
70
|
}
|
|
71
|
+
exports.toEnvList = toEnvList;
|
package/lib/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addAdditionalAccount = exports.logout = exports.getAccessToken = exports.haveValidTokens = exports.isExpired = exports.loggedIn = exports.findAccountByEmail = exports.loginGithub = exports.loginGoogle = exports.setGlobalDefaultAccount = exports.setProjectAccount = exports.loginAdditionalAccount = exports.selectAccount = exports.setRefreshToken = exports.setActiveAccount = exports.getAllAccounts = exports.getAdditionalAccounts = exports.getProjectDefaultAccount = exports.getGlobalDefaultAccount = void 0;
|
|
3
|
+
exports.addAdditionalAccount = exports.logout = exports.getAccessToken = exports.haveValidTokens = exports.isExpired = exports.loggedIn = exports.findAccountByEmail = exports.loginGithub = exports.loginGoogle = exports.setGlobalDefaultAccount = exports.setProjectAccount = exports.loginAdditionalAccount = exports.selectAccount = exports.setRefreshToken = exports.setActiveAccount = exports.assertAccount = exports.getAllAccounts = exports.getAdditionalAccounts = exports.getProjectDefaultAccount = exports.getGlobalDefaultAccount = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const FormData = require("form-data");
|
|
6
6
|
const http = require("http");
|
|
@@ -62,6 +62,16 @@ function getAllAccounts() {
|
|
|
62
62
|
return res;
|
|
63
63
|
}
|
|
64
64
|
exports.getAllAccounts = getAllAccounts;
|
|
65
|
+
function assertAccount(email, options) {
|
|
66
|
+
const allAccounts = getAllAccounts();
|
|
67
|
+
const accountExists = allAccounts.some((a) => a.user.email === email);
|
|
68
|
+
if (!accountExists) {
|
|
69
|
+
throw new error_1.FirebaseError(`Account ${email} does not exist, ${options?.mcp
|
|
70
|
+
? `use the 'firebase_get_environment' tool to see available accounts or instruct the user to use the 'firebase login:add' terminal command to add a new account.`
|
|
71
|
+
: `run "${clc.bold("firebase login:list")} to see valid accounts`}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.assertAccount = assertAccount;
|
|
65
75
|
function setActiveAccount(options, account) {
|
|
66
76
|
if (account.tokens.refresh_token) {
|
|
67
77
|
setRefreshToken(account.tokens.refresh_token);
|
|
@@ -121,7 +131,17 @@ function setProjectAccount(projectDir, email) {
|
|
|
121
131
|
configstore_1.configstore.set("activeAccounts", activeAccounts);
|
|
122
132
|
}
|
|
123
133
|
exports.setProjectAccount = setProjectAccount;
|
|
124
|
-
function setGlobalDefaultAccount(
|
|
134
|
+
function setGlobalDefaultAccount(accountOrEmail) {
|
|
135
|
+
let account;
|
|
136
|
+
if (typeof accountOrEmail === "string") {
|
|
137
|
+
const accountFromEmail = getAllAccounts().find((acc) => acc.user.email === accountOrEmail);
|
|
138
|
+
if (!accountFromEmail)
|
|
139
|
+
throw new error_1.FirebaseError(`Account '${accountOrEmail}' is not a signed-in user on this device.`);
|
|
140
|
+
account = accountFromEmail;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
account = accountOrEmail;
|
|
144
|
+
}
|
|
125
145
|
configstore_1.configstore.set("user", account.user);
|
|
126
146
|
configstore_1.configstore.set("tokens", account.tokens);
|
|
127
147
|
const additionalAccounts = getAdditionalAccounts();
|
|
@@ -298,10 +318,7 @@ async function loginRemotely() {
|
|
|
298
318
|
logger_1.logger.info();
|
|
299
319
|
logger_1.logger.info("3. Paste or enter the authorization code below once you have it:");
|
|
300
320
|
logger_1.logger.info();
|
|
301
|
-
const code = await (0, prompt_1.
|
|
302
|
-
type: "input",
|
|
303
|
-
message: "Enter authorization code:",
|
|
304
|
-
});
|
|
321
|
+
const code = await (0, prompt_1.input)({ message: "Enter authorization code:" });
|
|
305
322
|
try {
|
|
306
323
|
const tokens = await getTokensFromAuthorizationCode(code, `${(0, api_1.authProxyOrigin)()}/complete`, codeVerifier);
|
|
307
324
|
void (0, track_1.trackGA4)("login", { method: "google_remote" });
|
package/lib/bin/cli.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cli = void 0;
|
|
4
|
+
const updateNotifierPkg = require("update-notifier-cjs");
|
|
5
|
+
const clc = require("colorette");
|
|
6
|
+
const marked_terminal_1 = require("marked-terminal");
|
|
7
|
+
const marked_1 = require("marked");
|
|
8
|
+
marked_1.marked.use((0, marked_terminal_1.markedTerminal)());
|
|
9
|
+
const fs = require("node:fs");
|
|
10
|
+
const configstore_1 = require("../configstore");
|
|
11
|
+
const errorOut_1 = require("../errorOut");
|
|
12
|
+
const handlePreviewToggles_1 = require("../handlePreviewToggles");
|
|
13
|
+
const logger_1 = require("../logger");
|
|
14
|
+
const client = require("..");
|
|
15
|
+
const fsutils = require("../fsutils");
|
|
16
|
+
const utils = require("../utils");
|
|
17
|
+
const experiments_1 = require("../experiments");
|
|
18
|
+
const fetchMOTD_1 = require("../fetchMOTD");
|
|
19
|
+
function cli(pkg) {
|
|
20
|
+
const updateNotifier = updateNotifierPkg({ pkg });
|
|
21
|
+
const args = process.argv.slice(2);
|
|
22
|
+
let cmd;
|
|
23
|
+
if (!process.env.DEBUG && args.includes("--debug")) {
|
|
24
|
+
process.env.DEBUG = "true";
|
|
25
|
+
}
|
|
26
|
+
process.env.IS_FIREBASE_CLI = "true";
|
|
27
|
+
const logFilename = (0, logger_1.useFileLogger)();
|
|
28
|
+
logger_1.logger.debug("-".repeat(70));
|
|
29
|
+
logger_1.logger.debug("Command: ", process.argv.join(" "));
|
|
30
|
+
logger_1.logger.debug("CLI Version: ", pkg.version);
|
|
31
|
+
logger_1.logger.debug("Platform: ", process.platform);
|
|
32
|
+
logger_1.logger.debug("Node Version: ", process.version);
|
|
33
|
+
logger_1.logger.debug("Time: ", new Date().toString());
|
|
34
|
+
if (utils.envOverrides.length) {
|
|
35
|
+
logger_1.logger.debug("Env Overrides:", utils.envOverrides.join(", "));
|
|
36
|
+
}
|
|
37
|
+
logger_1.logger.debug("-".repeat(70));
|
|
38
|
+
logger_1.logger.debug();
|
|
39
|
+
(0, experiments_1.enableExperimentsFromCliEnvVariable)();
|
|
40
|
+
(0, fetchMOTD_1.fetchMOTD)();
|
|
41
|
+
process.on("exit", (code) => {
|
|
42
|
+
code = process.exitCode || code;
|
|
43
|
+
if (!process.env.DEBUG && code < 2 && fsutils.fileExistsSync(logFilename)) {
|
|
44
|
+
fs.unlinkSync(logFilename);
|
|
45
|
+
}
|
|
46
|
+
if (code > 0 && process.stdout.isTTY) {
|
|
47
|
+
const lastError = configstore_1.configstore.get("lastError") || 0;
|
|
48
|
+
const timestamp = Date.now();
|
|
49
|
+
if (lastError > timestamp - 120000) {
|
|
50
|
+
let help;
|
|
51
|
+
if (code === 1 && cmd) {
|
|
52
|
+
help = "Having trouble? Try " + clc.bold("firebase [command] --help");
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
help = "Having trouble? Try again or contact support with contents of firebase-debug.log";
|
|
56
|
+
}
|
|
57
|
+
if (cmd) {
|
|
58
|
+
console.log();
|
|
59
|
+
console.log(help);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
configstore_1.configstore.set("lastError", timestamp);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
configstore_1.configstore.delete("lastError");
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const installMethod = !process.env.FIREPIT_VERSION ? "npm" : "automatic script";
|
|
69
|
+
const updateCommand = !process.env.FIREPIT_VERSION
|
|
70
|
+
? "npm install -g firebase-tools"
|
|
71
|
+
: "curl -sL https://firebase.tools | upgrade=true bash";
|
|
72
|
+
const updateMessage = `Update available ${clc.gray("{currentVersion}")} → ${clc.green("{latestVersion}")}\n` +
|
|
73
|
+
`To update to the latest version using ${installMethod}, run\n${clc.cyan(updateCommand)}\n` +
|
|
74
|
+
`For other CLI management options, visit the ${(0, marked_1.marked)("[CLI documentation](https://firebase.google.com/docs/cli#update-cli)")}`;
|
|
75
|
+
updateNotifier.notify({ defer: false, isGlobal: true, message: updateMessage });
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
logger_1.logger.debug("Error when notifying about new CLI updates:");
|
|
79
|
+
if (err instanceof Error) {
|
|
80
|
+
logger_1.logger.debug(err);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
logger_1.logger.debug(`${err}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
process.on("uncaughtException", (err) => {
|
|
88
|
+
(0, errorOut_1.errorOut)(err);
|
|
89
|
+
});
|
|
90
|
+
if (!(0, handlePreviewToggles_1.handlePreviewToggles)(args)) {
|
|
91
|
+
if (!args.length) {
|
|
92
|
+
client.cli.help();
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
cmd = client.cli.parse(process.argv);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.cli = cli;
|
package/lib/bin/firebase.js
CHANGED
|
@@ -2,134 +2,18 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const semver = require("semver");
|
|
5
|
+
const experiments_1 = require("../experiments");
|
|
5
6
|
const pkg = require("../../package.json");
|
|
6
7
|
const nodeVersion = process.version;
|
|
7
8
|
if (!semver.satisfies(nodeVersion, pkg.engines.node)) {
|
|
8
9
|
console.error(`Firebase CLI v${pkg.version} is incompatible with Node.js ${nodeVersion} Please upgrade Node.js to version ${pkg.engines.node}`);
|
|
9
10
|
process.exit(1);
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const updateNotifier = updateNotifierPkg({ pkg });
|
|
15
|
-
const marked_1 = require("marked");
|
|
16
|
-
marked_1.marked.use((0, marked_terminal_1.markedTerminal)());
|
|
17
|
-
const node_path_1 = require("node:path");
|
|
18
|
-
const triple_beam_1 = require("triple-beam");
|
|
19
|
-
const node_util_1 = require("node:util");
|
|
20
|
-
const fs = require("node:fs");
|
|
21
|
-
const configstore_1 = require("../configstore");
|
|
22
|
-
const errorOut_1 = require("../errorOut");
|
|
23
|
-
const handlePreviewToggles_1 = require("../handlePreviewToggles");
|
|
24
|
-
const logger_1 = require("../logger");
|
|
25
|
-
const client = require("..");
|
|
26
|
-
const fsutils = require("../fsutils");
|
|
27
|
-
const utils = require("../utils");
|
|
28
|
-
const winston = require("winston");
|
|
29
|
-
const args = process.argv.slice(2);
|
|
30
|
-
let cmd;
|
|
31
|
-
function findAvailableLogFile() {
|
|
32
|
-
const candidates = ["firebase-debug.log"];
|
|
33
|
-
for (let i = 1; i < 10; i++) {
|
|
34
|
-
candidates.push(`firebase-debug.${i}.log`);
|
|
35
|
-
}
|
|
36
|
-
for (const c of candidates) {
|
|
37
|
-
const logFilename = (0, node_path_1.join)(process.cwd(), c);
|
|
38
|
-
try {
|
|
39
|
-
const fd = fs.openSync(logFilename, "r+");
|
|
40
|
-
fs.closeSync(fd);
|
|
41
|
-
return logFilename;
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
if (e.code === "ENOENT") {
|
|
45
|
-
return logFilename;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
throw new Error("Unable to obtain permissions for firebase-debug.log");
|
|
50
|
-
}
|
|
51
|
-
const logFilename = findAvailableLogFile();
|
|
52
|
-
if (!process.env.DEBUG && args.includes("--debug")) {
|
|
53
|
-
process.env.DEBUG = "true";
|
|
12
|
+
if ((0, experiments_1.isEnabled)("mcp") && process.argv[2] === "experimental:mcp") {
|
|
13
|
+
const { mcp } = require("./mcp");
|
|
14
|
+
mcp();
|
|
54
15
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
filename: logFilename,
|
|
59
|
-
format: winston.format.printf((info) => {
|
|
60
|
-
const segments = [info.message, ...(info[triple_beam_1.SPLAT] || [])].map(utils.tryStringify);
|
|
61
|
-
return `[${info.level}] ${(0, node_util_1.stripVTControlCharacters)(segments.join(" "))}`;
|
|
62
|
-
}),
|
|
63
|
-
}));
|
|
64
|
-
logger_1.logger.debug("-".repeat(70));
|
|
65
|
-
logger_1.logger.debug("Command: ", process.argv.join(" "));
|
|
66
|
-
logger_1.logger.debug("CLI Version: ", pkg.version);
|
|
67
|
-
logger_1.logger.debug("Platform: ", process.platform);
|
|
68
|
-
logger_1.logger.debug("Node Version: ", process.version);
|
|
69
|
-
logger_1.logger.debug("Time: ", new Date().toString());
|
|
70
|
-
if (utils.envOverrides.length) {
|
|
71
|
-
logger_1.logger.debug("Env Overrides:", utils.envOverrides.join(", "));
|
|
72
|
-
}
|
|
73
|
-
logger_1.logger.debug("-".repeat(70));
|
|
74
|
-
logger_1.logger.debug();
|
|
75
|
-
const experiments_1 = require("../experiments");
|
|
76
|
-
const fetchMOTD_1 = require("../fetchMOTD");
|
|
77
|
-
(0, experiments_1.enableExperimentsFromCliEnvVariable)();
|
|
78
|
-
(0, fetchMOTD_1.fetchMOTD)();
|
|
79
|
-
process.on("exit", (code) => {
|
|
80
|
-
code = process.exitCode || code;
|
|
81
|
-
if (!process.env.DEBUG && code < 2 && fsutils.fileExistsSync(logFilename)) {
|
|
82
|
-
fs.unlinkSync(logFilename);
|
|
83
|
-
}
|
|
84
|
-
if (code > 0 && process.stdout.isTTY) {
|
|
85
|
-
const lastError = configstore_1.configstore.get("lastError") || 0;
|
|
86
|
-
const timestamp = Date.now();
|
|
87
|
-
if (lastError > timestamp - 120000) {
|
|
88
|
-
let help;
|
|
89
|
-
if (code === 1 && cmd) {
|
|
90
|
-
help = "Having trouble? Try " + clc.bold("firebase [command] --help");
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
help = "Having trouble? Try again or contact support with contents of firebase-debug.log";
|
|
94
|
-
}
|
|
95
|
-
if (cmd) {
|
|
96
|
-
console.log();
|
|
97
|
-
console.log(help);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
configstore_1.configstore.set("lastError", timestamp);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
configstore_1.configstore.delete("lastError");
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
const installMethod = !process.env.FIREPIT_VERSION ? "npm" : "automatic script";
|
|
107
|
-
const updateCommand = !process.env.FIREPIT_VERSION
|
|
108
|
-
? "npm install -g firebase-tools"
|
|
109
|
-
: "curl -sL https://firebase.tools | upgrade=true bash";
|
|
110
|
-
const updateMessage = `Update available ${clc.gray("{currentVersion}")} → ${clc.green("{latestVersion}")}\n` +
|
|
111
|
-
`To update to the latest version using ${installMethod}, run\n${clc.cyan(updateCommand)}\n` +
|
|
112
|
-
`For other CLI management options, visit the ${(0, marked_1.marked)("[CLI documentation](https://firebase.google.com/docs/cli#update-cli)")}`;
|
|
113
|
-
updateNotifier.notify({ defer: false, isGlobal: true, message: updateMessage });
|
|
114
|
-
}
|
|
115
|
-
catch (err) {
|
|
116
|
-
logger_1.logger.debug("Error when notifying about new CLI updates:");
|
|
117
|
-
if (err instanceof Error) {
|
|
118
|
-
logger_1.logger.debug(err);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
logger_1.logger.debug(`${err}`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
process.on("uncaughtException", (err) => {
|
|
126
|
-
(0, errorOut_1.errorOut)(err);
|
|
127
|
-
});
|
|
128
|
-
if (!(0, handlePreviewToggles_1.handlePreviewToggles)(args)) {
|
|
129
|
-
if (!args.length) {
|
|
130
|
-
client.cli.help();
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
cmd = client.cli.parse(process.argv);
|
|
134
|
-
}
|
|
16
|
+
else {
|
|
17
|
+
const { cli } = require("./cli");
|
|
18
|
+
cli(pkg);
|
|
135
19
|
}
|