fix: build package manifests at pack time so releases actually publish - #35
Merged
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Releases silently no-op'd:
lerna publishreportedPackage is already published: latex2js@4.2.0for every package, yet npm is still servinglatex2js@4.0.8,@latex2js/utils@4.0.4, etc. Only@mathapedia/csswent out.Cause: every TS package publishes from
dist/(publishConfig.directory), sodist/package.jsonis the published manifest — but it was only rewritten by an explicitly-invokedtools/write-dist-manifest.mjs. Afterlerna versionbumped the package-root versions, thedist/manifests still held the previous version, so lerna packed and pushed tarballs for versions that already existed on npm, and npm's 403 surfaced as the misleading "already published" warning.@mathapedia/csswas immune precisely because it's the one package that publishes from its root.Fix: adopt the constructive/dev-utils convention — the manifest is produced by the build, and the build runs at pack time, so it can never be stale:
Notes on the two non-obvious pieces:
makage buildis deliberately not used. It isclean + build-ts + assets + check-publish, and that last step rejects anyworkspace:spec indist/package.json— which is the correct state after an ordinary local build, since lerna rewritesworkspace:^into concrete ranges in the package-root manifest only immediately before packing. Composing the sub-commands keepspnpm buildgreen, andprepackputscheck-publishwhere the specs are resolved, turning it into a real guard that a tarball can never ship an unresolvableworkspace:^dependency.prepackrunsmakage clean, which deletesdist/. Safe because lerna 8's publish packs viatopoMapPackages→runProjectsTopologically: a dependent is never packed until its local dependencies finish, so nothing reads a sibling'sdist/while it's being rebuilt.Package-specific build steps are preserved (latex2js grammar + css copies + bundle css, html5's
build-bundle.mjs --dist, vue's component copies).packages/csskeeps publishing from its root and loses itsprepack, since itsbuildwrites into../latex2js— a side effect that has no business firing during a pack.Also:
tools/check-dist-manifests.mjsasserts, for everydirectory: "dist"package, thatdist/package.jsonexists, its version matches the package root, andmain/module/typesresolve insidedist— wired into CI right afterpnpm buildso this class of bug fails a PR instead of a release.lerna.jsongains the registry, package globs,syncWorkspaceLock,allowBranch: mainand conventional commits; lerna8.2.3→8.2.4; rootworkspacesnow matchespnpm-workspace.yaml(the oldwebsite/*,examples/*entries don't exist);PUBLISHING.mdrewritten to drop the now-unnecessary manual build step.The
pnpm-lock.yamldiff is large mostly because pnpm 11.15.1 (the declaredpackageManager) reserializes the file — quote style and blank lines. The semantic changes are lerna 8.2.4,makage@0.6.0added,copyfiles/rimrafdropped.Verification
pnpm install,pnpm build(12 targets),pnpm test(36 suites / 589 tests), the manifest guard, and grammar/bundle no-drift checks all pass on Node 22 + pnpm 11.15.1. Alerna publishrehearsal against a dead registry ran every package'sprepack— each reportedcheck-publish: dist/package.json OK — no workspace: protocols found— and failed only at the intendedECONNREFUSED. Planting a stale version and aworkspace:^spec in a dist manifest was confirmed to be corrected and rejected respectively.No versions or tags are touched here. Note for the next release: npm won't allow reusing the already-tagged 4.2.0/4.3.0/4.1.0 versions, so
lerna versionwill need to bump past them.Link to Devin session: https://app.devin.ai/sessions/e51e8ecb94d241bd8d89e65e642c3e43
Requested by: @pyramation