Skip to content

Commit

Permalink
fix: React Native CodeGen integration for 0.64-stable (#31027)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
grabbou committed Mar 1, 2021
1 parent dfa4fa9 commit 12af849
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 20 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ package-lock.json
!/packages/rn-tester/Pods/__offline_mirrors__

# react-native-codegen
/React/FBReactNativeSpec/FBReactNativeSpec
/packages/react-native-codegen/lib
/ReactCommon/react/renderer/components/rncore/

Expand Down
Empty file.
Empty file.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"promise": "^8.0.3",
"prop-types": "^15.7.2",
"react-devtools-core": "^4.6.0",
"react-native-codegen": "^0.0.7",
"react-refresh": "^0.4.0",
"regenerator-runtime": "^0.13.2",
"scheduler": "^0.20.1",
Expand Down Expand Up @@ -155,4 +156,4 @@
}
}
}
}
}
20 changes: 3 additions & 17 deletions scripts/generate-specs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,33 +57,19 @@ main() {
TEMP_OUTPUT_DIR="$TEMP_DIR/out"
SCHEMA_FILE="$TEMP_DIR/schema.json"

CODEGEN_REPO_PATH="$RN_DIR/packages/react-native-codegen"
CODEGEN_NPM_PATH="$RN_DIR/../react-native-codegen"

if [ -z "$NODE_BINARY" ]; then
if [ -z "$NODE_BINARY" ]; then
echo "Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." 1>&2
exit 1
fi

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
CODEGEN_PATH=$("$NODE_BINARY" -e "console.log(require('path').dirname(require.resolve('react-native-codegen/package.json')))")

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

if [ -z "$NODE_BINARY" ]; then
echo "Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." 1>&2
exit 1
fi

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

Expand Down
1 change: 0 additions & 1 deletion template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.64.0",
"react-native-codegen": "^0.0.7",
"react-test-renderer": "17.0.1"
},
"jest": {
Expand Down

0 comments on commit 12af849

Please sign in to comment.