Skip to content

Commit 12af849

Browse files
authoredMar 1, 2021
fix: React Native CodeGen integration for 0.64-stable (#31027)
* fix: codegen blank files * chore: add codegen script back * chore: restore react_native_pods, prepare_command is still fine * feat: rework codegen sh setup * chore: revert unwanted change * chore: can't overwrite CODEGEN_PATH right now, remove this * chore: remove extra user-defined envs
1 parent dfa4fa9 commit 12af849

File tree

6 files changed

+5
-20
lines changed

6 files changed

+5
-20
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
@@ -105,6 +105,7 @@
105105
"promise": "^8.0.3",
106106
"prop-types": "^15.7.2",
107107
"react-devtools-core": "^4.6.0",
108+
"react-native-codegen": "^0.0.7",
108109
"react-refresh": "^0.4.0",
109110
"regenerator-runtime": "^0.13.2",
110111
"scheduler": "^0.20.1",
@@ -155,4 +156,4 @@
155156
}
156157
}
157158
}
158-
}
159+
}

‎scripts/generate-specs.sh

+3-17
Original file line numberDiff line numberDiff line change
@@ -57,33 +57,19 @@ main() {
5757
TEMP_OUTPUT_DIR="$TEMP_DIR/out"
5858
SCHEMA_FILE="$TEMP_DIR/schema.json"
5959

60-
CODEGEN_REPO_PATH="$RN_DIR/packages/react-native-codegen"
61-
CODEGEN_NPM_PATH="$RN_DIR/../react-native-codegen"
62-
63-
if [ -z "$NODE_BINARY" ]; then
60+
if [ -z "$NODE_BINARY" ]; then
6461
echo "Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." 1>&2
6562
exit 1
6663
fi
6764

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

67+
# Special case for running CodeGen from source: build it
7768
if [ ! -d "$CODEGEN_PATH/lib" ]; then
7869
describe "Building react-native-codegen package"
7970
bash "$CODEGEN_PATH/scripts/oss/build.sh"
8071
fi
8172

82-
if [ -z "$NODE_BINARY" ]; then
83-
echo "Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." 1>&2
84-
exit 1
85-
fi
86-
8773
describe "Generating schema from flow types"
8874
"$NODE_BINARY" "$CODEGEN_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR"
8975

‎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)