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

Javascript - firebase deploy just exits #17

Closed simeon9696 closed 2 years ago

simeon9696 commented 3 years ago

Hey! This is a really sweet package and I would like to use it in my JS project. I couldn't find much reference to JS in the docs and I'm a bit of a beginner so I apologise if this question is straightforward.

I set up the folder structure as mentioned: image

And inside of index.js all I have is, taken from this issue, :

const admin = require('firebase-admin');
admin.initializeApp();
require('better-firebase-functions').exportFunctions({__filename, exports: module.exports});

All my functions are structured like below:

"use strict";
const functions = require("firebase-functions");
const admin = require("firebase-admin");

module.exports.default = functions.firestore
  .document("items/{item}")
  .onCreate(async (doc, context) => {
    const db = admin.firestore();
    return db.doc("GLOBAL_DATA/GENERAL_DATA").update({
      itemCodes: admin.firestore.FieldValue.arrayUnion(doc.id),
      batchNumbers: admin.firestore.FieldValue.arrayUnion(
        doc.data().generalData.batchNumber
      )
    });
  });

But if I run firebase deploy it starts up and then exits:

firebase deploy --only functions

PS C:\Users\simeon.ramjit\Documents\projects\plant-order-form\functions> firebase deploy --only functions:scheduled
=== Deploying to 'plant-order-form'...

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint

> functions@ lint C:\Users\simeon.ramjit\Documents\projects\plant-order-form\functions
> eslint .

+  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
+  functions: required API cloudbuild.googleapis.com is enabled
+  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
PS C:\Users\simeon.ramjit\Documents\projects\plant-order-form\functions> 

I'm running Node v10 and I tried putting the api folder into a folder named src flag I'd appreciate any assistance on this.

LeadDreamer commented 3 years ago

I found a problem with deep function trees - the name generator wasn't formatting quite properly - only the FIRST "/" in the path was converted to "-" (the camelCase was working properly, node 8 or 10). I've created a pull request to fix this; waiting for it to be expected; currently using a local copy to get around this. If I don't see action in a week or so I guess I'll have to release my own package.

polymer-coder commented 3 years ago

@LeadDreamer thanks for your work! Let's hope it gets added soon.

polymer-coder commented 3 years ago

@LeadDreamer @george43g Hi! any update on this?

george43g commented 2 years ago

Hey guys, just cleaning up old issues - newer versions of this package have fixed the deeply nested issue.