Skip to content

check: docs built at prepack go unchecked, and links to files the tarball leaves out pass #52

Closed

Description

@tenphi

In short

  • harnesspm check decides what the docs are from git and the disk, not from what npm pack ships.
  • 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 in src/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 valid

Where 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 as npm pack --dry-run --json, or files read 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 .mdx pages too.
  • Spec: say in 2.7 rule 5 and 2.10 that check judges docs by the tarball.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions