popeyelau / wiki

📒Wiki for many useful notes, source, commands and snippets.
2 stars 0 forks source link

Shorebird - Flutter Code Push #41

Open popeyelau opened 1 year ago

popeyelau commented 1 year ago

https://docs.shorebird.dev/status https://github.com/shorebirdtech

shorebird.yaml

app_id: xxxxxxxxxxxxxx
flavors:
internal: xxxxxxxxxxxx
stable: xxxxxxxxxxxx
base_url: https://api.shorebird.dev
auto_update: false

// init shorebird https://github.com/shorebirdtech/engine/blob/shorebird/dev/shell/common/shorebird.cc#L42 https://github.com/shorebirdtech/engine/blob/shorebird/dev/shell/common/shorebird.cc#L73

// init updater https://github.com/shorebirdtech/updater/blob/main/library/src/c_api.rs#L104 https://github.com/shorebirdtech/updater/blob/main/library/src/updater.rs#L106

// shorebird_start_update_thread(); https://github.com/shorebirdtech/engine/blob/shorebird/dev/shell/common/shorebird.cc#L107

https://github.com/shorebirdtech/updater/blob/main/library/src/updater.rs#L271 https://github.com/shorebirdtech/updater/blob/main/library/src/cache.rs#L316

Android

https://github.com/shorebirdtech/engine/blob/shorebird/dev/shell/platform/android/flutter_main.cc#L134

iOS

// libupdater.a https://github.com/shorebirdtech/engine/blob/shorebird/dev/shell/platform/darwin/ios/BUILD.gn#L202

// settings.application_library_path https://github.com/shorebirdtech/engine/blob/shorebird/dev/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm#L222

// download patch https://github.com/shorebirdtech/updater/blob/main/library/src/updater.rs#L206

// restart with shorebird_next_boot_patch_path https://github.com/shorebirdtech/engine/blob/shorebird/dev/shell/common/shorebird.cc#L96

// Hacks for iOS demo https://github.com/shorebirdtech/engine/commit/12c4135b5c90854fb9efc360c0b3ac25d37e9f3f https://github.com/shorebirdtech/engine/blob/12c4135b5c90854fb9efc360c0b3ac25d37e9f3f/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm#L229

directory structure

AppData
├── AppDataInfo.plist
├── Documents
├── Library
│   ├── Application Support
│   │   └── shorebird
│   │       └── shorebird_updater
│   │           ├── downloads
│   │           │   ├── 1
│   │           │   └── 2
│   │           ├── slot_0
│   │           │   └── dlc.vmcode
│   │           ├── slot_1
│   │           │   └── dlc.vmcode
│   │           └── state.json

state.json


{
"cache_dir": "/private/var/mobile/Containers/Data/Application/9A5801A8-510F-48FD-A65C-A398F5D64591/Library/Application Support/shorebird/shorebird_updater",
"release_version": "1.0.0+1",
"failed_patches": [],
"successful_patches": [],
"current_boot_slot_index": 1,
"next_boot_slot_index": 1,
"slots": [
{
"patch_number": 1
},
{
"patch_number": 2
}
]
}

> get patches
``` bash
// check patches
curl -X "POST" "https://api.shorebird.dev/api/v1/patches/check" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "platform": "ios",
  "arch": "aarch64",
  "release_version": "1.0.0+1",
  "app_id": "xxxxxxxxxxxxxxxxx",
  "channel": "stable",
  "patch_number": 1
}'