#!/usr/bin/env bash # Packages flutter_sdk + its two private dependencies into a deliverable ZIP. # Usage: bash scripts/package_sdk.sh [version] # e.g. bash scripts/package_sdk.sh 1.2.0 set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SDK_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" WORK_DIR="$(cd "$SDK_DIR/.." && pwd)" # ── Version ────────────────────────────────────────────────────────────────── if [[ "${1:-}" != "" ]]; then VERSION="$1" else VERSION="$(grep '^version:' "$SDK_DIR/pubspec.yaml" | awk '{print $2}')" fi DIST_NAME="starcloud_flutter_sdk_v${VERSION}" # Stage in /tmp so the SDK source tree is never inside the staging area # (avoids rsync accidentally bundling dist/ into itself) STAGE_DIR="$(mktemp -d)/$DIST_NAME" mkdir -p "$STAGE_DIR" echo "Packaging $DIST_NAME ..." # ── Helpers ─────────────────────────────────────────────────────────────────── copy_pkg() { local src="$1" dst="$2" rsync -a \ --exclude='.git/' \ --exclude='build/' \ --exclude='dist/' \ --exclude='.dart_tool/' \ --exclude='.idea/' \ --exclude='*.iml' \ --exclude='.DS_Store' \ --exclude='pubspec.lock' \ "$src/" "$dst/" } # ── 1. flutter_sdk ──────────────────────────────────────────────────────────── echo " → flutter_sdk" copy_pkg "$SDK_DIR" "$STAGE_DIR/flutter_sdk" # Rewrite starcloud path for the delivery layout (../starcloud instead of the # internal monorepo path ../sikaigongyu/starcloud-sdk-flutter-master) perl -i -pe \ 's|path: \.\./sikaigongyu/starcloud-sdk-flutter-master|path: ../starcloud|g' \ "$STAGE_DIR/flutter_sdk/pubspec.yaml" # Same rewrite for the example app (../../starcloud vs ../../sikaigongyu/...) perl -i -pe \ 's|path: \.\./\.\./sikaigongyu/starcloud-sdk-flutter-master|path: ../../starcloud|g' \ "$STAGE_DIR/flutter_sdk/example/pubspec.yaml" # ── 2. starlock_ble ───────────────────────────────────────────────────────── echo " → starlock_ble" copy_pkg "$WORK_DIR/starlock_ble" "$STAGE_DIR/starlock_ble" # ── 3. starcloud ───────────────────────────────────────────────────────────── echo " → starcloud" copy_pkg "$WORK_DIR/sikaigongyu/starcloud-sdk-flutter-master" "$STAGE_DIR/starcloud" # ── 4. ZIP ─────────────────────────────────────────────────────────────────── echo " → zipping" mkdir -p "$SDK_DIR/dist" (cd "$(dirname "$STAGE_DIR")" && zip -r "${DIST_NAME}.zip" "$DIST_NAME" --quiet) mv "$(dirname "$STAGE_DIR")/${DIST_NAME}.zip" "$SDK_DIR/dist/" rm -rf "$(dirname "$STAGE_DIR")" echo "" echo "✅ dist/${DIST_NAME}.zip" echo "" echo "Partner setup (3 steps):" echo " 1. Unzip and copy the three SDK folders into vendor/" echo " 2. Add path dependencies to pubspec.yaml (see INTEGRATION.md)" echo " 3. flutter pub get"