Skip to content

feat: dprint upgrade downloads from npm - #1502

Merged
dsherret merged 3 commits into
mainfrom
feat/upgrade-from-npm
Dec 1, 2026
Merged

dsherret merged 3 commits into
mainfrom
feat/upgrade-from-npm

Conversation

@dsherret

@dsherret dsherret commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

dprint upgrade now downloads the executable from npm instead of getting the version from plugins.dprint.dev and the zip from GitHub, and is hardened in general. Replaces #1501, which verified a Sigstore bundle.

Downloading from npm:

  • Uses the @dprint/<platform> packages, which already exist for every release target. Published versions can't be replaced.
  • Uses the registry, credentials, and proxy in the user's ~/.npmrc (or the NPM_CONFIG_* environment variables). A project's .npmrc is never read, because a project must not choose where the executable comes from.
  • Respects min-release-age in ~/.npmrc and adds --minimum-dependency-age to override it.
  • DPRINT_ALLOWED_HOSTS applies to it, and only the registry (and where it serves tarballs from) needs to be allowed. Stacked on revert: "feat: dprint upgrade bypasses DPRINT_ALLOWED_HOSTS" #1503, which reverts the exemption.
  • Verifies the tarball against the registry's sha512 integrity, and only reads the executable from it.

Hardening:

  • The current executable is only replaced once the new one is written beside it and known to run. Previously, it was removed first on non-Windows, so a failure left no executable. Other dprint processes are now also only killed after that.
  • Only upgrades to newer versions, and the version must be strict semver.
  • Always requires https, including for redirects. Previously, this was only when DPRINT_ALLOWED_HOSTS was set.
  • Errors when DPRINT_IGNORE_CERTS is set.
  • Limits the size of what's downloaded and decompressed for upgrades.
  • Detects Homebrew under any prefix and resolves symlinks to the executable first.

Notes for reviewing

  • No new dependencies.
  • The integrity is from the same registry as the tarball, so this trusts the registry. Requiring provenance is left for a future PR.
  • Private registries that are only http, or that don't provide a sha512 integrity, don't work for upgrading.
  • The version check in --help still uses plugins.dprint.dev/cli.json, so it may mention a version that isn't on npm yet or that's newer than the minimum age allows.

Testing

  • Unit tests, including that every target in ci.ts maps to its package in deployment/npm/build.ts.
  • Manually built as 0.64.0 and upgraded to 0.65.0 from npm on Windows x64 and Linux x64, with killing other processes stubbed out.

@dsherret
dsherret changed the base branch from main to revert/upgrade-bypass-allowed-hosts December 1, 2026 01:34
@dsherret
dsherret force-pushed the feat/upgrade-from-npm branch from 0fdd2d6 to dbe9e3a Compare December 1, 2026 01:34
@dsherret
dsherret added this pull request to stack #1504 December 1, 2026 01:35
Base automatically changed from revert/upgrade-bypass-allowed-hosts to main December 1, 2026 01:35
@dsherret
dsherret force-pushed the feat/upgrade-from-npm branch from dbe9e3a to ce4c9d7 Compare December 1, 2026 01:35
@dsherret
dsherret merged commit 9bbdf68 into main Dec 1, 2026
5 checks passed
@dsherret
dsherret deleted the feat/upgrade-from-npm branch December 1, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant