Commit dcae79f
fix(create): read org manifest from the tarball when the registry strips createConfig (#2063)
Fixes #2062 (thanks @fengmk2 for the invitation to contribute the fix).
## Problem
`vp create @org:name` resolves the org template catalog by fetching the
registry packument and reading `versions[x].createConfig`. Some
registries — GitHub Packages among them — store only the package.json
fields the npm CLI requires, so custom fields like `createConfig` are
**absent from packument version metadata** even though the published
tarball preserves the full package.json byte-for-byte. (Per the [npm
registry
spec](https://github.com/npm/registry/blob/main/docs/responses/package-metadata.md),
full version objects *should* carry all publisher fields — npmjs.org
does — but alternative registries demonstrably don't; the same behavior
was hit by Renovate's npm-hosted presets in
[renovate#8266](renovatebot/renovate#8266),
where GitHub Support confirmed "only the fields required by the NPM CLI
are stored".)
Result: `No \`createConfig.templates\` manifest in @org/create —
\`@org:name\` requires one.` for any org package hosted on such a
registry, no matter how it was published.
## Fix
When the resolved packument version metadata lacks `createConfig`
**entirely** (as opposed to present-but-empty) and advertises
`dist.tarball`, download the tarball and read `createConfig` from its
`package.json` — the one artifact every registry preserves verbatim. New
`readPackageJsonFromTarball` helper in `org-tarball.ts` reuses the
existing `downloadTarball` (streaming + 50 MB cap + auth via
`fetchNpmResource`), `verifyIntegrity`, `parseTarGzip`, and
`normalizeEntryName` (so only the root `package/package.json` matches).
Behavior is unchanged everywhere else:
- packument carries the field → fast path, no extra request (asserted by
a test)
- 404s, `requestedVersion` resolution → unchanged
- `createConfig` present but `templates: []` → still "no manifest",
**no** fallback fetch
- malformed manifests (packument *or* tarball) → still
`OrgManifestSchemaError`
Known trade-off: in the fallback path the tarball can be downloaded
twice (once for the manifest read, once later by
`ensureOrgPackageExtracted` for bundled entries — which has its own
on-disk cache). Kept the diff minimal; happy to thread the bytes into
the extraction cache in this PR or a follow-up if you prefer.
## Validation
- Unit: 3 new tests in `org-manifest.spec.ts` (fallback success with a
real in-test `nanotar.createTarGzip` fixture and matching sha512
integrity; both-sources-missing → null; fast-path fetch-count
assertion); full spec 39/39, package unit suite green, `tsgo` clean, `vp
fmt --check` clean.
- End-to-end: replayed a **real GitHub Packages packument + tarball
pair** (captured from a live scoped package that exhibits the stripping)
through a local registry stub: the release CLI reproduces the failure;
this branch scaffolds successfully, with the tarball's original `sha512`
integrity verified.
- Snap tests: no diffs from this change (`create-generator-monorepo`
timed out in my local environment — its path doesn't involve the
org-manifest code; expecting CI to confirm).
Two adjacent issues from #2062 are intentionally **not** addressed here
to keep the diff focused: the unauthenticated-first fetch not retrying
on 404 (some registries 404 unauthenticated metadata), and the error
message conflating not-found / auth-gated / field-stripped. Happy to
follow up on either.
---------
Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>1 parent a6aafc3 commit dcae79f
3 files changed
Lines changed: 149 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
1 | 4 | | |
2 | 5 | | |
3 | 6 | | |
| |||
138 | 141 | | |
139 | 142 | | |
140 | 143 | | |
| 144 | + | |
| 145 | + | |
141 | 146 | | |
142 | 147 | | |
143 | 148 | | |
| |||
150 | 155 | | |
151 | 156 | | |
152 | 157 | | |
153 | | - | |
| 158 | + | |
154 | 159 | | |
155 | 160 | | |
156 | 161 | | |
| |||
171 | 176 | | |
172 | 177 | | |
173 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
174 | 210 | | |
175 | 211 | | |
176 | 212 | | |
| |||
181 | 217 | | |
182 | 218 | | |
183 | 219 | | |
184 | | - | |
185 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
186 | 278 | | |
187 | 279 | | |
188 | 280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
291 | 292 | | |
292 | 293 | | |
293 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
294 | 300 | | |
295 | 301 | | |
296 | 302 | | |
| |||
331 | 337 | | |
332 | 338 | | |
333 | 339 | | |
334 | | - | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
335 | 356 | | |
336 | 357 | | |
337 | 358 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
119 | 151 | | |
120 | 152 | | |
121 | 153 | | |
| |||
0 commit comments