diff --git a/package.json b/package.json index 51e8ae3b019b3b..0326e84134dbcb 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "Libraries", "LICENSE", "local-cli", - "packages/react-native-codegen", "React-Core.podspec", "react-native.config.js", "react.gradle", diff --git a/packages/react-native-codegen/package.json b/packages/react-native-codegen/package.json index 871da36b95f0a9..2ab4e05ad21a78 100644 --- a/packages/react-native-codegen/package.json +++ b/packages/react-native-codegen/package.json @@ -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": { diff --git a/packages/react-native-codegen/scripts/oss/build.sh b/packages/react-native-codegen/scripts/oss/build.sh index 28fe87693b4454..7e22d6bbd6040a 100755 --- a/packages/react-native-codegen/scripts/oss/build.sh +++ b/packages/react-native-codegen/scripts/oss/build.sh @@ -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 diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index 021f13970c392d..e939c4f2f0b7a8 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -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 diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 4034f23bda4545..6ba9855fd1872b 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -528,6 +528,6 @@ SPEC CHECKSUMS: Yoga: 69ef0b2bba5387523f793957a9f80dbd61e89631 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 961e081223f82b7e9208869de4d73534d949ae9e +PODFILE CHECKSUM: cd671238f92c51cd349a1c778fd089994174b101 COCOAPODS: 1.10.0 diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index f184a5c8784177..14d6166f3da6c1 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -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 diff --git a/template/package.json b/template/package.json index 2c481b9ec10034..6c1d3a08ebbd67 100644 --- a/template/package.json +++ b/template/package.json @@ -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": {