From 90d0453e585aee0e119332ffa4e7c650eb805a1e Mon Sep 17 00:00:00 2001 From: Emily Xiong Date: Fri, 2 Feb 2024 16:30:36 -0500 Subject: [PATCH] fix(expo): set port for e2e (#21559) --- packages/expo/src/generators/application/lib/add-e2e.ts | 8 +++++--- .../src/migrations/update-18-0-0/remove-block-list.ts | 4 +++- .../src/generators/application/lib/add-e2e.ts | 1 - .../src/generators/web-configuration/web-configuration.ts | 2 ++ .../src/migrations/update-18-0-0/remove-block-list.ts | 4 +++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/expo/src/generators/application/lib/add-e2e.ts b/packages/expo/src/generators/application/lib/add-e2e.ts index 0d48fc589bb55..8447605bbd482 100644 --- a/packages/expo/src/generators/application/lib/add-e2e.ts +++ b/packages/expo/src/generators/application/lib/add-e2e.ts @@ -15,6 +15,8 @@ export async function addE2e( tree: Tree, options: NormalizedSchema ): Promise { + const hasPlugin = hasExpoPlugin(tree); + const port = hasPlugin ? 8081 : 4200; switch (options.e2eTestRunner) { case 'cypress': { const hasNxExportPlugin = hasExpoPlugin(tree); @@ -46,8 +48,8 @@ export async function addE2e( bundler: 'none', skipFormat: true, devServerTarget: `${options.projectName}:serve`, - port: 4200, - baseUrl: 'http://localhost:4200', + port, + baseUrl: `http://localhost:${port}`, ciWebServerCommand: hasNxExportPlugin ? `nx run ${options.projectName}:serve-static` : undefined, @@ -77,7 +79,7 @@ export async function addE2e( webServerCommand: `${getPackageManagerCommand().exec} nx serve ${ options.name }`, - webServerAddress: 'http://localhost:4200', + webServerAddress: `http://localhost:${port}`, rootProject: options.rootProject, }); } diff --git a/packages/expo/src/migrations/update-18-0-0/remove-block-list.ts b/packages/expo/src/migrations/update-18-0-0/remove-block-list.ts index 27c2e516fc128..1f0ac30668ea3 100644 --- a/packages/expo/src/migrations/update-18-0-0/remove-block-list.ts +++ b/packages/expo/src/migrations/update-18-0-0/remove-block-list.ts @@ -13,8 +13,10 @@ export default async function update(tree: Tree) { let content = tree .read(joinPathFragments(config.root, 'metro.config.js')) .toString(); + content = content.replace(/blockList: exclusionList(.+?(?=\n))/, ''); + content = content.replace('// unstable_enableSymlinks: true,', ''); content = content.replace( - `blockList: exclusionList([/^(?!.*node_modules).*/dist/.*/]),`, + '// unstable_enablePackageExports: true,', '' ); content = content.replace('unstable_enableSymlinks: true,', ''); diff --git a/packages/react-native/src/generators/application/lib/add-e2e.ts b/packages/react-native/src/generators/application/lib/add-e2e.ts index 3640e6c642d21..6aff1fc81dd2f 100644 --- a/packages/react-native/src/generators/application/lib/add-e2e.ts +++ b/packages/react-native/src/generators/application/lib/add-e2e.ts @@ -28,7 +28,6 @@ export async function addE2e( hasStyles: false, unitTestRunner: 'none', }); - case 'detox': case 'detox': const { detoxApplicationGenerator } = ensurePackage< typeof import('@nx/detox') diff --git a/packages/react-native/src/generators/web-configuration/web-configuration.ts b/packages/react-native/src/generators/web-configuration/web-configuration.ts index 59ae399da106d..85204f46cf030 100644 --- a/packages/react-native/src/generators/web-configuration/web-configuration.ts +++ b/packages/react-native/src/generators/web-configuration/web-configuration.ts @@ -98,6 +98,7 @@ async function addBundlerConfiguration( typeof import('@nx/vite') >('@nx/vite', nxVersion); const viteTask = await viteConfigurationGenerator(tree, { + ...normalizedSchema, uiFramework: 'react', project: normalizedSchema.project, newProject: true, @@ -111,6 +112,7 @@ async function addBundlerConfiguration( typeof import('@nx/webpack') >('@nx/webpack', nxVersion); const webpackInitTask = await webpackInitGenerator(tree, { + ...normalizedSchema, skipFormat: true, skipPackageJson: normalizedSchema.skipPackageJson, }); diff --git a/packages/react-native/src/migrations/update-18-0-0/remove-block-list.ts b/packages/react-native/src/migrations/update-18-0-0/remove-block-list.ts index 8418072bef5e6..90762536b5e7d 100644 --- a/packages/react-native/src/migrations/update-18-0-0/remove-block-list.ts +++ b/packages/react-native/src/migrations/update-18-0-0/remove-block-list.ts @@ -13,8 +13,10 @@ export default async function update(tree: Tree) { let content = tree .read(joinPathFragments(config.root, 'metro.config.js')) .toString(); + content = content.replace(/blockList: exclusionList(.+?(?=\n))/, ''); + content = content.replace('// unstable_enableSymlinks: true,', ''); content = content.replace( - `blockList: exclusionList([/^(?!.*node_modules).*/dist/.*/]),`, + '// unstable_enablePackageExports: true,', '' ); content = content.replace('unstable_enableSymlinks: true,', '');