simondotm / nx-firebase

Firebase plugin for Nx Monorepos
https://www.npmjs.com/package/@simondotm/nx-firebase
MIT License
175 stars 31 forks source link

support for deploy --only functions:<functionName> #106

Closed Lowell20 closed 1 year ago

Lowell20 commented 1 year ago

Have a few functions in one app, and am trying to deploy just one at a time. Is this supported?

simondotm commented 1 year ago

You should be able to use: nx deploy <appname> --only functions:<functionname>

Lowell20 commented 1 year ago

am having trouble with it and trying to sort it out, maybe related to libs or something Have setup and deployed hello-world function, now moving functions into that app to see when it breaks. The error when nx deploy <appname> is something about "Failed to load function definition from source: Failed to generate manifest from function source"

Lowell20 commented 1 year ago

the error when nx deploy <appname> --only functions:<functionname> is "No function matches given --only filters. Aborting deployment."

Lowell20 commented 1 year ago

The setup is a vanilla nx15 workspace with an angular app and a functions app. The functions app is generated with nx g @simondotm/nx-firebase:app functions --project=<projectname> command. index.ts is modified to have a second HelloWorld function export

export const HelloWorld1 = functions.https.onRequest((request, response) => {
  functions.logger.info('Hello logs!', { structuredData: true });
  response.send('Hello from Firebase!');
});

export const HelloWorld2 = functions.https.onRequest((request, response) => {
  functions.logger.info('Hello logs!', { structuredData: true });
  response.send('Hello from Firebase!');
});

Running nx deploy functions --only functions successfully deploys both functions to <projectname> in firebase. However, running nx deploy functions --only functions:HelloWorld2 fails with the following error. Error: No function matches given --only filters. Aborting deployment.

screenshot:

image
simondotm commented 1 year ago

The nx-firebase plugin 'deploy' command is just a wrapper around the firebase CLI. Try running npx firebase deploy --config firebase.functions.json --project e2e-nx-1 --only functions:HelloWorld2 directly and see if you get more information as to why the deploy is failing.

Lowell20 commented 1 year ago

Thanks for getting back to me. Same error, and --debug does not provide any more info. I've pushed this to a public repo, lmk if you want to look at it yourself. Or I could try troubleshooting myself, with a little bit of direction.

simondotm commented 1 year ago

I suspect I know what it is, the plugin now sets a codebase in the firebase.functions.json You maybe have to deploy single functions like this, try: npx firebase deploy --config firebase.functions.json --project e2e-nx-1 --only functions:functions:HelloWorld2 See - https://firebase.google.com/docs/functions/beta/organize-functions#managing_multiple_source_packages_monorepo

Lowell20 commented 1 year ago

that's awesome, thanks This should get added to the docs somewhere. So far I love the way this handles the projects and functions, I really look forward to using it more.