1#!/bin/bash 2# Copyright (c) Meta Platforms, Inc. and affiliates. 3# 4# This source code is licensed under the MIT license found in the 5# LICENSE file in the root directory of this source tree. 6 7set -ex 8 9SCRIPTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 10ROOT="$(dirname "$SCRIPTS")" 11 12# Specify `SPEC_REPO` as an env variable if you want to push to a specific spec repo. 13# Defaults to `react-test`, which is meant to be a dummy repo used to test that the specs fully lint. 14: "${SPEC_REPO:=react-test}" 15SPEC_REPO_DIR="$HOME/.cocoapods/repos/$SPEC_REPO" 16 17# If the `SPEC_REPO` does not exist yet, assume this is purely for testing and create a dummy repo. 18if ! [ -d "$SPEC_REPO_DIR" ]; then 19 mkdir -p "$SPEC_REPO_DIR" 20 cd "$SPEC_REPO_DIR" 21 touch .gitkeep 22 git init 23 git add . 24 git commit -m "init" 25 git remote add origin "https://example.com/$SPEC_REPO.git" 26fi 27 28cd "$SPEC_REPO_DIR" 29SPEC_REPOS="$(git remote get-url origin),https://github.com/CocoaPods/Specs.git" 30 31POD_LINT_OPT=(--verbose --allow-warnings --fail-fast --private "--swift-version=3.0" "--sources=$SPEC_REPOS") 32 33# Get the version from a podspec. 34version() { 35 ruby -rcocoapods-core -rjson -e "puts Pod::Specification.from_file('$1').version" 36} 37 38# Lint both framework and static library builds. 39lint() { 40 local SUBSPEC="$1" 41 if [ "${SUBSPEC:-}" ]; then 42 local SUBSPEC_OPT="--subspec=$SUBSPEC" 43 fi 44 bundle exec pod lib lint "$SUBSPEC_OPT" "${POD_LINT_OPT[@]}" 45 bundle exec pod lib lint "$SUBSPEC_OPT" "${POD_LINT_OPT[@]}" --use-libraries 46} 47 48# Push the spec in arg `$1`, which is expected to be in the cwd, to the `SPEC_REPO` in JSON format. 49push() { 50 local SPEC_NAME POD_NAME SPEC_DIR SPEC_PATH 51 SPEC_NAME="$1" 52 POD_NAME=$(basename "$SPEC_NAME" .podspec) 53 SPEC_DIR="$SPEC_REPO_DIR/$POD_NAME/$(version "$SPEC_NAME")" 54 SPEC_PATH="$SPEC_DIR/$SPEC_NAME.json" 55 mkdir -p "$SPEC_DIR" 56 env INSTALL_YOGA_WITHOUT_PATH_OPTION=1 INSTALL_YOGA_FROM_LOCATION="$ROOT" bundle exec pod ipc spec "$SPEC_NAME" > "$SPEC_PATH" 57} 58 59# Perform linting and publishing of podspec in cwd. 60# Skip linting with `SKIP_LINT` if e.g. publishing to a private spec repo. 61process() { 62 cd "$1" 63 if [ -z "$SKIP_LINT" ]; then 64 lint "$2" 65 fi 66 local SPEC_NAME=(*.podspec) 67 push "${SPEC_NAME[0]}" 68} 69 70# Make third-party deps accessible 71cd "$ROOT/third-party-podspecs" 72push Folly.podspec 73push DoubleConversion.podspec 74push glog.podspec 75 76process "$ROOT/ReactCommon/yoga" 77process "$ROOT" _ignore_me_subspec_for_linting_ 78