@cleartrip/frontguard 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +309 -75
- package/dist/cli.js.map +1 -1
- package/package.json +5 -2
- package/templates/bitbucket-pipelines.yml +19 -6
- package/templates/freekit-ci-setup.md +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleartrip/frontguard",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Org-wide frontend PR guardrails: linting, hygiene, any-delta, cycles, dead code, bundle/CWV hints, custom rules, optional LLM brief",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"build": "tsup",
|
|
27
27
|
"dev": "tsup --watch",
|
|
28
28
|
"typecheck": "tsc --noEmit",
|
|
29
|
+
"test": "npm run build && tsx --test src/lib/bitbucket-checks-image-md.test.ts src/runner/checks-snapshot-png.integration.test.ts",
|
|
29
30
|
"format": "prettier --write .",
|
|
30
31
|
"prepack": "npm run build"
|
|
31
32
|
},
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
],
|
|
39
40
|
"license": "MIT",
|
|
40
41
|
"dependencies": {
|
|
42
|
+
"@resvg/resvg-js": "^2.6.2",
|
|
41
43
|
"fast-glob": "^3.3.3",
|
|
42
44
|
"typescript": "^5.8.2"
|
|
43
45
|
},
|
|
@@ -48,6 +50,7 @@
|
|
|
48
50
|
"picocolors": "^1.1.1",
|
|
49
51
|
"prettier": "^3.5.3",
|
|
50
52
|
"tinyexec": "^1.0.1",
|
|
51
|
-
"tsup": "^8.4.0"
|
|
53
|
+
"tsup": "^8.4.0",
|
|
54
|
+
"tsx": "^4.21.0"
|
|
52
55
|
}
|
|
53
56
|
}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
# FrontGuard — PR comment: checks screenshot (inline) + FreeKit full report
|
|
2
2
|
#
|
|
3
|
-
# •
|
|
3
|
+
# • PNG matches the HTML snapshot (Overview + Checks). If Bitbucket shows a broken/empty image,
|
|
4
|
+
# the host may strip data: URLs — use pipeline artifact frontguard-checks.png or HTTPS + FRONTGUARD_CHECKS_IMAGE_URL.
|
|
5
|
+
# • Raster: @resvg/resvg-js (no browser).
|
|
4
6
|
# • The PNG is embedded in the PR comment as a small base64 image (no Bitbucket Downloads / extra tokens).
|
|
5
7
|
# • Full HTML report is uploaded to FreeKit; the comment links to that URL for details.
|
|
6
8
|
#
|
|
7
9
|
# Secured variable: BITBUCKET_ACCESS_TOKEN — must be allowed to post pull request comments.
|
|
8
10
|
#
|
|
9
11
|
# Optional: FREEKIT_BASE_URL — override FreeKit API host (default https://freekit.dev).
|
|
12
|
+
#
|
|
13
|
+
# Deeper clone avoids shallow-git errors (e.g. merge-base / parent rev) for diff-based checks.
|
|
10
14
|
|
|
11
15
|
image: node:20
|
|
12
16
|
|
|
17
|
+
clone:
|
|
18
|
+
depth: 50
|
|
19
|
+
|
|
13
20
|
pipelines:
|
|
14
21
|
pull-requests:
|
|
15
22
|
'**':
|
|
@@ -24,6 +31,7 @@ pipelines:
|
|
|
24
31
|
- frontguard-checks.png
|
|
25
32
|
script:
|
|
26
33
|
- corepack enable
|
|
34
|
+
- apt-get update && apt-get install -y --no-install-recommends fonts-dejavu-core fonts-liberation
|
|
27
35
|
- yarn install --immutable || yarn install
|
|
28
36
|
- |
|
|
29
37
|
yarn frontguard run --markdown \
|
|
@@ -40,7 +48,9 @@ pipelines:
|
|
|
40
48
|
from urllib.request import Request, urlopen
|
|
41
49
|
|
|
42
50
|
DETAILED = "For detailed check analysis, please open the full interactive report:"
|
|
43
|
-
|
|
51
|
+
# Keep in sync with src/lib/bitbucket-checks-image-md.ts (markdown line length cap).
|
|
52
|
+
MAX_IMAGE_LINE = 300_000
|
|
53
|
+
PNG_SIG = bytes([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])
|
|
44
54
|
|
|
45
55
|
base = os.environ.get("FREEKIT_BASE_URL", "https://freekit.dev").rstrip("/")
|
|
46
56
|
with open("frontguard-report.html", encoding="utf-8") as f:
|
|
@@ -70,12 +80,15 @@ pipelines:
|
|
|
70
80
|
|
|
71
81
|
with open("frontguard-checks.png", "rb") as f:
|
|
72
82
|
raw = f.read()
|
|
83
|
+
if len(raw) < 8 or raw[:8] != PNG_SIG:
|
|
84
|
+
raise SystemExit("frontguard-checks.png is missing or not a valid PNG file.")
|
|
73
85
|
b64 = base64.standard_b64encode(raw).decode("ascii")
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
# ASCII alt text; standard Base64 — matches FrontGuard pngBufferToBitbucketImageMarkdownLine.
|
|
87
|
+
img_line = f""
|
|
88
|
+
if len(img_line) > MAX_IMAGE_LINE:
|
|
76
89
|
raise SystemExit(
|
|
77
|
-
f"Checks PNG too large for inline comment ({len(raw)} bytes). "
|
|
78
|
-
"Shrink the table or
|
|
90
|
+
f"Checks PNG too large for inline comment ({len(raw)} bytes, line {len(img_line)} chars). "
|
|
91
|
+
"Shrink the table or host the PNG and link it; see bitbucket-checks-image-md.ts limits."
|
|
79
92
|
)
|
|
80
93
|
|
|
81
94
|
body = f"{img_line}\n\n{DETAILED}\n{report_url}\n"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# FreeKit.dev + FrontGuard (Bitbucket Pipelines)
|
|
2
2
|
|
|
3
|
-
The Bitbucket template (`templates/bitbucket-pipelines.yml`) runs FrontGuard with **`--checksPngOut`** (
|
|
3
|
+
The Bitbucket template (`templates/bitbucket-pipelines.yml`) runs FrontGuard with **`--checksPngOut`** (SVG → PNG via **`@resvg/resvg-js`**, no headless browser), uploads the full HTML to **FreeKit**, and posts a PR comment that **inlines** the checks PNG as `data:image/png;base64,...` plus the FreeKit URL. You only need **`BITBUCKET_ACCESS_TOKEN`** with permission to **comment on pull requests** — no Repository Downloads or `repository:write`.
|
|
4
4
|
|
|
5
5
|
The same step uploads `frontguard-report.html` to FreeKit’s public API:
|
|
6
6
|
|
|
@@ -26,7 +26,7 @@ On **Bitbucket Pipelines** pull-request builds, FrontGuard reads **`BITBUCKET_PR
|
|
|
26
26
|
|
|
27
27
|
## Checks table image in PR comments
|
|
28
28
|
|
|
29
|
-
The default pipeline uses **`--checksPngOut`** so FrontGuard
|
|
29
|
+
The default pipeline uses **`--checksPngOut`** so FrontGuard writes **`frontguard-checks.png`** (raster from the checks table). A short Python step base64-embeds that image in the PR comment (no extra hosting). If the PNG is too large for Bitbucket, raise the limit in the pipeline script cautiously or host the image and set **`FRONTGUARD_CHECKS_IMAGE_URL`** with **`--prCommentOut`** instead.
|
|
30
30
|
|
|
31
31
|
## Compared to Surge
|
|
32
32
|
|