Files
pnpm/installing/commands/package.json
Zoltan Kochan c112b6106b feat(install): add --dry-run option (npm-style preview) (#12449)
## Description

Adds a `--dry-run` option to `pnpm install` with **npm-style preview semantics**: it runs a full dependency resolution and reports what a real install **would** add/remove/update, but writes **nothing** to disk (no lockfile, no `node_modules`, no `.modules.yaml`, no workspace-state file) and **always exits 0**.

```
$ pnpm install --dry-run
Dry run complete. A real install would make the following changes (nothing was written to disk):

Importers
.
  + is-negative 1.0.0

Packages
+ is-negative@1.0.0
```

When the lockfile is already up to date it prints `Dry run complete. pnpm-lock.yaml is up to date; a real install would make no changes.`

Resolves https://github.com/pnpm/pnpm/issues/7340.

### Why this shape

An earlier attempt (#12270, now closed) implemented `--dry-run` as `--frozen-lockfile --lockfile-only` — i.e. a fail-on-drift *lockfile validator*. That collides with the well-established meaning of `--dry-run` across npm/yarn ("preview, never fail") and duplicated existing behaviour (`pnpm install --frozen-lockfile --lockfile-only` already does that). This PR implements the intuitive preview meaning instead.

### How it works (pnpm)

- Reuses the existing `lockfileCheck` callback (resolve fully, skip the lockfile write, hand back the before/after wanted lockfile) plus `lockfileOnly` (skip `node_modules`, the workspace-state file, and metadata-cache writes).
- The frozen/headless fast path is disabled whenever `lockfileCheck` is set, so a check-only install always resolves and never materialises anything.
- The before/after lockfiles are diffed (reusing the dedupe diff engine, now exported as `calcDedupeCheckIssues`) and rendered into the report.
- `--dry-run` with a configured pnpr server is rejected (that path resolves/links through the server).

### Pacquet

Ported in the second commit — `pacquet install --dry-run` forces the fresh-resolve path, skips every write (a new `dry_run` flag on `InstallWithFreshLockfile` skips the `pnpm-lock.yaml` save), and a new `dry_run` module diffs the existing lockfile against the freshly-resolved one and prints the same report.
2026-06-16 19:12:56 +02:00

145 lines
5.2 KiB
JSON

{
"name": "@pnpm/installing.commands",
"version": "1100.9.0",
"description": "Commands for installation",
"keywords": [
"pnpm",
"pnpm11"
],
"license": "MIT",
"funding": "https://opencollective.com/pnpm",
"repository": "https://github.com/pnpm/pnpm/tree/main/installing/commands",
"homepage": "https://github.com/pnpm/pnpm/tree/main/installing/commands#readme",
"bugs": {
"url": "https://github.com/pnpm/pnpm/issues"
},
"type": "module",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"exports": {
".": "./lib/index.js"
},
"files": [
"lib",
"!*.map"
],
"scripts": {
"start": "tsgo --watch",
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
"test": "pn compile && pn .test",
"prepublishOnly": "tsgo --build",
"compile": "tsgo --build && pn lint --fix",
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
},
"dependencies": {
"@inquirer/prompts": "catalog:",
"@pnpm/building.after-install": "workspace:*",
"@pnpm/building.policy": "workspace:*",
"@pnpm/catalogs.config": "workspace:*",
"@pnpm/catalogs.types": "workspace:*",
"@pnpm/cli.command": "workspace:*",
"@pnpm/cli.common-cli-options-help": "workspace:*",
"@pnpm/cli.utils": "workspace:*",
"@pnpm/colorize-semver-diff": "catalog:",
"@pnpm/config.matcher": "workspace:*",
"@pnpm/config.pick-registry-for-package": "workspace:*",
"@pnpm/config.reader": "workspace:*",
"@pnpm/config.writer": "workspace:*",
"@pnpm/constants": "workspace:*",
"@pnpm/deps.inspection.outdated": "workspace:*",
"@pnpm/deps.path": "workspace:*",
"@pnpm/deps.security.signatures": "workspace:*",
"@pnpm/deps.status": "workspace:*",
"@pnpm/error": "workspace:*",
"@pnpm/fs.graceful-fs": "workspace:*",
"@pnpm/fs.read-modules-dir": "workspace:*",
"@pnpm/global.commands": "workspace:*",
"@pnpm/hooks.pnpmfile": "workspace:*",
"@pnpm/installing.context": "workspace:*",
"@pnpm/installing.dedupe.check": "workspace:*",
"@pnpm/installing.dedupe.issues-renderer": "workspace:*",
"@pnpm/installing.deps-installer": "workspace:*",
"@pnpm/installing.env-installer": "workspace:*",
"@pnpm/lockfile.fs": "workspace:*",
"@pnpm/lockfile.types": "workspace:*",
"@pnpm/network.auth-header": "workspace:*",
"@pnpm/network.fetch": "workspace:*",
"@pnpm/pkg-manifest.reader": "workspace:*",
"@pnpm/pkg-manifest.utils": "workspace:*",
"@pnpm/resolving.npm-resolver": "workspace:*",
"@pnpm/resolving.parse-wanted-dependency": "workspace:*",
"@pnpm/resolving.resolver-base": "workspace:*",
"@pnpm/semver-diff": "catalog:",
"@pnpm/store.connection-manager": "workspace:*",
"@pnpm/store.controller": "workspace:*",
"@pnpm/types": "workspace:*",
"@pnpm/util.lex-comparator": "catalog:",
"@pnpm/workspace.project-manifest-reader": "workspace:*",
"@pnpm/workspace.project-manifest-writer": "workspace:*",
"@pnpm/workspace.projects-filter": "workspace:*",
"@pnpm/workspace.projects-graph": "workspace:*",
"@pnpm/workspace.projects-reader": "workspace:*",
"@pnpm/workspace.projects-sorter": "workspace:*",
"@pnpm/workspace.root-finder": "workspace:*",
"@pnpm/workspace.state": "workspace:*",
"@pnpm/workspace.workspace-manifest-writer": "workspace:*",
"@yarnpkg/core": "catalog:",
"@yarnpkg/lockfile": "catalog:",
"@yarnpkg/parsers": "catalog:",
"@zkochan/rimraf": "catalog:",
"@zkochan/table": "catalog:",
"chalk": "catalog:",
"ci-info": "catalog:",
"detect-libc": "catalog:",
"get-npm-tarball-url": "catalog:",
"is-subdir": "catalog:",
"load-json-file": "catalog:",
"normalize-path": "catalog:",
"p-filter": "catalog:",
"p-limit": "catalog:",
"ramda": "catalog:",
"render-help": "catalog:",
"version-selector-type": "catalog:"
},
"peerDependencies": {
"@pnpm/logger": "catalog:"
},
"devDependencies": {
"@jest/globals": "catalog:",
"@pnpm/assert-project": "workspace:*",
"@pnpm/installing.commands": "workspace:*",
"@pnpm/installing.modules-yaml": "workspace:*",
"@pnpm/logger": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/store.index": "workspace:*",
"@pnpm/test-fixtures": "workspace:*",
"@pnpm/test-ipc-server": "workspace:*",
"@pnpm/testing.command-defaults": "workspace:*",
"@pnpm/testing.mock-agent": "workspace:*",
"@pnpm/testing.registry-mock": "workspace:*",
"@pnpm/worker": "workspace:*",
"@pnpm/workspace.projects-filter": "workspace:*",
"@types/normalize-path": "catalog:",
"@types/proxyquire": "catalog:",
"@types/ramda": "catalog:",
"@types/yarnpkg__lockfile": "catalog:",
"@types/zkochan__table": "catalog:",
"delay": "catalog:",
"jest-diff": "catalog:",
"path-name": "catalog:",
"proxyquire": "catalog:",
"read-yaml-file": "catalog:",
"symlink-dir": "catalog:",
"tempy": "catalog:",
"write-json-file": "catalog:",
"write-package": "catalog:",
"write-yaml-file": "catalog:"
},
"engines": {
"node": ">=22.13"
},
"jest": {
"preset": "@pnpm/jest-config/with-registry"
}
}