Skip to content

Commit e99b8bb

Browse files
hramosfacebook-github-bot
authored andcommitted
Use [email protected] in new app template
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 [email protected]. 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
1 parent f638aff commit e99b8bb

File tree

7 files changed

+20
-8
lines changed

7 files changed

+20
-8
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"Libraries",
2828
"LICENSE",
2929
"local-cli",
30-
"packages/react-native-codegen",
3130
"React-Core.podspec",
3231
"react-native.config.js",
3332
"react.gradle",

packages/react-native-codegen/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-codegen",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "⚛️ Code generation tools for React Native",
55
"homepage": "https://github.com/facebook/react-native/tree/master/packages/react-native-codegen",
66
"repository": {

packages/react-native-codegen/scripts/oss/build.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ CODEGEN_DIR="$THIS_DIR/../.."
1515

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

18-
YARN_BINARY="${YARN_BINARY:-$(command -v yarn)}"
18+
# Fallback to npm if yarn is not available
19+
if [ -x "$(command -v yarn)" ]; then
20+
YARN_OR_NPM=$(command -v yarn)
21+
else
22+
YARN_OR_NPM=$(command -v npm)
23+
fi
24+
YARN_BINARY="${YARN_BINARY:-$YARN_OR_NPM}"
1925

2026
if [[ ${FBSOURCE_ENV:-0} -eq 1 ]]; then
2127
# Custom FB-specific setup

packages/rn-tester/Podfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ pre_install do |installer|
6464
frameworks_pre_install(installer) if ENV['USE_FRAMEWORKS'] == '1'
6565
if ENV['USE_CODEGEN'] != '0'
6666
prefix_path = "../.."
67-
codegen_pre_install(installer, {path:prefix_path})
67+
codegen_path = "../../packages/react-native-codegen"
68+
system("./#{codegen_path}/scripts/oss/build.sh") or raise "Could not build react-native-codegen package"
69+
codegen_pre_install(installer, {path:prefix_path, codegen_path:codegen_path})
6870
end
6971
end
7072

packages/rn-tester/Podfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,6 @@ SPEC CHECKSUMS:
528528
Yoga: 69ef0b2bba5387523f793957a9f80dbd61e89631
529529
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
530530

531-
PODFILE CHECKSUM: 961e081223f82b7e9208869de4d73534d949ae9e
531+
PODFILE CHECKSUM: cd671238f92c51cd349a1c778fd089994174b101
532532

533533
COCOAPODS: 1.10.0

scripts/react_native_pods.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,18 @@ def flipper_post_install(installer)
111111

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

117+
# Path to react-native-codegen
118+
codegen_path = options[:codegen_path] ||= "#{prefix}/../react-native-codegen"
119+
120+
# Handle Core Modules
117121
Dir.mktmpdir do |dir|
118122
native_module_spec_name = "FBReactNativeSpec"
119123
schema_file = dir + "/schema-#{native_module_spec_name}.json"
120124
srcs_dir = "#{prefix}/Libraries"
121-
schema_generated = system("node #{prefix}/packages/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js #{schema_file} #{srcs_dir}")
122-
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}")
125+
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"
126+
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}"
123127
end
124128
end

template/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"eslint": "7.12.0",
2222
"jest": "^25.1.0",
2323
"metro-react-native-babel-preset": "^0.64.0",
24+
"react-native-codegen": "^0.0.6",
2425
"react-test-renderer": "17.0.1"
2526
},
2627
"jest": {

0 commit comments

Comments
 (0)