diff --git a/.github/labeler.yml b/.github/labeler.yml index c5e15a37..b82b065f 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,37 +1,37 @@ -# Configuration for .github/workflows/pull_request_label.yml. +# Configuration for .github/workflows/pull_request_label.yml. -'infra': +'type-infra': - changed-files: - - any-glob-to-any-file: '.github/**' + - any-glob-to-any-file: '.github/**' 'package:shelf': - changed-files: - - any-glob-to-any-file: 'pkgs/shelf/**' + - any-glob-to-any-file: 'pkgs/shelf/**' 'package:shelf_packages_handler': - changed-files: - - any-glob-to-any-file: 'pkgs/shelf_packages_handler/**' + - any-glob-to-any-file: 'pkgs/shelf_packages_handler/**' 'package:shelf_proxy': - changed-files: - - any-glob-to-any-file: 'pkgs/shelf_proxy/**' + - any-glob-to-any-file: 'pkgs/shelf_proxy/**' 'package:shelf_router': - changed-files: - - any-glob-to-any-file: 'pkgs/shelf_router/**' + - any-glob-to-any-file: 'pkgs/shelf_router/**' 'package:shelf_router_generator': - changed-files: - - any-glob-to-any-file: 'pkgs/shelf_router_generator/**' + - any-glob-to-any-file: 'pkgs/shelf_router_generator/**' 'package:shelf_static': - changed-files: - - any-glob-to-any-file: 'pkgs/shelf_static/**' + - any-glob-to-any-file: 'pkgs/shelf_static/**' 'package:shelf_test_handler': - changed-files: - - any-glob-to-any-file: 'pkgs/shelf_test_handler/**' + - any-glob-to-any-file: 'pkgs/shelf_test_handler/**' 'package:shelf_web_socket': - changed-files: - - any-glob-to-any-file: 'pkgs/shelf_web_socket/**' + - any-glob-to-any-file: 'pkgs/shelf_web_socket/**' diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index d59f173b..1c744b16 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -1,4 +1,4 @@ -# Created with package:mono_repo v6.6.1 +# Created with package:mono_repo v6.6.3 name: Dart CI on: push: @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable" @@ -29,37 +29,37 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: stable - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - name: mono_repo self validate - run: dart pub global activate mono_repo 6.6.1 + run: dart pub global activate mono_repo 6.6.3 - name: mono_repo self validate run: dart pub global run mono_repo generate --validate job_002: - name: "analyze_and_format; linux; Dart 3.3.0; PKGS: pkgs/shelf_packages_handler, pkgs/shelf_proxy, pkgs/shelf_router, pkgs/shelf_router_generator, pkgs/shelf_static, pkgs/shelf_test_handler, pkgs/shelf_web_socket; `dart analyze --fatal-infos .`" + name: "analyze_and_format; linux; Dart 3.3.0; PKGS: pkgs/shelf_packages_handler, pkgs/shelf_proxy, pkgs/shelf_router, pkgs/shelf_static; `dart analyze --fatal-infos .`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:pkgs/shelf_packages_handler-pkgs/shelf_proxy-pkgs/shelf_router-pkgs/shelf_router_generator-pkgs/shelf_static-pkgs/shelf_test_handler-pkgs/shelf_web_socket;commands:analyze" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:pkgs/shelf_packages_handler-pkgs/shelf_proxy-pkgs/shelf_router-pkgs/shelf_static;commands:analyze" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:pkgs/shelf_packages_handler-pkgs/shelf_proxy-pkgs/shelf_router-pkgs/shelf_router_generator-pkgs/shelf_static-pkgs/shelf_test_handler-pkgs/shelf_web_socket + os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:pkgs/shelf_packages_handler-pkgs/shelf_proxy-pkgs/shelf_router-pkgs/shelf_static os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: "3.3.0" - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_packages_handler_pub_upgrade name: pkgs/shelf_packages_handler; dart pub upgrade run: dart pub upgrade @@ -87,15 +87,6 @@ jobs: run: dart analyze --fatal-infos . if: "always() && steps.pkgs_shelf_router_pub_upgrade.conclusion == 'success'" working-directory: pkgs/shelf_router - - id: pkgs_shelf_router_generator_pub_upgrade - name: pkgs/shelf_router_generator; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: pkgs/shelf_router_generator - - name: "pkgs/shelf_router_generator; dart analyze --fatal-infos ." - run: dart analyze --fatal-infos . - if: "always() && steps.pkgs_shelf_router_generator_pub_upgrade.conclusion == 'success'" - working-directory: pkgs/shelf_router_generator - id: pkgs_shelf_static_pub_upgrade name: pkgs/shelf_static; dart pub upgrade run: dart pub upgrade @@ -105,6 +96,57 @@ jobs: run: dart analyze --fatal-infos . if: "always() && steps.pkgs_shelf_static_pub_upgrade.conclusion == 'success'" working-directory: pkgs/shelf_static + job_003: + name: "analyze_and_format; linux; Dart 3.4.0; PKG: pkgs/shelf; `dart analyze --fatal-infos .`" + runs-on: ubuntu-latest + steps: + - name: Cache Pub hosted dependencies + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 + with: + path: "~/.pub-cache/hosted" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf;commands:analyze" + restore-keys: | + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted + os:ubuntu-latest + - name: Setup Dart SDK + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c + with: + sdk: "3.4.0" + - id: checkout + name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - id: pkgs_shelf_pub_upgrade + name: pkgs/shelf; dart pub upgrade + run: dart pub upgrade + if: "always() && steps.checkout.conclusion == 'success'" + working-directory: pkgs/shelf + - name: "pkgs/shelf; dart analyze --fatal-infos ." + run: dart analyze --fatal-infos . + if: "always() && steps.pkgs_shelf_pub_upgrade.conclusion == 'success'" + working-directory: pkgs/shelf + job_004: + name: "analyze_and_format; linux; Dart 3.5.0; PKGS: pkgs/shelf_test_handler, pkgs/shelf_web_socket; `dart analyze --fatal-infos .`" + runs-on: ubuntu-latest + steps: + - name: Cache Pub hosted dependencies + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 + with: + path: "~/.pub-cache/hosted" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/shelf_test_handler-pkgs/shelf_web_socket;commands:analyze" + restore-keys: | + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/shelf_test_handler-pkgs/shelf_web_socket + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0 + os:ubuntu-latest;pub-cache-hosted + os:ubuntu-latest + - name: Setup Dart SDK + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c + with: + sdk: "3.5.0" + - id: checkout + name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_test_handler_pub_upgrade name: pkgs/shelf_test_handler; dart pub upgrade run: dart pub upgrade @@ -123,42 +165,42 @@ jobs: run: dart analyze --fatal-infos . if: "always() && steps.pkgs_shelf_web_socket_pub_upgrade.conclusion == 'success'" working-directory: pkgs/shelf_web_socket - job_003: - name: "analyze_and_format; linux; Dart 3.4.0; PKG: pkgs/shelf; `dart analyze --fatal-infos .`" + job_005: + name: "analyze_and_format; linux; Dart 3.9.0; PKG: pkgs/shelf_router_generator; `dart analyze --fatal-infos .`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf;commands:analyze" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.9.0;packages:pkgs/shelf_router_generator;commands:analyze" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.9.0;packages:pkgs/shelf_router_generator + os:ubuntu-latest;pub-cache-hosted;sdk:3.9.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: - sdk: "3.4.0" + sdk: "3.9.0" - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - - id: pkgs_shelf_pub_upgrade - name: pkgs/shelf; dart pub upgrade + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - id: pkgs_shelf_router_generator_pub_upgrade + name: pkgs/shelf_router_generator; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: pkgs/shelf - - name: "pkgs/shelf; dart analyze --fatal-infos ." + working-directory: pkgs/shelf_router_generator + - name: "pkgs/shelf_router_generator; dart analyze --fatal-infos ." run: dart analyze --fatal-infos . - if: "always() && steps.pkgs_shelf_pub_upgrade.conclusion == 'success'" - working-directory: pkgs/shelf - job_004: + if: "always() && steps.pkgs_shelf_router_generator_pub_upgrade.conclusion == 'success'" + working-directory: pkgs/shelf_router_generator + job_006: name: "analyze_and_format; linux; Dart dev; PKGS: pkgs/shelf, pkgs/shelf_packages_handler, pkgs/shelf_proxy, pkgs/shelf_router, pkgs/shelf_router_generator, pkgs/shelf_static, pkgs/shelf_test_handler, pkgs/shelf_web_socket; `dart analyze --fatal-infos .`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:pkgs/shelf-pkgs/shelf_packages_handler-pkgs/shelf_proxy-pkgs/shelf_router-pkgs/shelf_router_generator-pkgs/shelf_static-pkgs/shelf_test_handler-pkgs/shelf_web_socket;commands:analyze" @@ -168,12 +210,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_pub_upgrade name: pkgs/shelf; dart pub upgrade run: dart pub upgrade @@ -246,12 +288,12 @@ jobs: run: dart analyze --fatal-infos . if: "always() && steps.pkgs_shelf_web_socket_pub_upgrade.conclusion == 'success'" working-directory: pkgs/shelf_web_socket - job_005: + job_007: name: "analyze_and_format; linux; Dart dev; PKGS: pkgs/shelf, pkgs/shelf_packages_handler, pkgs/shelf_proxy, pkgs/shelf_router, pkgs/shelf_router_generator, pkgs/shelf_static, pkgs/shelf_test_handler, pkgs/shelf_web_socket; `dart format --output=none --set-exit-if-changed .`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:pkgs/shelf-pkgs/shelf_packages_handler-pkgs/shelf_proxy-pkgs/shelf_router-pkgs/shelf_router_generator-pkgs/shelf_static-pkgs/shelf_test_handler-pkgs/shelf_web_socket;commands:format" @@ -261,12 +303,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_pub_upgrade name: pkgs/shelf; dart pub upgrade run: dart pub upgrade @@ -339,27 +381,27 @@ jobs: run: "dart format --output=none --set-exit-if-changed ." if: "always() && steps.pkgs_shelf_web_socket_pub_upgrade.conclusion == 'success'" working-directory: pkgs/shelf_web_socket - job_006: - name: "unit_test; linux; Dart 3.3.0; PKGS: pkgs/shelf_packages_handler, pkgs/shelf_proxy, pkgs/shelf_router, pkgs/shelf_router_generator, pkgs/shelf_static, pkgs/shelf_test_handler, pkgs/shelf_web_socket; `dart test --test-randomize-ordering-seed=random`" + job_008: + name: "unit_test; linux; Dart 3.3.0; PKGS: pkgs/shelf_packages_handler, pkgs/shelf_proxy, pkgs/shelf_router, pkgs/shelf_static; `dart test --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:pkgs/shelf_packages_handler-pkgs/shelf_proxy-pkgs/shelf_router-pkgs/shelf_router_generator-pkgs/shelf_static-pkgs/shelf_test_handler-pkgs/shelf_web_socket;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:pkgs/shelf_packages_handler-pkgs/shelf_proxy-pkgs/shelf_router-pkgs/shelf_static;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:pkgs/shelf_packages_handler-pkgs/shelf_proxy-pkgs/shelf_router-pkgs/shelf_router_generator-pkgs/shelf_static-pkgs/shelf_test_handler-pkgs/shelf_web_socket + os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:pkgs/shelf_packages_handler-pkgs/shelf_proxy-pkgs/shelf_router-pkgs/shelf_static os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: "3.3.0" - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_packages_handler_pub_upgrade name: pkgs/shelf_packages_handler; dart pub upgrade run: dart pub upgrade @@ -387,15 +429,6 @@ jobs: run: "dart test --test-randomize-ordering-seed=random" if: "always() && steps.pkgs_shelf_router_pub_upgrade.conclusion == 'success'" working-directory: pkgs/shelf_router - - id: pkgs_shelf_router_generator_pub_upgrade - name: pkgs/shelf_router_generator; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: pkgs/shelf_router_generator - - name: "pkgs/shelf_router_generator; dart test --test-randomize-ordering-seed=random" - run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.pkgs_shelf_router_generator_pub_upgrade.conclusion == 'success'" - working-directory: pkgs/shelf_router_generator - id: pkgs_shelf_static_pub_upgrade name: pkgs/shelf_static; dart pub upgrade run: dart pub upgrade @@ -405,51 +438,111 @@ jobs: run: "dart test --test-randomize-ordering-seed=random" if: "always() && steps.pkgs_shelf_static_pub_upgrade.conclusion == 'success'" working-directory: pkgs/shelf_static - - id: pkgs_shelf_test_handler_pub_upgrade - name: pkgs/shelf_test_handler; dart pub upgrade + needs: + - job_001 + - job_002 + - job_003 + - job_004 + - job_005 + - job_006 + - job_007 + job_009: + name: "unit_test; linux; Dart 3.4.0; PKG: pkgs/shelf; `dart test --test-randomize-ordering-seed=random -p chrome`" + runs-on: ubuntu-latest + steps: + - name: Cache Pub hosted dependencies + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 + with: + path: "~/.pub-cache/hosted" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf;commands:test_1" + restore-keys: | + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted + os:ubuntu-latest + - name: Setup Dart SDK + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c + with: + sdk: "3.4.0" + - id: checkout + name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - id: pkgs_shelf_pub_upgrade + name: pkgs/shelf; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: pkgs/shelf_test_handler - - name: "pkgs/shelf_test_handler; dart test --test-randomize-ordering-seed=random" - run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.pkgs_shelf_test_handler_pub_upgrade.conclusion == 'success'" - working-directory: pkgs/shelf_test_handler - - id: pkgs_shelf_web_socket_pub_upgrade - name: pkgs/shelf_web_socket; dart pub upgrade + working-directory: pkgs/shelf + - name: "pkgs/shelf; dart test --test-randomize-ordering-seed=random -p chrome" + run: "dart test --test-randomize-ordering-seed=random -p chrome" + if: "always() && steps.pkgs_shelf_pub_upgrade.conclusion == 'success'" + working-directory: pkgs/shelf + needs: + - job_001 + - job_002 + - job_003 + - job_004 + - job_005 + - job_006 + - job_007 + job_010: + name: "unit_test; linux; Dart 3.4.0; PKG: pkgs/shelf; `dart test --test-randomize-ordering-seed=random`" + runs-on: ubuntu-latest + steps: + - name: Cache Pub hosted dependencies + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 + with: + path: "~/.pub-cache/hosted" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf;commands:test_0" + restore-keys: | + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted + os:ubuntu-latest + - name: Setup Dart SDK + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c + with: + sdk: "3.4.0" + - id: checkout + name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - id: pkgs_shelf_pub_upgrade + name: pkgs/shelf; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: pkgs/shelf_web_socket - - name: "pkgs/shelf_web_socket; dart test --test-randomize-ordering-seed=random" + working-directory: pkgs/shelf + - name: "pkgs/shelf; dart test --test-randomize-ordering-seed=random" run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.pkgs_shelf_web_socket_pub_upgrade.conclusion == 'success'" - working-directory: pkgs/shelf_web_socket + if: "always() && steps.pkgs_shelf_pub_upgrade.conclusion == 'success'" + working-directory: pkgs/shelf needs: - job_001 - job_002 - job_003 - job_004 - job_005 - job_007: - name: "unit_test; linux; Dart 3.3.0; PKG: pkgs/shelf_test_handler; `dart test --test-randomize-ordering-seed=random -p chrome`" + - job_006 + - job_007 + job_011: + name: "unit_test; linux; Dart 3.5.0; PKG: pkgs/shelf_test_handler; `dart test --test-randomize-ordering-seed=random -p chrome`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:pkgs/shelf_test_handler;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/shelf_test_handler;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0;packages:pkgs/shelf_test_handler - os:ubuntu-latest;pub-cache-hosted;sdk:3.3.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/shelf_test_handler + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: - sdk: "3.3.0" + sdk: "3.5.0" - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_test_handler_pub_upgrade name: pkgs/shelf_test_handler; dart pub upgrade run: dart pub upgrade @@ -465,84 +558,99 @@ jobs: - job_003 - job_004 - job_005 - job_008: - name: "unit_test; linux; Dart 3.4.0; PKG: pkgs/shelf; `dart test --test-randomize-ordering-seed=random -p chrome`" + - job_006 + - job_007 + job_012: + name: "unit_test; linux; Dart 3.5.0; PKGS: pkgs/shelf_test_handler, pkgs/shelf_web_socket; `dart test --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/shelf_test_handler-pkgs/shelf_web_socket;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/shelf_test_handler-pkgs/shelf_web_socket + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: - sdk: "3.4.0" + sdk: "3.5.0" - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - - id: pkgs_shelf_pub_upgrade - name: pkgs/shelf; dart pub upgrade + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - id: pkgs_shelf_test_handler_pub_upgrade + name: pkgs/shelf_test_handler; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: pkgs/shelf - - name: "pkgs/shelf; dart test --test-randomize-ordering-seed=random -p chrome" - run: "dart test --test-randomize-ordering-seed=random -p chrome" - if: "always() && steps.pkgs_shelf_pub_upgrade.conclusion == 'success'" - working-directory: pkgs/shelf + working-directory: pkgs/shelf_test_handler + - name: "pkgs/shelf_test_handler; dart test --test-randomize-ordering-seed=random" + run: "dart test --test-randomize-ordering-seed=random" + if: "always() && steps.pkgs_shelf_test_handler_pub_upgrade.conclusion == 'success'" + working-directory: pkgs/shelf_test_handler + - id: pkgs_shelf_web_socket_pub_upgrade + name: pkgs/shelf_web_socket; dart pub upgrade + run: dart pub upgrade + if: "always() && steps.checkout.conclusion == 'success'" + working-directory: pkgs/shelf_web_socket + - name: "pkgs/shelf_web_socket; dart test --test-randomize-ordering-seed=random" + run: "dart test --test-randomize-ordering-seed=random" + if: "always() && steps.pkgs_shelf_web_socket_pub_upgrade.conclusion == 'success'" + working-directory: pkgs/shelf_web_socket needs: - job_001 - job_002 - job_003 - job_004 - job_005 - job_009: - name: "unit_test; linux; Dart 3.4.0; PKG: pkgs/shelf; `dart test --test-randomize-ordering-seed=random`" + - job_006 + - job_007 + job_013: + name: "unit_test; linux; Dart 3.9.0; PKG: pkgs/shelf_router_generator; `dart test --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.9.0;packages:pkgs/shelf_router_generator;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:pkgs/shelf - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.9.0;packages:pkgs/shelf_router_generator + os:ubuntu-latest;pub-cache-hosted;sdk:3.9.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: - sdk: "3.4.0" + sdk: "3.9.0" - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - - id: pkgs_shelf_pub_upgrade - name: pkgs/shelf; dart pub upgrade + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - id: pkgs_shelf_router_generator_pub_upgrade + name: pkgs/shelf_router_generator; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: pkgs/shelf - - name: "pkgs/shelf; dart test --test-randomize-ordering-seed=random" + working-directory: pkgs/shelf_router_generator + - name: "pkgs/shelf_router_generator; dart test --test-randomize-ordering-seed=random" run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.pkgs_shelf_pub_upgrade.conclusion == 'success'" - working-directory: pkgs/shelf + if: "always() && steps.pkgs_shelf_router_generator_pub_upgrade.conclusion == 'success'" + working-directory: pkgs/shelf_router_generator needs: - job_001 - job_002 - job_003 - job_004 - job_005 - job_010: + - job_006 + - job_007 + job_014: name: "unit_test; linux; Dart dev; PKGS: pkgs/shelf, pkgs/shelf_test_handler; `dart test --test-randomize-ordering-seed=random -p chrome -c dart2wasm`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:pkgs/shelf-pkgs/shelf_test_handler;commands:test_2" @@ -552,12 +660,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_pub_upgrade name: pkgs/shelf; dart pub upgrade run: dart pub upgrade @@ -582,12 +690,14 @@ jobs: - job_003 - job_004 - job_005 - job_011: + - job_006 + - job_007 + job_015: name: "unit_test; linux; Dart dev; PKGS: pkgs/shelf, pkgs/shelf_test_handler; `dart test --test-randomize-ordering-seed=random -p chrome`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:pkgs/shelf-pkgs/shelf_test_handler;commands:test_1" @@ -597,12 +707,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_pub_upgrade name: pkgs/shelf; dart pub upgrade run: dart pub upgrade @@ -627,12 +737,14 @@ jobs: - job_003 - job_004 - job_005 - job_012: + - job_006 + - job_007 + job_016: name: "unit_test; linux; Dart dev; PKGS: pkgs/shelf, pkgs/shelf_packages_handler, pkgs/shelf_proxy, pkgs/shelf_router, pkgs/shelf_router_generator, pkgs/shelf_static, pkgs/shelf_test_handler, pkgs/shelf_web_socket; `dart test --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:pkgs/shelf-pkgs/shelf_packages_handler-pkgs/shelf_proxy-pkgs/shelf_router-pkgs/shelf_router_generator-pkgs/shelf_static-pkgs/shelf_test_handler-pkgs/shelf_web_socket;commands:test_0" @@ -642,12 +754,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_pub_upgrade name: pkgs/shelf; dart pub upgrade run: dart pub upgrade @@ -726,12 +838,14 @@ jobs: - job_003 - job_004 - job_005 - job_013: + - job_006 + - job_007 + job_017: name: "unit_test; linux; Dart dev; PKG: pkgs/shelf_router_generator; `dart test --run-skipped -t presubmit-only`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:pkgs/shelf_router_generator;commands:test_3" @@ -741,12 +855,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_router_generator_pub_upgrade name: pkgs/shelf_router_generator; dart pub upgrade run: dart pub upgrade @@ -762,17 +876,19 @@ jobs: - job_003 - job_004 - job_005 - job_014: - name: "unit_test; windows; Dart 3.3.0; PKGS: pkgs/shelf_packages_handler, pkgs/shelf_static, pkgs/shelf_test_handler, pkgs/shelf_web_socket; `dart test --test-randomize-ordering-seed=random`" + - job_006 + - job_007 + job_018: + name: "unit_test; windows; Dart 3.3.0; PKGS: pkgs/shelf_packages_handler, pkgs/shelf_static; `dart test --test-randomize-ordering-seed=random`" runs-on: windows-latest steps: - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: "3.3.0" - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_packages_handler_pub_upgrade name: pkgs/shelf_packages_handler; dart pub upgrade run: dart pub upgrade @@ -791,41 +907,53 @@ jobs: run: "dart test --test-randomize-ordering-seed=random" if: "always() && steps.pkgs_shelf_static_pub_upgrade.conclusion == 'success'" working-directory: pkgs/shelf_static - - id: pkgs_shelf_test_handler_pub_upgrade - name: pkgs/shelf_test_handler; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: pkgs/shelf_test_handler - - name: "pkgs/shelf_test_handler; dart test --test-randomize-ordering-seed=random" - run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.pkgs_shelf_test_handler_pub_upgrade.conclusion == 'success'" - working-directory: pkgs/shelf_test_handler - - id: pkgs_shelf_web_socket_pub_upgrade - name: pkgs/shelf_web_socket; dart pub upgrade + needs: + - job_001 + - job_002 + - job_003 + - job_004 + - job_005 + - job_006 + - job_007 + job_019: + name: "unit_test; windows; Dart 3.4.0; PKG: pkgs/shelf; `dart test --test-randomize-ordering-seed=random -p chrome`" + runs-on: windows-latest + steps: + - name: Setup Dart SDK + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c + with: + sdk: "3.4.0" + - id: checkout + name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - id: pkgs_shelf_pub_upgrade + name: pkgs/shelf; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: pkgs/shelf_web_socket - - name: "pkgs/shelf_web_socket; dart test --test-randomize-ordering-seed=random" - run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.pkgs_shelf_web_socket_pub_upgrade.conclusion == 'success'" - working-directory: pkgs/shelf_web_socket + working-directory: pkgs/shelf + - name: "pkgs/shelf; dart test --test-randomize-ordering-seed=random -p chrome" + run: "dart test --test-randomize-ordering-seed=random -p chrome" + if: "always() && steps.pkgs_shelf_pub_upgrade.conclusion == 'success'" + working-directory: pkgs/shelf needs: - job_001 - job_002 - job_003 - job_004 - job_005 - job_015: - name: "unit_test; windows; Dart 3.3.0; PKG: pkgs/shelf_test_handler; `dart test --test-randomize-ordering-seed=random -p chrome`" + - job_006 + - job_007 + job_020: + name: "unit_test; windows; Dart 3.5.0; PKG: pkgs/shelf_test_handler; `dart test --test-randomize-ordering-seed=random -p chrome`" runs-on: windows-latest steps: - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: - sdk: "3.3.0" + sdk: "3.5.0" - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_test_handler_pub_upgrade name: pkgs/shelf_test_handler; dart pub upgrade run: dart pub upgrade @@ -841,43 +969,56 @@ jobs: - job_003 - job_004 - job_005 - job_016: - name: "unit_test; windows; Dart 3.4.0; PKG: pkgs/shelf; `dart test --test-randomize-ordering-seed=random -p chrome`" + - job_006 + - job_007 + job_021: + name: "unit_test; windows; Dart 3.5.0; PKGS: pkgs/shelf_test_handler, pkgs/shelf_web_socket; `dart test --test-randomize-ordering-seed=random`" runs-on: windows-latest steps: - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: - sdk: "3.4.0" + sdk: "3.5.0" - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - - id: pkgs_shelf_pub_upgrade - name: pkgs/shelf; dart pub upgrade + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + - id: pkgs_shelf_test_handler_pub_upgrade + name: pkgs/shelf_test_handler; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: pkgs/shelf - - name: "pkgs/shelf; dart test --test-randomize-ordering-seed=random -p chrome" - run: "dart test --test-randomize-ordering-seed=random -p chrome" - if: "always() && steps.pkgs_shelf_pub_upgrade.conclusion == 'success'" - working-directory: pkgs/shelf + working-directory: pkgs/shelf_test_handler + - name: "pkgs/shelf_test_handler; dart test --test-randomize-ordering-seed=random" + run: "dart test --test-randomize-ordering-seed=random" + if: "always() && steps.pkgs_shelf_test_handler_pub_upgrade.conclusion == 'success'" + working-directory: pkgs/shelf_test_handler + - id: pkgs_shelf_web_socket_pub_upgrade + name: pkgs/shelf_web_socket; dart pub upgrade + run: dart pub upgrade + if: "always() && steps.checkout.conclusion == 'success'" + working-directory: pkgs/shelf_web_socket + - name: "pkgs/shelf_web_socket; dart test --test-randomize-ordering-seed=random" + run: "dart test --test-randomize-ordering-seed=random" + if: "always() && steps.pkgs_shelf_web_socket_pub_upgrade.conclusion == 'success'" + working-directory: pkgs/shelf_web_socket needs: - job_001 - job_002 - job_003 - job_004 - job_005 - job_017: + - job_006 + - job_007 + job_022: name: "unit_test; windows; Dart dev; PKGS: pkgs/shelf, pkgs/shelf_test_handler; `dart test --test-randomize-ordering-seed=random -p chrome`" runs-on: windows-latest steps: - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_pub_upgrade name: pkgs/shelf; dart pub upgrade run: dart pub upgrade @@ -902,17 +1043,19 @@ jobs: - job_003 - job_004 - job_005 - job_018: + - job_006 + - job_007 + job_023: name: "unit_test; windows; Dart dev; PKGS: pkgs/shelf_packages_handler, pkgs/shelf_static, pkgs/shelf_test_handler, pkgs/shelf_web_socket; `dart test --test-randomize-ordering-seed=random`" runs-on: windows-latest steps: - name: Setup Dart SDK - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - id: pkgs_shelf_packages_handler_pub_upgrade name: pkgs/shelf_packages_handler; dart pub upgrade run: dart pub upgrade @@ -955,3 +1098,5 @@ jobs: - job_003 - job_004 - job_005 + - job_006 + - job_007 diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml index 1a6f2ecd..a8dbc6be 100644 --- a/.github/workflows/no-response.yml +++ b/.github/workflows/no-response.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'dart-lang' }} steps: - - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e + - uses: actions/stale@3a9db7e6a41a89f618792c92c0e97cc736e1b13f with: days-before-stale: -1 days-before-close: 14 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index bf40d5f4..62b46d13 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -13,3 +13,6 @@ jobs: publish: if: ${{ github.repository_owner == 'dart-lang' }} uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main + permissions: + id-token: write + pull-requests: write diff --git a/.github/workflows/pull_request_label.yml b/.github/workflows/pull_request_label.yml index 54e3df53..3115ed45 100644 --- a/.github/workflows/pull_request_label.yml +++ b/.github/workflows/pull_request_label.yml @@ -16,7 +16,7 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 + - uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b with: repo-token: "${{ secrets.GITHUB_TOKEN }}" sync-labels: true diff --git a/README.md b/README.md index 617e6e98..1a42afb3 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,25 @@ See the [package:shelf readme](pkgs/shelf/) for more information. ## Packages -| Package | Description | Version | -| --- | --- | --- | -| [shelf](pkgs/shelf/) | A model for web server middleware that encourages composition and easy reuse. | [![pub package](https://img.shields.io/pub/v/shelf.svg)](https://pub.dev/packages/shelf) | -| [shelf_packages_handler](pkgs/shelf_packages_handler/) | A shelf handler for serving a `packages/` directory. | [![pub package](https://img.shields.io/pub/v/shelf_packages_handler.svg)](https://pub.dev/packages/shelf_packages_handler) | -| [shelf_proxy](pkgs/shelf_proxy/) | A shelf handler for proxying HTTP requests to another server. | [![pub package](https://img.shields.io/pub/v/shelf_proxy.svg)](https://pub.dev/packages/shelf_proxy) | -| [shelf_router](pkgs/shelf_router/) | A convenient request router for the shelf web-framework, with support for URL-parameters, nested routers and routers generated from source annotations. | [![pub package](https://img.shields.io/pub/v/shelf_router.svg)](https://pub.dev/packages/shelf_router) | -| [shelf_router_generator](pkgs/shelf_router_generator/) | A package:build-compatible builder for generating request routers for the shelf web-framework based on source annotations. | [![pub package](https://img.shields.io/pub/v/shelf_router_generator.svg)](https://pub.dev/packages/shelf_router_generator) | -| [shelf_static](pkgs/shelf_static/) | Static file server support for the shelf package and ecosystem. | [![pub package](https://img.shields.io/pub/v/shelf_static.svg)](https://pub.dev/packages/shelf_static) | -| [shelf_test_handler](pkgs/shelf_test_handler/) | A Shelf handler that makes it easy to test HTTP interactions. | [![pub package](https://img.shields.io/pub/v/shelf_test_handler.svg)](https://pub.dev/packages/shelf_test_handler) | -| [shelf_web_socket](pkgs/shelf_web_socket/) | A shelf handler that wires up a listener for every connection. | [![pub package](https://img.shields.io/pub/v/shelf_web_socket.svg)](https://pub.dev/packages/shelf_web_socket) | +| Package | Description | Issues | Version | +| --- | --- | --- | --- | +| [shelf](pkgs/shelf/) | A model for web server middleware that encourages composition and easy reuse. | [![issues](https://img.shields.io/badge/shelf-4774bc)][shelf_issues] | [![pub package](https://img.shields.io/pub/v/shelf.svg)](https://pub.dev/packages/shelf) | +| [shelf_packages_handler](pkgs/shelf_packages_handler/) | A shelf handler for serving a `packages/` directory. | [![issues](https://img.shields.io/badge/shelf__packages__handler-4774bc)][shelf_packages_handler_issues] | [![pub package](https://img.shields.io/pub/v/shelf_packages_handler.svg)](https://pub.dev/packages/shelf_packages_handler) | +| [shelf_proxy](pkgs/shelf_proxy/) | A shelf handler for proxying HTTP requests to another server. | [![issues](https://img.shields.io/badge/shelf__proxy-4774bc)][shelf_proxy_issues] | [![pub package](https://img.shields.io/pub/v/shelf_proxy.svg)](https://pub.dev/packages/shelf_proxy) | +| [shelf_router](pkgs/shelf_router/) | A convenient request router for the shelf web-framework, with support for URL-parameters, nested routers and routers generated from source annotations. | [![issues](https://img.shields.io/badge/shelf__router-4774bc)][shelf_router_issues] | [![pub package](https://img.shields.io/pub/v/shelf_router.svg)](https://pub.dev/packages/shelf_router) | +| [shelf_router_generator](pkgs/shelf_router_generator/) | A package:build-compatible builder for generating request routers for the shelf web-framework based on source annotations. | [![issues](https://img.shields.io/badge/shelf__router__generator-4774bc)][shelf_router_generator_issues] | [![pub package](https://img.shields.io/pub/v/shelf_router_generator.svg)](https://pub.dev/packages/shelf_router_generator) | +| [shelf_static](pkgs/shelf_static/) | Static file server support for the shelf package and ecosystem. | [![issues](https://img.shields.io/badge/shelf__static-4774bc)][shelf_static_issues] | [![pub package](https://img.shields.io/pub/v/shelf_static.svg)](https://pub.dev/packages/shelf_static) | +| [shelf_test_handler](pkgs/shelf_test_handler/) | A Shelf handler that makes it easy to test HTTP interactions. | [![issues](https://img.shields.io/badge/shelf__test__handler-4774bc)][shelf_test_handler_issues] | [![pub package](https://img.shields.io/pub/v/shelf_test_handler.svg)](https://pub.dev/packages/shelf_test_handler) | +| [shelf_web_socket](pkgs/shelf_web_socket/) | A shelf handler that wires up a listener for every connection. | [![issues](https://img.shields.io/badge/shelf__web__socket-4774bc)][shelf_web_socket_issues] | [![pub package](https://img.shields.io/pub/v/shelf_web_socket.svg)](https://pub.dev/packages/shelf_web_socket) | + +[shelf_issues]: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf +[shelf_packages_handler_issues]: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_packages_handler +[shelf_proxy_issues]: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_proxy +[shelf_router_issues]: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_router +[shelf_router_generator_issues]: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_router_generator +[shelf_static_issues]: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_static +[shelf_test_handler_issues]: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_test_handler +[shelf_web_socket_issues]: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_web_socket ## Publishing automation diff --git a/pkgs/shelf/CHANGELOG.md b/pkgs/shelf/CHANGELOG.md index daff6c4f..c08105fb 100644 --- a/pkgs/shelf/CHANGELOG.md +++ b/pkgs/shelf/CHANGELOG.md @@ -280,7 +280,7 @@ ## 0.6.1+2 -* `logRequests` outputs a better message a request has a query string. +* `logRequests` outputs a better message if a request has a query string. ## 0.6.1+1 diff --git a/analysis_options.yaml b/pkgs/shelf/analysis_options.yaml similarity index 75% rename from analysis_options.yaml rename to pkgs/shelf/analysis_options.yaml index 11122447..75fcb402 100644 --- a/analysis_options.yaml +++ b/pkgs/shelf/analysis_options.yaml @@ -1,13 +1,10 @@ # https://dart.dev/guides/language/analysis-options + include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: - strict-casts: true - strict-inference: true strict-raw-types: true - errors: - comment_references: ignore # too many false positives linter: rules: @@ -17,5 +14,4 @@ linter: - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString - - package_api_docs - unnecessary_await_in_return diff --git a/pkgs/shelf/lib/src/body.dart b/pkgs/shelf/lib/src/body.dart index 57f9fa4e..c80cc483 100644 --- a/pkgs/shelf/lib/src/body.dart +++ b/pkgs/shelf/lib/src/body.dart @@ -5,6 +5,8 @@ import 'dart:async'; import 'dart:convert'; +import 'message.dart'; + /// The body of a request or response. /// /// This tracks whether the body has been read. It's separate from [Message] diff --git a/pkgs/shelf/lib/src/hijack_exception.dart b/pkgs/shelf/lib/src/hijack_exception.dart index 4a3d84e4..41156495 100644 --- a/pkgs/shelf/lib/src/hijack_exception.dart +++ b/pkgs/shelf/lib/src/hijack_exception.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'request.dart'; + /// An exception used to indicate that a request has been hijacked. /// /// This shouldn't be captured by any code other than the Shelf adapter that diff --git a/pkgs/shelf/lib/src/message.dart b/pkgs/shelf/lib/src/message.dart index 8b28bb8e..c270d187 100644 --- a/pkgs/shelf/lib/src/message.dart +++ b/pkgs/shelf/lib/src/message.dart @@ -10,6 +10,9 @@ import 'package:http_parser/http_parser.dart'; import 'body.dart'; import 'headers.dart'; +import 'middleware/logger.dart'; +import 'request.dart'; +import 'response.dart'; import 'shelf_unmodifiable_map.dart'; import 'util.dart'; @@ -171,7 +174,7 @@ abstract class Message { {Map headers, Map context, Object? body}); } -/// Adds information about [encoding] to [headers]. +/// Adds information about encoding to [headers]. /// /// Returns a new map without modifying [headers]. Map> _adjustHeaders( diff --git a/pkgs/shelf/lib/src/middleware_extensions.dart b/pkgs/shelf/lib/src/middleware_extensions.dart index 8c707dfe..521710ae 100644 --- a/pkgs/shelf/lib/src/middleware_extensions.dart +++ b/pkgs/shelf/lib/src/middleware_extensions.dart @@ -1,5 +1,6 @@ import 'handler.dart'; import 'middleware.dart'; +import 'pipeline.dart'; /// Extensions on [Middleware] to aid in composing [Middleware] and [Handler]s. /// diff --git a/pkgs/shelf/lib/src/pipeline.dart b/pkgs/shelf/lib/src/pipeline.dart index d931a309..1d079350 100644 --- a/pkgs/shelf/lib/src/pipeline.dart +++ b/pkgs/shelf/lib/src/pipeline.dart @@ -4,6 +4,7 @@ import 'handler.dart'; import 'middleware.dart'; +import 'request.dart'; /// A helper that makes it easy to compose a set of [Middleware] and a /// [Handler]. diff --git a/pkgs/shelf/lib/src/response.dart b/pkgs/shelf/lib/src/response.dart index 1938a631..2cd40e48 100644 --- a/pkgs/shelf/lib/src/response.dart +++ b/pkgs/shelf/lib/src/response.dart @@ -6,6 +6,7 @@ import 'dart:convert'; import 'package:http_parser/http_parser.dart'; +import 'handler.dart'; import 'message.dart'; import 'util.dart'; diff --git a/pkgs/shelf/lib/src/server.dart b/pkgs/shelf/lib/src/server.dart index 8a20f0e2..72564e7e 100644 --- a/pkgs/shelf/lib/src/server.dart +++ b/pkgs/shelf/lib/src/server.dart @@ -20,8 +20,8 @@ import 'handler.dart'; /// code to a single server implementation. /// /// There are two built-in implementations of this interface. You can create a -/// server backed by `dart:io` using [IOServer], or you can create a server -/// that's backed by a normal [Handler] using [ServerHandler]. +/// server backed by `dart:io` using `IOServer`, or you can create a server +/// that's backed by a normal [Handler] using `ServerHandler`. /// /// Implementations of this interface are responsible for ensuring that the /// members work as documented. diff --git a/pkgs/shelf/pubspec.yaml b/pkgs/shelf/pubspec.yaml index ead1b55f..3dd9347c 100644 --- a/pkgs/shelf/pubspec.yaml +++ b/pkgs/shelf/pubspec.yaml @@ -3,6 +3,7 @@ version: 1.4.3-wip description: > A model for web server middleware that encourages composition and easy reuse. repository: https://github.com/dart-lang/shelf/tree/master/pkgs/shelf +issue_tracker: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf topics: - server diff --git a/pkgs/shelf_packages_handler/analysis_options.yaml b/pkgs/shelf_packages_handler/analysis_options.yaml new file mode 100644 index 00000000..d978f811 --- /dev/null +++ b/pkgs/shelf_packages_handler/analysis_options.yaml @@ -0,0 +1 @@ +include: package:dart_flutter_team_lints/analysis_options.yaml diff --git a/pkgs/shelf_packages_handler/pubspec.yaml b/pkgs/shelf_packages_handler/pubspec.yaml index bd119031..0d674ff2 100644 --- a/pkgs/shelf_packages_handler/pubspec.yaml +++ b/pkgs/shelf_packages_handler/pubspec.yaml @@ -2,6 +2,7 @@ name: shelf_packages_handler version: 3.0.3-wip description: A shelf handler for serving a `packages/` directory. repository: https://github.com/dart-lang/shelf/tree/master/pkgs/shelf_packages_handler +issue_tracker: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_packages_handler topics: - server diff --git a/pkgs/shelf_proxy/analysis_options.yaml b/pkgs/shelf_proxy/analysis_options.yaml new file mode 100644 index 00000000..d978f811 --- /dev/null +++ b/pkgs/shelf_proxy/analysis_options.yaml @@ -0,0 +1 @@ +include: package:dart_flutter_team_lints/analysis_options.yaml diff --git a/pkgs/shelf_proxy/pubspec.yaml b/pkgs/shelf_proxy/pubspec.yaml index 1ac4060d..2e4125f4 100644 --- a/pkgs/shelf_proxy/pubspec.yaml +++ b/pkgs/shelf_proxy/pubspec.yaml @@ -2,6 +2,7 @@ name: shelf_proxy version: 1.0.5-wip description: A shelf handler for proxying HTTP requests to another server. repository: https://github.com/dart-lang/shelf/tree/master/pkgs/shelf_proxy +issue_tracker: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_proxy topics: - server diff --git a/pkgs/shelf_router/analysis_options.yaml b/pkgs/shelf_router/analysis_options.yaml new file mode 100644 index 00000000..d978f811 --- /dev/null +++ b/pkgs/shelf_router/analysis_options.yaml @@ -0,0 +1 @@ +include: package:dart_flutter_team_lints/analysis_options.yaml diff --git a/pkgs/shelf_router/pubspec.yaml b/pkgs/shelf_router/pubspec.yaml index 9be8a34f..08a9ba43 100644 --- a/pkgs/shelf_router/pubspec.yaml +++ b/pkgs/shelf_router/pubspec.yaml @@ -4,6 +4,7 @@ description: > A convenient request router for the shelf web-framework, with support for URL-parameters, nested routers and routers generated from source annotations. repository: https://github.com/dart-lang/shelf/tree/master/pkgs/shelf_router +issue_tracker: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_router topics: - server diff --git a/pkgs/shelf_router_generator/CHANGELOG.md b/pkgs/shelf_router_generator/CHANGELOG.md index eeac453c..b1089aa5 100644 --- a/pkgs/shelf_router_generator/CHANGELOG.md +++ b/pkgs/shelf_router_generator/CHANGELOG.md @@ -1,5 +1,22 @@ -## 1.1.1-wip +## 1.1.3-wip +* Require `analyzer: ^8.1.1` +* Require `build: ^4.0.0` +* Require `build_config: ^1.2.0` +* Require `source_gen: ^4.0.1` +* Require `sdk: ^3.9.0` + +## 1.1.2 + +* Require `analyzer: '>=7.4.0 <9.0.0'` +* Require `build: ^3.0.0` +* Require `build_config: ^1.1.0` +* Require `source_gen: ^3.0.0` +* Require `sdk: ^3.7.0` + +## 1.1.1 + +* Support the latest `package:analyzer` and `package:source_gen` * Require `sdk: ^3.3.0` ## 1.1.0 diff --git a/pkgs/shelf_router_generator/analysis_options.yaml b/pkgs/shelf_router_generator/analysis_options.yaml new file mode 100644 index 00000000..d978f811 --- /dev/null +++ b/pkgs/shelf_router_generator/analysis_options.yaml @@ -0,0 +1 @@ +include: package:dart_flutter_team_lints/analysis_options.yaml diff --git a/pkgs/shelf_router_generator/example/main.g.dart b/pkgs/shelf_router_generator/example/main.g.dart index 869d8ecb..bb5347d1 100644 --- a/pkgs/shelf_router_generator/example/main.g.dart +++ b/pkgs/shelf_router_generator/example/main.g.dart @@ -8,47 +8,18 @@ part of 'main.dart'; Router _$ServiceRouter(Service service) { final router = Router(); - router.add( - 'GET', - r'/say-hi/', - service._hi, - ); - router.add( - 'GET', - r'/user/', - service._user, - ); - router.add( - 'GET', - r'/wave', - service._wave, - ); - router.mount( - r'/api', - service._api.call, - ); - router.all( - r'/', - service._notFound, - ); + router.add('GET', r'/say-hi/', service._hi); + router.add('GET', r'/user/', service._user); + router.add('GET', r'/wave', service._wave); + router.mount(r'/api', service._api.call); + router.all(r'/', service._notFound); return router; } Router _$ApiRouter(Api service) { final router = Router(); - router.add( - 'GET', - r'/messages', - service._messages, - ); - router.add( - 'GET', - r'/messages/', - service._messages, - ); - router.all( - r'/', - service._notFound, - ); + router.add('GET', r'/messages', service._messages); + router.add('GET', r'/messages/', service._messages); + router.all(r'/', service._notFound); return router; } diff --git a/pkgs/shelf_router_generator/lib/builder.dart b/pkgs/shelf_router_generator/lib/builder.dart index 5fe106a2..b790aed6 100644 --- a/pkgs/shelf_router_generator/lib/builder.dart +++ b/pkgs/shelf_router_generator/lib/builder.dart @@ -29,7 +29,5 @@ import 'src/shelf_router_generator.dart'; /// A [Builder] that generates a `_$Router( service)` /// function for each class `` containing a member annotated with /// [shelf_router.Route]. -Builder shelfRouter(BuilderOptions _) => SharedPartBuilder( - [ShelfRouterGenerator()], - 'shelf_router', - ); +Builder shelfRouter(BuilderOptions _) => + SharedPartBuilder([ShelfRouterGenerator()], 'shelf_router'); diff --git a/pkgs/shelf_router_generator/lib/src/shelf_router_generator.dart b/pkgs/shelf_router_generator/lib/src/shelf_router_generator.dart index 0ccf70d2..b3c148df 100644 --- a/pkgs/shelf_router_generator/lib/src/shelf_router_generator.dart +++ b/pkgs/shelf_router_generator/lib/src/shelf_router_generator.dart @@ -12,115 +12,142 @@ // See the License for the specific language governing permissions and // limitations under the License. +// While we support the older pkg:analyzer version +// ignore_for_file: deprecated_member_use + import 'dart:async' show Future; -import 'package:analyzer/dart/element/element.dart' - show ClassElement, ElementKind, ExecutableElement; +import 'package:analyzer/dart/element/element2.dart' + show ClassElement2, ElementKind, ExecutableElement2; import 'package:analyzer/dart/element/type.dart' show ParameterizedType; import 'package:build/build.dart' show BuildStep, log; import 'package:code_builder/code_builder.dart' as code; import 'package:http_methods/http_methods.dart' show isHttpMethod; import 'package:shelf/shelf.dart' as shelf; import 'package:shelf_router/shelf_router.dart' as shelf_router; -// ignore: implementation_imports -import 'package:shelf_router/src/router_entry.dart' show RouterEntry; +import 'package:shelf_router/src/router_entry.dart' // ignore: implementation_imports + show RouterEntry; import 'package:source_gen/source_gen.dart' as g; // Type checkers that we need later -const _routeType = g.TypeChecker.fromRuntime(shelf_router.Route); -const _routerType = g.TypeChecker.fromRuntime(shelf_router.Router); -const _responseType = g.TypeChecker.fromRuntime(shelf.Response); -const _requestType = g.TypeChecker.fromRuntime(shelf.Request); -const _stringType = g.TypeChecker.fromRuntime(String); +const _routeType = g.TypeChecker.typeNamed( + shelf_router.Route, + inPackage: 'shelf_router', +); +const _routerType = g.TypeChecker.typeNamed( + shelf_router.Router, + inPackage: 'shelf_router', +); +const _responseType = g.TypeChecker.typeNamed( + shelf.Response, + inPackage: 'shelf', +); +const _requestType = g.TypeChecker.typeNamed(shelf.Request, inPackage: 'shelf'); +const _stringType = g.TypeChecker.typeNamed(String, inSdk: true); /// A representation of a handler that was annotated with [shelf_router.Route]. class _Handler { final String verb, route; - final ExecutableElement element; + final ExecutableElement2 element; _Handler(this.verb, this.route, this.element); } /// Find members of a class annotated with [shelf_router.Route]. -List getAnnotatedElementsOrderBySourceOffset( - ClassElement cls) => - [ - ...cls.methods.where(_routeType.hasAnnotationOfExact), - ...cls.accessors.where(_routeType.hasAnnotationOfExact) - ]..sort((a, b) => (a.nameOffset).compareTo(b.nameOffset)); +List getAnnotatedElementsOrderBySourceOffset( + ClassElement2 cls, +) => + [ + ...cls.methods2.where(_routeType.hasAnnotationOfExact), + ...cls.getters2.where(_routeType.hasAnnotationOfExact), + ]..sort( + (a, b) => (a.firstFragment.nameOffset2!).compareTo( + b.firstFragment.nameOffset2!, + ), + ); /// Generate a `_$Router( service)` method that returns a /// [shelf_router.Router] configured based on annotated handlers. code.Method _buildRouterMethod({ - required ClassElement classElement, + required ClassElement2 classElement, required List<_Handler> handlers, -}) => - code.Method( +}) => code.Method( + (b) => b + ..name = '_\$${classElement.name3}Router' + ..requiredParameters.add( + code.Parameter( + (b) => b + ..name = 'service' + ..type = code.refer(classElement.name3!), + ), + ) + ..returns = code.refer('Router') + ..body = code.Block( (b) => b - ..name = '_\$${classElement.name}Router' - ..requiredParameters.add( - code.Parameter((b) => b - ..name = 'service' - ..type = code.refer(classElement.name)), + ..addExpression( + code + .declareFinal('router') + .assign(code.refer('Router').newInstance([])), ) - ..returns = code.refer('Router') - ..body = code.Block( - (b) => b - ..addExpression( - code - .declareFinal('router') - .assign(code.refer('Router').newInstance([])), - ) - ..statements.addAll(handlers.map((h) => _buildAddHandlerCode( - router: code.refer('router'), - service: code.refer('service'), - handler: h, - ))) - ..addExpression(code.refer('router').returned), - ), - ); + ..statements.addAll( + handlers.map( + (h) => _buildAddHandlerCode( + router: code.refer('router'), + service: code.refer('service'), + handler: h, + ), + ), + ) + ..addExpression(code.refer('router').returned), + ), +); /// Generate the code statement that adds [handler] from [service] to [router]. code.Code _buildAddHandlerCode({ required code.Reference router, required code.Reference service, required _Handler handler, -}) => - switch (handler.verb) { - r'$mount' => router.property('mount').call([ - code.literalString(handler.route, raw: true), - service.property(handler.element.name).property('call'), - ]).statement, - r'$all' => router.property('all').call([ - code.literalString(handler.route, raw: true), - service.property(handler.element.name), - ]).statement, - _ => router.property('add').call([ - code.literalString(handler.verb.toUpperCase()), - code.literalString(handler.route, raw: true), - service.property(handler.element.name), - ]).statement - }; +}) => switch (handler.verb) { + r'$mount' => router.property('mount').call([ + code.literalString(handler.route, raw: true), + service.property(handler.element.name3!).property('call'), + ]).statement, + r'$all' => router.property('all').call([ + code.literalString(handler.route, raw: true), + service.property(handler.element.name3!), + ]).statement, + _ => router.property('add').call([ + code.literalString(handler.verb.toUpperCase()), + code.literalString(handler.route, raw: true), + service.property(handler.element.name3!), + ]).statement, +}; class ShelfRouterGenerator extends g.Generator { @override Future generate(g.LibraryReader library, BuildStep buildStep) async { // Create a map from ClassElement to list of annotated elements sorted by // offset in source code, this is not type checked yet. - final classes = >{}; + final classes = >{}; for (final cls in library.classes) { final elements = getAnnotatedElementsOrderBySourceOffset(cls); if (elements.isEmpty) { continue; } - log.info('found shelf_router.Route annotations in ${cls.name}'); + log.info('found shelf_router.Route annotations in ${cls.name3}'); classes[cls] = elements - .map((e) => _routeType.annotationsOfExact(e).map((a) => _Handler( - a.getField('verb')!.toStringValue()!, - a.getField('route')!.toStringValue()!, - e, - ))) + .map( + (e) => _routeType + .annotationsOfExact(e) + .map( + (a) => _Handler( + a.getField('verb')!.toStringValue()!, + a.getField('route')!.toStringValue()!, + e, + ), + ), + ) .expand((i) => i) .toList(); } @@ -139,13 +166,12 @@ class ShelfRouterGenerator extends g.Generator { } // Build library and emit code with all generate methods. - final methods = classes.entries.map((e) => _buildRouterMethod( - classElement: e.key, - handlers: e.value, - )); - return code.Library((b) => b.body.addAll(methods)) - .accept(code.DartEmitter()) - .toString(); + final methods = classes.entries.map( + (e) => _buildRouterMethod(classElement: e.key, handlers: e.value), + ); + return code.Library( + (b) => b.body.addAll(methods), + ).accept(code.DartEmitter()).toString(); } } @@ -154,32 +180,36 @@ class ShelfRouterGenerator extends g.Generator { void _typeCheckHandler(_Handler h) { if (h.element.isStatic) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route annotation cannot be used on static members', - element: h.element); + 'The shelf_router.Route annotation cannot be used on static members', + element: h.element, + ); } // Check the verb, note that $all is a special value for handling all verbs. if (!isHttpMethod(h.verb) && h.verb != r'$all') { throw g.InvalidGenerationSourceError( - 'The verb "${h.verb}" used in shelf_router.Route annotation must be ' - 'a valid HTTP method', - element: h.element); + 'The verb "${h.verb}" used in shelf_router.Route annotation must be ' + 'a valid HTTP method', + element: h.element, + ); } // Check that this shouldn't have been annotated with Route.mount if (h.element.kind == ElementKind.GETTER) { throw g.InvalidGenerationSourceError( - 'Only the shelf_router.Route.mount annotation can only be used on a ' - 'getter, and only if it returns a shelf_router.Router', - element: h.element); + 'Only the shelf_router.Route.mount annotation can only be used on a ' + 'getter, and only if it returns a shelf_router.Router', + element: h.element, + ); } // Check that this is indeed a method if (h.element.kind != ElementKind.METHOD) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route annotation can only be used on request ' - 'handling methods', - element: h.element); + 'The shelf_router.Route annotation can only be used on request ' + 'handling methods', + element: h.element, + ); } // Check the route can parse @@ -188,60 +218,63 @@ void _typeCheckHandler(_Handler h) { params = RouterEntry(h.verb, h.route, () => null).params; // ignore: avoid_catching_errors } on ArgumentError catch (e) { - throw g.InvalidGenerationSourceError( - e.toString(), - element: h.element, - ); + throw g.InvalidGenerationSourceError(e.toString(), element: h.element); } // Ensure that the first parameter is shelf.Request - if (h.element.parameters.isEmpty) { + if (h.element.formalParameters.isEmpty) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route annotation can only be used on shelf request ' - 'handlers accept a shelf.Request parameter', - element: h.element); + 'The shelf_router.Route annotation can only be used on shelf request ' + 'handlers accept a shelf.Request parameter', + element: h.element, + ); } - for (final p in h.element.parameters) { + for (final p in h.element.formalParameters) { if (p.isOptional) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route annotation can only be used on shelf ' - 'request handlers accept a shelf.Request parameter and/or a ' - 'shelf.Request parameter and all string parameters in the route, ' - 'optional parameters are not permitted', - element: p); + 'The shelf_router.Route annotation can only be used on shelf ' + 'request handlers accept a shelf.Request parameter and/or a ' + 'shelf.Request parameter and all string parameters in the route, ' + 'optional parameters are not permitted', + element: p, + ); } } - if (!_requestType.isExactlyType(h.element.parameters.first.type)) { + if (!_requestType.isExactlyType(h.element.formalParameters.first.type)) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route annotation can only be used on shelf request ' - 'handlers accept a shelf.Request parameter as first parameter', - element: h.element); + 'The shelf_router.Route annotation can only be used on shelf request ' + 'handlers accept a shelf.Request parameter as first parameter', + element: h.element, + ); } - if (h.element.parameters.length > 1) { - if (h.element.parameters.length != params.length + 1) { + if (h.element.formalParameters.length > 1) { + if (h.element.formalParameters.length != params.length + 1) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route annotation can only be used on shelf ' - 'request handlers accept a shelf.Request parameter and/or a ' - 'shelf.Request parameter and all string parameters in the route', - element: h.element); + 'The shelf_router.Route annotation can only be used on shelf ' + 'request handlers accept a shelf.Request parameter and/or a ' + 'shelf.Request parameter and all string parameters in the route', + element: h.element, + ); } for (var i = 0; i < params.length; i++) { - final p = h.element.parameters[i + 1]; - if (p.name != params[i]) { + final p = h.element.formalParameters[i + 1]; + if (p.name3 != params[i]) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route annotation can only be used on shelf ' - 'request handlers accept a shelf.Request parameter and/or a ' - 'shelf.Request parameter and all string parameters in the route, ' - 'the "${p.name}" parameter should be named "${params[i]}"', - element: p); + 'The shelf_router.Route annotation can only be used on shelf ' + 'request handlers accept a shelf.Request parameter and/or a ' + 'shelf.Request parameter and all string parameters in the route, ' + 'the "${p.name3}" parameter should be named "${params[i]}"', + element: p, + ); } if (!_stringType.isExactlyType(p.type)) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route annotation can only be used on shelf ' - 'request handlers accept a shelf.Request parameter and/or a ' - 'shelf.Request parameter and all string parameters in the route, ' - 'the "${p.name}" parameter is not of type string', - element: p); + 'The shelf_router.Route annotation can only be used on shelf ' + 'request handlers accept a shelf.Request parameter and/or a ' + 'shelf.Request parameter and all string parameters in the route, ' + 'the "${p.name3}" parameter is not of type string', + element: p, + ); } } } @@ -254,10 +287,11 @@ void _typeCheckHandler(_Handler h) { } if (!_responseType.isAssignableFromType(returnType)) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route annotation can only be used on shelf request ' - 'handlers that return shelf.Response, Future or ' - 'FutureOr, and not "${h.element.returnType}"', - element: h.element); + 'The shelf_router.Route annotation can only be used on shelf request ' + 'handlers that return shelf.Response, Future or ' + 'FutureOr, and not "${h.element.returnType}"', + element: h.element, + ); } } @@ -266,36 +300,41 @@ void _typeCheckHandler(_Handler h) { void _typeCheckMount(_Handler h) { if (h.element.isStatic) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route annotation cannot be used on static members', - element: h.element); + 'The shelf_router.Route annotation cannot be used on static members', + element: h.element, + ); } // Check that this should have been annotated with Route.mount if (h.element.kind != ElementKind.GETTER) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route.mount annotation can only be used on a ' - 'getter that returns shelf_router.Router', - element: h.element); + 'The shelf_router.Route.mount annotation can only be used on a ' + 'getter that returns shelf_router.Router', + element: h.element, + ); } // Sanity checks for the prefix if (!h.route.startsWith('/')) { throw g.InvalidGenerationSourceError( - 'The prefix "${h.route}" in shelf_router.Route.mount(prefix) ' - 'annotation must begin with a slash', - element: h.element); + 'The prefix "${h.route}" in shelf_router.Route.mount(prefix) ' + 'annotation must begin with a slash', + element: h.element, + ); } if (h.route.contains('<')) { throw g.InvalidGenerationSourceError( - 'The prefix "${h.route}" in shelf_router.Route.mount(prefix) ' - 'annotation cannot contain <', - element: h.element); + 'The prefix "${h.route}" in shelf_router.Route.mount(prefix) ' + 'annotation cannot contain <', + element: h.element, + ); } if (!_routerType.isAssignableFromType(h.element.returnType)) { throw g.InvalidGenerationSourceError( - 'The shelf_router.Route.mount annotation can only be used on a ' - 'getter that returns shelf_router.Router', - element: h.element); + 'The shelf_router.Route.mount annotation can only be used on a ' + 'getter that returns shelf_router.Router', + element: h.element, + ); } } diff --git a/pkgs/shelf_router_generator/pubspec.yaml b/pkgs/shelf_router_generator/pubspec.yaml index 1dfc6832..2e28b510 100644 --- a/pkgs/shelf_router_generator/pubspec.yaml +++ b/pkgs/shelf_router_generator/pubspec.yaml @@ -1,30 +1,31 @@ name: shelf_router_generator -version: 1.1.1-wip +version: 1.1.3-wip description: > A package:build-compatible builder for generating request routers for the shelf web-framework based on source annotations. repository: https://github.com/dart-lang/shelf/tree/master/pkgs/shelf_router_generator +issue_tracker: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_router_generator topics: - server - shelf environment: - sdk: ^3.3.0 + sdk: ^3.9.0 dependencies: - analyzer: '>=4.6.0 <7.0.0' - build: ^2.0.0 - build_config: ^1.0.0 + analyzer: ^8.1.1 + build: ^4.0.0 + build_config: ^1.2.0 code_builder: ^4.2.0 - http_methods: ^1.0.0 + http_methods: ^1.1.0 shelf: ^1.1.0 shelf_router: ^1.1.0 - source_gen: ^1.0.0 + source_gen: ^4.0.1 dev_dependencies: - build_runner: ^2.0.0 + build_runner: ^2.7.2 build_verify: ^3.0.0 dart_flutter_team_lints: ^3.0.0 - http: '>=0.13.0 <2.0.0' - test: ^1.5.3 + http: ^1.0.0 + test: ^1.26.3 diff --git a/pkgs/shelf_router_generator/test/server/api.g.dart b/pkgs/shelf_router_generator/test/server/api.g.dart index 75e9a23c..b2dc9a96 100644 --- a/pkgs/shelf_router_generator/test/server/api.g.dart +++ b/pkgs/shelf_router_generator/test/server/api.g.dart @@ -8,20 +8,8 @@ part of 'api.dart'; Router _$ApiRouter(Api service) { final router = Router(); - router.add( - 'GET', - r'/time', - service._time, - ); - router.add( - 'GET', - r'/to-uppercase/', - service._toUpperCase, - ); - router.add( - 'GET', - r'/$string-escape', - service._stringEscapingWorks, - ); + router.add('GET', r'/time', service._time); + router.add('GET', r'/to-uppercase/', service._toUpperCase); + router.add('GET', r'/$string-escape', service._stringEscapingWorks); return router; } diff --git a/pkgs/shelf_router_generator/test/server/server.dart b/pkgs/shelf_router_generator/test/server/server.dart index ba55082a..70d911be 100644 --- a/pkgs/shelf_router_generator/test/server/server.dart +++ b/pkgs/shelf_router_generator/test/server/server.dart @@ -29,9 +29,5 @@ class Server { Future stop() => _server.close(); - Uri get uri => Uri( - scheme: 'http', - host: 'localhost', - port: _server.port, - ); + Uri get uri => Uri(scheme: 'http', host: 'localhost', port: _server.port); } diff --git a/pkgs/shelf_router_generator/test/server/service.g.dart b/pkgs/shelf_router_generator/test/server/service.g.dart index 07508c26..8140b76e 100644 --- a/pkgs/shelf_router_generator/test/server/service.g.dart +++ b/pkgs/shelf_router_generator/test/server/service.g.dart @@ -8,38 +8,12 @@ part of 'service.dart'; Router _$ServiceRouter(Service service) { final router = Router(); - router.add( - 'GET', - r'/say-hello', - service._sayHello, - ); - router.add( - 'GET', - r'/say-hello/', - service._sayHello, - ); - router.add( - 'GET', - r'/wave', - service._wave, - ); - router.add( - 'GET', - r'/greet/', - service._greet, - ); - router.add( - 'GET', - r'/hi/', - service._hi, - ); - router.mount( - r'/api/', - service._api.call, - ); - router.all( - r'/<_|.*>', - service._index, - ); + router.add('GET', r'/say-hello', service._sayHello); + router.add('GET', r'/say-hello/', service._sayHello); + router.add('GET', r'/wave', service._wave); + router.add('GET', r'/greet/', service._greet); + router.add('GET', r'/hi/', service._hi); + router.mount(r'/api/', service._api.call); + router.all(r'/<_|.*>', service._index); return router; } diff --git a/pkgs/shelf_router_generator/test/server_test.dart b/pkgs/shelf_router_generator/test/server_test.dart index df14559d..bb946eb6 100644 --- a/pkgs/shelf_router_generator/test/server_test.dart +++ b/pkgs/shelf_router_generator/test/server_test.dart @@ -22,10 +22,7 @@ void main() { setUpAll(server.start); tearDownAll(server.stop); - void testGet({ - required String path, - required String result, - }) => + void testGet({required String path, required String result}) => test('GET $path', () async { final result = await http.get(server.uri.resolve(path)); expect(result, equals(result)); diff --git a/pkgs/shelf_static/analysis_options.yaml b/pkgs/shelf_static/analysis_options.yaml new file mode 100644 index 00000000..d978f811 --- /dev/null +++ b/pkgs/shelf_static/analysis_options.yaml @@ -0,0 +1 @@ +include: package:dart_flutter_team_lints/analysis_options.yaml diff --git a/pkgs/shelf_static/pubspec.yaml b/pkgs/shelf_static/pubspec.yaml index 132e51a2..eb1c8e94 100644 --- a/pkgs/shelf_static/pubspec.yaml +++ b/pkgs/shelf_static/pubspec.yaml @@ -2,6 +2,7 @@ name: shelf_static version: 1.1.3 description: Static file server support for the shelf package and ecosystem. repository: https://github.com/dart-lang/shelf/tree/master/pkgs/shelf_static +issue_tracker: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_static topics: - server diff --git a/pkgs/shelf_test_handler/CHANGELOG.md b/pkgs/shelf_test_handler/CHANGELOG.md index 941ecbc6..cb895460 100644 --- a/pkgs/shelf_test_handler/CHANGELOG.md +++ b/pkgs/shelf_test_handler/CHANGELOG.md @@ -1,6 +1,8 @@ ## 2.0.3-wip -* Require Dart `^3.3.0`. +* Require `shelf: ^1.1.0` +* Require `test: ^1.25.15` +* Require `sdk: ^3.5.0`. ## 2.0.2 diff --git a/pkgs/shelf_test_handler/analysis_options.yaml b/pkgs/shelf_test_handler/analysis_options.yaml new file mode 100644 index 00000000..d978f811 --- /dev/null +++ b/pkgs/shelf_test_handler/analysis_options.yaml @@ -0,0 +1 @@ +include: package:dart_flutter_team_lints/analysis_options.yaml diff --git a/pkgs/shelf_test_handler/lib/src/expectation.dart b/pkgs/shelf_test_handler/lib/src/expectation.dart index ef189900..c08808bb 100644 --- a/pkgs/shelf_test_handler/lib/src/expectation.dart +++ b/pkgs/shelf_test_handler/lib/src/expectation.dart @@ -4,6 +4,8 @@ import 'package:shelf/shelf.dart'; +import 'handler.dart'; + /// A single expectation for an HTTP request sent to a [ShelfTestHandler]. class Expectation { /// The expected request method, or `null` if this allows any requests. diff --git a/pkgs/shelf_test_handler/lib/src/server.dart b/pkgs/shelf_test_handler/lib/src/server.dart index 32af56bd..d784ae41 100644 --- a/pkgs/shelf_test_handler/lib/src/server.dart +++ b/pkgs/shelf_test_handler/lib/src/server.dart @@ -7,6 +7,7 @@ import 'dart:io'; import 'package:http_multi_server/http_multi_server.dart'; import 'package:shelf/shelf_io.dart'; +import 'package:test/test.dart'; import 'handler.dart'; diff --git a/pkgs/shelf_test_handler/pubspec.yaml b/pkgs/shelf_test_handler/pubspec.yaml index bb9d8118..c8420493 100644 --- a/pkgs/shelf_test_handler/pubspec.yaml +++ b/pkgs/shelf_test_handler/pubspec.yaml @@ -2,21 +2,22 @@ name: shelf_test_handler version: 2.0.3-wip description: A Shelf handler that makes it easy to test HTTP interactions. repository: https://github.com/dart-lang/shelf/tree/master/pkgs/shelf_test_handler +issue_tracker: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_test_handler topics: - server - shelf environment: - sdk: ^3.3.0 + sdk: ^3.5.0 dependencies: http_multi_server: ^3.0.0 - shelf: ^1.0.0 - test: ^1.16.0 + shelf: ^1.1.0 + test: ^1.25.15 dev_dependencies: dart_flutter_team_lints: ^3.0.0 http: ^1.0.0 - shelf_web_socket: ^2.0.0 - web_socket_channel: ^2.0.0 + shelf_web_socket: ^3.0.0 + web_socket_channel: ^3.0.3 diff --git a/pkgs/shelf_test_handler/test/server_test.dart b/pkgs/shelf_test_handler/test/server_test.dart index 5e3c0e88..d92e85e7 100644 --- a/pkgs/shelf_test_handler/test/server_test.dart +++ b/pkgs/shelf_test_handler/test/server_test.dart @@ -29,7 +29,7 @@ void main() { addTearDown(server.close); server.handler.expect('GET', '/', - webSocketHandler((WebSocketChannel webSocket) { + webSocketHandler((WebSocketChannel webSocket, _) { webSocket.sink.add('hello!'); webSocket.sink.close(); })); diff --git a/pkgs/shelf_web_socket/CHANGELOG.md b/pkgs/shelf_web_socket/CHANGELOG.md index 77f0882d..980b77f2 100644 --- a/pkgs/shelf_web_socket/CHANGELOG.md +++ b/pkgs/shelf_web_socket/CHANGELOG.md @@ -1,12 +1,45 @@ -## 2.0.1-wip +## 3.0.1-wip + +## 3.0.0 + +* **BREAKING:**: Change the signature of the `webSocketHandler` method's + `onConnection` callback. Previously this took an untyped function with either + one or two parameters. This now requires a `ConnectionCallback`; a typedef + taking two parameters. See also https://github.com/dart-lang/shelf/issues/457. +* Add a API usage example. +* Require Dart `^3.5.0`. + +Note that most clients seeing analysis issues from the above breaking change can +fix it by adding a second parameter to their callback. So, they would change +this: + +```dart +webSocketHandler((webSocket) { + webSocket.stream.listen((message) { + webSocket.sink.add('echo $message'); + }); +}); +``` + +to this: + +``` +webSocketHandler((webSocket, _) { + webSocket.stream.listen((message) { + webSocket.sink.add('echo $message'); + }); +}); +``` + +## 2.0.1 * Require Dart `^3.3.0`. ## 2.0.0 -* Require Dart `^3.0.0`. * **BREAKING:**: Remove support for hijacking WebSocket requests that are not being transported using `dart:io` `Socket`s. +* Require Dart `^3.0.0`. ## 1.0.4 diff --git a/pkgs/shelf_web_socket/README.md b/pkgs/shelf_web_socket/README.md index 7105c114..a4854dca 100644 --- a/pkgs/shelf_web_socket/README.md +++ b/pkgs/shelf_web_socket/README.md @@ -19,12 +19,11 @@ connection that's established. ```dart import 'package:shelf/shelf_io.dart' as shelf_io; import 'package:shelf_web_socket/shelf_web_socket.dart'; -import 'package:web_socket_channel/web_socket_channel.dart'; void main() { - var handler = webSocketHandler((webSocket) { + var handler = webSocketHandler((webSocket, _) { webSocket.stream.listen((message) { - webSocket.sink.add("echo $message"); + webSocket.sink.add('echo $message'); }); }); diff --git a/pkgs/shelf_web_socket/analysis_options.yaml b/pkgs/shelf_web_socket/analysis_options.yaml new file mode 100644 index 00000000..d978f811 --- /dev/null +++ b/pkgs/shelf_web_socket/analysis_options.yaml @@ -0,0 +1 @@ +include: package:dart_flutter_team_lints/analysis_options.yaml diff --git a/pkgs/shelf_web_socket/example/example.dart b/pkgs/shelf_web_socket/example/example.dart new file mode 100644 index 00000000..44bb9e45 --- /dev/null +++ b/pkgs/shelf_web_socket/example/example.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:shelf/shelf_io.dart' as shelf_io; +import 'package:shelf_web_socket/shelf_web_socket.dart'; + +void main() { + var handler = webSocketHandler((webSocket, _) { + webSocket.stream.listen((message) { + webSocket.sink.add('echo $message'); + }); + }); + + shelf_io.serve(handler, 'localhost', 8080).then((server) { + print('Serving at ws://${server.address.host}:${server.port}'); + }); +} diff --git a/pkgs/shelf_web_socket/lib/shelf_web_socket.dart b/pkgs/shelf_web_socket/lib/shelf_web_socket.dart index 18e19e03..c6b0f9b6 100644 --- a/pkgs/shelf_web_socket/lib/shelf_web_socket.dart +++ b/pkgs/shelf_web_socket/lib/shelf_web_socket.dart @@ -18,12 +18,12 @@ import 'src/web_socket_handler.dart'; /// This means that this can be placed first in a [Cascade] and only upgrade /// requests will be handled. /// -/// The [onConnection] must take a [WebSocketChannel] as its first argument. It -/// may also take a string, the [WebSocket subprotocol][], as its second -/// argument. The subprotocol is determined by looking at the client's +/// The [onConnection] takes a [WebSocketChannel] as its first argument and a +/// nullable string, the [WebSocket subprotocol][], as its second argument. +/// The subprotocol is determined by looking at the client's /// `Sec-WebSocket-Protocol` header and selecting the first entry that also /// appears in [protocols]. If no subprotocols are shared between the client and -/// the server, `null` will be passed instead and no subprotocol heaader will be +/// the server, `null` will be passed instead and no subprotocol header will be /// sent to the client which may cause it to disconnect. /// /// [WebSocket subprotocol]: https://tools.ietf.org/html/rfc6455#section-1.9 @@ -37,18 +37,14 @@ import 'src/web_socket_handler.dart'; /// [origin considerations]: https://tools.ietf.org/html/rfc6455#section-10.2 /// /// If [pingInterval] is specified, it will get passed to the created -/// channel instance, enabling round-trip disconnect detection. -/// See [WebSocketChannel] for more details. -Handler webSocketHandler(Function onConnection, - {Iterable? protocols, - Iterable? allowedOrigins, - Duration? pingInterval}) { - if (onConnection is! void Function(Never, Never)) { - final innerOnConnection = onConnection; - // ignore: inference_failure_on_untyped_parameter, avoid_dynamic_calls - onConnection = (webSocket, _) => innerOnConnection(webSocket); - } - +/// channel instance, enabling round-trip disconnect detection. See +/// [WebSocketChannel] for more details. +Handler webSocketHandler( + ConnectionCallback onConnection, { + Iterable? protocols, + Iterable? allowedOrigins, + Duration? pingInterval, +}) { return WebSocketHandler( onConnection, protocols?.toSet(), diff --git a/pkgs/shelf_web_socket/lib/src/web_socket_handler.dart b/pkgs/shelf_web_socket/lib/src/web_socket_handler.dart index 4c9c5ceb..e86010fd 100644 --- a/pkgs/shelf_web_socket/lib/src/web_socket_handler.dart +++ b/pkgs/shelf_web_socket/lib/src/web_socket_handler.dart @@ -9,10 +9,17 @@ import 'package:shelf/shelf.dart'; import 'package:web_socket_channel/io.dart'; import 'package:web_socket_channel/web_socket_channel.dart'; +/// Used by `webSocketHandler` report connections back to callers. +/// +/// This takes a [WebSocketChannel] as its first argument and an optional +/// [subprotocol] as its second argument. +typedef ConnectionCallback = void Function( + WebSocketChannel webSocket, String? subprotocol); + /// A class that exposes a handler for upgrading WebSocket requests. class WebSocketHandler { /// The function to call when a request is upgraded. - final Function _onConnection; + final ConnectionCallback _onConnection; /// The set of protocols the user supports, or `null`. final Set? _protocols; @@ -88,7 +95,6 @@ class WebSocketHandler { protocol: protocol, serverSide: true) ..pingInterval = _pingInterval; - // ignore: avoid_dynamic_calls _onConnection(IOWebSocketChannel(webSocket), protocol); }); } diff --git a/pkgs/shelf_web_socket/pubspec.yaml b/pkgs/shelf_web_socket/pubspec.yaml index 84cf9f2f..9d142ddf 100644 --- a/pkgs/shelf_web_socket/pubspec.yaml +++ b/pkgs/shelf_web_socket/pubspec.yaml @@ -1,15 +1,15 @@ name: shelf_web_socket -version: 2.0.1-wip -description: > - A shelf handler that wires up a listener for every connection. +version: 3.0.1-wip +description: A shelf handler that wires up a listener for every connection. repository: https://github.com/dart-lang/shelf/tree/master/pkgs/shelf_web_socket +issue_tracker: https://github.com/dart-lang/shelf/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ashelf_web_socket topics: - server - shelf environment: - sdk: ^3.3.0 + sdk: ^3.5.0 dependencies: shelf: ^1.1.0 diff --git a/pkgs/shelf_web_socket/test/web_socket_test.dart b/pkgs/shelf_web_socket/test/web_socket_test.dart index eb8e00bb..dbc5878c 100644 --- a/pkgs/shelf_web_socket/test/web_socket_test.dart +++ b/pkgs/shelf_web_socket/test/web_socket_test.dart @@ -21,8 +21,7 @@ Map get _handshakeHeaders => { void main() { test('can communicate with a dart:io WebSocket client', () async { - final server = - await shelf_io.serve(webSocketHandler((WebSocketChannel webSocket) { + final server = await shelf_io.serve(webSocketHandler((webSocket, _) { webSocket.sink.add('hello!'); webSocket.stream.first.then((request) { expect(request, equals('ping')); @@ -73,8 +72,7 @@ void main() { }); test('handles protocol header without allowed protocols', () async { - final server = - await shelf_io.serve(webSocketHandler((WebSocketChannel webSocket) { + final server = await shelf_io.serve(webSocketHandler((webSocket, _) { webSocket.sink.close(); }), 'localhost', 0); @@ -136,7 +134,7 @@ void main() { late Uri url; setUp(() async { server = await shelf_io.serve( - webSocketHandler((WebSocketChannel webSocket) { + webSocketHandler((webSocket, _) { webSocket.sink.close(); }, allowedOrigins: ['pub.dartlang.org', 'GoOgLe.CoM']), 'localhost', @@ -177,8 +175,7 @@ void main() { // Regression test for issue 21894. test('allows a Connection header with multiple values', () async { - final server = - await shelf_io.serve(webSocketHandler((WebSocketChannel webSocket) { + final server = await shelf_io.serve(webSocketHandler((webSocket, _) { webSocket.sink.close(); }), 'localhost', 0); @@ -193,7 +190,7 @@ void main() { late HttpServer server; late Uri url; setUp(() async { - server = await shelf_io.serve(webSocketHandler((_) { + server = await shelf_io.serve(webSocketHandler((_, __) { fail('should not create a WebSocket'); }), 'localhost', 0); url = Uri.http('localhost:${server.port}', ''); diff --git a/tool/ci.sh b/tool/ci.sh index c7b4cd76..c5272b36 100644 --- a/tool/ci.sh +++ b/tool/ci.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Created with package:mono_repo v6.6.1 +# Created with package:mono_repo v6.6.3 # Support built in commands on windows out of the box.