-
Notifications
You must be signed in to change notification settings - Fork 14
Add Support for patches in nightly #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
46fcc8e
Fix Lint
riteshshukla04 d4c9019
This will be probably run
riteshshukla04 83ac7dd
This will be probably run
riteshshukla04 65f6cc3
This will be probably run
riteshshukla04 4efd222
This will be probably run
riteshshukla04 87fbafa
Fix Lint
riteshshukla04 3ae1658
Fix Lint
riteshshukla04 f7c6b97
Fix Lint
riteshshukla04 dd9a6c3
Fix Lint
riteshshukla04 05e44df
Add usage instruction
riteshshukla04 919da72
Add usage instruction
riteshshukla04 697eeb4
Solved Nits
riteshshukla04 f60d78e
Solved Nits
riteshshukla04 e303563
Fixed issue where Libraries changed are not considered
riteshshukla04 11f59d5
Added a non patched library just to be safe
riteshshukla04 e8cbd65
Description updated
riteshshukla04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
diff --git a/babel.config.js b/babel.config.js | ||
index f7b3da3..8ba8eb6 100644 | ||
--- a/babel.config.js | ||
+++ b/babel.config.js | ||
@@ -1,3 +1,4 @@ | ||
module.exports = { | ||
presets: ['module:@react-native/babel-preset'], | ||
+ plugins: ['react-native-worklets/plugin'], | ||
riteshshukla04 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <patchfile> | ||
*/ | ||
|
||
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 <patchfile>"); | ||
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); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.