@cleartrip/frontguard 0.2.6 → 0.2.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleartrip/frontguard",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
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,20 @@
1
1
  # FrontGuard — PR comment: checks screenshot (inline) + FreeKit full report
2
2
  #
3
- # • FrontGuard renders the checks table to HTML, then to PNG using Playwright (`npx`, no apt Chromium).
3
+ # • The checks-table PNG is generated with @resvg/resvg-js (SVG raster; no Playwright/Chromium).
4
4
  # • The PNG is embedded in the PR comment as a small base64 image (no Bitbucket Downloads / extra tokens).
5
5
  # • Full HTML report is uploaded to FreeKit; the comment links to that URL for details.
6
6
  #
7
7
  # Secured variable: BITBUCKET_ACCESS_TOKEN — must be allowed to post pull request comments.
8
8
  #
9
9
  # Optional: FREEKIT_BASE_URL — override FreeKit API host (default https://freekit.dev).
10
+ #
11
+ # Deeper clone avoids shallow-git errors (e.g. merge-base / parent rev) for diff-based checks.
10
12
 
11
13
  image: node:20
12
14
 
15
+ clone:
16
+ depth: 50
17
+
13
18
  pipelines:
14
19
  pull-requests:
15
20
  '**':
@@ -24,6 +29,7 @@ pipelines:
24
29
  - frontguard-checks.png
25
30
  script:
26
31
  - corepack enable
32
+ - apt-get update && apt-get install -y --no-install-recommends fonts-dejavu-core
27
33
  - yarn install --immutable || yarn install
28
34
  - |
29
35
  yarn frontguard run --markdown \
@@ -40,7 +46,9 @@ pipelines:
40
46
  from urllib.request import Request, urlopen
41
47
 
42
48
  DETAILED = "For detailed check analysis, please open the full interactive report:"
43
- MAX_B64 = 290_000
49
+ # Keep in sync with src/lib/bitbucket-checks-image-md.ts (markdown line length cap).
50
+ MAX_IMAGE_LINE = 300_000
51
+ PNG_SIG = bytes([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])
44
52
 
45
53
  base = os.environ.get("FREEKIT_BASE_URL", "https://freekit.dev").rstrip("/")
46
54
  with open("frontguard-report.html", encoding="utf-8") as f:
@@ -70,12 +78,15 @@ pipelines:
70
78
 
71
79
  with open("frontguard-checks.png", "rb") as f:
72
80
  raw = f.read()
81
+ if len(raw) < 8 or raw[:8] != PNG_SIG:
82
+ raise SystemExit("frontguard-checks.png is missing or not a valid PNG file.")
73
83
  b64 = base64.standard_b64encode(raw).decode("ascii")
74
- img_line = f"![FrontGuardchecks summary](data:image/png;base64,{b64})"
75
- if len(img_line) > MAX_B64:
84
+ # ASCII alt text; standard Base64 matches FrontGuard pngBufferToBitbucketImageMarkdownLine.
85
+ img_line = f"![FrontGuard checks summary](data:image/png;base64,{b64})"
86
+ if len(img_line) > MAX_IMAGE_LINE:
76
87
  raise SystemExit(
77
- f"Checks PNG too large for inline comment ({len(raw)} bytes). "
78
- "Shrink the table or raise MAX_B64 after verifying Bitbucket limits."
88
+ f"Checks PNG too large for inline comment ({len(raw)} bytes, line {len(img_line)} chars). "
89
+ "Shrink the table or host the PNG and link it; see bitbucket-checks-image-md.ts limits."
79
90
  )
80
91
 
81
92
  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`** (Playwright via `npx`), 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`.
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 runs **Playwright via `npx`** and writes `frontguard-checks.png`. 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.
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