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
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.promptWriteMode = exports.isPackageJson = exports.isTsConfig = exports.genkitSetup = exports.ensureVertexApiEnabled = exports.doSetup = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
|
-
const inquirer = require("inquirer");
|
|
6
5
|
const path = require("path");
|
|
7
6
|
const semver = require("semver");
|
|
8
7
|
const clc = require("colorette");
|
|
@@ -14,32 +13,45 @@ const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
|
|
|
14
13
|
const logger_1 = require("../../../logger");
|
|
15
14
|
const error_1 = require("../../../error");
|
|
16
15
|
const utils_1 = require("../../../utils");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
semver.parse(
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
try {
|
|
28
|
-
genkitVersion = await (0, spawn_1.spawnWithOutput)("npm", ["view", "genkit", "version"]);
|
|
16
|
+
const UNKNOWN_VERSION_TOO_HIGH = "2.0.0";
|
|
17
|
+
const MIN_VERSION = "0.6.0";
|
|
18
|
+
const LATEST_TEMPLATE = "1.0.0";
|
|
19
|
+
async function getPackageVersion(packageName, envVariable) {
|
|
20
|
+
const envVal = process.env[envVariable];
|
|
21
|
+
if (envVal && typeof envVal === "string") {
|
|
22
|
+
if (semver.parse(envVal)) {
|
|
23
|
+
return envVal;
|
|
29
24
|
}
|
|
30
|
-
|
|
31
|
-
throw new error_1.FirebaseError(
|
|
32
|
-
`npm Error: ${(0, error_1.getErrMsg)(err)}\n\n` +
|
|
33
|
-
"For a possible workaround run\n npm view genkit version\n" +
|
|
34
|
-
"and then set an environment variable:\n" +
|
|
35
|
-
" export GENKIT_DEV_VERSION=<output from previous command>\n" +
|
|
36
|
-
"and run `firebase init genkit` again");
|
|
25
|
+
else {
|
|
26
|
+
throw new error_1.FirebaseError(`Invalid version string '${envVal}' specified in ${envVariable}`);
|
|
37
27
|
}
|
|
38
28
|
}
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
try {
|
|
30
|
+
const output = await (0, spawn_1.spawnWithOutput)("npm", ["view", packageName, "version"]);
|
|
31
|
+
if (!output) {
|
|
32
|
+
throw new error_1.FirebaseError(`Unable to determine ${packageName} version to install`);
|
|
33
|
+
}
|
|
34
|
+
return output;
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
throw new error_1.FirebaseError(`Unable to determine which version of ${packageName} to install.\n` +
|
|
38
|
+
`npm Error: ${(0, error_1.getErrMsg)(err)}\n\n` +
|
|
39
|
+
"For a possible workaround run\n npm view " +
|
|
40
|
+
packageName +
|
|
41
|
+
" version\n" +
|
|
42
|
+
"and then set an environment variable:\n" +
|
|
43
|
+
` export ${envVariable}=<output from previous command>\n` +
|
|
44
|
+
"and run `firebase init genkit` again");
|
|
41
45
|
}
|
|
42
|
-
|
|
46
|
+
}
|
|
47
|
+
async function getGenkitInfo() {
|
|
48
|
+
let templateVersion = LATEST_TEMPLATE;
|
|
49
|
+
let stopInstall = false;
|
|
50
|
+
const genkitVersion = await getPackageVersion("genkit", "GENKIT_DEV_VERSION");
|
|
51
|
+
const cliVersion = await getPackageVersion("genkit-cli", "GENKIT_CLI_DEV_VERSION");
|
|
52
|
+
const vertexVersion = await getPackageVersion("@genkit-ai/vertexai", "GENKIT_VERTEX_VERSION");
|
|
53
|
+
const googleAiVersion = await getPackageVersion("@genkit-ai/googleai", "GENKIT_GOOGLEAI_VERSION");
|
|
54
|
+
if (semver.gte(genkitVersion, UNKNOWN_VERSION_TOO_HIGH)) {
|
|
43
55
|
const continueInstall = await (0, prompt_1.confirm)({
|
|
44
56
|
message: clc.yellow(`WARNING: The latest version of Genkit (${genkitVersion}) isn't supported by this\n` +
|
|
45
57
|
"version of firebase-tools. You can proceed, but the provided sample code may\n" +
|
|
@@ -51,16 +63,35 @@ async function getGenkitVersion() {
|
|
|
51
63
|
stopInstall = true;
|
|
52
64
|
}
|
|
53
65
|
}
|
|
54
|
-
else if (semver.gte(genkitVersion, "0.
|
|
66
|
+
else if (semver.gte(genkitVersion, "1.0.0-rc.1")) {
|
|
67
|
+
templateVersion = "1.0.0";
|
|
55
68
|
}
|
|
56
|
-
else {
|
|
57
|
-
templateVersion = "";
|
|
58
|
-
useInit = true;
|
|
69
|
+
else if (semver.gte(genkitVersion, MIN_VERSION)) {
|
|
70
|
+
templateVersion = "0.9.0";
|
|
59
71
|
}
|
|
60
|
-
|
|
72
|
+
else {
|
|
73
|
+
throw new error_1.FirebaseError(`The requested version of Genkit (${genkitVersion}) is no ` +
|
|
74
|
+
`longer supported. Please specify a newer version.`);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
genkitVersion,
|
|
78
|
+
cliVersion,
|
|
79
|
+
vertexVersion,
|
|
80
|
+
googleAiVersion,
|
|
81
|
+
templateVersion,
|
|
82
|
+
stopInstall,
|
|
83
|
+
};
|
|
61
84
|
}
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
function showStartMessage(setup, command) {
|
|
86
|
+
logger_1.logger.info();
|
|
87
|
+
logger_1.logger.info("\nLogin to Google Cloud using:");
|
|
88
|
+
logger_1.logger.info(clc.bold(clc.green(` gcloud auth application-default login --project ${setup.projectId || "your-project-id"}\n`)));
|
|
89
|
+
logger_1.logger.info("Then start the Genkit developer experience by running:");
|
|
90
|
+
logger_1.logger.info(clc.bold(clc.green(` ${command}`)));
|
|
91
|
+
}
|
|
92
|
+
async function doSetup(initSetup, config, options) {
|
|
93
|
+
const setup = initSetup;
|
|
94
|
+
const genkitInfo = await getGenkitInfo();
|
|
64
95
|
if (genkitInfo.stopInstall) {
|
|
65
96
|
(0, utils_1.logLabeledWarning)("genkit", "Stopped Genkit initialization");
|
|
66
97
|
return;
|
|
@@ -83,47 +114,24 @@ async function doSetup(setup, config, options) {
|
|
|
83
114
|
throw new error_1.FirebaseError("Failed to initialize Genkit prerequisite: Firebase functions");
|
|
84
115
|
}
|
|
85
116
|
const projectDir = `${config.projectDir}/${setup.functions.source}`;
|
|
86
|
-
const installType =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
{ name: "Just this project", value: "project" },
|
|
94
|
-
],
|
|
95
|
-
},
|
|
96
|
-
])).choice;
|
|
117
|
+
const installType = await (0, prompt_1.select)({
|
|
118
|
+
message: "Install the Genkit CLI globally or locally in this project?",
|
|
119
|
+
choices: [
|
|
120
|
+
{ name: "Globally", value: "globally" },
|
|
121
|
+
{ name: "Just this project", value: "project" },
|
|
122
|
+
],
|
|
123
|
+
});
|
|
97
124
|
try {
|
|
98
|
-
(0, utils_1.logLabeledBullet)("genkit", `Installing Genkit CLI version ${genkitInfo.
|
|
125
|
+
(0, utils_1.logLabeledBullet)("genkit", `Installing Genkit CLI version ${genkitInfo.cliVersion}`);
|
|
99
126
|
if (installType === "globally") {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
logger_1.logger.info("Start the Genkit developer experience by running:");
|
|
104
|
-
logger_1.logger.info(` cd ${setup.functions.source} && genkit start`);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
await (0, spawn_1.wrapSpawn)("npm", ["install", "-g", `genkit-cli@${genkitInfo.genkitVersion}`], projectDir);
|
|
108
|
-
await genkitSetup(options, genkitInfo, projectDir);
|
|
109
|
-
logger_1.logger.info("Start the Genkit developer experience by running:");
|
|
110
|
-
logger_1.logger.info(` cd ${setup.functions.source} && npm run genkit:start`);
|
|
111
|
-
}
|
|
127
|
+
await (0, spawn_1.wrapSpawn)("npm", ["install", "-g", `genkit-cli@${genkitInfo.cliVersion}`], projectDir);
|
|
128
|
+
await genkitSetup(options, genkitInfo, projectDir);
|
|
129
|
+
showStartMessage(setup, `cd ${setup.functions.source} && npm run genkit:start`);
|
|
112
130
|
}
|
|
113
131
|
else {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
logger_1.logger.info("Start the Genkit developer experience by running:");
|
|
118
|
-
logger_1.logger.info(` cd ${setup.functions.source} && npx genkit start`);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
await (0, spawn_1.wrapSpawn)("npm", ["install", `genkit-cli@${genkitInfo.genkitVersion}`, "--save-dev"], projectDir);
|
|
122
|
-
await genkitSetup(options, genkitInfo, projectDir);
|
|
123
|
-
logger_1.logger.info("Start the Genkit developer experience by running:");
|
|
124
|
-
logger_1.logger.info();
|
|
125
|
-
logger_1.logger.info(clc.bold(clc.green(` cd ${setup.functions.source} && npm run genkit:start`)));
|
|
126
|
-
}
|
|
132
|
+
await (0, spawn_1.wrapSpawn)("npm", ["install", `genkit-cli@${genkitInfo.cliVersion}`, "--save-dev"], projectDir);
|
|
133
|
+
await genkitSetup(options, genkitInfo, projectDir);
|
|
134
|
+
showStartMessage(setup, `cd ${setup.functions.source} && npm run genkit:start`);
|
|
127
135
|
}
|
|
128
136
|
}
|
|
129
137
|
catch (err) {
|
|
@@ -142,17 +150,17 @@ async function ensureVertexApiEnabled(options) {
|
|
|
142
150
|
return await (0, ensureApiEnabled_1.ensure)(projectId, VERTEX_AI_URL, "aiplatform", silently);
|
|
143
151
|
}
|
|
144
152
|
exports.ensureVertexApiEnabled = ensureVertexApiEnabled;
|
|
145
|
-
function getModelOptions(
|
|
153
|
+
function getModelOptions(genkitInfo) {
|
|
146
154
|
const modelOptions = {
|
|
147
155
|
vertexai: {
|
|
148
156
|
label: "Google Cloud Vertex AI",
|
|
149
157
|
plugin: "@genkit-ai/vertexai",
|
|
150
|
-
package: `@genkit-ai/vertexai@${
|
|
158
|
+
package: `@genkit-ai/vertexai@${genkitInfo.vertexVersion}`,
|
|
151
159
|
},
|
|
152
160
|
googleai: {
|
|
153
161
|
label: "Google AI",
|
|
154
162
|
plugin: "@genkit-ai/googleai",
|
|
155
|
-
package: `@genkit-ai/googleai@${
|
|
163
|
+
package: `@genkit-ai/googleai@${genkitInfo.googleAiVersion}`,
|
|
156
164
|
},
|
|
157
165
|
none: { label: "None", plugin: undefined, package: undefined },
|
|
158
166
|
};
|
|
@@ -170,26 +178,26 @@ const pluginToInfo = {
|
|
|
170
178
|
imports: "vertexAI",
|
|
171
179
|
modelImportComment: `
|
|
172
180
|
// Import models from the Vertex AI plugin. The Vertex AI API provides access to
|
|
173
|
-
// several generative models. Here, we import Gemini
|
|
181
|
+
// several generative models. Here, we import Gemini 2.0 Flash.`.trimStart(),
|
|
174
182
|
init: `
|
|
175
183
|
// Load the Vertex AI plugin. You can optionally specify your project ID
|
|
176
184
|
// by passing in a config object; if you don't, the Vertex AI plugin uses
|
|
177
185
|
// the value from the GCLOUD_PROJECT environment variable.
|
|
178
186
|
vertexAI({location: "us-central1"})`.trimStart(),
|
|
179
|
-
model: "
|
|
187
|
+
model: "gemini20Flash",
|
|
180
188
|
},
|
|
181
189
|
"@genkit-ai/googleai": {
|
|
182
190
|
imports: "googleAI",
|
|
183
191
|
modelImportComment: `
|
|
184
192
|
// Import models from the Google AI plugin. The Google AI API provides access to
|
|
185
|
-
// several generative models. Here, we import Gemini
|
|
193
|
+
// several generative models. Here, we import Gemini 2.0 Flash.`.trimStart(),
|
|
186
194
|
init: `
|
|
187
195
|
// Load the Google AI plugin. You can optionally specify your API key
|
|
188
196
|
// by passing in a config object; if you don't, the Google AI plugin uses
|
|
189
197
|
// the value from the GOOGLE_GENAI_API_KEY environment variable, which is
|
|
190
198
|
// the recommended practice.
|
|
191
199
|
googleAI()`.trimStart(),
|
|
192
|
-
model: "
|
|
200
|
+
model: "gemini20Flash",
|
|
193
201
|
},
|
|
194
202
|
};
|
|
195
203
|
function getBasePackages(genkitVersion) {
|
|
@@ -198,20 +206,15 @@ function getBasePackages(genkitVersion) {
|
|
|
198
206
|
}
|
|
199
207
|
const externalDevPackages = ["typescript", "tsx"];
|
|
200
208
|
async function genkitSetup(options, genkitInfo, projectDir) {
|
|
201
|
-
const modelOptions = getModelOptions(genkitInfo
|
|
209
|
+
const modelOptions = getModelOptions(genkitInfo);
|
|
202
210
|
const supportedModels = Object.keys(modelOptions);
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
name:
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
value: model,
|
|
211
|
-
})),
|
|
212
|
-
},
|
|
213
|
-
]);
|
|
214
|
-
const model = answer.model;
|
|
211
|
+
const model = await (0, prompt_1.select)({
|
|
212
|
+
message: "Select a model provider:",
|
|
213
|
+
choices: supportedModels.map((model) => ({
|
|
214
|
+
name: modelOptions[model].label,
|
|
215
|
+
value: model,
|
|
216
|
+
})),
|
|
217
|
+
});
|
|
215
218
|
if (model === "vertexai") {
|
|
216
219
|
await ensureVertexApiEnabled(options);
|
|
217
220
|
}
|
|
@@ -237,7 +240,13 @@ async function genkitSetup(options, genkitInfo, projectDir) {
|
|
|
237
240
|
message: "Would you like to generate a sample flow?",
|
|
238
241
|
default: true,
|
|
239
242
|
}))) {
|
|
240
|
-
|
|
243
|
+
logger_1.logger.info("Telemetry data can be used to monitor and gain insights into your AI features. There may be a cost associated with using this feature. See https://firebase.google.com/docs/genkit/observability/telemetry-collection.");
|
|
244
|
+
const enableTelemetry = options.nonInteractive ||
|
|
245
|
+
(await (0, prompt_1.confirm)({
|
|
246
|
+
message: "Would like you to enable telemetry collection?",
|
|
247
|
+
default: true,
|
|
248
|
+
}));
|
|
249
|
+
generateSampleFile(modelOptions[model].plugin, plugins, projectDir, genkitInfo.templateVersion, enableTelemetry);
|
|
241
250
|
}
|
|
242
251
|
}
|
|
243
252
|
exports.genkitSetup = genkitSetup;
|
|
@@ -328,7 +337,7 @@ async function installNpmPackages(projectDir, packages, devPackages) {
|
|
|
328
337
|
process.exit(1);
|
|
329
338
|
}
|
|
330
339
|
}
|
|
331
|
-
function generateSampleFile(modelPlugin, configPlugins, projectDir, templateVersion) {
|
|
340
|
+
function generateSampleFile(modelPlugin, configPlugins, projectDir, templateVersion, enableTelemetry) {
|
|
332
341
|
let modelImport = "";
|
|
333
342
|
if (modelPlugin && pluginToInfo[modelPlugin].model) {
|
|
334
343
|
const modelInfo = pluginToInfo[modelPlugin].model || "";
|
|
@@ -346,7 +355,7 @@ function generateSampleFile(modelPlugin, configPlugins, projectDir, templateVers
|
|
|
346
355
|
.replace("$GENKIT_MODEL_IMPORT\n", commentedModelImport)
|
|
347
356
|
.replace("$GENKIT_MODEL", modelPlugin
|
|
348
357
|
? pluginToInfo[modelPlugin].model || pluginToInfo[modelPlugin].modelStr || ""
|
|
349
|
-
: "'' /* TODO: Set a model. */"));
|
|
358
|
+
: "'' /* TODO: Set a model. */"), enableTelemetry);
|
|
350
359
|
(0, utils_1.logLabeledBullet)("genkit", "Generating sample file");
|
|
351
360
|
try {
|
|
352
361
|
const samplePath = "src/genkit-sample.ts";
|
|
@@ -420,7 +429,7 @@ async function updatePackageJson(nonInteractive, projectDir) {
|
|
|
420
429
|
process.exit(1);
|
|
421
430
|
}
|
|
422
431
|
}
|
|
423
|
-
function renderConfig(pluginNames, template) {
|
|
432
|
+
function renderConfig(pluginNames, template, enableTelemetry) {
|
|
424
433
|
const imports = pluginNames
|
|
425
434
|
.map((pluginName) => generateImportStatement(pluginToInfo[pluginName].imports, pluginName))
|
|
426
435
|
.join("\n");
|
|
@@ -428,25 +437,21 @@ function renderConfig(pluginNames, template) {
|
|
|
428
437
|
" /* Add your plugins here. */";
|
|
429
438
|
return template
|
|
430
439
|
.replace("$GENKIT_CONFIG_IMPORTS", imports)
|
|
431
|
-
.replace("$GENKIT_CONFIG_PLUGINS", plugins)
|
|
440
|
+
.replace("$GENKIT_CONFIG_PLUGINS", plugins)
|
|
441
|
+
.replaceAll("$TELEMETRY_COMMENT", enableTelemetry ? "" : "// ");
|
|
432
442
|
}
|
|
433
443
|
function generateImportStatement(imports, name) {
|
|
434
444
|
return `import {${imports}} from "${name}";`;
|
|
435
445
|
}
|
|
436
446
|
async function promptWriteMode(message, defaultOption = "merge") {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
name: "
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
],
|
|
447
|
-
default: defaultOption,
|
|
448
|
-
},
|
|
449
|
-
]);
|
|
450
|
-
return answer.option;
|
|
447
|
+
return (0, prompt_1.select)({
|
|
448
|
+
message,
|
|
449
|
+
choices: [
|
|
450
|
+
{ name: "Set if unset", value: "merge" },
|
|
451
|
+
{ name: "Overwrite", value: "overwrite" },
|
|
452
|
+
{ name: "Keep unchanged", value: "keep" },
|
|
453
|
+
],
|
|
454
|
+
default: defaultOption,
|
|
455
|
+
});
|
|
451
456
|
}
|
|
452
457
|
exports.promptWriteMode = promptWriteMode;
|
|
@@ -66,7 +66,7 @@ async function initGitHub(setup) {
|
|
|
66
66
|
(0, utils_1.logSuccess)(`Uploaded service account JSON to GitHub as secret ${(0, colorette_1.bold)(githubSecretName)}.`);
|
|
67
67
|
(0, utils_1.logBullet)(`You can manage your secrets at https://github.com/${repo}/settings/secrets.`);
|
|
68
68
|
logger_1.logger.info();
|
|
69
|
-
if (setup.config.hosting.predeploy) {
|
|
69
|
+
if (!Array.isArray(setup.config.hosting) && setup.config.hosting.predeploy) {
|
|
70
70
|
(0, utils_1.logBullet)(`You have a predeploy script configured in firebase.json.`);
|
|
71
71
|
}
|
|
72
72
|
const { script } = await promptForBuildScript(setup?.hosting?.useWebFrameworks);
|
|
@@ -74,7 +74,7 @@ async function initGitHub(setup) {
|
|
|
74
74
|
let shouldWriteYMLHostingFile = true;
|
|
75
75
|
let shouldWriteYMLDeployFile = false;
|
|
76
76
|
if (fs.existsSync(YML_FULL_PATH_PULL_REQUEST)) {
|
|
77
|
-
const
|
|
77
|
+
const overwrite = await (0, prompt_1.confirm)({
|
|
78
78
|
message: `GitHub workflow file for PR previews exists. Overwrite? ${YML_PULL_REQUEST_FILENAME}`,
|
|
79
79
|
});
|
|
80
80
|
shouldWriteYMLHostingFile = overwrite;
|
|
@@ -91,10 +91,9 @@ async function initGitHub(setup) {
|
|
|
91
91
|
shouldWriteYMLDeployFile = true;
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
|
-
|
|
94
|
+
shouldWriteYMLDeployFile = await (0, prompt_1.confirm)({
|
|
95
95
|
message: `The GitHub workflow file for deploying to the live channel already exists. Overwrite? ${YML_MERGE_FILENAME}`,
|
|
96
96
|
});
|
|
97
|
-
shouldWriteYMLDeployFile = overwrite;
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
else {
|
|
@@ -259,10 +258,8 @@ async function uploadSecretToGitHub(repo, ghAccessToken, encryptedServiceAccount
|
|
|
259
258
|
async function promptForRepo(options, ghAccessToken) {
|
|
260
259
|
let key = "";
|
|
261
260
|
let keyId = "";
|
|
262
|
-
const
|
|
263
|
-
{
|
|
264
|
-
type: "input",
|
|
265
|
-
name: "repo",
|
|
261
|
+
const repo = options.repo ||
|
|
262
|
+
(await (0, prompt_1.input)({
|
|
266
263
|
default: defaultGithubRepo(),
|
|
267
264
|
message: "For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository)",
|
|
268
265
|
validate: async (repo) => {
|
|
@@ -288,64 +285,37 @@ async function promptForRepo(options, ghAccessToken) {
|
|
|
288
285
|
}
|
|
289
286
|
return true;
|
|
290
287
|
},
|
|
291
|
-
}
|
|
292
|
-
|
|
288
|
+
}));
|
|
289
|
+
options.repo = repo;
|
|
293
290
|
return { repo, key, keyId };
|
|
294
291
|
}
|
|
295
292
|
async function promptForBuildScript(useWebFrameworks) {
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
name: "shouldSetupScript",
|
|
300
|
-
default: false,
|
|
301
|
-
message: "Set up the workflow to run a build script before every deploy?",
|
|
302
|
-
},
|
|
303
|
-
]);
|
|
293
|
+
const shouldSetupScript = await (0, prompt_1.confirm)({
|
|
294
|
+
message: "Set up the workflow to run a build script before every deploy?",
|
|
295
|
+
});
|
|
304
296
|
if (!shouldSetupScript) {
|
|
305
297
|
return { script: undefined };
|
|
306
298
|
}
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
default: useWebFrameworks ? undefined : "npm ci && npm run build",
|
|
312
|
-
message: "What script should be run before every deploy?",
|
|
313
|
-
},
|
|
314
|
-
]);
|
|
299
|
+
const script = await (0, prompt_1.input)({
|
|
300
|
+
default: useWebFrameworks ? undefined : "npm ci && npm run build",
|
|
301
|
+
message: "What script should be run before every deploy?",
|
|
302
|
+
});
|
|
315
303
|
return { script };
|
|
316
304
|
}
|
|
317
305
|
async function promptToSetupDeploys(defaultBranch) {
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
default: true,
|
|
323
|
-
message: "Set up automatic deployment to your site's live channel when a PR is merged?",
|
|
324
|
-
},
|
|
325
|
-
]);
|
|
306
|
+
const setupDeploys = await (0, prompt_1.confirm)({
|
|
307
|
+
default: true,
|
|
308
|
+
message: "Set up automatic deployment to your site's live channel when a PR is merged?",
|
|
309
|
+
});
|
|
326
310
|
if (!setupDeploys) {
|
|
327
311
|
return { setupDeploys };
|
|
328
312
|
}
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
default: defaultBranch,
|
|
334
|
-
message: "What is the name of the GitHub branch associated with your site's live channel?",
|
|
335
|
-
},
|
|
336
|
-
]);
|
|
313
|
+
const branch = await (0, prompt_1.input)({
|
|
314
|
+
default: defaultBranch,
|
|
315
|
+
message: "What is the name of the GitHub branch associated with your site's live channel?",
|
|
316
|
+
});
|
|
337
317
|
return { branch, setupDeploys };
|
|
338
318
|
}
|
|
339
|
-
async function promptForWriteYMLFile({ message }) {
|
|
340
|
-
return await (0, prompt_1.prompt)({}, [
|
|
341
|
-
{
|
|
342
|
-
type: "confirm",
|
|
343
|
-
name: "overwrite",
|
|
344
|
-
default: false,
|
|
345
|
-
message,
|
|
346
|
-
},
|
|
347
|
-
]);
|
|
348
|
-
}
|
|
349
319
|
async function getGitHubUserDetails(ghAccessToken) {
|
|
350
320
|
const { body: ghUserDetails } = await githubApiClient.get("/user", {
|
|
351
321
|
headers: { Authorization: `token ${ghAccessToken}`, "User-Agent": "Firebase CLI" },
|
|
@@ -19,6 +19,7 @@ const INDEX_TEMPLATE = (0, templates_1.readTemplateSync)("init/hosting/index.htm
|
|
|
19
19
|
const MISSING_TEMPLATE = (0, templates_1.readTemplateSync)("init/hosting/404.html");
|
|
20
20
|
const DEFAULT_IGNORES = ["firebase.json", "**/.*", "**/node_modules/**"];
|
|
21
21
|
async function doSetup(setup, config, options) {
|
|
22
|
+
var _a, _b, _c;
|
|
22
23
|
setup.hosting = {};
|
|
23
24
|
if (setup.projectId) {
|
|
24
25
|
let hasHostingSite = true;
|
|
@@ -32,8 +33,7 @@ async function doSetup(setup, config, options) {
|
|
|
32
33
|
hasHostingSite = false;
|
|
33
34
|
}
|
|
34
35
|
if (!hasHostingSite) {
|
|
35
|
-
const confirmCreate = await (0, prompt_1.
|
|
36
|
-
type: "confirm",
|
|
36
|
+
const confirmCreate = await (0, prompt_1.confirm)({
|
|
37
37
|
message: "A Firebase Hosting site is required to deploy. Would you like to create one now?",
|
|
38
38
|
default: true,
|
|
39
39
|
});
|
|
@@ -55,44 +55,33 @@ async function doSetup(setup, config, options) {
|
|
|
55
55
|
if (experiments.isEnabled("webframeworks")) {
|
|
56
56
|
if (discoveredFramework) {
|
|
57
57
|
const name = frameworks_1.WebFrameworks[discoveredFramework.framework].name;
|
|
58
|
-
await (0, prompt_1.
|
|
59
|
-
name: "useDiscoveredFramework",
|
|
60
|
-
type: "confirm",
|
|
61
|
-
default: true,
|
|
58
|
+
(_a = setup.hosting).useDiscoveredFramework ?? (_a.useDiscoveredFramework = await (0, prompt_1.confirm)({
|
|
62
59
|
message: `Detected an existing ${name} codebase in the current directory, should we use this?`,
|
|
63
|
-
|
|
60
|
+
default: true,
|
|
61
|
+
}));
|
|
64
62
|
}
|
|
65
63
|
if (setup.hosting.useDiscoveredFramework) {
|
|
66
64
|
setup.hosting.source = ".";
|
|
67
65
|
setup.hosting.useWebFrameworks = true;
|
|
68
66
|
}
|
|
69
67
|
else {
|
|
70
|
-
await (0, prompt_1.
|
|
71
|
-
name: "useWebFrameworks",
|
|
72
|
-
type: "confirm",
|
|
73
|
-
default: false,
|
|
74
|
-
message: `Do you want to use a web framework? (${clc.bold("experimental")})`,
|
|
75
|
-
}, setup.hosting);
|
|
68
|
+
setup.hosting.useWebFrameworks = await (0, prompt_1.confirm)(`Do you want to use a web framework? (${clc.bold("experimental")})`);
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
if (setup.hosting.useWebFrameworks) {
|
|
79
|
-
await (0, prompt_1.
|
|
80
|
-
name: "source",
|
|
81
|
-
type: "input",
|
|
82
|
-
default: "hosting",
|
|
72
|
+
(_b = setup.hosting).source ?? (_b.source = await (0, prompt_1.input)({
|
|
83
73
|
message: "What folder would you like to use for your web application's root directory?",
|
|
84
|
-
|
|
74
|
+
default: "hosting",
|
|
75
|
+
}));
|
|
85
76
|
if (setup.hosting.source !== ".")
|
|
86
77
|
delete setup.hosting.useDiscoveredFramework;
|
|
87
78
|
discoveredFramework = await (0, frameworks_1.discover)((0, path_1.join)(config.projectDir, setup.hosting.source));
|
|
88
79
|
if (discoveredFramework) {
|
|
89
80
|
const name = frameworks_1.WebFrameworks[discoveredFramework.framework].name;
|
|
90
|
-
await (0, prompt_1.
|
|
91
|
-
name: "useDiscoveredFramework",
|
|
92
|
-
type: "confirm",
|
|
93
|
-
default: true,
|
|
81
|
+
(_c = setup.hosting).useDiscoveredFramework ?? (_c.useDiscoveredFramework = await (0, prompt_1.confirm)({
|
|
94
82
|
message: `Detected an existing ${name} codebase in ${setup.hosting.source}, should we use this?`,
|
|
95
|
-
|
|
83
|
+
default: true,
|
|
84
|
+
}));
|
|
96
85
|
}
|
|
97
86
|
if (setup.hosting.useDiscoveredFramework && discoveredFramework) {
|
|
98
87
|
setup.hosting.webFramework = discoveredFramework.framework;
|
|
@@ -107,24 +96,24 @@ async function doSetup(setup, config, options) {
|
|
|
107
96
|
}
|
|
108
97
|
}
|
|
109
98
|
const defaultChoice = choices.find(({ value }) => value === discoveredFramework?.framework)?.value;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
setup.hosting.whichFramework =
|
|
100
|
+
setup.hosting.whichFramework ||
|
|
101
|
+
(await (0, prompt_1.select)({
|
|
102
|
+
message: "Please choose the framework:",
|
|
103
|
+
default: defaultChoice,
|
|
104
|
+
choices,
|
|
105
|
+
}));
|
|
117
106
|
if (discoveredFramework)
|
|
118
107
|
(0, node_fs_1.rmSync)(setup.hosting.source, { recursive: true });
|
|
119
108
|
await frameworks_1.WebFrameworks[setup.hosting.whichFramework].init(setup, config);
|
|
120
109
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
110
|
+
setup.hosting.region =
|
|
111
|
+
setup.hosting.region ||
|
|
112
|
+
(await (0, prompt_1.select)({
|
|
113
|
+
message: "In which region would you like to host server-side content, if applicable?",
|
|
114
|
+
default: constants_1.DEFAULT_REGION,
|
|
115
|
+
choices: constants_1.ALLOWED_SSR_REGIONS.filter((region) => region.recommended),
|
|
116
|
+
}));
|
|
128
117
|
setup.config.hosting = {
|
|
129
118
|
source: setup.hosting.source,
|
|
130
119
|
ignore: DEFAULT_IGNORES,
|
|
@@ -139,31 +128,22 @@ async function doSetup(setup, config, options) {
|
|
|
139
128
|
logger_1.logger.info(`will contain Hosting assets to be uploaded with ${clc.bold("firebase deploy")}. If you`);
|
|
140
129
|
logger_1.logger.info("have a build process for your assets, use your build's output directory.");
|
|
141
130
|
logger_1.logger.info();
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
type: "confirm",
|
|
152
|
-
default: false,
|
|
153
|
-
message: "Configure as a single-page app (rewrite all urls to /index.html)?",
|
|
154
|
-
},
|
|
155
|
-
]);
|
|
131
|
+
setup.hosting.public =
|
|
132
|
+
setup.hosting.public ||
|
|
133
|
+
(await (0, prompt_1.input)({
|
|
134
|
+
message: "What do you want to use as your public directory?",
|
|
135
|
+
default: "public",
|
|
136
|
+
}));
|
|
137
|
+
setup.hosting.spa =
|
|
138
|
+
setup.hosting.spa ||
|
|
139
|
+
(await (0, prompt_1.confirm)("Configure as a single-page app (rewrite all urls to /index.html)?"));
|
|
156
140
|
setup.config.hosting = {
|
|
157
141
|
public: setup.hosting.public,
|
|
158
142
|
ignore: DEFAULT_IGNORES,
|
|
159
143
|
};
|
|
160
144
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
type: "confirm",
|
|
164
|
-
default: false,
|
|
165
|
-
message: "Set up automatic builds and deploys with GitHub?",
|
|
166
|
-
}, setup.hosting);
|
|
145
|
+
setup.hosting.github =
|
|
146
|
+
setup.hosting.github || (await (0, prompt_1.confirm)("Set up automatic builds and deploys with GitHub?"));
|
|
167
147
|
if (!setup.hosting.useWebFrameworks) {
|
|
168
148
|
if (setup.hosting.spa) {
|
|
169
149
|
setup.config.hosting.rewrites = [{ source: "**", destination: "/index.html" }];
|