Skip to content

Commit c284fad

Browse files
authored
Merge pull request #2 from VisActor/pre-release/0.1.0-alpha.0
Pre release/0.1.0 alpha.0
2 parents 6439e2e + 71b1eb3 commit c284fad

7 files changed

Lines changed: 92 additions & 44 deletions

File tree

.github/workflows/release.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -407,20 +407,22 @@ jobs:
407407
}
408408
409409
if (published.length > 0) {
410-
console.error(
410+
console.log(
411411
`Detected partially published packages for ${packageVersion}. Published: ${published.join(', ')}. Missing: ${missing.join(
412412
', '
413-
)}.`
413+
)}. Continue publish to let rush skip existing packages and publish missing ones.`
414414
);
415-
process.exit(1);
415+
} else {
416+
console.log(`No publishable package exists on npm for ${packageVersion}, continue publish.`);
416417
}
417-
418-
console.log(`No publishable package exists on npm for ${packageVersion}, continue publish.`);
419418
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'skip_publish=false\n');
420419
NODE
421420
422421
- name: Publish to npm (release)
423422
if: startsWith(github.ref_name, 'release/') && steps.npm_version_release.outputs.skip_publish != 'true'
423+
env:
424+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
425+
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
424426
run: node common/scripts/install-run-rush.js publish --publish --include-all --tag latest
425427

426428
- name: Check npm versions (hotfix)
@@ -465,20 +467,23 @@ jobs:
465467
}
466468
467469
if (published.length > 0) {
468-
console.error(
470+
console.log(
469471
`Detected partially published packages for ${packageVersion}. Published: ${published.join(', ')}. Missing: ${missing.join(
470472
', '
471-
)}.`
473+
)}. Continue publish to let rush skip existing packages and publish missing ones.`
472474
);
473-
process.exit(1);
475+
} else {
476+
console.log(`No publishable package exists on npm for ${packageVersion}, continue publish.`);
474477
}
475478
476-
console.log(`No publishable package exists on npm for ${packageVersion}, continue publish.`);
477479
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'skip_publish=false\n');
478480
NODE
479481
480482
- name: Publish to npm (hotfix)
481483
if: startsWith(github.ref_name, 'hotfix/') && steps.npm_version_hotfix.outputs.skip_publish != 'true'
484+
env:
485+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
486+
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
482487
run: node common/scripts/install-run-rush.js publish --publish --include-all --tag hotfix
483488

484489
- name: Check npm versions (pre-release)
@@ -523,20 +528,23 @@ jobs:
523528
}
524529
525530
if (published.length > 0) {
526-
console.error(
531+
console.log(
527532
`Detected partially published packages for ${packageVersion}. Published: ${published.join(', ')}. Missing: ${missing.join(
528533
', '
529-
)}.`
534+
)}. Continue publish to let rush skip existing packages and publish missing ones.`
530535
);
531-
process.exit(1);
536+
} else {
537+
console.log(`No publishable package exists on npm for ${packageVersion}, continue publish.`);
532538
}
533539
534-
console.log(`No publishable package exists on npm for ${packageVersion}, continue publish.`);
535540
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'skip_publish=false\n');
536541
NODE
537542
538543
- name: Publish to npm (pre-release)
539544
if: startsWith(github.ref_name, 'pre-release/') && steps.npm_version_prerelease.outputs.skip_publish != 'true'
545+
env:
546+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
547+
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
540548
run: node common/scripts/install-run-rush.js publish --publish --include-all --tag ${{ steps.semver_prerelease.outputs.pre_release_type }}
541549

542550
- name: Update shrinkwrap

common/config/rush/pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
},
1212
"dependencies": {
1313
"@arco-design/web-react": "2.39.3",
14-
"@visactor/vgraph": "workspace:*",
15-
"@visactor/react-vgraph": "workspace:*",
16-
"@visactor/react-vgraph-ui": "workspace:*",
14+
"@visactor/vgraph": "workspace:0.1.0-alpha.0",
15+
"@visactor/react-vgraph": "workspace:0.1.0-alpha.0",
16+
"@visactor/react-vgraph-ui": "workspace:0.1.0-alpha.0",
1717
"buble": "^0.20.0",
1818
"highlight.js": "^11.8.0",
1919
"markdown-it": "^13.0.0",

packages/react-vgraph-ui/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@visactor/react-vgraph-ui",
3-
"version": "0.1.0",
3+
"version": "0.1.0-alpha.0",
44
"description": "React UI components for VGraph",
55
"keywords": [
66
"react",
@@ -58,7 +58,7 @@
5858
"@babel/preset-typescript": "^7.26.0",
5959
"@internal/eslint-config": "workspace:*",
6060
"@rushstack/eslint-patch": "~1.1.4",
61-
"@visactor/vgraph": "workspace:*",
61+
"@visactor/vgraph": "workspace:0.1.0-alpha.0",
6262
"@testing-library/jest-dom": "^5.16.4",
6363
"@testing-library/react": "12",
6464
"@types/jest": "^27.0.2",
@@ -93,7 +93,7 @@
9393
"worker-loader": "^3.0.8"
9494
},
9595
"peerDependencies": {
96-
"@visactor/vgraph": "^0.1.0",
96+
"@visactor/vgraph": "^0.1.0-alpha.0",
9797
"@arco-design/web-react": "^2.39.3",
9898
"react": ">=16",
9999
"react-dom": ">=16",

packages/react-vgraph/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@visactor/react-vgraph",
3-
"version": "0.1.0",
3+
"version": "0.1.0-alpha.0",
44
"description": "The react version of VGraph",
55
"keywords": [
66
"react",
@@ -56,7 +56,7 @@
5656
"@babel/preset-typescript": "^7.26.0",
5757
"@internal/eslint-config": "workspace:*",
5858
"@rushstack/eslint-patch": "~1.1.4",
59-
"@visactor/vgraph": "workspace:*",
59+
"@visactor/vgraph": "workspace:0.1.0-alpha.0",
6060
"@testing-library/jest-dom": "^5.16.4",
6161
"@testing-library/react": "12",
6262
"@types/dom-to-image": "^2.6.7",
@@ -94,7 +94,7 @@
9494
"worker-loader": "^3.0.8"
9595
},
9696
"peerDependencies": {
97-
"@visactor/vgraph": "^0.1.0",
97+
"@visactor/vgraph": "^0.1.0-alpha.0",
9898
"react": ">=16",
9999
"react-dom": ">=16",
100100
"@types/react": ">=16"

packages/vgraph/__tests__/renderer/text.spec.ts

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Text } from "../../src/renderer/shapes/text";
2+
import { measureText } from "../../src/renderer/utils/text";
23
const OS_PLATFORM = process.platform;
34

45
function expectValueBySystem(value: any, macValue: any, winValue: any) {
@@ -11,6 +12,46 @@ function expectValueBySystem(value: any, macValue: any, winValue: any) {
1112
}
1213
}
1314

15+
function expectWrappedTextWithinWidth(
16+
sourceText: string,
17+
wrappedText: string,
18+
width: number
19+
) {
20+
const measureConfigs = { text: "", x: 0, y: 0, width };
21+
expect(sourceText.startsWith(wrappedText)).toBe(true);
22+
expect(measureText(wrappedText, measureConfigs)).toBeLessThanOrEqual(width);
23+
24+
if (wrappedText.length < sourceText.length) {
25+
expect(
26+
measureText(sourceText.slice(0, wrappedText.length + 1), measureConfigs)
27+
).toBeGreaterThan(width);
28+
}
29+
}
30+
31+
function expectEllipsizedTextWithinWidth(
32+
sourceText: string,
33+
ellipsizedText: string,
34+
width: number
35+
) {
36+
const measureConfigs = { text: "", x: 0, y: 0, width };
37+
expect(ellipsizedText.endsWith("...")).toBe(true);
38+
39+
const visibleText = ellipsizedText.slice(0, -3);
40+
expect(sourceText.startsWith(visibleText)).toBe(true);
41+
expect(measureText(ellipsizedText, measureConfigs)).toBeLessThanOrEqual(
42+
width
43+
);
44+
45+
if (visibleText.length < sourceText.length) {
46+
expect(
47+
measureText(
48+
`${sourceText.slice(0, visibleText.length + 1)}...`,
49+
measureConfigs
50+
)
51+
).toBeGreaterThan(width);
52+
}
53+
}
54+
1455
describe("src/shapes/text.ts", () => {
1556
it("should work without width & height", () => {
1657
const text = new Text({
@@ -161,29 +202,29 @@ describe("src/shapes/text.ts", () => {
161202
});
162203

163204
expect(text.getDrawText()).toEqual(["a", "b", "c", "d", "e"]);
164-
expect(text.getBBox().top).toBe(-45);
165-
expect(text.getBBox().height).toBe(90);
205+
const bbox = text.getBBox();
206+
expect(bbox.height).toBe(text.getDrawText().length * text.getLineHeight());
207+
expect(bbox.top).toBe(-bbox.height / 2);
166208
});
167209

168210
it("bugfix: 文本阶段长度计算", () => {
211+
const sourceText = "支付用户渗透率支付用户渗透率";
212+
const width = 122;
169213
const text = new Text({
170-
text: "支付用户渗透率支付用户渗透率",
214+
text: sourceText,
171215
x: 0,
172216
y: 0,
173-
width: 122,
217+
width,
174218
});
175-
if (OS_PLATFORM === "linux") {
176-
expect(text.getDrawText()).toEqual(["支付用户渗透率支"]);
177-
} else {
178-
expect(text.getDrawText()).toEqual(["支付用户渗透率支付用"]);
179-
}
219+
220+
const drawText = text.getDrawText();
221+
expect(drawText).toHaveLength(1);
222+
expectWrappedTextWithinWidth(sourceText, drawText[0], width);
180223

181224
text.set("textOverflow", "ellipsis");
182-
if (OS_PLATFORM === "linux") {
183-
expect(text.getDrawText()).toEqual(["支付用户渗透率..."]);
184-
} else {
185-
expect(text.getDrawText()).toEqual(["支付用户渗透率支付..."]);
186-
}
225+
const ellipsizedText = text.getDrawText();
226+
expect(ellipsizedText).toHaveLength(1);
227+
expectEllipsizedTextWithinWidth(sourceText, ellipsizedText[0], width);
187228
});
188229

189230
it("bugfix: 连续换行情况", () => {

packages/vgraph/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@visactor/vgraph",
3-
"version": "0.1.0",
3+
"version": "0.1.0-alpha.0",
44
"description": "graph visualization engine",
55
"main": "cjs/index.js",
66
"module": "es/index.js",
@@ -93,6 +93,5 @@
9393
"d3-ease": "^3.0.1",
9494
"d3-interpolate": "^3.0.1",
9595
"d3-quadtree": "^3.0.1"
96-
},
97-
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
96+
}
9897
}

0 commit comments

Comments
 (0)