chore: upgrade hosted-git-info to v10 - #215
Conversation
v4 dropped the string `browsetemplate` that repo-info.ts was string-replacing
into. Build the edit URL from the parsed host metadata instead, which keeps the
literal `{filepath}` placeholder intact -- the host's own `edit()`/`browse()`
helpers percent-encode the braces.
Generated URLs are unchanged for GitHub, GitLab and Bitbucket. Those three are
now an explicit whitelist rather than a fallback: `getTreePath` only knows their
two URL shapes, so every other host hosted-git-info can parse returns null
instead of a plausible looking but wrong URL. That covers gist, whose URL
previously came out as a broken `.../{project}{/committish}` with no
`{filepath}`, and sourcehut, which v9 newly parses.
v9 is the newest release whose engines (`^20.17.0 || >=22.9.0`) still fit inside
docfy's own `^20.19.0 || >=22.12.0`; v10 narrows to `^22.22.2 || ^24.15.0 ||
>=26.0.0` and would force an engines bump on consumers.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Follow-up on the v9 commit: the maintainer opted for v10 and the wider engines break it implies. All four published packages now declare `^22.22.2 || ^24.15.0 || >=26.0.0`, matching hosted-git-info's own range rather than depending on a package we do not support. They are kept in sync deliberately so a consumer installing @docfy/ember-cli on Node 20 gets a warning from every package, not just core. The docs previously justified the floor as "the Node versions that support require() of ES modules". That no longer explains the number — require(esm) landed in 20.19/22.12 — so getting-started and the upgrade guide now separate the two constraints instead of leaving a stale rationale attached to a new range. The upgrade guide states the break plainly: this drops Node 20 entirely and also 22.12 through 22.22. Behaviour re-verified against the original v3 baseline rather than against v9: all 16 GitHub/GitLab/Bitbucket URLs byte-identical, gist and sourcehut null. v10's host parsing is unchanged from v9, so the whitelist needed no changes. CI's `node-version: 24.x` already satisfies the range (resolves to 24.19.0) and is left untouched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Updated to v10 per maintainer decision, as an additional commit rather than a force-push so the v9 step stays reviewable.
Behaviour re-verified against the original v3 baseline rather than against v9, since v10 could have changed host parsing — it didn't. All 16 GitHub/GitLab/Bitbucket URLs byte-identical; gist and sourcehut CI's
|
The templates guard added in #214 flagged these: the committed .gjs templates are rendered from docs/, so editing the Node requirement prose changes them. Only the three pages whose text changed are affected, and the diff contains no editUrl changes — the worktree path segment that git-repo-info introduces when building from a linked worktree was stripped before committing, so these match what a clean checkout produces. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Answering whether the @types package is still needed now that we're on v10: it is not removable in favour of the package's own types, because hosted-git-info v10.1.1 ships none — no `types` field, no `.d.ts` anywhere in the tarball. And DefinitelyTyped never went past 3.0.5, so `@types/hosted-git-info` is now four majors behind and wrong where it matters: it declares the `*template` members as strings when they have been functions since v4, and its `Hosts` union does not know about hosts the current version parses. So rather than keep type-checking against a four-major-old contract, this declares only the five members repo-info.ts actually consumes — `fromUrl`, `type`, `domain`, `user`, `project` — and drops the devDependency. Nothing leaks into the public API: `getRepoEditUrl` returns `string | null`, and the emitted lib/-private/repo-info.d.ts makes no reference to GitHost, so consumers are unaffected. Verified the compiled output is byte-for-byte equivalent in behaviour: the URL probe produces output identical to the @types-based build, and still differs from the original v3 baseline only in the gist case. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Mirroring hosted-git-info's own `^22.22.2 || ^24.15.0 || >=26.0.0` meant Docfy declared support for LTS lines only, excluding Node 23 and all of Node 25. That made every `pnpm install` — including in this repo, which runs Node 25 — print an Unsupported engine warning from all four published packages. A plain `>=22.22.2` keeps the same practical floor without the noise. Verified: zero engine warnings on install now, and hosted-git-info does not start warning in its place — pnpm only reports engine mismatches for workspace projects, not for third-party dependencies. The docs rationale is updated rather than just having the number swapped. The previous wording said Docfy "matches" hosted-git-info's range rather than depending on a package it does not support, which is no longer what we do; getting-started now notes that the dependency expresses its range as a list of LTS lines and that Docfy deliberately uses `>=` instead. Templates regenerated for the changed docs prose, with the worktree path segment stripped — the diff contains no editUrl changes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Engines widened to Mirroring hosted-git-info's own Two things checked rather than assumed:
Also in this PR since the last update: Templates regenerated for the changed prose; the diff contains no |
Follow-up to #213, which deliberately left
hosted-git-infoat v3 because v4+ removedbrowsetemplatein favour of.edit()/.browse()— an unrelated refactor ofrepo-info.ts.Why v9 and not v10
Engines by major:
^18.17.0 || >=20.5.0^20.17.0 || >=22.9.0^22.22.2 || ^24.15.0 || >=26.0.0Docfy declares
^20.19.0 || >=22.12.0, which is a strict subset of v9's range. v10's range is narrower than docfy's, so adopting it would force an engines bump on every consumer — out of scope here.Why the URL is assembled by hand
Neither
.edit()nor.browse()can produce what Docfy needs. In v9 every*templateis a function, and both helpers percent-encode the path, which mangles the literal{filepath}placeholder Docfy substitutes later. On top of that, GitLab's.edit()emits-/editrather than the legacy/edit, and Bitbucket'sedittemplateemits only?mode=editwithout Docfy's&spa=0&at=…&fileviewer=…tail.So the URL is now built from the parsed host metadata (
repo.domain/repo.user/repo.project), which are still first-class properties onGitHost.getTreePathis untouched.Supported hosts are now an explicit whitelist
The first cut of this change imposed one URL shape on every host
hosted-git-infocan parse, which meant sourcehut got a plausible-looking but wrong edit URL where it previously got none.getTreePathonly knows two shapes — Bitbucket's, and the/edit/form GitHub and GitLab accept — so the three real ones are now listed explicitly and everything else returnsnull. No edit link beats a broken one, and this also means a futurehosted-git-inforelease that learns a new host can't silently produce garbage.Behaviour: verified, not asserted
Both implementations were compiled and run against an identical
rootargument (so git-root differences don't skew the comparison) over 10 input URLs × {default, custom branch}:usercomes back as"group/sub"), SSHgit@host:forms, and.gitsuffixes. The literal un-encoded{filepath}is preserved throughout.nullbefore,nullafter (the intermediate regression above was demonstrated and then closed).not-a-repo-url:nullbefore and after.One intentional change:
https://gist.github.com/…https://gist.github.com/…{/committish}nullThe old value was an artifact of naive string substitution — gist's
browsetemplatehas no{/tree/committish}token, so nothing was replaced, leaving a literal{/committish}and no{filepath}at all. It was never a usable edit URL and no test covers it.Known follow-up
@types/hosted-git-infostays at^3.0.5— DefinitelyTyped never published typings for v4+ and v9 ships none. The stale package still describes the five members actually used (fromUrl,type,domain,user,project) correctly, but is wrong about*templatebeing astringand itsHostsunion doesn't knowsourcehutexists. There's a comment at the import saying so. The clean fix is dropping the@typesdependency for a small hand-written ambient declaration; left out as scope creep.Also worth knowing: GitLab keeps the legacy
/edit/path rather than/-/edit/, per the no-URL-change constraint. Worth revisiting if GitLab ever drops the redirect.Verification
pnpm -r run compileclean;@docfy/ember-vite60/60;@docfy/plugin-with-prose2/2; eslint clean.@docfy/coreshows 6 failures which are the known worktree-only ones (git-repo-inforeports a root containing the worktree path) — every failure differs from expected by nothing but that path prefix, and #213's CI run confirms they pass on a normal checkout.🤖 Generated with Claude Code