Usage: wx-cli [options][command]
Options:
-v --version output the version number
-h, --help display help for command
Commands:
create 创建页面/组件
env 选择开发环境
publish 发布体验版
help [command] display help for command
自定义配置
在根目录下新建wx.config.js
module.exports = {
root: __dirname,
dir_root: process.cwd(),
entry: './',
output: './',
common: {
// 钉钉通知
DINGTALK_WARN_URL: {
title: '钉钉报警URL',
value:
'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxx',
},
atMobiles: ['188xxxxxxxx'],
},
env: {
// 会自动更新小程序版本号
relase: {
A: {
title: 'URL',
value: 'www.baidu.com',
},
},
pre: {
A: {
title: 'URL',
value: 'www.baidu.com',
},
},
pre2: {
A: {
title: 'URL',
value: 'www.baidu.com',
},
},
pre3: {
A: {
title: 'URL',
value: 'www.baidu.com',
},
},
},
};
创建包/组件
// 命令
wx-cli create
// 运行
? 选择你想生成的文件类型 (Use arrow keys)
❯ page
component
? 选择你想生成的文件类型 page
? 设置page的名字(例如:index) w
? 设置页面所属的分包 (Use arrow keys or type to search)
❯ none
修改开发环境
// 根据配置会输出配置的所有环境
wx-cli env
? 选择小程序的开发环境 (Use arrow keys)
❯ relase
pre
pre2
pre3
relase为发布环境配置,会自动更新版本号
? Select increment (next version): (Use arrow keys)
❯ patch (1.0.4)
minor (1.1.0)
major (2.0.0)
prepatch (1.0.4-0)
preminor (1.1.0-0)
premajor (2.0.0-0)
Other, please specify...
如果是其他环境则直接修改对应的配置
预览和发布体验版
wx-cli publish
? 选择要使用的功能 (Use arrow keys)
❯ preview
upload
priview是生成测试版
测试版会把二维码保存在本地
upload上传体验版
直接上传体验版并触发钉钉通知
如果使用上传还需要获取上传key在小程序管理后台中获取
private.xxxxxxx.key
与小程序提供的ci使用方式一至