From 877e4462e37a32789931a1f3d10c58580f2045a6 Mon Sep 17 00:00:00 2001 From: Nicholas Cunningham Date: Thu, 4 May 2023 17:31:54 -0600 Subject: [PATCH] fix(nextjs): remove outdated packages The features should be available by default closed #11882 --- packages/expo/migrations.json | 6 +++++ packages/expo/src/generators/init/init.ts | 2 -- .../update-16-1-0-remove-package.spec.ts | 23 ++++++++++++++++ .../update-16-1-0-remove-package.ts | 10 +++++++ packages/expo/src/utils/versions.ts | 1 - packages/react-native/migrations.json | 6 +++++ .../react-native/src/generators/init/init.ts | 2 -- .../update-16-1-0-remove-package.spec.ts | 23 ++++++++++++++++ .../update-16-1-0-remove-package.ts | 10 +++++++ packages/react-native/src/utils/versions.ts | 1 - packages/react/migrations.json | 6 +++++ packages/react/src/generators/init/init.ts | 2 -- .../update-16-1-0-remove-package.spec.ts | 23 ++++++++++++++++ .../update-16-1-0-remove-package.ts | 10 +++++++ packages/react/src/utils/versions.ts | 1 - packages/web/migrations.json | 6 +++++ packages/web/src/generators/init/init.ts | 2 -- .../update-16-1-0-remove-packages.spec.ts | 27 +++++++++++++++++++ .../update-16-1-0-remove-packages.ts | 15 +++++++++++ 19 files changed, 165 insertions(+), 11 deletions(-) create mode 100644 packages/expo/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts create mode 100644 packages/expo/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts create mode 100644 packages/react-native/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts create mode 100644 packages/react-native/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts create mode 100644 packages/react/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts create mode 100644 packages/react/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts create mode 100644 packages/web/src/migrations/update-16-1-0-remove-packages/update-16-1-0-remove-packages.spec.ts create mode 100644 packages/web/src/migrations/update-16-1-0-remove-packages/update-16-1-0-remove-packages.ts diff --git a/packages/expo/migrations.json b/packages/expo/migrations.json index a394f2ab40063..381eebc2f9e83 100644 --- a/packages/expo/migrations.json +++ b/packages/expo/migrations.json @@ -53,6 +53,12 @@ "version": "16.0.0-beta.1", "description": "Replace @nrwl/expo with @nx/expo", "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages" + }, + "update-16-1-0-remove-package": { + "cli": "nx", + "version": "16.1.0-beta.0", + "description": "Remove react-test-renderer from package.json", + "implementation": "./src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package" } }, "packageJsonUpdates": { diff --git a/packages/expo/src/generators/init/init.ts b/packages/expo/src/generators/init/init.ts index d066d0d8aba1b..33222f1e76f65 100644 --- a/packages/expo/src/generators/init/init.ts +++ b/packages/expo/src/generators/init/init.ts @@ -24,7 +24,6 @@ import { reactNativeSvgVersion, reactNativeVersion, reactNativeWebVersion, - reactTestRendererVersion, reactVersion, testingLibraryJestNativeVersion, testingLibraryReactNativeVersion, @@ -98,7 +97,6 @@ export function updateDependencies(host: Tree) { '@types/react-native': typesReactNativeVersion, metro: metroVersion, 'metro-resolver': metroVersion, - 'react-test-renderer': reactTestRendererVersion, '@testing-library/react-native': testingLibraryReactNativeVersion, '@testing-library/jest-native': testingLibraryJestNativeVersion, 'jest-expo': jestExpoVersion, diff --git a/packages/expo/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts b/packages/expo/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts new file mode 100644 index 0000000000000..9aae51ba1fb7b --- /dev/null +++ b/packages/expo/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts @@ -0,0 +1,23 @@ +import { Tree, readJson, updateJson } from '@nx/devkit'; +import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports'; +import removePackage from './update-16-1-0-remove-package'; + +describe('update-16-1-0-remove-package', () => { + let tree: Tree; + beforeEach(() => { + tree = createTreeWithEmptyWorkspace(); + + updateJson(tree, 'package.json', (json) => { + json.devDependencies['react-test-renderer'] = '18.2.0'; + return json; + }); + }); + + it('should remove react-test-renderer from package.json', async () => { + await removePackage(tree); + + expect( + readJson(tree, 'package.json').devDependencies['react-test-renderer'] + ).not.toBeDefined(); + }); +}); diff --git a/packages/expo/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts b/packages/expo/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts new file mode 100644 index 0000000000000..00b761a185508 --- /dev/null +++ b/packages/expo/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts @@ -0,0 +1,10 @@ +import { + Tree, + formatFiles, + removeDependenciesFromPackageJson, +} from '@nx/devkit'; + +export default async function removePackage(tree: Tree): Promise { + removeDependenciesFromPackageJson(tree, [], ['react-test-renderer']); + await formatFiles(tree); +} diff --git a/packages/expo/src/utils/versions.ts b/packages/expo/src/utils/versions.ts index 09c841606baec..23f693349dc0d 100644 --- a/packages/expo/src/utils/versions.ts +++ b/packages/expo/src/utils/versions.ts @@ -10,7 +10,6 @@ export const babelPresetExpoVersion = '~9.3.2'; export const reactVersion = '18.2.0'; export const reactDomVersion = '18.2.0'; -export const reactTestRendererVersion = '18.2.0'; export const typesReactVersion = '18.0.28'; export const reactNativeVersion = '0.71.7'; diff --git a/packages/react-native/migrations.json b/packages/react-native/migrations.json index e13028592051f..2ec8dc0069190 100644 --- a/packages/react-native/migrations.json +++ b/packages/react-native/migrations.json @@ -89,6 +89,12 @@ "version": "16.1.0-beta.0", "description": "Upgrade @storybook/react-native to 6.5", "implementation": "./src/migrations/update-16-1-0/upgrade-storybook-6-5" + }, + "update-16-1-0-remove-package": { + "cli": "nx", + "version": "16.1.0-beta.0", + "description": "Remove react-test-renderer from package.json", + "implementation": "./src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package" } }, "packageJsonUpdates": { diff --git a/packages/react-native/src/generators/init/init.ts b/packages/react-native/src/generators/init/init.ts index 8bfabf03701e7..38eb52f27bd16 100644 --- a/packages/react-native/src/generators/init/init.ts +++ b/packages/react-native/src/generators/init/init.ts @@ -28,7 +28,6 @@ import { reactNativeSvgTransformerVersion, reactNativeSvgVersion, reactNativeVersion, - reactTestRendererVersion, reactVersion, testingLibraryJestNativeVersion, testingLibraryReactNativeVersion, @@ -104,7 +103,6 @@ export function updateDependencies(host: Tree) { 'metro-babel-register': metroVersion, 'metro-react-native-babel-preset': metroVersion, 'metro-react-native-babel-transformer': metroVersion, - 'react-test-renderer': reactTestRendererVersion, 'react-native-svg-transformer': reactNativeSvgTransformerVersion, 'react-native-svg': reactNativeSvgVersion, '@babel/preset-react': babelPresetReactVersion, diff --git a/packages/react-native/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts b/packages/react-native/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts new file mode 100644 index 0000000000000..9aae51ba1fb7b --- /dev/null +++ b/packages/react-native/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts @@ -0,0 +1,23 @@ +import { Tree, readJson, updateJson } from '@nx/devkit'; +import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports'; +import removePackage from './update-16-1-0-remove-package'; + +describe('update-16-1-0-remove-package', () => { + let tree: Tree; + beforeEach(() => { + tree = createTreeWithEmptyWorkspace(); + + updateJson(tree, 'package.json', (json) => { + json.devDependencies['react-test-renderer'] = '18.2.0'; + return json; + }); + }); + + it('should remove react-test-renderer from package.json', async () => { + await removePackage(tree); + + expect( + readJson(tree, 'package.json').devDependencies['react-test-renderer'] + ).not.toBeDefined(); + }); +}); diff --git a/packages/react-native/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts b/packages/react-native/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts new file mode 100644 index 0000000000000..00b761a185508 --- /dev/null +++ b/packages/react-native/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts @@ -0,0 +1,10 @@ +import { + Tree, + formatFiles, + removeDependenciesFromPackageJson, +} from '@nx/devkit'; + +export default async function removePackage(tree: Tree): Promise { + removeDependenciesFromPackageJson(tree, [], ['react-test-renderer']); + await formatFiles(tree); +} diff --git a/packages/react-native/src/utils/versions.ts b/packages/react-native/src/utils/versions.ts index e2900881ed0e3..b20a94e403a5e 100644 --- a/packages/react-native/src/utils/versions.ts +++ b/packages/react-native/src/utils/versions.ts @@ -13,7 +13,6 @@ export const reactNativeCommunityCliAndroid = '10.2.0'; export const reactVersion = '18.2.0'; export const reactDomVersion = '18.2.0'; -export const reactTestRendererVersion = '18.2.0'; export const typesReactVersion = '18.0.28'; export const testingLibraryReactNativeVersion = '12.0.1'; diff --git a/packages/react/migrations.json b/packages/react/migrations.json index bdeeca3c2af3f..625635a317ef5 100644 --- a/packages/react/migrations.json +++ b/packages/react/migrations.json @@ -89,6 +89,12 @@ "version": "16.0.0-beta.1", "description": "Replace @nrwl/react with @nx/react", "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages" + }, + "update-16-1-0-remove-package": { + "cli": "nx", + "version": "16.1.0-beta.0", + "description": "Remove react-test-renderer from package.json", + "implementation": "./src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package" } }, "packageJsonUpdates": { diff --git a/packages/react/src/generators/init/init.ts b/packages/react/src/generators/init/init.ts index 59aa332673f19..dee9e57e2ad75 100755 --- a/packages/react/src/generators/init/init.ts +++ b/packages/react/src/generators/init/init.ts @@ -16,7 +16,6 @@ import { babelPresetReactVersion, nxVersion, reactDomVersion, - reactTestRendererVersion, reactVersion, testingLibraryReactVersion, tsLibVersion, @@ -63,7 +62,6 @@ function updateDependencies(host: Tree, schema: InitSchema) { '@types/react': typesReactVersion, '@types/react-dom': typesReactDomVersion, '@testing-library/react': testingLibraryReactVersion, - 'react-test-renderer': reactTestRendererVersion, }); } diff --git a/packages/react/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts b/packages/react/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts new file mode 100644 index 0000000000000..9aae51ba1fb7b --- /dev/null +++ b/packages/react/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.spec.ts @@ -0,0 +1,23 @@ +import { Tree, readJson, updateJson } from '@nx/devkit'; +import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports'; +import removePackage from './update-16-1-0-remove-package'; + +describe('update-16-1-0-remove-package', () => { + let tree: Tree; + beforeEach(() => { + tree = createTreeWithEmptyWorkspace(); + + updateJson(tree, 'package.json', (json) => { + json.devDependencies['react-test-renderer'] = '18.2.0'; + return json; + }); + }); + + it('should remove react-test-renderer from package.json', async () => { + await removePackage(tree); + + expect( + readJson(tree, 'package.json').devDependencies['react-test-renderer'] + ).not.toBeDefined(); + }); +}); diff --git a/packages/react/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts b/packages/react/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts new file mode 100644 index 0000000000000..00b761a185508 --- /dev/null +++ b/packages/react/src/migrations/update-16-1-0-remove-package/update-16-1-0-remove-package.ts @@ -0,0 +1,10 @@ +import { + Tree, + formatFiles, + removeDependenciesFromPackageJson, +} from '@nx/devkit'; + +export default async function removePackage(tree: Tree): Promise { + removeDependenciesFromPackageJson(tree, [], ['react-test-renderer']); + await formatFiles(tree); +} diff --git a/packages/react/src/utils/versions.ts b/packages/react/src/utils/versions.ts index c3d7cc00be128..a15e5254bf35d 100755 --- a/packages/react/src/utils/versions.ts +++ b/packages/react/src/utils/versions.ts @@ -33,7 +33,6 @@ export const testingLibraryReactVersion = '14.0.0'; export const reduxjsToolkitVersion = '1.9.3'; export const reactReduxVersion = '8.0.5'; -export const reactTestRendererVersion = '18.2.0'; export const eslintPluginImportVersion = '2.27.5'; export const eslintPluginJsxA11yVersion = '6.7.1'; diff --git a/packages/web/migrations.json b/packages/web/migrations.json index 84c2150e77d84..1afc7efac47ba 100644 --- a/packages/web/migrations.json +++ b/packages/web/migrations.json @@ -71,6 +71,12 @@ "version": "16.0.0-beta.4", "description": "Replace @nrwl/web executors with @nx/webpack and @nx/rollup", "implementation": "./src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors" + }, + "update-16-1-0-remove-packages": { + "cli": "nx", + "version": "16.1.0-beta.0", + "description": "Remove core-js and regenerator-runtime packages", + "implementation": "./src/migrations/update-16-1-0-remove-packages/update-16-1-0-remove-packages" } }, "packageJsonUpdates": { diff --git a/packages/web/src/generators/init/init.ts b/packages/web/src/generators/init/init.ts index 4b3f1e804c746..a703a0cac0e65 100644 --- a/packages/web/src/generators/init/init.ts +++ b/packages/web/src/generators/init/init.ts @@ -29,8 +29,6 @@ function updateDependencies(tree: Tree, schema: Schema) { return addDependenciesToPackageJson( tree, { - 'core-js': '^3.6.5', - 'regenerator-runtime': '0.13.7', tslib: tsLibVersion, }, devDependencies diff --git a/packages/web/src/migrations/update-16-1-0-remove-packages/update-16-1-0-remove-packages.spec.ts b/packages/web/src/migrations/update-16-1-0-remove-packages/update-16-1-0-remove-packages.spec.ts new file mode 100644 index 0000000000000..d27bbe97d9e2b --- /dev/null +++ b/packages/web/src/migrations/update-16-1-0-remove-packages/update-16-1-0-remove-packages.spec.ts @@ -0,0 +1,27 @@ +import { Tree, readJson, updateJson } from '@nx/devkit'; +import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports'; +import removePackages from './update-16-1-0-remove-packages'; + +describe('update-16-1-0-remove-packages', () => { + let tree: Tree; + beforeEach(() => { + tree = createTreeWithEmptyWorkspace(); + + updateJson(tree, 'package.json', (json) => { + json.dependencies['core-js'] = '3.6.5'; + json.dependencies['regenerator-runtime'] = '0.13.7'; + return json; + }); + }); + + it('should remove core-js & regenerator-runtime packages', async () => { + await removePackages(tree); + + expect( + readJson(tree, 'package.json').dependencies['core-js'] + ).not.toBeDefined(); + expect( + readJson(tree, 'package.json').dependencies['regenerator-runtime'] + ).not.toBeDefined(); + }); +}); diff --git a/packages/web/src/migrations/update-16-1-0-remove-packages/update-16-1-0-remove-packages.ts b/packages/web/src/migrations/update-16-1-0-remove-packages/update-16-1-0-remove-packages.ts new file mode 100644 index 0000000000000..ae9653465ca1f --- /dev/null +++ b/packages/web/src/migrations/update-16-1-0-remove-packages/update-16-1-0-remove-packages.ts @@ -0,0 +1,15 @@ +import { + Tree, + formatFiles, + removeDependenciesFromPackageJson, +} from '@nx/devkit'; + +export default async function removePackages(tree: Tree): Promise { + removeDependenciesFromPackageJson( + tree, + ['core-js', 'regenerator-runtime'], + [] + ); + + await formatFiles(tree); +}