Skip to content

Commit 14db556

Browse files
committed
fix: React Native CodeGen integration for 0.64-stable (#31027)
1 parent 4b68734 commit 14db556

File tree

7 files changed

+11
-43
lines changed

7 files changed

+11
-43
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ package-lock.json
100100
!/packages/rn-tester/Pods/__offline_mirrors__
101101

102102
# react-native-codegen
103-
/React/FBReactNativeSpec/FBReactNativeSpec
104103
/packages/react-native-codegen/lib
105104
/ReactCommon/react/renderer/components/rncore/
106105

React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm

Whitespace-only changes.

React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h

Whitespace-only changes.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
"promise": "^8.0.3",
107107
"prop-types": "^15.7.2",
108108
"react-devtools-core": "^4.6.0",
109+
"react-native-codegen": "^0.0.7",
109110
"react-refresh": "^0.4.0",
110111
"regenerator-runtime": "^0.13.2",
111112
"scheduler": "^0.20.1",
@@ -156,4 +157,4 @@
156157
}
157158
}
158159
}
159-
}
160+
}

scripts/generate-specs.sh

+7-17
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ set -e
2727
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
2828
TEMP_DIR=$(mktemp -d /tmp/react-native-codegen-XXXXXXXX)
2929
RN_DIR=$(cd "$THIS_DIR/.." && pwd)
30+
31+
# find node path
32+
source "$RN_DIR/scripts/find-node.sh"
33+
3034
NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"
3135
USE_FABRIC="${USE_FABRIC:-0}"
3236

@@ -53,33 +57,19 @@ main() {
5357
TEMP_OUTPUT_DIR="$TEMP_DIR/out"
5458
SCHEMA_FILE="$TEMP_DIR/schema.json"
5559

56-
CODEGEN_REPO_PATH="$RN_DIR/packages/react-native-codegen"
57-
CODEGEN_NPM_PATH="$RN_DIR/../react-native-codegen"
58-
59-
if [ -z "$NODE_BINARY" ]; then
60+
if [ -z "$NODE_BINARY" ]; then
6061
echo "Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." 1>&2
6162
exit 1
6263
fi
6364

64-
if [ -d "$CODEGEN_REPO_PATH" ]; then
65-
CODEGEN_PATH=$(cd "$CODEGEN_REPO_PATH" && pwd)
66-
elif [ -d "$CODEGEN_NPM_PATH" ]; then
67-
CODEGEN_PATH=$(cd "$CODEGEN_NPM_PATH" && pwd)
68-
else
69-
echo "Error: Could not determine react-native-codegen location. Try running 'yarn install' or 'npm install' in your project root." 1>&2
70-
exit 1
71-
fi
65+
CODEGEN_PATH=$("$NODE_BINARY" -e "console.log(require('path').dirname(require.resolve('react-native-codegen/package.json')))")
7266

67+
# Special case for running CodeGen from source: build it
7368
if [ ! -d "$CODEGEN_PATH/lib" ]; then
7469
describe "Building react-native-codegen package"
7570
bash "$CODEGEN_PATH/scripts/oss/build.sh"
7671
fi
7772

78-
if [ -z "$NODE_BINARY" ]; then
79-
echo "Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." 1>&2
80-
exit 1
81-
fi
82-
8373
describe "Generating schema from flow types"
8474
"$NODE_BINARY" "$CODEGEN_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR"
8575

scripts/react-native-xcode.sh

+2-23
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ PROJECT_ROOT=${PROJECT_ROOT:-"$REACT_NATIVE_DIR/../.."}
6464

6565
cd "$PROJECT_ROOT" || exit
6666

67-
# Define NVM_DIR and source the nvm.sh setup script
68-
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
69-
7067
# Define entry file
7168
if [[ "$ENTRY_FILE" ]]; then
7269
# Use ENTRY_FILE defined by user
@@ -82,26 +79,8 @@ if [[ $DEV != true && ! -f "$ENTRY_FILE" ]]; then
8279
exit 2
8380
fi
8481

85-
if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
86-
. "$HOME/.nvm/nvm.sh"
87-
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
88-
. "$(brew --prefix nvm)/nvm.sh"
89-
fi
90-
91-
# Set up the nodenv node version manager if present
92-
if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
93-
eval "$("$HOME/.nodenv/bin/nodenv" init -)"
94-
elif [[ -x "$(command -v brew)" && -x "$(brew --prefix nodenv)/bin/nodenv" ]]; then
95-
eval "$("$(brew --prefix nodenv)/bin/nodenv" init -)"
96-
fi
97-
98-
# Set up the ndenv of anyenv if preset
99-
if [[ ! -x node && -d ${HOME}/.anyenv/bin ]]; then
100-
export PATH=${HOME}/.anyenv/bin:${PATH}
101-
if [[ "$(anyenv envs | grep -c ndenv )" -eq 1 ]]; then
102-
eval "$(anyenv init -)"
103-
fi
104-
fi
82+
# find node path
83+
source "$REACT_NATIVE_DIR/scripts/find-node.sh"
10584

10685
# check and assign NODE_BINARY env
10786
# shellcheck source=/dev/null

template/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"eslint": "7.14.0",
2222
"jest": "^26.6.3",
2323
"metro-react-native-babel-preset": "^0.64.0",
24-
"react-native-codegen": "^0.0.7",
2524
"react-test-renderer": "17.0.1"
2625
},
2726
"jest": {

0 commit comments

Comments
 (0)