shorebirdtech / shorebird

Code Push for Flutter and other tools for Flutter businesses.
https://shorebird.dev
Other
2.31k stars 140 forks source link

feat: improve local artifact proxy use #2106

Open felangel opened 5 months ago

felangel commented 5 months ago

Description

Currently, in order to use a local instance of the artifact proxy, we need to manually change two places:

  1. shorebird/third_party/flutter/bin/internal/shared.sh

    # Either clones or pulls the Shorebird Flutter repository, depending on whether FLUTTER_PATH exists.
    function update_flutter {
    if [[ -d "$FLUTTER_PATH" ]]; then
    git -C "$FLUTTER_PATH" fetch
    else
    git clone --filter=tree:0 https://github.com/shorebirdtech/flutter.git --no-checkout "$FLUTTER_PATH"
    fi
    # -c to avoid printing a warning about being in a detached head state.
    git -C "$FLUTTER_PATH" -c advice.detachedHead=false checkout "$FLUTTER_VERSION"
    SHOREBIRD_ENGINE_VERSION=`cat "$FLUTTER_PATH/bin/internal/engine.version"`
    echo "Shorebird Engine • revision $SHOREBIRD_ENGINE_VERSION"
    # Install Shorebird Flutter Artifacts
    - FLUTTER_STORAGE_BASE_URL=https://download.shorebird.dev $FLUTTER_PATH/bin/flutter --version
    + FLUTTER_STORAGE_BASE_URL=http://localhost:8080 $FLUTTER_PATH/bin/flutter --version  
    }
  2. shorebird/packages/shorebird_cli/lib/src/shorebird_process.dart

    Map<String, String> _environmentOverrides({
    required String executable,
    }) {
    if (executable == 'flutter') {
      // If this ever changes we also need to update the `shorebird` shell
      // wrapper which downloads runs Flutter to fetch artifacts the first time.
    -     return {'FLUTTER_STORAGE_BASE_URL': 'https://download.shorebird.dev'};
    +     return {'FLUTTER_STORAGE_BASE_URL': 'http://localhost:8080'};
    }
    
    return {};
    }
    }

In addition, the local build.gradle needs to be modified to allow http:

allprojects {
    repositories {
        google()
        mavenCentral()

+       all {
+           allowInsecureProtocol = true
+       }
    }
}

It would be nice to expose an environment variable that can be specified to override this without modifying the source e.g. SHOREBIRD_ARTIFACT_PROXY_URL.

Not sure about how to improve the build.gradle experience but open to suggestions.