From 0f27961e1c3a948725c1c3b29002384a95fce644 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Wed, 29 Sep 2021 09:45:26 -0300 Subject: [PATCH 1/7] Provide template/Gemfile with recommended Ruby and CocoaPods The Gemfile is used by https://bundler.io/ to install and use tools with the correct version and environment. The scripts/update-ruby.sh will take care to update ruby-version and related files, including the Gemfile and Gemfile.lock These files are added to git staging (git add) --- .bundle/config | 2 + .gitignore | 4 ++ .ruby-version | 1 + Gemfile | 6 +++ Gemfile.lock | 100 ++++++++++++++++++++++++++++++++++++++++ scripts/update-ruby.sh | 66 ++++++++++++++++++++++++++ template/Gemfile | 6 +++ template/Gemfile.lock | 100 ++++++++++++++++++++++++++++++++++++++++ template/_bundle/config | 2 + template/_ruby-version | 1 + 10 files changed, 288 insertions(+) create mode 100644 .bundle/config create mode 100644 .ruby-version create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100755 scripts/update-ruby.sh create mode 100644 template/Gemfile create mode 100644 template/Gemfile.lock create mode 100644 template/_bundle/config create mode 100644 template/_ruby-version diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 000000000000..848943bb5274 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/.gitignore b/.gitignore index a34c407b2a35..c60f27e2a091 100644 --- a/.gitignore +++ b/.gitignore @@ -91,6 +91,10 @@ package-lock.json /React/FBReactNativeSpec/**/*.xcodeproj /packages/react-native-codegen/**/*.xcodeproj +# Ruby Gems (Bundler) +/vendor +/template/vendor + # CocoaPods /template/ios/Pods/ /template/ios/Podfile.lock diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 000000000000..a4dd9dba4fbf --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.7.4 diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000000..2c3edcf4b701 --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version +ruby '2.7.4' + +gem 'cocoapods', '~> 1.11', '>= 1.11.2' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000000..de5f3d29a1b7 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,100 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.4) + rexml + activesupport (6.1.4.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + algoliasearch (1.27.5) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) + atomos (0.1.3) + claide (1.0.3) + cocoapods (1.11.2) + addressable (~> 2.8) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.11.2) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 1.4.0, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.4.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.3.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.8.0) + nap (~> 1.0) + ruby-macho (>= 1.0, < 3.0) + xcodeproj (>= 1.21.0, < 2.0) + cocoapods-core (1.11.2) + activesupport (>= 5.0, < 7) + addressable (~> 2.8) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + netrc (~> 0.11) + public_suffix (~> 4.0) + typhoeus (~> 1.0) + cocoapods-deintegrate (1.0.5) + cocoapods-downloader (1.5.1) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.1) + cocoapods-trunk (1.6.0) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.2.0) + colored2 (3.1.2) + concurrent-ruby (1.1.9) + escape (0.0.4) + ethon (0.14.0) + ffi (>= 1.15.0) + ffi (1.15.4) + fourflusher (2.3.1) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + httpclient (2.8.3) + i18n (1.8.10) + concurrent-ruby (~> 1.0) + json (2.5.1) + minitest (5.14.4) + molinillo (0.8.0) + nanaimo (0.3.0) + nap (1.1.0) + netrc (0.11.0) + public_suffix (4.0.6) + rexml (3.2.5) + ruby-macho (2.5.1) + typhoeus (1.4.0) + ethon (>= 0.9.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + xcodeproj (1.21.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.3.0) + rexml (~> 3.2.4) + zeitwerk (2.4.2) + +PLATFORMS + ruby + +DEPENDENCIES + cocoapods (~> 1.11, >= 1.11.2) + +RUBY VERSION + ruby 2.7.4p191 + +BUNDLED WITH + 2.2.28 diff --git a/scripts/update-ruby.sh b/scripts/update-ruby.sh new file mode 100755 index 000000000000..a220ad847359 --- /dev/null +++ b/scripts/update-ruby.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +set -e + +if [ "$VERBOSE" = 1 ]; then + set -x +fi + +case $(sed --help 2>&1) in + *GNU*) sed_i () { sed -i "$@"; };; + *) sed_i () { sed -i '' "$@"; };; +esac + +SCRIPTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="$(dirname "$SCRIPTS")" + +die() { + echo "ERROR: $*" >&2 + exit 1 +} + +if [ $# -eq 1 ]; then + VERSION=$1 +else + VERSION=$(ruby --version | cut -d' ' -f2 | cut -dp -f1) +fi + +if [ -z "$VERSION" ]; then + die "Please provide an installed/usable Ruby version" +fi +echo "Setting Ruby version to: $VERSION" + +cd "$ROOT" || die "Failed to change to $ROOT" + +# do this first, so rbenv/rvm will automatically pick the desired version +echo "$VERSION" > .ruby-version + +# make sure we're using it +CURRENT_VERSION=$(ruby --version | cut -d' ' -f2 | cut -dp -f1) +if [ -z "$CURRENT_VERSION" ]; then + # rbenv/rvm uses shims, the commands do exist, but do not return a version if misconfigured + die "Missing usable ruby, check your installation" +elif [ "$VERSION" != "$CURRENT_VERSION" ]; then + die "Plese use the ruby version you are trying to set: $VERSION ('$CURRENT_VERSION' in use)" +fi + +echo "$VERSION" > template/_ruby-version + +sed_i -e "s/^\(ruby '\)[^']*\('.*\)$/\1$VERSION\2/" Gemfile +sed_i -e "s/^\(ruby '\)[^']*\('.*\)$/\1$VERSION\2/" template/Gemfile + +rm -f Gemfile.lock template/Gemfile.lock + +bundle lock +(cd template && bundle lock) + +git add \ + .ruby-version \ + Gemfile \ + template/_ruby-version \ + template/Gemfile \ + template/Gemfile.lock diff --git a/template/Gemfile b/template/Gemfile new file mode 100644 index 000000000000..2c3edcf4b701 --- /dev/null +++ b/template/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version +ruby '2.7.4' + +gem 'cocoapods', '~> 1.11', '>= 1.11.2' diff --git a/template/Gemfile.lock b/template/Gemfile.lock new file mode 100644 index 000000000000..f0b073f27b1d --- /dev/null +++ b/template/Gemfile.lock @@ -0,0 +1,100 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.4) + rexml + activesupport (6.1.4.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + algoliasearch (1.27.5) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) + atomos (0.1.3) + claide (1.0.3) + cocoapods (1.11.2) + addressable (~> 2.8) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.11.2) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 1.4.0, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.4.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.3.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.8.0) + nap (~> 1.0) + ruby-macho (>= 1.0, < 3.0) + xcodeproj (>= 1.21.0, < 2.0) + cocoapods-core (1.11.2) + activesupport (>= 5.0, < 7) + addressable (~> 2.8) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + netrc (~> 0.11) + public_suffix (~> 4.0) + typhoeus (~> 1.0) + cocoapods-deintegrate (1.0.5) + cocoapods-downloader (1.5.1) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.1) + cocoapods-trunk (1.6.0) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.2.0) + colored2 (3.1.2) + concurrent-ruby (1.1.9) + escape (0.0.4) + ethon (0.14.0) + ffi (>= 1.15.0) + ffi (1.15.4) + fourflusher (2.3.1) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + httpclient (2.8.3) + i18n (1.8.10) + concurrent-ruby (~> 1.0) + json (2.5.1) + minitest (5.14.4) + molinillo (0.8.0) + nanaimo (0.3.0) + nap (1.1.0) + netrc (0.11.0) + public_suffix (4.0.6) + rexml (3.2.5) + ruby-macho (2.5.1) + typhoeus (1.4.0) + ethon (>= 0.9.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + xcodeproj (1.21.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.3.0) + rexml (~> 3.2.4) + zeitwerk (2.4.2) + +PLATFORMS + arm64-darwin-20 + +DEPENDENCIES + cocoapods (~> 1.11, >= 1.11.2) + +RUBY VERSION + ruby 2.7.4p191 + +BUNDLED WITH + 2.2.28 diff --git a/template/_bundle/config b/template/_bundle/config new file mode 100644 index 000000000000..848943bb5274 --- /dev/null +++ b/template/_bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/template/_ruby-version b/template/_ruby-version new file mode 100644 index 000000000000..a4dd9dba4fbf --- /dev/null +++ b/template/_ruby-version @@ -0,0 +1 @@ +2.7.4 From 553fe9cbecc394eb69d0624723784c953368a00f Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Thu, 30 Sep 2021 17:39:21 -0300 Subject: [PATCH 2/7] Simplify scripts/update_podfile_lock.sh Since the packages/rn-tester provides a Gemfile, we can trust 'bundle check' to do the validation. While at that, use the 'bundle exec' execution to always use the correct version. --- scripts/update_podfile_lock.sh | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/scripts/update_podfile_lock.sh b/scripts/update_podfile_lock.sh index 31163e29e436..a8de5eb768c8 100755 --- a/scripts/update_podfile_lock.sh +++ b/scripts/update_podfile_lock.sh @@ -11,31 +11,9 @@ THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) RNTESTER_DIR="$THIS_DIR/../packages/rn-tester" -# Note: Keep in sync with FB internal. -REQUIRED_COCOAPODS_VERSION="1.11.2" - -validate_env () { - # Check that CocoaPods is working. - if [ -z "$(command -v pod)" ]; then - echo "You need to install CocoaPods." - echo "See https://guides.cocoapods.org/using/getting-started.html#getting-started for instructions." - exit 1 - fi - - COCOAPODS_VERSION=$(pod --version) - if [[ "$COCOAPODS_VERSION" != "$REQUIRED_COCOAPODS_VERSION" ]]; - then - echo "You must have CocoaPods $REQUIRED_COCOAPODS_VERSION installed; you have $COCOAPODS_VERSION." - echo "Installing via gem is recommended:" - echo " sudo gem install cocoapods -v $REQUIRED_COCOAPODS_VERSION" - exit 1 - fi -} - update_pods () { - validate_env - cd "$RNTESTER_DIR" || exit - pod install + bundle check || exit + bundle exec pod install cd "$THIS_DIR" || exit } From e1d9cfa89c06e8872f6352a2d8cac61ed8be3e86 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Thu, 30 Sep 2021 18:00:15 -0300 Subject: [PATCH 3/7] NativeAnimatedHelper: Improve warning to use "bundle exec" Since we're now providing a Gemfile, use "bundle exec" so we have the user to get the correct versions when executing a command. --- Libraries/Animated/NativeAnimatedHelper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Animated/NativeAnimatedHelper.js b/Libraries/Animated/NativeAnimatedHelper.js index 6bac8cb1fbd8..89fe7b5a8d2a 100644 --- a/Libraries/Animated/NativeAnimatedHelper.js +++ b/Libraries/Animated/NativeAnimatedHelper.js @@ -355,7 +355,7 @@ function shouldUseNativeDriver( 'animated module is missing. Falling back to JS-based animation. To ' + 'resolve this, add `RCTAnimation` module to this app, or remove ' + '`useNativeDriver`. ' + - 'Make sure to run `pod install` first. Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', + 'Make sure to run `bundle exec pod install` first. Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', ); _warnedMissingNativeAnimated = true; } From 202c69a44753b6ad7afa1a812b2973e1222813c2 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Thu, 30 Sep 2021 18:12:19 -0300 Subject: [PATCH 4/7] CircleCI uses our Gemfile Let's use the specified CocoaPods and other gems in our Gemfile instead of the system versions. As documented at https://circleci.com/docs/2.0/testing-ios/#using-custom-versions-of-cocoapods-and-other-ruby-gems --- .circleci/config.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5bcebf7b8215..064417039742 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -65,6 +65,16 @@ commands: name: Initial Setup command: mkdir -p ./reports/{buck,build,junit,outputs} + setup_ruby: + steps: + - restore_cache: + key: 1-gems-{{ checksum "Gemfile.lock" }} + - run: bundle check || bundle install --path vendor/bundle --clean + - save_cache: + key: 1-gems-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + run_yarn: steps: - restore_cache: @@ -351,6 +361,7 @@ jobs: steps: - checkout - setup_artifacts + - setup_ruby - run_yarn - run: | @@ -402,7 +413,7 @@ jobs: - run: name: Setup the CocoaPods environment - command: pod setup + command: bundle exec pod setup - with_rntester_pods_cache_span: steps: From f047e06ad0b71b0f7566970603ee321d4140e7b3 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Thu, 30 Sep 2021 18:14:41 -0300 Subject: [PATCH 5/7] Update all CocoaPods use to use "bundle exec" This way we make sure the correct versions are in use. --- scripts/process-podspecs.sh | 6 +++--- scripts/react-native-xcode.sh | 2 +- scripts/run-ci-e2e-tests.js | 3 ++- scripts/test-manual-e2e.sh | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/process-podspecs.sh b/scripts/process-podspecs.sh index 539a4fea34ec..3053b72e4e16 100755 --- a/scripts/process-podspecs.sh +++ b/scripts/process-podspecs.sh @@ -41,8 +41,8 @@ lint() { if [ "${SUBSPEC:-}" ]; then local SUBSPEC_OPT="--subspec=$SUBSPEC" fi - pod lib lint $SUBSPEC_OPT $POD_LINT_OPT - pod lib lint $SUBSPEC_OPT $POD_LINT_OPT --use-libraries + bundle exec pod lib lint $SUBSPEC_OPT $POD_LINT_OPT + bundle exec pod lib lint $SUBSPEC_OPT $POD_LINT_OPT --use-libraries } # Push the spec in arg `$1`, which is expected to be in the cwd, to the `SPEC_REPO` in JSON format. @@ -52,7 +52,7 @@ push() { local SPEC_DIR="$SPEC_REPO_DIR/$POD_NAME/$(version $SPEC_NAME)" local SPEC_PATH="$SPEC_DIR/$SPEC_NAME.json" mkdir -p $SPEC_DIR - env INSTALL_YOGA_WITHOUT_PATH_OPTION=1 INSTALL_YOGA_FROM_LOCATION="$ROOT" pod ipc spec $SPEC_NAME > $SPEC_PATH + env INSTALL_YOGA_WITHOUT_PATH_OPTION=1 INSTALL_YOGA_FROM_LOCATION="$ROOT" bundle exec pod ipc spec $SPEC_NAME > $SPEC_PATH } # Perform linting and publishing of podspec in cwd. diff --git a/scripts/react-native-xcode.sh b/scripts/react-native-xcode.sh index 83c55d43f42d..e9ddec0c304b 100755 --- a/scripts/react-native-xcode.sh +++ b/scripts/react-native-xcode.sh @@ -96,7 +96,7 @@ fi if [[ $USE_HERMES == true && ! -f "$HERMES_CLI_PATH" ]]; then echo "error: USE_HERMES is set to true but the hermesc binary could not be " \ - "found at ${HERMES_CLI_PATH}. Perhaps you need to run pod install or otherwise " \ + "found at ${HERMES_CLI_PATH}. Perhaps you need to run 'bundle exec pod install' or otherwise " \ "point the HERMES_CLI_PATH variable to your custom location." >&2 exit 2 fi diff --git a/scripts/run-ci-e2e-tests.js b/scripts/run-ci-e2e-tests.js index ecbaea2409a9..a2bcb45c4216 100644 --- a/scripts/run-ci-e2e-tests.js +++ b/scripts/run-ci-e2e-tests.js @@ -99,6 +99,7 @@ try { ); mv('_flowconfig', '.flowconfig'); mv('_watchmanconfig', '.watchmanconfig'); + mv('_bundle', '.bundle'); describe('Install React Native package'); exec(`npm install ${REACT_NATIVE_PACKAGE}`); @@ -210,7 +211,7 @@ try { echo(`Metro is running, ${SERVER_PID}`); describe('Install CocoaPod dependencies'); - exec('pod install'); + exec('bundle exec pod install'); describe('Test: iOS end-to-end test'); if ( diff --git a/scripts/test-manual-e2e.sh b/scripts/test-manual-e2e.sh index 6ea038b1caf3..137d4c66f9c1 100755 --- a/scripts/test-manual-e2e.sh +++ b/scripts/test-manual-e2e.sh @@ -71,7 +71,7 @@ read -r -n 1 success "About to test iOS JSC... " success "Installing CocoaPods dependencies..." rm -rf packages/rn-tester/Pods -(cd packages/rn-tester && pod install) +(cd packages/rn-tester && bundle exec pod install) info "Press any key to open the workspace in Xcode, then build and test manually." info "" @@ -85,7 +85,7 @@ read -r -n 1 success "About to test iOS Hermes... " success "Installing CocoaPods dependencies..." rm -rf packages/rn-tester/Pods -(cd packages/rn-tester && USE_HERMES=1 pod install) +(cd packages/rn-tester && USE_HERMES=1 bundle exec pod install) info "Press any key to open the workspace in Xcode, then build and test manually." info "" From bc0856bf117d9131f0bb6c14831fbf670d4a3afe Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Thu, 30 Sep 2021 17:29:56 -0300 Subject: [PATCH 6/7] Update Ruby version from bump-oss-version.js Assume the system version is the latest and desired, update all related files to use that version. https://circleci.com/docs/2.0/testing-ios/#using-ruby states CircleCI will use the latest stable version (2.7 at this moment), which is excellent. --- scripts/bump-oss-version.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/bump-oss-version.js b/scripts/bump-oss-version.js index 2eaa43095d82..6550726ed89e 100755 --- a/scripts/bump-oss-version.js +++ b/scripts/bump-oss-version.js @@ -172,6 +172,12 @@ let numberOfChangedLinesWithNewVersion = exec( {silent: true}, ).stdout.trim(); +// Make sure to update ruby version +if (exec('scripts/update-ruby.sh').code) { + echo('Failed to update Ruby version'); + exit(1); +} + // Release builds should commit the version bumps, and create tags. // Nightly builds do not need to do that. if (!nightlyBuild) { From 1e2f8194a5cb392db8c49e5b72933c918ab1e804 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Fri, 1 Oct 2021 17:22:24 -0300 Subject: [PATCH 7/7] Shellcheck scripts/process-podspecs.sh Fix all issues reported by https://github.com/koalaman/shellcheck --- scripts/process-podspecs.sh | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/scripts/process-podspecs.sh b/scripts/process-podspecs.sh index 3053b72e4e16..97ec80c8e0cb 100755 --- a/scripts/process-podspecs.sh +++ b/scripts/process-podspecs.sh @@ -6,12 +6,12 @@ set -ex -SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -ROOT=$(dirname $SCRIPTS) +SCRIPTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="$(dirname "$SCRIPTS")" # Specify `SPEC_REPO` as an env variable if you want to push to a specific spec repo. # Defaults to `react-test`, which is meant to be a dummy repo used to test that the specs fully lint. -: ${SPEC_REPO:="react-test"} +: "${SPEC_REPO:=react-test}" SPEC_REPO_DIR="$HOME/.cocoapods/repos/$SPEC_REPO" # If the `SPEC_REPO` does not exist yet, assume this is purely for testing and create a dummy repo. @@ -28,7 +28,7 @@ fi cd "$SPEC_REPO_DIR" SPEC_REPOS="$(git remote get-url origin),https://github.com/CocoaPods/Specs.git" -POD_LINT_OPT="--verbose --allow-warnings --fail-fast --private --swift-version=3.0 --sources=$SPEC_REPOS" +POD_LINT_OPT=(--verbose --allow-warnings --fail-fast --private "--swift-version=3.0" "--sources=$SPEC_REPOS") # Get the version from a podspec. version() { @@ -37,33 +37,34 @@ version() { # Lint both framework and static library builds. lint() { - local SUBSPEC=$1 + local SUBSPEC="$1" if [ "${SUBSPEC:-}" ]; then local SUBSPEC_OPT="--subspec=$SUBSPEC" fi - bundle exec pod lib lint $SUBSPEC_OPT $POD_LINT_OPT - bundle exec pod lib lint $SUBSPEC_OPT $POD_LINT_OPT --use-libraries + bundle exec pod lib lint "$SUBSPEC_OPT" "${POD_LINT_OPT[@]}" + bundle exec pod lib lint "$SUBSPEC_OPT" "${POD_LINT_OPT[@]}" --use-libraries } # Push the spec in arg `$1`, which is expected to be in the cwd, to the `SPEC_REPO` in JSON format. push() { - local SPEC_NAME=$1 - local POD_NAME=$(basename $SPEC_NAME .podspec) - local SPEC_DIR="$SPEC_REPO_DIR/$POD_NAME/$(version $SPEC_NAME)" - local SPEC_PATH="$SPEC_DIR/$SPEC_NAME.json" - mkdir -p $SPEC_DIR - env INSTALL_YOGA_WITHOUT_PATH_OPTION=1 INSTALL_YOGA_FROM_LOCATION="$ROOT" bundle exec pod ipc spec $SPEC_NAME > $SPEC_PATH + local SPEC_NAME POD_NAME SPEC_DIR SPEC_PATH + SPEC_NAME="$1" + POD_NAME=$(basename "$SPEC_NAME" .podspec) + SPEC_DIR="$SPEC_REPO_DIR/$POD_NAME/$(version "$SPEC_NAME")" + SPEC_PATH="$SPEC_DIR/$SPEC_NAME.json" + mkdir -p "$SPEC_DIR" + env INSTALL_YOGA_WITHOUT_PATH_OPTION=1 INSTALL_YOGA_FROM_LOCATION="$ROOT" bundle exec pod ipc spec "$SPEC_NAME" > "$SPEC_PATH" } # Perform linting and publishing of podspec in cwd. # Skip linting with `SKIP_LINT` if e.g. publishing to a private spec repo. process() { - cd $1 + cd "$1" if [ -z "$SKIP_LINT" ]; then - lint $2 + lint "$2" fi local SPEC_NAME=(*.podspec) - push $SPEC_NAME + push "${SPEC_NAME[0]}" } # Make third-party deps accessible