Skip to content

Commit

Permalink
feat(react-native): upgrade metro to 0.71.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Jun 6, 2022
1 parent a0bf1f0 commit 887642e
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 32 deletions.
10 changes: 10 additions & 0 deletions docs/generated/packages/react-native.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@
"type": "string",
"enum": ["detox", "none"],
"default": "detox"
},
"install": {
"type": "boolean",
"description": "Runs `pod install` for native modules before building iOS app.",
"default": true
}
},
"required": [],
Expand Down Expand Up @@ -474,6 +479,11 @@
"type": "string",
"enum": ["detox", "none"],
"default": "detox"
},
"install": {
"type": "boolean",
"description": "Runs `pod install` for native modules before building iOS app.",
"default": true
}
},
"required": ["name"],
Expand Down
12 changes: 9 additions & 3 deletions e2e/react-native/src/react-native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ describe('react native', () => {
const libName = uniq('lib');
const componentName = uniq('component');

runCLI(`generate @nrwl/react-native:application ${appName}`);
runCLI(
`generate @nrwl/react-native:application ${appName} --install=false`
);
runCLI(`generate @nrwl/react-native:library ${libName}`);
runCLI(
`generate @nrwl/react-native:component ${componentName} --project=${libName} --export`
Expand Down Expand Up @@ -59,7 +61,9 @@ describe('react native', () => {

it('should create storybook with application', async () => {
const appName = uniq('my-app');
runCLI(`generate @nrwl/react-native:application ${appName}`);
runCLI(
`generate @nrwl/react-native:application ${appName} --install=false`
);
runCLI(
`generate @nrwl/react-native:storybook-configuration ${appName} --generateStories --no-interactive`
);
Expand All @@ -86,7 +90,9 @@ describe('react native', () => {

it('sync npm dependencies for autolink', async () => {
const appName = uniq('my-app');
runCLI(`generate @nrwl/react-native:application ${appName}`);
runCLI(
`generate @nrwl/react-native:application ${appName} --install=false`
);
// Add npm package with native modules
updateFile(join('package.json'), (content) => {
const json = JSON.parse(content);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
"license-webpack-plugin": "^4.0.2",
"loader-utils": "1.2.3",
"memfs": "^3.0.1",
"metro-resolver": "^0.70.3",
"metro-resolver": "^0.71.0",
"mime": "2.4.4",
"mini-css-extract-plugin": "~2.4.7",
"minimatch": "3.0.5",
Expand Down
9 changes: 9 additions & 0 deletions packages/detox/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@
"alwaysAddToPackageJson": false
}
}
},
"14.2.1": {
"version": "14.2.1-beta.0",
"packages": {
"detox": {
"version": "19.7.1",
"alwaysAddToPackageJson": false
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/detox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"chalk": "^4.1.0"
},
"peerDependencies": {
"detox": "^19.6.9"
"detox": "^19.7.1"
},
"builders": "./executors.json",
"ng-update": {
Expand Down
2 changes: 1 addition & 1 deletion packages/detox/src/utils/versions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const nxVersion = require('../../package.json').version;

export const detoxVersion = '19.6.9';
export const detoxVersion = '19.7.1';
export const testingLibraryJestDom = '5.16.4';
37 changes: 37 additions & 0 deletions packages/react-native/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,43 @@
"alwaysAddToPackageJson": false
}
}
},
"14.2.1": {
"version": "14.2.1-beta.0",
"packages": {
"metro": {
"version": "0.71.0",
"alwaysAddToPackageJson": false
},
"metro-resolver": {
"version": "0.71.0",
"alwaysAddToPackageJson": false
},
"metro-babel-register": {
"version": "0.71.0",
"alwaysAddToPackageJson": false
},
"metro-config": {
"version": "0.71.0",
"alwaysAddToPackageJson": false
},
"metro-react-native-babel-preset": {
"version": "0.71.0",
"alwaysAddToPackageJson": false
},
"@testing-library/jest-native": {
"version": "4.0.5",
"alwaysAddToPackageJson": false
},
"@babel/runtime": {
"version": "7.18.3",
"alwaysAddToPackageJson": false
},
"@types/react-native": {
"version": "0.67.8",
"alwaysAddToPackageJson": false
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"enhanced-resolve": "^5.8.3",
"fs-extra": "^10.1.0",
"ignore": "^5.0.4",
"metro-resolver": "^0.70.3",
"metro-resolver": "^0.71.0",
"node-fetch": "^2.6.7",
"tsconfig-paths": "^3.9.0"
},
Expand Down
16 changes: 6 additions & 10 deletions packages/react-native/plugins/metro-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ export function getResolveRequest(extensions: string[]) {
return function (
_context: any,
realModuleName: string,
platform: string | null,
moduleName: string
platform: string | null
) {
const DEBUG = process.env.NX_REACT_NATIVE_DEBUG === 'true';

if (DEBUG) console.log(chalk.cyan(`[Nx] Resolving: ${moduleName}`));
if (DEBUG) console.log(chalk.cyan(`[Nx] Resolving: ${realModuleName}`));

const { resolveRequest, ...context } = _context;

Expand All @@ -32,15 +31,14 @@ export function getResolveRequest(extensions: string[]) {
context,
extensions,
realModuleName,
moduleName,
platform,
DEBUG
) ||
pnpmResolver(extensions, context, realModuleName, moduleName, DEBUG);
pnpmResolver(extensions, context, realModuleName, DEBUG);
if (resolvedPath) {
return resolvedPath;
}
throw new Error(`Cannot resolve ${chalk.bold(moduleName)}`);
throw new Error(`Cannot resolve ${chalk.bold(realModuleName)}`);
};
}

Expand Down Expand Up @@ -75,7 +73,6 @@ function pnpmResolver(
extensions: string[],
context: any,
realModuleName: string,
moduleName: string,
debug: boolean
) {
try {
Expand All @@ -93,7 +90,7 @@ function pnpmResolver(
if (debug)
console.log(
chalk.cyan(
`[Nx] Unable to resolve with default PNPM resolver: ${moduleName}`
`[Nx] Unable to resolve with default PNPM resolver: ${realModuleName}`
)
);
}
Expand All @@ -107,7 +104,6 @@ function tsconfigPathsResolver(
context: any,
extensions: string[],
realModuleName: string,
moduleName: string,
platform: string,
debug: boolean
) {
Expand All @@ -124,7 +120,7 @@ function tsconfigPathsResolver(
} else {
if (debug) {
console.log(
chalk.red(`[Nx] Failed to resolve ${chalk.bold(moduleName)}`)
chalk.red(`[Nx] Failed to resolve ${chalk.bold(realModuleName)}`)
);
console.log(
chalk.cyan(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export async function reactNativeApplicationGenerator(
);
const detoxTask = await addDetox(host, options);
const symlinkTask = runSymlink(host.root, options.appProjectRoot);
const podInstallTask = runPodInstall(join(host.root, options.iosProjectRoot));
const podInstallTask = runPodInstall(
join(host.root, options.iosProjectRoot),
options.install
);
const chmodTaskGradlew = runChmod(
join(host.root, options.androidProjectRoot, 'gradlew'),
0o775
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export interface Schema {
linter?: Linter;
setParserOptionsProject?: boolean;
e2eTestRunner?: 'detox' | 'none';
install: boolean; // default is true
}
5 changes: 5 additions & 0 deletions packages/react-native/src/generators/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
"type": "string",
"enum": ["detox", "none"],
"default": "detox"
},
"install": {
"type": "boolean",
"description": "Runs `pod install` for native modules before building iOS app.",
"default": true
}
},
"required": []
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-ser
import { jestInitGenerator } from '@nrwl/jest';
import { detoxInitGenerator } from '@nrwl/detox';
import {
reactTestRendererVersion,
reactVersion,
typesReactVersion,
} from '@nrwl/react/src/utils/versions';
Expand All @@ -29,7 +30,6 @@ import {
reactNativeSvgTransformerVersion,
reactNativeSvgVersion,
reactNativeVersion,
reactTestRendererVersion,
testingLibraryJestNativeVersion,
testingLibraryReactNativeVersion,
typesNodeVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export interface UpgradeNativeConfigureSchema {
displayName?: string;
js: boolean; // default is false
e2eTestRunner: 'detox' | 'none'; // default is detox
install: boolean; // default is true
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"type": "string",
"enum": ["detox", "none"],
"default": "detox"
},
"install": {
"type": "boolean",
"description": "Runs `pod install` for native modules before building iOS app.",
"default": true
}
},
"required": ["name"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function reactNativeUpgradeNativeGenerator(

createNativeFiles(host, schema, root);

const podInstallTask = runPodInstall(iosProjectRoot);
const podInstallTask = runPodInstall(iosProjectRoot, schema.install);
const chmodTaskGradlew = runChmod(join(androidProjectRoot, 'gradlew'), 0o775);
const chmodTaskGradlewBat = runChmod(
join(androidProjectRoot, 'gradlew.bat'),
Expand Down
10 changes: 9 additions & 1 deletion packages/react-native/src/utils/pod-install-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ ${chalk.bold('sudo xcode-select --switch /Applications/Xcode.app')}
* @param iosDirectory ios directory that contains Podfile
* @returns resolve with 0 if not error, reject with error otherwise
*/
export function runPodInstall(iosDirectory: string): GeneratorCallback {
export function runPodInstall(
iosDirectory: string,
install: boolean = true
): GeneratorCallback {
return () => {
if (platform() !== 'darwin') {
logger.info('Skipping `pod install` on non-darwin platform');
return;
}

if (!install) {
logger.info('Skipping `pod install`');
return;
}

logger.info(`Running \`pod install\` from "${iosDirectory}"`);

return podInstall(iosDirectory);
Expand Down
12 changes: 5 additions & 7 deletions packages/react-native/src/utils/versions.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
export const nxVersion = require('../../package.json').version;

export const reactNativeVersion = '0.68.2';
export const typesReactNativeVersion = '0.67.7';
export const typesReactNativeVersion = '0.67.8';

export const typesNodeVersion = '16.11.7';

export const metroVersion = '0.70.3';
export const metroVersion = '0.71.0';

export const reactNativeCommunityCli = '7.0.3';
export const reactNativeCommunityCliIos = '7.0.1';
export const reactNativeCommunityCliAndroid = '7.0.1';

export const reactNativeConfigVersion = '1.4.5';
export const reactNativeAsyncStorageAsyncStorageVersion = '1.16.3';
export const reactNativeAsyncStorageAsyncStorageVersion = '1.17.5';

export const testingLibraryReactNativeVersion = '9.1.0';
export const testingLibraryJestNativeVersion = '4.0.4';
export const testingLibraryJestNativeVersion = '4.0.5';

export const jestReactNativeVersion = '18.0.0';

export const reactTestRendererVersion = '18.1.0';

export const reactNativeSvgTransformerVersion = '1.0.0';
export const reactNativeSvgVersion = '12.3.0';

export const babelRuntimeVersion = '7.17.9';
export const babelRuntimeVersion = '7.18.3';
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16895,10 +16895,10 @@ methods@~1.1.2:
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=

metro-resolver@^0.70.3:
version "0.70.3"
resolved "https://registry.yarnpkg.com/metro-resolver/-/metro-resolver-0.70.3.tgz#c64fdd6d0a88fa62f3f99f87e539b5f603bd47bf"
integrity sha512-5Pc5S/Gs4RlLbziuIWtvtFd9GRoILlaRC8RZDVq5JZWcWHywKy/PjNmOBNhpyvtRlzpJfy/ssIfLhu8zINt1Mw==
metro-resolver@^0.71.0:
version "0.71.0"
resolved "https://registry.yarnpkg.com/metro-resolver/-/metro-resolver-0.71.0.tgz#2eee9c04055fbb043b3a97d6fd7a27b221b8748c"
integrity sha512-VUc7+nPOb/pthwDNMsulAWu63QqRa6O7/hW8J/jXYXR7cnkjF1vV08KT+28smrvb/jEKS8Saqn08pcqF/uxkuQ==
dependencies:
absolute-path "^0.0.0"

Expand Down

0 comments on commit 887642e

Please sign in to comment.