1.0.1 • Published 1 year ago

geelygo-watch v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

geelygo-watch 介绍

  • 该npm包当前版本集成了阿里云的arms前端监控。里面已经集成了私有请求接口(获取参数的敏感key值List, 因为api上报数据的时候有一些敏感字段不能上传,该敏感字段list 通过接口获取)

####用法: 1.在项目中引入该npm包:

yarn add geelygo-watch

2.在项目入口文件index.js 引入该包,并初始化。

import { geelyGoAliArms } from 'geelygo-watch';

// 参数的含义可参考阿里云 arms前端监控文档。
geelyGoAliArms.init({
  appType: 'h5',
  pid: "xxxxxxxxxx",
})

3.需要进行api接口上报的时候 直接调用:

import { geelyGoAliArms } from 'geelygo-watch';

geelyGoAliArms.api({
  success: isSuccess, // api 接口正确还是错误
  request: param, // 传入请求参数
  response: res  // 传入接口返回的数据
  apis: {
    success: true,
    time: ''
    ... // 参考arms的 .api()参数即可
  }
});

scripts命令介绍

"scripts": {
    "pub": "npm run compile && c3-version upgrade && npm publish",
    "pub:next": "npm run compile && c3-version upgrade -t next && npm publish --tag next",
    "compile": "npm run lint && npm run test && npm run es && npm run lib",
    "es": "ytian-scabbard compile",
    "lib": "ytian-scabbard compile -t commonjs",
    "lint": "eslint --fix src/",
    "test": "cross-env BABEL_ENV=test jest --colors --config .jest.js --no-cache",
    "cz": "git cz",
    "preversion": "npm run changelog && git add CHANGELOG.md",
    "postversion": "git push && git push --tags",
    "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
    "pre-commit": "lint-staged"
},
  • pub: 版本发布,包发布到latest这个tag下面
  • pub:next: 预发版本发布,包发布到next这个tag下面
  • compile: 对包进行编译,编译前进行eslint校验并跑通单测
  • es: 将包编译为ES的模块规范
  • lib: 将包编译为CommonJS的模块规范
  • lint: 运行eslint
  • test: 运行单测
  • cz: git commit msg 命令
  • preversion和postversion: npm version的钩子
  • changelog: 生成CHANGELOG.md文件
  • pre-commit: git 的钩子

文件规范

默认的入口文件为src/index.js,尽量扁平化项目结构,不要有太深的文件层级。

代码在发布的时候,会把编译后的代码发布上去,包括ES6和commonjs两个版本。

组件库的开发,git的commit msg必须遵循commitizen规范,否则无法提交代码。

git commit -m

 ↓  ↓  ↓

git cz (需要全局安装commitizen) 或 yarn cz