If you need to upload or preview Mini Program projects in scenarios that do not rely on the Developer Tools, such as your own business engineering pipelines, miniprogram-ci is recommended.
The Developer Tools provide two types of interfaces for external invocation: Command Line and HTTP Service. Developers can use the command line or HTTP requests to instruct the tool to perform operations such as login, preview, and upload.
Upgrade Note: Starting from
1.02.202003092, the CLI & HTTP interfaces have been upgraded to thev2version. In thev2version, legacy commands remain usable but are deprecated and will be removed in the future. Please use the v2 commands. The v2 version adds support for Cloud Development management operations, optimizes command formats, enhances detailed status prompts, supports long-running commands, and supports internationalization (choice between Chinese and English).
Invoke the installed tool executable via the command line to complete operations such as login, preview, upload, and automated testing. A return code of 0 indicates success, while -1 indicates an error.
To use the command line, ensure that the Service Port is enabled in Settings -> Security Settings of the Developer Tools.
Location of the command-line tool:
macOS: <installation path>/Contents/MacOS/cli
Windows: <installation path>/cli.bat
Command Index
You can use cli -h to view all commands, and cli --lang zh -h to access the Chinese version of the help documentation.
| Category | Description | Command |
|---|---|---|
| Help | View help | cli -h |
| Login | Login tool | cli login |
| Check login status | cli islogin | |
| Mini Program Code | Preview | cli preview |
| Upload code | cli upload | |
| Auto preview | cli auto-preview | |
| Enable automation | cli auto | |
| Enable automation | cli auto-replay | |
| Build npm | cli build-npm | |
| Clear cache | cli cache | |
| Tool Window | Launch tool | cli open |
| Open other project | cli open-other | |
| Close project window | cli close | |
| Quit tool | cli quit | |
| Rebuild file listener | cli reset-fileutils | |
| Cloud Development | Cloud development operations | cli cloud -h |
| Cloud environment operations | cli cloud env -h | |
| Cloud function operations | cli cloud functions -h | |
| View cloud environment list | cli cloud env list | |
| View cloud function list | cli cloud functions list | |
| View cloud function info | cli cloud functions info | |
| Upload cloud function | cli cloud functions deploy | |
| Incremental upload cloud function | cli cloud functions inc-deploy | |
| Download cloud function | cli cloud functions download |
You can append -h or --help to any command to view its help documentation.
Common Options
Project Options
| Command | Description |
|---|---|
| --project | Project path |
| --appid | Mini Program AppID or Third-Party Platform AppID. If --project is provided, this option will be ignored |
| --ext-appid | Developer AppID used during Third-Party Platform development. If --project is provided, this option will be ignored |
Global Options
| Action | Command | Description |
|---|---|---|
| View help | -h, --help | |
| Select language | --lang | Optional. en or zh. Default is en |
| Specify port number | --port | Optional. The HTTP service port for the tool. If the tool is not running, it will be started with the specified port number. If the tool is already running but on a different port, you must exit the tool first and then run it again. |
| Enable debug mode | --debug | Optional. Enables debug mode to output additional information to assist in troubleshooting. |
Command Documentation
Login Utilities
The command line interface offers two login methods: one converts the login QR code into base64 format for users to integrate into their own systems; the other prints the QR code directly in the command line.
--qr-format, -f: Optional. QR code format. Options: terminal, image, base64. Default: terminal.
--qr-size, -f: Optional. QR code size. Only applicable when qr-format=terminal. Options: small, default. Default: default (available from tool version 1.05.2105072 onwards).
--qr-output, -o: Optional. The QR code will be output to the specified path.
--result-output, -r: Outputs the login result to the specified file.
Example:
# Login, Print Login QR Code in Terminal
cli login
# Log In, Print the Login Base64-Format QR Code in the Terminal
`cli login -f base64`
# Log in, convert the QR code to base64 and save it to the file /Users/username/code.txt
cli login -f base64 -o /Users/username/code.txt
# Log in and output the login result to a file /Users/username/result.json
cli login -r /Users/username/result.json
Check if Logged In
Query whether the tool is currently logged in.
cli islogin
Preview
Help: cli preview -h
Options
--qr-format, -f: Optional. QR code format, options: terminal, image, base64. Default: terminal.
--qr-size, -f: Optional. QR code size, effective only when qr-format=terminal. Options: small, default. Default: default (since tool version 1.05.2105072).
--qr-output, -o: Optional. The QR code will be output to the specified path.
--info-output, -i: Optional. Related information will be output to the specified path.
--project: Project path.
Example:
# Preview: Print the Login QR Code in the Terminal
cli preview --project /Users/username/demo
# Preview, convert the QR code to base64 and save it to the file /Users/username/code.txt
cli preview --project /Users/username/demo --qr-output base64@/Users/username/code.txt --qr-format base64
# Preview, and save preview code package size and other info to /Users/username/info.json
cli preview --project /Users/username/demo --info-output /Users/username/info.json
# Preview, Specify Custom Compilation Conditions, pathName
cli preview --compile-condition '{"pathName":"pages/index/index","query":"x=1&y=2"}'
Auto Preview
Help: cli auto-preview -h
Auto preview requires a logged-in session. If not logged in, a prompt will ask you to log in first.
--info-output <path>: When specified, additional information about the current preview, such as the code package size and subpackage size details, will be output in JSON format to the specified path.
--auto-preview-type <mobile|pc>: Specifies the push platform. mobile refers to WeChat Mobile, and pc refers to WeChat Desktop. If not provided, the current IDE setting will be used (default is mobile). This parameter only affects the current invocation and will not be written back to the IDE settings. The value must be either mobile or pc; other values will be rejected locally.
--project: Project path.
Example:
# Preview and save the preview package size and other information to /Users/username/info.json
cli auto-preview --project /Users/username/demo --info-output /Users/username/info.json
# Push to WeChat Desktop (Suitable for PC Preview of Mini Games)
cli auto-preview --project /Users/username/demo --auto-preview-type pc
Upload Code
Help: cli upload -h
You must be logged in to upload code. If not logged in, you will be prompted to log in first.
The information required for uploading code includes the project root directory, version number, and an optional version description.
--version, -v: Upload code, where version specifies the version number and project_root specifies the project root path.
--desc, -d: The description or notes for the code upload.
--info-output, -i: When specified, additional information about the current upload (such as code package size and subpackage size details) is output to the specified path in JSON format.
--project: Project path
Example:
# Upload the project located at /Users/username/demo, specifying the version number as 1.0.0 and the version notes as "initial release"
cli upload --project /Users/username/demo -v 1.0.0 -d 'initial release'
# Upload and store code package size and other information into /Users/username/info.json
cli upload --project /Users/username/demo -v 1.0.0 -d 'initial release' -i /Users/username/info.json
Build npm
Trigger npm build via the command line.
--project: Project path
--compile-type <type>: Manually specify the compilation type ("miniprogram" | "plugin"), used to determine whether to use miniprogramRoot or pluginRoot. This takes precedence over the configuration in project.config.json
Example:
cli build-npm --project /Users/username/demo
Enable Automation
Enable Mini Program automation. For detailed information, see here.
--project: Open the specified project and enable the automation feature.
--auto-port <port>: Specify the automation listening port.
--auto-account <openid>: Specify the openid to use.
Example:
cli auto --project /Users/username/demo --auto-port 9420
Open Automated Testing Window
Open the automated testing window and simultaneously start replaying previously recorded test cases.
You can view the recording and replay feature by clicking here.
Minimum supported tool version: 1.05.2111232
--project: Project path
--replay-all: Replay all
# Open the Automated Test Window
cli auto-replay --project /Users/username/demo
# Open the automated testing window and replay all test cases
cli auto-replay --project /Users/username/demo --replay-all
Launching the Tool
--project: Optional. If the --project flag is omitted, the tool launches without opening a specific project. If a project path is provided, the tool opens the project at that path, automatically compiles and refreshes it on every execution, and launches the Simulator and Debugger. The project path must not be a relative path. The project directory must contain a validly formatted project.config.json file with the appid and projectname fields.
--pure-simulator: Optional. If the --pure-simulator flag is not used, the tool defaults to project editing window mode. If the --pure-simulator flag is used, the tool operates in pure simulator mode. This mode supports Mini Games and Mini Program.
Example:
# Open Tool
cli open
# Open the project at the /Users/username/demo path
cli open --project /Users/username/demo
Opening Other Projects
You can use the CLI command line to open files or folders in the tool as "Other" projects. (Pure editor mode)
--project: Required. Specifies the path of the file or folder to open. Both absolute and relative paths are supported.
Example:
# Open the specified project in the "Other" project window
cli open-other --project /Users/username/demo
Close Project Window
Close the project window
--project: Optional. If the specified project_root project is open, it will be automatically closed.
Example:
# Close a Specified Project
cli close --project /Users/username/demo
Note: When closing a project, a dialog box will appear asking whether to block the operation; if not blocked, the project will be closed after 3 seconds
Close Tool
Close Developer Tool
# Quit Developer Tools
cli quit
Note: When quitting Developer Tools, a dialog will prompt you to confirm whether to block the exit. If not blocked, it will close in 3 seconds.
Rebuild File Watcher
Resets the internal file cache of the tool and resumes monitoring project files.
--project: Project path
# You must ensure that the project window is opened first
cli open --project /Users/username/demo
# Invoke reset-fileutils to rebuild file watching for the enabled project
cli reset-fileutils --project /Users/username/demo
Clear Tool Cache
Help: cli cache -h
--clean, -c: Cache type storage(Data)/file(File)/seeion(Login)/auth(Authorization)/network(Network)/compile(Compile)/all(All)
Example:
# clean all
cli cache --clean all --project /Users/xxx/miniprogram-10
# Clean storage
cli cache --clean storage --project /Users/xxx/miniprogram-10
Cloud Development Operations
Cloud development command help: cli cloud -h
Cloud development cloud environment command help: cli cloud env -h
Cloud development cloud function command help: cli cloud functions -h
In Cloud Development commands, unless otherwise specified, operations can be performed by specifying either the --project option or the --appid (add --ext-appid if it is a third-party platform), choosing one of the two.
View Cloud Environment List
Help: cli cloud env list -h
Example:
# View via --project
cli cloud env list --project /Users/username/demo
# View by --appid
cli cloud env list --appid wx1111111111111
View the List of Cloud Functions
Help: cli cloud functions list -h
--env, -e: Cloud environment ID
Example:
# View Online Cloud Functions in Environment test-123 Using --project
cli cloud functions list --env test-123 --project /Users/username/demo
# View online cloud functions in environment test-123 via --appid
cli cloud functions list --env test-123 --appid wx11111111111111
View Cloud Function Information
Help: cli cloud functions info -h
--env, -e: Cloud environment ID
--names, -n: Cloud function names. Separate multiple names with spaces. Example: cli cloud functions info --names func_a func_b
Example:
# View cloud function information for aaa and bbb in environment test-123 using --project
cli cloud functions info --env test-123 --names aaa bbb --project /Users/username/demo
# View Information for Cloud Functions aaa and bbb in Environment test-123 via --appid
cli cloud functions info --env test-123 --names aaa bbb --appid wx1111111111111
Upload Cloud Functions
Help: cli cloud functions deploy -h
--env, -e: Cloud environment ID
--names, -n: Names of the cloud functions. Separate multiple names with spaces. The system will look for folders with the same names in the "cloudfunctionRoot" directory specified in project.config.json. If used, the --project option must be provided
--paths, -p: Directory paths of the cloud functions to be deployed. Separate multiple paths with spaces. The folder name is considered as the function name. Using this option means the cloud function directory structure does not need to follow the "cloudfunctionRoot" method in project.config.json
--remote-npm-install, -r: Install dependencies on the cloud side. After specifying this option, node_modules will not be uploaded
Example:
# Upload two Cloud Functions named func_a and func_b in the Cloud Function root directory to the Cloud Environment ENVID, with server-side dependency installation enabled
cli cloud functions deploy --env ENVID -r --names func_a func_b --project /aaa/bbb/ccc
# Upload by specifying absolute path directories, enable cloud-side dependency installation
cli cloud functions deploy --env ENVID -r --paths /a/b/func_a /x/y/func_b --appid APPID
Incremental Upload of Cloud Functions
Help: cli cloud functions inc-deploy -h
--env, -e: Cloud environment ID
--name, -n: Name of the Cloud Function to be updated. When using this option, do not use the path option. It will look for a folder with the same name under the "cloudfunctionRoot" directory specified in project.config.json. If used, the --project option must be provided
--path, -p: Directory of the Cloud Function. When using this option, do not use the name option. The name of the function directory is considered the function name. When using this option, the Cloud Function directory structure does not need to follow the "cloudfunctionRoot" requirement in project.config.json
--file, -f: Relative file/directory path for incremental update. The path must be relative to the Cloud Function directory
Example:
# Incremental Upload, Specify Cloud Function Name
cli cloud functions inc-deploy --env ENVID --name func_a --file index.js --project /aaa/bbb/ccc
# Incremental Upload, Specifying Cloud Function Path
cli cloud functions inc-deploy --env ENVID --path /aaa/func_a --file index.js --appid APPID
Download Cloud Functions
Help: cli cloud functions download -h
--env, -e: Cloud Environment ID
--name, -n: Cloud Function Name
--path, -p: Destination path for the download
Example:
# Download cloud function func_a to the /xxx/yyy directory
cli cloud functions download --env ENVID --name func_a --path /xxx/yyy --appid APPID