-
Notifications
You must be signed in to change notification settings - Fork 2
/
justfile
214 lines (183 loc) · 7.83 KB
/
justfile
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# do not create a shorcut for `publish` command to avoid accidental publishing
alias b := build
alias c := clean
alias cjcfrn := copy-js-code-from-react-native
alias cncfrn := copy-native-code-from-react-native
alias d := docs
alias gd := get-dependencies
alias od := open-docs
alias ogp := open-github-prs
alias ogr := open-github-releases
alias pt := push-tag
alias r := release
alias us := update-sdk
alias usa := update-sdk-android
alias usal := update-sdk-android-latest
alias usi := update-sdk-ios
alias usil := update-sdk-ios-latest
alias usl := update-sdk-latest
alias v := version
# Source: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
# \ are escaped
SEMVER_REGEX := "(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?"
# MAKE SURE YOU HAVE
# #!/usr/bin/env sh
# set -e
# AT THE TOP OF YOUR RECIPE
_ask-confirm:
@bash -c 'read confirmation; if [[ $confirmation != "y" && $confirmation != "Y" ]]; then echo "Okay 😮💨 😅"; exit 1; fi'
build: get-dependencies
npm run build
clean: _clear-node-modules
rm package-lock.json
copy-native-code-from-react-native:
cp -rf ../sdk-react-native/sdk/android/src/main/java/com/reactnativehypertracksdk/common android/src/main/java/com/hypertrack/sdk/capacitor/
cp -rf ../sdk-react-native/sdk/ios/common ios/Plugin/
copy-js-code-from-react-native:
cp -rf ../sdk-react-native/sdk/src/HyperTrack/data_types src
cp -f ../sdk-react-native/sdk/src/HyperTrack/HyperTrack.ts src/HyperTrack.ts
cp -f ../sdk-react-native/sdk/src/index.tsx src/index.ts
_clear-node-modules:
rm -rf node_modules
docs: build format
npm run docgen
format:
brew upgrade ktlint
ktlint --format android/src/main/
get-dependencies:
npm i
_latest-android:
@curl -s https://s3-us-west-2.amazonaws.com/m2.hypertrack.com/com/hypertrack/sdk-android/maven-metadata-sdk-android.xml | grep latest | grep -o -E '{{SEMVER_REGEX}}' | head -n 1
_latest-ios:
@curl -s https://cocoapods.org/pods/HyperTrack | grep -m 1 -o -E "HyperTrack <span>{{SEMVER_REGEX}}" | grep -o -E '{{SEMVER_REGEX}}' | head -n 1
open-docs: docs
open docs/index.html
open-github-prs:
open "https://github.com/hypertrack/sdk-ionic-capacitor/pulls"
open-github-releases:
open "https://github.com/hypertrack/sdk-ionic-capacitor/releases"
_open-github-release-data:
code CHANGELOG.md
just open-github-releases
push-tag:
#!/usr/bin/env sh
set -euo pipefail
if [ $(git symbolic-ref --short HEAD) = "main" ] ; then
VERSION=$(just version)
git tag $VERSION
git push origin $VERSION
just _open-github-release-data
else
echo "You are not on main branch"
fi
release publish="dry-run": build
#!/usr/bin/env sh
set -euo pipefail
VERSION=$(just version)
if [ {{publish}} = "publish" ]; then
BRANCH=$(git branch --show-current)
if [ $BRANCH != "main" ]; then
echo "You must be on main branch to publish a new version (current branch: $BRANCH))"
exit 1
fi
echo "Are you sure you want to publish version $VERSION? (y/N)"
just _ask-confirm
npm publish
open "https://www.npmjs.com/package/hypertrack-sdk-ionic-capacitor/v/$VERSION"
open "https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/$VERSION"
else
npm publish --dry-run
fi
setup: get-dependencies
_update-readme-android android_version:
./scripts/update_file.sh README.md 'Android\%20SDK-.*-brightgreen.svg' 'Android%20SDK-{{android_version}}-brightgreen.svg'
_update-readme-ios ios_version:
./scripts/update_file.sh README.md 'iOS\%20SDK-.*-brightgreen.svg' 'iOS%20SDK-{{ios_version}}-brightgreen.svg'
update-sdk-latest wrapper_version commit="true" branch="true":
#!/usr/bin/env sh
set -euo pipefail
LATEST_IOS=$(just _latest-ios)
LATEST_ANDROID=$(just _latest-android)
just update-sdk {{wrapper_version}} $LATEST_IOS $LATEST_ANDROID {{commit}} {{branch}}
update-sdk-android-latest wrapper_version commit="true" branch="true":
#!/usr/bin/env sh
set -euo pipefail
LATEST_ANDROID=$(just _latest-android)
just update-sdk-android {{wrapper_version}} $LATEST_ANDROID {{commit}} {{branch}}
update-sdk-ios-latest wrapper_version commit="true" branch="true":
#!/usr/bin/env sh
set -euo pipefail
LATEST_IOS=$(just _latest-ios)
just update-sdk-ios {{wrapper_version}} $LATEST_IOS {{commit}} {{branch}}
update-sdk wrapper_version ios_version android_version commit="true" branch="true": build
#!/usr/bin/env sh
set -euo pipefail
if [ "{{branch}}" = "true" ] ; then
git checkout -b update-sdk-ios-{{ios_version}}-android-{{android_version}}
fi
just version
echo "New version is {{wrapper_version}}"
just _update-wrapper-version-file {{wrapper_version}}
./scripts/update_changelog.sh -w {{wrapper_version}} -i {{ios_version}} -a {{android_version}}
echo "Updating HyperTrack SDK iOS to {{ios_version}}"
just _update-sdk-ios-version-file {{ios_version}}
just _update-readme-ios {{ios_version}}
echo "Updating HyperTrack SDK Android to {{android_version}}"
just _update-sdk-android-version-file {{android_version}}
just _update-readme-android {{android_version}}
just docs
if [ "{{commit}}" = "true" ] ; then
git add .
git commit -m "Update HyperTrack SDK iOS to {{ios_version}} and Android to {{android_version}}"
fi
if [ "{{branch}}" = "true" ] && [ "{{commit}}" = "true" ] ; then
just open-github-prs
fi
update-sdk-android wrapper_version android_version commit="true" branch="true": build
#!/usr/bin/env sh
set -euo pipefail
if [ "{{branch}}" = "true" ] ; then
git checkout -b update-sdk-android-{{android_version}}
fi
just version
echo "Updating HyperTrack SDK Android to {{android_version}} on {{wrapper_version}}"
just _update-wrapper-version-file {{wrapper_version}}
just _update-sdk-android-version-file {{android_version}}
just _update-readme-android {{android_version}}
./scripts/update_changelog.sh -w {{wrapper_version}} -a {{android_version}}
just docs
if [ "{{commit}}" = "true" ] ; then
git add .
git commit -m "Update HyperTrack SDK Android to {{android_version}}"
fi
if [ "{{branch}}" = "true" ] && [ "{{commit}}" = "true" ] ; then
just open-github-prs
fi
update-sdk-ios wrapper_version ios_version commit="true" branch="true": build
#!/usr/bin/env sh
set -euo pipefail
if [ "{{branch}}" = "true" ] ; then
git checkout -b update-sdk-ios-{{ios_version}}
fi
just version
echo "Updating HyperTrack SDK iOS to {{ios_version}} on {{wrapper_version}}"
just _update-wrapper-version-file {{wrapper_version}}
just _update-sdk-ios-version-file {{ios_version}}
just _update-readme-ios {{ios_version}}
./scripts/update_changelog.sh -w {{wrapper_version}} -i {{ios_version}}
just docs
if [ "{{commit}}" = "true" ] ; then
git add .
git commit -m "Update HyperTrack SDK iOS to {{ios_version}}"
fi
if [ "{{branch}}" = "true" ] && [ "{{commit}}" = "true" ] ; then
just open-github-prs
fi
_update-sdk-android-version-file android_version:
./scripts/update_file.sh android/build.gradle 'ext.hypertrack_sdk_version = ".*"' 'ext.hypertrack_sdk_version = "{{android_version}}"'
_update-sdk-ios-version-file ios_version:
./scripts/update_file.sh HypertrackSdkIonicCapacitor.podspec "'HyperTrack','.*'" "'HyperTrack','{{ios_version}}'"
_update-wrapper-version-file wrapper_version:
./scripts/update_file.sh package.json '"version": ".*"' '"version": "{{wrapper_version}}"'
version:
@cat package.json | grep version | head -n 1 | grep -o -E '{{SEMVER_REGEX}}'