Skip to content

Commit

Permalink
Merge pull request #214 from antvis/fix-publish
Browse files Browse the repository at this point in the history
build: Should run build when versions are modified and committed for lerna
  • Loading branch information
诸岳 authored Oct 17, 2019
2 parents 281b4f6 + 6a0533b commit cc8566e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 44 deletions.
44 changes: 13 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
# Util
# G

> 所有 Util 模块

## Lerna
## 开发

使用 lerna 进行多模块的管理和开发,所有的模块都在 `packages` 目录中,每个模块都是独立的 npm 包,并且解决了各个包之间依赖本地开发文件的问题。


使用的基本操作为:
使用的基本操作为:

- 安装依赖

```bash
tnpm i
npm i
npx lerna bootstrap
```


- link

通过 link 操作,可以将包之间的依赖改成依赖为本地开发的文件。
Expand All @@ -26,9 +21,9 @@ npx lerna bootstrap
npx lerna link
```

- run (test、build...)
- run

可以通过这个命令批量跑 `scripts`。例如
可以通过这个命令批量跑 `scripts`。例如:

```bash
npx lerna run test
Expand All @@ -37,7 +32,12 @@ npx lerna run build

- publish

批量 publish。
```bash
npm run pre-publish # 执行发布前脚本
npm run publish # 发布正式版本
# or
npm run publish-beta # 发布 beta 版本
```

- clean

Expand All @@ -47,22 +47,4 @@ npx lerna run build
npx lerna clean
```


以上命令基本够用,深度用户参考其他命令:[lerna](https://github.com/lerna/lerna)

## Principles

- 尽量统一编译、工具链,保证版本一致,比如:babel、typescript、jest 等,各个 packages 尽量使用统一的版本,并将依赖写到根目录 package.json。
- tsconfig.json 需要 extends 根目录配置,各模块的特性化配置自己管理。
- 模块需要有单测覆盖。
- 相同规范的 `scripts`
- start
- test
- build
- 增加 .npmignore,去除源码,仅保留编译压缩之后的包。
- 统一 lint 配置。
- README.md 模块需要清晰展现模块的 API 和主路径使用示例。

<!-- GITCONTRIBUTOR_START -->

<!-- GITCONTRIBUTOR_END -->
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build": "lerna run build",
"contributor": "git-contributor",
"link": "lerna link",
"lint": "npm run eslint",
"lint": "npm run eslint && npm run tslint",
"eslint": "eslint --ext .html,.js ./packages",
"eslint-fix": "eslint --fix --ext .html,.js ./packages",
"tslint": "tslint ./packages/**/*.ts",
Expand All @@ -23,8 +23,10 @@
"prettier": "prettier --write './packages/**/*.{js,ts}'",
"test": "lerna run test",
"ci": "npm run lint && npm run bootstrap && npm run build && npm run test",
"publish": "rm -rf node_modules && npm install && npm run bootstrap && npm run build && lerna publish",
"publish-beta": "rm -rf node_modules && npm install && npm run bootstrap && npm run build && lerna publish --dist-tag beta",
"pre-publish": "npm run lint && rm -rf node_modules && npm install && npm run bootstrap",
"postversion": "npm run build",
"publish": "lerna publish",
"publish-beta": "npm run pre-publish && lerna publish --dist-tag beta",
"site:build": "gatsby build",
"site:develop": "gatsby develop",
"site:clean": "gatsby clean"
Expand Down
9 changes: 4 additions & 5 deletions packages/g-base/src/animate/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,18 @@ class Timeline {
* 初始化定时器
*/
initTimer() {
const self = this;
let isFinished = false;
let shape: IElement;
let animations: Animation[];
let animation: Animation;
self.timer = d3Timer.timer((elapsed) => {
self.current = elapsed;
this.timer = d3Timer.timer((elapsed) => {
this.current = elapsed;
if (this.animators.length > 0) {
for (let i = this.animators.length - 1; i >= 0; i--) {
shape = this.animators[i];
if (shape.destroyed) {
// 如果已经被销毁,直接移出队列
self.removeAnimator(i);
this.removeAnimator(i);
continue;
}
if (!shape.isAnimatePaused()) {
Expand All @@ -178,7 +177,7 @@ class Timeline {
}
}
if (animations.length === 0) {
self.removeAnimator(i);
this.removeAnimator(i);
}
}
const autoDraw = this.canvas.get('autoDraw');
Expand Down
6 changes: 4 additions & 2 deletions packages/g-base/src/util/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ const pathTocurve = function(path, path2?) {
let pcom = ''; // holder for previous path command of original path
let ii;
const processPath = function(path, d, pcom) {
let nx, ny;
let nx;
let ny;
if (!path) {
return ['C', d.x, d.y, d.x, d.y, d.x, d.y];
}
Expand Down Expand Up @@ -1143,7 +1144,8 @@ function getMinDiff(del, add, modify) {
const levenshteinDistance = function(source, target) {
const sourceLen = source.length;
const targetLen = target.length;
let sourceSegment, targetSegment;
let sourceSegment;
let targetSegment;
let temp = 0;
if (sourceLen === 0 || targetLen === 0) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions packages/g-svg/src/util/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ export function parsePath(path) {

if (isString(path)) {
path = path.match(regexTags);
each(path, function(item, index) {
each(path, (item, index) => {
item = item.match(regexDot);
if (item[0].length > 1) {
const tag = item[0].charAt(0);
item.splice(1, 0, item[0].substr(1));
item[0] = tag;
}
each(item, function(sub, i) {
each(item, (sub, i) => {
if (!isNaN(sub)) {
item[i] = +sub;
}
Expand Down
3 changes: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"object-shorthand-properties-first": [false],
"no-increment-decrement": [false],
"no-console": [true, "log"],
"no-debugger": true
"no-debugger": true,
"no-parameter-reassignment": false
}
}

0 comments on commit cc8566e

Please sign in to comment.