diff --git a/e2e/expo/project.json b/e2e/expo/project.json index 9e84a4fc0cb1e..f660ac0090db7 100644 --- a/e2e/expo/project.json +++ b/e2e/expo/project.json @@ -4,7 +4,7 @@ "sourceRoot": "e2e/expo", "projectType": "application", "targets": { - "e2e": {}, + "e2e-macos": {}, "run-e2e-tests": {} }, "implicitDependencies": ["expo"] diff --git a/e2e/expo/src/expo.test.ts b/e2e/expo/src/expo.test.ts index 6dd76a49067fc..efff49151ffb1 100644 --- a/e2e/expo/src/expo.test.ts +++ b/e2e/expo/src/expo.test.ts @@ -3,11 +3,14 @@ import { cleanupProject, expectTestsPass, newProject, + readJson, + readResolvedConfiguration, runCLI, runCLIAsync, uniq, updateFile, } from '@nrwl/e2e/utils'; +import { join } from 'path'; describe('expo', () => { let proj: string; @@ -17,15 +20,15 @@ describe('expo', () => { ); afterEach(() => cleanupProject()); - it('should test, lint and export', async () => { + it('should test, lint, export and prebuild', async () => { const appName = uniq('my-app'); const libName = uniq('lib'); const componentName = uniq('component'); - runCLI(`generate @nrwl/expo:application ${appName}`); - runCLI(`generate @nrwl/expo:library ${libName}`); + runCLI(`generate @nrwl/expo:application ${appName} --no-interactive`); + runCLI(`generate @nrwl/expo:library ${libName} --no-interactive`); runCLI( - `generate @nrwl/expo:component ${componentName} --project=${libName} --export` + `generate @nrwl/expo:component ${componentName} --project=${libName} --export --no-interactive` ); expectTestsPass(await runCLIAsync(`test ${appName}`)); expectTestsPass(await runCLIAsync(`test ${libName}`)); @@ -43,11 +46,33 @@ describe('expo', () => { const libLintResults = await runCLIAsync(`lint ${libName}`); expect(libLintResults.combinedOutput).toContain('All files pass linting.'); - const exportResults = await runCLIAsync(`export ${appName}`); + const exportResults = await runCLIAsync( + `export ${appName} --no-interactive` + ); expect(exportResults.combinedOutput).toContain( 'Export was successful. Your exported files can be found' ); - }, 1000000); + + // set a mock package name for ios and android in expo's app.json + const workspace = readResolvedConfiguration(); + const root = workspace.projects[appName].root; + const appJsonPath = join(root, `app.json`); + const appJson = await readJson(appJsonPath); + if (appJson.expo.ios) { + appJson.expo.ios.bundleIdentifier = 'nx.test'; + } + if (appJson.expo.android) { + appJson.expo.android.package = 'nx.test'; + } + updateFile(appJsonPath, JSON.stringify(appJson)); + + // run prebuild command with git check disable + process.env['EXPO_NO_GIT_STATUS'] = 'true'; + const prebuildResult = await runCLIAsync( + `prebuild ${appName} --no-interactive` + ); + expect(prebuildResult.combinedOutput).toContain('Config synced'); + }, 1_000_000); it('should build publishable library', async () => { const libName = uniq('lib'); diff --git a/packages/expo/src/executors/build-android/build-android.impl.ts b/packages/expo/src/executors/build-android/build-android.impl.ts index 560b5876319c4..67f2269593798 100644 --- a/packages/expo/src/executors/build-android/build-android.impl.ts +++ b/packages/expo/src/executors/build-android/build-android.impl.ts @@ -57,7 +57,7 @@ function runCliBuild( childProcess = fork( join(workspaceRoot, './node_modules/expo-cli/bin/expo.js'), ['build:android', ...createRunOptions(options)], - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ); // Ensure the child process is killed when the parent exits diff --git a/packages/expo/src/executors/build-ios/build-ios.impl.ts b/packages/expo/src/executors/build-ios/build-ios.impl.ts index 0b03c5c7cd76c..1e3f9d0cf07dd 100644 --- a/packages/expo/src/executors/build-ios/build-ios.impl.ts +++ b/packages/expo/src/executors/build-ios/build-ios.impl.ts @@ -57,7 +57,7 @@ function runCliBuildIOS( childProcess = fork( join(workspaceRoot, './node_modules/expo-cli/bin/expo.js'), ['build:ios', ...createRunOptions(options)], - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ); // Ensure the child process is killed when the parent exits diff --git a/packages/expo/src/executors/build-list/build-list.impl.ts b/packages/expo/src/executors/build-list/build-list.impl.ts index 9c49d61e8eab3..fa63d8f34fc63 100644 --- a/packages/expo/src/executors/build-list/build-list.impl.ts +++ b/packages/expo/src/executors/build-list/build-list.impl.ts @@ -31,7 +31,7 @@ export function runCliBuildList( `./node_modules/eas-cli/bin/run build:list ${createBuildListOptions( options ).join(' ')}`, - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ).toString(); } diff --git a/packages/expo/src/executors/build-status/build-status.impl.ts b/packages/expo/src/executors/build-status/build-status.impl.ts index d0c668fe69dd0..1820e5a4bbcd9 100644 --- a/packages/expo/src/executors/build-status/build-status.impl.ts +++ b/packages/expo/src/executors/build-status/build-status.impl.ts @@ -43,7 +43,7 @@ function runCliBuild( childProcess = fork( join(workspaceRoot, './node_modules/expo-cli/bin/expo.js'), ['build:status', ...createRunOptions(options)], - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ); // Ensure the child process is killed when the parent exits diff --git a/packages/expo/src/executors/build-web/build-web.impl.ts b/packages/expo/src/executors/build-web/build-web.impl.ts index 06ee6e259bcb9..c9f3e18085239 100644 --- a/packages/expo/src/executors/build-web/build-web.impl.ts +++ b/packages/expo/src/executors/build-web/build-web.impl.ts @@ -43,7 +43,7 @@ function runCliBuild( childProcess = fork( join(workspaceRoot, './node_modules/expo-cli/bin/expo.js'), ['build:web', ...createRunOptions(options)], - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ); // Ensure the child process is killed when the parent exits diff --git a/packages/expo/src/executors/build/build.impl.ts b/packages/expo/src/executors/build/build.impl.ts index ba2cd15e55c4c..c9e031a14ac7e 100644 --- a/packages/expo/src/executors/build/build.impl.ts +++ b/packages/expo/src/executors/build/build.impl.ts @@ -39,7 +39,7 @@ function runCliBuild( childProcess = fork( join(workspaceRoot, './node_modules/eas-cli/bin/run'), ['build', ...createBuildOptions(options)], - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ); // Ensure the child process is killed when the parent exits diff --git a/packages/expo/src/executors/export/export.impl.ts b/packages/expo/src/executors/export/export.impl.ts index 4c27a901a4b79..ecfb51e467b97 100644 --- a/packages/expo/src/executors/export/export.impl.ts +++ b/packages/expo/src/executors/export/export.impl.ts @@ -45,7 +45,7 @@ function exportAsync( '.', ...createExportOptions(options), ], - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ); // Ensure the child process is killed when the parent exits diff --git a/packages/expo/src/executors/install/install.impl.ts b/packages/expo/src/executors/install/install.impl.ts index 60e243ba7b78f..1ea78a4edcf5d 100644 --- a/packages/expo/src/executors/install/install.impl.ts +++ b/packages/expo/src/executors/install/install.impl.ts @@ -40,7 +40,7 @@ export function installAsync( childProcess = fork( join(workspaceRoot, './node_modules/@expo/cli/build/bin/cli'), ['install', ...createInstallOptions(options)], - { cwd: workspaceRoot } + { cwd: workspaceRoot, env: process.env } ); // Ensure the child process is killed when the parent exits diff --git a/packages/expo/src/executors/prebuild/prebuild.impl.ts b/packages/expo/src/executors/prebuild/prebuild.impl.ts index dba9469230f7c..8bf1363b1912c 100644 --- a/packages/expo/src/executors/prebuild/prebuild.impl.ts +++ b/packages/expo/src/executors/prebuild/prebuild.impl.ts @@ -51,7 +51,7 @@ function prebuildAsync( childProcess = fork( join(workspaceRoot, './node_modules/@expo/cli/build/bin/cli'), ['prebuild', ...createPrebuildOptions(options), '--no-install'], - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ); // Ensure the child process is killed when the parent exits @@ -71,13 +71,13 @@ function prebuildAsync( }); } -const nxOptions = ['install']; +const nxOptions = ['install', 'interactive']; // options from https://github.com/expo/expo/blob/main/packages/%40expo/cli/src/prebuild/index.ts function createPrebuildOptions(options: ExpoPrebuildOptions) { return Object.keys(options).reduce((acc, k) => { if (!nxOptions.includes(k)) { const v = options[k]; - acc.push(`--${names(k).fileName}`, v); + acc.push(`--${names(k).fileName}=${v}`); } return acc; }, []); diff --git a/packages/expo/src/executors/start/start.impl.ts b/packages/expo/src/executors/start/start.impl.ts index 4e79ff08b2ce4..156b3786c53ce 100644 --- a/packages/expo/src/executors/start/start.impl.ts +++ b/packages/expo/src/executors/start/start.impl.ts @@ -47,7 +47,7 @@ function startAsync( childProcess = fork( join(workspaceRoot, './node_modules/@expo/cli/build/bin/cli'), ['start', ...createStartOptions(options)], - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ); // Ensure the child process is killed when the parent exits diff --git a/packages/expo/src/executors/update/update.impl.ts b/packages/expo/src/executors/update/update.impl.ts index b44385afff761..e00aeb3297a4c 100644 --- a/packages/expo/src/executors/update/update.impl.ts +++ b/packages/expo/src/executors/update/update.impl.ts @@ -39,7 +39,7 @@ function runCliUpdate( childProcess = fork( join(workspaceRoot, './node_modules/eas-cli/bin/run'), ['update', ...createUpdateOptions(options)], - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ); // Ensure the child process is killed when the parent exits diff --git a/packages/react-native/src/executors/bundle/bundle.impl.ts b/packages/react-native/src/executors/bundle/bundle.impl.ts index a097cab59447a..01a5d5a4767b1 100644 --- a/packages/react-native/src/executors/bundle/bundle.impl.ts +++ b/packages/react-native/src/executors/bundle/bundle.impl.ts @@ -45,7 +45,7 @@ function runCliBuild( childProcess = fork( join(workspaceRoot, './node_modules/react-native/cli.js'), ['bundle', ...cliOptions], - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ); // Ensure the child process is killed when the parent exits diff --git a/packages/react-native/src/executors/start/start.impl.ts b/packages/react-native/src/executors/start/start.impl.ts index 6b80d5132cd91..e5eb20b14683f 100644 --- a/packages/react-native/src/executors/start/start.impl.ts +++ b/packages/react-native/src/executors/start/start.impl.ts @@ -82,7 +82,7 @@ function startAsync( childProcess = fork( join(workspaceRoot, './node_modules/react-native/cli.js'), ['start', ...createStartOptions(options)], - { cwd: join(workspaceRoot, projectRoot) } + { cwd: join(workspaceRoot, projectRoot), env: process.env } ); // Ensure the child process is killed when the parent exits