Skip to content

Commit

Permalink
fix(nextjs): remove outdated packages
Browse files Browse the repository at this point in the history
The features should be available by default

closed nrwl#11882
  • Loading branch information
ndcunningham committed May 5, 2023
1 parent 8d35eda commit 07d438d
Show file tree
Hide file tree
Showing 19 changed files with 165 additions and 11 deletions.
6 changes: 6 additions & 0 deletions packages/expo/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 0 additions & 2 deletions packages/expo/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
reactNativeSvgVersion,
reactNativeVersion,
reactNativeWebVersion,
reactTestRendererVersion,
reactVersion,
testingLibraryJestNativeVersion,
testingLibraryReactNativeVersion,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {
Tree,
formatFiles,
removeDependenciesFromPackageJson,
} from '@nx/devkit';

export default async function removePackage(tree: Tree): Promise<void> {
removeDependenciesFromPackageJson(tree, [], ['react-test-renderer']);
await formatFiles(tree);
}
1 change: 0 additions & 1 deletion packages/expo/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 6 additions & 0 deletions packages/react-native/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 0 additions & 2 deletions packages/react-native/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
reactNativeSvgTransformerVersion,
reactNativeSvgVersion,
reactNativeVersion,
reactTestRendererVersion,
reactVersion,
testingLibraryJestNativeVersion,
testingLibraryReactNativeVersion,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {
Tree,
formatFiles,
removeDependenciesFromPackageJson,
} from '@nx/devkit';

export default async function removePackage(tree: Tree): Promise<void> {
removeDependenciesFromPackageJson(tree, [], ['react-test-renderer']);
await formatFiles(tree);
}
1 change: 0 additions & 1 deletion packages/react-native/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 6 additions & 0 deletions packages/react/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 0 additions & 2 deletions packages/react/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
babelPresetReactVersion,
nxVersion,
reactDomVersion,
reactTestRendererVersion,
reactVersion,
testingLibraryReactVersion,
tsLibVersion,
Expand Down Expand Up @@ -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,
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {
Tree,
formatFiles,
removeDependenciesFromPackageJson,
} from '@nx/devkit';

export default async function removePackage(tree: Tree): Promise<void> {
removeDependenciesFromPackageJson(tree, [], ['react-test-renderer']);
await formatFiles(tree);
}
1 change: 0 additions & 1 deletion packages/react/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 6 additions & 0 deletions packages/web/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 0 additions & 2 deletions packages/web/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {
Tree,
formatFiles,
removeDependenciesFromPackageJson,
} from '@nx/devkit';

export default async function removePackages(tree: Tree): Promise<void> {
removeDependenciesFromPackageJson(
tree,
['core-js', 'regenerator-runtime'],
[]
);

await formatFiles(tree);
}

0 comments on commit 07d438d

Please sign in to comment.