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
@@ -1,55 +1,91 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.doSetup = void 0;
4
- const logger_1 = require("../../../logger");
5
- const apiEnabled = require("../../../ensureApiEnabled");
6
- const requirePermissions_1 = require("../../../requirePermissions");
7
- const checkDatabaseType_1 = require("../../../firestore/checkDatabaseType");
3
+ exports.actuate = exports.askQuestions = void 0;
8
4
  const rules = require("./rules");
9
5
  const indexes = require("./indexes");
10
6
  const error_1 = require("../../../error");
11
- const clc = require("colorette");
7
+ const api_1 = require("../../../firestore/api");
12
8
  const prompt_1 = require("../../../prompt");
13
- async function checkProjectSetup(setup, config, options) {
14
- const firestoreUnusedError = new error_1.FirebaseError(`It looks like you haven't used Cloud Firestore in this project before. Go to ${clc.bold(clc.underline(`https://console.firebase.google.com/project/${setup.projectId}/firestore`))} to create your Cloud Firestore database.`, { exit: 1 });
15
- const isFirestoreEnabled = await apiEnabled.check(setup.projectId, "firestore.googleapis.com", "", true);
16
- if (!isFirestoreEnabled) {
17
- throw firestoreUnusedError;
18
- }
19
- const dbType = await getDatabaseType(setup);
20
- logger_1.logger.debug(`database_type: ${dbType}`);
21
- if (!dbType) {
22
- throw firestoreUnusedError;
23
- }
24
- else if (dbType !== "FIRESTORE_NATIVE") {
25
- throw new error_1.FirebaseError(`It looks like this project is using Cloud Datastore or Cloud Firestore in Datastore mode. The Firebase CLI can only manage projects using Cloud Firestore in Native mode. For more information, visit https://cloud.google.com/datastore/docs/firestore-or-datastore`, { exit: 1 });
9
+ const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
10
+ const api_2 = require("../../../api");
11
+ async function askQuestions(setup, config) {
12
+ const firestore = !Array.isArray(setup.config.firestore) ? setup.config.firestore : undefined;
13
+ const info = {
14
+ databaseId: firestore?.database || "",
15
+ locationId: firestore?.location || "",
16
+ rulesFilename: firestore?.rules || "",
17
+ rules: "",
18
+ writeRules: true,
19
+ indexesFilename: firestore?.indexes || "",
20
+ indexes: "",
21
+ writeIndexes: true,
22
+ };
23
+ if (setup.projectId) {
24
+ await (0, ensureApiEnabled_1.ensure)(setup.projectId, (0, api_2.firestoreOrigin)(), "firestore");
25
+ info.databaseId = info.databaseId || "(default)";
26
+ const api = new api_1.FirestoreApi();
27
+ const databases = await api.listDatabases(setup.projectId);
28
+ const nativeDatabaseNames = databases
29
+ .filter((db) => db.type === "FIRESTORE_NATIVE")
30
+ .map((db) => db.name.split("/")[3]);
31
+ if (nativeDatabaseNames.length === 0) {
32
+ if (databases.length > 0) {
33
+ throw new error_1.FirebaseError(`It looks like this project is using Cloud Firestore in ${databases[0].type}. The Firebase CLI can only manage projects using Cloud Firestore in Native mode. For more information, visit https://cloud.google.com/datastore/docs/firestore-or-datastore`, { exit: 1 });
34
+ }
35
+ info.databaseId = "(default)";
36
+ const locations = await api.locations(setup.projectId);
37
+ const choice = await (0, prompt_1.select)({
38
+ message: "Please select the location of your Firestore database:",
39
+ choices: locations.map((location) => location.name.split("/")[3]),
40
+ default: "nam5",
41
+ });
42
+ info.locationId = choice;
43
+ }
44
+ else if (nativeDatabaseNames.length === 1) {
45
+ info.databaseId = nativeDatabaseNames[0];
46
+ info.locationId = databases
47
+ .filter((db) => db.name.endsWith(`databases/${info.databaseId}`))
48
+ .map((db) => db.locationId)[0];
49
+ }
50
+ else if (nativeDatabaseNames.length > 1) {
51
+ const choice = await (0, prompt_1.select)({
52
+ message: "Please select the name of the Native Firestore database you would like to use:",
53
+ choices: nativeDatabaseNames,
54
+ });
55
+ info.databaseId = choice;
56
+ info.locationId = databases
57
+ .filter((db) => db.name.endsWith(`databases/${info.databaseId}`))
58
+ .map((db) => db.locationId)[0];
59
+ }
26
60
  }
27
- await (0, requirePermissions_1.requirePermissions)({ ...options, project: setup.projectId });
61
+ await rules.initRules(setup, config, info);
62
+ await indexes.initIndexes(setup, config, info);
63
+ setup.featureInfo = setup.featureInfo || {};
64
+ setup.featureInfo.firestore = info;
28
65
  }
29
- async function getDatabaseType(setup) {
30
- const dbType = await (0, checkDatabaseType_1.checkDatabaseType)(setup.projectId, setup.databaseId);
31
- logger_1.logger.debug(`database_type: ${dbType}`);
32
- if (dbType === "DATABASE_DOES_NOT_EXIST") {
33
- setup.databaseId = await selectDatabaseByPrompting();
34
- return await getDatabaseType(setup);
66
+ exports.askQuestions = askQuestions;
67
+ async function actuate(setup, config) {
68
+ const info = setup.featureInfo?.firestore;
69
+ if (!info) {
70
+ throw new error_1.FirebaseError("Firestore featureInfo is not found");
35
71
  }
36
- else {
37
- return dbType;
72
+ info.databaseId = info.databaseId || "(default)";
73
+ info.locationId = info.locationId || "nam5";
74
+ info.rules = info.rules || rules.getDefaultRules();
75
+ info.rulesFilename = info.rulesFilename || rules.DEFAULT_RULES_FILE;
76
+ info.indexes = info.indexes || indexes.INDEXES_TEMPLATE;
77
+ info.indexesFilename = info.indexesFilename || indexes.DEFAULT_INDEXES_FILE;
78
+ setup.config.firestore = {
79
+ database: info.databaseId,
80
+ location: info.locationId,
81
+ rules: info.rulesFilename,
82
+ indexes: info.indexesFilename,
83
+ };
84
+ if (info.writeRules) {
85
+ config.writeProjectFile(info.rulesFilename, info.rules);
38
86
  }
39
- }
40
- async function selectDatabaseByPrompting() {
41
- const database = await (0, prompt_1.promptOnce)({
42
- type: "input",
43
- message: "Please input the name of the Native Firestore database you would like to use:",
44
- });
45
- return database;
46
- }
47
- async function doSetup(setup, config, options) {
48
- if (setup.projectId) {
49
- await checkProjectSetup(setup, config, options);
87
+ if (info.writeIndexes) {
88
+ config.writeProjectFile(info.indexesFilename, info.indexes);
50
89
  }
51
- setup.config.firestore = {};
52
- await rules.initRules(setup, config);
53
- await indexes.initIndexes(setup, config);
54
90
  }
55
- exports.doSetup = doSetup;
91
+ exports.actuate = actuate;
@@ -1,71 +1,56 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initIndexes = void 0;
3
+ exports.initIndexes = exports.INDEXES_TEMPLATE = exports.DEFAULT_INDEXES_FILE = void 0;
4
4
  const clc = require("colorette");
5
5
  const error_1 = require("../../../error");
6
6
  const api = require("../../../firestore/api");
7
- const fsutils = require("../../../fsutils");
8
7
  const prompt_1 = require("../../../prompt");
8
+ const utils = require("../../../utils");
9
9
  const logger_1 = require("../../../logger");
10
10
  const templates_1 = require("../../../templates");
11
11
  const indexes = new api.FirestoreApi();
12
- const INDEXES_TEMPLATE = (0, templates_1.readTemplateSync)("init/firestore/firestore.indexes.json");
13
- function initIndexes(setup, config) {
12
+ exports.DEFAULT_INDEXES_FILE = "firestore.indexes.json";
13
+ exports.INDEXES_TEMPLATE = (0, templates_1.readTemplateSync)("init/firestore/firestore.indexes.json");
14
+ async function initIndexes(setup, config, info) {
14
15
  logger_1.logger.info();
15
16
  logger_1.logger.info("Firestore indexes allow you to perform complex queries while");
16
17
  logger_1.logger.info("maintaining performance that scales with the size of the result");
17
18
  logger_1.logger.info("set. You can keep index definitions in your project directory");
18
19
  logger_1.logger.info("and publish them with " + clc.bold("firebase deploy") + ".");
19
20
  logger_1.logger.info();
20
- return (0, prompt_1.prompt)(setup.config.firestore, [
21
- {
22
- type: "input",
23
- name: "indexes",
24
- message: "What file should be used for Firestore indexes?",
25
- default: "firestore.indexes.json",
26
- },
27
- ])
28
- .then(() => {
29
- const filename = setup.config.firestore.indexes;
30
- if (fsutils.fileExistsSync(filename)) {
31
- const msg = "File " +
32
- clc.bold(filename) +
33
- " already exists." +
34
- " Do you want to overwrite it with the Firestore Indexes from the Firebase Console?";
35
- return (0, prompt_1.promptOnce)({
36
- type: "confirm",
37
- message: msg,
38
- default: false,
39
- });
21
+ info.indexesFilename =
22
+ info.indexesFilename ||
23
+ (await (0, prompt_1.input)({
24
+ message: "What file should be used for Firestore indexes?",
25
+ default: exports.DEFAULT_INDEXES_FILE,
26
+ }));
27
+ info.indexes = exports.INDEXES_TEMPLATE;
28
+ if (setup.projectId) {
29
+ const downloadIndexes = await getIndexesFromConsole(setup.projectId, info.databaseId);
30
+ if (downloadIndexes) {
31
+ info.indexes = downloadIndexes;
32
+ utils.logBullet(`Downloaded the existing Firestore indexes from the Firebase console`);
40
33
  }
41
- return Promise.resolve(true);
42
- })
43
- .then((overwrite) => {
44
- if (!overwrite) {
45
- return Promise.resolve();
46
- }
47
- if (!setup.projectId) {
48
- return config.writeProjectFile(setup.config.firestore.indexes, INDEXES_TEMPLATE);
49
- }
50
- return getIndexesFromConsole(setup.projectId, setup.databaseId).then((contents) => {
51
- return config.writeProjectFile(setup.config.firestore.indexes, contents);
52
- });
53
- });
34
+ }
35
+ info.writeRules = await config.confirmWriteProjectFile(info.indexesFilename, info.indexes);
54
36
  }
55
37
  exports.initIndexes = initIndexes;
56
- function getIndexesFromConsole(projectId, databaseId) {
38
+ async function getIndexesFromConsole(projectId, databaseId) {
57
39
  const indexesPromise = indexes.listIndexes(projectId, databaseId);
58
40
  const fieldOverridesPromise = indexes.listFieldOverrides(projectId, databaseId);
59
- return Promise.all([indexesPromise, fieldOverridesPromise])
60
- .then((res) => {
61
- return indexes.makeIndexSpec(res[0], res[1]);
62
- })
63
- .catch((e) => {
41
+ try {
42
+ const res = await Promise.all([indexesPromise, fieldOverridesPromise]);
43
+ return JSON.stringify(indexes.makeIndexSpec(res[0], res[1]), null, 2);
44
+ }
45
+ catch (e) {
46
+ if (e.status === 404) {
47
+ return null;
48
+ }
64
49
  if (e.message.indexOf("is not a Cloud Firestore enabled project") >= 0) {
65
- return INDEXES_TEMPLATE;
50
+ return null;
66
51
  }
67
52
  throw new error_1.FirebaseError("Error fetching Firestore indexes", {
68
53
  original: e,
69
54
  });
70
- });
55
+ }
71
56
  }
@@ -1,80 +1,54 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initRules = void 0;
3
+ exports.initRules = exports.getDefaultRules = exports.DEFAULT_RULES_FILE = void 0;
4
4
  const clc = require("colorette");
5
5
  const gcp = require("../../../gcp");
6
- const fsutils = require("../../../fsutils");
7
6
  const prompt_1 = require("../../../prompt");
8
7
  const logger_1 = require("../../../logger");
9
8
  const utils = require("../../../utils");
10
9
  const templates_1 = require("../../../templates");
11
- const DEFAULT_RULES_FILE = "firestore.rules";
10
+ exports.DEFAULT_RULES_FILE = "firestore.rules";
12
11
  const RULES_TEMPLATE = (0, templates_1.readTemplateSync)("init/firestore/firestore.rules");
13
- function initRules(setup, config) {
12
+ function getDefaultRules() {
13
+ const date = utils.thirtyDaysFromNow();
14
+ const formattedForRules = `${date.getFullYear()}, ${date.getMonth() + 1}, ${date.getDate()}`;
15
+ return RULES_TEMPLATE.replace(/{{IN_30_DAYS}}/g, formattedForRules);
16
+ }
17
+ exports.getDefaultRules = getDefaultRules;
18
+ async function initRules(setup, config, info) {
14
19
  logger_1.logger.info();
15
20
  logger_1.logger.info("Firestore Security Rules allow you to define how and when to allow");
16
21
  logger_1.logger.info("requests. You can keep these rules in your project directory");
17
22
  logger_1.logger.info("and publish them with " + clc.bold("firebase deploy") + ".");
18
23
  logger_1.logger.info();
19
- return (0, prompt_1.prompt)(setup.config.firestore, [
20
- {
21
- type: "input",
22
- name: "rules",
23
- message: "What file should be used for Firestore Rules?",
24
- default: DEFAULT_RULES_FILE,
25
- },
26
- ])
27
- .then(() => {
28
- const filename = setup.config.firestore.rules;
29
- if (fsutils.fileExistsSync(filename)) {
30
- const msg = "File " +
31
- clc.bold(filename) +
32
- " already exists." +
33
- " Do you want to overwrite it with the Firestore Rules from the Firebase Console?";
34
- return (0, prompt_1.promptOnce)({
35
- type: "confirm",
36
- message: msg,
37
- default: false,
38
- });
39
- }
40
- return Promise.resolve(true);
41
- })
42
- .then((overwrite) => {
43
- if (!overwrite) {
44
- return Promise.resolve();
24
+ info.rulesFilename =
25
+ info.rulesFilename ||
26
+ (await (0, prompt_1.input)({
27
+ message: "What file should be used for Firestore Rules?",
28
+ default: exports.DEFAULT_RULES_FILE,
29
+ }));
30
+ info.rules = getDefaultRules();
31
+ if (setup.projectId) {
32
+ const downloadedRules = await getRulesFromConsole(setup.projectId);
33
+ if (downloadedRules) {
34
+ info.rules = downloadedRules;
35
+ utils.logBullet(`Downloaded the existing Firestore Security Rules from the Firebase console`);
45
36
  }
46
- if (!setup.projectId) {
47
- return config.writeProjectFile(setup.config.firestore.rules, getDefaultRules());
48
- }
49
- return getRulesFromConsole(setup.projectId).then((contents) => {
50
- return config.writeProjectFile(setup.config.firestore.rules, contents);
51
- });
52
- });
37
+ }
38
+ info.writeRules = await config.confirmWriteProjectFile(info.rulesFilename, info.rules);
53
39
  }
54
40
  exports.initRules = initRules;
55
- function getDefaultRules() {
56
- const date = utils.thirtyDaysFromNow();
57
- const formattedForRules = `${date.getFullYear()}, ${date.getMonth() + 1}, ${date.getDate()}`;
58
- return RULES_TEMPLATE.replace(/{{IN_30_DAYS}}/g, formattedForRules);
59
- }
60
- function getRulesFromConsole(projectId) {
61
- return gcp.rules
62
- .getLatestRulesetName(projectId, "cloud.firestore")
63
- .then((name) => {
64
- if (!name) {
65
- logger_1.logger.debug("No rulesets found, using default.");
66
- return [{ name: DEFAULT_RULES_FILE, content: getDefaultRules() }];
67
- }
68
- logger_1.logger.debug("Found ruleset: " + name);
69
- return gcp.rules.getRulesetContent(name);
70
- })
71
- .then((rules) => {
72
- if (rules.length <= 0) {
73
- return utils.reject("Ruleset has no files", { exit: 1 });
74
- }
75
- if (rules.length > 1) {
76
- return utils.reject("Ruleset has too many files: " + rules.length, { exit: 1 });
77
- }
78
- return rules[0].content;
79
- });
41
+ async function getRulesFromConsole(projectId) {
42
+ const name = await gcp.rules.getLatestRulesetName(projectId, "cloud.firestore");
43
+ if (!name) {
44
+ return null;
45
+ }
46
+ const rules = await gcp.rules.getRulesetContent(name);
47
+ if (rules.length <= 0) {
48
+ return utils.reject("Ruleset has no files", { exit: 1 });
49
+ }
50
+ if (rules.length > 1) {
51
+ return utils.reject("Ruleset has too many files: " + rules.length, { exit: 1 });
52
+ }
53
+ return rules[0].content;
80
54
  }
@@ -9,6 +9,7 @@ const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
9
9
  const projectConfig_1 = require("../../../functions/projectConfig");
10
10
  const error_1 = require("../../../error");
11
11
  const api_1 = require("../../../api");
12
+ const supported = require("../../../deploy/functions/runtimes/supported");
12
13
  const MAX_ATTEMPTS = 5;
13
14
  async function doSetup(setup, config, options) {
14
15
  const projectId = setup?.rcfile?.projects?.default;
@@ -37,8 +38,7 @@ async function doSetup(setup, config, options) {
37
38
  value: "overwrite",
38
39
  },
39
40
  ];
40
- const initOpt = await (0, prompt_1.promptOnce)({
41
- type: "list",
41
+ const initOpt = await (0, prompt_1.select)({
42
42
  message: "Would you like to initialize a new codebase, or overwrite an existing one?",
43
43
  default: "new",
44
44
  choices,
@@ -65,10 +65,7 @@ async function initNewCodebase(setup, config) {
65
65
  if (attempts++ >= MAX_ATTEMPTS) {
66
66
  throw new error_1.FirebaseError("Exceeded max number of attempts to input valid codebase name. Please restart.");
67
67
  }
68
- codebase = await (0, prompt_1.promptOnce)({
69
- type: "input",
70
- message: "What should be the name of this codebase?",
71
- });
68
+ codebase = await (0, prompt_1.input)("What should be the name of this codebase?");
72
69
  try {
73
70
  (0, projectConfig_1.validateCodebase)(codebase);
74
71
  (0, projectConfig_1.assertUnique)(setup.config.functions, "codebase", codebase);
@@ -84,8 +81,7 @@ async function initNewCodebase(setup, config) {
84
81
  throw new error_1.FirebaseError("Exceeded max number of attempts to input valid source. Please restart.");
85
82
  }
86
83
  attempts++;
87
- source = await (0, prompt_1.promptOnce)({
88
- type: "input",
84
+ source = await (0, prompt_1.input)({
89
85
  message: `In what sub-directory would you like to initialize your functions for codebase ${clc.bold(codebase)}?`,
90
86
  default: codebase,
91
87
  });
@@ -113,8 +109,7 @@ async function overwriteCodebase(setup, config) {
113
109
  name: cfg["codebase"],
114
110
  value: cfg["codebase"],
115
111
  }));
116
- codebase = await (0, prompt_1.promptOnce)({
117
- type: "list",
112
+ codebase = await (0, prompt_1.select)({
118
113
  message: "Which codebase would you like to overwrite?",
119
114
  choices,
120
115
  });
@@ -141,13 +136,12 @@ async function languageSetup(setup, config) {
141
136
  name: "TypeScript",
142
137
  value: "typescript",
143
138
  },
139
+ {
140
+ name: "Python",
141
+ value: "python",
142
+ },
144
143
  ];
145
- choices.push({
146
- name: "Python",
147
- value: "python",
148
- });
149
- const language = await (0, prompt_1.promptOnce)({
150
- type: "list",
144
+ const language = await (0, prompt_1.select)({
151
145
  message: "What language would you like to use to write Cloud Functions?",
152
146
  default: "javascript",
153
147
  choices,
@@ -174,6 +168,7 @@ async function languageSetup(setup, config) {
174
168
  break;
175
169
  case "python":
176
170
  cbconfig.ignore = ["venv", ".git", "firebase-debug.log", "firebase-debug.*.log", "*.local"];
171
+ cbconfig.runtime = supported.latest("python");
177
172
  break;
178
173
  }
179
174
  setup.functions.languageChoice = language;
@@ -5,40 +5,27 @@ const npm_dependencies_1 = require("./npm-dependencies");
5
5
  const prompt_1 = require("../../../prompt");
6
6
  const projectConfig_1 = require("../../../functions/projectConfig");
7
7
  const templates_1 = require("../../../templates");
8
+ const supported = require("../../../deploy/functions/runtimes/supported");
8
9
  const INDEX_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/index.js");
9
10
  const PACKAGE_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/package.lint.json");
10
11
  const PACKAGE_NO_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/package.nolint.json");
11
12
  const ESLINT_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/_eslintrc");
12
13
  const GITIGNORE_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/_gitignore");
13
- function setup(setup, config) {
14
- return (0, prompt_1.prompt)(setup.functions, [
15
- {
16
- name: "lint",
17
- type: "confirm",
18
- message: "Do you want to use ESLint to catch probable bugs and enforce style?",
19
- default: false,
20
- },
21
- ])
22
- .then(() => {
23
- if (setup.functions.lint) {
24
- const cbconfig = (0, projectConfig_1.configForCodebase)(setup.config.functions, setup.functions.codebase);
25
- cbconfig.predeploy = ['npm --prefix "$RESOURCE_DIR" run lint'];
26
- return config
27
- .askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_LINTING_TEMPLATE)
28
- .then(() => {
29
- config.askWriteProjectFile(`${setup.functions.source}/.eslintrc.js`, ESLINT_TEMPLATE);
30
- });
31
- }
32
- return config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_NO_LINTING_TEMPLATE);
33
- })
34
- .then(() => {
35
- return config.askWriteProjectFile(`${setup.functions.source}/index.js`, INDEX_TEMPLATE);
36
- })
37
- .then(() => {
38
- return config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
39
- })
40
- .then(() => {
41
- return (0, npm_dependencies_1.askInstallDependencies)(setup.functions, config);
42
- });
14
+ async function setup(setup, config) {
15
+ setup.functions.lint =
16
+ setup.functions.lint ||
17
+ (await (0, prompt_1.confirm)("Do you want to use ESLint to catch probable bugs and enforce style?"));
18
+ if (setup.functions.lint) {
19
+ const cbconfig = (0, projectConfig_1.configForCodebase)(setup.config.functions, setup.functions.codebase);
20
+ cbconfig.predeploy = ['npm --prefix "$RESOURCE_DIR" run lint'];
21
+ await config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_LINTING_TEMPLATE.replace("{{RUNTIME}}", supported.latest("nodejs").replace("nodejs", "")));
22
+ await config.askWriteProjectFile(`${setup.functions.source}/.eslintrc.js`, ESLINT_TEMPLATE);
23
+ }
24
+ else {
25
+ await config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_NO_LINTING_TEMPLATE.replace("{{RUNTIME}}", supported.latest("nodejs").replace("nodejs", "")));
26
+ }
27
+ await config.askWriteProjectFile(`${setup.functions.source}/index.js`, INDEX_TEMPLATE);
28
+ await config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
29
+ await (0, npm_dependencies_1.askInstallDependencies)(setup.functions, config);
43
30
  }
44
31
  exports.setup = setup;
@@ -5,14 +5,10 @@ const logger_1 = require("../../../logger");
5
5
  const prompt_1 = require("../../../prompt");
6
6
  const spawn_1 = require("../../spawn");
7
7
  async function askInstallDependencies(setup, config) {
8
- await (0, prompt_1.prompt)(setup, [
9
- {
10
- name: "npm",
11
- type: "confirm",
12
- message: "Do you want to install dependencies with npm now?",
13
- default: true,
14
- },
15
- ]);
8
+ setup.npm = await (0, prompt_1.confirm)({
9
+ message: "Do you want to install dependencies with npm now?",
10
+ default: true,
11
+ });
16
12
  if (setup.npm) {
17
13
  try {
18
14
  await (0, spawn_1.wrapSpawn)("npm", ["install"], config.projectDir + `/${setup.source}`);
@@ -25,9 +25,7 @@ async function setup(setup, config) {
25
25
  venvProcess.on("exit", resolve);
26
26
  venvProcess.on("error", reject);
27
27
  });
28
- const install = await (0, prompt_1.promptOnce)({
29
- name: "install",
30
- type: "confirm",
28
+ const install = await (0, prompt_1.confirm)({
31
29
  message: "Do you want to install dependencies now?",
32
30
  default: true,
33
31
  });
@@ -5,6 +5,7 @@ const npm_dependencies_1 = require("./npm-dependencies");
5
5
  const prompt_1 = require("../../../prompt");
6
6
  const projectConfig_1 = require("../../../functions/projectConfig");
7
7
  const templates_1 = require("../../../templates");
8
+ const supported = require("../../../deploy/functions/runtimes/supported");
8
9
  const PACKAGE_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/package.lint.json");
9
10
  const PACKAGE_NO_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/package.nolint.json");
10
11
  const ESLINT_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/_eslintrc");
@@ -12,48 +13,29 @@ const TSCONFIG_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/type
12
13
  const TSCONFIG_DEV_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/tsconfig.dev.json");
13
14
  const INDEX_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/index.ts");
14
15
  const GITIGNORE_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/_gitignore");
15
- function setup(setup, config) {
16
- return (0, prompt_1.prompt)(setup.functions, [
17
- {
18
- name: "lint",
19
- type: "confirm",
20
- message: "Do you want to use ESLint to catch probable bugs and enforce style?",
21
- default: true,
22
- },
23
- ])
24
- .then(() => {
25
- const cbconfig = (0, projectConfig_1.configForCodebase)(setup.config.functions, setup.functions.codebase);
26
- cbconfig.predeploy = [];
27
- if (setup.functions.lint) {
28
- cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run lint');
29
- cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run build');
30
- return config
31
- .askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_LINTING_TEMPLATE)
32
- .then(() => {
33
- return config.askWriteProjectFile(`${setup.functions.source}/.eslintrc.js`, ESLINT_TEMPLATE);
34
- });
35
- }
36
- else {
37
- cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run build');
38
- }
39
- return config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_NO_LINTING_TEMPLATE);
40
- })
41
- .then(() => {
42
- return config.askWriteProjectFile(`${setup.functions.source}/tsconfig.json`, TSCONFIG_TEMPLATE);
43
- })
44
- .then(() => {
45
- if (setup.functions.lint) {
46
- return config.askWriteProjectFile(`${setup.functions.source}/tsconfig.dev.json`, TSCONFIG_DEV_TEMPLATE);
47
- }
48
- })
49
- .then(() => {
50
- return config.askWriteProjectFile(`${setup.functions.source}/src/index.ts`, INDEX_TEMPLATE);
51
- })
52
- .then(() => {
53
- return config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
54
- })
55
- .then(() => {
56
- return (0, npm_dependencies_1.askInstallDependencies)(setup.functions, config);
57
- });
16
+ async function setup(setup, config) {
17
+ setup.functions.lint =
18
+ setup.functions.lint ||
19
+ (await (0, prompt_1.confirm)({
20
+ message: "Do you want to use ESLint to catch probable bugs and enforce style?",
21
+ default: true,
22
+ }));
23
+ const cbconfig = (0, projectConfig_1.configForCodebase)(setup.config.functions, setup.functions.codebase);
24
+ cbconfig.predeploy = [];
25
+ if (setup.functions.lint) {
26
+ cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run lint');
27
+ cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run build');
28
+ await config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_LINTING_TEMPLATE.replace("{{RUNTIME}}", supported.latest("nodejs").replace("nodejs", "")));
29
+ await config.askWriteProjectFile(`${setup.functions.source}/.eslintrc.js`, ESLINT_TEMPLATE);
30
+ await config.askWriteProjectFile(`${setup.functions.source}/tsconfig.dev.json`, TSCONFIG_DEV_TEMPLATE);
31
+ }
32
+ else {
33
+ cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run build');
34
+ await config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_NO_LINTING_TEMPLATE.replace("{{RUNTIME}}", supported.latest("nodejs").replace("nodejs", "")));
35
+ }
36
+ await config.askWriteProjectFile(`${setup.functions.source}/tsconfig.json`, TSCONFIG_TEMPLATE);
37
+ await config.askWriteProjectFile(`${setup.functions.source}/src/index.ts`, INDEX_TEMPLATE);
38
+ await config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
39
+ await (0, npm_dependencies_1.askInstallDependencies)(setup.functions, config);
58
40
  }
59
41
  exports.setup = setup;