Skip to content

Commit fcfa9db

Browse files
committed
refactor: emit jsonobject-based models without any
Regenerate types from https://github.com/hyodotdev/openiap-gql/releases/tag/1.0.8
1 parent f115c8e commit fcfa9db

File tree

5 files changed

+82
-19
lines changed

5 files changed

+82
-19
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ Add to your module's `build.gradle.kts`:
4848

4949
```kotlin
5050
dependencies {
51-
implementation("io.github.hyochan.openiap:openiap-google:1.1.12")
51+
implementation("io.github.hyochan.openiap:openiap-google:1.2.5")
5252
}
5353
```
5454

5555
Or `build.gradle`:
5656

5757
```groovy
5858
dependencies {
59-
implementation 'io.github.hyochan.openiap:openiap-google:1.1.12'
59+
implementation 'io.github.hyochan.openiap:openiap-google:1.2.5'
6060
}
6161
```
6262

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ kotlin.code.style=official
1616
android.nonTransitiveRClass=true
1717

1818
# Version
19-
OPENIAP_VERSION=1.1.12
19+
OPENIAP_VERSION=1.2.5
2020

2121
# Library Info
2222
OPENIAP_GROUP_ID=io.github.hyochan.openiap

openiap/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ dependencies {
5353

5454
// Google Play Billing Library (align with app/lib v8)
5555
api("com.android.billingclient:billing-ktx:8.0.0")
56+
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
5657

5758
// Kotlin Coroutines
5859
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")

scripts/generate-types.sh

Lines changed: 78 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,94 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
VERSION="${1:-1.0.8}"
5-
REPO="https://github.com/hyodotdev/openiap-gql"
6-
ASSET="openiap-kotlin.zip"
7-
DOWNLOAD_URL="${REPO}/releases/download/${VERSION}/${ASSET}"
4+
VERSION="1.0.8"
5+
SKIP_DOWNLOAD=false
6+
7+
while [[ $# -gt 0 ]]; do
8+
case "$1" in
9+
--skip-download)
10+
SKIP_DOWNLOAD=true
11+
shift
12+
;;
13+
--version)
14+
if [[ $# -lt 2 ]]; then
15+
echo "--version requires an argument" >&2
16+
exit 1
17+
fi
18+
shift 2
19+
;;
20+
--help)
21+
cat <<'EOF'
22+
Usage: ./scripts/generate-types.sh [--version <tag>] [--skip-download]
23+
24+
Options:
25+
--version Release tag to download from openiap-gql (default: VERSION file)
26+
--skip-download Reuse the existing Types.kt and only run post-processing
27+
EOF
28+
exit 0
29+
;;
30+
--*)
31+
echo "Unknown option: $1" >&2
32+
exit 1
33+
;;
34+
*)
35+
if [[ -n "$VERSION" ]]; then
36+
echo "Unexpected argument: $1" >&2
37+
exit 1
38+
fi
39+
VERSION="$1"
40+
shift
41+
;;
42+
esac
43+
done
844

945
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1046
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
1147
TARGET_DIR="${REPO_ROOT}/openiap/src/main/java/dev/hyo/openiap"
1248
TARGET_FILE="${TARGET_DIR}/Types.kt"
49+
VERSION_FILE="${REPO_ROOT}/VERSION"
1350

14-
TMP_DIR="$(mktemp -d)"
15-
cleanup() {
16-
rm -rf "${TMP_DIR}"
17-
}
18-
trap cleanup EXIT
51+
if [[ -z "$VERSION" ]] && [[ -f "$VERSION_FILE" ]]; then
52+
VERSION="$(head -n1 "$VERSION_FILE" | tr -d ' \r')"
53+
fi
1954

20-
printf 'Downloading %s\n' "${DOWNLOAD_URL}"
21-
curl -fL "${DOWNLOAD_URL}" -o "${TMP_DIR}/${ASSET}"
55+
if [[ -z "$VERSION" ]]; then
56+
echo "Unable to determine version. Provide --version or make sure VERSION file exists." >&2
57+
exit 1
58+
fi
2259

23-
printf 'Extracting Types.kt\n'
24-
unzip -q "${TMP_DIR}/${ASSET}" -d "${TMP_DIR}"
60+
REPO="https://github.com/hyodotdev/openiap-gql"
61+
ASSET="openiap-kotlin.zip"
62+
DOWNLOAD_URL="${REPO}/releases/download/${VERSION}/${ASSET}"
2563

2664
mkdir -p "${TARGET_DIR}"
27-
rm -f "${TARGET_FILE}"
28-
cp "${TMP_DIR}/Types.kt" "${TARGET_FILE}"
65+
66+
TMP_DIR=""
67+
cleanup() {
68+
if [[ -n "$TMP_DIR" && -d "$TMP_DIR" ]]; then
69+
rm -rf "$TMP_DIR"
70+
fi
71+
}
72+
73+
if [[ "$SKIP_DOWNLOAD" == false ]]; then
74+
TMP_DIR="$(mktemp -d)"
75+
trap cleanup EXIT
76+
77+
printf 'Downloading %s\n' "${DOWNLOAD_URL}"
78+
curl -fL "${DOWNLOAD_URL}" -o "${TMP_DIR}/${ASSET}"
79+
80+
printf 'Extracting Types.kt\n'
81+
unzip -q "${TMP_DIR}/${ASSET}" -d "${TMP_DIR}"
82+
83+
rm -f "${TARGET_FILE}"
84+
cp "${TMP_DIR}/Types.kt" "${TARGET_FILE}"
85+
else
86+
if [[ ! -f "${TARGET_FILE}" ]]; then
87+
echo "Types.kt not found at ${TARGET_FILE}; cannot skip download" >&2
88+
exit 1
89+
fi
90+
printf 'Skipping download; reusing existing %s\n' "${TARGET_FILE}"
91+
fi
2992

3093
# Patch known Kotlin formatting issues in the upstream artifact so the file compiles
3194
TARGET_FILE="${TARGET_FILE}" python3 <<'PY'

0 commit comments

Comments
 (0)