george43g / better-firebase-functions

This repo provides functionality for a better way of organising files, imports and function triggers in Firebase Cloud Functions
Mozilla Public License 2.0
179 stars 15 forks source link

modifiers for local development only #5

Closed TomKaltz closed 4 years ago

TomKaltz commented 4 years ago

Similar to what was implemented here... https://gist.github.com/theprojectsomething/2076f856f9c4488366dc88e6e8ab2f20

...it would be nice to be able to specify a modifier in the filename for local-only functions. I am currently using a glob pattern to ignore files with the word "ignore" in them but preventing local-only endpoints from deploying would be great!

george43g commented 4 years ago

Isn't it possible to do this only using glob? I believe you can create ignore groups, in the same way you would ignore *.spec files. Something like **/!(*.spec|*.ignore).js

george43g commented 4 years ago

it seems as though this here emulating: process.env.hasOwnProperty('FIREBASE_PROJECT') is the crux of this feature - this detects if we are emulating.

Just as a side note - most things that people use functions for that they don't want deployed can usually just be done locally with admin sdk. For example, you can write a script in js/ts and then use node/ts-node to run it. You don't need to create a local function unless you somehow call it from your emulated front end. You can access emulated firestore or live firestore just using admin sdk or @firebase/testing.

TomKaltz commented 4 years ago

Standalone admin sdk solves my use case. Well played!