https://github.com/wang-jun-coder/lerna-example
这是一个使用 lerna 的 demo,请不要使用
https://github.com/wang-jun-coder/lerna-example
Last synced: 4 months ago
JSON representation
这是一个使用 lerna 的 demo,请不要使用
- Host: GitHub
- URL: https://github.com/wang-jun-coder/lerna-example
- Owner: wang-jun-coder
- License: mit
- Created: 2019-12-05T01:03:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-05T06:49:03.000Z (over 6 years ago)
- Last Synced: 2024-04-29T23:00:01.907Z (almost 2 years ago)
- Language: TypeScript
- Size: 148 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lerna-example
这是一个使用 lerna 的 demo,请不要使用
## 操作步骤记录
### 初始化仓库
* 全局安装 lerna
* lerna init --independent 初始化仓库
* 如不适用 independent 参数, 则默认所有包均共享一个版本号
* 配置初始配置
* lerna.json
```json
{
"packages": [
"packages/*"
],
"npmClient": "yarn", // 指定包管理器,使用 yarn,默认 npm
"useWorkspaces": true, // 配合使用 yarn workspace
"command": {
"publish": {
"ignoreChanges": [],
"message": "chore(none): publish", // 发布时提交的commit message
"registry": " https://registry.npmjs.org"
},
},
"version": "independent"
}
```
* package.json
```json
{
"name": "root",
"private": true,
"packages": [ // yarn workspace 对应的配置项
"packages/*"
],
"devDependencies": {
"lerna": "^3.19.0"
}
}
```
* 创建包
* `lerna create @wangjuncode/lerna-example-tools`
* 创建一个工具包,可单独使用,也可作为依赖
* 注意:
* 如为 scope 包, 则package.json 需有如下配置(使用命令创建,默认会有配置)
```json
{
...
"publishConfig": {
"access": "public"
},
...
}
```
* `lerna create @wangjuncode/lerna-example-module`
* 创建一个独立模块包
* `lerna create @wangjuncode/lerna-example`
* 创建一个主包,依赖 tools 和 module
* 安装通用依赖
此处均已 typescript 包来进行配置
* `yarn add typescript -W -D`
* 安装 ts 依赖
* 创建 tsconfig.json 文件
```json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true,
"strict": true,
"outDir": "lib",
"declaration": true
},
"include": [
"packages/**/*"
],
"exclude": [
"node_modules",
"**/__tests__/*"
]
}
```
* 编写相关代码逻辑(见代码)
* 安装 lint 相关依赖并配置
* `yarn add prettier tslint tslint-config-prettier -W -D`
* 配置 .prettierrc
* tslint.json
* 安装 jest 相关
* `yarn add jest ts-jest @types/jest -W -D`
* 配置 jestconfig.json
* 配置 git 等流程
* 安装相关依赖
* `yarn add -W -D @commitlint/cli @commitlint/config-conventional commitizen cz-lerna-changelog lint-staged husky`
* commitizen, cz-lerna-changelog 规范化提交记录
* commitlint, husky 提交前校验提交信息是否符合规范
* tslint 校验代码风格