pnpm-settings-migrator 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -20
- package/dist/cli.mjs +1986 -1378
- package/dist/index.d.mts +317 -63
- package/dist/index.mjs +1977 -1570
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -19,7 +19,8 @@ After migration, the CLI reports how many root settings changed and shows a
|
|
|
19
19
|
GitHub-style YAML diff. Removed lines are red and added lines are green:
|
|
20
20
|
|
|
21
21
|
```text
|
|
22
|
-
|
|
22
|
+
✔ 2 settings changed
|
|
23
|
+
|
|
23
24
|
packages:
|
|
24
25
|
- packages/*
|
|
25
26
|
+ - apps/*
|
|
@@ -29,6 +30,40 @@ GitHub-style YAML diff. Removed lines are red and added lines are green:
|
|
|
29
30
|
+ bar: 2.0.0
|
|
30
31
|
```
|
|
31
32
|
|
|
33
|
+
When nothing needs updating, the only output is:
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
ℹ No changes needed.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The CLI no longer prints a startup banner, missing optional files, a zero-change
|
|
40
|
+
count, or a duplicate completion message. Use `--version` to see the version.
|
|
41
|
+
Warnings are reserved for settings requiring attention. Information blocks have
|
|
42
|
+
one blank line between them, with no extra blank lines at the start or end.
|
|
43
|
+
|
|
44
|
+
Other outcomes are reported according to the files actually changed:
|
|
45
|
+
|
|
46
|
+
- No configuration files: `ℹ No configuration files found.`
|
|
47
|
+
- Source cleanup with no settings diff: `✔ Migration completed. Source settings cleaned up.`
|
|
48
|
+
- Runtime migration with no settings diff: `✔ Migration completed. Node.js runtime updated in package.json.`
|
|
49
|
+
- File formatting changes with no settings diff: `✔ Migration completed. Configuration files updated.`
|
|
50
|
+
- Failure: one error report and exit code `1`.
|
|
51
|
+
|
|
52
|
+
## Library usage
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { migratePnpmSettings } from 'pnpm-settings-migrator'
|
|
56
|
+
|
|
57
|
+
const result = await migratePnpmSettings({ cwd: '/path/to/workspace' })
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Library calls now return a `MigrationResult` and do not print logs. The result
|
|
61
|
+
contains `settingsChanges` (before/after root workspace settings), `changedFiles`
|
|
62
|
+
(absolute paths, including created or removed files), `sourceSettingsCleaned`,
|
|
63
|
+
`packageJsonRuntimeChanged`, `hasConfigurationFiles`, and `warnings`. Errors are
|
|
64
|
+
thrown to the caller. Consumers that relied on console output should render the
|
|
65
|
+
returned changes and warnings themselves.
|
|
66
|
+
|
|
32
67
|
## CLI Options
|
|
33
68
|
|
|
34
69
|
### `--cwd`
|
|
@@ -50,19 +85,52 @@ Sort keys when write `pnpm-workspace.yaml`.
|
|
|
50
85
|
- **Type**: `'auto' | 'v10' | 'v11' | 'v12'`
|
|
51
86
|
- **Default**: `'auto'`
|
|
52
87
|
|
|
53
|
-
Compatibility
|
|
88
|
+
Compatibility major for migrated settings:
|
|
89
|
+
|
|
90
|
+
- `auto`: infer from `targetVersion`, `packageManager`, or
|
|
91
|
+
`devEngines.packageManager` (`pnpm@12+` => `v12`, `pnpm@11` => `v11`,
|
|
92
|
+
otherwise `v10`).
|
|
93
|
+
- `v10`: keep legacy settings and migrate schema-aligned pnpm config keys from `.npmrc`.
|
|
94
|
+
- `v11`: normalize to v11-compatible settings (`allowBuilds`, `allowUnusedPatches`, etc.).
|
|
95
|
+
- `v12`: use the v12 schema, including `globalShims`, and enable additional
|
|
96
|
+
fields according to the confirmed target version.
|
|
54
97
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
and migrate recognized project settings from `.npmrc` to `pnpm-workspace.yaml`
|
|
60
|
-
- `v12`: use the shared v11 schema plus the v12 delta, including
|
|
61
|
-
`globalShims`, while rejecting v11-only workspace settings.
|
|
98
|
+
An explicit major still uses a matching version from the project declarations.
|
|
99
|
+
For example, `--compatibility v12` with `packageManager: "pnpm@12.4.0"` enables
|
|
100
|
+
12.4 capabilities. A pin to another major supplies no minor capabilities for
|
|
101
|
+
the selected major; use `--target-version` to state the intended release.
|
|
62
102
|
|
|
63
103
|
In `v11` and `v12` modes, the migrator validates existing workspace keys,
|
|
64
|
-
filters incoming settings against the
|
|
65
|
-
normalization to legacy files and `pnpm-workspace.yaml`.
|
|
104
|
+
filters incoming settings against the resolved capabilities, and applies
|
|
105
|
+
required normalization to legacy files and `pnpm-workspace.yaml`.
|
|
106
|
+
|
|
107
|
+
### `--target-version`
|
|
108
|
+
|
|
109
|
+
- **Type**: `string` (an exact version such as `'12.4.0'`)
|
|
110
|
+
- **Default**: inferred from the project when possible
|
|
111
|
+
|
|
112
|
+
Override the target pnpm version without changing the project's package manager
|
|
113
|
+
pin. Resolution order is explicit `targetVersion`, then `packageManager`, then
|
|
114
|
+
`devEngines.packageManager`. An explicit `compatibility` major must agree with
|
|
115
|
+
`targetVersion`; conflicts fail before any files are written.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
await migratePnpmSettings() // Infer the target from the project
|
|
119
|
+
await migratePnpmSettings({ compatibility: 'v12' }) // Infer a matching minor
|
|
120
|
+
await migratePnpmSettings({ targetVersion: '12.4.0' }) // Target this exact release
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Version ranges are not accepted by `targetVersion`. Project ranges, conflicting
|
|
124
|
+
`devEngines` entries, prereleases, and declarations without a confirmed matching
|
|
125
|
+
version retain the base major schema. Build metadata on exact stable versions
|
|
126
|
+
is accepted. Later stable minors automatically inherit known capabilities;
|
|
127
|
+
there are no minor-specific compatibility options.
|
|
128
|
+
|
|
129
|
+
For pnpm 12.4.0 and later stable v12 releases, the migrator additionally accepts
|
|
130
|
+
`trustPolicyExcludePrune`, `python`, `cargo`, `pipelines`, `pipelineBase`, and
|
|
131
|
+
`packageConfigs`, plus task fields `outputs`, `inputs`, `env`, `cache`, and
|
|
132
|
+
`cargoTargetDir`. On older or unconfirmed targets, a `tasks` object containing
|
|
133
|
+
these fields stays in its source as a whole.
|
|
66
134
|
|
|
67
135
|
Automated v10 to v11 conversions include:
|
|
68
136
|
|
|
@@ -81,20 +149,41 @@ Automated v10 to v11 conversions include:
|
|
|
81
149
|
Notes:
|
|
82
150
|
|
|
83
151
|
- `.npmrc` migration is aligned with the target pnpm workspace schema. Unknown
|
|
84
|
-
keys and settings supported only by a different pnpm
|
|
152
|
+
keys and settings supported only by a different pnpm version stay in `.npmrc`
|
|
85
153
|
with a warning.
|
|
86
154
|
- In `v11` and `v12`, auth/registry keys and project-refused machine settings
|
|
87
155
|
such as `globalDir`, `stateDir`, `configDir`, and `scope` stay in `.npmrc`.
|
|
88
156
|
- Registry declarations containing embedded credentials or dynamic `${...}`
|
|
89
157
|
URLs stay in their source with a warning.
|
|
90
|
-
-
|
|
91
|
-
`
|
|
92
|
-
|
|
93
|
-
|
|
158
|
+
- Dynamic `${...}` values in `httpProxy`, `httpsProxy`, `noProxy`, `proxy`, and
|
|
159
|
+
`noproxy` stay in their source for every target. Project YAML does not expand
|
|
160
|
+
these placeholders; configure them globally in trusted configuration or use
|
|
161
|
+
environment variables. Existing dynamic proxy settings in YAML block migration.
|
|
162
|
+
The migrator never expands and writes these values.
|
|
163
|
+
- pnpm v11 and confirmed stable v12 targets from 12.4.0 accept `packageConfigs`
|
|
164
|
+
as package-name maps or matcher arrays, with `hoist`, `modulesDir`,
|
|
165
|
+
`overrides`, `saveExact`, and `savePrefix`. Supported subproject `.npmrc`
|
|
166
|
+
fields are moved there by package name. pnpm 12.0–12.3 does not support
|
|
167
|
+
`packageConfigs`.
|
|
168
|
+
- For v12 targets from 12.4.0, migrating `packageConfigs` or subproject settings
|
|
169
|
+
requires `sharedWorkspaceLockfile: false` in the merged workspace. Otherwise
|
|
170
|
+
source settings remain with a warning; existing `packageConfigs` blocks
|
|
171
|
+
migration until the effective lockfile mode is compatible. This restriction
|
|
172
|
+
does not apply to v11. The migrator does not change this mode automatically.
|
|
94
173
|
- Cleanup removes only source keys represented in the final workspace after
|
|
95
174
|
applying the selected merge strategy.
|
|
175
|
+
Each source is checked against its own values, including deprecated-key
|
|
176
|
+
replacements. Conflicting values in `.npmrc`, `package.json#pnpm`, or Yarn
|
|
177
|
+
resolutions remain in their original source.
|
|
96
178
|
Unrecognized, refused, incompatible, or otherwise unsupported
|
|
97
179
|
`package.json#pnpm` child keys remain in `package.json`.
|
|
180
|
+
- Runtime migration writes `devEngines.runtime` before removing a workspace
|
|
181
|
+
runtime declaration. A failed write preserves source settings for retry.
|
|
182
|
+
If an existing runtime declaration conflicts with a workspace runtime, migration
|
|
183
|
+
stops before writing any files. An identical Node.js declaration is reused.
|
|
184
|
+
- YAML aliases remain when their anchors are unchanged and precede them.
|
|
185
|
+
If replacement, removal, or sorting would invalidate an alias, its original
|
|
186
|
+
value is written explicitly so unrelated settings keep their values.
|
|
98
187
|
- If no auth/registry lines remain after a v11 or v12 migration, the empty
|
|
99
188
|
`.npmrc` is removed.
|
|
100
189
|
- Values moved from `auditConfig.ignoreCves` still contain CVE IDs. Replace them
|
|
@@ -102,11 +191,30 @@ Notes:
|
|
|
102
191
|
- The migrator does not update the `packageManager` version, CI environment variables,
|
|
103
192
|
shell setup, or pnpm commands in scripts. When `packageManager` still pins pnpm 10,
|
|
104
193
|
pass `--compatibility v11` explicitly and update the pin separately.
|
|
105
|
-
-
|
|
106
|
-
|
|
194
|
+
- Compatibility checks cover pnpm 11.26.0, 12.3.4, and 12.4.0, retaining
|
|
195
|
+
11.25.0 and 12.2.1 regressions. As audited on 2026-09-10, 12.3.4 is npm
|
|
196
|
+
`latest` and 12.4.0 is on `next-12`; the project stays pinned to 12.3.4. Its removed `pnpm install --resolution-only` CLI
|
|
107
197
|
flag is outside this settings migrator's scope; replace it with
|
|
108
198
|
`pnpm peers check` in scripts before upgrading.
|
|
109
199
|
|
|
200
|
+
For example, `--target-version 12.4.0` migrates this legacy configuration:
|
|
201
|
+
|
|
202
|
+
```json
|
|
203
|
+
{ "pnpm": { "pipelines": { "ci": ["build", "test"] }, "pipelineBase": "main" } }
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
into `pnpm-workspace.yaml` and removes the applied `pnpm` keys:
|
|
207
|
+
|
|
208
|
+
```yaml
|
|
209
|
+
pipelines:
|
|
210
|
+
ci: [build, test]
|
|
211
|
+
pipelineBase: main
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
With `--target-version 12.3.4`, these settings remain in `package.json` with an
|
|
215
|
+
incompatibility warning. See the [version audit](docs/research/pnpm-recent-settings-audit-2026-09-10.md)
|
|
216
|
+
for the upstream release and schema references.
|
|
217
|
+
|
|
110
218
|
### `--replace-deprecated`
|
|
111
219
|
|
|
112
220
|
- **Type**: `boolean`
|
|
@@ -144,13 +252,29 @@ Strategy to handle conflicts when merging settings with existing `pnpm-workspace
|
|
|
144
252
|
|
|
145
253
|
Disable migrating `resolutions` field in `package.json`.
|
|
146
254
|
|
|
255
|
+
By default, plain package names are copied to pnpm overrides and global Yarn
|
|
256
|
+
selectors are translated: `**/foo` becomes `foo`, and `**/@scope/foo` becomes
|
|
257
|
+
`@scope/foo`. Path-specific selectors such as `parent/child` and
|
|
258
|
+
`parent/**/child` remain in `resolutions` with a warning. Conflicting selectors
|
|
259
|
+
that translate to the same pnpm key also remain for manual resolution.
|
|
260
|
+
Only individual resolutions whose values reach the final workspace are removed.
|
|
261
|
+
|
|
262
|
+
For example, an unsupported selector is now reported and retained instead of
|
|
263
|
+
being copied into an override that prevents pnpm from installing:
|
|
264
|
+
|
|
265
|
+
```text
|
|
266
|
+
WARN Kept Yarn resolution "parent/**/child" in package.json: its selector cannot be translated safely to pnpm overrides.
|
|
267
|
+
|
|
268
|
+
ℹ No changes needed.
|
|
269
|
+
```
|
|
270
|
+
|
|
147
271
|
### `--no-show-changes`
|
|
148
272
|
|
|
149
273
|
- **Type**: `boolean`
|
|
150
274
|
- **Default behavior**: `showChanges=true` (use this flag to disable)
|
|
151
275
|
|
|
152
|
-
|
|
153
|
-
|
|
276
|
+
Hide the settings diff while keeping the outcome summary and warnings. This is a
|
|
277
|
+
CLI display preference; library results always include settings changes.
|
|
154
278
|
|
|
155
279
|
### `--no-clean-npmrc`
|
|
156
280
|
|