# Run with tooling from https://github.com/flutter/codelabs/tree/main/tooling/codelab_rebuild
name: Infinite List rebuild script
steps:
  - name: Remove runners
    rmdirs:
      - android
      - ios 
      - macos
      - linux
      - windows
      - web
  - name: Recreate runners
    flutter: create --org dev.flutter .
  - name: Patch macos/Runner/DebugProfile.entitlements
    path: macos/Runner/DebugProfile.entitlements
    patch-u: |
      --- b/macos/Runner/DebugProfile.entitlements
      +++ a/macos/Runner/DebugProfile.entitlements
      @@ -6,6 +6,10 @@
       	<true/>
       	<key>com.apple.security.cs.allow-jit</key>
       	<true/>
      +	<key>com.apple.security.files.user-selected.read-write</key>
      +	<true/>
      +	<key>com.apple.security.network.client</key>
      +	<true/>
       	<key>com.apple.security.network.server</key>
       	<true/>
       </dict>
  - name: Patch macos/Runner/Release.entitlements
    path: macos/Runner/Release.entitlements
    patch-u: |
      --- b/macos/Runner/Release.entitlements
      +++ a/macos/Runner/Release.entitlements
      @@ -4,5 +4,9 @@
       <dict>
       	<key>com.apple.security.app-sandbox</key>
       	<true/>
      +	<key>com.apple.security.files.user-selected.read-write</key>
      +	<true/>
      +	<key>com.apple.security.network.client</key>
      +	<true/>
       </dict>
       </plist>
  - name: Remove widget_test.dart
    rm: test/widget_test.dart
  - name: Flutter upgrade
    flutter: pub upgrade --major-versions
  - name: Flutter build macOS
    flutter: build macos
  - name: Flutter build macOS
    flutter: build ios --simulator
