diff --git a/__e2e__/config.test.ts b/__e2e__/config.test.ts index 75cce706a..cd2c5560c 100644 --- a/__e2e__/config.test.ts +++ b/__e2e__/config.test.ts @@ -8,6 +8,8 @@ import { writeFiles, spawnScript, replaceProjectRootInOutput, + getAllPackages, + addRNCPrefix, } from '../jest/helpers'; const DIR = getTempDirectory('test_root'); @@ -36,8 +38,10 @@ function createCorruptedSetupEnvScript() { } beforeAll(() => { + const packages = getAllPackages(); + // Register all packages to be linked - for (const pkg of ['cli-platform-ios', 'cli-platform-android']) { + for (const pkg of packages) { spawnScript('yarn', ['link'], { cwd: path.join(__dirname, `../packages/${pkg}`), }); @@ -48,18 +52,17 @@ beforeAll(() => { writeFiles(DIR, {}); // Initialise React Native project - - runCLI(DIR, ['init', 'TestProject', '--install-pods']); + runCLI(DIR, ['init', 'TestProject']); // Link CLI to the project - const pkgs = [ - '@react-native-community/cli-platform-ios', - '@react-native-community/cli-platform-android', - ]; - - spawnScript('yarn', ['link', ...pkgs], { + spawnScript('yarn', ['link', ...addRNCPrefix(packages)], { cwd: path.join(DIR, 'TestProject'), }); + + // Install pods after linking packages because Podfile uses `use_native_modules` function that executes `config` command. In case there was introduce breaking change in `cli-config` package, it will fail since it will be using old version of the package. + spawnScript('pod', ['install'], { + cwd: path.join(DIR, 'TestProject', 'ios'), + }); }); afterAll(() => { diff --git a/__e2e__/root.test.ts b/__e2e__/root.test.ts index ade652f8b..a3253d8c9 100644 --- a/__e2e__/root.test.ts +++ b/__e2e__/root.test.ts @@ -6,13 +6,17 @@ import { getTempDirectory, cleanup, writeFiles, + addRNCPrefix, + getAllPackages, } from '../jest/helpers'; const cwd = getTempDirectory('test_different_roots'); beforeAll(() => { + const packages = getAllPackages(); + // Register all packages to be linked - for (const pkg of ['cli-platform-ios', 'cli-platform-android']) { + for (const pkg of packages) { spawnScript('yarn', ['link'], { cwd: path.join(__dirname, `../packages/${pkg}`), }); @@ -23,14 +27,11 @@ beforeAll(() => { writeFiles(cwd, {}); // Initialise React Native project - runCLI(cwd, ['init', 'TestProject', '--install-pods']); + runCLI(cwd, ['init', 'TestProject']); + // Link CLI to the project - const pkgs = [ - '@react-native-community/cli-platform-ios', - '@react-native-community/cli-platform-android', - ]; - spawnScript('yarn', ['link', ...pkgs], { + spawnScript('yarn', ['link', ...addRNCPrefix(packages)], { cwd: path.join(cwd, 'TestProject'), }); }); diff --git a/jest/helpers.ts b/jest/helpers.ts index f65a779b9..20f1ed003 100644 --- a/jest/helpers.ts +++ b/jest/helpers.ts @@ -207,3 +207,11 @@ export function replaceProjectRootInOutput(output: string, testFolder: string) { const regex = new RegExp(`(:\\s").*(${slash(testFolder)})`, 'g'); return slash(output).replace(regex, '$1<>'); } + +export function getAllPackages() { + return fs.readdirSync(path.resolve(__dirname, '../packages')); +} + +export function addRNCPrefix(packages: string[]) { + return packages.map((p) => `@react-native-community/${p}`); +} diff --git a/packages/cli-platform-ios/src/tools/installPods.ts b/packages/cli-platform-ios/src/tools/installPods.ts index d49866a96..32bd75eea 100644 --- a/packages/cli-platform-ios/src/tools/installPods.ts +++ b/packages/cli-platform-ios/src/tools/installPods.ts @@ -37,6 +37,7 @@ async function runPodInstall(loader: Ora, options?: RunPodInstallOptions) { }, }); } catch (error) { + logger.debug(error as string); // "pod" command outputs errors to stdout (at least some of them) const stderr = (error as any).stderr || (error as any).stdout;