Repository navigation
fix(registry): pick another version when the locked one left the registry, and refuse links - #380
Merged
Merged
Conversation
…stry A locked version the registry no longer has made every package operation fail with a TypeError on `versions.find(...)!`. The lock is now kept only when the registry still has that version, otherwise the newest version that fits is taken, and a missing entry throws a RegistryError naming the package and version. Closes NanoForge-dev/Editor#254
A linked nf_modules, scope or package folder made restore remove, and install write, files outside the project: a cloned project could link nf_modules/@evil to the user's home and have restore empty it. Restore and every install, update and uninstall now lstat nf_modules, its scopes and their entries first, and refuse with a RegistryError (INVALID) when one is a link or junction. Refs NanoForge-dev/Editor#248
…ugh it Install and restore wrote the paths of the packages with a plain writeFile, which follows a linked tsconfig.json out of the project. It is now written like the list and the lock: a temporary file renamed over it, which replaces the link. The unreachable NOT_FOUND guard on a missing registry entry gets a note, and the install docs say nf_modules links are refused. Refs NanoForge-dev/Editor#248
The list, the lock and tsconfig.json were read through a symbolic link, which copies JSON from outside the project into it. They are now refused like the links in nf_modules. writeAtomically creates its temporary file exclusively (wx), and the rollback of the list and the lock writes them atomically too, never through a link. Refs NanoForge-dev/Editor#248
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.
What does this PR do?
Closes NanoForge-dev/Editor#254
Refs NanoForge-dev/Editor#248
Two fixes in
@nanoforge-dev/registry(libs/registry):TypeErroronversions.find(...)!. The lock is now kept only when the registry still has that version; otherwise the newest version that fits is taken. A missing entry throws aRegistryError(NOT_FOUND) naming the package and version.RegistryError(INVALID), a symbolic link or junction asnf_modules, one of its scopes or entries,nanoforge.packages.json,nanoforge.packages.lock.jsonortsconfig.json.assertNoLinks/assertNotLink(modules-folder.ts) run at the start ofrestore(), in_applybefore any write or removal, and in the read helpers of the list, the lock andtsconfig.json.writeAtomicallycreates its temporary file exclusively (wx), and the rollback of the list and the lock writes them atomically too.docs/docs/commands/install.mdxsaysnf installrefuses these links.The editor's own checks (NanoForge-dev/Editor fix/registry-trust-gate (NanoForge-dev/Editor#386)) are what settle NanoForge-dev/Editor#248, because the editor still ships registry 3.0.1. This PR is the lib side of it.
How do you test this PR?
libs/registry/test/registry.spec.ts)TypeError: Cannot read properties of undefined (reading 'sha256')nf_moduleson restore, linked scope on install, linked package folder (4 tests)INVALIDFirst run: 5 failed, 10 passed before the fix. Registry lib on the final code: 58 passed, 0 skipped. The links are made as junctions so the folder tests also run on Windows CI without symlink rights; the linked
tsconfig.jsoncase needs a file symlink (not checked on a Windows runner).Commands run from the worktree:
pnpm repo:build,pnpm repo:lint,pnpm repo:test:unit,pnpm build,pnpm lint,pnpm test:unit(345 passed): all pass. After the last docs commit (0ea19b2):pnpm lint,pnpm repo:lint.Merge danger
@nanoforge-dev/registry, used bynf installand, after a catalog bump, by the editor (code, project, protocol, server-core, settings, runtime, ui).npm link-style link innf_modulesis now refused.list()andoutdated()also refuse a linked list or lock. A locked version that left the registry is replaced by the newest one that fits, without a warning yet (Warn when install replaces a locked version that left the registry #372).Follow-up issues
Quality gate
docs/docs/commands/install.mdx(250a11b, 0ea19b2)wx, the rollback write), fixed in f78acb3Last round f78acb3 and 0ea19b2: producer red→green, not re-reviewed.