From b907ca61e680233cb04295577a93d29d9b5aac2a Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Wed, 16 Jul 2025 17:48:21 -0700 Subject: [PATCH] app: fixes for ota update capabilities --- cmd/libstreamplace/build-flags.go | 14 ++++++++--- js/app/components/settings/updates.native.tsx | 22 +++++++++++------- pkg/api/app-updates.go | 23 +++++++++++++++++-- util/streamplace-dev.sh | 5 ++-- 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/cmd/libstreamplace/build-flags.go b/cmd/libstreamplace/build-flags.go index 3fe7171f1..21e466baf 100644 --- a/cmd/libstreamplace/build-flags.go +++ b/cmd/libstreamplace/build-flags.go @@ -1,5 +1,13 @@ package main -var Version = "unknown" -var BuildTime = "0" -var UUID = "unknown" +import ( + "fmt" + "os" + "time" + + "github.com/google/uuid" +) + +var Version = os.Getenv("STREAMPLACE_DEV_VERSION") +var BuildTime = fmt.Sprint(time.Now().Unix()) +var UUID = uuid.New().String() diff --git a/js/app/components/settings/updates.native.tsx b/js/app/components/settings/updates.native.tsx index c771f65fc..d07f1ba0e 100644 --- a/js/app/components/settings/updates.native.tsx +++ b/js/app/components/settings/updates.native.tsx @@ -7,16 +7,12 @@ import pkg from "../../package.json"; export function Updates() { const version = pkg.version; - const { currentlyRunning, isUpdateAvailable, isUpdatePending } = - ExpoUpdates.useUpdates(); + const updateInfo = ExpoUpdates.useUpdates(); + const { currentlyRunning, isUpdateAvailable, isUpdatePending } = updateInfo; - const [checked, setChecked] = useState(false); + console.log(`updateInfo: ${JSON.stringify(updateInfo)}`); - useEffect(() => { - if (isUpdatePending) { - ExpoUpdates.reloadAsync(); - } - }, [isUpdatePending]); + const [checked, setChecked] = useState(false); useEffect(() => { if (isUpdateAvailable && checked) { @@ -74,6 +70,16 @@ export function Updates() { > {buttonText} + {isUpdatePending && ( + + )} ); diff --git a/pkg/api/app-updates.go b/pkg/api/app-updates.go index 77cb74225..f33b087cd 100644 --- a/pkg/api/app-updates.go +++ b/pkg/api/app-updates.go @@ -238,6 +238,21 @@ func PrepareUpdater(cli *config.CLI) (*Updater, error) { return nil, fmt.Errorf("package.json has runtimeVersion that's not a string") } + expoConfig, err := fs.Open("expoConfig.json") + if err != nil { + return nil, fmt.Errorf("couldn't open expoConfig.json: %w", err) + } + expoConfigBytes, err := io.ReadAll(expoConfig) + if err != nil { + return nil, fmt.Errorf("couldn't read expoConfig.json: %w", err) + } + expoConfigJSON := map[string]any{} + err = json.Unmarshal(expoConfigBytes, &expoConfigJSON) + if err != nil { + return nil, fmt.Errorf("couldn't parse expoConfig.json: %w", err) + } + extra["expoClient"] = expoConfigJSON + var privateKey *rsa.PrivateKey if cli.SigningKeyPath != "" { privateKey, err = cli.ParseSigningKey() @@ -257,10 +272,14 @@ func PrepareUpdater(cli *config.CLI) (*Updater, error) { func (a *StreamplaceAPI) HandleAppUpdates(ctx context.Context) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { - prefix := fmt.Sprintf("http://%s", req.Host) + proto := "http" if req.TLS != nil { - prefix = fmt.Sprintf("https://%s", req.Host) + proto = "https" + } + if xfproto := req.Header.Get("x-forwarded-proto"); xfproto == "https" { + proto = "https" } + prefix := fmt.Sprintf("%s://%s", proto, req.Host) log.Log(ctx, "got app-updates request", "method", req.Method, "headers", req.Header) plat := req.Header.Get("expo-platform") if plat == "" { diff --git a/util/streamplace-dev.sh b/util/streamplace-dev.sh index ae5ba6632..a81e14d2f 100755 --- a/util/streamplace-dev.sh +++ b/util/streamplace-dev.sh @@ -6,7 +6,8 @@ set -euo pipefail SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +STREAMPLACE_DEV_VERSION=$(go run ./pkg/config/git/git.go -v) \ LD_LIBRARY_PATH="$SCRIPT_DIR/lib/usr/local/lib/x86_64-linux-gnu" \ - DYLD_LIBRARY_PATH="$SCRIPT_DIR/lib/usr/local/lib" \ - SP_DEV_FRONTEND_PROXY="http://127.0.0.1:38081" \ +DYLD_LIBRARY_PATH="$SCRIPT_DIR/lib/usr/local/lib" \ +SP_DEV_FRONTEND_PROXY="http://127.0.0.1:38081" \ exec "$SCRIPT_DIR/libstreamplace" "$@" -- 2.51.2