跳到主要内容

CLI

This document is a comprehensive guide on how to utilize the bmp Command Line Interface (CLI).

CLI Download

Let's start by installing the CLI.

# optional
# Set the Binance npm registry (if not set already)
# npm config set @binance:registry https://npm.binance.com

# Install the CLI globally
$ npm install -g @binance/mp-cli

CLI Usage

Breeze through the following commands to get used to the bmp CLI:

Creating a New Project

$ bmp init [project-name]

Running the above command will conjure an initialized mini-program project brimming with potential!

For instance:

$ bmp init magnificent-mini-program

Adding Support to an Existing React Project

# Navigate to the project root directory
$ cd [path-to-desirable-project-root]

# Run bmp bootstrap
$ bmp bootstrap

The above commands spin off a .bmp directory and add essential configurations to the existing tsconfig.json file. This ensures support for importing @binance/*, thereby enabling TypeScript syntax support.

Kicking Off with devServer

# Navigate to the project root directory
$ cd [path-to-project-root]

# Run bmp dev
$ npx bmp dev

Introducing the command that compiles your project and spins up devServer, listening on locahost:3000 by default. As you hop into the project and select the dist project, you will be greeted by your running mini-program. With liveReload enabled on devServer, any changes to your code will trigger an automatic rebuild and refreshes the page.

Build and Compile

# Navigate to the project root directory
$ cd [path-to-project-root]

# Run bmp build
$ npx bmp build

Compiling the project code has never been easier! The above command renders mini-program files in the project directory. With Binance Devtools, developers can smoothly upload these files to the management portal for release or swift online testing.