From f41536eb7d1fde1061b8bff3e060c7285bd7edcb Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Mon, 6 May 2024 19:13:18 +0200 Subject: [PATCH 1/4] fix(e2e): sync with React Native 0.74 --- __e2e__/__snapshots__/config.test.ts.snap | 8 ++++++- __e2e__/config.test.ts | 13 +---------- __e2e__/init.test.ts | 11 ++------- __e2e__/root.test.ts | 28 +++++++---------------- 4 files changed, 18 insertions(+), 42 deletions(-) diff --git a/__e2e__/__snapshots__/config.test.ts.snap b/__e2e__/__snapshots__/config.test.ts.snap index de4d477f0..b2b7c4c2a 100644 --- a/__e2e__/__snapshots__/config.test.ts.snap +++ b/__e2e__/__snapshots__/config.test.ts.snap @@ -4,7 +4,7 @@ exports[`shows up current config without unnecessary output 1`] = ` { "root": "<>/TestProject", "reactNativePath": "<>/TestProject/node_modules/react-native", - "reactNativeVersion": "0.73", + "reactNativeVersion": "0.74", "dependencies": {}, "commands": [ { @@ -72,6 +72,12 @@ exports[`shows up current config without unnecessary output 1`] = ` "options": [ "<>" ] + }, + { + "name": "codegen", + "options": [ + "<>" + ] } ], "healthChecks": [], diff --git a/__e2e__/config.test.ts b/__e2e__/config.test.ts index 9c4e99527..ecd954409 100644 --- a/__e2e__/config.test.ts +++ b/__e2e__/config.test.ts @@ -8,8 +8,6 @@ import { writeFiles, spawnScript, replaceProjectRootInOutput, - getAllPackages, - addRNCPrefix, } from '../jest/helpers'; const DIR = getTempDirectory('test_root'); @@ -38,15 +36,6 @@ function createCorruptedSetupEnvScript() { } beforeAll(() => { - const packages = getAllPackages(); - - // Register all packages to be linked - for (const pkg of packages) { - spawnScript('yarn', ['link'], { - cwd: path.join(__dirname, `../packages/${pkg}`), - }); - } - // Clean up folder and re-create a new project cleanup(DIR); writeFiles(DIR, {}); @@ -55,7 +44,7 @@ beforeAll(() => { runCLI(DIR, ['init', 'TestProject', '--install-pods']); // Link CLI to the project - spawnScript('yarn', ['link', ...addRNCPrefix(packages)], { + spawnScript('yarn', ['link', __dirname, '--all'], { cwd: path.join(DIR, 'TestProject'), }); }); diff --git a/__e2e__/init.test.ts b/__e2e__/init.test.ts index 99c66b648..162741178 100644 --- a/__e2e__/init.test.ts +++ b/__e2e__/init.test.ts @@ -1,15 +1,8 @@ import fs from 'fs'; import path from 'path'; import {runCLI, getTempDirectory, cleanup, writeFiles} from '../jest/helpers'; -import {execSync} from 'child_process'; -import semver from 'semver'; import slash from 'slash'; -const yarnVersion = semver.parse(execSync('yarn --version').toString().trim())!; - -// .yarnrc -> .yarnrc.yml >= 2.0.0: yarnpkg/berry/issues/239 -const yarnConfigFile = yarnVersion.major > 1 ? '.yarnrc.yml' : '.yarnrc'; - const DIR = getTempDirectory('command-init'); const PROJECT_NAME = 'TestInit'; @@ -30,7 +23,7 @@ function createCustomTemplateFiles() { const customTemplateCopiedFiles = [ '.git', '.yarn', - yarnConfigFile, + '.yarnrc.yml', // .yarnrc.yml for Yarn versions >= 2.0.0 'dir', 'file', 'node_modules', @@ -185,7 +178,7 @@ test('init uses npm as the package manager with --npm', () => { // Remove yarn specific files and node_modules const filteredFiles = customTemplateCopiedFiles.filter( (file) => - !['yarn.lock', 'node_modules', yarnConfigFile, '.yarn'].includes(file), + !['yarn.lock', 'node_modules', '.yarnrc.yml', '.yarn'].includes(file), ); // Add package-lock.json diff --git a/__e2e__/root.test.ts b/__e2e__/root.test.ts index e296c2d9e..6dfb642e0 100644 --- a/__e2e__/root.test.ts +++ b/__e2e__/root.test.ts @@ -6,45 +6,33 @@ import { getTempDirectory, cleanup, writeFiles, - addRNCPrefix, - getAllPackages, } from '../jest/helpers'; -const cwd = getTempDirectory('test_different_roots'); +const DIR = getTempDirectory('test_different_roots'); beforeAll(() => { - const packages = getAllPackages(); - - // Register all packages to be linked - for (const pkg of packages) { - spawnScript('yarn', ['link'], { - cwd: path.join(__dirname, `../packages/${pkg}`), - }); - } - // Clean up folder and re-create a new project - cleanup(cwd); - writeFiles(cwd, {}); + cleanup(DIR); + writeFiles(DIR, {}); // Initialise React Native project - runCLI(cwd, ['init', 'TestProject']); + runCLI(DIR, ['init', 'TestProject', '--install-pods']); // Link CLI to the project - - spawnScript('yarn', ['link', ...addRNCPrefix(packages)], { - cwd: path.join(cwd, 'TestProject'), + spawnScript('yarn', ['link', __dirname, '--all'], { + cwd: path.join(DIR, 'TestProject'), }); }); afterAll(() => { - cleanup(cwd); + cleanup(DIR); }); test('works when Gradle is run outside of the project hierarchy', async () => { /** * Location of Android project */ - const androidProjectRoot = path.join(cwd, 'TestProject/android'); + const androidProjectRoot = path.join(DIR, 'TestProject/android'); /* * Grab absolute path to Gradle wrapper. The fact that we are using From 6f1dc0ab8246a36155d073a3d6e12b3716ffe6d9 Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Mon, 6 May 2024 19:42:42 +0200 Subject: [PATCH 2/4] ci: bump gradle --- .github/workflows/test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3f8603d6a..3866e1386 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,9 +58,7 @@ jobs: distribution: 'zulu' java-version: 17 - - uses: gradle/gradle-build-action@v2 - with: - gradle-version: 8.0.1 + - uses: gradle/actions/setup-gradle@v3 - uses: ruby/setup-ruby@v1 if: runner.os == 'macOS' From 8f5e03ebc91a28e012b07d714e9cca6df3c8f74d Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Mon, 6 May 2024 19:51:57 +0200 Subject: [PATCH 3/4] fix: do not hardcode gradle version --- __e2e__/root.test.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/__e2e__/root.test.ts b/__e2e__/root.test.ts index 6dfb642e0..48e814f39 100644 --- a/__e2e__/root.test.ts +++ b/__e2e__/root.test.ts @@ -42,13 +42,9 @@ test('works when Gradle is run outside of the project hierarchy', async () => { const gradleWrapper = path.join(androidProjectRoot, 'gradlew'); // Make sure that we use `-bin` distribution of Gradle - await spawnScript( - gradleWrapper, - ['wrapper', '--gradle-version=8.0.1', '--distribution-type', 'bin'], - { - cwd: androidProjectRoot, - }, - ); + await spawnScript(gradleWrapper, ['wrapper', '--distribution-type', 'bin'], { + cwd: androidProjectRoot, + }); // Execute `gradle` with `-p` flag and `cwd` outside of project hierarchy const {stdout} = spawnScript(gradleWrapper, ['-p', androidProjectRoot], { From 6d101b4bd8daecce7f022f75d39878284aaec8a3 Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Tue, 7 May 2024 14:34:10 +0200 Subject: [PATCH 4/4] ci(win): try setting `shell: true` --- scripts/buildTs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/buildTs.js b/scripts/buildTs.js index 854a601b8..f727fca6a 100644 --- a/scripts/buildTs.js +++ b/scripts/buildTs.js @@ -35,7 +35,7 @@ console.log(chalk.inverse('Building TypeScript definition files')); process.stdout.write(adjustToTerminalWidth('Building\n')); try { - execa.sync('node', args, {stdio: 'inherit'}); + execa.sync('node', args, {stdio: 'inherit', shell: true}); process.stdout.write(`${OK}\n`); } catch (e) { process.stdout.write('\n');