Repository navigation
Closed
Description
In short
harnesspm checkdecides what the docs are from git and the disk, not from whatnpm packships.- So
"prepack": "build-docs && harnesspm check"can pass while the package ships dead links. - Seen on 0.8.0. The code on
main(0.9.0) is the same:docsFiles()and the link loop insrc/check.ts.
What happens
Three cases pass check but ship broken docs:
| Case | Why check misses it | Spec |
|---|---|---|
1. A page built at prepack into a docs folder that also holds tracked files. git ignores the built pages, not the folder. |
docsFiles() keeps only what gitKeeps() keeps, so check never reads the built pages, which are exactly the ones that ship (npm packs by files, not .gitignore). |
2.7 rule 5 leaves ignored files out of check. 2.10 says check runs at prepack. Together, they check nothing of a built docs folder. |
2. A doc links to a file that exists in the repository but is not in files, such as ../src/x.ts. |
The link check tests fs.existsSync() only. |
2.10: check fails when "a link in a rule, skill or doc points at a file that will not be published". |
3. An .mdx page has a dead link. |
The link loop skips every file that does not end with .md. |
2.7 indexes .md and .mdx pages alike. |
Reproduction
mkdir demo && cd demo && git init -q
mkdir -p harness docs/rules src
echo '{"name":"demo","version":"1.0.0","files":["harness","docs/*.md"]}' > package.json
echo '{"$schema":"https://agent-plugins.org/schemas/1.0.0/plugin.schema.json","name":"demo","extensions":{"dev.harnesspm":{"docs":"../docs"}}}' > harness/plugin.json
printf '# Rules\n\nInternal.\n' > docs/rules/internal.md
echo 'export {}' > src/x.ts
printf 'docs/*.md\n' > .gitignore
printf '# Built\n\nSee [nothing](./nope.md).\n' > docs/built.md # case 1: built at prepack, ignored
git add -A && git commit -qm init
npx -y @tenphi/[email protected] check . # ✅ harness is valid
npm pack --dry-run # ships docs/built.md, with its dead link
printf '# Tracked\n\nSee [code](../src/x.ts).\n' > docs/tracked.md # case 2
printf -- '---\ntitle: X\n---\n\nSee [gone](./gone.md).\n' > docs/page.mdx # case 3
printf '!docs/tracked.md\n!docs/page.mdx\n' >> .gitignore
git add -A && git commit -qm more
npx -y @tenphi/[email protected] check . # ✅ harness is validWhere we met it
cube-js/cube-ui-kit#1697 makes @cube-dev/ui-kit build its docs into docs/ at prepack, next to its tracked docs/rules/, and points docs at ../docs. Its prepack runs harnesspm check after the build, and that check reads only docs/rules/. The workaround is to run harnesspm check <extracted tarball> in a package test, where no .gitignore applies.
Proposal
- For
check, take the docs pages and link targets from what npm would pack, such asnpm pack --dry-run --json, orfilesread with npm's rules, instead of git and the disk. Keep rule 5 for the index and the lock, where it keeps machine-local files out. - Check links in
.mdxpages too. - Spec: say in 2.7 rule 5 and 2.10 that check judges docs by the tarball.
Metadata
Metadata
Assignees
Labels
No labels
Activity