Skip to content

Add packaged, root-level Lychee link-check tooling - #2667

Merged
chalin merged 6 commits into
docsy:mainfrom
chalin:chalin-m24-lychee-cache-stats-2026-0626
Jun 29, 2026
Merged

chalin merged 6 commits into
docsy:mainfrom
chalin:chalin-m24-lychee-cache-stats-2026-0626

Conversation

@chalin

@chalin chalin commented Jun 26, 2026 •

Copy link
Copy Markdown
Collaborator

Builds on the htmltest→Lychee switch (#2665) to make cached Lychee link-checking consumable by any Docsy-based site, not just docsy.dev. The helpers move out of the private docsy.dev/ site to root-level scripts/lychee/, so they ship with the published docsy package (alongside gen-favicons) and are exposed as bins.

Tooling (scripts/lychee/)

  • check/ (bin lychee-norm-cache) — the link-check wrapper, converted from docsy.dev/scripts/check-links-lychee.sh to a tested .mjs. It resolves a GitHub token (GITHUB_TOKEN or gh auth token), runs Lychee over the built site, and normalizes the .lycheecache (LC_ALL=C-equivalent byte sort) even on failure. It operates on the current working directory, so any consuming site can call it. -h/--help prints usage.
  • refcache/ (bin refcache) — a small multi-tool over the committed .lycheecache:
    • -l/--list NUM lists the NUM oldest entries; -p/--prune NUM[%] drops the NUM (or NUM%) oldest and rewrites the file; -s/--summary prints counts, status breakdown, oldest/newest timestamp (local time) and age, and an adaptive age histogram that scales to the cache's own age span.
    • Options run in the order given over the evolving cache, so -l 5 -p 5 lists the 5 about to be pruned while -p 5 -l 5 looks ahead at the next 5. Flags may not repeat; with no options it prints the summary. -h/--help prints usage.
    • Pruning preserves line order, so the rewrite stays sorted and diffs minimally.
  • README.md — what/why, requirements, and usage; shipped in files.

Both pure helpers (token resolution, cache sort, refcache parse/select/arg-parsing/ordered-execution) are unit-tested under scripts/lychee/**/*.test.mjs, now run by root test:tooling on Linux + Windows. The files/bin packaging surface is locked down by npm-pack.test.mjs, and the new-site smoke test exercises npx <bin> --help for each shipped bin.

Wiring

  • fix:refcache (docsy.dev) — runs check:links, which adds any missing entries to the .lycheecache and renormalizes it. (A fix:*-family alias for the cache-refresh side effect of a normal check.)
  • fix:refcache and refcache are also exposed from the repo root, delegating to docsy.dev, so the cache can be refreshed (npm run fix:refcache) and inspected (npm run refcache -- -s) from either place.
  • Arg forwarding — appends a trailing -- to check:links so flags forwarded through the nested npm run reach lychee instead of being swallowed as npm config.
  • Cleanup — drops the redundant check:links:ccr / precheck:links:ccr pair; the shared-chrome variant is already reachable via npm run ccr check:links.
  • CI — the offline lychee sanity tests (test:lychee) now run on Linux, catching --index-files / fragment regressions without a full site build.
  • Maintainer docs — maintainer-notes.md gains a short "Link checking and the refcache" section.

Usage:

npx refcache -s               # summary
npx refcache -l 20            # 20 oldest entries
npx refcache -l 50 -p 50      # list the 50 about to be pruned, then prune them
npm run fix:refcache          # re-run the link check, refreshing the cache (docsy.dev or root)

Prettier floor (independent of Lychee)

Unrelated to the Lychee work, but bundled here: raises the prettier devDependency to ^3.9.3. Prettier 3.9.0–3.9.2 silently corrupt multi-line Hugo shortcodes (a standalone %}} line is rewritten to }); the regression (prettier/prettier#19488) was fixed in 3.9.3. With no committed lockfile and CI running npm install, the package.json range is the only guard against resolving a broken 3.9.x, so the floor is set past the broken range.

@chalin chalin added this to the 0.16.0 milestone Jun 26, 2026
@chalin
chalin force-pushed the chalin-m24-lychee-cache-stats-2026-0626 branch from b432845 to 80e44d8 Compare June 27, 2026 01:12
@chalin chalin changed the title Add Lychee refcache stats and refresh npm helpers Add a Lychee refcache helper (list, prune, summary) Jun 27, 2026
@chalin
chalin force-pushed the chalin-m24-lychee-cache-stats-2026-0626 branch from 80e44d8 to 27a707e Compare June 27, 2026 13:35
@chalin chalin changed the title Add a Lychee refcache helper (list, prune, summary) Add packaged, root-level Lychee link-check tooling Jun 27, 2026
@chalin
chalin force-pushed the chalin-m24-lychee-cache-stats-2026-0626 branch from 27a707e to 9cfb67a Compare June 27, 2026 14:30
chalin added 2 commits June 29, 2026 09:42
Move the Lychee helpers out of the private docsy.dev site into root-level
`scripts/lychee/`, so they ship with the published `docsy` package and any
Docsy-based site can run cached Lychee link checking.

- `scripts/lychee/check/`: the link-check wrapper (was
  `docsy.dev/scripts/check-links-lychee.sh`), rewritten as a tested `.mjs`.
  It resolves a GitHub token, runs Lychee over the built site, and
  normalizes the cache. Exposed as the `lychee-norm-cache` bin, with `--help`.
- `scripts/lychee/refcache/`: the refcache list/prune/summary multi-tool,
  exposed as the `refcache` bin.
- `scripts/lychee/README.md`: usage for both tools, shipped in `files`.
- Add the new scripts to root `package.json` `files`/`bin`, and extend
  `npm-pack.test.mjs` to keep the packaged surface in sync.
- Cover the bins in the new-site smoke test via `npx <bin> --help`.
- Wire docsy.dev to call the root scripts. `fix:refcache` runs `check:links`,
  which adds any missing entries to the cache and renormalizes it.
- Expose `fix:refcache` and `refcache` from the repo root too, delegating to
  docsy.dev, so the cache can be refreshed and inspected from either place.
- Removes `check:links:ccr` and `precheck:links:ccr`: the run-command duplicated `check:links`, and the shared-chrome build they triggered is already reachable through the generic `ccr` runner.
- Use `npm run ccr check:links` instead — it sets `HUGO_PARAMS_TD_CHROME=shared`, which the inherited `precheck:links` build picks up to produce the same shared-chrome site.
@chalin
chalin force-pushed the chalin-m24-lychee-cache-stats-2026-0626 branch from 9cfb67a to 7c489b6 Compare June 29, 2026 13:43
chalin added 2 commits June 29, 2026 10:12
Prettier 3.9.0–3.9.2 silently corrupt multi-line Hugo shortcodes — a standalone
`%}}` line is rewritten to `}` — breaking `{{% blocks/cover … %}}` content. The
regression (prettier/prettier#19488) was fixed in 3.9.3, so raise the
devDependency floor past the broken range rather than just allowing it.

There's no committed lockfile and CI runs `npm install` (not `npm ci`), so the
`package.json` range is the only guard against resolving a broken 3.9.x.
@chalin
chalin force-pushed the chalin-m24-lychee-cache-stats-2026-0626 branch from 7c489b6 to cedbae4 Compare June 29, 2026 14:13
chalin added 2 commits June 29, 2026 12:15
- maintainer-notes.md: add a "Link checking and the refcache" section
  documenting the lychee check, the committed .lycheecache, and the
  fix:refcache / refcache scripts.
- lychee.toml: fix a stale run-command in the header comment
  (check:links:lychee -> check:links).
- Replace private-notes pointers in the lychee config and test headers with
  a neutral, traceable reference (no private repo name).
- test.yaml: run the offline lychee sanity tests in CI (Linux-only, like
  ci:test), so --index-files / fragment regressions are caught without a
  full site build.
- refcache/index.mjs: drop the usage/flags block from the file header; it
  duplicated the USAGE string printed by --help. Keep only the non-obvious
  bits (read-only/no-network, the refcache line format).
- check/index.mjs: same — trim the header's usage line and the parts that
  restated USAGE, keeping the reuse and gh-token rationale; tighten two
  helper comments.
- README: collapse the usage examples to one per tool and point readers to
  `--help` (and `lychee --help` for forwarded flags) for the full options.
@chalin
chalin merged commit 56c2cf0 into docsy:main Jun 29, 2026
16 checks passed
@chalin
chalin deleted the chalin-m24-lychee-cache-stats-2026-0626 branch June 29, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant