pnpm-settings-migrator 0.4.0 → 0.5.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
@@ -43,6 +43,18 @@ Compatibility target for migrated settings:
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
+ ### `--replace-deprecated`
47
+
48
+ - **Type**: `boolean`
49
+ - **Default**: `false`
50
+
51
+ Force replacing deprecated pnpm settings with new keys and remove old keys during migration.
52
+
53
+ Example conversions:
54
+
55
+ - `allowNonAppliedPatches` -> `allowUnusedPatches`
56
+ - `onlyBuiltDependencies` / `ignoredBuiltDependencies` / `neverBuiltDependencies` -> `allowBuilds`
57
+
46
58
  ### `--strategy`
47
59
 
48
60
  - **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.5.0";
17
17
  //#endregion
18
18
  //#region src/constants.ts
19
19
  const NPMRC = ".npmrc";
@@ -69,6 +69,7 @@ const DEFAULT_OPTIONS = {
69
69
  compatibility: "auto",
70
70
  cwd: process.cwd(),
71
71
  newlineBetween: true,
72
+ replaceDeprecated: false,
72
73
  sortKeys: false,
73
74
  strategy: "merge",
74
75
  yarnResolutions: true
@@ -113,7 +114,8 @@ function resolveOptions(options = {}) {
113
114
  sortKeys: options.sortKeys ?? DEFAULT_OPTIONS.sortKeys,
114
115
  strategy: resolveStrategy(options.strategy),
115
116
  yarnResolutions: options.yarnResolutions ?? DEFAULT_OPTIONS.yarnResolutions,
116
- cleanPackageJson: options.cleanPackageJson ?? DEFAULT_OPTIONS.cleanPackageJson
117
+ cleanPackageJson: options.cleanPackageJson ?? DEFAULT_OPTIONS.cleanPackageJson,
118
+ replaceDeprecated: options.replaceDeprecated ?? DEFAULT_OPTIONS.replaceDeprecated
117
119
  };
118
120
  }
119
121
  function resolveCompatibility(compatibility) {
@@ -442,7 +444,7 @@ async function migratePnpmSettings(rawOptions = {}) {
442
444
  ...pnpmSettingsInNpmrc,
443
445
  ...pnpmSettingsInPackageJson
444
446
  };
445
- normalizeIncomingSettings(incomingSettings, compatibility);
447
+ normalizeIncomingSettings(incomingSettings, compatibility, options.replaceDeprecated);
446
448
  const pnpmWorkspaceResult = mergeByStrategy(pnpmWorkspaceYamlObject, incomingSettings, options.strategy);
447
449
  const yamlDocument = new Document({}, { sortMapEntries: options.sortKeys });
448
450
  Object.entries(pnpmWorkspaceResult).forEach(([key, value]) => {
@@ -477,8 +479,8 @@ function collectAllowBuildsFromLegacy(incomingSettings) {
477
479
  /**
478
480
  * Normalize incoming settings according to compatibility target.
479
481
  */
480
- function normalizeIncomingSettings(incomingSettings, compatibility) {
481
- if (compatibility === "v10") return;
482
+ function normalizeIncomingSettings(incomingSettings, compatibility, replaceDeprecated) {
483
+ if (compatibility === "v10" && !replaceDeprecated) return;
482
484
  if (incomingSettings.allowNonAppliedPatches !== void 0) incomingSettings.allowUnusedPatches = incomingSettings.allowUnusedPatches ?? incomingSettings.allowNonAppliedPatches;
483
485
  const allowBuildsFromLegacy = collectAllowBuildsFromLegacy(incomingSettings);
484
486
  if (allowBuildsFromLegacy) incomingSettings.allowBuilds = {
@@ -498,7 +500,7 @@ function resolveCompatibilityTarget(compatibility, packageManager) {
498
500
  //#endregion
499
501
  //#region src/cli.ts
500
502
  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();
503
+ 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
504
  cli.command("").action(async (options) => {
503
505
  try {
504
506
  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
@@ -64,6 +64,7 @@ const DEFAULT_OPTIONS = {
64
64
  compatibility: "auto",
65
65
  cwd: process.cwd(),
66
66
  newlineBetween: true,
67
+ replaceDeprecated: false,
67
68
  sortKeys: false,
68
69
  strategy: "merge",
69
70
  yarnResolutions: true
@@ -108,7 +109,8 @@ function resolveOptions(options = {}) {
108
109
  sortKeys: options.sortKeys ?? DEFAULT_OPTIONS.sortKeys,
109
110
  strategy: resolveStrategy(options.strategy),
110
111
  yarnResolutions: options.yarnResolutions ?? DEFAULT_OPTIONS.yarnResolutions,
111
- cleanPackageJson: options.cleanPackageJson ?? DEFAULT_OPTIONS.cleanPackageJson
112
+ cleanPackageJson: options.cleanPackageJson ?? DEFAULT_OPTIONS.cleanPackageJson,
113
+ replaceDeprecated: options.replaceDeprecated ?? DEFAULT_OPTIONS.replaceDeprecated
112
114
  };
113
115
  }
114
116
  function resolveCompatibility(compatibility) {
@@ -437,7 +439,7 @@ async function migratePnpmSettings(rawOptions = {}) {
437
439
  ...pnpmSettingsInNpmrc,
438
440
  ...pnpmSettingsInPackageJson
439
441
  };
440
- normalizeIncomingSettings(incomingSettings, compatibility);
442
+ normalizeIncomingSettings(incomingSettings, compatibility, options.replaceDeprecated);
441
443
  const pnpmWorkspaceResult = mergeByStrategy(pnpmWorkspaceYamlObject, incomingSettings, options.strategy);
442
444
  const yamlDocument = new Document({}, { sortMapEntries: options.sortKeys });
443
445
  Object.entries(pnpmWorkspaceResult).forEach(([key, value]) => {
@@ -472,8 +474,8 @@ function collectAllowBuildsFromLegacy(incomingSettings) {
472
474
  /**
473
475
  * Normalize incoming settings according to compatibility target.
474
476
  */
475
- function normalizeIncomingSettings(incomingSettings, compatibility) {
476
- if (compatibility === "v10") return;
477
+ function normalizeIncomingSettings(incomingSettings, compatibility, replaceDeprecated) {
478
+ if (compatibility === "v10" && !replaceDeprecated) return;
477
479
  if (incomingSettings.allowNonAppliedPatches !== void 0) incomingSettings.allowUnusedPatches = incomingSettings.allowUnusedPatches ?? incomingSettings.allowNonAppliedPatches;
478
480
  const allowBuildsFromLegacy = collectAllowBuildsFromLegacy(incomingSettings);
479
481
  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.5.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",
@@ -37,7 +37,7 @@
37
37
  "sideEffects": false,
38
38
  "dependencies": {
39
39
  "@ntnyq/utils": "^0.13.2",
40
- "@pnpm/types": "^1101.0.0",
40
+ "@pnpm/types": "^1101.1.0",
41
41
  "cac": "^7.0.0",
42
42
  "camelcase-keys": "^10.0.2",
43
43
  "consola": "^3.4.2",
@@ -46,21 +46,20 @@
46
46
  "pathe": "^2.0.3",
47
47
  "read-ini-file": "^5.0.0",
48
48
  "uncase": "^0.2.0",
49
- "yaml": "^2.8.4"
49
+ "yaml": "^2.9.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@ntnyq/eslint-config": "^6.1.3",
53
- "@types/node": "^25.6.2",
54
- "@typescript/native-preview": "^7.0.0-dev.20260510.1",
53
+ "@types/node": "^25.7.0",
54
+ "@typescript/native-preview": "^7.0.0-dev.20260512.1",
55
55
  "bumpp": "^11.1.0",
56
56
  "eslint": "^10.3.0",
57
57
  "husky": "^9.1.7",
58
58
  "nano-staged": "^1.0.2",
59
59
  "npm-run-all2": "^8.0.4",
60
- "oxfmt": "^0.48.0",
60
+ "oxfmt": "^0.49.0",
61
61
  "tsdown": "^0.22.0",
62
- "typescript": "^6.0.3",
63
- "vitest": "^4.1.5"
62
+ "vitest": "^4.1.6"
64
63
  },
65
64
  "nano-staged": {
66
65
  "*.{js,ts,mjs,tsx,md,yml,yaml,toml,json}": "eslint --fix",