Skip to content

Commit

Permalink
Use react-native-codegen@0.0.6 in new app template
Browse files Browse the repository at this point in the history
Summary:
Use pre-built react-native-codegen library from npm in the iOS app template.
Built react-native-codegen from source when used with RNTester.
Published react-native-codegen@0.0.6.

Changelog:
[iOS][Added] - Use react-native-codegen in iOS app template
[Internal] - Bump react-native-codegen: 0.0.6

Reviewed By: fkgozali

Differential Revision: D25128036

fbshipit-source-id: f294c23b9b911aae6f404edc01b62426fb578477
  • Loading branch information
hramos authored and facebook-github-bot committed Nov 21, 2020
1 parent f638aff commit e99b8bb
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"Libraries",
"LICENSE",
"local-cli",
"packages/react-native-codegen",
"React-Core.podspec",
"react-native.config.js",
"react.gradle",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-codegen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-codegen",
"version": "0.0.5",
"version": "0.0.6",
"description": "⚛️ Code generation tools for React Native",
"homepage": "https://github.com/facebook/react-native/tree/master/packages/react-native-codegen",
"repository": {
Expand Down
8 changes: 7 additions & 1 deletion packages/react-native-codegen/scripts/oss/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ CODEGEN_DIR="$THIS_DIR/../.."

rm -rf "${CODEGEN_DIR:?}/lib" "${CODEGEN_DIR:?}/node_modules"

YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}"
# Fallback to npm if yarn is not available
if [ -x "$(command -v yarn)" ]; then
YARN_OR_NPM=$(command -v yarn)
else
YARN_OR_NPM=$(command -v npm)
fi
YARN_BINARY="${YARN_BINARY:-$YARN_OR_NPM}"

if [[ ${FBSOURCE_ENV:-0} -eq 1 ]]; then
# Custom FB-specific setup
Expand Down
4 changes: 3 additions & 1 deletion packages/rn-tester/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ pre_install do |installer|
frameworks_pre_install(installer) if ENV['USE_FRAMEWORKS'] == '1'
if ENV['USE_CODEGEN'] != '0'
prefix_path = "../.."
codegen_pre_install(installer, {path:prefix_path})
codegen_path = "../../packages/react-native-codegen"
system("./#{codegen_path}/scripts/oss/build.sh") or raise "Could not build react-native-codegen package"
codegen_pre_install(installer, {path:prefix_path, codegen_path:codegen_path})
end
end

Expand Down
2 changes: 1 addition & 1 deletion packages/rn-tester/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,6 @@ SPEC CHECKSUMS:
Yoga: 69ef0b2bba5387523f793957a9f80dbd61e89631
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 961e081223f82b7e9208869de4d73534d949ae9e
PODFILE CHECKSUM: cd671238f92c51cd349a1c778fd089994174b101

COCOAPODS: 1.10.0
10 changes: 7 additions & 3 deletions scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,18 @@ def flipper_post_install(installer)

# Pre Install processing for Native Modules
def codegen_pre_install(installer, options={})
# Path to React Native
prefix = options[:path] ||= "../node_modules/react-native"
system("./#{prefix}/packages/react-native-codegen/scripts/oss/build.sh")

# Path to react-native-codegen
codegen_path = options[:codegen_path] ||= "#{prefix}/../react-native-codegen"

# Handle Core Modules
Dir.mktmpdir do |dir|
native_module_spec_name = "FBReactNativeSpec"
schema_file = dir + "/schema-#{native_module_spec_name}.json"
srcs_dir = "#{prefix}/Libraries"
schema_generated = system("node #{prefix}/packages/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js #{schema_file} #{srcs_dir}")
specs_generated = system("node #{prefix}/scripts/generate-native-modules-specs-cli.js ios #{schema_file} #{srcs_dir}/#{native_module_spec_name}/#{native_module_spec_name}")
schema_generated = system("node #{codegen_path}/lib/cli/combine/combine-js-to-schema-cli.js #{schema_file} #{srcs_dir}") or raise "Could not generate Native Module schema"
specs_generated = system("node #{prefix}/scripts/generate-native-modules-specs-cli.js ios #{schema_file} #{srcs_dir}/#{native_module_spec_name}/#{native_module_spec_name}") or raise "Could not generate code for #{native_module_spec_name}"
end
end
1 change: 1 addition & 0 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"eslint": "7.12.0",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.64.0",
"react-native-codegen": "^0.0.6",
"react-test-renderer": "17.0.1"
},
"jest": {
Expand Down

0 comments on commit e99b8bb

Please sign in to comment.