firebase-tools-with-isolate 13.29.1-2 → 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 (395) hide show
  1. package/README.md +5 -3
  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 +50 -17
  162. package/lib/deploy/functions/prompts.js +24 -17
  163. package/lib/deploy/functions/release/fabricator.js +4 -4
  164. package/lib/deploy/functions/release/index.js +27 -9
  165. package/lib/deploy/functions/release/planner.js +1 -0
  166. package/lib/deploy/functions/runtimes/discovery/index.js +13 -5
  167. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +4 -4
  168. package/lib/deploy/functions/runtimes/python/index.js +4 -1
  169. package/lib/deploy/functions/runtimes/supported/types.js +17 -11
  170. package/lib/deploy/functions/services/firestore.js +23 -4
  171. package/lib/deploy/index.js +29 -10
  172. package/lib/deploy/lifecycleHooks.js +2 -3
  173. package/lib/emulator/ExpressBasedEmulator.js +1 -1
  174. package/lib/emulator/apphosting/config.js +15 -14
  175. package/lib/emulator/apphosting/index.js +2 -0
  176. package/lib/emulator/apphosting/serve.js +147 -10
  177. package/lib/emulator/auth/cloudFunctions.js +13 -1
  178. package/lib/emulator/auth/operations.js +2 -1
  179. package/lib/emulator/auth/widget_ui.js +2 -1
  180. package/lib/emulator/commandUtils.js +14 -20
  181. package/lib/emulator/constants.js +2 -0
  182. package/lib/emulator/controller.js +24 -9
  183. package/lib/emulator/dataconnect/pgliteServer.js +136 -45
  184. package/lib/emulator/dataconnectEmulator.js +34 -6
  185. package/lib/emulator/dataconnectToolkitController.js +5 -0
  186. package/lib/emulator/downloadableEmulatorInfo.json +81 -0
  187. package/lib/emulator/downloadableEmulators.js +28 -80
  188. package/lib/emulator/env.js +47 -1
  189. package/lib/emulator/extensionsEmulator.js +5 -3
  190. package/lib/emulator/functionsEmulator.js +6 -26
  191. package/lib/emulator/hub.js +5 -4
  192. package/lib/emulator/hubClient.js +5 -0
  193. package/lib/emulator/initEmulators.js +29 -15
  194. package/lib/emulator/ui.js +4 -8
  195. package/lib/ensureApiEnabled.js +32 -1
  196. package/lib/experiments.js +11 -12
  197. package/lib/extensions/askUserForEventsConfig.js +6 -15
  198. package/lib/extensions/askUserForParam.js +23 -52
  199. package/lib/extensions/change-log.js +1 -25
  200. package/lib/extensions/checkProjectBilling.js +3 -9
  201. package/lib/extensions/diagnose.js +3 -6
  202. package/lib/extensions/emulator/triggerHelper.js +4 -0
  203. package/lib/extensions/extensionsHelper.js +25 -31
  204. package/lib/extensions/listExtensions.js +1 -1
  205. package/lib/extensions/manifest.js +3 -7
  206. package/lib/extensions/paramHelper.js +11 -2
  207. package/lib/extensions/provisioningHelper.js +1 -1
  208. package/lib/extensions/tos.js +4 -2
  209. package/lib/extensions/utils.js +1 -10
  210. package/lib/firebaseConfigValidate.js +7 -5
  211. package/lib/firestore/delete.js +5 -4
  212. package/lib/firestore/pretty-print.js +1 -1
  213. package/lib/frameworks/angular/index.js +11 -6
  214. package/lib/frameworks/angular/utils.js +76 -47
  215. package/lib/frameworks/constants.js +1 -1
  216. package/lib/frameworks/index.js +6 -4
  217. package/lib/frameworks/next/index.js +7 -4
  218. package/lib/frameworks/utils.js +11 -3
  219. package/lib/frameworks/vite/index.js +2 -3
  220. package/lib/fsAsync.js +9 -2
  221. package/lib/fsutils.js +16 -1
  222. package/lib/functions/artifacts.js +196 -0
  223. package/lib/functions/secrets.js +15 -16
  224. package/lib/gcp/apphosting.js +13 -1
  225. package/lib/gcp/artifactregistry.js +27 -2
  226. package/lib/gcp/auth.js +113 -1
  227. package/lib/gcp/cloudbilling.js +12 -1
  228. package/lib/gcp/cloudfunctions.js +32 -4
  229. package/lib/gcp/cloudfunctionsv2.js +15 -9
  230. package/lib/gcp/cloudscheduler.js +2 -2
  231. package/lib/gcp/cloudsql/cloudsqladmin.js +32 -11
  232. package/lib/gcp/cloudsql/connect.js +21 -14
  233. package/lib/gcp/cloudsql/interactive.js +1 -1
  234. package/lib/gcp/cloudsql/permissions.js +46 -99
  235. package/lib/gcp/cloudsql/permissionsSetup.js +224 -0
  236. package/lib/gcp/computeEngine.js +19 -2
  237. package/lib/gcp/devConnect.js +6 -1
  238. package/lib/gcp/firestore.js +55 -16
  239. package/lib/gcp/iam.js +1 -5
  240. package/lib/gcp/proto.js +4 -3
  241. package/lib/gcp/run.js +18 -1
  242. package/lib/gcp/serviceusage.js +2 -1
  243. package/lib/gcp/storage.js +47 -1
  244. package/lib/gemini/fdcExperience.js +56 -0
  245. package/lib/gemini/types.js +2 -0
  246. package/lib/hosting/api.js +4 -0
  247. package/lib/hosting/implicitInit.js +7 -3
  248. package/lib/hosting/interactive.js +2 -3
  249. package/lib/index.js +1 -2
  250. package/lib/init/features/account.js +2 -4
  251. package/lib/init/features/apphosting.js +75 -6
  252. package/lib/init/features/database.js +63 -62
  253. package/lib/init/features/dataconnect/index.js +131 -85
  254. package/lib/init/features/dataconnect/sdk.js +73 -18
  255. package/lib/init/features/emulators.js +29 -46
  256. package/lib/init/features/firestore/index.js +79 -43
  257. package/lib/init/features/firestore/indexes.js +30 -45
  258. package/lib/init/features/firestore/rules.js +36 -62
  259. package/lib/init/features/functions/index.js +11 -16
  260. package/lib/init/features/functions/javascript.js +17 -30
  261. package/lib/init/features/functions/npm-dependencies.js +4 -8
  262. package/lib/init/features/functions/python.js +1 -3
  263. package/lib/init/features/functions/typescript.js +25 -43
  264. package/lib/init/features/genkit/index.js +111 -106
  265. package/lib/init/features/hosting/github.js +22 -52
  266. package/lib/init/features/hosting/index.js +37 -57
  267. package/lib/init/features/index.js +10 -5
  268. package/lib/init/features/project.js +18 -21
  269. package/lib/init/features/remoteconfig.js +5 -10
  270. package/lib/init/features/storage.js +30 -10
  271. package/lib/init/index.js +79 -24
  272. package/lib/logger.js +76 -3
  273. package/lib/management/apps.js +292 -7
  274. package/lib/management/projects.js +100 -52
  275. package/lib/mcp/errors.js +20 -0
  276. package/lib/mcp/index.js +227 -0
  277. package/lib/mcp/tool.js +12 -0
  278. package/lib/mcp/tools/apphosting/fetch_logs.js +68 -0
  279. package/lib/mcp/tools/apphosting/index.js +6 -0
  280. package/lib/mcp/tools/apphosting/list_backends.js +51 -0
  281. package/lib/mcp/tools/auth/disable_user.js +30 -0
  282. package/lib/mcp/tools/auth/get_user.js +38 -0
  283. package/lib/mcp/tools/auth/index.js +15 -0
  284. package/lib/mcp/tools/auth/list_users.js +36 -0
  285. package/lib/mcp/tools/auth/set_claims.js +43 -0
  286. package/lib/mcp/tools/auth/set_sms_region_policy.js +36 -0
  287. package/lib/mcp/tools/core/consult_assistant.js +28 -0
  288. package/lib/mcp/tools/core/create_android_sha.js +43 -0
  289. package/lib/mcp/tools/core/create_app.js +90 -0
  290. package/lib/mcp/tools/core/create_project.js +68 -0
  291. package/lib/mcp/tools/core/get_admin_sdk_config.js +26 -0
  292. package/lib/mcp/tools/core/get_environment.js +51 -0
  293. package/lib/mcp/tools/core/get_project.js +22 -0
  294. package/lib/mcp/tools/core/get_sdk_config.js +40 -0
  295. package/lib/mcp/tools/core/index.js +29 -0
  296. package/lib/mcp/tools/core/init.js +153 -0
  297. package/lib/mcp/tools/core/list_apps.js +34 -0
  298. package/lib/mcp/tools/core/list_projects.js +45 -0
  299. package/lib/mcp/tools/core/update_environment.js +55 -0
  300. package/lib/mcp/tools/crashlytics/index.js +5 -0
  301. package/lib/mcp/tools/crashlytics/list_top_issues.js +39 -0
  302. package/lib/mcp/tools/dataconnect/converter.js +60 -0
  303. package/lib/mcp/tools/dataconnect/emulator.js +16 -0
  304. package/lib/mcp/tools/dataconnect/execute_graphql.js +48 -0
  305. package/lib/mcp/tools/dataconnect/execute_graphql_read.js +48 -0
  306. package/lib/mcp/tools/dataconnect/execute_mutation.js +62 -0
  307. package/lib/mcp/tools/dataconnect/execute_query.js +62 -0
  308. package/lib/mcp/tools/dataconnect/generate_operation.js +34 -0
  309. package/lib/mcp/tools/dataconnect/generate_schema.js +26 -0
  310. package/lib/mcp/tools/dataconnect/get_connector.js +31 -0
  311. package/lib/mcp/tools/dataconnect/get_schema.js +31 -0
  312. package/lib/mcp/tools/dataconnect/index.js +23 -0
  313. package/lib/mcp/tools/dataconnect/list_services.js +23 -0
  314. package/lib/mcp/tools/firestore/converter.js +102 -0
  315. package/lib/mcp/tools/firestore/delete_document.js +50 -0
  316. package/lib/mcp/tools/firestore/get_documents.js +58 -0
  317. package/lib/mcp/tools/firestore/index.js +17 -0
  318. package/lib/mcp/tools/firestore/list_collections.js +36 -0
  319. package/lib/mcp/tools/firestore/query_collection.js +132 -0
  320. package/lib/mcp/tools/index.js +62 -0
  321. package/lib/mcp/tools/messaging/index.js +5 -0
  322. package/lib/mcp/tools/messaging/send_message.js +42 -0
  323. package/lib/mcp/tools/remoteconfig/get_template.js +27 -0
  324. package/lib/mcp/tools/remoteconfig/index.js +7 -0
  325. package/lib/mcp/tools/remoteconfig/publish_template.js +34 -0
  326. package/lib/mcp/tools/remoteconfig/rollback_template.js +29 -0
  327. package/lib/mcp/tools/rules/get_rules.js +29 -0
  328. package/lib/mcp/tools/rules/validate_rules.js +97 -0
  329. package/lib/mcp/tools/storage/get_download_url.js +40 -0
  330. package/lib/mcp/tools/storage/get_rules.js +26 -0
  331. package/lib/mcp/tools/storage/index.js +11 -0
  332. package/lib/mcp/types.js +13 -0
  333. package/lib/mcp/util.js +214 -0
  334. package/lib/mcp/util.test.js +468 -0
  335. package/lib/messaging/interfaces.js +2 -0
  336. package/lib/messaging/sendMessage.js +48 -0
  337. package/lib/operation-poller.js +3 -1
  338. package/lib/profileReport.js +1 -1
  339. package/lib/prompt.js +86 -54
  340. package/lib/remoteconfig/publish.js +39 -0
  341. package/lib/requireAuth.js +2 -2
  342. package/lib/requireTosAcceptance.js +4 -0
  343. package/lib/rulesDeploy.js +10 -15
  344. package/lib/track.js +7 -37
  345. package/lib/utils.js +28 -41
  346. package/lib/vsCodeUtils.js +7 -3
  347. package/package.json +31 -15
  348. package/schema/connector-yaml.json +12 -0
  349. package/schema/dataconnect-yaml.json +5 -0
  350. package/schema/extension-yaml.json +17 -4
  351. package/schema/firebase-config.json +1117 -2121
  352. package/standalone/package-lock.json +1255 -992
  353. package/standalone/package.json +1 -1
  354. package/templates/dataconnect-prompts/operation-generation-cursor-windsurf-rule.txt +273 -0
  355. package/templates/dataconnect-prompts/schema-generation-cursor-windsurf-rule.txt +653 -0
  356. package/templates/genkit/firebase.0.9.0.template +1 -1
  357. package/templates/genkit/firebase.1.0.0.template +71 -0
  358. package/templates/init/dataconnect/connector.yaml +4 -1
  359. package/templates/init/dataconnect/dataconnect.yaml +1 -1
  360. package/templates/init/dataconnect/mutations.gql +9 -26
  361. package/templates/init/dataconnect/queries.gql +9 -14
  362. package/templates/init/dataconnect/schema.gql +28 -21
  363. package/templates/init/firestore/firestore.rules +2 -0
  364. package/templates/init/functions/javascript/index.js +14 -1
  365. package/templates/init/functions/javascript/package.lint.json +1 -1
  366. package/templates/init/functions/javascript/package.nolint.json +1 -1
  367. package/templates/init/functions/python/_gitignore +6 -1
  368. package/templates/init/functions/python/main.py +8 -0
  369. package/templates/init/functions/typescript/index.ts +14 -1
  370. package/templates/init/functions/typescript/package.lint.json +2 -2
  371. package/templates/init/functions/typescript/package.nolint.json +3 -3
  372. package/lib/commands/apphosting-config-export.js +0 -28
  373. package/lib/commands/experimental-functions-shell.js +0 -13
  374. package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +0 -11
  375. package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +0 -58
  376. package/lib/emulator/dataconnect/pg-gateway/auth/index.js +0 -22
  377. package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +0 -124
  378. package/lib/emulator/dataconnect/pg-gateway/auth/password.js +0 -54
  379. package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +0 -34
  380. package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +0 -270
  381. package/lib/emulator/dataconnect/pg-gateway/backend-error.js +0 -75
  382. package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +0 -54
  383. package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +0 -79
  384. package/lib/emulator/dataconnect/pg-gateway/connection.js +0 -315
  385. package/lib/emulator/dataconnect/pg-gateway/connection.types.js +0 -8
  386. package/lib/emulator/dataconnect/pg-gateway/crypto.js +0 -40
  387. package/lib/emulator/dataconnect/pg-gateway/duplex.js +0 -53
  388. package/lib/emulator/dataconnect/pg-gateway/index.js +0 -27
  389. package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +0 -82
  390. package/lib/emulator/dataconnect/pg-gateway/message-codes.js +0 -52
  391. package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +0 -16
  392. package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +0 -35
  393. package/lib/emulator/dataconnect/pg-gateway/utils.js +0 -40
  394. package/templates/setup/web.js +0 -5
  395. /package/lib/{emulator/dataconnect/pg-gateway/auth/trust.js → dataconnect/cloudAICompanionTypes.js} +0 -0
@@ -1,28 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadConfigToExportSecrets = exports.loadConfigForEnvironment = exports.exportConfig = exports.maybeAddSecretToYaml = exports.upsertEnv = exports.findEnv = exports.store = exports.load = exports.listAppHostingFilesInPath = exports.discoverBackendRoot = exports.APPHOSTING_YAML_FILE_REGEX = exports.APPHOSTING_LOCAL_YAML_FILE = exports.APPHOSTING_BASE_YAML_FILE = void 0;
3
+ exports.suggestedTestKeyName = exports.overrideChosenEnv = exports.maybeGenerateEmulatorYaml = exports.maybeAddSecretToYaml = exports.upsertEnv = exports.findEnv = exports.store = exports.load = exports.listAppHostingFilesInPath = exports.discoverBackendRoot = exports.APPHOSTING_YAML_FILE_REGEX = exports.APPHOSTING_LOCAL_YAML_FILE = exports.APPHOSTING_EMULATORS_YAML_FILE = exports.APPHOSTING_BASE_YAML_FILE = void 0;
4
4
  const path_1 = require("path");
5
5
  const fs_1 = require("fs");
6
6
  const yaml = require("yaml");
7
+ const clc = require("colorette");
7
8
  const fs = require("../fsutils");
8
9
  const prompt = require("../prompt");
9
10
  const dialogs = require("./secrets/dialogs");
10
11
  const yaml_1 = require("./yaml");
11
- const error_1 = require("../error");
12
- const utils_1 = require("./utils");
13
- const secrets_1 = require("./secrets");
14
12
  const logger_1 = require("../logger");
15
- const utils_2 = require("../utils");
16
- const projects_1 = require("../management/projects");
13
+ const csm = require("../gcp/secretManager");
14
+ const error_1 = require("../error");
17
15
  exports.APPHOSTING_BASE_YAML_FILE = "apphosting.yaml";
16
+ exports.APPHOSTING_EMULATORS_YAML_FILE = "apphosting.emulator.yaml";
18
17
  exports.APPHOSTING_LOCAL_YAML_FILE = "apphosting.local.yaml";
19
18
  exports.APPHOSTING_YAML_FILE_REGEX = /^apphosting(\.[a-z0-9_]+)?\.yaml$/;
20
- const SECRET_CONFIG = "Secret";
21
- const EXPORTABLE_CONFIG = [SECRET_CONFIG];
22
19
  function discoverBackendRoot(cwd) {
23
20
  let dir = cwd;
24
- while (!fs.fileExistsSync((0, path_1.resolve)(dir, exports.APPHOSTING_BASE_YAML_FILE))) {
25
- if (fs.fileExistsSync((0, path_1.resolve)(dir, "firebase.json"))) {
21
+ while (true) {
22
+ const files = fs.listFiles(dir);
23
+ if (files.some((file) => exports.APPHOSTING_YAML_FILE_REGEX.test(file))) {
24
+ return dir;
25
+ }
26
+ if (files.includes("firebase.json")) {
26
27
  return null;
27
28
  }
28
29
  const parent = (0, path_1.dirname)(dir);
@@ -31,7 +32,6 @@ function discoverBackendRoot(cwd) {
31
32
  }
32
33
  dir = parent;
33
34
  }
34
- return dir;
35
35
  }
36
36
  exports.discoverBackendRoot = discoverBackendRoot;
37
37
  function listAppHostingFilesInPath(path) {
@@ -42,7 +42,18 @@ function listAppHostingFilesInPath(path) {
42
42
  }
43
43
  exports.listAppHostingFilesInPath = listAppHostingFilesInPath;
44
44
  function load(yamlPath) {
45
- const raw = fs.readFile(yamlPath);
45
+ let raw;
46
+ try {
47
+ raw = fs.readFile(yamlPath);
48
+ }
49
+ catch (err) {
50
+ if (err.code !== "ENOENT") {
51
+ throw new error_1.FirebaseError(`Unexpected error trying to load ${yamlPath}`, {
52
+ original: (0, error_1.getError)(err),
53
+ });
54
+ }
55
+ return new yaml.Document();
56
+ }
46
57
  return yaml.parseDocument(raw);
47
58
  }
48
59
  exports.load = load;
@@ -79,13 +90,13 @@ function upsertEnv(document, env) {
79
90
  envs.add(envYaml);
80
91
  }
81
92
  exports.upsertEnv = upsertEnv;
82
- async function maybeAddSecretToYaml(secretName) {
83
- const dynamicDispatch = exports;
93
+ const dynamicDispatch = exports;
94
+ async function maybeAddSecretToYaml(secretName, fileName = exports.APPHOSTING_BASE_YAML_FILE) {
84
95
  const backendRoot = dynamicDispatch.discoverBackendRoot(process.cwd());
85
96
  let path;
86
97
  let projectYaml;
87
98
  if (backendRoot) {
88
- path = (0, path_1.join)(backendRoot, exports.APPHOSTING_BASE_YAML_FILE);
99
+ path = (0, path_1.join)(backendRoot, fileName);
89
100
  projectYaml = dynamicDispatch.load(path);
90
101
  }
91
102
  else {
@@ -95,20 +106,20 @@ async function maybeAddSecretToYaml(secretName) {
95
106
  return;
96
107
  }
97
108
  const addToYaml = await prompt.confirm({
98
- message: "Would you like to add this secret to apphosting.yaml?",
109
+ message: `Would you like to add this secret to ${fileName}?`,
99
110
  default: true,
100
111
  });
101
112
  if (!addToYaml) {
102
113
  return;
103
114
  }
104
115
  if (!path) {
105
- path = await prompt.promptOnce({
106
- message: "It looks like you don't have an apphosting.yaml yet. Where would you like to store it?",
116
+ path = await prompt.input({
117
+ message: `It looks like you don't have an ${fileName} yet. Where would you like to store it?`,
107
118
  default: process.cwd(),
108
119
  });
109
- path = (0, path_1.join)(path, exports.APPHOSTING_BASE_YAML_FILE);
120
+ path = (0, path_1.join)(path, fileName);
110
121
  }
111
- const envName = await dialogs.envVarForSecret(secretName);
122
+ const envName = await dialogs.envVarForSecret(secretName, fileName === exports.APPHOSTING_EMULATORS_YAML_FILE);
112
123
  dynamicDispatch.upsertEnv(projectYaml, {
113
124
  variable: envName,
114
125
  secret: secretName,
@@ -116,90 +127,99 @@ async function maybeAddSecretToYaml(secretName) {
116
127
  dynamicDispatch.store(path, projectYaml);
117
128
  }
118
129
  exports.maybeAddSecretToYaml = maybeAddSecretToYaml;
119
- async function exportConfig(cwd, projectRoot, backendRoot, projectId, userGivenConfigFile) {
120
- const choices = await prompt.prompt({}, [
121
- {
122
- type: "checkbox",
123
- name: "configurations",
124
- message: "What configs would you like to export?",
125
- choices: EXPORTABLE_CONFIG,
126
- },
127
- ]);
128
- if (!choices.configurations.includes(SECRET_CONFIG)) {
129
- logger_1.logger.info("No configs selected to export");
130
- return;
131
- }
132
- if (!projectId) {
133
- const project = await (0, projects_1.getOrPromptProject)({});
134
- projectId = project.projectId;
135
- }
136
- let localAppHostingConfig = yaml_1.AppHostingYamlConfig.empty();
137
- const localAppHostingConfigPath = (0, path_1.resolve)(backendRoot, exports.APPHOSTING_LOCAL_YAML_FILE);
138
- if (fs.fileExistsSync(localAppHostingConfigPath)) {
139
- localAppHostingConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(localAppHostingConfigPath);
140
- }
141
- const configToExport = await loadConfigToExportSecrets(cwd, userGivenConfigFile);
142
- const secretsToExport = configToExport.secrets;
143
- if (!secretsToExport) {
144
- logger_1.logger.info("No secrets found to export in the chosen App Hosting config files");
145
- return;
146
- }
147
- const secretMaterial = await (0, secrets_1.fetchSecrets)(projectId, secretsToExport);
148
- for (const [key, value] of secretMaterial) {
149
- localAppHostingConfig.addEnvironmentVariable({
150
- variable: key,
151
- value: value,
152
- availability: ["RUNTIME"],
153
- });
154
- }
155
- localAppHostingConfig.clearSecrets();
156
- localAppHostingConfig.upsertFile(localAppHostingConfigPath);
157
- logger_1.logger.info(`Wrote secrets as environment variables to ${exports.APPHOSTING_LOCAL_YAML_FILE}.`);
158
- (0, utils_2.updateOrCreateGitignore)(projectRoot, [exports.APPHOSTING_LOCAL_YAML_FILE]);
159
- logger_1.logger.info(`${exports.APPHOSTING_LOCAL_YAML_FILE} has been automatically added to your .gitignore.`);
160
- }
161
- exports.exportConfig = exportConfig;
162
- async function loadConfigForEnvironment(envYamlPath, baseYamlPath) {
163
- const envYamlConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(envYamlPath);
164
- if (baseYamlPath) {
165
- const baseConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(baseYamlPath);
166
- baseConfig.merge(envYamlConfig);
167
- return baseConfig;
168
- }
169
- return envYamlConfig;
170
- }
171
- exports.loadConfigForEnvironment = loadConfigForEnvironment;
172
- async function loadConfigToExportSecrets(cwd, userGivenConfigFile) {
173
- if (userGivenConfigFile && !exports.APPHOSTING_YAML_FILE_REGEX.test(userGivenConfigFile)) {
174
- throw new error_1.FirebaseError("Invalid apphosting yaml config file provided. File must be in format: 'apphosting.yaml' or 'apphosting.<environment>.yaml'");
175
- }
176
- const allConfigs = getValidConfigs(cwd);
177
- let userGivenConfigFilePath;
178
- if (userGivenConfigFile) {
179
- if (!allConfigs.has(userGivenConfigFile)) {
180
- throw new error_1.FirebaseError(`The provided app hosting config file "${userGivenConfigFile}" does not exist`);
130
+ async function maybeGenerateEmulatorYaml(projectId, backendRoot) {
131
+ const basePath = dynamicDispatch.discoverBackendRoot(backendRoot) || backendRoot;
132
+ if (fs.fileExistsSync((0, path_1.join)(basePath, exports.APPHOSTING_EMULATORS_YAML_FILE))) {
133
+ logger_1.logger.debug("apphosting.emulator.yaml already exists, skipping generation and secrets access prompt");
134
+ return null;
135
+ }
136
+ let baseConfig;
137
+ try {
138
+ baseConfig = await yaml_1.AppHostingYamlConfig.loadFromFile((0, path_1.join)(basePath, exports.APPHOSTING_BASE_YAML_FILE));
139
+ }
140
+ catch {
141
+ baseConfig = yaml_1.AppHostingYamlConfig.empty();
142
+ }
143
+ const createFile = await prompt.confirm({
144
+ message: "The App Hosting emulator uses a file called apphosting.emulator.yaml to override " +
145
+ "values in apphosting.yaml for local testing. This codebase does not have one, would you like " +
146
+ "to create it?",
147
+ default: true,
148
+ });
149
+ if (!createFile) {
150
+ return (0, yaml_1.toEnvList)(baseConfig.env);
151
+ }
152
+ const newEnv = await dynamicDispatch.overrideChosenEnv(projectId, baseConfig.env || {});
153
+ const envList = Object.entries(newEnv);
154
+ if (envList.length) {
155
+ const newYaml = new yaml.Document();
156
+ for (const [variable, env] of envList) {
157
+ dynamicDispatch.upsertEnv(newYaml, { variable, ...env });
181
158
  }
182
- userGivenConfigFilePath = allConfigs.get(userGivenConfigFile);
159
+ dynamicDispatch.store((0, path_1.join)(basePath, exports.APPHOSTING_EMULATORS_YAML_FILE), newYaml);
183
160
  }
184
161
  else {
185
- userGivenConfigFilePath = await (0, utils_1.promptForAppHostingYaml)(allConfigs, "Which environment would you like to export secrets from Secret Manager for?");
186
- }
187
- if (userGivenConfigFile === exports.APPHOSTING_BASE_YAML_FILE) {
188
- return yaml_1.AppHostingYamlConfig.loadFromFile(allConfigs.get(exports.APPHOSTING_BASE_YAML_FILE));
162
+ const sample = "env:\n" +
163
+ "#- variable: ENV_VAR_NAME\n" +
164
+ "# value: plaintext value\n" +
165
+ "#- variable: SECRET_ENV_VAR_NAME\n" +
166
+ "# secret: cloud-secret-manager-id\n";
167
+ (0, fs_1.writeFileSync)((0, path_1.join)(basePath, exports.APPHOSTING_EMULATORS_YAML_FILE), sample);
168
+ }
169
+ return (0, yaml_1.toEnvList)({ ...baseConfig.env, ...newEnv });
170
+ }
171
+ exports.maybeGenerateEmulatorYaml = maybeGenerateEmulatorYaml;
172
+ async function overrideChosenEnv(projectId, env) {
173
+ const names = Object.keys(env);
174
+ if (!names.length) {
175
+ return {};
176
+ }
177
+ const toOverwrite = await prompt.checkbox({
178
+ message: "Which environment variables would you like to override?",
179
+ choices: names,
180
+ });
181
+ if (!projectId && toOverwrite.some((name) => "secret" in env[name])) {
182
+ throw new error_1.FirebaseError(`Need a project ID to overwrite a secret. Either use ${clc.bold("firebase use")} or pass the ${clc.bold("--project")} flag`);
183
+ }
184
+ const newEnv = {};
185
+ for (const name of toOverwrite) {
186
+ if ("value" in env[name]) {
187
+ const newValue = await prompt.input(`What new value would you like for plaintext ${name}?`);
188
+ newEnv[name] = { variable: name, value: newValue };
189
+ continue;
190
+ }
191
+ let secretRef;
192
+ let action = "pick-new";
193
+ while (action === "pick-new") {
194
+ secretRef = await prompt.input({
195
+ message: `What would you like to name the secret reference for ${name}?`,
196
+ default: suggestedTestKeyName(name),
197
+ });
198
+ if (await csm.secretExists(projectId, secretRef)) {
199
+ action = await prompt.select({
200
+ message: "This secret reference already exists, would you like to reuse it or create a new one?",
201
+ choices: [
202
+ { name: "Reuse it", value: "reuse" },
203
+ { name: "Create a new one", value: "pick-new" },
204
+ ],
205
+ });
206
+ }
207
+ else {
208
+ action = "create";
209
+ }
210
+ }
211
+ newEnv[name] = { variable: name, secret: secretRef };
212
+ if (action === "reuse") {
213
+ continue;
214
+ }
215
+ const secretValue = await prompt.password(`What new value would you like for secret ${name} [input is hidden]?`);
216
+ await csm.createSecret(projectId, secretRef, { [csm.FIREBASE_MANAGED]: "apphosting" });
217
+ await csm.addVersion(projectId, secretRef, secretValue);
189
218
  }
190
- const baseFilePath = allConfigs.get(exports.APPHOSTING_BASE_YAML_FILE);
191
- return await loadConfigForEnvironment(userGivenConfigFilePath, baseFilePath);
219
+ return newEnv;
192
220
  }
193
- exports.loadConfigToExportSecrets = loadConfigToExportSecrets;
194
- function getValidConfigs(cwd) {
195
- const appHostingConfigPaths = listAppHostingFilesInPath(cwd).filter((path) => !path.endsWith(exports.APPHOSTING_LOCAL_YAML_FILE));
196
- if (appHostingConfigPaths.length === 0) {
197
- throw new error_1.FirebaseError("No apphosting.*.yaml configs found");
198
- }
199
- const fileNameToPathMap = new Map();
200
- for (const path of appHostingConfigPaths) {
201
- const fileName = (0, path_1.basename)(path);
202
- fileNameToPathMap.set(fileName, path);
203
- }
204
- return fileNameToPathMap;
221
+ exports.overrideChosenEnv = overrideChosenEnv;
222
+ function suggestedTestKeyName(variable) {
223
+ return "test-" + variable.replace(/_/g, "-").toLowerCase();
205
224
  }
225
+ exports.suggestedTestKeyName = suggestedTestKeyName;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGitHubCommit = exports.getGitHubBranch = exports.fetchRepositoryCloneUris = exports.listAppHostingConnections = exports.getOrCreateRepository = exports.getOrCreateConnection = exports.createConnection = exports.ensureSecretManagerAdminGrant = exports.promptGitHubBranch = exports.getOrCreateOauthConnection = exports.listValidInstallations = exports.promptGitHubInstallation = exports.getConnectionForInstallation = exports.linkGitHubRepository = exports.getOrCreateGithubConnectionWithSentinel = exports.generateRepositoryId = exports.extractRepoSlugFromUri = exports.parseConnectionName = void 0;
3
+ exports.getGitHubCommit = exports.getGitHubBranch = exports.fetchRepositoryCloneUris = exports.listAppHostingConnections = exports.getOrCreateRepository = exports.getOrCreateConnection = exports.createConnection = exports.ensureSecretManagerAdminGrant = exports.promptGitHubBranch = exports.getOrCreateOauthConnection = exports.listValidInstallations = exports.promptGitHubInstallation = exports.getConnectionForInstallation = exports.linkGitHubRepository = exports.getOrCreateFullyInstalledGithubConnection = exports.generateConnectionId = exports.generateRepositoryId = exports.extractRepoSlugFromUri = exports.parseConnectionName = void 0;
4
4
  const clc = require("colorette");
5
5
  const devConnect = require("../gcp/devConnect");
6
6
  const rm = require("../gcp/resourceManager");
@@ -11,11 +11,9 @@ const prompt_1 = require("../prompt");
11
11
  const getProjectNumber_1 = require("../getProjectNumber");
12
12
  const api_1 = require("../api");
13
13
  const fuzzy = require("fuzzy");
14
- const inquirer = require("inquirer");
15
14
  const apiv2_1 = require("../apiv2");
16
15
  const githubApiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.githubApiOrigin)(), auth: false });
17
16
  const APPHOSTING_CONN_PATTERN = /.+\/apphosting-github-conn-.+$/;
18
- const APPHOSTING_OAUTH_CONN_NAME = "firebase-app-hosting-github-oauth";
19
17
  const CONNECTION_NAME_REGEX = /^projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/connections\/(?<id>[^\/]+)$/;
20
18
  function parseConnectionName(name) {
21
19
  const match = CONNECTION_NAME_REGEX.exec(name);
@@ -48,13 +46,14 @@ function generateRepositoryId(remoteUri) {
48
46
  return extractRepoSlugFromUri(remoteUri)?.replaceAll("/", "-");
49
47
  }
50
48
  exports.generateRepositoryId = generateRepositoryId;
51
- function generateConnectionId() {
49
+ const generateConnectionId = () => {
52
50
  const randomHash = Math.random().toString(36).slice(6);
53
51
  return `apphosting-github-conn-${randomHash}`;
54
- }
52
+ };
53
+ exports.generateConnectionId = generateConnectionId;
55
54
  const ADD_ACCOUNT_CHOICE = "@ADD_ACCOUNT";
56
55
  const MANAGE_INSTALLATION_CHOICE = "@MANAGE_INSTALLATION";
57
- async function getOrCreateGithubConnectionWithSentinel(projectId, location, createConnectionId) {
56
+ async function getOrCreateFullyInstalledGithubConnection(projectId, location, createConnectionId) {
58
57
  utils.logBullet(clc.bold(`${clc.yellow("===")} Import a GitHub repository`));
59
58
  if (createConnectionId) {
60
59
  try {
@@ -75,10 +74,7 @@ async function getOrCreateGithubConnectionWithSentinel(projectId, location, crea
75
74
  const apphostingGitHubInstallationURL = (0, api_1.apphostingGitHubAppInstallationURL)();
76
75
  utils.logBullet(apphostingGitHubInstallationURL);
77
76
  await utils.openInBrowser(apphostingGitHubInstallationURL);
78
- await (0, prompt_1.promptOnce)({
79
- type: "input",
80
- message: "Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.",
81
- });
77
+ await (0, prompt_1.input)("Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.");
82
78
  installationId = await promptGitHubInstallation(projectId, location, oauthConn);
83
79
  }
84
80
  const connectionMatchingInstallation = await getConnectionForInstallation(projectId, location, installationId);
@@ -90,14 +86,14 @@ async function getOrCreateGithubConnectionWithSentinel(projectId, location, crea
90
86
  }
91
87
  }
92
88
  if (!createConnectionId) {
93
- createConnectionId = generateConnectionId();
89
+ createConnectionId = (0, exports.generateConnectionId)();
94
90
  }
95
91
  const connection = await createFullyInstalledConnection(projectId, location, createConnectionId, oauthConn, installationId);
96
92
  return connection;
97
93
  }
98
- exports.getOrCreateGithubConnectionWithSentinel = getOrCreateGithubConnectionWithSentinel;
94
+ exports.getOrCreateFullyInstalledGithubConnection = getOrCreateFullyInstalledGithubConnection;
99
95
  async function linkGitHubRepository(projectId, location, createConnectionId) {
100
- const connection = await getOrCreateGithubConnectionWithSentinel(projectId, location, createConnectionId);
96
+ const connection = await getOrCreateFullyInstalledGithubConnection(projectId, location, createConnectionId);
101
97
  let repoCloneUri;
102
98
  do {
103
99
  if (repoCloneUri === MANAGE_INSTALLATION_CHOICE) {
@@ -124,10 +120,7 @@ async function createFullyInstalledConnection(projectId, location, connectionId,
124
120
  const targetUri = conn.installationState.actionUri;
125
121
  utils.logBullet(targetUri);
126
122
  await utils.openInBrowser(targetUri);
127
- await (0, prompt_1.promptOnce)({
128
- type: "input",
129
- message: "Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.",
130
- });
123
+ await (0, prompt_1.input)("Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.");
131
124
  conn = await devConnect.getConnection(projectId, location, connectionId);
132
125
  }
133
126
  return conn;
@@ -140,10 +133,7 @@ async function manageInstallation(connection) {
140
133
  }
141
134
  utils.logBullet(targetUri);
142
135
  await utils.openInBrowser(targetUri);
143
- await (0, prompt_1.promptOnce)({
144
- type: "input",
145
- message: "Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.",
146
- });
136
+ await (0, prompt_1.input)("Press Enter once you have installed or configured the Firebase App Hosting GitHub app to access your GitHub repo.");
147
137
  }
148
138
  async function getConnectionForInstallation(projectId, location, installationId) {
149
139
  const connections = await listAppHostingConnections(projectId, location);
@@ -160,30 +150,26 @@ async function getConnectionForInstallation(projectId, location, installationId)
160
150
  exports.getConnectionForInstallation = getConnectionForInstallation;
161
151
  async function promptGitHubInstallation(projectId, location, connection) {
162
152
  const installations = await listValidInstallations(projectId, location, connection);
163
- const installationName = await (0, prompt_1.promptOnce)({
164
- type: "autocomplete",
165
- name: "installation",
153
+ const installationName = await (0, prompt_1.search)({
166
154
  message: "Which GitHub account do you want to use?",
167
- source: (_, input = "") => {
168
- return new Promise((resolve) => resolve([
169
- new inquirer.Separator(),
170
- {
171
- name: "Missing an account? Select this option to add a GitHub account",
172
- value: ADD_ACCOUNT_CHOICE,
173
- },
174
- new inquirer.Separator(),
175
- ...fuzzy
176
- .filter(input, installations, {
177
- extract: (installation) => installation.name || "",
178
- })
179
- .map((result) => {
180
- return {
181
- name: result.original.name || "",
182
- value: result.original.id,
183
- };
184
- }),
185
- ]));
186
- },
155
+ source: (input = "") => [
156
+ new prompt_1.Separator(),
157
+ {
158
+ name: "Missing an account? Select this option to add a GitHub account",
159
+ value: ADD_ACCOUNT_CHOICE,
160
+ },
161
+ new prompt_1.Separator(),
162
+ ...fuzzy
163
+ .filter(input, installations, {
164
+ extract: (installation) => installation.name || "",
165
+ })
166
+ .map((result) => {
167
+ return {
168
+ name: result.original.name || "",
169
+ value: result.original.id,
170
+ };
171
+ }),
172
+ ],
187
173
  });
188
174
  return installationName;
189
175
  }
@@ -201,26 +187,17 @@ async function listValidInstallations(projectId, location, connection) {
201
187
  exports.listValidInstallations = listValidInstallations;
202
188
  async function getOrCreateOauthConnection(projectId, location) {
203
189
  let conn;
204
- try {
205
- conn = await devConnect.getConnection(projectId, location, APPHOSTING_OAUTH_CONN_NAME);
206
- }
207
- catch (err) {
208
- if (err.status === 404) {
209
- await ensureSecretManagerAdminGrant(projectId);
210
- conn = await createConnection(projectId, location, APPHOSTING_OAUTH_CONN_NAME);
211
- }
212
- else {
213
- throw err;
214
- }
190
+ const completedConnections = await listAppHostingConnections(projectId, location);
191
+ if (completedConnections.length > 0) {
192
+ return completedConnections[0];
215
193
  }
194
+ await ensureSecretManagerAdminGrant(projectId);
195
+ conn = await createConnection(projectId, location, (0, exports.generateConnectionId)());
216
196
  while (conn.installationState.stage === "PENDING_USER_OAUTH") {
217
197
  utils.logBullet("Please authorize the Firebase GitHub app by visiting this url:");
218
198
  const { url, cleanup } = await utils.openInBrowserPopup(conn.installationState.actionUri, "Authorize the GitHub app");
219
199
  utils.logBullet(`\t${url}`);
220
- await (0, prompt_1.promptOnce)({
221
- type: "input",
222
- message: "Press Enter once you have authorized the GitHub App.",
223
- });
200
+ await (0, prompt_1.input)("Press Enter once you have authorized the GitHub App.");
224
201
  cleanup();
225
202
  const { projectId, location, id } = parseConnectionName(conn.name);
226
203
  conn = await devConnect.getConnection(projectId, location, id);
@@ -231,51 +208,42 @@ async function getOrCreateOauthConnection(projectId, location) {
231
208
  exports.getOrCreateOauthConnection = getOrCreateOauthConnection;
232
209
  async function promptCloneUri(projectId, connection) {
233
210
  const cloneUris = await fetchRepositoryCloneUris(projectId, connection);
234
- const cloneUri = await (0, prompt_1.promptOnce)({
235
- type: "autocomplete",
236
- name: "cloneUri",
211
+ const cloneUri = await (0, prompt_1.search)({
237
212
  message: "Which GitHub repo do you want to deploy?",
238
- source: (_, input = "") => {
239
- return new Promise((resolve) => resolve([
240
- new inquirer.Separator(),
241
- {
242
- name: "Missing a repo? Select this option to configure your GitHub connection settings",
243
- value: MANAGE_INSTALLATION_CHOICE,
244
- },
245
- new inquirer.Separator(),
246
- ...fuzzy
247
- .filter(input, cloneUris, {
248
- extract: (uri) => extractRepoSlugFromUri(uri) || "",
249
- })
250
- .map((result) => {
251
- return {
252
- name: extractRepoSlugFromUri(result.original) || "",
253
- value: result.original,
254
- };
255
- }),
256
- ]));
257
- },
213
+ source: (input = "") => [
214
+ new prompt_1.Separator(),
215
+ {
216
+ name: "Missing a repo? Select this option to configure your GitHub connection settings",
217
+ value: MANAGE_INSTALLATION_CHOICE,
218
+ },
219
+ new prompt_1.Separator(),
220
+ ...fuzzy
221
+ .filter(input, cloneUris, {
222
+ extract: (uri) => extractRepoSlugFromUri(uri) || "",
223
+ })
224
+ .map((result) => {
225
+ return {
226
+ name: extractRepoSlugFromUri(result.original) || "",
227
+ value: result.original,
228
+ };
229
+ }),
230
+ ],
258
231
  });
259
232
  return cloneUri;
260
233
  }
261
234
  async function promptGitHubBranch(repoLink) {
262
235
  const branches = await devConnect.listAllBranches(repoLink.name);
263
- const branch = await (0, prompt_1.promptOnce)({
264
- type: "autocomplete",
265
- name: "branch",
236
+ const branch = await (0, prompt_1.search)({
266
237
  message: "Pick a branch for continuous deployment",
267
- source: (_, input = "") => {
268
- return new Promise((resolve) => resolve([
269
- ...fuzzy.filter(input, Array.from(branches)).map((result) => {
270
- return {
271
- name: result.original,
272
- value: result.original,
273
- };
274
- }),
275
- ]));
276
- },
238
+ source: (input = "") => [
239
+ ...fuzzy.filter(input, Array.from(branches)).map((result) => {
240
+ return {
241
+ name: result.original,
242
+ value: result.original,
243
+ };
244
+ }),
245
+ ],
277
246
  });
278
- utils.logWarning(`The branch "${branch}" does not exist on "${extractRepoSlugFromUri(repoLink.cloneUri) ?? ""}". Please enter a valid branch for this repo.`);
279
247
  return branch;
280
248
  }
281
249
  exports.promptGitHubBranch = promptGitHubBranch;
@@ -288,10 +256,7 @@ async function ensureSecretManagerAdminGrant(projectId) {
288
256
  return;
289
257
  }
290
258
  utils.logBullet("To create a new GitHub connection, Secret Manager Admin role (roles/secretmanager.admin) is required on the Developer Connect Service Agent.");
291
- const grant = await (0, prompt_1.promptOnce)({
292
- type: "confirm",
293
- message: "Grant the required role to the Developer Connect Service Agent?",
294
- });
259
+ const grant = await (0, prompt_1.confirm)("Grant the required role to the Developer Connect Service Agent?");
295
260
  if (!grant) {
296
261
  utils.logBullet("You, or your project administrator, should run the following command to grant the required role:\n\n" +
297
262
  "You, or your project adminstrator, can run the following command to grant the required role manually:\n\n" +
@@ -11,7 +11,6 @@ const error_1 = require("../error");
11
11
  const prompt_1 = require("../prompt");
12
12
  const getProjectNumber_1 = require("../getProjectNumber");
13
13
  const fuzzy = require("fuzzy");
14
- const inquirer = require("inquirer");
15
14
  const APPHOSTING_CONN_PATTERN = /.+\/apphosting-github-conn-.+$/;
16
15
  const APPHOSTING_OAUTH_CONN_NAME = "apphosting-github-oauth";
17
16
  const CONNECTION_NAME_REGEX = /^projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/connections\/(?<id>[^\/]+)$/;
@@ -86,10 +85,7 @@ async function createFullyInstalledConnection(projectId, location, connectionId,
86
85
  const targetUri = conn.installationState.actionUri;
87
86
  utils.logBullet(targetUri);
88
87
  await utils.openInBrowser(targetUri);
89
- await (0, prompt_1.promptOnce)({
90
- type: "input",
91
- message: "Press Enter once you have installed or configured the Cloud Build GitHub app to access your GitHub repo.",
92
- });
88
+ await (0, prompt_1.input)("Press Enter once you have installed or configured the Cloud Build GitHub app to access your GitHub repo.");
93
89
  conn = await gcb.getConnection(projectId, location, connectionId);
94
90
  }
95
91
  return conn;
@@ -113,10 +109,7 @@ async function getOrCreateOauthConnection(projectId, location) {
113
109
  utils.logBullet("Sign in to GitHub and authorize Cloud Build GitHub app:");
114
110
  const { url, cleanup } = await utils.openInBrowserPopup(conn.installationState.actionUri, "Authorize the GitHub app");
115
111
  utils.logBullet(`\t${url}`);
116
- await (0, prompt_1.promptOnce)({
117
- type: "input",
118
- message: "Press Enter once you have authorized the app",
119
- });
112
+ await (0, prompt_1.input)("Press Enter once you have authorized the app");
120
113
  cleanup();
121
114
  const { projectId, location, id } = parseConnectionName(conn.name);
122
115
  conn = await gcb.getConnection(projectId, location, id);
@@ -126,30 +119,26 @@ async function getOrCreateOauthConnection(projectId, location) {
126
119
  exports.getOrCreateOauthConnection = getOrCreateOauthConnection;
127
120
  async function promptRepositoryUri(projectId, connections) {
128
121
  const { repos, remoteUriToConnection } = await fetchAllRepositories(projectId, connections);
129
- const remoteUri = await (0, prompt_1.promptOnce)({
130
- type: "autocomplete",
131
- name: "remoteUri",
122
+ const remoteUri = await (0, prompt_1.search)({
132
123
  message: "Which GitHub repo do you want to deploy?",
133
- source: (_, input = "") => {
134
- return new Promise((resolve) => resolve([
135
- new inquirer.Separator(),
136
- {
137
- name: "Missing a repo? Select this option to configure your GitHub connection settings",
138
- value: ADD_CONN_CHOICE,
139
- },
140
- new inquirer.Separator(),
141
- ...fuzzy
142
- .filter(input, repos, {
143
- extract: (repo) => extractRepoSlugFromUri(repo.remoteUri) || "",
144
- })
145
- .map((result) => {
146
- return {
147
- name: extractRepoSlugFromUri(result.original.remoteUri) || "",
148
- value: result.original.remoteUri,
149
- };
150
- }),
151
- ]));
152
- },
124
+ source: (input) => [
125
+ new prompt_1.Separator(),
126
+ {
127
+ name: "Missing a repo? Select this option to configure your GitHub connection settings",
128
+ value: ADD_CONN_CHOICE,
129
+ },
130
+ new prompt_1.Separator(),
131
+ ...fuzzy
132
+ .filter(input ?? "", repos, {
133
+ extract: (repo) => extractRepoSlugFromUri(repo.remoteUri) || "",
134
+ })
135
+ .map((result) => {
136
+ return {
137
+ name: extractRepoSlugFromUri(result.original.remoteUri) || "",
138
+ value: result.original.remoteUri,
139
+ };
140
+ }),
141
+ ],
153
142
  });
154
143
  return { remoteUri, connection: remoteUriToConnection[remoteUri] };
155
144
  }
@@ -161,10 +150,7 @@ async function ensureSecretManagerAdminGrant(projectId) {
161
150
  return;
162
151
  }
163
152
  utils.logBullet("To create a new GitHub connection, Secret Manager Admin role (roles/secretmanager.admin) is required on the Cloud Build Service Agent.");
164
- const grant = await (0, prompt_1.promptOnce)({
165
- type: "confirm",
166
- message: "Grant the required role to the Cloud Build Service Agent?",
167
- });
153
+ const grant = await (0, prompt_1.confirm)("Grant the required role to the Cloud Build Service Agent?");
168
154
  if (!grant) {
169
155
  utils.logBullet("You, or your project administrator, should run the following command to grant the required role:\n\n" +
170
156
  "You, or your project adminstrator, can run the following command to grant the required role manually:\n\n" +