CLI Reference

InstallationAnchorIcon

Before installing the braintree-functions-cli, make sure you have Node.js installed on your machine. To install the CLI globally, run:
  1. 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:
  1. bash
$ npx btfns <command>

UninstallAnchorIcon

If installed globally:
  1. bash
$ npm uninstall -g @braintree/functions-cli

OptionsAnchorIcon

OptionDescription
-v, --versionshow installed version

CLI CommandsAnchorIcon

CommandDescription
`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

deployAnchorIcon

Deploy your function.
  1. bash
$ btfns deploy

deployOptionsAnchorIcon

OptionDescription
-h, --helpshow command help
--productiondeploys function to production environment

helpAnchorIcon

Displays commands and version of your installation of btfns.

initAnchorIcon

Create a new function.
  1. bash
$ btfns init MyFunction --template=dataExport --events=transaction.settled

initOptionsAnchorIcon

OptionDescription
-t, --template=templateType creates configuration and javascript files for type. valid types: `dataExport`, `dataImport`, `paymentMethod`
-h, --helpshow command help
-T, --triggers=triggertriggers associated to the function, use `btfn ls --triggers` to see all
-e, --events=eventevents associated to a `dataExport` function, use `btfns ls --events` to see all

loginAnchorIcon

Login to a Braintree account.
  1. bash
$ btfns login -e sandbox -m merchantId

loginOptionsAnchorIcon

OptionDescription
-e, --environmentset environment
-h, --helpshow command help
-m, --merchantset merchant ID
-u, --userset username

logoutAnchorIcon

Logout of your Braintree account.
  1. bash
$ btfns logout

lsAnchorIcon

List functions, events, or triggers.
  1. bash
$ btfns ls --functions -e sandbox

lsOptionsAnchorIcon

OptionDescription
-h, --helpshow command help
-e, --environmentset environment
--functionslist functions deployed to your account
--triggerslist triggers available to be used by a function
--eventslist events available to be used by a function

packageAnchorIcon

Package and publish your function to share with others.
  1. bash
$ btfns package .

packageOptionsAnchorIcon

OptionDescription
-h, --helpshow command help

publishAnchorIcon

Package and publish your function to share with others.
  1. bash
$ btfns publish . -v 1.0.0

publishOptionsAnchorIcon

OptionDescription
-h, --helpshow command help
-v, --versionsets version of function

testAnchorIcon

Simulate function invocation to test your code before deployment. Depending on your template type the appropriate payload will be sent to your function.
  1. bash
$ btfns test -p tests/sample.json

testOptionsAnchorIcon

OptionDescription
-h, --helpSee available options for the `test` command
-p, --test-payloadPath to a test `json` file with a pre-build payload

generate-test-dataAnchorIcon

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.
  1. bash
$ btfns generate-test-data -o test/sample.json

generate-test-dataOptionsAnchorIcon

OptionDescription
-h, --helpSee available options for the `test` command
-o, --output The name and path of the generated file (defaults to `tests/.json`)