From ad069d51c74dd5a9d100457ec8243ff27e214401 Mon Sep 17 00:00:00 2001 From: Isaac Lee <16869656+ijlee2@users.noreply.github.com> Date: Sun, 29 Oct 2023 14:03:20 +0100 Subject: [PATCH] Updated pnpm.overrides to show the correct version for eslint-plugin-import (#97) * bugfix: Updated pnpm.overrides to show the correct version for eslint-plugin-import * chore: Updated test fixtures * refactor: Allowed the update-package-json step to set pnpm.overrides * chore: Added changeset --------- Co-authored-by: ijlee2 --- .changeset/late-hairs-cough.md | 5 +++++ packages/cli/src/blueprints/package.json | 5 ----- .../src/migration/steps/update-package-json.ts | 17 +++++++++++++++++ .../package.json | 5 ----- .../ember-codemod-pod-to-octane/package.json | 5 ----- .../package.json | 2 +- .../package.json | 2 +- .../ember-codemod-pod-to-octane/package.json | 2 +- .../ember-codemod-pod-to-octane/package.json | 2 +- .../package.json | 2 +- .../ember-codemod-pod-to-octane/package.json | 2 +- 11 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 .changeset/late-hairs-cough.md diff --git a/.changeset/late-hairs-cough.md b/.changeset/late-hairs-cough.md new file mode 100644 index 00000000..778593fb --- /dev/null +++ b/.changeset/late-hairs-cough.md @@ -0,0 +1,5 @@ +--- +"@codemod-utils/cli": patch +--- + +Updated pnpm.overrides to show the correct version for eslint-plugin-import diff --git a/packages/cli/src/blueprints/package.json b/packages/cli/src/blueprints/package.json index 0e919e94..a630ca80 100644 --- a/packages/cli/src/blueprints/package.json +++ b/packages/cli/src/blueprints/package.json @@ -44,11 +44,6 @@ "enhance: dependency": "Internal", "enhance: documentation": "Documentation" } - }, - "pnpm": { - "overrides": { - "eslint-plugin-import@2.28.1>tsconfig-paths": "^4.2.0" - } } }<% } else { %>{ "name": "<%= options.codemod.name %>", diff --git a/packages/cli/src/migration/steps/update-package-json.ts b/packages/cli/src/migration/steps/update-package-json.ts index fe807641..3645acc6 100644 --- a/packages/cli/src/migration/steps/update-package-json.ts +++ b/packages/cli/src/migration/steps/update-package-json.ts @@ -77,6 +77,22 @@ function updateDevDependencies( packageJson['devDependencies'] = convertToObject(devDependencies); } +function addPnpmOverrides(packageJson: PackageJson, options: Options): void { + const { codemod } = options; + + if (!codemod.hasTypeScript) { + return; + } + + const version = getVersion('eslint-plugin-import').replace(/^\^/, ''); + + packageJson['pnpm'] = { + overrides: { + [`eslint-plugin-import@${version}>tsconfig-paths`]: '^4.2.0', + }, + }; +} + export function updatePackageJson(options: Options): void { const { codemod, projectRoot } = options; @@ -86,6 +102,7 @@ export function updatePackageJson(options: Options): void { updateDependencies(packageJson, options); updateDevDependencies(packageJson, options); + addPnpmOverrides(packageJson, options); const destination = join(projectRoot, codemod.name, 'package.json'); const file = JSON.stringify(packageJson, null, 2) + '\n'; diff --git a/packages/cli/tests/fixtures/steps/create-files-from-blueprints/typescript-with-addons/output/ember-codemod-args-to-signature/package.json b/packages/cli/tests/fixtures/steps/create-files-from-blueprints/typescript-with-addons/output/ember-codemod-args-to-signature/package.json index cd69ecb2..c3f1196e 100644 --- a/packages/cli/tests/fixtures/steps/create-files-from-blueprints/typescript-with-addons/output/ember-codemod-args-to-signature/package.json +++ b/packages/cli/tests/fixtures/steps/create-files-from-blueprints/typescript-with-addons/output/ember-codemod-args-to-signature/package.json @@ -44,10 +44,5 @@ "enhance: dependency": "Internal", "enhance: documentation": "Documentation" } - }, - "pnpm": { - "overrides": { - "eslint-plugin-import@2.28.1>tsconfig-paths": "^4.2.0" - } } } diff --git a/packages/cli/tests/fixtures/steps/create-files-from-blueprints/typescript/output/ember-codemod-pod-to-octane/package.json b/packages/cli/tests/fixtures/steps/create-files-from-blueprints/typescript/output/ember-codemod-pod-to-octane/package.json index 27001ff5..abc22aed 100644 --- a/packages/cli/tests/fixtures/steps/create-files-from-blueprints/typescript/output/ember-codemod-pod-to-octane/package.json +++ b/packages/cli/tests/fixtures/steps/create-files-from-blueprints/typescript/output/ember-codemod-pod-to-octane/package.json @@ -44,10 +44,5 @@ "enhance: dependency": "Internal", "enhance: documentation": "Documentation" } - }, - "pnpm": { - "overrides": { - "eslint-plugin-import@2.28.1>tsconfig-paths": "^4.2.0" - } } } diff --git a/packages/cli/tests/fixtures/steps/update-package-json/typescript-with-addons/input/ember-codemod-args-to-signature/package.json b/packages/cli/tests/fixtures/steps/update-package-json/typescript-with-addons/input/ember-codemod-args-to-signature/package.json index 7ec58207..ca93be7d 100644 --- a/packages/cli/tests/fixtures/steps/update-package-json/typescript-with-addons/input/ember-codemod-args-to-signature/package.json +++ b/packages/cli/tests/fixtures/steps/update-package-json/typescript-with-addons/input/ember-codemod-args-to-signature/package.json @@ -47,7 +47,7 @@ }, "pnpm": { "overrides": { - "eslint-plugin-import@2.27.5>tsconfig-paths": "^4.2.0" + "eslint-plugin-import@2.29.0>tsconfig-paths": "^4.2.0" } } } diff --git a/packages/cli/tests/fixtures/steps/update-package-json/typescript-with-addons/output/ember-codemod-args-to-signature/package.json b/packages/cli/tests/fixtures/steps/update-package-json/typescript-with-addons/output/ember-codemod-args-to-signature/package.json index b6960de8..5e6649af 100644 --- a/packages/cli/tests/fixtures/steps/update-package-json/typescript-with-addons/output/ember-codemod-args-to-signature/package.json +++ b/packages/cli/tests/fixtures/steps/update-package-json/typescript-with-addons/output/ember-codemod-args-to-signature/package.json @@ -77,7 +77,7 @@ }, "pnpm": { "overrides": { - "eslint-plugin-import@2.27.5>tsconfig-paths": "^4.2.0" + "eslint-plugin-import@2.29.0>tsconfig-paths": "^4.2.0" } } } diff --git a/packages/cli/tests/fixtures/steps/update-package-json/typescript/input/ember-codemod-pod-to-octane/package.json b/packages/cli/tests/fixtures/steps/update-package-json/typescript/input/ember-codemod-pod-to-octane/package.json index bb50909f..ba7c1328 100644 --- a/packages/cli/tests/fixtures/steps/update-package-json/typescript/input/ember-codemod-pod-to-octane/package.json +++ b/packages/cli/tests/fixtures/steps/update-package-json/typescript/input/ember-codemod-pod-to-octane/package.json @@ -47,7 +47,7 @@ }, "pnpm": { "overrides": { - "eslint-plugin-import@2.27.5>tsconfig-paths": "^4.2.0" + "eslint-plugin-import@2.29.0>tsconfig-paths": "^4.2.0" } } } diff --git a/packages/cli/tests/fixtures/steps/update-package-json/typescript/output/ember-codemod-pod-to-octane/package.json b/packages/cli/tests/fixtures/steps/update-package-json/typescript/output/ember-codemod-pod-to-octane/package.json index da1c8777..be128a0b 100644 --- a/packages/cli/tests/fixtures/steps/update-package-json/typescript/output/ember-codemod-pod-to-octane/package.json +++ b/packages/cli/tests/fixtures/steps/update-package-json/typescript/output/ember-codemod-pod-to-octane/package.json @@ -72,7 +72,7 @@ }, "pnpm": { "overrides": { - "eslint-plugin-import@2.27.5>tsconfig-paths": "^4.2.0" + "eslint-plugin-import@2.29.0>tsconfig-paths": "^4.2.0" } } } diff --git a/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/package.json b/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/package.json index b217e04b..5e6649af 100644 --- a/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/package.json +++ b/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/package.json @@ -77,7 +77,7 @@ }, "pnpm": { "overrides": { - "eslint-plugin-import@2.28.1>tsconfig-paths": "^4.2.0" + "eslint-plugin-import@2.29.0>tsconfig-paths": "^4.2.0" } } } diff --git a/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/package.json b/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/package.json index 70ee50b6..be128a0b 100644 --- a/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/package.json +++ b/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/package.json @@ -72,7 +72,7 @@ }, "pnpm": { "overrides": { - "eslint-plugin-import@2.28.1>tsconfig-paths": "^4.2.0" + "eslint-plugin-import@2.29.0>tsconfig-paths": "^4.2.0" } } }