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.
Files changed (396) hide show
  1. package/README.md +53 -4
  2. package/lib/api.js +10 -2
  3. package/lib/appdistribution/client.js +2 -2
  4. package/lib/apphosting/backend.js +157 -55
  5. package/lib/apphosting/config.js +121 -101
  6. package/lib/apphosting/githubConnections.js +65 -100
  7. package/lib/apphosting/repo.js +22 -36
  8. package/lib/apphosting/rollout.js +5 -11
  9. package/lib/apphosting/secrets/dialogs.js +13 -11
  10. package/lib/apphosting/secrets/index.js +47 -5
  11. package/lib/apphosting/utils.js +1 -3
  12. package/lib/apphosting/yaml.js +35 -49
  13. package/lib/auth.js +23 -6
  14. package/lib/bin/cli.js +99 -0
  15. package/lib/bin/firebase.js +7 -123
  16. package/lib/bin/mcp.js +49 -0
  17. package/lib/checkValidTargetFilters.js +1 -0
  18. package/lib/command.js +3 -2
  19. package/lib/commands/appdistribution-distribute.js +1 -1
  20. package/lib/commands/appdistribution-groups-create.js +1 -1
  21. package/lib/commands/appdistribution-groups-delete.js +1 -1
  22. package/lib/commands/appdistribution-groups-list.js +2 -2
  23. package/lib/commands/appdistribution-testers-add.js +1 -1
  24. package/lib/commands/appdistribution-testers-list.js +3 -3
  25. package/lib/commands/appdistribution-testers-remove.js +1 -1
  26. package/lib/commands/apphosting-backends-create.js +3 -3
  27. package/lib/commands/apphosting-backends-delete.js +23 -27
  28. package/lib/commands/apphosting-backends-get.js +12 -12
  29. package/lib/commands/apphosting-backends-list.js +5 -5
  30. package/lib/commands/apphosting-builds-create.js +8 -2
  31. package/lib/commands/apphosting-builds-get.js +8 -1
  32. package/lib/commands/apphosting-rollouts-create.js +3 -3
  33. package/lib/commands/apphosting-rollouts-list.js +8 -2
  34. package/lib/commands/apphosting-secrets-access.js +1 -1
  35. package/lib/commands/apphosting-secrets-describe.js +2 -2
  36. package/lib/commands/apphosting-secrets-grantaccess.js +20 -10
  37. package/lib/commands/apphosting-secrets-set.js +27 -1
  38. package/lib/commands/apps-android-sha-create.js +1 -1
  39. package/lib/commands/apps-android-sha-delete.js +1 -1
  40. package/lib/commands/apps-android-sha-list.js +2 -2
  41. package/lib/commands/apps-create.js +4 -108
  42. package/lib/commands/apps-init.js +94 -0
  43. package/lib/commands/apps-list.js +1 -1
  44. package/lib/commands/apps-sdkconfig.js +5 -10
  45. package/lib/commands/auth-export.js +1 -1
  46. package/lib/commands/auth-import.js +1 -1
  47. package/lib/commands/database-import.js +4 -6
  48. package/lib/commands/database-instances-create.js +1 -1
  49. package/lib/commands/database-instances-list.js +1 -1
  50. package/lib/commands/database-profile.js +1 -2
  51. package/lib/commands/database-remove.js +4 -6
  52. package/lib/commands/database-set.js +6 -6
  53. package/lib/commands/database-settings-set.js +1 -1
  54. package/lib/commands/database-update.js +6 -6
  55. package/lib/commands/dataconnect-sdk-generate.js +5 -2
  56. package/lib/commands/dataconnect-services-list.js +2 -2
  57. package/lib/commands/dataconnect-sql-diff.js +2 -2
  58. package/lib/commands/dataconnect-sql-grant.js +3 -3
  59. package/lib/commands/dataconnect-sql-migrate.js +2 -2
  60. package/lib/commands/dataconnect-sql-setup.js +39 -0
  61. package/lib/commands/dataconnect-sql-shell.js +5 -7
  62. package/lib/commands/deploy.js +4 -3
  63. package/lib/commands/emulators-exec.js +1 -1
  64. package/lib/commands/emulators-start.js +4 -3
  65. package/lib/commands/experiments-list.js +1 -1
  66. package/lib/commands/ext-dev-deprecate.js +1 -0
  67. package/lib/commands/ext-dev-init.js +3 -12
  68. package/lib/commands/ext-dev-list.js +1 -1
  69. package/lib/commands/ext-dev-register.js +3 -5
  70. package/lib/commands/ext-dev-undeprecate.js +1 -2
  71. package/lib/commands/ext-dev-usage.js +4 -6
  72. package/lib/commands/ext-export.js +1 -2
  73. package/lib/commands/ext-install.js +3 -3
  74. package/lib/commands/ext-sdk-install.js +1 -0
  75. package/lib/commands/ext-update.js +1 -0
  76. package/lib/commands/firestore-backups-delete.js +3 -4
  77. package/lib/commands/firestore-backups-get.js +1 -1
  78. package/lib/commands/firestore-backups-list.js +2 -2
  79. package/lib/commands/firestore-backups-schedules-create.js +4 -4
  80. package/lib/commands/firestore-backups-schedules-delete.js +3 -4
  81. package/lib/commands/firestore-backups-schedules-list.js +2 -2
  82. package/lib/commands/firestore-backups-schedules-update.js +1 -1
  83. package/lib/commands/firestore-databases-create.js +6 -6
  84. package/lib/commands/firestore-databases-delete.js +3 -7
  85. package/lib/commands/firestore-databases-get.js +1 -1
  86. package/lib/commands/firestore-databases-list.js +1 -1
  87. package/lib/commands/firestore-databases-restore.js +5 -5
  88. package/lib/commands/firestore-databases-update.js +4 -4
  89. package/lib/commands/firestore-delete.js +13 -14
  90. package/lib/commands/firestore-indexes-list.js +4 -4
  91. package/lib/commands/firestore-locations.js +1 -1
  92. package/lib/commands/functions-artifacts-setpolicy.js +132 -0
  93. package/lib/commands/functions-config-export.js +6 -10
  94. package/lib/commands/functions-delete.js +5 -7
  95. package/lib/commands/functions-deletegcfartifacts.js +5 -5
  96. package/lib/commands/functions-list.js +24 -33
  97. package/lib/commands/functions-secrets-access.js +1 -1
  98. package/lib/commands/functions-secrets-describe.js +1 -1
  99. package/lib/commands/functions-secrets-destroy.js +10 -12
  100. package/lib/commands/functions-secrets-get.js +1 -1
  101. package/lib/commands/functions-secrets-prune.js +14 -15
  102. package/lib/commands/functions-secrets-set.js +14 -18
  103. package/lib/commands/hosting-channel-create.js +1 -2
  104. package/lib/commands/hosting-channel-delete.js +4 -4
  105. package/lib/commands/hosting-channel-list.js +1 -1
  106. package/lib/commands/hosting-channel-open.js +2 -3
  107. package/lib/commands/hosting-disable.js +5 -5
  108. package/lib/commands/hosting-sites-delete.js +4 -4
  109. package/lib/commands/hosting-sites-get.js +1 -1
  110. package/lib/commands/hosting-sites-list.js +1 -1
  111. package/lib/commands/index.js +7 -4
  112. package/lib/commands/init.js +54 -60
  113. package/lib/commands/internaltesting-frameworks-compose.js +1 -1
  114. package/lib/commands/login-use.js +2 -11
  115. package/lib/commands/login.js +10 -8
  116. package/lib/commands/logout.js +2 -3
  117. package/lib/commands/mcp.js +11 -0
  118. package/lib/commands/open.js +4 -2
  119. package/lib/commands/projects-create.js +1 -2
  120. package/lib/commands/projects-list.js +1 -1
  121. package/lib/commands/remoteconfig-get.js +1 -1
  122. package/lib/commands/remoteconfig-rollback.js +5 -5
  123. package/lib/commands/remoteconfig-versions-list.js +2 -2
  124. package/lib/commands/setup-emulators-database.js +1 -1
  125. package/lib/commands/setup-emulators-dataconnect.js +1 -1
  126. package/lib/commands/setup-emulators-firestore.js +1 -1
  127. package/lib/commands/setup-emulators-pubsub.js +1 -1
  128. package/lib/commands/setup-emulators-storage.js +1 -1
  129. package/lib/commands/setup-emulators-ui.js +1 -1
  130. package/lib/commands/use.js +115 -111
  131. package/lib/config.js +49 -33
  132. package/lib/crashlytics/buildToolsJarHelper.js +1 -1
  133. package/lib/crashlytics/listTopIssues.js +45 -0
  134. package/lib/dataconnect/build.js +61 -4
  135. package/lib/dataconnect/client.js +26 -17
  136. package/lib/dataconnect/cloudAICompanionClient.js +72 -0
  137. package/lib/dataconnect/dataplaneClient.js +19 -2
  138. package/lib/dataconnect/ensureApis.js +6 -3
  139. package/lib/dataconnect/fileUtils.js +39 -6
  140. package/lib/dataconnect/freeTrial.js +21 -9
  141. package/lib/dataconnect/graphqlError.js +56 -2
  142. package/lib/dataconnect/provisionCloudSql.js +23 -12
  143. package/lib/dataconnect/schemaMigration.js +46 -26
  144. package/lib/dataconnect/types.js +5 -1
  145. package/lib/defaultCredentials.js +12 -1
  146. package/lib/deploy/apphosting/args.js +2 -0
  147. package/lib/deploy/apphosting/deploy.js +77 -0
  148. package/lib/deploy/apphosting/index.js +9 -0
  149. package/lib/deploy/apphosting/prepare.js +138 -0
  150. package/lib/deploy/apphosting/release.js +56 -0
  151. package/lib/deploy/apphosting/util.js +65 -0
  152. package/lib/deploy/dataconnect/deploy.js +14 -7
  153. package/lib/deploy/dataconnect/prepare.js +3 -5
  154. package/lib/deploy/extensions/v2FunctionHelper.js +2 -1
  155. package/lib/deploy/firestore/deploy.js +50 -4
  156. package/lib/deploy/functions/build.js +1 -0
  157. package/lib/deploy/functions/checkIam.js +41 -6
  158. package/lib/deploy/functions/containerCleaner.js +17 -2
  159. package/lib/deploy/functions/ensure.js +2 -1
  160. package/lib/deploy/functions/params.js +10 -17
  161. package/lib/deploy/functions/prepare.js +51 -18
  162. package/lib/deploy/functions/prepareFunctionsUpload.js +9 -5
  163. package/lib/deploy/functions/prompts.js +24 -17
  164. package/lib/deploy/functions/release/fabricator.js +4 -4
  165. package/lib/deploy/functions/release/index.js +27 -9
  166. package/lib/deploy/functions/release/planner.js +1 -0
  167. package/lib/deploy/functions/runtimes/discovery/index.js +13 -5
  168. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +4 -4
  169. package/lib/deploy/functions/runtimes/python/index.js +4 -1
  170. package/lib/deploy/functions/runtimes/supported/types.js +17 -11
  171. package/lib/deploy/functions/services/firestore.js +23 -4
  172. package/lib/deploy/index.js +29 -10
  173. package/lib/deploy/lifecycleHooks.js +6 -12
  174. package/lib/emulator/ExpressBasedEmulator.js +1 -1
  175. package/lib/emulator/apphosting/config.js +15 -14
  176. package/lib/emulator/apphosting/index.js +2 -0
  177. package/lib/emulator/apphosting/serve.js +147 -10
  178. package/lib/emulator/auth/cloudFunctions.js +13 -1
  179. package/lib/emulator/auth/operations.js +2 -1
  180. package/lib/emulator/auth/widget_ui.js +2 -1
  181. package/lib/emulator/commandUtils.js +14 -20
  182. package/lib/emulator/constants.js +2 -0
  183. package/lib/emulator/controller.js +24 -9
  184. package/lib/emulator/dataconnect/pgliteServer.js +136 -45
  185. package/lib/emulator/dataconnectEmulator.js +34 -6
  186. package/lib/emulator/dataconnectToolkitController.js +5 -0
  187. package/lib/emulator/downloadableEmulatorInfo.json +81 -0
  188. package/lib/emulator/downloadableEmulators.js +28 -80
  189. package/lib/emulator/env.js +47 -1
  190. package/lib/emulator/extensionsEmulator.js +5 -3
  191. package/lib/emulator/functionsEmulator.js +6 -26
  192. package/lib/emulator/hub.js +5 -4
  193. package/lib/emulator/hubClient.js +5 -0
  194. package/lib/emulator/initEmulators.js +29 -15
  195. package/lib/emulator/ui.js +4 -8
  196. package/lib/ensureApiEnabled.js +32 -1
  197. package/lib/experiments.js +11 -12
  198. package/lib/extensions/askUserForEventsConfig.js +6 -15
  199. package/lib/extensions/askUserForParam.js +23 -52
  200. package/lib/extensions/change-log.js +1 -25
  201. package/lib/extensions/checkProjectBilling.js +3 -9
  202. package/lib/extensions/diagnose.js +3 -6
  203. package/lib/extensions/emulator/triggerHelper.js +4 -0
  204. package/lib/extensions/extensionsHelper.js +25 -31
  205. package/lib/extensions/listExtensions.js +1 -1
  206. package/lib/extensions/manifest.js +3 -7
  207. package/lib/extensions/paramHelper.js +11 -2
  208. package/lib/extensions/provisioningHelper.js +1 -1
  209. package/lib/extensions/tos.js +4 -2
  210. package/lib/extensions/utils.js +1 -10
  211. package/lib/firebaseConfigValidate.js +7 -5
  212. package/lib/firestore/delete.js +5 -4
  213. package/lib/firestore/pretty-print.js +1 -1
  214. package/lib/frameworks/angular/index.js +11 -6
  215. package/lib/frameworks/angular/utils.js +76 -47
  216. package/lib/frameworks/constants.js +1 -1
  217. package/lib/frameworks/index.js +6 -4
  218. package/lib/frameworks/next/index.js +7 -4
  219. package/lib/frameworks/utils.js +11 -3
  220. package/lib/frameworks/vite/index.js +2 -3
  221. package/lib/fsAsync.js +9 -2
  222. package/lib/fsutils.js +16 -1
  223. package/lib/functions/artifacts.js +196 -0
  224. package/lib/functions/secrets.js +15 -16
  225. package/lib/gcp/apphosting.js +13 -1
  226. package/lib/gcp/artifactregistry.js +27 -2
  227. package/lib/gcp/auth.js +113 -1
  228. package/lib/gcp/cloudbilling.js +12 -1
  229. package/lib/gcp/cloudfunctions.js +32 -4
  230. package/lib/gcp/cloudfunctionsv2.js +15 -9
  231. package/lib/gcp/cloudscheduler.js +2 -2
  232. package/lib/gcp/cloudsql/cloudsqladmin.js +32 -11
  233. package/lib/gcp/cloudsql/connect.js +21 -14
  234. package/lib/gcp/cloudsql/interactive.js +1 -1
  235. package/lib/gcp/cloudsql/permissions.js +46 -99
  236. package/lib/gcp/cloudsql/permissionsSetup.js +224 -0
  237. package/lib/gcp/computeEngine.js +19 -2
  238. package/lib/gcp/devConnect.js +6 -1
  239. package/lib/gcp/firestore.js +55 -16
  240. package/lib/gcp/iam.js +1 -5
  241. package/lib/gcp/proto.js +4 -3
  242. package/lib/gcp/run.js +18 -1
  243. package/lib/gcp/serviceusage.js +2 -1
  244. package/lib/gcp/storage.js +47 -1
  245. package/lib/gemini/fdcExperience.js +56 -0
  246. package/lib/gemini/types.js +2 -0
  247. package/lib/hosting/api.js +4 -0
  248. package/lib/hosting/implicitInit.js +7 -3
  249. package/lib/hosting/interactive.js +2 -3
  250. package/lib/index.js +1 -2
  251. package/lib/init/features/account.js +2 -4
  252. package/lib/init/features/apphosting.js +75 -6
  253. package/lib/init/features/database.js +63 -62
  254. package/lib/init/features/dataconnect/index.js +131 -85
  255. package/lib/init/features/dataconnect/sdk.js +73 -18
  256. package/lib/init/features/emulators.js +29 -46
  257. package/lib/init/features/firestore/index.js +79 -43
  258. package/lib/init/features/firestore/indexes.js +30 -45
  259. package/lib/init/features/firestore/rules.js +36 -62
  260. package/lib/init/features/functions/index.js +11 -16
  261. package/lib/init/features/functions/javascript.js +17 -30
  262. package/lib/init/features/functions/npm-dependencies.js +4 -8
  263. package/lib/init/features/functions/python.js +1 -3
  264. package/lib/init/features/functions/typescript.js +25 -43
  265. package/lib/init/features/genkit/index.js +111 -106
  266. package/lib/init/features/hosting/github.js +22 -52
  267. package/lib/init/features/hosting/index.js +37 -57
  268. package/lib/init/features/index.js +10 -5
  269. package/lib/init/features/project.js +18 -21
  270. package/lib/init/features/remoteconfig.js +5 -10
  271. package/lib/init/features/storage.js +30 -10
  272. package/lib/init/index.js +79 -24
  273. package/lib/logger.js +76 -3
  274. package/lib/management/apps.js +292 -7
  275. package/lib/management/projects.js +100 -52
  276. package/lib/mcp/errors.js +20 -0
  277. package/lib/mcp/index.js +227 -0
  278. package/lib/mcp/tool.js +12 -0
  279. package/lib/mcp/tools/apphosting/fetch_logs.js +68 -0
  280. package/lib/mcp/tools/apphosting/index.js +6 -0
  281. package/lib/mcp/tools/apphosting/list_backends.js +51 -0
  282. package/lib/mcp/tools/auth/disable_user.js +30 -0
  283. package/lib/mcp/tools/auth/get_user.js +38 -0
  284. package/lib/mcp/tools/auth/index.js +15 -0
  285. package/lib/mcp/tools/auth/list_users.js +36 -0
  286. package/lib/mcp/tools/auth/set_claims.js +43 -0
  287. package/lib/mcp/tools/auth/set_sms_region_policy.js +36 -0
  288. package/lib/mcp/tools/core/consult_assistant.js +28 -0
  289. package/lib/mcp/tools/core/create_android_sha.js +43 -0
  290. package/lib/mcp/tools/core/create_app.js +90 -0
  291. package/lib/mcp/tools/core/create_project.js +68 -0
  292. package/lib/mcp/tools/core/get_admin_sdk_config.js +26 -0
  293. package/lib/mcp/tools/core/get_environment.js +51 -0
  294. package/lib/mcp/tools/core/get_project.js +22 -0
  295. package/lib/mcp/tools/core/get_sdk_config.js +40 -0
  296. package/lib/mcp/tools/core/index.js +29 -0
  297. package/lib/mcp/tools/core/init.js +153 -0
  298. package/lib/mcp/tools/core/list_apps.js +34 -0
  299. package/lib/mcp/tools/core/list_projects.js +45 -0
  300. package/lib/mcp/tools/core/update_environment.js +55 -0
  301. package/lib/mcp/tools/crashlytics/index.js +5 -0
  302. package/lib/mcp/tools/crashlytics/list_top_issues.js +39 -0
  303. package/lib/mcp/tools/dataconnect/converter.js +60 -0
  304. package/lib/mcp/tools/dataconnect/emulator.js +16 -0
  305. package/lib/mcp/tools/dataconnect/execute_graphql.js +48 -0
  306. package/lib/mcp/tools/dataconnect/execute_graphql_read.js +48 -0
  307. package/lib/mcp/tools/dataconnect/execute_mutation.js +62 -0
  308. package/lib/mcp/tools/dataconnect/execute_query.js +62 -0
  309. package/lib/mcp/tools/dataconnect/generate_operation.js +34 -0
  310. package/lib/mcp/tools/dataconnect/generate_schema.js +26 -0
  311. package/lib/mcp/tools/dataconnect/get_connector.js +31 -0
  312. package/lib/mcp/tools/dataconnect/get_schema.js +31 -0
  313. package/lib/mcp/tools/dataconnect/index.js +23 -0
  314. package/lib/mcp/tools/dataconnect/list_services.js +23 -0
  315. package/lib/mcp/tools/firestore/converter.js +102 -0
  316. package/lib/mcp/tools/firestore/delete_document.js +50 -0
  317. package/lib/mcp/tools/firestore/get_documents.js +58 -0
  318. package/lib/mcp/tools/firestore/index.js +17 -0
  319. package/lib/mcp/tools/firestore/list_collections.js +36 -0
  320. package/lib/mcp/tools/firestore/query_collection.js +132 -0
  321. package/lib/mcp/tools/index.js +62 -0
  322. package/lib/mcp/tools/messaging/index.js +5 -0
  323. package/lib/mcp/tools/messaging/send_message.js +42 -0
  324. package/lib/mcp/tools/remoteconfig/get_template.js +27 -0
  325. package/lib/mcp/tools/remoteconfig/index.js +7 -0
  326. package/lib/mcp/tools/remoteconfig/publish_template.js +34 -0
  327. package/lib/mcp/tools/remoteconfig/rollback_template.js +29 -0
  328. package/lib/mcp/tools/rules/get_rules.js +29 -0
  329. package/lib/mcp/tools/rules/validate_rules.js +97 -0
  330. package/lib/mcp/tools/storage/get_download_url.js +40 -0
  331. package/lib/mcp/tools/storage/get_rules.js +26 -0
  332. package/lib/mcp/tools/storage/index.js +11 -0
  333. package/lib/mcp/types.js +13 -0
  334. package/lib/mcp/util.js +214 -0
  335. package/lib/mcp/util.test.js +468 -0
  336. package/lib/messaging/interfaces.js +2 -0
  337. package/lib/messaging/sendMessage.js +48 -0
  338. package/lib/operation-poller.js +3 -1
  339. package/lib/profileReport.js +1 -1
  340. package/lib/prompt.js +86 -54
  341. package/lib/remoteconfig/publish.js +39 -0
  342. package/lib/requireAuth.js +2 -2
  343. package/lib/requireTosAcceptance.js +4 -0
  344. package/lib/rulesDeploy.js +10 -15
  345. package/lib/track.js +7 -37
  346. package/lib/utils.js +28 -41
  347. package/lib/vsCodeUtils.js +7 -3
  348. package/package.json +31 -15
  349. package/schema/connector-yaml.json +12 -0
  350. package/schema/dataconnect-yaml.json +5 -0
  351. package/schema/extension-yaml.json +17 -4
  352. package/schema/firebase-config.json +1117 -2121
  353. package/standalone/package-lock.json +1255 -992
  354. package/standalone/package.json +1 -1
  355. package/templates/dataconnect-prompts/operation-generation-cursor-windsurf-rule.txt +273 -0
  356. package/templates/dataconnect-prompts/schema-generation-cursor-windsurf-rule.txt +653 -0
  357. package/templates/genkit/firebase.0.9.0.template +1 -1
  358. package/templates/genkit/firebase.1.0.0.template +71 -0
  359. package/templates/init/dataconnect/connector.yaml +4 -1
  360. package/templates/init/dataconnect/dataconnect.yaml +1 -1
  361. package/templates/init/dataconnect/mutations.gql +9 -26
  362. package/templates/init/dataconnect/queries.gql +9 -14
  363. package/templates/init/dataconnect/schema.gql +28 -21
  364. package/templates/init/firestore/firestore.rules +2 -0
  365. package/templates/init/functions/javascript/index.js +14 -1
  366. package/templates/init/functions/javascript/package.lint.json +1 -1
  367. package/templates/init/functions/javascript/package.nolint.json +1 -1
  368. package/templates/init/functions/python/_gitignore +6 -1
  369. package/templates/init/functions/python/main.py +8 -0
  370. package/templates/init/functions/typescript/index.ts +14 -1
  371. package/templates/init/functions/typescript/package.lint.json +2 -2
  372. package/templates/init/functions/typescript/package.nolint.json +3 -3
  373. package/lib/commands/apphosting-config-export.js +0 -28
  374. package/lib/commands/experimental-functions-shell.js +0 -13
  375. package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +0 -11
  376. package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +0 -58
  377. package/lib/emulator/dataconnect/pg-gateway/auth/index.js +0 -22
  378. package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +0 -124
  379. package/lib/emulator/dataconnect/pg-gateway/auth/password.js +0 -54
  380. package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +0 -34
  381. package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +0 -270
  382. package/lib/emulator/dataconnect/pg-gateway/backend-error.js +0 -75
  383. package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +0 -54
  384. package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +0 -79
  385. package/lib/emulator/dataconnect/pg-gateway/connection.js +0 -315
  386. package/lib/emulator/dataconnect/pg-gateway/connection.types.js +0 -8
  387. package/lib/emulator/dataconnect/pg-gateway/crypto.js +0 -40
  388. package/lib/emulator/dataconnect/pg-gateway/duplex.js +0 -53
  389. package/lib/emulator/dataconnect/pg-gateway/index.js +0 -27
  390. package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +0 -82
  391. package/lib/emulator/dataconnect/pg-gateway/message-codes.js +0 -52
  392. package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +0 -16
  393. package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +0 -35
  394. package/lib/emulator/dataconnect/pg-gateway/utils.js +0 -40
  395. package/templates/setup/web.js +0 -5
  396. /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
- async function getGenkitVersion() {
18
- let genkitVersion;
19
- let templateVersion = "0.9.0";
20
- let useInit = false;
21
- let stopInstall = false;
22
- if (process.env.GENKIT_DEV_VERSION && typeof process.env.GENKIT_DEV_VERSION === "string") {
23
- semver.parse(process.env.GENKIT_DEV_VERSION);
24
- genkitVersion = process.env.GENKIT_DEV_VERSION;
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
- catch (err) {
31
- throw new error_1.FirebaseError("Unable to determine which genkit version to install.\n" +
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
- if (!genkitVersion) {
40
- throw new error_1.FirebaseError("Unable to determine genkit version to install");
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
- if (semver.gte(genkitVersion, "1.0.0")) {
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.6.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
- return { genkitVersion, templateVersion, useInit, stopInstall };
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
- async function doSetup(setup, config, options) {
63
- const genkitInfo = await getGenkitVersion();
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 = (await inquirer.prompt([
87
- {
88
- name: "choice",
89
- type: "list",
90
- message: "Install the Genkit CLI globally or locally in this project?",
91
- choices: [
92
- { name: "Globally", value: "globally" },
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.genkitVersion}`);
125
+ (0, utils_1.logLabeledBullet)("genkit", `Installing Genkit CLI version ${genkitInfo.cliVersion}`);
99
126
  if (installType === "globally") {
100
- if (genkitInfo.useInit) {
101
- await (0, spawn_1.wrapSpawn)("npm", ["install", "-g", `genkit@${genkitInfo.genkitVersion}`], projectDir);
102
- await (0, spawn_1.wrapSpawn)("genkit", ["init", "-p", "firebase"], projectDir);
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
- if (genkitInfo.useInit) {
115
- await (0, spawn_1.wrapSpawn)("npm", ["install", `genkit@${genkitInfo.genkitVersion}`, "--save-dev"], projectDir);
116
- await (0, spawn_1.wrapSpawn)("npx", ["genkit", "init", "-p", "firebase"], projectDir);
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(genkitVersion) {
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@${genkitVersion}`,
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@${genkitVersion}`,
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 1.5 Flash.`.trimStart(),
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: "gemini15Flash",
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 1.5 Flash.`.trimStart(),
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: "gemini15Flash",
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.genkitVersion);
209
+ const modelOptions = getModelOptions(genkitInfo);
202
210
  const supportedModels = Object.keys(modelOptions);
203
- const answer = await inquirer.prompt([
204
- {
205
- type: "list",
206
- name: "model",
207
- message: "Select a model provider:",
208
- choices: supportedModels.map((model) => ({
209
- name: modelOptions[model].label,
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
- generateSampleFile(modelOptions[model].plugin, plugins, projectDir, genkitInfo.templateVersion);
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
- const answer = await inquirer.prompt([
438
- {
439
- type: "list",
440
- name: "option",
441
- message,
442
- choices: [
443
- { name: "Set if unset", value: "merge" },
444
- { name: "Overwrite", value: "overwrite" },
445
- { name: "Keep unchanged", value: "keep" },
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 { overwrite } = await promptForWriteYMLFile({
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
- const { overwrite } = await promptForWriteYMLFile({
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 { repo } = await (0, prompt_1.prompt)(options, [
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 { shouldSetupScript } = await (0, prompt_1.prompt)({}, [
297
- {
298
- type: "confirm",
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 { script } = await (0, prompt_1.prompt)({}, [
308
- {
309
- type: "input",
310
- name: "script",
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 { setupDeploys } = await (0, prompt_1.prompt)({}, [
319
- {
320
- type: "confirm",
321
- name: "setupDeploys",
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 { branch } = await (0, prompt_1.prompt)({}, [
330
- {
331
- type: "input",
332
- name: "branch",
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.promptOnce)({
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.promptOnce)({
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
- }, setup.hosting);
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.promptOnce)({
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.promptOnce)({
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
- }, setup.hosting);
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.promptOnce)({
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
- }, setup.hosting);
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
- await (0, prompt_1.promptOnce)({
111
- name: "whichFramework",
112
- type: "list",
113
- message: "Please choose the framework:",
114
- default: defaultChoice,
115
- choices,
116
- }, setup.hosting);
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
- await (0, prompt_1.promptOnce)({
122
- name: "region",
123
- type: "list",
124
- message: "In which region would you like to host server-side content, if applicable?",
125
- default: constants_1.DEFAULT_REGION,
126
- choices: constants_1.ALLOWED_SSR_REGIONS.filter((region) => region.recommended),
127
- }, setup.hosting);
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
- await (0, prompt_1.prompt)(setup.hosting, [
143
- {
144
- name: "public",
145
- type: "input",
146
- default: "public",
147
- message: "What do you want to use as your public directory?",
148
- },
149
- {
150
- name: "spa",
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
- await (0, prompt_1.promptOnce)({
162
- name: "github",
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" }];