firebase-tools-with-isolate 13.29.1 → 14.10.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.actuate = exports.
|
|
3
|
+
exports.toDNSCompatibleId = exports.postSetup = exports.actuate = exports.askQuestions = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const clc = require("colorette");
|
|
6
6
|
const fs = require("fs-extra");
|
|
@@ -18,6 +18,8 @@ const utils_1 = require("../../../utils");
|
|
|
18
18
|
const cloudbilling_1 = require("../../../gcp/cloudbilling");
|
|
19
19
|
const sdk = require("./sdk");
|
|
20
20
|
const fileUtils_1 = require("../../../dataconnect/fileUtils");
|
|
21
|
+
const fdcExperience_1 = require("../../../gemini/fdcExperience");
|
|
22
|
+
const configstore_1 = require("../../../configstore");
|
|
21
23
|
const DATACONNECT_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/dataconnect.yaml");
|
|
22
24
|
const CONNECTOR_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/connector.yaml");
|
|
23
25
|
const SCHEMA_TEMPLATE = (0, templates_1.readTemplateSync)("init/dataconnect/schema.gql");
|
|
@@ -43,29 +45,11 @@ const defaultConnector = {
|
|
|
43
45
|
],
|
|
44
46
|
};
|
|
45
47
|
const defaultSchema = { path: "schema.gql", content: SCHEMA_TEMPLATE };
|
|
46
|
-
async function
|
|
47
|
-
const
|
|
48
|
+
async function askQuestions(setup) {
|
|
49
|
+
const hasBilling = await (0, cloudbilling_1.isBillingEnabled)(setup);
|
|
48
50
|
if (setup.projectId) {
|
|
49
|
-
|
|
51
|
+
hasBilling ? await (0, ensureApis_1.ensureApis)(setup.projectId) : await (0, ensureApis_1.ensureSparkApis)(setup.projectId);
|
|
50
52
|
}
|
|
51
|
-
const info = await askQuestions(setup, isBillingEnabled);
|
|
52
|
-
const dir = config.get("dataconnect.source", "dataconnect");
|
|
53
|
-
const dataDir = config.get("emulators.dataconnect.dataDir", `${dir}/.dataconnect/pgliteData`);
|
|
54
|
-
config.set("emulators.dataconnect.dataDir", dataDir);
|
|
55
|
-
await actuate(setup, config, info);
|
|
56
|
-
const cwdPlatformGuess = await (0, fileUtils_1.getPlatformFromFolder)(process.cwd());
|
|
57
|
-
if (cwdPlatformGuess !== types_1.Platform.NONE) {
|
|
58
|
-
await sdk.doSetup(setup, config);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
(0, utils_1.logBullet)(`If you'd like to add the generated SDK to your app your, run ${clc.bold("firebase init dataconnect:sdk")}`);
|
|
62
|
-
}
|
|
63
|
-
if (setup.projectId && !isBillingEnabled) {
|
|
64
|
-
(0, utils_1.logBullet)((0, freeTrial_1.upgradeInstructions)(setup.projectId));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.doSetup = doSetup;
|
|
68
|
-
async function askQuestions(setup, isBillingEnabled) {
|
|
69
53
|
let info = {
|
|
70
54
|
serviceId: "",
|
|
71
55
|
locationId: "",
|
|
@@ -73,72 +57,91 @@ async function askQuestions(setup, isBillingEnabled) {
|
|
|
73
57
|
isNewInstance: false,
|
|
74
58
|
cloudSqlDatabase: "",
|
|
75
59
|
isNewDatabase: false,
|
|
76
|
-
connectors: [
|
|
77
|
-
schemaGql: [
|
|
60
|
+
connectors: [],
|
|
61
|
+
schemaGql: [],
|
|
78
62
|
shouldProvisionCSQL: false,
|
|
79
63
|
};
|
|
80
|
-
info = await promptForExistingServices(setup, info
|
|
64
|
+
info = await promptForExistingServices(setup, info);
|
|
81
65
|
const requiredConfigUnset = info.serviceId === "" ||
|
|
82
66
|
info.cloudSqlInstanceId === "" ||
|
|
83
67
|
info.locationId === "" ||
|
|
84
68
|
info.cloudSqlDatabase === "";
|
|
85
|
-
const shouldConfigureBackend =
|
|
86
|
-
|
|
87
|
-
|
|
69
|
+
const shouldConfigureBackend = hasBilling &&
|
|
70
|
+
requiredConfigUnset &&
|
|
71
|
+
(await (0, prompt_1.confirm)({
|
|
72
|
+
message: `Would you like to configure your Cloud SQL datasource now?`,
|
|
88
73
|
default: true,
|
|
89
|
-
})
|
|
90
|
-
: false;
|
|
74
|
+
}));
|
|
91
75
|
if (shouldConfigureBackend) {
|
|
92
|
-
info = await
|
|
76
|
+
info = await promptForSchema(setup, info);
|
|
93
77
|
info = await promptForCloudSQL(setup, info);
|
|
94
78
|
info.shouldProvisionCSQL = !!(setup.projectId &&
|
|
95
79
|
(info.isNewInstance || info.isNewDatabase) &&
|
|
96
|
-
|
|
80
|
+
hasBilling &&
|
|
97
81
|
(await (0, prompt_1.confirm)({
|
|
98
82
|
message: `Would you like to provision your Cloud SQL instance and database now?${info.isNewInstance ? " This will take several minutes." : ""}.`,
|
|
99
83
|
default: true,
|
|
100
84
|
})));
|
|
101
85
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
info.cloudSqlInstanceId = info.cloudSqlInstanceId || `${info.serviceId || "app"}-fdc`;
|
|
105
|
-
info.locationId = info.locationId || `us-central1`;
|
|
106
|
-
info.cloudSqlDatabase = info.cloudSqlDatabase || `fdcdb`;
|
|
107
|
-
}
|
|
108
|
-
return info;
|
|
86
|
+
setup.featureInfo = setup.featureInfo || {};
|
|
87
|
+
setup.featureInfo.dataconnect = info;
|
|
109
88
|
}
|
|
110
|
-
|
|
111
|
-
|
|
89
|
+
exports.askQuestions = askQuestions;
|
|
90
|
+
async function actuate(setup, config, options) {
|
|
91
|
+
const dir = config.get("dataconnect.source", "dataconnect");
|
|
92
|
+
const dataDir = config.get("emulators.dataconnect.dataDir", `${dir}/.dataconnect/pgliteData`);
|
|
93
|
+
config.set("emulators.dataconnect.dataDir", dataDir);
|
|
94
|
+
const info = setup.featureInfo?.dataconnect;
|
|
95
|
+
if (!info) {
|
|
96
|
+
throw new Error("Data Connect feature RequiredInfo is not provided");
|
|
97
|
+
}
|
|
98
|
+
const defaultServiceId = toDNSCompatibleId((0, path_1.basename)(process.cwd()));
|
|
99
|
+
info.serviceId = info.serviceId || defaultServiceId;
|
|
100
|
+
info.cloudSqlInstanceId =
|
|
101
|
+
info.cloudSqlInstanceId || `${info.serviceId.toLowerCase() || "app"}-fdc`;
|
|
102
|
+
info.locationId = info.locationId || `us-central1`;
|
|
103
|
+
info.cloudSqlDatabase = info.cloudSqlDatabase || `fdcdb`;
|
|
104
|
+
if (!info.schemaGql.length && !info.connectors.flatMap((r) => r.files).length) {
|
|
105
|
+
info.schemaGql = [defaultSchema];
|
|
106
|
+
info.connectors = [defaultConnector];
|
|
107
|
+
}
|
|
108
|
+
await writeFiles(config, info, options);
|
|
112
109
|
if (setup.projectId && info.shouldProvisionCSQL) {
|
|
113
110
|
await (0, provisionCloudSql_1.provisionCloudSql)({
|
|
114
111
|
projectId: setup.projectId,
|
|
115
|
-
|
|
112
|
+
location: info.locationId,
|
|
116
113
|
instanceId: info.cloudSqlInstanceId,
|
|
117
114
|
databaseId: info.cloudSqlDatabase,
|
|
118
|
-
configYamlPath: (0, path_1.join)(config.get("dataconnect.source"), "dataconnect.yaml"),
|
|
119
115
|
enableGoogleMlIntegration: false,
|
|
120
116
|
waitForCreation: false,
|
|
121
117
|
});
|
|
122
118
|
}
|
|
123
119
|
}
|
|
124
120
|
exports.actuate = actuate;
|
|
125
|
-
async function
|
|
121
|
+
async function postSetup(setup, config) {
|
|
122
|
+
const cwdPlatformGuess = await (0, fileUtils_1.getPlatformFromFolder)(process.cwd());
|
|
123
|
+
if (cwdPlatformGuess !== types_1.Platform.NONE || (0, utils_1.envOverride)("FDC_CONNECTOR", "")) {
|
|
124
|
+
await sdk.doSetup(setup, config);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
(0, utils_1.logBullet)(`If you'd like to add the generated SDK to your app later, run ${clc.bold("firebase init dataconnect:sdk")}`);
|
|
128
|
+
}
|
|
129
|
+
if (setup.projectId && !setup.isBillingEnabled) {
|
|
130
|
+
(0, utils_1.logBullet)((0, freeTrial_1.upgradeInstructions)(setup.projectId));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.postSetup = postSetup;
|
|
134
|
+
async function writeFiles(config, info, options) {
|
|
126
135
|
const dir = config.get("dataconnect.source") || "dataconnect";
|
|
127
136
|
const subbedDataconnectYaml = subDataconnectYamlValues({
|
|
128
137
|
...info,
|
|
129
138
|
connectorDirs: info.connectors.map((c) => c.path),
|
|
130
139
|
});
|
|
131
|
-
if (!config.get("dataconnect.source")) {
|
|
132
|
-
if (!info.schemaGql.length && !info.connectors.flatMap((r) => r.files).length) {
|
|
133
|
-
info.schemaGql = [defaultSchema];
|
|
134
|
-
info.connectors = [defaultConnector];
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
140
|
config.set("dataconnect", { source: dir });
|
|
138
|
-
await config.askWriteProjectFile((0, path_1.join)(dir, "dataconnect.yaml"), subbedDataconnectYaml,
|
|
141
|
+
await config.askWriteProjectFile((0, path_1.join)(dir, "dataconnect.yaml"), subbedDataconnectYaml, !!options.force, true);
|
|
139
142
|
if (info.schemaGql.length) {
|
|
140
143
|
for (const f of info.schemaGql) {
|
|
141
|
-
await config.askWriteProjectFile((0, path_1.join)(dir, "schema", f.path), f.content);
|
|
144
|
+
await config.askWriteProjectFile((0, path_1.join)(dir, "schema", f.path), f.content, !!options.force);
|
|
142
145
|
}
|
|
143
146
|
}
|
|
144
147
|
else {
|
|
@@ -180,31 +183,16 @@ function subConnectorYamlValues(replacementValues) {
|
|
|
180
183
|
}
|
|
181
184
|
return replaced;
|
|
182
185
|
}
|
|
183
|
-
async function promptForExistingServices(setup, info
|
|
184
|
-
if (!setup.projectId
|
|
186
|
+
async function promptForExistingServices(setup, info) {
|
|
187
|
+
if (!setup.projectId) {
|
|
185
188
|
return info;
|
|
186
189
|
}
|
|
187
190
|
const existingServices = await (0, client_1.listAllServices)(setup.projectId);
|
|
188
191
|
const existingServicesAndSchemas = await Promise.all(existingServices.map(async (s) => {
|
|
189
|
-
return {
|
|
190
|
-
service: s,
|
|
191
|
-
schema: await (0, client_1.getSchema)(s.name),
|
|
192
|
-
};
|
|
192
|
+
return { service: s, schema: await (0, client_1.getSchema)(s.name) };
|
|
193
193
|
}));
|
|
194
194
|
if (existingServicesAndSchemas.length) {
|
|
195
|
-
const
|
|
196
|
-
const serviceName = (0, names_1.parseServiceName)(s.service.name);
|
|
197
|
-
return {
|
|
198
|
-
name: `${serviceName.location}/${serviceName.serviceId}`,
|
|
199
|
-
value: s,
|
|
200
|
-
};
|
|
201
|
-
});
|
|
202
|
-
choices.push({ name: "Create a new service", value: undefined });
|
|
203
|
-
const choice = await (0, prompt_1.promptOnce)({
|
|
204
|
-
message: "Your project already has existing services. Which would you like to set up local files for?",
|
|
205
|
-
type: "list",
|
|
206
|
-
choices,
|
|
207
|
-
});
|
|
195
|
+
const choice = await chooseExistingService(existingServicesAndSchemas);
|
|
208
196
|
if (choice) {
|
|
209
197
|
const serviceName = (0, names_1.parseServiceName)(choice.service.name);
|
|
210
198
|
info.serviceId = serviceName.serviceId;
|
|
@@ -240,6 +228,34 @@ async function promptForExistingServices(setup, info, isBillingEnabled) {
|
|
|
240
228
|
}
|
|
241
229
|
return info;
|
|
242
230
|
}
|
|
231
|
+
async function chooseExistingService(existing) {
|
|
232
|
+
const serviceEnvVar = (0, utils_1.envOverride)("FDC_CONNECTOR", "") || (0, utils_1.envOverride)("FDC_SERVICE", "");
|
|
233
|
+
if (serviceEnvVar) {
|
|
234
|
+
const [serviceLocationFromEnvVar, serviceIdFromEnvVar] = serviceEnvVar.split("/");
|
|
235
|
+
const serviceFromEnvVar = existing.find((s) => {
|
|
236
|
+
const serviceName = (0, names_1.parseServiceName)(s.service.name);
|
|
237
|
+
return (serviceName.serviceId === serviceIdFromEnvVar &&
|
|
238
|
+
serviceName.location === serviceLocationFromEnvVar);
|
|
239
|
+
});
|
|
240
|
+
if (serviceFromEnvVar) {
|
|
241
|
+
(0, utils_1.logBullet)(`Picking up the existing service ${clc.bold(serviceLocationFromEnvVar + "/" + serviceIdFromEnvVar)}.`);
|
|
242
|
+
return serviceFromEnvVar;
|
|
243
|
+
}
|
|
244
|
+
(0, utils_1.logWarning)(`Unable to pick up an existing service based on FDC_SERVICE=${serviceEnvVar}.`);
|
|
245
|
+
}
|
|
246
|
+
const choices = existing.map((s) => {
|
|
247
|
+
const serviceName = (0, names_1.parseServiceName)(s.service.name);
|
|
248
|
+
return {
|
|
249
|
+
name: `${serviceName.location}/${serviceName.serviceId}`,
|
|
250
|
+
value: s,
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
choices.push({ name: "Create a new service", value: undefined });
|
|
254
|
+
return await (0, prompt_1.select)({
|
|
255
|
+
message: "Your project already has existing services. Which would you like to set up local files for?",
|
|
256
|
+
choices,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
243
259
|
async function promptForCloudSQL(setup, info) {
|
|
244
260
|
if (info.cloudSqlInstanceId === "" && setup.projectId) {
|
|
245
261
|
const instances = await cloudsql.listInstances(setup.projectId);
|
|
@@ -255,9 +271,11 @@ async function promptForCloudSQL(setup, info) {
|
|
|
255
271
|
if (!(await (0, freeTrial_1.checkFreeTrialInstanceUsed)(setup.projectId))) {
|
|
256
272
|
choices.push({ name: "Create a new free trial instance", value: "", location: "" });
|
|
257
273
|
}
|
|
258
|
-
|
|
274
|
+
else {
|
|
275
|
+
choices.push({ name: "Create a new CloudSQL instance", value: "", location: "" });
|
|
276
|
+
}
|
|
277
|
+
info.cloudSqlInstanceId = await (0, prompt_1.select)({
|
|
259
278
|
message: `Which CloudSQL instance would you like to use?`,
|
|
260
|
-
type: "list",
|
|
261
279
|
choices,
|
|
262
280
|
});
|
|
263
281
|
if (info.cloudSqlInstanceId !== "") {
|
|
@@ -267,17 +285,15 @@ async function promptForCloudSQL(setup, info) {
|
|
|
267
285
|
}
|
|
268
286
|
if (info.cloudSqlInstanceId === "") {
|
|
269
287
|
info.isNewInstance = true;
|
|
270
|
-
info.cloudSqlInstanceId = await (0, prompt_1.
|
|
288
|
+
info.cloudSqlInstanceId = await (0, prompt_1.input)({
|
|
271
289
|
message: `What ID would you like to use for your new CloudSQL instance?`,
|
|
272
|
-
|
|
273
|
-
default: `${info.serviceId || "app"}-fdc`,
|
|
290
|
+
default: `${info.serviceId.toLowerCase() || "app"}-fdc`,
|
|
274
291
|
});
|
|
275
292
|
}
|
|
276
293
|
if (info.locationId === "") {
|
|
277
294
|
const choices = await locationChoices(setup);
|
|
278
|
-
info.locationId = await (0, prompt_1.
|
|
295
|
+
info.locationId = await (0, prompt_1.select)({
|
|
279
296
|
message: "What location would like to use?",
|
|
280
|
-
type: "list",
|
|
281
297
|
choices,
|
|
282
298
|
});
|
|
283
299
|
}
|
|
@@ -289,9 +305,8 @@ async function promptForCloudSQL(setup, info) {
|
|
|
289
305
|
});
|
|
290
306
|
choices.push({ name: "Create a new database", value: "" });
|
|
291
307
|
if (dbs.length) {
|
|
292
|
-
info.cloudSqlDatabase = await (0, prompt_1.
|
|
308
|
+
info.cloudSqlDatabase = await (0, prompt_1.select)({
|
|
293
309
|
message: `Which database in ${info.cloudSqlInstanceId} would you like to use?`,
|
|
294
|
-
type: "list",
|
|
295
310
|
choices,
|
|
296
311
|
});
|
|
297
312
|
}
|
|
@@ -302,21 +317,38 @@ async function promptForCloudSQL(setup, info) {
|
|
|
302
317
|
}
|
|
303
318
|
if (info.cloudSqlDatabase === "") {
|
|
304
319
|
info.isNewDatabase = true;
|
|
305
|
-
info.cloudSqlDatabase = await (0, prompt_1.
|
|
320
|
+
info.cloudSqlDatabase = await (0, prompt_1.input)({
|
|
306
321
|
message: `What ID would you like to use for your new database in ${info.cloudSqlInstanceId}?`,
|
|
307
|
-
type: "input",
|
|
308
322
|
default: `fdcdb`,
|
|
309
323
|
});
|
|
310
324
|
}
|
|
311
325
|
return info;
|
|
312
326
|
}
|
|
313
|
-
async function
|
|
327
|
+
async function promptForSchema(setup, info) {
|
|
314
328
|
if (info.serviceId === "") {
|
|
315
|
-
info.serviceId = await (0, prompt_1.
|
|
329
|
+
info.serviceId = await (0, prompt_1.input)({
|
|
316
330
|
message: "What ID would you like to use for this service?",
|
|
317
|
-
type: "input",
|
|
318
331
|
default: (0, path_1.basename)(process.cwd()),
|
|
319
332
|
});
|
|
333
|
+
if (setup.projectId) {
|
|
334
|
+
if (!configstore_1.configstore.get("gemini")) {
|
|
335
|
+
(0, utils_1.logBullet)("Learn more about Gemini in Firebase and how it uses your data: https://firebase.google.com/docs/gemini-in-firebase#how-gemini-in-firebase-uses-your-data");
|
|
336
|
+
}
|
|
337
|
+
if (await (0, prompt_1.confirm)({
|
|
338
|
+
message: `Do you want Gemini in Firebase to help generate a schema for your service?`,
|
|
339
|
+
default: false,
|
|
340
|
+
})) {
|
|
341
|
+
configstore_1.configstore.set("gemini", true);
|
|
342
|
+
await (0, ensureApis_1.ensureGIFApis)(setup.projectId);
|
|
343
|
+
const prompt = await (0, prompt_1.input)({
|
|
344
|
+
message: "Describe the app you are building:",
|
|
345
|
+
default: "movie rating app",
|
|
346
|
+
});
|
|
347
|
+
const schema = await (0, utils_1.promiseWithSpinner)(() => (0, fdcExperience_1.generateSchema)(prompt, setup.projectId), "Generating the Data Connect Schema...");
|
|
348
|
+
info.schemaGql = [{ path: "schema.gql", content: (0, fdcExperience_1.extractCodeBlock)(schema) }];
|
|
349
|
+
info.connectors = [emptyConnector];
|
|
350
|
+
}
|
|
351
|
+
}
|
|
320
352
|
}
|
|
321
353
|
return info;
|
|
322
354
|
}
|
|
@@ -340,3 +372,17 @@ async function locationChoices(setup) {
|
|
|
340
372
|
];
|
|
341
373
|
}
|
|
342
374
|
}
|
|
375
|
+
function toDNSCompatibleId(id) {
|
|
376
|
+
let defaultServiceId = (0, path_1.basename)(id)
|
|
377
|
+
.toLowerCase()
|
|
378
|
+
.replaceAll(/[^a-z0-9-]/g, "")
|
|
379
|
+
.slice(0, 63);
|
|
380
|
+
while (defaultServiceId.endsWith("-") && defaultServiceId.length) {
|
|
381
|
+
defaultServiceId = defaultServiceId.slice(0, defaultServiceId.length - 1);
|
|
382
|
+
}
|
|
383
|
+
while (defaultServiceId.startsWith("-") && defaultServiceId.length) {
|
|
384
|
+
defaultServiceId = defaultServiceId.slice(1, defaultServiceId.length);
|
|
385
|
+
}
|
|
386
|
+
return defaultServiceId || "app";
|
|
387
|
+
}
|
|
388
|
+
exports.toDNSCompatibleId = toDNSCompatibleId;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.actuate = exports.generateSdkYaml = exports.doSetup = exports.FDC_APP_FOLDER = void 0;
|
|
4
4
|
const yaml = require("yaml");
|
|
5
|
-
const fs = require("fs");
|
|
6
5
|
const clc = require("colorette");
|
|
7
6
|
const path = require("path");
|
|
8
7
|
const fsutils_1 = require("../../../fsutils");
|
|
@@ -14,10 +13,11 @@ const dataconnectEmulator_1 = require("../../../emulator/dataconnectEmulator");
|
|
|
14
13
|
const error_1 = require("../../../error");
|
|
15
14
|
const lodash_1 = require("lodash");
|
|
16
15
|
const utils_1 = require("../../../utils");
|
|
16
|
+
const auth_1 = require("../../../auth");
|
|
17
17
|
exports.FDC_APP_FOLDER = "_FDC_APP_FOLDER";
|
|
18
18
|
async function doSetup(setup, config) {
|
|
19
19
|
const sdkInfo = await askQuestions(setup, config);
|
|
20
|
-
await actuate(sdkInfo);
|
|
20
|
+
await actuate(sdkInfo, config);
|
|
21
21
|
(0, utils_1.logSuccess)(`If you'd like to add more generated SDKs to your app your later, run ${clc.bold("firebase init dataconnect:sdk")} again`);
|
|
22
22
|
}
|
|
23
23
|
exports.doSetup = doSetup;
|
|
@@ -28,7 +28,7 @@ async function askQuestions(setup, config) {
|
|
|
28
28
|
.map((si) => {
|
|
29
29
|
return si.connectorInfo.map((ci) => {
|
|
30
30
|
return {
|
|
31
|
-
name: `${si.dataConnectYaml.serviceId}/${ci.connectorYaml.connectorId}`,
|
|
31
|
+
name: `${si.dataConnectYaml.location}/${si.dataConnectYaml.serviceId}/${ci.connectorYaml.connectorId}`,
|
|
32
32
|
value: ci,
|
|
33
33
|
};
|
|
34
34
|
});
|
|
@@ -40,7 +40,7 @@ async function askQuestions(setup, config) {
|
|
|
40
40
|
let appDir = process.env[exports.FDC_APP_FOLDER] || process.cwd();
|
|
41
41
|
let targetPlatform = await (0, fileUtils_1.getPlatformFromFolder)(appDir);
|
|
42
42
|
if (targetPlatform === types_1.Platform.NONE && !process.env[exports.FDC_APP_FOLDER]?.length) {
|
|
43
|
-
appDir = await (0,
|
|
43
|
+
appDir = await (0, utils_1.promptForDirectory)({
|
|
44
44
|
config,
|
|
45
45
|
message: "Where is your app directory? Leave blank to set up a generated SDK in your current directory.",
|
|
46
46
|
});
|
|
@@ -59,28 +59,57 @@ async function askQuestions(setup, config) {
|
|
|
59
59
|
{ name: "Android (Kotlin)", value: types_1.Platform.ANDROID },
|
|
60
60
|
{ name: "Flutter (Dart)", value: types_1.Platform.FLUTTER },
|
|
61
61
|
];
|
|
62
|
-
targetPlatform = await (0, prompt_1.
|
|
62
|
+
targetPlatform = await (0, prompt_1.select)({
|
|
63
63
|
message: "Which platform do you want to set up a generated SDK for?",
|
|
64
|
-
type: "list",
|
|
65
64
|
choices: platforms,
|
|
66
65
|
});
|
|
67
66
|
}
|
|
68
67
|
else {
|
|
69
68
|
(0, utils_1.logSuccess)(`Detected ${targetPlatform} app in directory ${appDir}`);
|
|
70
69
|
}
|
|
71
|
-
const connectorInfo = await (
|
|
72
|
-
message: "Which connector do you want set up a generated SDK for?",
|
|
73
|
-
type: "list",
|
|
74
|
-
choices: connectorChoices,
|
|
75
|
-
});
|
|
70
|
+
const connectorInfo = await chooseExistingConnector(connectorChoices);
|
|
76
71
|
const connectorYaml = JSON.parse(JSON.stringify(connectorInfo.connectorYaml));
|
|
77
|
-
const newConnectorYaml = generateSdkYaml(targetPlatform, connectorYaml, connectorInfo.directory, appDir);
|
|
72
|
+
const newConnectorYaml = await generateSdkYaml(targetPlatform, connectorYaml, connectorInfo.directory, appDir);
|
|
73
|
+
if (targetPlatform === types_1.Platform.WEB) {
|
|
74
|
+
const unusedFrameworks = fileUtils_1.SUPPORTED_FRAMEWORKS.filter((framework) => !newConnectorYaml.generate?.javascriptSdk[framework]);
|
|
75
|
+
if (unusedFrameworks.length > 0) {
|
|
76
|
+
const additionalFrameworks = await (0, prompt_1.checkbox)({
|
|
77
|
+
message: "Which frameworks would you like to generate SDKs for? " +
|
|
78
|
+
"Press Space to select features, then Enter to confirm your choices.",
|
|
79
|
+
choices: fileUtils_1.SUPPORTED_FRAMEWORKS.map((frameworkStr) => ({
|
|
80
|
+
value: frameworkStr,
|
|
81
|
+
checked: newConnectorYaml?.generate?.javascriptSdk?.[frameworkStr],
|
|
82
|
+
})),
|
|
83
|
+
});
|
|
84
|
+
for (const framework of additionalFrameworks) {
|
|
85
|
+
newConnectorYaml.generate.javascriptSdk[framework] = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
78
89
|
const connectorYamlContents = yaml.stringify(newConnectorYaml);
|
|
79
90
|
connectorInfo.connectorYaml = newConnectorYaml;
|
|
80
91
|
const displayIOSWarning = targetPlatform === types_1.Platform.IOS;
|
|
81
92
|
return { connectorYamlContents, connectorInfo, displayIOSWarning };
|
|
82
93
|
}
|
|
83
|
-
function
|
|
94
|
+
async function chooseExistingConnector(choices) {
|
|
95
|
+
if (choices.length === 1) {
|
|
96
|
+
return choices[0].value;
|
|
97
|
+
}
|
|
98
|
+
const connectorEnvVar = (0, utils_1.envOverride)("FDC_CONNECTOR", "");
|
|
99
|
+
if (connectorEnvVar) {
|
|
100
|
+
const existingConnector = choices.find((c) => c.name === connectorEnvVar);
|
|
101
|
+
if (existingConnector) {
|
|
102
|
+
(0, utils_1.logBullet)(`Picking up the existing connector ${clc.bold(connectorEnvVar)}.`);
|
|
103
|
+
return existingConnector.value;
|
|
104
|
+
}
|
|
105
|
+
(0, utils_1.logWarning)(`Unable to pick up an existing connector based on FDC_CONNECTOR=${connectorEnvVar}.`);
|
|
106
|
+
}
|
|
107
|
+
return await (0, prompt_1.select)({
|
|
108
|
+
message: "Which connector do you want set up a generated SDK for?",
|
|
109
|
+
choices: choices,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async function generateSdkYaml(targetPlatform, connectorYaml, connectorDir, appDir) {
|
|
84
113
|
if (!connectorYaml.generate) {
|
|
85
114
|
connectorYaml.generate = {};
|
|
86
115
|
}
|
|
@@ -93,11 +122,20 @@ function generateSdkYaml(targetPlatform, connectorYaml, connectorDir, appDir) {
|
|
|
93
122
|
}
|
|
94
123
|
if (targetPlatform === types_1.Platform.WEB) {
|
|
95
124
|
const pkg = `${connectorYaml.connectorId}-connector`;
|
|
125
|
+
const packageJsonDir = path.relative(connectorDir, appDir);
|
|
96
126
|
const javascriptSdk = {
|
|
97
127
|
outputDir: path.relative(connectorDir, path.join(appDir, `dataconnect-generated/js/${pkg}`)),
|
|
98
128
|
package: `@firebasegen/${pkg}`,
|
|
99
|
-
packageJsonDir
|
|
129
|
+
packageJsonDir,
|
|
100
130
|
};
|
|
131
|
+
const packageJson = await (0, fileUtils_1.resolvePackageJson)(appDir);
|
|
132
|
+
if (packageJson) {
|
|
133
|
+
const frameworksUsed = (0, fileUtils_1.getFrameworksFromPackageJson)(packageJson);
|
|
134
|
+
for (const framework of frameworksUsed) {
|
|
135
|
+
(0, utils_1.logBullet)(`Detected ${framework} app. Enabling ${framework} generated SDKs.`);
|
|
136
|
+
javascriptSdk[framework] = true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
101
139
|
connectorYaml.generate.javascriptSdk = javascriptSdk;
|
|
102
140
|
}
|
|
103
141
|
if (targetPlatform === types_1.Platform.FLUTTER) {
|
|
@@ -124,17 +162,34 @@ function generateSdkYaml(targetPlatform, connectorYaml, connectorDir, appDir) {
|
|
|
124
162
|
return connectorYaml;
|
|
125
163
|
}
|
|
126
164
|
exports.generateSdkYaml = generateSdkYaml;
|
|
127
|
-
async function actuate(sdkInfo) {
|
|
165
|
+
async function actuate(sdkInfo, config) {
|
|
128
166
|
const connectorYamlPath = `${sdkInfo.connectorInfo.directory}/connector.yaml`;
|
|
129
|
-
|
|
130
|
-
(
|
|
167
|
+
(0, utils_1.logBullet)(`Writing your new SDK configuration to ${connectorYamlPath}`);
|
|
168
|
+
await config.askWriteProjectFile(path.relative(config.projectDir, connectorYamlPath), sdkInfo.connectorYamlContents, false, true);
|
|
169
|
+
const account = (0, auth_1.getGlobalDefaultAccount)();
|
|
131
170
|
await dataconnectEmulator_1.DataConnectEmulator.generate({
|
|
132
171
|
configDir: sdkInfo.connectorInfo.directory,
|
|
133
172
|
connectorId: sdkInfo.connectorInfo.connectorYaml.connectorId,
|
|
173
|
+
account,
|
|
134
174
|
});
|
|
135
175
|
(0, utils_1.logBullet)(`Generated SDK code for ${sdkInfo.connectorInfo.connectorYaml.connectorId}`);
|
|
136
176
|
if (sdkInfo.connectorInfo.connectorYaml.generate?.swiftSdk && sdkInfo.displayIOSWarning) {
|
|
137
|
-
(0, utils_1.logBullet)(clc.bold("Please follow the instructions here to add your generated sdk to your XCode project:\n\thttps://firebase.google.com/docs/data-connect/
|
|
177
|
+
(0, utils_1.logBullet)(clc.bold("Please follow the instructions here to add your generated sdk to your XCode project:\n\thttps://firebase.google.com/docs/data-connect/ios-sdk#set-client"));
|
|
178
|
+
}
|
|
179
|
+
if (sdkInfo.connectorInfo.connectorYaml.generate?.javascriptSdk) {
|
|
180
|
+
for (const framework of fileUtils_1.SUPPORTED_FRAMEWORKS) {
|
|
181
|
+
if (sdkInfo.connectorInfo.connectorYaml.generate.javascriptSdk[framework]) {
|
|
182
|
+
logInfoForFramework(framework);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
138
185
|
}
|
|
139
186
|
}
|
|
140
187
|
exports.actuate = actuate;
|
|
188
|
+
function logInfoForFramework(framework) {
|
|
189
|
+
if (framework === "react") {
|
|
190
|
+
(0, utils_1.logBullet)("Visit https://firebase.google.com/docs/data-connect/web-sdk#react for more information on how to set up React Generated SDKs for Firebase Data Connect");
|
|
191
|
+
}
|
|
192
|
+
else if (framework === "angular") {
|
|
193
|
+
(0, utils_1.logBullet)("Run `npm i --save @angular/fire @tanstack-query-firebase/angular @tanstack/angular-query-experimental` to install angular sdk dependencies.\nVisit https://github.com/invertase/tanstack-query-firebase/tree/main/packages/angular for more information on how to set up Angular Generated SDKs for Firebase Data Connect");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -13,44 +13,40 @@ async function doSetup(setup, config) {
|
|
|
13
13
|
return {
|
|
14
14
|
value: e,
|
|
15
15
|
name: constants_1.Constants.description(e),
|
|
16
|
-
checked: config
|
|
16
|
+
checked: config?.has(e) || config?.has(`emulators.${e}`),
|
|
17
17
|
};
|
|
18
18
|
});
|
|
19
19
|
const selections = {};
|
|
20
|
-
await (0, prompt_1.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"Press Space to select emulators, then Enter to confirm your choices.",
|
|
26
|
-
choices: choices,
|
|
27
|
-
},
|
|
28
|
-
]);
|
|
20
|
+
selections.emulators = await (0, prompt_1.checkbox)({
|
|
21
|
+
message: "Which Firebase emulators do you want to set up? " +
|
|
22
|
+
"Press Space to select emulators, then Enter to confirm your choices.",
|
|
23
|
+
choices: choices,
|
|
24
|
+
});
|
|
29
25
|
if (!selections.emulators) {
|
|
30
26
|
return;
|
|
31
27
|
}
|
|
32
28
|
setup.config.emulators = setup.config.emulators || {};
|
|
29
|
+
const emulators = setup.config.emulators || {};
|
|
33
30
|
for (const selected of selections.emulators) {
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
if (selected === "extensions")
|
|
32
|
+
continue;
|
|
33
|
+
const selectedEmulator = emulators[selected] || {};
|
|
34
|
+
const currentPort = selectedEmulator.port;
|
|
36
35
|
if (currentPort) {
|
|
37
36
|
utils.logBullet(`Port for ${selected} already configured: ${clc.cyan(currentPort)}`);
|
|
38
37
|
}
|
|
39
38
|
else {
|
|
40
|
-
await (0, prompt_1.
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
message: `Which port do you want to use for the ${clc.underline(selected)} emulator?`,
|
|
45
|
-
default: constants_1.Constants.getDefaultPort(selected),
|
|
46
|
-
},
|
|
47
|
-
]);
|
|
39
|
+
selectedEmulator.port = await (0, prompt_1.number)({
|
|
40
|
+
message: `Which port do you want to use for the ${clc.underline(selected)} emulator?`,
|
|
41
|
+
default: constants_1.Constants.getDefaultPort(selected),
|
|
42
|
+
});
|
|
48
43
|
}
|
|
44
|
+
emulators[selected] = selectedEmulator;
|
|
49
45
|
const additionalInitFn = initEmulators_1.AdditionalInitFns[selected];
|
|
50
46
|
if (additionalInitFn) {
|
|
51
47
|
const additionalOptions = await additionalInitFn(config);
|
|
52
48
|
if (additionalOptions) {
|
|
53
|
-
|
|
49
|
+
emulators[selected] = {
|
|
54
50
|
...setup.config.emulators[selected],
|
|
55
51
|
...additionalOptions,
|
|
56
52
|
};
|
|
@@ -66,34 +62,21 @@ async function doSetup(setup, config) {
|
|
|
66
62
|
else {
|
|
67
63
|
const ui = setup.config.emulators.ui || {};
|
|
68
64
|
setup.config.emulators.ui = ui;
|
|
69
|
-
await (0, prompt_1.
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
message: `Would you like to enable the ${uiDesc}?`,
|
|
74
|
-
default: true,
|
|
75
|
-
},
|
|
76
|
-
]);
|
|
65
|
+
ui.enabled = await (0, prompt_1.confirm)({
|
|
66
|
+
message: `Would you like to enable the ${uiDesc}?`,
|
|
67
|
+
default: true,
|
|
68
|
+
});
|
|
77
69
|
if (ui.enabled) {
|
|
78
|
-
await (0, prompt_1.
|
|
79
|
-
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
message: `Which port do you want to use for the ${clc.underline(uiDesc)} (leave empty to use any available port)?`,
|
|
83
|
-
},
|
|
84
|
-
]);
|
|
85
|
-
const portNum = Number.parseInt(ui.port);
|
|
86
|
-
ui.port = isNaN(portNum) ? undefined : portNum;
|
|
70
|
+
ui.port = await (0, prompt_1.number)({
|
|
71
|
+
message: `Which port do you want to use for the ${clc.underline(uiDesc)} (leave empty to use any available port)?`,
|
|
72
|
+
required: false,
|
|
73
|
+
});
|
|
87
74
|
}
|
|
88
75
|
}
|
|
89
|
-
await (0, prompt_1.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
message: "Would you like to download the emulators now?",
|
|
94
|
-
default: true,
|
|
95
|
-
},
|
|
96
|
-
]);
|
|
76
|
+
selections.download = await (0, prompt_1.confirm)({
|
|
77
|
+
message: "Would you like to download the emulators now?",
|
|
78
|
+
default: true,
|
|
79
|
+
});
|
|
97
80
|
}
|
|
98
81
|
if (setup.config.emulators.singleProjectMode === undefined) {
|
|
99
82
|
setup.config.emulators.singleProjectMode = true;
|