Skip to content

Commit c750a8e

Browse files
authored
Merge pull request #5193 from wordpress-mobile/rnmobile/upgrade/0.69.4
React Native 0.69.4 Upgrade
2 parents 7e410e6 + a86a685 commit c750a8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6435
-6942
lines changed

bin/generate-podspecs.sh

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ done
9999
# Change to the React Native directory to get relative paths for the RN podspecs
100100
cd "$NODE_MODULES_DIR/react-native"
101101

102-
RN_PODSPECS=$(find * -type f -name "*.podspec" -not -path "third-party-podspecs/*" -not -path "*Fabric*" -print)
102+
RN_DIR="./"
103+
SCRIPTS_PATH="./scripts/"
104+
CODEGEN_REPO_PATH="../packages/react-native-codegen"
105+
CODEGEN_NPM_PATH="../react-native-codegen"
106+
SRCS_DIR=${SRCS_DIR:-$(cd "./Libraries" && pwd)}
107+
RN_VERSION=$(cat ./package.json | grep -m 1 version | sed 's/[^0-9.]//g')
108+
109+
RN_PODSPECS=$(find * -type f -name "*.podspec" -not -name "React-rncore.podspec" -not -path "third-party-podspecs/*" -not -path "*Fabric*" -print)
103110
TMP_DEST=$(mktemp -d)
104111

105112
for podspec in $RN_PODSPECS
@@ -109,6 +116,8 @@ do
109116

110117
echo "Generating podspec for $pod with path $path"
111118
pod ipc spec "$podspec" > "$TMP_DEST/$pod.podspec.json"
119+
# Removes message [Codegen] Found at the beginning of the file
120+
sed -i '' -e '/\[Codegen\] Found/d' "$TMP_DEST/$pod.podspec.json"
112121
cat "$TMP_DEST/$pod.podspec.json" | jq > "$DEST/$pod.podspec.json"
113122

114123
# Add a "prepare_command" entry to each podspec so that 'pod install' will fetch sources from the correct directory
@@ -135,7 +144,50 @@ do
135144
# They are normally generated during compile time using a Script Phase in FBReactNativeSpec added via the `use_react_native_codegen` function.
136145
# This script is inside node_modules/react-native/scripts folder. Since we don't have the node_modules when compiling WPiOS,
137146
# we're calling the script here manually to generate these files ahead of time.
138-
MODULES_OUTPUT_DIR=$DEST/FBReactNativeSpec ./scripts/generate-specs.sh
147+
SCHEMA_FILE="$TMP_DEST/schema.json"
148+
NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"
149+
150+
if [ -d "$CODEGEN_REPO_PATH" ]; then
151+
CODEGEN_PATH=$(cd "$CODEGEN_REPO_PATH" && pwd)
152+
elif [ -d "$CODEGEN_NPM_PATH" ]; then
153+
CODEGEN_PATH=$(cd "$CODEGEN_NPM_PATH" && pwd)
154+
else
155+
echo "Error: Could not determine react-native-codegen location. Try running 'yarn install' or 'npm install' in your project root." 1>&2
156+
exit 1
157+
fi
158+
159+
if [ ! -d "$CODEGEN_PATH/lib" ]; then
160+
describe "Building react-native-codegen package"
161+
bash "$CODEGEN_PATH/scripts/oss/build.sh"
162+
fi
163+
164+
# Generate React-Codegen
165+
# A copy of react_native_pods is done to modify the content within get_react_codegen_spec
166+
# this enables getting the schema for React-Codegen in runtime by printing the content.
167+
echo "Generating React-Codegen"
168+
REACT_NATIVE_PODS_PATH="$SCRIPTS_PATH/react_native_pods.rb"
169+
REACT_NATIVE_PODS_MODIFIED_PATH="$SCRIPTS_PATH/react_native_pods_modified.rb"
170+
# Making a temp copy of react_native_pods.rb
171+
cp $REACT_NATIVE_PODS_PATH $REACT_NATIVE_PODS_MODIFIED_PATH
172+
# Modify the get_react_codegen_spec method to return the result using print and JSON.pretty
173+
sed -i '' -e "s/:git => ''/:git => 'https:\/\/github.com\/facebook\/react-native.git', :tag => 'v$RN_VERSION'/" "$REACT_NATIVE_PODS_MODIFIED_PATH"
174+
sed -i '' -e 's/return spec/print JSON.pretty_generate(spec)/' "$REACT_NATIVE_PODS_MODIFIED_PATH"
175+
# Run get_react_codegen_spec and generate React-Codegen.podspec.json
176+
ruby -r "./scripts/react_native_pods_modified.rb" -e "get_react_codegen_spec" > "$DEST/React-Codegen.podspec.json"
177+
TMP_ReactCodeGenSpec=$(mktemp)
178+
jq '.source_files = "third-party-podspecs/FBReactNativeSpec/**/*.{c,h,m,mm,cpp}"' "$DEST/React-Codegen.podspec.json" > "$TMP_ReactCodeGenSpec"
179+
mv "$TMP_ReactCodeGenSpec" "$DEST/React-Codegen.podspec.json"
180+
# Remove temp copy of react_native_pods.rb
181+
rm $REACT_NATIVE_PODS_MODIFIED_PATH
182+
183+
echo "Generating schema from Flow types"
184+
"$NODE_BINARY" "$CODEGEN_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR"
185+
186+
echo "Generating native code from schema (iOS)"
187+
"$NODE_BINARY" "./scripts/generate-specs-cli.js" -p "ios" -s "$SCHEMA_FILE" -o "$DEST/FBReactNativeSpec"
188+
189+
# Removing unneeded files
190+
find "$DEST/FBReactNativeSpec" -type f -not -name "FBReactNativeSpec.podspec.json" -not -name "FBReactNativeSpec-generated.mm" -not -name "FBReactNativeSpec.h" -not -name "FBReactNativeSpec.h" -delete
139191

140192
# Removing 'script_phases' that shouldn't be needed anymore.
141193
# Removing 'prepare_command' that includes additional steps to create intermediate folders to keep generated files which won't be needed.
@@ -144,4 +196,4 @@ do
144196
jq --arg COMMIT_HASH "$COMMIT_HASH" 'del(.script_phases) | del(.prepare_command) | del(.source.tag) | .source.git = "https://github.com/wordpress-mobile/gutenberg-mobile.git" | .source.commit = $COMMIT_HASH | .source.submodules = "true" | .source_files = "third-party-podspecs/FBReactNativeSpec/**/*.{c,h,m,mm,cpp}"' "$DEST/FBReactNativeSpec/FBReactNativeSpec.podspec.json" > "$TMP_FBReactNativeSpec"
145197
mv "$TMP_FBReactNativeSpec" "$DEST/FBReactNativeSpec/FBReactNativeSpec.podspec.json"
146198
fi
147-
done
199+
done

bundle/ios/App.js

Lines changed: 3681 additions & 3682 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/ios/App.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gutenberg

Submodule gutenberg updated 298 files

0 commit comments

Comments
 (0)