简体   繁体   中英

Get code from firebase console which I deployed earlier

I had created firebase functions in nodejs and deployed the code on firebase. The function was to send an email when the new user is created. I have lost the code now. Can we pull that code from firebase?

Note : the process below may work or not for your case. Don't rely on it as a replacement for keeping your code in a proper version control system.

You can retrieve the code for your Cloud Functions from the Cloud Console.

  1. Go to this URL
  2. Select the project that the function is in
  3. Select a function from the list
  4. You will get to this page : Google Cloud Functions 的 Source 选项卡

  5. Select the Source at the top

  6. Click the "Source location" link

A zip file with the latest source of your function will start to download.

Note that these files may periodically get deleted. In that case, the above process will not work to recover your source code.

When you click to select your project, make sure you have the right organization selected.

选择组织

In the firebase console in the left hand menu select Functions. Hover over the function you want to view and click the three vertical dots. Select Detailed Usage Stats. This will bring you to the Google Cloud console. Select 'Source' to get the source code.

The google cloud console link didn't work for me (might have been outdated)

Updated

  1. Go to https://console.cloud.google.com/
  2. Select your project [ 1 ]
  3. Go to https://console.cloud.google.com/functions/list
  4. Under Actions (with the 3 dots), click Test Function [ 2 ]
  5. Go to Source, and you will be able to see your entire deployed project functions [ 3 ]

After downloading the source using the method of the selected answer, you need to perform the following tasks to be able to create/edit functions.

  1. Create a new folder. eg, myFunctions.
  2. cd into myFunctions.
  3. run firebase init.
  4. Follow the onscreen instructions. Be sure to select "Cloud Functions" in the list of firebase features to initialise. Also be sure to choose existing project & choose your project.
  5. After npm finishes, a functions folder will be created in myFunctions.
  6. Delete the functions folder.
  7. Copy the functions folder that you downloaded initially.

That should be the trick!

It looks like that the answers given above are outdated and do not work anymore. This is the latest and most robust thalaiva way of accomplishing the task assigned to you in this tight deadline.

  1. Goto https://console.cloud.google.com/storage/
  2. Choose the bucket staging.<project-name>.appspot.com
  3. Click on firebase-functions-source file.

The zipped folder of your firebase functions will get downloaded

Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM