Installing the Mambu CLI
  • 05 Jan 2024
  • 4 Minutes To Read
  • Dark
    Light
  • PDF

Installing the Mambu CLI

  • Dark
    Light
  • PDF

Article Summary

Mambu Functions allow you to extend the functionality of Mambu through custom code.

Prerequisites

To create and use Mambu Functions you should have the following skills and tools:

  • Basic knowledge of bash or any other scripting language.
  • An understanding of TypeScript or JavaScript.
  • A code or text editor to edit your Mambu Functions.
  • Access to your Mambu UI environment in order to bind functions to products.
  • You need to have Node (Use LTS Version and NOT current/latest) installed. Use node v18 or higher.
  • A Mambu API key. See API Consumers for more information on creating keys. We strongly recommend that you create separate API keys for each user. API keys used by the Mambu CLI are not encrypted at rest in the credentials file. Please ensure that your local disk is encrypted and that your workspace is secure.

Set up your environment

Point to the registry that Mambu Functions will use with the following commands in your terminal.

Linux and macOS

npm config set @mambucom:registry https://gitlab.com/api/v4/projects/43738078/packages/npm/

Windows Powershell

Please note the extra backtick before @mambucom:registry… ; without this the command will return an error in Windows Powershell.

npm config set `@mambucom:registry https://gitlab.com/api/v4/projects/43738078/packages/npm/

Download the Mambu command-line interface (CLI) to start working with Mambu Functions by running:

npm i -g @mambucom/cli-core

This command installs the latest version of the Mambu CLI.

The Mambu CLI comes with the Functions plugin installed by default. Once the Mambu CLI is installed, you can run the command mambu --help to bring up the help documentation. For help documentation specific to Mambu Functions, run the command mambu functions --help. You can also call up the help documentation for individual actions - for example mambu functions create --help.

CommandDescriptionNotes
mambu functions createCreate a Mambu Function in a Mambu tenant.For more information, see Deploy your Mambu Function.
mambu functions updateUpdate a Mambu Function in a Mambu tenant.For more information, see Deploy your Mambu Function.
mambu functions deleteDelete a Mambu Function that has been deployed to a Mambu tenant.For more information, see Deleting a Mambu Function.
mambu functions generateGenerate the standard Node project scaffolding for a new Mambu Function. This command requires a location and the name of the Mambu Function that you want to create.For more information, see Create the project scaffolding.
mambu functions listList all the Mambu Functions in a Mambu tenant. This command uses the Mambu tenant URL saved in configuration settings or a URL that pass to it as a parameter.For more information, see Listing deployed Mambu Functions.

Set your credentials

The Mambu CLI uses your Mambu API key and the Mambu environment URL as parameters for a number of commands. To save time, you can add these credentials to a configuration file by running:

mambu configure --profile=PROFILE_NAME --apiKey=API_KEY --url=MAMBU_TENANT.mambu.com

These details are stored in the ~/.mambu-cli/credentials file in plain text. Make sure that your local environment is secure by encrypting your disk.

[default]
apiKey = a1b2c3d4e5f6g7
instanceUrl = MAMBU_TENANT.mambu.com

You can re-run the mambu configure command at any point to edit these credentials or you can add a different Mambu environment URL or API key to individual commands to override the saved credentials.

If you want to use multiple sets of credentials - for example, if you want to have credentials saved for your sandbox and your production tenant - you can create multiple credentials profiles. In this way you can switch between profiles as you are working on your Functions. For more information, see Creating multiple credentials profiles.

Updating the Mambu CLI

To update the Mambu CLI run the command: npm update -g @mambucom/cli-core . The release notes for Mambu CLI can be found on our Release Notes page.

Uninstalling the Mambu CLI

To uninstall the Mambu CLI run the command: npm uninstall -g @mambucom/cli-core. You can also delete the ~/.mambu-cli directory, which contains your credentials file, to completely remove all traces of the CLI.

Troubleshooting

I’m getting EACCESS permission errors
These errors may occur when installing node packages globally. For more information, see Resolving EACCESS permissions errors when installing packages globally.

I’m getting npm ERR! While resolving: demo-fun-1@0.0.1 errors
If you get an error similar to npm ERR! While resolving: demo-fun-1@0.0.1, run npm cache clean --force and start the installation process again.

I’m getting npm ERR! 404 Not Found - GET https://registry.npmjs.org/@mambucom%2fmambu-functions - Not found
Check that you have set up the environment registry correctly. Your setup should be pointed to the Mambu registry. See the Set up your environment section for instructions.

I’m getting an npm is not a valid option error in Windows Powershell
Make sure that you escape @ with a tick: `@ .

I can’t run scripts in Windows Powershell and I get the error running scripts is disabled on this system
You need to do the following:

  • Run Powershell as an Administrator.
  • Run the following command to allow signed scripts to run: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Was this article helpful?