Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pull lost code from Firebase Hosting deployment

I need to pull down my code from a firebase hosted site, I created a site this past summer and no longer have the code locally on my laptop. I would like to recode some of the pieces, but don't have the source code anymore (other than the javascript and css I can glean from the served pages). I can't find a way to get the code from the firebase site, does anyone have any ideas?

like image 537
Randal Wilcox Avatar asked Oct 09 '14 19:10

Randal Wilcox


People also ask

How do I roll back Firebase deployment?

Here's how to roll back: In the Firebase console, in the Release History table for your site, hover over the previous release entry that you want to roll back to. Click more_vert, then select Roll back.

Where is my Firebase JSON file?

Firebase automatically creates your firebase. json file at the root of your project directory when you run the firebase init command.


1 Answers

You should of course add your own version control (e.g. git) to manage your revisions and backups so this doesn't occur.

There is a script you can run to download all the assets using the CLI. You can find the script and instructions here. It can also be run using npx:

npx https://gist.github.com/mbleigh/9c8680cf319ace2f506f57380da66e7d <site_name> 

Note that this only returns the compiled/rendered content from the specified public folder and not any precompiled source you may have had on the development machine.

Since your files are static assets, you could also scrape them using wget. This is inferior for advanced apps as you'll get the rendered content and not the source:

wget -r -np https://<YOURAPPNAME>.firebaseapp.com 

Read more on scraping web sites here: https://apple.stackexchange.com/questions/100570/getting-files-all-at-once-from-a-web-page-using-curl

like image 172
Kato Avatar answered Sep 18 '22 00:09

Kato