firebase-tools 15.0.0 → 15.2.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/lib/accountExporter.js +3 -5
- package/lib/accountImporter.js +4 -5
- package/lib/api.js +3 -3
- package/lib/apiv2.js +9 -13
- package/lib/appUtils.js +33 -36
- package/lib/appdistribution/client.js +4 -8
- package/lib/appdistribution/distribution.js +4 -4
- package/lib/appdistribution/options-parser-util.js +8 -9
- package/lib/appdistribution/types.js +2 -2
- package/lib/appdistribution/yaml_helper.js +33 -17
- package/lib/apphosting/app.js +8 -13
- package/lib/apphosting/backend.js +34 -24
- package/lib/apphosting/config.js +14 -14
- package/lib/apphosting/githubConnections.js +38 -35
- package/lib/apphosting/localbuilds.js +4 -6
- package/lib/apphosting/repo.js +24 -20
- package/lib/apphosting/rollout.js +12 -5
- package/lib/apphosting/secrets/dialogs.js +9 -9
- package/lib/apphosting/secrets/index.js +9 -11
- package/lib/apphosting/utils.js +2 -3
- package/lib/apphosting/yaml.js +12 -11
- package/lib/apptesting/ensureProjectConfigured.js +1 -2
- package/lib/apptesting/invokeTests.js +2 -3
- package/lib/apptesting/parseTestFiles.js +5 -6
- package/lib/apptesting/types.js +2 -2
- package/lib/archiveDirectory.js +1 -2
- package/lib/auth.js +36 -40
- package/lib/bin/cli.js +2 -3
- package/lib/bin/mcp.js +47 -10
- package/lib/checkMinRequiredVersion.js +1 -2
- package/lib/checkValidTargetFilters.js +1 -2
- package/lib/command.js +6 -9
- package/lib/commands/appdistribution-testers-list.js +2 -3
- package/lib/commands/apphosting-backends-list.js +4 -6
- package/lib/commands/apphosting-builds-create.js +2 -3
- package/lib/commands/apphosting-builds-get.js +1 -2
- package/lib/commands/apphosting-rollouts-list.js +1 -2
- package/lib/commands/apps-init.js +1 -1
- package/lib/commands/{apptesting-execute.js → apptesting-wata.js} +3 -4
- package/lib/commands/crashlytics-symbols-upload.js +2 -2
- package/lib/commands/dataconnect-execute.js +4 -4
- package/lib/commands/dataconnect-sdk-generate.js +5 -6
- package/lib/commands/dataconnect-services-list.js +7 -8
- package/lib/commands/dataconnect-sql-diff.js +1 -2
- package/lib/commands/dataconnect-sql-migrate.js +4 -3
- package/lib/commands/dataconnect-sql-setup.js +2 -2
- package/lib/commands/dataconnect-sql-shell.js +5 -1
- package/lib/commands/emulators-start.js +1 -2
- package/lib/commands/ext-configure.js +6 -4
- package/lib/commands/ext-dev-list.js +2 -3
- package/lib/commands/ext-dev-upload.js +2 -2
- package/lib/commands/ext-export.js +1 -1
- package/lib/commands/ext-info.js +2 -3
- package/lib/commands/ext-install.js +5 -7
- package/lib/commands/firestore-backups-list.js +1 -2
- package/lib/commands/firestore-backups-schedules-list.js +1 -2
- package/lib/commands/firestore-indexes-list.js +1 -2
- package/lib/commands/firestore-utils.js +1 -2
- package/lib/commands/functions-artifacts-setpolicy.js +1 -2
- package/lib/commands/functions-config-export.js +2 -3
- package/lib/commands/hosting-channel-deploy.js +2 -2
- package/lib/commands/hosting-clone.js +2 -3
- package/lib/commands/hosting-sites-create.js +1 -1
- package/lib/commands/index.js +2 -3
- package/lib/commands/init.js +4 -5
- package/lib/commands/internaltesting-functions-discover.js +1 -1
- package/lib/commands/login.js +4 -5
- package/lib/commands/logout.js +3 -3
- package/lib/commands/projects-create.js +1 -1
- package/lib/commands/remoteconfig-experiments-list.js +2 -3
- package/lib/commands/remoteconfig-get.js +1 -1
- package/lib/commands/remoteconfig-rollback.js +1 -2
- package/lib/commands/remoteconfig-rollouts-list.js +2 -3
- package/lib/commands/remoteconfig-versions-list.js +3 -4
- package/lib/commands/use.js +3 -3
- package/lib/config.js +4 -5
- package/lib/crashlytics/buildToolsJarHelper.js +3 -5
- package/lib/crashlytics/events.js +4 -7
- package/lib/crashlytics/filters.js +10 -12
- package/lib/crashlytics/issues.js +2 -3
- package/lib/crashlytics/notes.js +3 -4
- package/lib/crashlytics/reports.js +21 -15
- package/lib/crashlytics/types.js +7 -7
- package/lib/crashlytics/utils.js +4 -4
- package/lib/database/api.js +2 -3
- package/lib/database/import.js +4 -4
- package/lib/database/metadata.js +5 -6
- package/lib/database/rulesConfig.js +2 -3
- package/lib/dataconnect/build.js +10 -13
- package/lib/dataconnect/checkIam.js +1 -2
- package/lib/dataconnect/client.js +15 -18
- package/lib/dataconnect/dataplaneClient.js +6 -6
- package/lib/dataconnect/ensureApis.js +2 -3
- package/lib/dataconnect/errors.js +8 -11
- package/lib/dataconnect/filters.js +2 -3
- package/lib/dataconnect/freeTrial.js +3 -4
- package/lib/dataconnect/graphqlError.js +5 -8
- package/lib/dataconnect/load.js +10 -11
- package/lib/dataconnect/names.js +14 -18
- package/lib/dataconnect/prompts.js +1 -2
- package/lib/dataconnect/provisionCloudSql.js +13 -17
- package/lib/dataconnect/schemaMigration.js +60 -27
- package/lib/dataconnect/types.js +10 -12
- package/lib/dataconnect/webhook.js +3 -3
- package/lib/defaultCredentials.js +3 -4
- package/lib/deploy/apphosting/deploy.js +2 -3
- package/lib/deploy/apphosting/prepare.js +3 -5
- package/lib/deploy/apphosting/release.js +1 -1
- package/lib/deploy/apphosting/util.js +1 -2
- package/lib/deploy/database/deploy.js +1 -2
- package/lib/deploy/database/prepare.js +1 -2
- package/lib/deploy/database/release.js +1 -2
- package/lib/deploy/dataconnect/context.js +15 -4
- package/lib/deploy/dataconnect/deploy.js +5 -6
- package/lib/deploy/dataconnect/prepare.js +7 -9
- package/lib/deploy/dataconnect/release.js +7 -10
- package/lib/deploy/extensions/deploy.js +7 -9
- package/lib/deploy/extensions/deploymentSummary.js +6 -7
- package/lib/deploy/extensions/planner.js +15 -18
- package/lib/deploy/extensions/prepare.js +9 -11
- package/lib/deploy/extensions/release.js +10 -12
- package/lib/deploy/extensions/secrets.js +8 -11
- package/lib/deploy/extensions/tasks.js +6 -8
- package/lib/deploy/extensions/v2FunctionHelper.js +2 -3
- package/lib/deploy/extensions/validate.js +1 -2
- package/lib/deploy/firestore/deploy.js +3 -5
- package/lib/deploy/firestore/prepare.js +2 -3
- package/lib/deploy/firestore/release.js +3 -4
- package/lib/deploy/functions/backend.js +52 -42
- package/lib/deploy/functions/build.js +41 -15
- package/lib/deploy/functions/cache/applyHash.js +3 -5
- package/lib/deploy/functions/cache/hash.js +4 -5
- package/lib/deploy/functions/cel.js +3 -3
- package/lib/deploy/functions/checkIam.js +8 -8
- package/lib/deploy/functions/containerCleaner.js +10 -6
- package/lib/deploy/functions/deploy.js +6 -8
- package/lib/deploy/functions/ensure.js +6 -9
- package/lib/deploy/functions/functionsDeployHelper.js +10 -11
- package/lib/deploy/functions/params.js +10 -10
- package/lib/deploy/functions/prepare.js +41 -36
- package/lib/deploy/functions/prepareFunctionsUpload.js +24 -10
- package/lib/deploy/functions/pricing.js +3 -3
- package/lib/deploy/functions/prompts.js +7 -10
- package/lib/deploy/functions/release/executor.js +5 -6
- package/lib/deploy/functions/release/fabricator.js +76 -29
- package/lib/deploy/functions/release/index.js +23 -14
- package/lib/deploy/functions/release/planner.js +15 -14
- package/lib/deploy/functions/release/reporter.js +20 -20
- package/lib/deploy/functions/release/sourceTokenScraper.js +4 -5
- package/lib/deploy/functions/remoteSource.js +3 -4
- package/lib/deploy/functions/runtimes/discovery/index.js +9 -12
- package/lib/deploy/functions/runtimes/discovery/parsing.js +2 -3
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +29 -10
- package/lib/deploy/functions/runtimes/index.js +1 -2
- package/lib/deploy/functions/runtimes/node/index.js +18 -9
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +2 -2
- package/lib/deploy/functions/runtimes/node/validate.js +1 -2
- package/lib/deploy/functions/runtimes/node/versioning.js +6 -7
- package/lib/deploy/functions/runtimes/python/index.js +12 -12
- package/lib/deploy/functions/runtimes/supported/index.js +5 -6
- package/lib/deploy/functions/services/auth.js +49 -36
- package/lib/deploy/functions/services/database.js +1 -2
- package/lib/deploy/functions/services/dataconnect.js +16 -2
- package/lib/deploy/functions/services/firebaseAlerts.js +1 -2
- package/lib/deploy/functions/services/firestore.js +3 -5
- package/lib/deploy/functions/services/index.js +2 -2
- package/lib/deploy/functions/services/remoteConfig.js +1 -2
- package/lib/deploy/functions/services/storage.js +3 -5
- package/lib/deploy/functions/services/testLab.js +1 -2
- package/lib/deploy/functions/triggerRegionHelper.js +1 -2
- package/lib/deploy/functions/validate.js +12 -11
- package/lib/deploy/hosting/convertConfig.js +38 -22
- package/lib/deploy/hosting/deploy.js +4 -7
- package/lib/deploy/hosting/hashcache.js +2 -3
- package/lib/deploy/hosting/prepare.js +14 -14
- package/lib/deploy/hosting/release.js +1 -2
- package/lib/deploy/index.js +7 -8
- package/lib/deploy/lifecycleHooks.js +3 -5
- package/lib/deploy/remoteconfig/deploy.js +1 -1
- package/lib/deploy/remoteconfig/functions.js +5 -6
- package/lib/deploy/remoteconfig/prepare.js +2 -3
- package/lib/deploy/remoteconfig/release.js +2 -2
- package/lib/deploy/storage/deploy.js +1 -1
- package/lib/deploy/storage/prepare.js +1 -1
- package/lib/deploy/storage/release.js +1 -1
- package/lib/deploymentTool.js +5 -6
- package/lib/detectProjectRoot.js +1 -2
- package/lib/downloadUtils.js +2 -3
- package/lib/emulator/adminSdkConfig.js +2 -3
- package/lib/emulator/apphosting/config.js +1 -2
- package/lib/emulator/apphosting/developmentServer.js +3 -3
- package/lib/emulator/apphosting/serve.js +20 -14
- package/lib/emulator/auth/cloudFunctions.js +2 -3
- package/lib/emulator/auth/errors.js +2 -2
- package/lib/emulator/auth/handlers.js +3 -4
- package/lib/emulator/auth/index.js +6 -6
- package/lib/emulator/auth/operations.js +171 -129
- package/lib/emulator/auth/server.js +30 -22
- package/lib/emulator/auth/state.js +26 -36
- package/lib/emulator/auth/utils.js +12 -13
- package/lib/emulator/commandUtils.js +20 -20
- package/lib/emulator/controller.js +32 -29
- package/lib/emulator/databaseEmulator.js +1 -2
- package/lib/emulator/dataconnect/pgliteServer.js +48 -104
- package/lib/emulator/dataconnectEmulator.js +6 -9
- package/lib/emulator/download.js +2 -3
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/downloadableEmulators.js +49 -24
- package/lib/emulator/emulatorLogger.js +19 -4
- package/lib/emulator/env.js +6 -8
- package/lib/emulator/eventarcEmulator.js +2 -3
- package/lib/emulator/eventarcEmulatorUtils.js +3 -6
- package/lib/emulator/extensions/postinstall.js +1 -2
- package/lib/emulator/extensions/validation.js +4 -7
- package/lib/emulator/extensionsEmulator.js +6 -9
- package/lib/emulator/functionsEmulator.js +89 -46
- package/lib/emulator/functionsEmulatorRuntime.js +1 -1
- package/lib/emulator/functionsEmulatorShared.js +30 -30
- package/lib/emulator/functionsEmulatorShell.js +4 -6
- package/lib/emulator/functionsEmulatorUtils.js +8 -9
- package/lib/emulator/functionsRuntimeWorker.js +18 -9
- package/lib/emulator/hub.js +41 -34
- package/lib/emulator/hubClient.js +1 -1
- package/lib/emulator/initEmulators.js +2 -3
- package/lib/emulator/loggingEmulator.js +2 -2
- package/lib/emulator/portUtils.js +4 -5
- package/lib/emulator/registry.js +10 -4
- package/lib/emulator/shared/request.js +1 -2
- package/lib/emulator/storage/apis/firebase.js +16 -20
- package/lib/emulator/storage/apis/gcloud.js +6 -9
- package/lib/emulator/storage/apis/shared.js +1 -2
- package/lib/emulator/storage/crc.js +2 -3
- package/lib/emulator/storage/files.js +18 -41
- package/lib/emulator/storage/metadata.js +10 -4
- package/lib/emulator/storage/multipart.js +1 -2
- package/lib/emulator/storage/rfc.js +1 -2
- package/lib/emulator/storage/rules/config.js +1 -2
- package/lib/emulator/storage/rules/manager.js +3 -5
- package/lib/emulator/storage/rules/runtime.js +15 -13
- package/lib/emulator/storage/rules/types.js +2 -2
- package/lib/emulator/storage/rules/utils.js +5 -6
- package/lib/emulator/storage/server.js +1 -2
- package/lib/emulator/storage/upload.js +3 -4
- package/lib/emulator/taskQueue.js +11 -4
- package/lib/emulator/tasksEmulator.js +11 -12
- package/lib/emulator/types.js +6 -6
- package/lib/emulator/ui.js +6 -1
- package/lib/ensureApiEnabled.js +7 -9
- package/lib/env.js +2 -3
- package/lib/error.js +11 -13
- package/lib/errorOut.js +1 -2
- package/lib/experiments.js +15 -18
- package/lib/extensions/askUserForEventsConfig.js +12 -13
- package/lib/extensions/askUserForParam.js +11 -12
- package/lib/extensions/change-log.js +4 -5
- package/lib/extensions/checkProjectBilling.js +1 -2
- package/lib/extensions/diagnose.js +1 -2
- package/lib/extensions/displayExtensionInfo.js +25 -32
- package/lib/extensions/emulator/optionsHelper.js +6 -8
- package/lib/extensions/emulator/specHelper.js +15 -16
- package/lib/extensions/emulator/triggerHelper.js +3 -5
- package/lib/extensions/etags.js +2 -3
- package/lib/extensions/export.js +7 -9
- package/lib/extensions/extensionsApi.js +23 -29
- package/lib/extensions/extensionsHelper.js +52 -80
- package/lib/extensions/listExtensions.js +3 -5
- package/lib/extensions/localHelper.js +5 -5
- package/lib/extensions/manifest.js +15 -16
- package/lib/extensions/metricsUtils.js +3 -4
- package/lib/extensions/paramHelper.js +21 -18
- package/lib/extensions/provisioningHelper.js +17 -21
- package/lib/extensions/publishHelpers.js +1 -2
- package/lib/extensions/publisherApi.js +11 -13
- package/lib/extensions/refs.js +6 -7
- package/lib/extensions/runtimes/common.js +18 -19
- package/lib/extensions/runtimes/node.js +5 -6
- package/lib/extensions/secretsUtils.js +8 -8
- package/lib/extensions/tos.js +7 -8
- package/lib/extensions/types.js +3 -3
- package/lib/extensions/updateHelper.js +6 -7
- package/lib/extensions/utils.js +6 -8
- package/lib/extensions/versionHelper.js +1 -2
- package/lib/extensions/warnings.js +6 -8
- package/lib/fetchMOTD.js +1 -2
- package/lib/fetchWebSetup.js +3 -4
- package/lib/filterTargets.js +1 -2
- package/lib/firebaseConfigValidate.js +2 -3
- package/lib/firestore/api-sort.js +8 -9
- package/lib/firestore/api-types.js +15 -15
- package/lib/firestore/api.js +15 -13
- package/lib/firestore/backupUtils.js +3 -3
- package/lib/firestore/checkDatabaseType.js +1 -2
- package/lib/firestore/delete.js +1 -2
- package/lib/firestore/encodeFirestoreValue.js +1 -2
- package/lib/firestore/fsConfig.js +1 -2
- package/lib/firestore/options.js +1 -1
- package/lib/firestore/util.js +5 -6
- package/lib/firestore/validator.js +4 -5
- package/lib/frameworks/angular/index.js +14 -15
- package/lib/frameworks/angular/utils.js +21 -23
- package/lib/frameworks/astro/index.js +7 -7
- package/lib/frameworks/astro/utils.js +4 -6
- package/lib/frameworks/compose/discover/filesystem.js +3 -3
- package/lib/frameworks/compose/discover/frameworkMatcher.js +4 -5
- package/lib/frameworks/compose/discover/index.js +1 -2
- package/lib/frameworks/compose/discover/runtime/node.js +8 -11
- package/lib/frameworks/compose/driver/docker.js +3 -5
- package/lib/frameworks/compose/driver/hooks.js +2 -2
- package/lib/frameworks/compose/driver/index.js +2 -2
- package/lib/frameworks/compose/driver/local.js +2 -3
- package/lib/frameworks/compose/index.js +5 -7
- package/lib/frameworks/constants.js +3 -3
- package/lib/frameworks/express/index.js +7 -8
- package/lib/frameworks/flutter/index.js +6 -7
- package/lib/frameworks/flutter/utils.js +4 -5
- package/lib/frameworks/index.js +21 -22
- package/lib/frameworks/next/constants.js +5 -2
- package/lib/frameworks/next/index.js +34 -32
- package/lib/frameworks/next/utils.js +40 -39
- package/lib/frameworks/nuxt/index.js +9 -9
- package/lib/frameworks/nuxt/utils.js +4 -6
- package/lib/frameworks/nuxt2/index.js +7 -7
- package/lib/frameworks/sveltekit/index.js +6 -8
- package/lib/frameworks/utils.js +26 -24
- package/lib/frameworks/vite/index.js +8 -9
- package/lib/fsAsync.js +1 -2
- package/lib/fsutils.js +5 -6
- package/lib/functional.js +11 -11
- package/lib/functions/artifacts.js +25 -22
- package/lib/functions/ensureTargeted.js +1 -2
- package/lib/functions/env.js +13 -14
- package/lib/functions/functionslog.js +2 -3
- package/lib/functions/projectConfig.js +29 -33
- package/lib/functions/python.js +10 -4
- package/lib/functions/secrets.js +32 -18
- package/lib/functionsConfig.js +14 -14
- package/lib/functionsConfigClone.js +1 -2
- package/lib/functionsShellCommandAction.js +2 -3
- package/lib/gcp/apphosting.js +43 -28
- package/lib/gcp/apptesting.js +2 -2
- package/lib/gcp/artifactregistry.js +5 -5
- package/lib/gcp/auth.js +11 -13
- package/lib/gcp/cloudbilling.js +4 -5
- package/lib/gcp/cloudbuild.js +10 -11
- package/lib/gcp/cloudfunctions.js +61 -45
- package/lib/gcp/cloudfunctionsv2.js +81 -43
- package/lib/gcp/cloudlogging.js +2 -4
- package/lib/gcp/cloudmonitoring.js +7 -7
- package/lib/gcp/cloudscheduler.js +12 -14
- package/lib/gcp/cloudsql/cloudsqladmin.js +19 -21
- package/lib/gcp/cloudsql/connect.js +14 -9
- package/lib/gcp/cloudsql/fbToolsAuthClient.js +5 -3
- package/lib/gcp/cloudsql/interactive.js +2 -3
- package/lib/gcp/cloudsql/permissions.js +8 -8
- package/lib/gcp/cloudsql/permissionsSetup.js +9 -9
- package/lib/gcp/cloudtasks.js +19 -18
- package/lib/gcp/computeEngine.js +1 -2
- package/lib/gcp/devConnect.js +32 -29
- package/lib/gcp/docker.js +2 -4
- package/lib/gcp/eventarc.js +5 -5
- package/lib/gcp/firedata.js +4 -4
- package/lib/gcp/firestore.js +16 -16
- package/lib/gcp/iam.js +11 -12
- package/lib/gcp/identityPlatform.js +4 -5
- package/lib/gcp/k8s.js +1 -2
- package/lib/gcp/location.js +2 -2
- package/lib/gcp/proto.js +10 -11
- package/lib/gcp/pubsub.js +4 -5
- package/lib/gcp/resourceManager.js +5 -5
- package/lib/gcp/rules.js +13 -14
- package/lib/gcp/run.js +24 -31
- package/lib/gcp/runv2.js +39 -27
- package/lib/gcp/secretManager.js +60 -39
- package/lib/gcp/serviceusage.js +8 -4
- package/lib/gcp/storage.js +22 -20
- package/lib/gemini/fdcExperience.js +5 -5
- package/lib/getDefaultDatabaseInstance.js +2 -4
- package/lib/getDefaultHostingSite.js +3 -4
- package/lib/getProjectNumber.js +1 -2
- package/lib/hosting/api.js +32 -36
- package/lib/hosting/cloudRunProxy.js +2 -3
- package/lib/hosting/config.js +17 -17
- package/lib/hosting/expireUtils.js +3 -3
- package/lib/hosting/functionsProxy.js +1 -2
- package/lib/hosting/implicitInit.js +1 -2
- package/lib/hosting/initMiddleware.js +1 -2
- package/lib/hosting/interactive.js +1 -2
- package/lib/hosting/proxy.js +3 -5
- package/lib/hosting/runTags.js +8 -11
- package/lib/init/features/account.js +1 -2
- package/lib/init/features/ailogic/index.js +3 -5
- package/lib/init/features/ailogic/utils.js +6 -8
- package/lib/init/features/aitools/claude.js +1 -2
- package/lib/init/features/aitools/cursor.js +1 -2
- package/lib/init/features/aitools/gemini.js +1 -1
- package/lib/init/features/aitools/promptUpdater.js +10 -12
- package/lib/init/features/aitools.js +1 -2
- package/lib/init/features/apphosting.js +3 -4
- package/lib/init/features/apptesting/index.js +9 -9
- package/lib/init/features/database.js +4 -5
- package/lib/init/features/dataconnect/create_app.js +3 -4
- package/lib/init/features/dataconnect/index.js +25 -22
- package/lib/init/features/dataconnect/resolver.js +6 -10
- package/lib/init/features/dataconnect/sdk.js +31 -24
- package/lib/init/features/emulators.js +7 -6
- package/lib/init/features/extensions/index.js +3 -5
- package/lib/init/features/firestore/index.js +7 -9
- package/lib/init/features/firestore/indexes.js +2 -2
- package/lib/init/features/firestore/rules.js +3 -3
- package/lib/init/features/functions/index.js +3 -5
- package/lib/init/features/functions/javascript.js +1 -2
- package/lib/init/features/functions/npm-dependencies.js +1 -2
- package/lib/init/features/functions/python.js +1 -2
- package/lib/init/features/functions/typescript.js +1 -2
- package/lib/init/features/genkit/index.js +44 -18
- package/lib/init/features/hosting/github.js +6 -8
- package/lib/init/features/hosting/index.js +10 -13
- package/lib/init/features/project.js +4 -7
- package/lib/init/features/remoteconfig.js +1 -2
- package/lib/init/features/storage.js +3 -5
- package/lib/init/index.js +4 -7
- package/lib/init/spawn.js +7 -9
- package/lib/listFiles.js +1 -2
- package/lib/loadCJSON.js +1 -2
- package/lib/localFunction.js +14 -15
- package/lib/logError.js +1 -2
- package/lib/logger.js +7 -7
- package/lib/management/apps.js +22 -22
- package/lib/management/database.js +11 -12
- package/lib/management/projects.js +57 -56
- package/lib/management/provisioning/errorHandler.js +3 -5
- package/lib/management/provisioning/provision.js +15 -9
- package/lib/management/studio.js +2 -3
- package/lib/mcp/errors.js +4 -4
- package/lib/mcp/index.js +47 -45
- package/lib/mcp/prompt.js +1 -2
- package/lib/mcp/prompts/core/consult.js +2 -3
- package/lib/mcp/prompts/crashlytics/connect.js +15 -122
- package/lib/mcp/prompts/dataconnect/schema.js +3 -3
- package/lib/mcp/prompts/index.js +8 -10
- package/lib/mcp/resource.js +3 -15
- package/lib/mcp/resources/guides/app_id.js +39 -0
- package/lib/mcp/resources/guides/crashlytics_connect.js +51 -0
- package/lib/mcp/resources/guides/crashlytics_investigations.js +51 -0
- package/lib/mcp/resources/guides/crashlytics_issues.js +42 -0
- package/lib/mcp/resources/guides/crashlytics_reports.js +112 -0
- package/lib/mcp/resources/index.js +11 -3
- package/lib/mcp/tool.js +3 -15
- package/lib/mcp/tools/apphosting/fetch_logs.js +3 -4
- package/lib/mcp/tools/apphosting/list_backends.js +1 -1
- package/lib/mcp/tools/auth/get_users.js +5 -16
- package/lib/mcp/tools/core/create_android_sha.js +4 -1
- package/lib/mcp/tools/core/get_environment.js +7 -4
- package/lib/mcp/tools/core/get_sdk_config.js +4 -5
- package/lib/mcp/tools/core/get_security_rules.js +1 -2
- package/lib/mcp/tools/core/init.js +2 -2
- package/lib/mcp/tools/core/logout.js +1 -1
- package/lib/mcp/tools/core/read_resources.js +2 -2
- package/lib/mcp/tools/core/validate_security_rules.js +1 -2
- package/lib/mcp/tools/crashlytics/events.js +43 -19
- package/lib/mcp/tools/crashlytics/index.js +1 -6
- package/lib/mcp/tools/crashlytics/issues.js +33 -12
- package/lib/mcp/tools/crashlytics/reports.js +66 -117
- package/lib/mcp/tools/dataconnect/list_services.js +2 -3
- package/lib/mcp/tools/firestore/converter.js +3 -5
- package/lib/mcp/tools/firestore/delete_document.js +1 -1
- package/lib/mcp/tools/functions/get_logs.js +14 -12
- package/lib/mcp/tools/functions/list_functions.js +1 -1
- package/lib/mcp/tools/index.js +67 -50
- package/lib/mcp/util/apptesting/availability.js +1 -2
- package/lib/mcp/util/availability.js +1 -2
- package/lib/mcp/util/crashlytics/availability.js +1 -2
- package/lib/mcp/util/dataconnect/compile.js +7 -6
- package/lib/mcp/util/dataconnect/converter.js +7 -10
- package/lib/mcp/util/dataconnect/emulator.js +1 -2
- package/lib/mcp/util.js +9 -11
- package/lib/messaging/sendMessage.js +1 -2
- package/lib/metaprogramming.js +1 -2
- package/lib/operation-poller.js +2 -2
- package/lib/profileReport.js +6 -6
- package/lib/profiler.js +1 -2
- package/lib/projectPath.js +1 -2
- package/lib/projectUtils.js +5 -6
- package/lib/prompt.js +22 -13
- package/lib/rc.js +5 -7
- package/lib/remoteconfig/deleteExperiment.js +1 -2
- package/lib/remoteconfig/deleteRollout.js +1 -2
- package/lib/remoteconfig/get.js +2 -3
- package/lib/remoteconfig/getExperiment.js +2 -2
- package/lib/remoteconfig/getRollout.js +2 -2
- package/lib/remoteconfig/interfaces.js +1 -1
- package/lib/remoteconfig/listExperiments.js +2 -2
- package/lib/remoteconfig/listRollouts.js +2 -2
- package/lib/remoteconfig/publish.js +1 -2
- package/lib/remoteconfig/rollback.js +1 -2
- package/lib/remoteconfig/versionslist.js +1 -2
- package/lib/requireAuth.js +4 -6
- package/lib/requireConfig.js +5 -8
- package/lib/requireDatabaseInstance.js +2 -2
- package/lib/requireHostingSite.js +1 -2
- package/lib/requireInteractive.js +1 -1
- package/lib/requirePermissions.js +1 -2
- package/lib/requireTosAcceptance.js +1 -2
- package/lib/responseToError.js +1 -2
- package/lib/rtdb.js +2 -3
- package/lib/rulesDeploy.js +3 -4
- package/lib/serve/functions.js +9 -1
- package/lib/serve/hosting.js +4 -5
- package/lib/serve/index.js +1 -2
- package/lib/shortenUrl.js +1 -2
- package/lib/templates.js +3 -4
- package/lib/throttler/throttler.js +3 -3
- package/lib/timeout.js +2 -3
- package/lib/track.js +23 -14
- package/lib/tsconfig.publish.tsbuildinfo +1 -0
- package/lib/unzip.js +2 -3
- package/lib/utils.js +62 -63
- package/lib/vsCodeUtils.js +2 -3
- package/package.json +6 -6
- package/templates/extensions/typescript/index.ts +1 -1
- package/templates/extensions/typescript/package.lint.json +1 -1
- package/templates/extensions/typescript/package.nolint.json +1 -1
- package/templates/extensions/typescript/tsconfig.json +2 -1
package/lib/apphosting/app.js
CHANGED
|
@@ -13,7 +13,6 @@ exports.webApps = {
|
|
|
13
13
|
generateWebAppName,
|
|
14
14
|
};
|
|
15
15
|
async function getOrCreateWebApp(projectId, firebaseWebAppId, backendId) {
|
|
16
|
-
var _a;
|
|
17
16
|
const webAppsInProject = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.WEB);
|
|
18
17
|
if (firebaseWebAppId) {
|
|
19
18
|
const webApp = webAppsInProject.find((app) => app.appId === firebaseWebAppId);
|
|
@@ -21,7 +20,7 @@ async function getOrCreateWebApp(projectId, firebaseWebAppId, backendId) {
|
|
|
21
20
|
throw new error_1.FirebaseError(`The web app '${firebaseWebAppId}' does not exist in project ${projectId}`);
|
|
22
21
|
}
|
|
23
22
|
return {
|
|
24
|
-
name:
|
|
23
|
+
name: webApp.displayName ?? webApp.appId,
|
|
25
24
|
id: webApp.appId,
|
|
26
25
|
};
|
|
27
26
|
}
|
|
@@ -56,19 +55,15 @@ async function generateWebAppName(projectId, backendId) {
|
|
|
56
55
|
return webAppName;
|
|
57
56
|
}
|
|
58
57
|
function firebaseAppsToMap(apps) {
|
|
59
|
-
return new Map(apps.map((obj) =>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
obj.appId,
|
|
64
|
-
];
|
|
65
|
-
}));
|
|
58
|
+
return new Map(apps.map((obj) => [
|
|
59
|
+
obj.displayName ?? obj.appId,
|
|
60
|
+
obj.appId,
|
|
61
|
+
]));
|
|
66
62
|
}
|
|
67
63
|
function isQuotaError(error) {
|
|
68
|
-
var _a, _b, _c, _d, _e;
|
|
69
64
|
const original = error.original;
|
|
70
|
-
const code =
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
const code = original?.status ||
|
|
66
|
+
original?.context?.response?.statusCode ||
|
|
67
|
+
original?.context?.body?.error?.code;
|
|
73
68
|
return code === 429;
|
|
74
69
|
}
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.doSetup = doSetup;
|
|
4
|
+
exports.doSetupSourceDeploy = doSetupSourceDeploy;
|
|
5
|
+
exports.ensureRequiredApisEnabled = ensureRequiredApisEnabled;
|
|
6
|
+
exports.createGitRepoLink = createGitRepoLink;
|
|
7
|
+
exports.ensureAppHostingComputeServiceAccount = ensureAppHostingComputeServiceAccount;
|
|
8
|
+
exports.promptNewBackendId = promptNewBackendId;
|
|
9
|
+
exports.createBackend = createBackend;
|
|
10
|
+
exports.setDefaultTrafficPolicy = setDefaultTrafficPolicy;
|
|
11
|
+
exports.deleteBackendAndPoll = deleteBackendAndPoll;
|
|
12
|
+
exports.promptLocation = promptLocation;
|
|
13
|
+
exports.getBackendForLocation = getBackendForLocation;
|
|
14
|
+
exports.promptExistingBackend = promptExistingBackend;
|
|
15
|
+
exports.chooseBackends = chooseBackends;
|
|
16
|
+
exports.getBackendForAmbiguousLocation = getBackendForAmbiguousLocation;
|
|
17
|
+
exports.getBackend = getBackend;
|
|
4
18
|
const clc = require("colorette");
|
|
5
19
|
const poller = require("../operation-poller");
|
|
6
20
|
const apphosting = require("../gcp/apphosting");
|
|
@@ -28,15 +42,14 @@ const apphostingPollerOptions = {
|
|
|
28
42
|
maxBackoff: 10000,
|
|
29
43
|
};
|
|
30
44
|
async function tlsReady(url) {
|
|
31
|
-
var _a;
|
|
32
45
|
try {
|
|
33
46
|
await (0, node_fetch_1.default)(url);
|
|
34
47
|
return true;
|
|
35
48
|
}
|
|
36
49
|
catch (err) {
|
|
37
50
|
const maybeNodeError = err;
|
|
38
|
-
if (/HANDSHAKE_FAILURE/.test(
|
|
39
|
-
"EPROTO" ===
|
|
51
|
+
if (/HANDSHAKE_FAILURE/.test(maybeNodeError?.cause?.code) ||
|
|
52
|
+
"EPROTO" === maybeNodeError?.code) {
|
|
40
53
|
return false;
|
|
41
54
|
}
|
|
42
55
|
return true;
|
|
@@ -89,7 +102,7 @@ async function doSetup(projectId, nonInteractive, webAppName, backendId, service
|
|
|
89
102
|
(0, utils_1.logWarning)(`Firebase web app not set`);
|
|
90
103
|
}
|
|
91
104
|
const createBackendSpinner = ora("Creating your new backend...").start();
|
|
92
|
-
const backend = await createBackend(projectId, location, backendId, serviceAccount ? serviceAccount : null, gitRepositoryLink, webApp
|
|
105
|
+
const backend = await createBackend(projectId, location, backendId, serviceAccount ? serviceAccount : null, gitRepositoryLink, webApp?.id, rootDir);
|
|
93
106
|
createBackendSpinner.succeed(`Successfully created backend!\n\t${backend.name}\n`);
|
|
94
107
|
if (nonInteractive) {
|
|
95
108
|
return;
|
|
@@ -130,7 +143,6 @@ async function doSetup(projectId, nonInteractive, webAppName, backendId, service
|
|
|
130
143
|
}
|
|
131
144
|
(0, utils_1.logSuccess)(`Your backend is now deployed at:\n\thttps://${backend.uri}`);
|
|
132
145
|
}
|
|
133
|
-
exports.doSetup = doSetup;
|
|
134
146
|
async function doSetupSourceDeploy(projectId, backendId) {
|
|
135
147
|
const location = await promptLocation(projectId, "Select a primary region to host your backend:\n");
|
|
136
148
|
const webAppSpinner = ora("Creating a new web app...\n").start();
|
|
@@ -140,14 +152,13 @@ async function doSetupSourceDeploy(projectId, backendId) {
|
|
|
140
152
|
}
|
|
141
153
|
webAppSpinner.stop();
|
|
142
154
|
const createBackendSpinner = ora("Creating your new backend...").start();
|
|
143
|
-
const backend = await createBackend(projectId, location, backendId, null, undefined, webApp
|
|
155
|
+
const backend = await createBackend(projectId, location, backendId, null, undefined, webApp?.id);
|
|
144
156
|
createBackendSpinner.succeed(`Successfully created backend!\n\t${backend.name}\n`);
|
|
145
157
|
return {
|
|
146
158
|
backend,
|
|
147
159
|
location,
|
|
148
160
|
};
|
|
149
161
|
}
|
|
150
|
-
exports.doSetupSourceDeploy = doSetupSourceDeploy;
|
|
151
162
|
async function ensureRequiredApisEnabled(projectId) {
|
|
152
163
|
await Promise.all([
|
|
153
164
|
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.developerConnectOrigin)(), "apphosting", true),
|
|
@@ -158,7 +169,6 @@ async function ensureRequiredApisEnabled(projectId) {
|
|
|
158
169
|
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.iamOrigin)(), "apphosting", true),
|
|
159
170
|
]);
|
|
160
171
|
}
|
|
161
|
-
exports.ensureRequiredApisEnabled = ensureRequiredApisEnabled;
|
|
162
172
|
async function createGitRepoLink(projectId, location, connectionId) {
|
|
163
173
|
await Promise.all([
|
|
164
174
|
(0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.developerConnectOrigin)(), "apphosting", true),
|
|
@@ -176,7 +186,6 @@ async function createGitRepoLink(projectId, location, connectionId) {
|
|
|
176
186
|
(await promptLocation(projectId, "Select a location for your GitRepoLink's connection:\n"));
|
|
177
187
|
await githubConnections.linkGitHubRepository(projectId, location, connectionId);
|
|
178
188
|
}
|
|
179
|
-
exports.createGitRepoLink = createGitRepoLink;
|
|
180
189
|
async function ensureAppHostingComputeServiceAccount(projectId, serviceAccount) {
|
|
181
190
|
const sa = serviceAccount || defaultComputeServiceAccountEmail(projectId);
|
|
182
191
|
const name = `projects/${projectId}/serviceAccounts/${sa}`;
|
|
@@ -196,7 +205,6 @@ async function ensureAppHostingComputeServiceAccount(projectId, serviceAccount)
|
|
|
196
205
|
}
|
|
197
206
|
await provisionDefaultComputeServiceAccount(projectId);
|
|
198
207
|
}
|
|
199
|
-
exports.ensureAppHostingComputeServiceAccount = ensureAppHostingComputeServiceAccount;
|
|
200
208
|
async function promptNewBackendId(projectId, location) {
|
|
201
209
|
while (true) {
|
|
202
210
|
const backendId = await (0, prompt_1.input)({
|
|
@@ -216,7 +224,6 @@ async function promptNewBackendId(projectId, location) {
|
|
|
216
224
|
(0, utils_1.logWarning)(`Backend with id ${backendId} already exists in ${location}`);
|
|
217
225
|
}
|
|
218
226
|
}
|
|
219
|
-
exports.promptNewBackendId = promptNewBackendId;
|
|
220
227
|
function defaultComputeServiceAccountEmail(projectId) {
|
|
221
228
|
return `${DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME}@${projectId}.iam.gserviceaccount.com`;
|
|
222
229
|
}
|
|
@@ -236,11 +243,14 @@ async function createBackend(projectId, location, backendId, serviceAccount, rep
|
|
|
236
243
|
};
|
|
237
244
|
async function createBackendAndPoll() {
|
|
238
245
|
const op = await apphosting.createBackend(projectId, location, backendReqBody, backendId);
|
|
239
|
-
return await poller.pollOperation(
|
|
246
|
+
return await poller.pollOperation({
|
|
247
|
+
...apphostingPollerOptions,
|
|
248
|
+
pollerName: `create-${projectId}-${location}-${backendId}`,
|
|
249
|
+
operationResourceName: op.name,
|
|
250
|
+
});
|
|
240
251
|
}
|
|
241
252
|
return await createBackendAndPoll();
|
|
242
253
|
}
|
|
243
|
-
exports.createBackend = createBackend;
|
|
244
254
|
async function provisionDefaultComputeServiceAccount(projectId) {
|
|
245
255
|
try {
|
|
246
256
|
await iam.createServiceAccount(projectId, DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME, "Default service account used to run builds and deploys for Firebase App Hosting", "Firebase App Hosting compute service account");
|
|
@@ -274,14 +284,20 @@ async function setDefaultTrafficPolicy(projectId, location, backendId, codebaseB
|
|
|
274
284
|
},
|
|
275
285
|
};
|
|
276
286
|
const op = await apphosting.updateTraffic(projectId, location, backendId, traffic);
|
|
277
|
-
await poller.pollOperation(
|
|
287
|
+
await poller.pollOperation({
|
|
288
|
+
...apphostingPollerOptions,
|
|
289
|
+
pollerName: `updateTraffic-${projectId}-${location}-${backendId}`,
|
|
290
|
+
operationResourceName: op.name,
|
|
291
|
+
});
|
|
278
292
|
}
|
|
279
|
-
exports.setDefaultTrafficPolicy = setDefaultTrafficPolicy;
|
|
280
293
|
async function deleteBackendAndPoll(projectId, location, backendId) {
|
|
281
294
|
const op = await apphosting.deleteBackend(projectId, location, backendId);
|
|
282
|
-
await poller.pollOperation(
|
|
295
|
+
await poller.pollOperation({
|
|
296
|
+
...apphostingPollerOptions,
|
|
297
|
+
pollerName: `delete-${projectId}-${location}-${backendId}`,
|
|
298
|
+
operationResourceName: op.name,
|
|
299
|
+
});
|
|
283
300
|
}
|
|
284
|
-
exports.deleteBackendAndPoll = deleteBackendAndPoll;
|
|
285
301
|
async function promptLocation(projectId, prompt = "Please select a location:") {
|
|
286
302
|
const allowedLocations = (await apphosting.listLocations(projectId)).map((loc) => loc.locationId);
|
|
287
303
|
if (allowedLocations.length === 1) {
|
|
@@ -295,7 +311,6 @@ async function promptLocation(projectId, prompt = "Please select a location:") {
|
|
|
295
311
|
(0, utils_1.logSuccess)(`Location set to ${location}.\n`);
|
|
296
312
|
return location;
|
|
297
313
|
}
|
|
298
|
-
exports.promptLocation = promptLocation;
|
|
299
314
|
async function getBackendForLocation(projectId, location, backendId) {
|
|
300
315
|
try {
|
|
301
316
|
return await apphosting.getBackend(projectId, location, backendId);
|
|
@@ -306,7 +321,6 @@ async function getBackendForLocation(projectId, location, backendId) {
|
|
|
306
321
|
});
|
|
307
322
|
}
|
|
308
323
|
}
|
|
309
|
-
exports.getBackendForLocation = getBackendForLocation;
|
|
310
324
|
async function promptExistingBackend(projectId, promptMessage) {
|
|
311
325
|
const { backends } = await apphosting.listBackends(projectId, "-");
|
|
312
326
|
const backendId = await (0, prompt_1.search)({
|
|
@@ -328,7 +342,6 @@ async function promptExistingBackend(projectId, promptMessage) {
|
|
|
328
342
|
});
|
|
329
343
|
return backendId;
|
|
330
344
|
}
|
|
331
|
-
exports.promptExistingBackend = promptExistingBackend;
|
|
332
345
|
async function chooseBackends(projectId, backendId, chooseBackendPrompt, force) {
|
|
333
346
|
let { unreachable, backends } = await apphosting.listBackends(projectId, "-");
|
|
334
347
|
if (unreachable && unreachable.length !== 0) {
|
|
@@ -369,7 +382,6 @@ async function chooseBackends(projectId, backendId, chooseBackendPrompt, force)
|
|
|
369
382
|
});
|
|
370
383
|
return chosenBackends;
|
|
371
384
|
}
|
|
372
|
-
exports.chooseBackends = chooseBackends;
|
|
373
385
|
async function getBackendForAmbiguousLocation(projectId, backendId, locationDisambugationPrompt, force) {
|
|
374
386
|
let { unreachable, backends } = await apphosting.listBackends(projectId, "-");
|
|
375
387
|
if (unreachable && unreachable.length !== 0) {
|
|
@@ -394,7 +406,6 @@ async function getBackendForAmbiguousLocation(projectId, backendId, locationDisa
|
|
|
394
406
|
});
|
|
395
407
|
return backendsByLocation.get(location);
|
|
396
408
|
}
|
|
397
|
-
exports.getBackendForAmbiguousLocation = getBackendForAmbiguousLocation;
|
|
398
409
|
async function getBackend(projectId, backendId) {
|
|
399
410
|
let { unreachable, backends } = await apphosting.listBackends(projectId, "-");
|
|
400
411
|
backends = backends.filter((backend) => apphosting.parseBackendName(backend.name).id === backendId);
|
|
@@ -412,4 +423,3 @@ async function getBackend(projectId, backendId) {
|
|
|
412
423
|
}
|
|
413
424
|
throw new error_1.FirebaseError(`No backend named ${backendId} found.`);
|
|
414
425
|
}
|
|
415
|
-
exports.getBackend = getBackend;
|
package/lib/apphosting/config.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.APPHOSTING_YAML_FILE_REGEX = exports.APPHOSTING_LOCAL_YAML_FILE = exports.APPHOSTING_EMULATORS_YAML_FILE = exports.APPHOSTING_BASE_YAML_FILE = void 0;
|
|
4
|
+
exports.discoverBackendRoot = discoverBackendRoot;
|
|
5
|
+
exports.listAppHostingFilesInPath = listAppHostingFilesInPath;
|
|
6
|
+
exports.load = load;
|
|
7
|
+
exports.store = store;
|
|
8
|
+
exports.findEnv = findEnv;
|
|
9
|
+
exports.upsertEnv = upsertEnv;
|
|
10
|
+
exports.maybeAddSecretToYaml = maybeAddSecretToYaml;
|
|
11
|
+
exports.maybeGenerateEmulatorYaml = maybeGenerateEmulatorYaml;
|
|
12
|
+
exports.overrideChosenEnv = overrideChosenEnv;
|
|
13
|
+
exports.suggestedTestKeyName = suggestedTestKeyName;
|
|
4
14
|
const path_1 = require("path");
|
|
5
15
|
const fs_1 = require("fs");
|
|
6
16
|
const yaml = require("yaml");
|
|
@@ -33,14 +43,12 @@ function discoverBackendRoot(cwd) {
|
|
|
33
43
|
dir = parent;
|
|
34
44
|
}
|
|
35
45
|
}
|
|
36
|
-
exports.discoverBackendRoot = discoverBackendRoot;
|
|
37
46
|
function listAppHostingFilesInPath(path) {
|
|
38
47
|
return fs
|
|
39
48
|
.listFiles(path)
|
|
40
49
|
.filter((file) => exports.APPHOSTING_YAML_FILE_REGEX.test(file))
|
|
41
50
|
.map((file) => (0, path_1.join)(path, file));
|
|
42
51
|
}
|
|
43
|
-
exports.listAppHostingFilesInPath = listAppHostingFilesInPath;
|
|
44
52
|
function load(yamlPath) {
|
|
45
53
|
let raw;
|
|
46
54
|
try {
|
|
@@ -56,11 +64,9 @@ function load(yamlPath) {
|
|
|
56
64
|
}
|
|
57
65
|
return yaml.parseDocument(raw);
|
|
58
66
|
}
|
|
59
|
-
exports.load = load;
|
|
60
67
|
function store(yamlPath, document) {
|
|
61
68
|
(0, fs_1.writeFileSync)(yamlPath, document.toString());
|
|
62
69
|
}
|
|
63
|
-
exports.store = store;
|
|
64
70
|
function findEnv(document, variable) {
|
|
65
71
|
if (!document.has("env")) {
|
|
66
72
|
return undefined;
|
|
@@ -73,7 +79,6 @@ function findEnv(document, variable) {
|
|
|
73
79
|
}
|
|
74
80
|
return undefined;
|
|
75
81
|
}
|
|
76
|
-
exports.findEnv = findEnv;
|
|
77
82
|
function upsertEnv(document, env) {
|
|
78
83
|
if (!document.has("env")) {
|
|
79
84
|
document.set("env", document.createNode([env]));
|
|
@@ -89,7 +94,6 @@ function upsertEnv(document, env) {
|
|
|
89
94
|
}
|
|
90
95
|
envs.add(envYaml);
|
|
91
96
|
}
|
|
92
|
-
exports.upsertEnv = upsertEnv;
|
|
93
97
|
const dynamicDispatch = exports;
|
|
94
98
|
async function maybeAddSecretToYaml(secretName, fileName = exports.APPHOSTING_BASE_YAML_FILE) {
|
|
95
99
|
const backendRoot = dynamicDispatch.discoverBackendRoot(process.cwd());
|
|
@@ -126,7 +130,6 @@ async function maybeAddSecretToYaml(secretName, fileName = exports.APPHOSTING_BA
|
|
|
126
130
|
});
|
|
127
131
|
dynamicDispatch.store(path, projectYaml);
|
|
128
132
|
}
|
|
129
|
-
exports.maybeAddSecretToYaml = maybeAddSecretToYaml;
|
|
130
133
|
async function maybeGenerateEmulatorYaml(projectId, backendRoot) {
|
|
131
134
|
const basePath = dynamicDispatch.discoverBackendRoot(backendRoot) || backendRoot;
|
|
132
135
|
if (fs.fileExistsSync((0, path_1.join)(basePath, exports.APPHOSTING_EMULATORS_YAML_FILE))) {
|
|
@@ -137,7 +140,7 @@ async function maybeGenerateEmulatorYaml(projectId, backendRoot) {
|
|
|
137
140
|
try {
|
|
138
141
|
baseConfig = await yaml_1.AppHostingYamlConfig.loadFromFile((0, path_1.join)(basePath, exports.APPHOSTING_BASE_YAML_FILE));
|
|
139
142
|
}
|
|
140
|
-
catch
|
|
143
|
+
catch {
|
|
141
144
|
baseConfig = yaml_1.AppHostingYamlConfig.empty();
|
|
142
145
|
}
|
|
143
146
|
const createFile = await prompt.confirm({
|
|
@@ -154,7 +157,7 @@ async function maybeGenerateEmulatorYaml(projectId, backendRoot) {
|
|
|
154
157
|
if (envList.length) {
|
|
155
158
|
const newYaml = new yaml.Document();
|
|
156
159
|
for (const [variable, env] of envList) {
|
|
157
|
-
dynamicDispatch.upsertEnv(newYaml,
|
|
160
|
+
dynamicDispatch.upsertEnv(newYaml, { variable, ...env });
|
|
158
161
|
}
|
|
159
162
|
dynamicDispatch.store((0, path_1.join)(basePath, exports.APPHOSTING_EMULATORS_YAML_FILE), newYaml);
|
|
160
163
|
}
|
|
@@ -166,9 +169,8 @@ async function maybeGenerateEmulatorYaml(projectId, backendRoot) {
|
|
|
166
169
|
"# secret: cloud-secret-manager-id\n";
|
|
167
170
|
(0, fs_1.writeFileSync)((0, path_1.join)(basePath, exports.APPHOSTING_EMULATORS_YAML_FILE), sample);
|
|
168
171
|
}
|
|
169
|
-
return (0, yaml_1.toEnvList)(
|
|
172
|
+
return (0, yaml_1.toEnvList)({ ...baseConfig.env, ...newEnv });
|
|
170
173
|
}
|
|
171
|
-
exports.maybeGenerateEmulatorYaml = maybeGenerateEmulatorYaml;
|
|
172
174
|
async function overrideChosenEnv(projectId, env) {
|
|
173
175
|
const names = Object.keys(env);
|
|
174
176
|
if (!names.length) {
|
|
@@ -218,8 +220,6 @@ async function overrideChosenEnv(projectId, env) {
|
|
|
218
220
|
}
|
|
219
221
|
return newEnv;
|
|
220
222
|
}
|
|
221
|
-
exports.overrideChosenEnv = overrideChosenEnv;
|
|
222
223
|
function suggestedTestKeyName(variable) {
|
|
223
224
|
return "test-" + variable.replace(/_/g, "-").toLowerCase();
|
|
224
225
|
}
|
|
225
|
-
exports.suggestedTestKeyName = suggestedTestKeyName;
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateConnectionId = void 0;
|
|
4
|
+
exports.parseConnectionName = parseConnectionName;
|
|
5
|
+
exports.extractRepoSlugFromUri = extractRepoSlugFromUri;
|
|
6
|
+
exports.generateRepositoryId = generateRepositoryId;
|
|
7
|
+
exports.getOrCreateFullyInstalledGithubConnection = getOrCreateFullyInstalledGithubConnection;
|
|
8
|
+
exports.linkGitHubRepository = linkGitHubRepository;
|
|
9
|
+
exports.getConnectionForInstallation = getConnectionForInstallation;
|
|
10
|
+
exports.promptGitHubInstallation = promptGitHubInstallation;
|
|
11
|
+
exports.listValidInstallations = listValidInstallations;
|
|
12
|
+
exports.getOrCreateOauthConnection = getOrCreateOauthConnection;
|
|
13
|
+
exports.promptGitHubBranch = promptGitHubBranch;
|
|
14
|
+
exports.ensureSecretManagerAdminGrant = ensureSecretManagerAdminGrant;
|
|
15
|
+
exports.createConnection = createConnection;
|
|
16
|
+
exports.getOrCreateConnection = getOrCreateConnection;
|
|
17
|
+
exports.getOrCreateRepository = getOrCreateRepository;
|
|
18
|
+
exports.listAppHostingConnections = listAppHostingConnections;
|
|
19
|
+
exports.fetchRepositoryCloneUris = fetchRepositoryCloneUris;
|
|
20
|
+
exports.getGitHubBranch = getGitHubBranch;
|
|
21
|
+
exports.getGitHubCommit = getGitHubCommit;
|
|
4
22
|
const clc = require("colorette");
|
|
5
23
|
const devConnect = require("../gcp/devConnect");
|
|
6
24
|
const rm = require("../gcp/resourceManager");
|
|
@@ -17,7 +35,7 @@ const APPHOSTING_CONN_PATTERN = /.+\/apphosting-github-conn-.+$/;
|
|
|
17
35
|
const CONNECTION_NAME_REGEX = /^projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/connections\/(?<id>[^\/]+)$/;
|
|
18
36
|
function parseConnectionName(name) {
|
|
19
37
|
const match = CONNECTION_NAME_REGEX.exec(name);
|
|
20
|
-
if (!match || typeof match.groups === undefined) {
|
|
38
|
+
if (!match || typeof match.groups === "undefined") {
|
|
21
39
|
return;
|
|
22
40
|
}
|
|
23
41
|
const { projectId, location, id } = match.groups;
|
|
@@ -27,7 +45,6 @@ function parseConnectionName(name) {
|
|
|
27
45
|
id,
|
|
28
46
|
};
|
|
29
47
|
}
|
|
30
|
-
exports.parseConnectionName = parseConnectionName;
|
|
31
48
|
const devConnectPollerOptions = {
|
|
32
49
|
apiOrigin: (0, api_1.developerConnectOrigin)(),
|
|
33
50
|
apiVersion: "v1",
|
|
@@ -41,12 +58,9 @@ function extractRepoSlugFromUri(cloneUri) {
|
|
|
41
58
|
}
|
|
42
59
|
return match[1];
|
|
43
60
|
}
|
|
44
|
-
exports.extractRepoSlugFromUri = extractRepoSlugFromUri;
|
|
45
61
|
function generateRepositoryId(remoteUri) {
|
|
46
|
-
|
|
47
|
-
return (_a = extractRepoSlugFromUri(remoteUri)) === null || _a === void 0 ? void 0 : _a.replaceAll("/", "-");
|
|
62
|
+
return extractRepoSlugFromUri(remoteUri)?.replaceAll("/", "-");
|
|
48
63
|
}
|
|
49
|
-
exports.generateRepositoryId = generateRepositoryId;
|
|
50
64
|
const generateConnectionId = () => {
|
|
51
65
|
const randomHash = Math.random().toString(36).slice(6);
|
|
52
66
|
return `apphosting-github-conn-${randomHash}`;
|
|
@@ -92,9 +106,7 @@ async function getOrCreateFullyInstalledGithubConnection(projectId, location, cr
|
|
|
92
106
|
const connection = await createFullyInstalledConnection(projectId, location, createConnectionId, oauthConn, installationId);
|
|
93
107
|
return connection;
|
|
94
108
|
}
|
|
95
|
-
exports.getOrCreateFullyInstalledGithubConnection = getOrCreateFullyInstalledGithubConnection;
|
|
96
109
|
async function linkGitHubRepository(projectId, location, createConnectionId) {
|
|
97
|
-
var _a, _b;
|
|
98
110
|
const connection = await getOrCreateFullyInstalledGithubConnection(projectId, location, createConnectionId);
|
|
99
111
|
let repoCloneUri;
|
|
100
112
|
do {
|
|
@@ -105,18 +117,16 @@ async function linkGitHubRepository(projectId, location, createConnectionId) {
|
|
|
105
117
|
} while (repoCloneUri === MANAGE_INSTALLATION_CHOICE);
|
|
106
118
|
const { id: connectionId } = parseConnectionName(connection.name);
|
|
107
119
|
await getOrCreateConnection(projectId, location, connectionId, {
|
|
108
|
-
authorizerCredential:
|
|
109
|
-
appInstallationId:
|
|
120
|
+
authorizerCredential: connection.githubConfig?.authorizerCredential,
|
|
121
|
+
appInstallationId: connection.githubConfig?.appInstallationId,
|
|
110
122
|
});
|
|
111
123
|
const repo = await getOrCreateRepository(projectId, location, connectionId, repoCloneUri);
|
|
112
124
|
return repo;
|
|
113
125
|
}
|
|
114
|
-
exports.linkGitHubRepository = linkGitHubRepository;
|
|
115
126
|
async function createFullyInstalledConnection(projectId, location, connectionId, oauthConn, installationId) {
|
|
116
|
-
var _a;
|
|
117
127
|
let conn = await createConnection(projectId, location, connectionId, {
|
|
118
128
|
appInstallationId: installationId,
|
|
119
|
-
authorizerCredential:
|
|
129
|
+
authorizerCredential: oauthConn.githubConfig?.authorizerCredential,
|
|
120
130
|
});
|
|
121
131
|
while (conn.installationState.stage !== "COMPLETE") {
|
|
122
132
|
utils.logBullet("Install the Firebase App Hosting GitHub app to enable access to GitHub repositories");
|
|
@@ -129,9 +139,8 @@ async function createFullyInstalledConnection(projectId, location, connectionId,
|
|
|
129
139
|
return conn;
|
|
130
140
|
}
|
|
131
141
|
async function manageInstallation(connection) {
|
|
132
|
-
var _a;
|
|
133
142
|
utils.logBullet("Manage the Firebase App Hosting GitHub app to enable access to GitHub repositories");
|
|
134
|
-
const targetUri =
|
|
143
|
+
const targetUri = connection.githubConfig?.installationUri;
|
|
135
144
|
if (!targetUri) {
|
|
136
145
|
throw new error_1.FirebaseError("Failed to get Installation URI. Please try again.");
|
|
137
146
|
}
|
|
@@ -141,7 +150,7 @@ async function manageInstallation(connection) {
|
|
|
141
150
|
}
|
|
142
151
|
async function getConnectionForInstallation(projectId, location, installationId) {
|
|
143
152
|
const connections = await listAppHostingConnections(projectId, location);
|
|
144
|
-
const connectionsMatchingInstallation = connections.filter((conn) =>
|
|
153
|
+
const connectionsMatchingInstallation = connections.filter((conn) => conn.githubConfig?.appInstallationId === installationId);
|
|
145
154
|
if (connectionsMatchingInstallation.length === 0) {
|
|
146
155
|
return null;
|
|
147
156
|
}
|
|
@@ -151,7 +160,6 @@ async function getConnectionForInstallation(projectId, location, installationId)
|
|
|
151
160
|
}
|
|
152
161
|
return connectionsMatchingInstallation[0];
|
|
153
162
|
}
|
|
154
|
-
exports.getConnectionForInstallation = getConnectionForInstallation;
|
|
155
163
|
async function promptGitHubInstallation(projectId, location, connection) {
|
|
156
164
|
const installations = await listValidInstallations(projectId, location, connection);
|
|
157
165
|
const installationName = await (0, prompt_1.search)({
|
|
@@ -177,19 +185,16 @@ async function promptGitHubInstallation(projectId, location, connection) {
|
|
|
177
185
|
});
|
|
178
186
|
return installationName;
|
|
179
187
|
}
|
|
180
|
-
exports.promptGitHubInstallation = promptGitHubInstallation;
|
|
181
188
|
async function listValidInstallations(projectId, location, connection) {
|
|
182
189
|
const { id: connId } = parseConnectionName(connection.name);
|
|
183
190
|
let installations = await devConnect.fetchGitHubInstallations(projectId, location, connId);
|
|
184
191
|
installations = installations.filter((installation) => {
|
|
185
|
-
var _a, _b;
|
|
186
192
|
return ((installation.type === "user" &&
|
|
187
|
-
installation.name ===
|
|
193
|
+
installation.name === connection.githubConfig?.authorizerCredential?.username) ||
|
|
188
194
|
installation.type === "organization");
|
|
189
195
|
});
|
|
190
196
|
return installations;
|
|
191
197
|
}
|
|
192
|
-
exports.listValidInstallations = listValidInstallations;
|
|
193
198
|
async function getOrCreateOauthConnection(projectId, location) {
|
|
194
199
|
let conn;
|
|
195
200
|
const completedConnections = await listAppHostingConnections(projectId, location);
|
|
@@ -210,7 +215,6 @@ async function getOrCreateOauthConnection(projectId, location) {
|
|
|
210
215
|
utils.logSuccess("Connected with GitHub successfully\n");
|
|
211
216
|
return conn;
|
|
212
217
|
}
|
|
213
|
-
exports.getOrCreateOauthConnection = getOrCreateOauthConnection;
|
|
214
218
|
async function promptCloneUri(projectId, connection) {
|
|
215
219
|
const cloneUris = await fetchRepositoryCloneUris(projectId, connection);
|
|
216
220
|
const cloneUri = await (0, prompt_1.search)({
|
|
@@ -251,7 +255,6 @@ async function promptGitHubBranch(repoLink) {
|
|
|
251
255
|
});
|
|
252
256
|
return branch;
|
|
253
257
|
}
|
|
254
|
-
exports.promptGitHubBranch = promptGitHubBranch;
|
|
255
258
|
async function ensureSecretManagerAdminGrant(projectId) {
|
|
256
259
|
const projectNumber = await (0, getProjectNumber_1.getProjectNumber)({ projectId });
|
|
257
260
|
const dcsaEmail = devConnect.serviceAgentEmail(projectNumber);
|
|
@@ -274,7 +277,7 @@ async function ensureSecretManagerAdminGrant(projectId) {
|
|
|
274
277
|
await rm.addServiceAccountToRoles(projectId, dcsaEmail, ["roles/secretmanager.admin"], true);
|
|
275
278
|
}
|
|
276
279
|
catch (e) {
|
|
277
|
-
if (
|
|
280
|
+
if (e?.code === 400 || e?.status === 400) {
|
|
278
281
|
await devConnect.generateP4SA(projectNumber);
|
|
279
282
|
await rm.addServiceAccountToRoles(projectId, dcsaEmail, ["roles/secretmanager.admin"], true);
|
|
280
283
|
}
|
|
@@ -284,13 +287,15 @@ async function ensureSecretManagerAdminGrant(projectId) {
|
|
|
284
287
|
}
|
|
285
288
|
utils.logSuccess("Successfully granted the required role to the Developer Connect Service Agent!\n");
|
|
286
289
|
}
|
|
287
|
-
exports.ensureSecretManagerAdminGrant = ensureSecretManagerAdminGrant;
|
|
288
290
|
async function createConnection(projectId, location, connectionId, githubConfig) {
|
|
289
291
|
const op = await devConnect.createConnection(projectId, location, connectionId, githubConfig);
|
|
290
|
-
const conn = await poller.pollOperation(
|
|
292
|
+
const conn = await poller.pollOperation({
|
|
293
|
+
...devConnectPollerOptions,
|
|
294
|
+
pollerName: `create-${location}-${connectionId}`,
|
|
295
|
+
operationResourceName: op.name,
|
|
296
|
+
});
|
|
291
297
|
return conn;
|
|
292
298
|
}
|
|
293
|
-
exports.createConnection = createConnection;
|
|
294
299
|
async function getOrCreateConnection(projectId, location, connectionId, githubConfig) {
|
|
295
300
|
let conn;
|
|
296
301
|
try {
|
|
@@ -307,7 +312,6 @@ async function getOrCreateConnection(projectId, location, connectionId, githubCo
|
|
|
307
312
|
}
|
|
308
313
|
return conn;
|
|
309
314
|
}
|
|
310
|
-
exports.getOrCreateConnection = getOrCreateConnection;
|
|
311
315
|
async function getOrCreateRepository(projectId, location, connectionId, cloneUri) {
|
|
312
316
|
const repositoryId = generateRepositoryId(cloneUri);
|
|
313
317
|
if (!repositoryId) {
|
|
@@ -320,7 +324,11 @@ async function getOrCreateRepository(projectId, location, connectionId, cloneUri
|
|
|
320
324
|
catch (err) {
|
|
321
325
|
if (err.status === 404) {
|
|
322
326
|
const op = await devConnect.createGitRepositoryLink(projectId, location, connectionId, repositoryId, cloneUri);
|
|
323
|
-
repo = await poller.pollOperation(
|
|
327
|
+
repo = await poller.pollOperation({
|
|
328
|
+
...devConnectPollerOptions,
|
|
329
|
+
pollerName: `create-${location}-${connectionId}-${repositoryId}`,
|
|
330
|
+
operationResourceName: op.name,
|
|
331
|
+
});
|
|
324
332
|
}
|
|
325
333
|
else {
|
|
326
334
|
throw err;
|
|
@@ -328,21 +336,18 @@ async function getOrCreateRepository(projectId, location, connectionId, cloneUri
|
|
|
328
336
|
}
|
|
329
337
|
return repo;
|
|
330
338
|
}
|
|
331
|
-
exports.getOrCreateRepository = getOrCreateRepository;
|
|
332
339
|
async function listAppHostingConnections(projectId, location) {
|
|
333
340
|
const conns = await devConnect.listAllConnections(projectId, location);
|
|
334
341
|
return conns.filter((conn) => APPHOSTING_CONN_PATTERN.test(conn.name) &&
|
|
335
342
|
conn.installationState.stage === "COMPLETE" &&
|
|
336
343
|
!conn.disabled);
|
|
337
344
|
}
|
|
338
|
-
exports.listAppHostingConnections = listAppHostingConnections;
|
|
339
345
|
async function fetchRepositoryCloneUris(projectId, connection) {
|
|
340
346
|
const { location, id } = parseConnectionName(connection.name);
|
|
341
347
|
const connectionRepos = await devConnect.listAllLinkableGitRepositories(projectId, location, id);
|
|
342
348
|
const cloneUris = connectionRepos.map((conn) => conn.cloneUri);
|
|
343
349
|
return cloneUris;
|
|
344
350
|
}
|
|
345
|
-
exports.fetchRepositoryCloneUris = fetchRepositoryCloneUris;
|
|
346
351
|
async function getGitHubBranch(owner, repo, branch, readToken) {
|
|
347
352
|
const headers = { Authorization: `Bearer ${readToken}`, "User-Agent": "Firebase CLI" };
|
|
348
353
|
const { body } = await githubApiClient.get(`/repos/${owner}/${repo}/branches/${branch}`, {
|
|
@@ -350,7 +355,6 @@ async function getGitHubBranch(owner, repo, branch, readToken) {
|
|
|
350
355
|
});
|
|
351
356
|
return body;
|
|
352
357
|
}
|
|
353
|
-
exports.getGitHubBranch = getGitHubBranch;
|
|
354
358
|
async function getGitHubCommit(owner, repo, ref, readToken) {
|
|
355
359
|
const headers = { Authorization: `Bearer ${readToken}`, "User-Agent": "Firebase CLI" };
|
|
356
360
|
const { body } = await githubApiClient.get(`/repos/${owner}/${repo}/commits/${ref}`, {
|
|
@@ -358,4 +362,3 @@ async function getGitHubCommit(owner, repo, ref, readToken) {
|
|
|
358
362
|
});
|
|
359
363
|
return body;
|
|
360
364
|
}
|
|
361
|
-
exports.getGitHubCommit = getGitHubCommit;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.localBuild =
|
|
3
|
+
exports.localBuild = localBuild;
|
|
4
4
|
const build_1 = require("@apphosting/build");
|
|
5
5
|
async function localBuild(projectRoot, framework) {
|
|
6
|
-
var _a, _b, _c;
|
|
7
6
|
const apphostingBuildOutput = await (0, build_1.localBuild)(projectRoot, framework);
|
|
8
7
|
const annotations = Object.fromEntries(Object.entries(apphostingBuildOutput.metadata).map(([key, value]) => [key, String(value)]));
|
|
9
|
-
const env =
|
|
8
|
+
const env = apphostingBuildOutput.runConfig.environmentVariables?.map(({ variable, value, availability }) => ({
|
|
10
9
|
variable,
|
|
11
10
|
value,
|
|
12
11
|
availability,
|
|
13
12
|
}));
|
|
14
13
|
return {
|
|
15
|
-
outputFiles:
|
|
14
|
+
outputFiles: apphostingBuildOutput.outputFiles?.serverApp.include ?? [],
|
|
16
15
|
annotations,
|
|
17
16
|
buildConfig: {
|
|
18
17
|
runCommand: apphostingBuildOutput.runConfig.runCommand,
|
|
19
|
-
env: env
|
|
18
|
+
env: env ?? [],
|
|
20
19
|
},
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
|
-
exports.localBuild = localBuild;
|