如何在不影响其他功能的情况下将一些功能部署到Cloud Functions for Firebase?

Ran*_*ku' 60 firebase firebase-tools google-cloud-functions

我跑的时候

firebase deploy --only functions

它读取index.js文件并更新从该文件导出的所有函数.如果在之前的部署中有一个名为的函数a,并且在当前部署中没有这样的函数,a将被删除.

换句话说,效果与删除所有现有函数,然后index.js添加当前文件中的所有函数相同.

是否可以添加/更新/删除单个功能?

Ran*_*ku' 150

Firebase CLI工具3.8.0增加了部署特定功能的能力.

firebase deploy --only functions:func1,functions:func2

--only <targets>     
only deploy to specified, comma-separated targets (e.g. "hosting,storage"). For functions, 
can specify filters with colons to scope function deploys to only those functions (e.g. "--only functions:func1,functions:func2"). 
When filtering based on export groups (the exported module object keys), use dots to specify group names 
(e.g. "--only functions:group1.subgroup1,functions:group2)"
Run Code Online (Sandbox Code Playgroud)

  • 目前看来应该是 firebase deploy --only "functions:func1,functions:func2" (8认同)
  • 请注意:不要在逗号后添加空格 firebase deploy --only functions:func1,functions:func2 (3认同)

Arj*_*jun 20

以下方式对我来说是一种部署特定功能而不影响其他功能的方法

firebase deploy --only functions:specificFunctionName
Run Code Online (Sandbox Code Playgroud)


Seb*_* F. 12

我从未设法让它工作(并且我的 firebase.json 中没有代码库属性),直到我尝试了 @Sergey Mell 在他的评论中提到的内容:

firebase deploy --only "functions:func1,functions:func2"
Run Code Online (Sandbox Code Playgroud)

周围的双引号解决了这个问题。


Fra*_*len 6

这里有一个firebaser

目前无法使用Firebase CLI部署单个功能.Running firebase deploy将部署所有功能.

我们最近讨论过部署函数的子集,但目前还没有 - 我们也不能给出它是否/何时可能的大概.

更新自Firebase CLI发布以来,可以使用部署单个功能的功能.见yuku的回答.

  • 这样的世界真是太棒了 (2认同)

Dav*_*vid 6

firebase deploy --only "functions:<fileName>.<functionName>"
Run Code Online (Sandbox Code Playgroud)

示例文件夹结构:

functions 
  node_modules
  index.js
  smsNotification.js
  ...
Run Code Online (Sandbox Code Playgroud)

您可以仅重新部署文件中的函数

firebase deploy --only "functions:smsNotification.sendChatNotif"
Run Code Online (Sandbox Code Playgroud)

您可以使用以下命令重新部署文件中的所有函数

firebase deploy --only "functions:smsNotification"
Run Code Online (Sandbox Code Playgroud)


小智 5

如果有人仍然无法使用 使其工作firebase deploy --only functions:func1,functions:func2,可能是因为您可能"codebase": "my-codebase"firebase.json. 我花了一段时间来诊断,但在删除该代码库属性后,使用该--only标志仅部署一些功能对我有用