Skip to content
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

React Native 0.69.4 Upgrade #5193

Merged
merged 14 commits into from
Dec 2, 2022
58 changes: 55 additions & 3 deletions bin/generate-podspecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ done
# Change to the React Native directory to get relative paths for the RN podspecs
cd "$NODE_MODULES_DIR/react-native"

RN_PODSPECS=$(find * -type f -name "*.podspec" -not -path "third-party-podspecs/*" -not -path "*Fabric*" -print)
RN_DIR="./"
SCRIPTS_PATH="./scripts/"
CODEGEN_REPO_PATH="../packages/react-native-codegen"
CODEGEN_NPM_PATH="../react-native-codegen"
SRCS_DIR=${SRCS_DIR:-$(cd "./Libraries" && pwd)}
RN_VERSION=$(cat ./package.json | grep -m 1 version | sed 's/[^0-9.]//g')

RN_PODSPECS=$(find * -type f -name "*.podspec" -not -name "React-rncore.podspec" -not -path "third-party-podspecs/*" -not -path "*Fabric*" -print)
TMP_DEST=$(mktemp -d)

for podspec in $RN_PODSPECS
Expand All @@ -109,6 +116,8 @@ do

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

# Add a "prepare_command" entry to each podspec so that 'pod install' will fetch sources from the correct directory
Expand All @@ -135,7 +144,50 @@ do
# They are normally generated during compile time using a Script Phase in FBReactNativeSpec added via the `use_react_native_codegen` function.
# This script is inside node_modules/react-native/scripts folder. Since we don't have the node_modules when compiling WPiOS,
# we're calling the script here manually to generate these files ahead of time.
MODULES_OUTPUT_DIR=$DEST/FBReactNativeSpec ./scripts/generate-specs.sh
SCHEMA_FILE="$TMP_DEST/schema.json"
NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"

if [ -d "$CODEGEN_REPO_PATH" ]; then
CODEGEN_PATH=$(cd "$CODEGEN_REPO_PATH" && pwd)
elif [ -d "$CODEGEN_NPM_PATH" ]; then
CODEGEN_PATH=$(cd "$CODEGEN_NPM_PATH" && pwd)
else
echo "Error: Could not determine react-native-codegen location. Try running 'yarn install' or 'npm install' in your project root." 1>&2
exit 1
fi

if [ ! -d "$CODEGEN_PATH/lib" ]; then
describe "Building react-native-codegen package"
bash "$CODEGEN_PATH/scripts/oss/build.sh"
fi

# Generate React-Codegen
# A copy of react_native_pods is done to modify the content within get_react_codegen_spec
# this enables getting the schema for React-Codegen in runtime by printing the content.
echo "Generating React-Codegen"
REACT_NATIVE_PODS_PATH="$SCRIPTS_PATH/react_native_pods.rb"
REACT_NATIVE_PODS_MODIFIED_PATH="$SCRIPTS_PATH/react_native_pods_modified.rb"
# Making a temp copy of react_native_pods.rb
cp $REACT_NATIVE_PODS_PATH $REACT_NATIVE_PODS_MODIFIED_PATH
# Modify the get_react_codegen_spec method to return the result using print and JSON.pretty
sed -i '' -e "s/:git => ''/:git => 'https:\/\/github.com\/facebook\/react-native.git', :tag => 'v$RN_VERSION'/" "$REACT_NATIVE_PODS_MODIFIED_PATH"
sed -i '' -e 's/return spec/print JSON.pretty_generate(spec)/' "$REACT_NATIVE_PODS_MODIFIED_PATH"
# Run get_react_codegen_spec and generate React-Codegen.podspec.json
ruby -r "./scripts/react_native_pods_modified.rb" -e "get_react_codegen_spec" > "$DEST/React-Codegen.podspec.json"
TMP_ReactCodeGenSpec=$(mktemp)
jq '.source_files = "third-party-podspecs/FBReactNativeSpec/**/*.{c,h,m,mm,cpp}"' "$DEST/React-Codegen.podspec.json" > "$TMP_ReactCodeGenSpec"
mv "$TMP_ReactCodeGenSpec" "$DEST/React-Codegen.podspec.json"
# Remove temp copy of react_native_pods.rb
rm $REACT_NATIVE_PODS_MODIFIED_PATH

echo "Generating schema from Flow types"
"$NODE_BINARY" "$CODEGEN_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR"

echo "Generating native code from schema (iOS)"
"$NODE_BINARY" "./scripts/generate-specs-cli.js" -p "ios" -s "$SCHEMA_FILE" -o "$DEST/FBReactNativeSpec"

# Removing unneeded files
find "$DEST/FBReactNativeSpec" -type f -not -name "FBReactNativeSpec.podspec.json" -not -name "FBReactNativeSpec-generated.mm" -not -name "FBReactNativeSpec.h" -not -name "FBReactNativeSpec.h" -delete

# Removing 'script_phases' that shouldn't be needed anymore.
# Removing 'prepare_command' that includes additional steps to create intermediate folders to keep generated files which won't be needed.
Expand All @@ -144,4 +196,4 @@ do
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"
mv "$TMP_FBReactNativeSpec" "$DEST/FBReactNativeSpec/FBReactNativeSpec.podspec.json"
fi
done
done
7,363 changes: 3,681 additions & 3,682 deletions bundle/ios/App.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/App.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 298 files
Loading