I. Introduction
Lark DevTools is a command line tool used to develop gadgets for Lark. This tool allows you to create projects, carry out local debugging, upload projects, preview gadgets, troubleshoot problems, and provide feedback.
You can also log in and out of the tool. You can use opdev commands in the terminal as soon as the tool is globally installed. Use opdev new
to quickly create a new project or opdev preview
to preview a gadget in development. You can also use opdev devtools
to launch a simulator to debug your gadget. We will explain all of the features in depth in this guide.
II. Installation
1. Prerequisites
1.1 Install Node.js 10.16.0 or above. The node package manager npm will also be automatically installed alongside Node.js. Ruby:
# Node.js check version
$ node -v
# 10.16.0 or above
You can use nvm on the same computer to manage multiple versions of Node. 1.2 Make sure that the npm version number is no lower than 6.9.0.
Ruby:
# npm check version
$ npm -v
# 6.9.0 or above
2. Global installation
Once you've installed Node.js, open the command line and execute the command below to install Lark DevTools. This will install the opdev command globally on your computer.
Plain Text:
npm install -g --registry https://registry.npm.taobao.org
The installation package download address is <tarball url>. The download address for each version can be found in the CHANGE LOG. For example:
SQL:
npm install https://sf1-scmcdn-tos.pstatp.com/goofy/lark/opdev/cli/bdeefe-opdev-cli-1.5.3.tgz -g --registry https://registry.npm.taobao.org
Next, execute the following command to check if the opdev command has been installed correctly.
SQL:
$ opdev help
opdev: Lark Open Platform Developer Toolset
USAGE
$ opdev [COMMAND]
COMMANDS
Create a new project with templates
new Create a new project
template Show available templates
Account related
login Login with Lark account
logout Log out of the Lark account
whoami Show account information
Open simulator for debugging
devtools Open devtools
audit Open the audit panel of devtools
Preview or upload
preview Preview application on Lark client
upload Upload project to Lark Open Platform
Tools
diagnose Diagnose the dependences on running opdev
list Show recently opened projects, display project path
clear Clear run cache and application compilation cache
Help
help Display help information
feedback Give us feedback
OPTIONS
-a, --all print all available commands
-h, --help print CLI help information
-v, --version print CLI version
You can also use opdev version to check if the version you've installed is the one you wanted.
Ruby:
$ opdev --version
1.0.0
If you encounter any of the following problems during the installation process, see the FAQ for help. III. Features
Help information
You can use help
for all commands to see relevant help information.
Ruby:
# View help information
$ opdev help
# View help information for a particular command, for example, the upload command
$ opdev upload --help
new
The CLI can use a preset template to create a new project. Before creating a project, use opdev template
to view the preset template names.
Ruby:
# View the preset template list
$ opdev template
# Use a preset template to create a project
$ opdev new [project-path] -t template name
login
Login is required to upload gadgets, preview gadgets, use tt.login API, and log in on the simulator.
Ruby:
# log on
$ opdev login
logout
If you need to switch accounts or tenants, you will need to log out first.
Ruby:
# log out
$ opdev logout
devtools (debugger)
Launch the debugger
Ruby:
$ opdev devtools [project-path]
Launch the simulator only (this launches more quickly and is better for quickly viewing code)
Support version 0.7.0 and above. Please use the opdev simulator [project-path] command for versions earlier than 0.7.0.
Ruby:
$ opdev devtools [project-path] -s
For more information on the debugger, see the Debug guide preview
Preview gadgets: The terminal will display a QR code for mobile gadgets. For PC gadgets, a preview link will be sent to the Lark PC client.
Before previewing the gadget, make sure:
- 1.You are logged in to the command line tool
- 2.The correct appId has been entered in the project.config.json file. To learn how to get the appId, see Find the app ID.
Ruby:
$ opdev preview [project-path] -p mobile
Preview web apps (the debugging feature is currently only compatible with the Lark PC client): A QR code will be displayed in the terminal for mobile apps, and PC apps will be opened in Workplace.
To preview a web gadget, make sure the Lark PC client is no lower than 3.31
Ruby:
$ opdev preview [URL] -t h5 -p pc
Real-time preview
Monitor file changes and directly preview updated mobile gadgets (not support PC gadgets).
Ruby:
$ opdev preview [project-path] -p mobile -w
upload
Before uploading, make sure:
- 1.You are logged in to the command line tool
- 2.The correct appId has been entered in the project.config.json file
Upload a gadget to Lark Developer
Ruby:
$ opdev upload [project-path] -p pc -v version number -d description
# You must enter a valid version number, e.g.1.0.0and it must be greater than the previous version number
Upload the main navigation gadget for the mobile version to Lark Developer
Ruby:
$ opdev upload [project-path] -t gadget-nav -p mobile -v version number -d description
feedback
Open Lark DevTools Service Desk to ask a question or send feedback.