2017-02-07 00:16:46 +00:00
|
|
|
#!/bin/bash
|
2021-12-30 23:08:43 +00:00
|
|
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
2018-09-07 20:08:05 +00:00
|
|
|
#
|
|
|
|
# This source code is licensed under the MIT license found in the
|
|
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
|
2017-02-07 00:16:46 +00:00
|
|
|
set -ex
|
|
|
|
|
2021-10-02 04:21:03 +00:00
|
|
|
SCRIPTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
ROOT="$(dirname "$SCRIPTS")"
|
2017-02-07 00:16:46 +00:00
|
|
|
|
|
|
|
# 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.
|
2021-10-02 04:21:03 +00:00
|
|
|
: "${SPEC_REPO:=react-test}"
|
2017-02-07 00:16:46 +00:00
|
|
|
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.
|
|
|
|
if ! [ -d "$SPEC_REPO_DIR" ]; then
|
|
|
|
mkdir -p "$SPEC_REPO_DIR"
|
|
|
|
cd "$SPEC_REPO_DIR"
|
2017-07-07 09:29:23 +00:00
|
|
|
touch .gitkeep
|
2017-02-07 00:16:46 +00:00
|
|
|
git init
|
2017-07-07 09:29:23 +00:00
|
|
|
git add .
|
2017-02-07 00:16:46 +00:00
|
|
|
git commit -m "init"
|
|
|
|
git remote add origin "https://example.com/$SPEC_REPO.git"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$SPEC_REPO_DIR"
|
2017-07-07 09:29:23 +00:00
|
|
|
SPEC_REPOS="$(git remote get-url origin),https://github.com/CocoaPods/Specs.git"
|
2017-02-07 00:16:46 +00:00
|
|
|
|
2021-10-02 04:21:03 +00:00
|
|
|
POD_LINT_OPT=(--verbose --allow-warnings --fail-fast --private "--swift-version=3.0" "--sources=$SPEC_REPOS")
|
2017-02-07 00:16:46 +00:00
|
|
|
|
|
|
|
# Get the version from a podspec.
|
|
|
|
version() {
|
|
|
|
ruby -rcocoapods-core -rjson -e "puts Pod::Specification.from_file('$1').version"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Lint both framework and static library builds.
|
|
|
|
lint() {
|
2021-10-02 04:21:03 +00:00
|
|
|
local SUBSPEC="$1"
|
2017-07-07 09:29:23 +00:00
|
|
|
if [ "${SUBSPEC:-}" ]; then
|
|
|
|
local SUBSPEC_OPT="--subspec=$SUBSPEC"
|
|
|
|
fi
|
2021-10-02 04:21:03 +00:00
|
|
|
bundle exec pod lib lint "$SUBSPEC_OPT" "${POD_LINT_OPT[@]}"
|
|
|
|
bundle exec pod lib lint "$SUBSPEC_OPT" "${POD_LINT_OPT[@]}" --use-libraries
|
2017-02-07 00:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Push the spec in arg `$1`, which is expected to be in the cwd, to the `SPEC_REPO` in JSON format.
|
|
|
|
push() {
|
2021-10-02 04:21:03 +00:00
|
|
|
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"
|
2017-02-07 00:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Perform linting and publishing of podspec in cwd.
|
|
|
|
# Skip linting with `SKIP_LINT` if e.g. publishing to a private spec repo.
|
|
|
|
process() {
|
2021-10-02 04:21:03 +00:00
|
|
|
cd "$1"
|
2017-02-07 00:16:46 +00:00
|
|
|
if [ -z "$SKIP_LINT" ]; then
|
2021-10-02 04:21:03 +00:00
|
|
|
lint "$2"
|
2017-02-07 00:16:46 +00:00
|
|
|
fi
|
|
|
|
local SPEC_NAME=(*.podspec)
|
2021-10-02 04:21:03 +00:00
|
|
|
push "${SPEC_NAME[0]}"
|
2017-02-07 00:16:46 +00:00
|
|
|
}
|
|
|
|
|
2017-07-07 09:29:23 +00:00
|
|
|
# Make third-party deps accessible
|
|
|
|
cd "$ROOT/third-party-podspecs"
|
|
|
|
push Folly.podspec
|
|
|
|
push DoubleConversion.podspec
|
2018-01-29 06:12:19 +00:00
|
|
|
push glog.podspec
|
2017-07-07 09:29:23 +00:00
|
|
|
|
|
|
|
process "$ROOT/ReactCommon/yoga"
|
|
|
|
process "$ROOT" _ignore_me_subspec_for_linting_
|