From 572944eaeb28d0000a94b4ec55b2be2fcae0bc66 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Tue, 6 May 2025 11:28:14 +0200 Subject: [PATCH 1/3] fix: generate Ruby Bundler config in new projects --- .bundle/config | 2 ++ .gitignore | 2 ++ .rubocop.yml | 2 +- .yarn/plugins/clean.cjs | 9 +++++---- example/.gitignore | 2 ++ scripts/configure.mjs | 1 + test/configure/getConfig.test.ts | 1 + 7 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .bundle/config diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 000000000..c1c6d27db --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: ".bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/.gitignore b/.gitignore index 368d05c07..14ad4951f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ *.xcworkspace/ .DS_Store .android-test-* +.bundle/* +!.bundle/config .ccache/* !.ccache/ccache.conf .cxx/ diff --git a/.rubocop.yml b/.rubocop.yml index 7846a1402..e9a144ae6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,4 @@ -require: +plugins: - rubocop-minitest AllCops: diff --git a/.yarn/plugins/clean.cjs b/.yarn/plugins/clean.cjs index 492967646..1ecc30919 100644 --- a/.yarn/plugins/clean.cjs +++ b/.yarn/plugins/clean.cjs @@ -26,10 +26,11 @@ module.exports = { ); fs.rmSync(symlink, { force: true, maxRetries: 3, recursive: true }); - spawnSync("git", ["clean", "-dfqx", "--exclude=.yarn/cache"], { - cwd: projectRoot, - stdio: "inherit", - }); + spawnSync( + "git", + ["clean", "-dfqx", "--exclude=.bundle", "--exclude=.yarn/cache"], + { cwd: projectRoot, stdio: "inherit" } + ); } } diff --git a/example/.gitignore b/example/.gitignore index 65aa665cb..12680029e 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -3,6 +3,8 @@ *.xcworkspace/ *.zip .DS_Store +.bundle/* +!.bundle/config .gradle/ .idea/ .vs/ diff --git a/scripts/configure.mjs b/scripts/configure.mjs index fc3c37f32..80e2a4b05 100755 --- a/scripts/configure.mjs +++ b/scripts/configure.mjs @@ -305,6 +305,7 @@ export const getConfig = (() => { : { "App.js": copyFrom(templateDir, "App.js"), }), + ".bundle/config": copyFrom(testAppPath, ".bundle", "config"), Gemfile: copyFrom(templateDir, "Gemfile"), "app.json": appManifest(name), "index.js": copyFrom(templateDir, "index.js"), diff --git a/test/configure/getConfig.test.ts b/test/configure/getConfig.test.ts index 032a57a4d..783a59e77 100644 --- a/test/configure/getConfig.test.ts +++ b/test/configure/getConfig.test.ts @@ -45,6 +45,7 @@ describe("getConfig()", () => { const config = getConfig(params, "common"); deepEqual(Object.keys(config.files).sort(), [ + ".bundle/config", ".gitignore", ".watchmanconfig", "App.tsx", From d86717e4b7995a857b315f5328cc3ae168394cb9 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Tue, 6 May 2025 11:42:42 +0200 Subject: [PATCH 2/3] include `.bundle/config` --- package.json | 1 + test/pack.test.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/package.json b/package.json index 804a71c0e..4d3c5bdf4 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ }, "files": [ "*.md", + ".bundle/config", "ReactTestApp-DevSupport.podspec", "android/**/*.gradle", "android/android-manifest.js", diff --git a/test/pack.test.ts b/test/pack.test.ts index ba223d1e0..b32053251 100644 --- a/test/pack.test.ts +++ b/test/pack.test.ts @@ -26,6 +26,7 @@ describe("npm pack", () => { .sort(); deepEqual(content, [ + ".bundle/config", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "LICENSE", From f9240fd6a804f5d8565bf44adf98b0959db8a75c Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Tue, 6 May 2025 13:53:25 +0200 Subject: [PATCH 3/3] don't check in '.bundle/config' --- .bundle/config | 2 -- .gitignore | 2 -- .yarn/plugins/clean.cjs | 9 ++++----- Gemfile.lock | 2 +- package.json | 1 - scripts/configure.mjs | 3 ++- scripts/template.mjs | 12 ++++++++++++ test/pack.test.ts | 1 - 8 files changed, 19 insertions(+), 13 deletions(-) delete mode 100644 .bundle/config diff --git a/.bundle/config b/.bundle/config deleted file mode 100644 index c1c6d27db..000000000 --- a/.bundle/config +++ /dev/null @@ -1,2 +0,0 @@ -BUNDLE_PATH: ".bundle" -BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/.gitignore b/.gitignore index 14ad4951f..368d05c07 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,6 @@ *.xcworkspace/ .DS_Store .android-test-* -.bundle/* -!.bundle/config .ccache/* !.ccache/ccache.conf .cxx/ diff --git a/.yarn/plugins/clean.cjs b/.yarn/plugins/clean.cjs index 1ecc30919..492967646 100644 --- a/.yarn/plugins/clean.cjs +++ b/.yarn/plugins/clean.cjs @@ -26,11 +26,10 @@ module.exports = { ); fs.rmSync(symlink, { force: true, maxRetries: 3, recursive: true }); - spawnSync( - "git", - ["clean", "-dfqx", "--exclude=.bundle", "--exclude=.yarn/cache"], - { cwd: projectRoot, stdio: "inherit" } - ); + spawnSync("git", ["clean", "-dfqx", "--exclude=.yarn/cache"], { + cwd: projectRoot, + stdio: "inherit", + }); } } diff --git a/Gemfile.lock b/Gemfile.lock index 2905dfbc0..d4ee72317 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,4 +64,4 @@ DEPENDENCIES xcodeproj BUNDLED WITH - 2.5.14 + 2.6.8 diff --git a/package.json b/package.json index 4d3c5bdf4..804a71c0e 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ }, "files": [ "*.md", - ".bundle/config", "ReactTestApp-DevSupport.podspec", "android/**/*.gradle", "android/android-manifest.js", diff --git a/scripts/configure.mjs b/scripts/configure.mjs index 80e2a4b05..bf58fd8b3 100755 --- a/scripts/configure.mjs +++ b/scripts/configure.mjs @@ -29,6 +29,7 @@ import { import { appManifest, buildGradle, + bundleConfig, gradleProperties, podfile, serialize, @@ -305,7 +306,7 @@ export const getConfig = (() => { : { "App.js": copyFrom(templateDir, "App.js"), }), - ".bundle/config": copyFrom(testAppPath, ".bundle", "config"), + ".bundle/config": bundleConfig(), Gemfile: copyFrom(templateDir, "Gemfile"), "app.json": appManifest(name), "index.js": copyFrom(templateDir, "index.js"), diff --git a/scripts/template.mjs b/scripts/template.mjs index 465dfcc16..bab239cbd 100644 --- a/scripts/template.mjs +++ b/scripts/template.mjs @@ -97,6 +97,18 @@ export function buildGradle() { ); } +/** + * Returns `.bundle/config`. + * + * @note We don't use a checked in file because of + * https://github.com/ruby/setup-ruby/discussions/576. + * + * @returns {string} + */ +export function bundleConfig() { + return join('BUNDLE_PATH: ".bundle"', "BUNDLE_FORCE_RUBY_PLATFORM: 1"); +} + /** * @param {number} targetVersion Target React Native version * @returns {string} diff --git a/test/pack.test.ts b/test/pack.test.ts index b32053251..ba223d1e0 100644 --- a/test/pack.test.ts +++ b/test/pack.test.ts @@ -26,7 +26,6 @@ describe("npm pack", () => { .sort(); deepEqual(content, [ - ".bundle/config", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "LICENSE",