pnpm-settings-migrator 0.4.0 → 0.6.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 CHANGED
@@ -39,10 +39,31 @@ Sort keys when write `pnpm-workspace.yaml`.
39
39
  Compatibility target for migrated settings:
40
40
 
41
41
  - `auto`: infer from `packageManager` (`pnpm@11+` => `v11`, otherwise `v10`)
42
- - `v10`: keep legacy settings as-is
42
+ - `v10`: keep legacy settings as-is and migrate schema-aligned pnpm config keys from `.npmrc`
43
43
  - `v11`: normalize to v11-compatible settings (`allowBuilds`, `allowUnusedPatches`, etc.)
44
44
  and migrate all non auth/registry `.npmrc` entries to `pnpm-workspace.yaml`
45
45
 
46
+ Notes:
47
+
48
+ - `.npmrc` migration is aligned with pnpm workspace config fields such as `node-linker`,
49
+ hoist settings, lockfile settings, store settings, proxy settings, and other pnpm
50
+ runtime/install options.
51
+ - Workspace manifest-only fields such as `packages`, `catalog`, and `catalogs` are not
52
+ migrated from `.npmrc`.
53
+ - In `v11`, auth/registry-related keys still stay in `.npmrc`.
54
+
55
+ ### `--replace-deprecated`
56
+
57
+ - **Type**: `boolean`
58
+ - **Default**: `false`
59
+
60
+ Force replacing deprecated pnpm settings with new keys and remove old keys during migration.
61
+
62
+ Example conversions:
63
+
64
+ - `allowNonAppliedPatches` -> `allowUnusedPatches`
65
+ - `onlyBuiltDependencies` / `ignoredBuiltDependencies` / `neverBuiltDependencies` -> `allowBuilds`
66
+
46
67
  ### `--strategy`
47
68
 
48
69
  - **Type**: `'discard' | 'merge' | 'overwrite'`
package/dist/cli.mjs CHANGED
@@ -13,7 +13,7 @@ import { readIniFile } from "read-ini-file";
13
13
  import { kebabCase } from "uncase";
14
14
  //#region package.json
15
15
  var name = "pnpm-settings-migrator";
16
- var version = "0.4.0";
16
+ var version = "0.6.0";
17
17
  //#endregion
18
18
  //#region src/constants.ts
19
19
  const NPMRC = ".npmrc";
@@ -21,6 +21,14 @@ const PACKAGE_JSON = "package.json";
21
21
  const PNPM_WORKSPACE_YAML = "pnpm-workspace.yaml";
22
22
  /**
23
23
  * @see {@link https://github.com/pnpm/pnpm/blob/main/packages/types/src/package.ts}
24
+ * Schema-aligned pnpm config fields that can be migrated from `.npmrc`.
25
+ *
26
+ * Intentionally excluded workspace manifest-only fields:
27
+ * - `catalog`
28
+ * - `catalogMode`
29
+ * - `catalogs`
30
+ * - `cleanupUnusedCatalogs`
31
+ * - `packages`
24
32
  */
25
33
  const PNPM_SETTINGS_FIELDS = [
26
34
  "allowBuilds",
@@ -29,26 +37,96 @@ const PNPM_SETTINGS_FIELDS = [
29
37
  "allowUnusedPatches",
30
38
  "auditConfig",
31
39
  "configDependencies",
40
+ "dedupeDirectDeps",
41
+ "dedupeInjectedDeps",
42
+ "dedupePeerDependents",
43
+ "deployAllFiles",
44
+ "engineStrict",
32
45
  "executionEnv",
46
+ "fetchMinSpeedKiBps",
47
+ "fetchRetryFactor",
48
+ "fetchRetryMaxtimeout",
49
+ "fetchRetryMintimeout",
50
+ "fetchRetryTimeout",
51
+ "fetchWarnTimeoutMs",
52
+ "forceLegacyDeploy",
53
+ "gitChecks",
54
+ "gitShallowHosts",
55
+ "globalVirtualStore",
56
+ "globalVirtualStoreDir",
57
+ "hoist",
58
+ "hoistPattern",
59
+ "hoistWorkspacePackages",
33
60
  "httpProxy",
34
61
  "httpsProxy",
35
62
  "ignoredBuiltDependencies",
63
+ "ignoreDeps",
36
64
  "ignoredOptionalDependencies",
37
65
  "ignorePatchFailures",
66
+ "ignoreWorkspaceCycles",
67
+ "injectWorkspacePackages",
68
+ "linkWorkspacePackages",
69
+ "lockfile",
70
+ "lockfileDir",
71
+ "managePackageManagerVersions",
72
+ "mergeGitBranchLockfiles",
73
+ "mergeGitBranchLockfilesBranchPattern",
74
+ "modulesCacheMaxAge",
75
+ "networkConcurrency",
38
76
  "neverBuiltDependencies",
39
77
  "nodeDownloadMirrors",
78
+ "nodeLinker",
79
+ "noproxy",
40
80
  "noProxy",
81
+ "npmPath",
41
82
  "npmrcAuthFile",
42
83
  "onlyBuiltDependencies",
43
84
  "onlyBuiltDependenciesFile",
85
+ "optimisticRepeatInstall",
86
+ "optional",
44
87
  "overrides",
45
88
  "packageExtensions",
89
+ "packageImportMethod",
46
90
  "patchedDependencies",
47
91
  "peerDependencyRules",
92
+ "peersSuffixMaxLength",
93
+ "pnpmfile",
94
+ "pnpmfileIgnorePkgManifest",
95
+ "preferFrozenLockfile",
96
+ "preferWorkspacePackages",
97
+ "production",
98
+ "proxy",
99
+ "publicHoistPattern",
100
+ "recursiveInstall",
48
101
  "registries",
49
102
  "requiredScripts",
103
+ "resolutionMode",
104
+ "resolvePeersFromWorkspaceRoot",
105
+ "saveExact",
106
+ "savePrefix",
107
+ "scriptShell",
108
+ "shamefullyHoist",
109
+ "sharedWorkspaceLockfile",
110
+ "shellEmulator",
111
+ "sideEffectsCache",
112
+ "sideEffectsCacheReadonly",
113
+ "storeDir",
114
+ "strictDepBuilds",
115
+ "strictPeerDependencies",
116
+ "strictSsl",
50
117
  "supportedArchitectures",
51
- "updateConfig"
118
+ "syncInjectedDepsAfterScripts",
119
+ "tag",
120
+ "targetDependenciesField",
121
+ "timeout",
122
+ "updateConfig",
123
+ "useBetaCli",
124
+ "useNodeVersion",
125
+ "verifyDepsBeforeRun",
126
+ "verifyStoreIntegrity",
127
+ "virtualStoreDir",
128
+ "virtualStoreDirMaxLength",
129
+ "workspaceConcurrency"
52
130
  ];
53
131
  const PNPM_V11_REMOVED_SETTINGS = [
54
132
  "allowNonAppliedPatches",
@@ -69,6 +147,7 @@ const DEFAULT_OPTIONS = {
69
147
  compatibility: "auto",
70
148
  cwd: process.cwd(),
71
149
  newlineBetween: true,
150
+ replaceDeprecated: false,
72
151
  sortKeys: false,
73
152
  strategy: "merge",
74
153
  yarnResolutions: true
@@ -113,7 +192,8 @@ function resolveOptions(options = {}) {
113
192
  sortKeys: options.sortKeys ?? DEFAULT_OPTIONS.sortKeys,
114
193
  strategy: resolveStrategy(options.strategy),
115
194
  yarnResolutions: options.yarnResolutions ?? DEFAULT_OPTIONS.yarnResolutions,
116
- cleanPackageJson: options.cleanPackageJson ?? DEFAULT_OPTIONS.cleanPackageJson
195
+ cleanPackageJson: options.cleanPackageJson ?? DEFAULT_OPTIONS.cleanPackageJson,
196
+ replaceDeprecated: options.replaceDeprecated ?? DEFAULT_OPTIONS.replaceDeprecated
117
197
  };
118
198
  }
119
199
  function resolveCompatibility(compatibility) {
@@ -442,7 +522,7 @@ async function migratePnpmSettings(rawOptions = {}) {
442
522
  ...pnpmSettingsInNpmrc,
443
523
  ...pnpmSettingsInPackageJson
444
524
  };
445
- normalizeIncomingSettings(incomingSettings, compatibility);
525
+ normalizeIncomingSettings(incomingSettings, compatibility, options.replaceDeprecated);
446
526
  const pnpmWorkspaceResult = mergeByStrategy(pnpmWorkspaceYamlObject, incomingSettings, options.strategy);
447
527
  const yamlDocument = new Document({}, { sortMapEntries: options.sortKeys });
448
528
  Object.entries(pnpmWorkspaceResult).forEach(([key, value]) => {
@@ -477,8 +557,8 @@ function collectAllowBuildsFromLegacy(incomingSettings) {
477
557
  /**
478
558
  * Normalize incoming settings according to compatibility target.
479
559
  */
480
- function normalizeIncomingSettings(incomingSettings, compatibility) {
481
- if (compatibility === "v10") return;
560
+ function normalizeIncomingSettings(incomingSettings, compatibility, replaceDeprecated) {
561
+ if (compatibility === "v10" && !replaceDeprecated) return;
482
562
  if (incomingSettings.allowNonAppliedPatches !== void 0) incomingSettings.allowUnusedPatches = incomingSettings.allowUnusedPatches ?? incomingSettings.allowNonAppliedPatches;
483
563
  const allowBuildsFromLegacy = collectAllowBuildsFromLegacy(incomingSettings);
484
564
  if (allowBuildsFromLegacy) incomingSettings.allowBuilds = {
@@ -498,7 +578,7 @@ function resolveCompatibilityTarget(compatibility, packageManager) {
498
578
  //#endregion
499
579
  //#region src/cli.ts
500
580
  const cli = cac(name);
501
- cli.version(version).option("--cwd [cwd]", "Current working directory").option("--sort-keys", "Sort keys when write pnpm-workspace.yaml").option("--compatibility <compatibility>", "Compatibility target (auto, v10, v11)").option("--strategy <strategy>", "Strategy to handle conflicts (discard, merge, overwrite)").option("--no-yarn-resolutions", "Disable migrating resolutions field in package.json").option("--no-newline-between", "Disable adding newlines between each root keys").option("--no-clean-npmrc", "Disable removing pnpm settings in .npmrc file").option("--no-clean-package-json", "Disable removing pnpm fields in package.json").help();
581
+ cli.version(version).option("--cwd [cwd]", "Current working directory").option("--sort-keys", "Sort keys when write pnpm-workspace.yaml").option("--compatibility <compatibility>", "Compatibility target (auto, v10, v11)").option("--replace-deprecated", "Replace deprecated pnpm settings with new ones and remove old keys").option("--strategy <strategy>", "Strategy to handle conflicts (discard, merge, overwrite)").option("--no-yarn-resolutions", "Disable migrating resolutions field in package.json").option("--no-newline-between", "Disable adding newlines between each root keys").option("--no-clean-npmrc", "Disable removing pnpm settings in .npmrc file").option("--no-clean-package-json", "Disable removing pnpm fields in package.json").help();
502
582
  cli.command("").action(async (options) => {
503
583
  try {
504
584
  consola$1.log(`\n${bold(magenta(name))} ${dim(`v${version}`)}`);
package/dist/index.d.mts CHANGED
@@ -45,6 +45,12 @@ interface Options {
45
45
  * @default true
46
46
  */
47
47
  newlineBetween?: boolean;
48
+ /**
49
+ * Replace deprecated settings with new ones and remove deprecated keys.
50
+ *
51
+ * @default false
52
+ */
53
+ replaceDeprecated?: boolean;
48
54
  /**
49
55
  * Sort keys when write `pnpm-workspace.yaml`
50
56
  *
package/dist/index.mjs CHANGED
@@ -16,6 +16,14 @@ const PACKAGE_JSON = "package.json";
16
16
  const PNPM_WORKSPACE_YAML = "pnpm-workspace.yaml";
17
17
  /**
18
18
  * @see {@link https://github.com/pnpm/pnpm/blob/main/packages/types/src/package.ts}
19
+ * Schema-aligned pnpm config fields that can be migrated from `.npmrc`.
20
+ *
21
+ * Intentionally excluded workspace manifest-only fields:
22
+ * - `catalog`
23
+ * - `catalogMode`
24
+ * - `catalogs`
25
+ * - `cleanupUnusedCatalogs`
26
+ * - `packages`
19
27
  */
20
28
  const PNPM_SETTINGS_FIELDS = [
21
29
  "allowBuilds",
@@ -24,26 +32,96 @@ const PNPM_SETTINGS_FIELDS = [
24
32
  "allowUnusedPatches",
25
33
  "auditConfig",
26
34
  "configDependencies",
35
+ "dedupeDirectDeps",
36
+ "dedupeInjectedDeps",
37
+ "dedupePeerDependents",
38
+ "deployAllFiles",
39
+ "engineStrict",
27
40
  "executionEnv",
41
+ "fetchMinSpeedKiBps",
42
+ "fetchRetryFactor",
43
+ "fetchRetryMaxtimeout",
44
+ "fetchRetryMintimeout",
45
+ "fetchRetryTimeout",
46
+ "fetchWarnTimeoutMs",
47
+ "forceLegacyDeploy",
48
+ "gitChecks",
49
+ "gitShallowHosts",
50
+ "globalVirtualStore",
51
+ "globalVirtualStoreDir",
52
+ "hoist",
53
+ "hoistPattern",
54
+ "hoistWorkspacePackages",
28
55
  "httpProxy",
29
56
  "httpsProxy",
30
57
  "ignoredBuiltDependencies",
58
+ "ignoreDeps",
31
59
  "ignoredOptionalDependencies",
32
60
  "ignorePatchFailures",
61
+ "ignoreWorkspaceCycles",
62
+ "injectWorkspacePackages",
63
+ "linkWorkspacePackages",
64
+ "lockfile",
65
+ "lockfileDir",
66
+ "managePackageManagerVersions",
67
+ "mergeGitBranchLockfiles",
68
+ "mergeGitBranchLockfilesBranchPattern",
69
+ "modulesCacheMaxAge",
70
+ "networkConcurrency",
33
71
  "neverBuiltDependencies",
34
72
  "nodeDownloadMirrors",
73
+ "nodeLinker",
74
+ "noproxy",
35
75
  "noProxy",
76
+ "npmPath",
36
77
  "npmrcAuthFile",
37
78
  "onlyBuiltDependencies",
38
79
  "onlyBuiltDependenciesFile",
80
+ "optimisticRepeatInstall",
81
+ "optional",
39
82
  "overrides",
40
83
  "packageExtensions",
84
+ "packageImportMethod",
41
85
  "patchedDependencies",
42
86
  "peerDependencyRules",
87
+ "peersSuffixMaxLength",
88
+ "pnpmfile",
89
+ "pnpmfileIgnorePkgManifest",
90
+ "preferFrozenLockfile",
91
+ "preferWorkspacePackages",
92
+ "production",
93
+ "proxy",
94
+ "publicHoistPattern",
95
+ "recursiveInstall",
43
96
  "registries",
44
97
  "requiredScripts",
98
+ "resolutionMode",
99
+ "resolvePeersFromWorkspaceRoot",
100
+ "saveExact",
101
+ "savePrefix",
102
+ "scriptShell",
103
+ "shamefullyHoist",
104
+ "sharedWorkspaceLockfile",
105
+ "shellEmulator",
106
+ "sideEffectsCache",
107
+ "sideEffectsCacheReadonly",
108
+ "storeDir",
109
+ "strictDepBuilds",
110
+ "strictPeerDependencies",
111
+ "strictSsl",
45
112
  "supportedArchitectures",
46
- "updateConfig"
113
+ "syncInjectedDepsAfterScripts",
114
+ "tag",
115
+ "targetDependenciesField",
116
+ "timeout",
117
+ "updateConfig",
118
+ "useBetaCli",
119
+ "useNodeVersion",
120
+ "verifyDepsBeforeRun",
121
+ "verifyStoreIntegrity",
122
+ "virtualStoreDir",
123
+ "virtualStoreDirMaxLength",
124
+ "workspaceConcurrency"
47
125
  ];
48
126
  const PNPM_V11_REMOVED_SETTINGS = [
49
127
  "allowNonAppliedPatches",
@@ -64,6 +142,7 @@ const DEFAULT_OPTIONS = {
64
142
  compatibility: "auto",
65
143
  cwd: process.cwd(),
66
144
  newlineBetween: true,
145
+ replaceDeprecated: false,
67
146
  sortKeys: false,
68
147
  strategy: "merge",
69
148
  yarnResolutions: true
@@ -108,7 +187,8 @@ function resolveOptions(options = {}) {
108
187
  sortKeys: options.sortKeys ?? DEFAULT_OPTIONS.sortKeys,
109
188
  strategy: resolveStrategy(options.strategy),
110
189
  yarnResolutions: options.yarnResolutions ?? DEFAULT_OPTIONS.yarnResolutions,
111
- cleanPackageJson: options.cleanPackageJson ?? DEFAULT_OPTIONS.cleanPackageJson
190
+ cleanPackageJson: options.cleanPackageJson ?? DEFAULT_OPTIONS.cleanPackageJson,
191
+ replaceDeprecated: options.replaceDeprecated ?? DEFAULT_OPTIONS.replaceDeprecated
112
192
  };
113
193
  }
114
194
  function resolveCompatibility(compatibility) {
@@ -437,7 +517,7 @@ async function migratePnpmSettings(rawOptions = {}) {
437
517
  ...pnpmSettingsInNpmrc,
438
518
  ...pnpmSettingsInPackageJson
439
519
  };
440
- normalizeIncomingSettings(incomingSettings, compatibility);
520
+ normalizeIncomingSettings(incomingSettings, compatibility, options.replaceDeprecated);
441
521
  const pnpmWorkspaceResult = mergeByStrategy(pnpmWorkspaceYamlObject, incomingSettings, options.strategy);
442
522
  const yamlDocument = new Document({}, { sortMapEntries: options.sortKeys });
443
523
  Object.entries(pnpmWorkspaceResult).forEach(([key, value]) => {
@@ -472,8 +552,8 @@ function collectAllowBuildsFromLegacy(incomingSettings) {
472
552
  /**
473
553
  * Normalize incoming settings according to compatibility target.
474
554
  */
475
- function normalizeIncomingSettings(incomingSettings, compatibility) {
476
- if (compatibility === "v10") return;
555
+ function normalizeIncomingSettings(incomingSettings, compatibility, replaceDeprecated) {
556
+ if (compatibility === "v10" && !replaceDeprecated) return;
477
557
  if (incomingSettings.allowNonAppliedPatches !== void 0) incomingSettings.allowUnusedPatches = incomingSettings.allowUnusedPatches ?? incomingSettings.allowNonAppliedPatches;
478
558
  const allowBuildsFromLegacy = collectAllowBuildsFromLegacy(incomingSettings);
479
559
  if (allowBuildsFromLegacy) incomingSettings.allowBuilds = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pnpm-settings-migrator",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.6.0",
5
5
  "description": "Move pnpm settings from `pnpm` field in `package.json` and `.npmrc` file to `pnpm-workspace.yaml`",
6
6
  "keywords": [
7
7
  "migrator",
@@ -14,7 +14,10 @@
14
14
  "email": "ntnyq13@gmail.com"
15
15
  },
16
16
  "homepage": "https://github.com/ntnyq/pnpm-settings-migrator#readme",
17
- "repository": "ntnyq/pnpm-settings-migrator",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "ntnyq/pnpm-settings-migrator"
20
+ },
18
21
  "bugs": {
19
22
  "url": "https://github.com/ntnyq/pnpm-settings-migrator/issues"
20
23
  },
@@ -36,8 +39,8 @@
36
39
  },
37
40
  "sideEffects": false,
38
41
  "dependencies": {
39
- "@ntnyq/utils": "^0.13.2",
40
- "@pnpm/types": "^1101.0.0",
42
+ "@ntnyq/utils": "^0.15.0",
43
+ "@pnpm/types": "^1101.3.0",
41
44
  "cac": "^7.0.0",
42
45
  "camelcase-keys": "^10.0.2",
43
46
  "consola": "^3.4.2",
@@ -46,21 +49,20 @@
46
49
  "pathe": "^2.0.3",
47
50
  "read-ini-file": "^5.0.0",
48
51
  "uncase": "^0.2.0",
49
- "yaml": "^2.8.4"
52
+ "yaml": "^2.9.0"
50
53
  },
51
54
  "devDependencies": {
52
- "@ntnyq/eslint-config": "^6.1.3",
53
- "@types/node": "^25.6.2",
54
- "@typescript/native-preview": "^7.0.0-dev.20260510.1",
55
+ "@ntnyq/eslint-config": "^6.1.5",
56
+ "@types/node": "^25.9.2",
57
+ "@typescript/native-preview": "^7.0.0-dev.20260607.1",
55
58
  "bumpp": "^11.1.0",
56
- "eslint": "^10.3.0",
59
+ "eslint": "^10.4.1",
57
60
  "husky": "^9.1.7",
58
61
  "nano-staged": "^1.0.2",
59
- "npm-run-all2": "^8.0.4",
60
- "oxfmt": "^0.48.0",
61
- "tsdown": "^0.22.0",
62
- "typescript": "^6.0.3",
63
- "vitest": "^4.1.5"
62
+ "npm-run-all2": "^9.0.1",
63
+ "oxfmt": "^0.53.0",
64
+ "tsdown": "^0.22.2",
65
+ "vitest": "^4.1.8"
64
66
  },
65
67
  "nano-staged": {
66
68
  "*.{js,ts,mjs,tsx,md,yml,yaml,toml,json}": "eslint --fix",