diff --git a/.github/actions/test-library-on-nightly/action.yml b/.github/actions/test-library-on-nightly/action.yml index f108f69..d3ab8ae 100644 --- a/.github/actions/test-library-on-nightly/action.yml +++ b/.github/actions/test-library-on-nightly/action.yml @@ -11,6 +11,10 @@ inputs: description: Number of retry attempts for failed operations required: false default: '3' + patch-file: + description: Optional path to a patch file to apply after installing the library + required: false + default: '' runs: using: composite steps: @@ -19,6 +23,22 @@ runs: run: | cd /tmp npx @react-native-community/cli init RNApp --skip-install --version nightly + + + - name: Apply patch if specified + if: ${{ inputs.patch-file != '' }} + shell: bash + run: | + if [ -f "$GITHUB_WORKSPACE/${{ inputs.patch-file }}" ]; then + echo "Applying patch: ${{ inputs.patch-file }}" + cd /tmp/RNApp + node "$GITHUB_WORKSPACE/scripts/apply-patch.js" "$GITHUB_WORKSPACE/${{ inputs.patch-file }}" + echo "✅ Patch applied successfully" + else + echo "⚠️ Warning: Patch file not found: ${{ inputs.patch-file }}" + exit 1 + fi + - name: Add library with retry uses: nick-fields/retry@v3 with: diff --git a/.github/workflows/check-nightly.yml b/.github/workflows/check-nightly.yml index f9ec4f5..4565c31 100644 --- a/.github/workflows/check-nightly.yml +++ b/.github/workflows/check-nightly.yml @@ -45,4 +45,4 @@ jobs: firebase_app_email: ${{ secrets.FIREBASE_APP_EMAIL }} firebase_app_pass: ${{ secrets.FIREBASE_APP_PASS }} firebase_app_projectname: ${{ secrets.FIREBASE_APP_PROJECTNAME }} - firebase_app_apikey: ${{ secrets.FIREBASE_APP_APIKEY }} + firebase_app_apikey: ${{ secrets.FIREBASE_APP_APIKEY }} \ No newline at end of file diff --git a/.github/workflows/pr-check-new-entries.yml b/.github/workflows/pr-check-new-entries.yml index 59f03d5..ad0822a 100644 --- a/.github/workflows/pr-check-new-entries.yml +++ b/.github/workflows/pr-check-new-entries.yml @@ -62,3 +62,4 @@ jobs: with: library-npm-package: ${{ fromJSON(needs.runner-setup.outputs.library-data)[matrix.library].installCommand }} platform: ${{ matrix.platform }} + patch-file: ${{ fromJSON(needs.runner-setup.outputs.library-data)[matrix.library].patchFile || '' }} diff --git a/.github/workflows/test-libraries-on-nightlies.yml b/.github/workflows/test-libraries-on-nightlies.yml index c5cc921..099b52e 100644 --- a/.github/workflows/test-libraries-on-nightlies.yml +++ b/.github/workflows/test-libraries-on-nightlies.yml @@ -58,6 +58,7 @@ jobs: with: library-npm-package: ${{ fromJSON(needs.runner-setup.outputs.library-data)[matrix.library].installCommand }} platform: ${{ matrix.platform }} + patch-file: ${{ fromJSON(needs.runner-setup.outputs.library-data)[matrix.library].patchFile || '' }} - name: Save outcome id: save-outcome if: always() @@ -71,7 +72,7 @@ jobs: with: name: ${{ steps.save-outcome.outputs.lib_folder }}-${{ matrix.platform }}-outcome path: /tmp/${{ steps.save-outcome.outputs.lib_folder }}-${{ matrix.platform }}-outcome - + collect-results: runs-on: ubuntu-latest needs: [test-library-on-nightly] diff --git a/.gitignore b/.gitignore index 351fbe0..f25b90e 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,8 @@ jspm_packages/ !.yarn/releases !.yarn/sdks !.yarn/versions + +#Tmp Templates +tmp/ + + diff --git a/README.md b/README.md index 4746c73..fb43a4f 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,10 @@ The repository includes Jest tests for the workflow scripts. To run the tests lo yarn install && yarn test ``` +### Working with Patch Files + +Some libraries may require modifications to the React Native template (e.g., editing pod files, manifest files) to work properly with nightly builds. For detailed instructions on creating and applying patch files, see the [Patch Instructions](patch.md) guide. + ## 📄 License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. diff --git a/libraries.json b/libraries.json index 85c518a..8bddc82 100644 --- a/libraries.json +++ b/libraries.json @@ -87,6 +87,15 @@ "maintainersUsernames": [], "notes": "" }, + "react-native-firebase": { + "description": "🔥 A well-tested feature-rich modular Firebase implementation for React Native", + "installCommand": "@react-native-firebase/app", + "android": true, + "ios": true, + "maintainersUsernames": [], + "notes": "", + "patchFile": "patches/react-native-firebase.patch" + }, "react-native-svg": { "description": "SVG library for React Native, React Native Web, and plain React web projects", "installCommand": "react-native-svg", @@ -116,7 +125,7 @@ "installCommand": "react-native-mmkv", "android": true, "ios": true, - "maintainersUsernames": [], + "maintainersUsernames": ["mrousavy"], "notes": "" }, "react-native-nitro-modules": { diff --git a/libraries.schema.json b/libraries.schema.json index f6199b2..21351a6 100644 --- a/libraries.schema.json +++ b/libraries.schema.json @@ -50,6 +50,14 @@ "Build currently broken due to X reason.", "One of top most used libraries according to the npm stats." ] + }, + "patchFile": { + "type": "string", + "description": "Optional path to a patch file (relative to repo root) to apply after installing the library but before building. Patch should be created using 'git diff --binary' format (e.g., using scripts/make-patch.js).", + "examples": [ + "patches/react-native-reanimated.patch", + "patches/library-name-fix.patch" + ] } }, "required": [ diff --git a/patch.md b/patch.md new file mode 100644 index 0000000..558d83e --- /dev/null +++ b/patch.md @@ -0,0 +1,67 @@ +# Patch Instructions + +This guide covers how to generate a patch file for your libraries. This is helpful in cases where you need to edit pod files, manifest files, etc. + +## How to Generate a Patch File + +### Step 1: Create a New Project + +Clone this repository, then create a new project with the following command: + +```sh +npx @react-native-community/cli@latest init RNApp --version nightly --skip-install --directory tmp/RNApp +``` + +### Step 2: Navigate to the Directory + +```sh +cd tmp/RNApp +``` + +### Step 3: Make Necessary Changes + +Make the necessary changes to the template. + +### Step 4: Generate the Patch File + +```sh +node ../../scripts/make-patch.js ../../patches/{libraryName}.patch +``` + +For example: +```sh +node ../../scripts/make-patch.js ../../patches/react-native-turbo-encryption.patch +``` + +This will generate a patch file in the patches folder. + +**Note:** Remove any lock files like `yarn.lock`, `Podfile.lock`, or any generated files that are tracked before generating the patch file, as these can lead to an excessively long patch file. + +### Step 5: Verify the Patch File + +```sh +node ../../scripts/apply-patch.js ../../patches/{libraryName}.patch +``` +For example: +```sh +node ../../scripts/apply-patch.js ../../patches/react-native-turbo-encryption.patch +``` + + +### Step 6: Add the Patch File to `libraries.json` + +```json +"react-native-reanimated": { + "description": "React Native's Animated library reimplemented", + "installCommand": "react-native-reanimated@nightly react-native-worklets@nightly", + "android": true, + "ios": true, + "maintainersUsernames": [], + "notes": "", + "patchFile": "patches/reanimated.patch" # <-- Path to patch file + } +``` + +### Step 7: Submit Your Changes + +Push the changes and create a pull request. Your patch file is ready! \ No newline at end of file diff --git a/patches/.gitkeep b/patches/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/patches/react-native-firebase.patch b/patches/react-native-firebase.patch new file mode 100644 index 0000000..f933f03 --- /dev/null +++ b/patches/react-native-firebase.patch @@ -0,0 +1,13 @@ +diff --git a/ios/Podfile b/ios/Podfile +index b4aa3be..cb46b59 100644 +--- a/ios/Podfile ++++ b/ios/Podfile +@@ -17,6 +17,8 @@ end + target 'RNApp' do + config = use_native_modules! + ++ use_frameworks! :linkage => :static ++ $RNFirebaseAsStaticFramework = true + use_react_native!( + :path => config[:reactNativePath], + # An absolute path to your application root. diff --git a/scripts/apply-patch.js b/scripts/apply-patch.js new file mode 100755 index 0000000..8b820a7 --- /dev/null +++ b/scripts/apply-patch.js @@ -0,0 +1,48 @@ +#!/usr/bin/env node +/** + * apply-patch.js + * Applies a patch file to the current directory + * + * Usage: + * node scripts/apply-patch.js + */ + +const { execSync } = require("child_process"); +const fs = require("fs"); +const path = require("path"); + +// Get patch file from arguments +const patchFile = process.argv[2]; + +if (!patchFile) { + console.error("Usage: node scripts/apply-patch.js "); + console.error("Example: node scripts/apply-patch.js patches/my-fix.patch"); + process.exit(1); +} + +try { + // Check if we're in a git repository + execSync("git rev-parse --is-inside-work-tree", { stdio: "ignore" }); + + // Check if patch file exists + const patchPath = path.resolve(process.cwd(), patchFile); + if (!fs.existsSync(patchPath)) { + console.error(`❌ Patch file not found: ${patchPath}`); + process.exit(1); + } + + console.log(`Applying patch: ${patchFile}`); + + // Apply the patch + execSync(`git apply --binary --3way --whitespace=nowarn "${patchPath}"`, { + stdio: "inherit", + encoding: "utf8" + }); + + console.log("✅ Patch applied successfully!"); + +} catch (err) { + console.error("❌ Failed to apply patch"); + console.error(err.message); + process.exit(1); +} diff --git a/scripts/make-patch.js b/scripts/make-patch.js new file mode 100755 index 0000000..9cfcaca --- /dev/null +++ b/scripts/make-patch.js @@ -0,0 +1,55 @@ +#!/usr/bin/env node +/** + * make-patch.js + * Creates a patch file from all current changes (staged and unstaged) + * + * Usage: + * node scripts/make-patch.js [output-filename] + * + * If no filename is provided, generates one with timestamp. + */ + +const { execSync } = require("child_process"); +const fs = require("fs"); +const path = require("path"); + +// Get output filename from args or generate timestamp-based name +const outputFile = process.argv[2] || (() => { + const d = new Date(); + const pad = n => String(n).padStart(2, "0"); + return `patch-${d.getFullYear()}${pad(d.getMonth()+1)}${pad(d.getDate())}-${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}.patch`; +})(); + +try { + // Check if we're in a git repository + execSync("git rev-parse --is-inside-work-tree", { stdio: "ignore" }); + + // Create diff of all changes (staged + unstaged + untracked) + console.log("Creating patch from all changes..."); + + // Stage untracked files temporarily (without content) + execSync("git add -N .", { stdio: "ignore" }); + + // Generate the patch + const patch = execSync("git diff HEAD --binary", { + encoding: "utf8", + maxBuffer: 100 * 1024 * 1024 // 100MB buffer + }); + + if (!patch.trim()) { + console.log("No changes found. Nothing to patch."); + process.exit(0); + } + + // Write patch file + const outputPath = path.resolve(process.cwd(), outputFile); + fs.writeFileSync(outputPath, patch, "utf8"); + + console.log(`✅ Patch created successfully: ${outputPath}`); + console.log(` To apply: node scripts/apply-patch.js ${outputFile}`); + +} catch (err) { + console.error("❌ Error creating patch:"); + console.error(err.message); + process.exit(1); +}