elong-build 使用说明
这篇文章介绍 elong-build 1.0 版本基础功能
安装
npm install elong-build -g
目录
高级语法
执行 tc-build build --src 源码路径 --dist 目标路径
源码编译后将支持高级语法 修饰器、async await 、对象解构... 新 API Proxy、Reflect...
babel 配置如下
const defaultConfig = "presets": "env" "targets": "browsers": "last 2 versions" "plugins": "transform-object-rest-spread" "transform-decorators-legacy" ;
ESLint
代码规范检查,支持 git 钩子关联
moduleexports = extends: 'airbnb-base' parserOptions: 'ecmaVersion': 7 'sourceType': 'module' globals: 'App': true 'Page': true 'getApp': true 'getCurrentPages': true rules: 'no-extend-native': 'off' 'eol-last': 'off' 'spaced-comment': 'off' 'no-use-before-define': 'off' 'prefer-template': 'off' 'no-bitwise': 'off' 'no-unused-expressions': 'off' 'consistent-return': 'off' 'arrow-parens': 'off' 'prefer-spread': 'off' 'brace-style': 'off' 'dot-notation': 'off' 'no-underscore-dangle': 'off' 'no-restricted-syntax': 'off' 'guard-for-in': 'off' 'no-trailing-spaces': 'off' 'no-useless-return': 'off' 'no-else-return': 'off' 'prefer-const': 'off' 'comma-dangle': 'error' 'never' 'func-names': 'off' 'max-len': 'error' 200 'no-plusplus': 'off' 'no-param-reassign': 'off' 'one-var': 'off' 'one-var-declaration-per-line': 'off' 'no-undef': "error" "typeof": true 'no-nested-ternary': 'off' 'no-new': 'off' 'no-unneeded-ternary': 'off' "class-methods-use-this": "off" ;
AB下线
执行 tc-build offline --src 源码路径
已废弃的 AB 实验,人工删除代码时容易出问题或遗忘,导致后续冗余代码堆积占用体积且难以维护
//预加载配置(可选)AB2'kanjia''xinke''kanjia2'; //逻辑配置;
注意:配置 config 时,可根据需要为 AB 方法传递第二个参数——页面实例。如果提供,获取到的 AB 值将setData 到该实例中供 wxml 模板使用,这里 setData 的实验 key 默认会添加下划线 "_"(因为当前我们的实验 key 不符合变量规范),请使用时也按照此规则使用 —— {{ _kanjia }} 。
//wxml AB 使用规范 {{commentInfo.totalCount}}条点评 {{commentInfo.totalCount > 0 && kanjia == 'A' }} 条点评
用于管理员配置 AB 实验
小程序Xpath
执行 tc-build wrap --src 源码路径 --dist 目标路径 --_x --id --reset
tc-build wrap --src 目录 --_x --id --reset dist:可选,目标路径 _x:可选,是否生成 xpath id:可选,是否生成构建 id reset:可选,是否还原 src 格式—— /a/b/c /a/b/c/b/c/d /a/b/c/b/c/d/e/f/g dist 格式—— /a/b/c /a/b/c/b/c/d /a/b/c/b/c/d/e/f/g
//预加载 <!--code-->
生成 xpath
2 3 刘杰666 获取头"{{'sdlfkj'}}"像昵称 {{userInfo.nickName}} {{'index:'+_0}} {{'index_i:' + _1}} {{'index_2:' + _2}} {{motto}}
用于管理员配置 AB 实验
/view/view3/view@id=wx:for12/div/div@id=wx:for13/div@id=wx:for11a2d3e1/view/view3/view@id=wx:for12/div/div@id=wx:for14/div@id=wx:for13a2d4e3/view/view3/view@id=wx:for13/div/diva3c/view/view3/view@id=wx:for13/div/div@id=wx:for13/div@id=wx:for11a3d3e1/view/view3/view@id=wx:for13/div/div@id=wx:for13/div@id=wx:for12a3d3e2
ci
自动拉分支项目目录执行 tc-build checkout --name 新分支名称
新分支固定基于 master-hotel 分支拉取 ,新分支拉取后程序将自动修改对应版本信息,并提前交远端
修改规则 —— APPVersion:当前分支名, commitId:当前commitId, buildVer:build供给版本号
APPVersion: 'b180622'//用于对应迭代版本 pubAppVersion: appVersion commitId:'8dc4ac6'//用于对应客户端代码 buildVer:'1.0.4'//用于对应 mapping 版本