New netlify functions:invoke command in CLI

I just realized i added https://github.com/netlify/netlify-dev-plugin/pull/213 but didnt do much publicity

Locally Testing Functions with netlify functions:invoke

netlify functions:invoke allows you to locally test functions going above and beyond a simple GET request in browser. (we only model POSTs now but could easily expand from here).

If you have Netlify Dev running your functions, you can then test sending payloads of data, or authentication payloads:


# with prompting
netlify functions:invoke # we will prompt you at each step
netlify functions:invoke myfunction # invoke a specific function
netlify functions:invoke --name myfunction # invoke a specific function

# no prompting (good for CI)
netlify functions:invoke --name myfunction --identity # invoke a specific function with netlify identity headers
netlify functions:invoke --name myfunction --no-identity # invoke a specific function without netlify identity headers

# sending payloads
netlify functions:invoke myfunction --payload '{"foo": 1}'
netlify functions:invoke myfunction --querystring "foo=1"
netlify functions:invoke myfunction --payload "./pathTo.json"

There are special cases for event triggered functions (eg identity-signup) which will also give you mock data for testing. This makes manual local testing of event triggered functions possible, which drastically improves the development experience.

This is a new feature; ideas and feedback and issues and PR’s welcome! docs here: https://github.com/netlify/netlify-dev-plugin/blob/master/README.md#locally-testing-functions-with-netlify-functionsinvoke