
Show HN: REPL for Your Firebase Cloud Functions - mlejva
https://github.com/FoundryApp/foundry-cli
======
mlejva
Hello HN, OP here.

My friend and I have built Foundry for ourselves to have a better way of
developing Firebase Cloud Functions.

It's a command-line tool that works like an interactive read-eval-print-loop
for your cloud functions. Everything happens in real-time. It connects you to
a pre-configured cloud environment and with every code change you make, it
triggers your functions and sends you back the output.

It may sound similar to testing your functions locally with existing tools but
there are a few key differences:

\- There isn't any configuration. Just run `$ foundry init` and then `$
foundry go` and you're ready. A lot of people complained to us that they
didn't know how to set up a local environment to their Firebase Cloud
Functions or they didn't want to spend time on it. We made it as much
straightforward as possible.

\- With Foundry, your functions will run in an environment that is almost
identical to the environment where your functions are deployed (we tried
really hard to have it behave like in production). So you don't have
unexpected production bugs. You don't have to create a separate Firebase
project as your staging environment. Foundry is your staging environment.

\- We use the Firestore emulator and we also emulate Firebase Auth users
ourselves. You can use the Admin SDK as you would normally and have access to
your data. You can easily access your production data. In the config file, you
specify what data you want to copy from your production Firestore and
production users. We copy the data and fill the emulated Firestore and
Firebase Auth. No need to maintain any custom scripts. You just write your
code as you would normally. For example, you can write the following in the
config file:

    
    
        users:
          # Copy first 5 users from your Firebase project
          - getFromProd: 5 
          # Copy users with the specified IDs from your Firebase project
          - getFromProd: ['id-1', 'id-2'] 
        # Copy first 3 documents from production from the collection 'userWorkspaces'
        # also add a custom document with id 'new-user-workspace' with a new data
        # format that you want to use
        firestore:
         - collection: userWorkspaces
           docs:
             - getFromProd: 3
             - id: new-user-workspace
               data: {"newDataFormat": 42}
    
    

We copy the data for you. You access this data as you would normally in your
Firebase functions code - with the Admin SDK

\- You don't have to manually trigger your functions to run them, we trigger
them for you every time you make a change in your code. You just specify how
you want to trigger in the config file. For example:

    
    
      functions:
         - name: onUserSignUp
           type: auth
           trigger: onCreate
           createUser:
             - id: new-user-id-1
               data: {"displayName": "John"}
    
    

On each code change, this will trigger the userSignUp function in your code
with a user object with id new-user-id-1 with the user's data {"displayName":
"John"} This way, the development is very interactive because you always have
a response and always know whether your code will run on production and with
your production data. It all happens in real-time, it's like a read-eval-
print-loop for your functions.

\- It's fast. It usually takes 1-2 seconds to get the results back. That's
with the deployment time.

The reason we are building this is that we have always struggled to easily
develop & test our functions/backend. We talked to a lot of Firebase
developers and they shared our problems. People are either deploying their
functions into production just to test their code and have access to their
production data or they spend a lot of time configuring their local
environment and creating separated Firebase projects with dummy data.

It's really annoying to deploy your functions on Firebase, every time you want
to check if your code is working. Just the deployment itself takes 2-5
minutes, not to speak about the needed context switches from your code editor.
If you are doing this multiple times per day, you are losing a serious
development time.

Currently, we are in beta. It's completely free and you can use it without any
registration (an anonymous user will be created for you that you can later
link to your real account). We don't store any of your data or code for a time
longer than is your session. The only exception is the environment variables
you can set.

Feel free to ask any questions and let me know if you are using Firebase Cloud
Functions and would like to try it out. I'm more than happy to help you set it
up in your project!

GitHub repo - [https://github.com/FoundryApp/foundry-
cli](https://github.com/FoundryApp/foundry-cli)

Docs - [https://docs.foundryapp.co/](https://docs.foundryapp.co/)

Website - [https://www.foundryapp.co/](https://www.foundryapp.co/)

~~~
kulesh
> brew info foundry Error: No available formula with the name "foundry"

:(

~~~
mlejva
Hey!

I'm having problems reproducing this error on my side. Have you tapped before
installing CLI? Please try this:

    
    
        $ brew tap foundryapp/foundry-cli
        $ brew install foundry
    

Otherwise, please try installing Foundry through the install script

    
    
        $ curl https://get.foundryapp.co -sSfL | sh
    

Let me know if it works!

