@ranchuanjiang/ms-cli
v0.0.1
Published
React 前端团队一体式脚手架工具
Readme
@msxf/ms-cli - 前端构建脚手架
效能研发团队自用 cli 工具,如在使用中遇到问题或有希望添加的新功能,欢迎积极反馈。
安装
使用马上消费镜像安装 npm
npm install -g @msxf/ms-cli1、项目创建
cloud-cli create myapp
? 请选择开发脚手架: react
✔ 获取模板数据...
? 请选择模板 cloud-ecs-admin-frontend
✔ 获取版本信息...
? 请选择对应版本 dev-cicd
? 请输入项目名称(例: audit) ecs-admin
? 请输入项目简介: (例: 审计前管项目) ecs后管项目
✔ waiting download template
Successfully created project myapp
2、项目启动
cloud-cli dev3、项目构建
cloud-cli build4、lint 检查
- 含 eslint、stylelint 检查
cloud-cli lint
$ cloud-cli lint
info - msResourceFreight
src/global.less
30:3 ✖ Expected whitespace after "/*" comment-whitespace-inside
30:14 ✖ Expected whitespace before "*/" comment-whitespace-inside
E:\代码\msxf\gc-backend-bfe\src\utils\sentryInit\index.ts
112:17 warning 'dsns' is assigned a value but never used @typescript-eslint/no-unused-vars
112:23 warning 'dsn' is assigned a value but never used @typescript-eslint/no-unused-vars5、代码查重
- --threshold 允许通过的重复率
cloud-cli jscpd --threshold 10
┌────────────┬────────────────┬─────────────┬──────────────┬──────────────┬──────────────────┬───────────────────┐
│ Format │ Files analyzed │ Total lines │ Total tokens │ Clones found │ Duplicated lines │ Duplicated tokens │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ javascript │ 19 │ 706 │ 6221 │ 0 │ 0 (0%) │ 0 (0%) │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ tsx │ 25 │ 1994 │ 17006 │ 7 │ 109 (5.47%) │ 966 (5.68%) │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ less │ 7 │ 651 │ 3619 │ 0 │ 0 (0%) │ 0 (0%) │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ typescript │ 30 │ 1049 │ 7715 │ 1 │ 6 (0.57%) │ 85 (1.1%) │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ Total: │ 81 │ 4400 │ 34561 │ 8 │ 115 (2.61%) │ 1051 (3.04%) │
└────────────┴────────────────┴─────────────┴──────────────┴──────────────┴──────────────────┴───────────────────┘
Found 8 clones.7、组件命名校验
yarn check-naming
yarn run v1.22.19
$ cloud-cli check-naming
info - 开始文件命名检查
error - File name -- components 下的文件 confirm.tsx !UpperCamelCase: E:\代码\msxf\gc-backend-bfe\src\layouts\components\AuthModal\confirm.tsx
error - File name -- components 下的文件 action.tsx !UpperCamelCase: E:\代码\msxf\gc-backend-bfe\src\layouts\components\Header\action.tsx
done - 文件命名检查已完成8、项目测试
- 支持快照
$ cloud-cli test
info - msResourceFreight
info - generate files
info - Preparing...
PASS src/utils/__test__/index.test.tsx (52.427 s)
getRouteItem
√ should return null when no matching route is found (5 ms)
√ should find a nested route (2 ms)
√ should find a route with a hidden property (1 ms)
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 54.834 s9、快速强制清空项目依赖,重新安装
cloud-cli clean10、未使用文件检测
cloud-cli deadcode