项目介绍
此项目乃固守前端脚手架命令工具,脚手架地址
目录
安装
npm install gsg-client@latest -g
使用
说明
命令参数格式:xxx // 可选参数<xxx> // 必填参数
基础
gsg -h // 查看帮助gsg -v // 查看版本
查看脚手架列表
gsg l
构建项目
gsg i 脚手架名称,默认 gsg-scaffold
快速合并推送分支
gsg push <branch> options // git 快捷操作 branch: 分支名称 只支持 'test,release,master' Options: -m --msg <msg> commit -h --help output usage information 例如:gsg push test -m 'xxx' // -m可选 提交当前分支然后合并到test,然后push例如:gsg push release -m 'xxx' // -m可选 提交当前分支然后合并到release,然后push,注:如果release上有未发布正式的版本,则会提示例如:gsg push master -m 'fixbug' // -m必填 以--squash的方式合并origin/release 到master,然后push
部署项目
gsg d env options env: 环境名称详见配置文件说明,默认:default Options: -c --config <config> -h --help output usage information 例如:gsg d // 部署default环境例如:gsg d test // 部署test环境例如:gsg d -c './config/deploy.config.js' // 使用./config/deploy.config.js配置部署efault环境
部署配置文件说明 ./deploy.config.js
// config 的属性 defalt,test,release,prod 作为 gsg d 命令的 env 参数,读取对应的配置
const path = ; const config = test: host: '10.10.100.2' // 服务器地址 user: 'root' // 用户 password: 'G3Sde1d2' // 密码 remotePath: '/home/tomcat/node/demo-admin' // 服务器文件目录 pm2App: 'demo-admin' // pm2本项目的 app名字 release: host: '10.10.100.113' user: 'tomcat' password: '12354@qwsf' remotePath: '/data/demo-admin' pm2App: 'demo-admin' prod: {} //没有host配置则不传远端,仅本地构建打包;Object;configdefault = configtest; // 默认发布到test环境moduleexports = config;
运行mock服务
gsg mock options Options: -c --config <config> : -h --help output usage information 例如:gsg mock // 启动mock服务
mock 配置文件说明 ./mock.config.js
moduleexports = db: './mock' // mock数据位置 mock数据格式详见下面说明 port: 3000 // mock服务端口 prefix: '/api' // mock接口前缀,包含这个前缀的才会作为mock接口;
mock 数据说明 ./mock/a/b/c.js
// 创建路径建议配合 mk 命令: gsg mk mock/a/b/c.js // 以上 mock 配置接口访问 127.0.0.1:3000/api/a/b/c
例1:module { return "code": 1 "message": null "data": ;};例2:module { // req 和 res 的其他用法参考node http模块 console; // url 参数对象 console; // url pathname const data = "code": 1 "message": null "data": "name": "北京市" "id": "11" res;};
mock 数据说明 ./mock/a/b/c.json
// 以上 mock 配置接口访问 127.0.0.1:3000/api/a/b/c
创建文件或者目录
gsg mk <name>
name: (必填)文件或者目录路径
例如:gsg mk a/b 在当前目录下创建a/b 目录
例如:gsg mk a/b/c.js 在当前目录下创建a/b/c.js 文件
解析excel
gsg excel options Options: -c --config <config> : -h --help output usage information 例如:gsg excel // 解析excel
mock 配置文件说明 ./excel.config.js
moduleexports = entry: './测试.xlsx' // [必填] excel文件 output: './测试.json' // [可选] 默认为excel同名的json文件 { // [可选] 读出来的数据进行转换 return data; };
通过jenkins发布版本
gsg publish <branch> branch:必填git分支环境 例如:gsg publish test // 发布测试例如:gsg publish release // 发布预生产