-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathsetup_private_specs.sh
executable file
·108 lines (82 loc) · 2.86 KB
/
setup_private_specs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# This script generates a private spec repo in your $HOME/.aws-amplify
# directory, to enable `pod lib lint`. It also makes it easier to do
# development against unreleased versions of Amplify, at least until we start
# releasing nightly builds.
set -e
declare -r LOCAL_SPEC_GIT_ROOT="$HOME/.aws-amplify/aws-appsync-realtime-client-ios/aws-appsync-realtime-client-ios-podspecs.git"
declare -r LOCAL_SPEC_REPO_NAME="aws-appsync-realtime-client-ios-local-specs"
declare -r COCOAPODS_REPO_DIR="${HOME}/.cocoapods/repos/${LOCAL_SPEC_REPO_NAME}"
function init_spec_git_root {
# If directory exists, assume it's correctly set up; don't attempt any
# repairs or validation
if [[ -d "${LOCAL_SPEC_GIT_ROOT}" ]] ; then
return 0
fi
mkdir -p "${LOCAL_SPEC_GIT_ROOT}"
old_pwd="${PWD}"
cd "${LOCAL_SPEC_GIT_ROOT}"
git init --bare
cd "${old_pwd}"
}
function init_spec_repo {
# If repo exists, assume it's correctly set up; don't attempt any
# repairs or validation
if [[ -n "$(pod repo list | grep ${LOCAL_SPEC_REPO_NAME})" ]] ; then
return 0
fi
init_spec_git_root
pod repo add --silent "${LOCAL_SPEC_REPO_NAME}" "${LOCAL_SPEC_GIT_ROOT}"
old_pwd="${PWD}"
cd "${COCOAPODS_REPO_DIR}"
git commit --allow-empty -m "Empty commit"
git push
cd "${old_pwd}"
if [[ -z "$(pod repo list | grep ${LOCAL_SPEC_REPO_NAME})" ]] ; then
pod repo add --silent "${LOCAL_SPEC_REPO_NAME}" "${LOCAL_SPEC_GIT_ROOT}"
else
pod repo update --silent "${LOCAL_SPEC_REPO_NAME}"
fi
}
function update_spec_repo {
old_pwd="${PWD}"
cd "${COCOAPODS_REPO_DIR}"
git add .
git commit --allow-empty -m "Update specs"
git push
cd "${old_pwd}"
}
function write_munged_podspec {
declare -r src_file=$1
declare -r dst_file=$2
ruby -e "puts ARGF.read.gsub('$old_version', '$new_version').gsub!(/s.source *=.*?\}/m,'s.source = { :git => \'file://${src_dir}\' }')" "${src_file}" \
> "${dst_file}"
}
declare -r old_version="$1"
if [[ -z $old_version ]] ; then
echo "Must specify old_version" >&2
exit 1
fi
declare -r new_version="$2"
if [[ -z $new_version ]] ; then
echo "Must specify new_version" >&2
exit 1
fi
init_spec_repo
declare -r src_dir="$PWD"
podspec_file_names=()
while read -r podspec_file ; do
podspec_file_name=$( basename "$podspec_file" )
podspec_file_names+=("$podspec_file_name")
pod_name=$( basename "$podspec_file_name" .podspec )
dst_dir="${COCOAPODS_REPO_DIR}/${pod_name}/${new_version}"
dst_file="${dst_dir}/${podspec_file_name}"
mkdir -p "${dst_dir}"
write_munged_podspec "$podspec_file" "$dst_file"
done < <( find "${src_dir}" -maxdepth 1 -mindepth 1 -name "*.podspec" | sort --ignore-case )
update_spec_repo
echo "Done. You may now validate podspec files by running:"
for podspec_file_name in "${podspec_file_names[@]}" ; do
echo
echo "pod lib lint --sources=${LOCAL_SPEC_REPO_NAME},trunk ${podspec_file_name}"
done