functions (Preview)
CLI Reference
Installation
Before installing the braintree-functions-cli
, make sure you have Node.js installed on your machine.
To install the CLI globally, run:
- bash
$ npm i -g @braintree/functions-cli
This will make the btfns
namespace available to you from the command line. If you would prefer to not install this package globally, use the npx
command:
- bash
$ npx btfns <command>
Uninstall
If installed globally:
- bash
$ npm uninstall -g @braintree/functions-cli
Options
Option | Description |
---|---|
-v, --version | show installed version |
CLI Commands
Command | Description |
---|---|
deploy | Deploy your function |
help | Display help for btfns |
init | Create a new function |
login | Login to your Braintree account for deployment and testing |
logout | Log out of your Braintree account |
ls | List functions, events, or triggers |
package | Package your function in order to publish to Braintree's function ecosystem |
publish | Publish your function to share with others |
test | Simulate function invocation to test your code before deployment |
generate-test-data | Generate JSON files to mock expected payloads for testing |
deploy
Deploy your function.
- bash
$ btfns deploy
deploy
Options
Option | Description |
---|---|
-h, --help | show command help |
--production | deploys function to production environment |
help
Displays commands and version of your installation of btfns
.
init
Create a new function.
- bash
$ btfns init MyFunction --template=dataExport --events=transaction.settled
init
Options
Option | Description |
---|---|
-t, --template=templateType | creates configuration and javascript files for type. valid types: dataExport , dataImport , paymentMethod |
-h, --help | show command help |
-T, --triggers=trigger | triggers associated to the function, use btfn ls --triggers to see all |
-e, --events=event | events associated to a dataExport function, use btfns ls --events to see all |
login
Login to a Braintree account.
- bash
$ btfns login -e sandbox -m merchantId
login
Options
Option | Description |
---|---|
-e, --environment | set environment |
-h, --help | show command help |
-m, --merchant | set merchant ID |
-u, --user | set username |
logout
Logout of your Braintree account.
- bash
$ btfns logout
ls
List functions, events, or triggers.
- bash
$ btfns ls --functions -e sandbox
ls
Options
Option | Description |
---|---|
-h, --help | show command help |
-e, --environment | set environment |
--functions | list functions deployed to your account |
--triggers | list triggers available to be used by a function |
--events | list events available to be used by a function |
package
Package and publish your function to share with others.
- bash
$ btfns package .
package
Options
Option | Description |
---|---|
-h, --help | show command help |
publish
Package and publish your function to share with others.
- bash
$ btfns publish . -v 1.0.0
publish
Options
Option | Description |
---|---|
-h, --help | show command help |
-v, --version | sets version of function |
test
Simulate function invocation to test your code before deployment. Depending on your template type the appropriate payload will be sent to your function.
- bash
$ btfns test -p tests/sample.json
test
Options
Option | Description |
---|---|
-h, --help | See available options for the test command |
-p, --test-payload | Path to a test json file with a pre-build payload |
generate-test-data
Generate JSON files to mock expected payloads for testing. Running this command will write a JSON file to the __tests__
directory generated by your project.
- bash
$ btfns generate-test-data -o test/sample.json
generate-test-data
Options
Option | Description |
---|---|
-h, --help | See available options for the test command |
-o, --output | The name and path of the generated file (defaults to __tests__/<filename>.json ) |