From 8db82e2d8e84b86856f30cc2ee33ca43e79f33de Mon Sep 17 00:00:00 2001 From: j4qfrost Date: Sat, 22 Oct 2022 18:29:58 -0700 Subject: [PATCH] fix: Upgrade to latest dependencies (#120) * fix(ci): Add override melos script * fix: Upgrade to latest dependencies * cache hacking * internal getField * cleanup obsolete files * dart fix --- .github/workflows/publish.yml | 4 + .github/workflows/test.yml | 91 ++- melos.yaml | 10 +- packages/codable/.github/workflows/dart.yml | 33 -- .../codable/lib/src/version/version.g.dart | 3 - packages/codable/pubspec.yaml | 2 +- packages/codable/test/encode_test.dart | 5 + packages/common/overrides.yaml | 5 + packages/common/pubspec.yaml | 5 + packages/common_test/overrides.yaml | 17 + packages/common_test/pubspec.yaml | 19 +- .../lib/src/auth/auth_code_controller.dart | 2 - .../src/auth/auth_redirect_controller.dart | 2 - .../src/http/managed_object_controller.dart | 1 - .../conduit/lib/src/runtime/orm_impl.dart | 6 +- .../conduit/lib/src/version/version.g.dart | 3 - packages/conduit/overrides.yaml | 17 + packages/conduit/pubspec.yaml | 27 +- packages/conduit/templates/db/pubspec.yaml | 2 +- .../templates/db_and_auth/pubspec.yaml | 2 +- .../conduit/templates/default/pubspec.yaml | 2 +- .../conduit/test/command/create_test.dart | 2 +- .../command/migration_execution_test.dart | 2 +- .../conduit/test/http/controller_test.dart | 1 + packages/conduit/tool/release.dart | 537 ------------------ packages/config/.github/workflows/dart.yml | 40 -- .../config/lib/src/version/version.g.dart | 3 - packages/config/overrides.yaml | 5 + packages/config/pubspec.yaml | 7 +- packages/config/tool/runtime_test_runner.dart | 72 --- .../fs_test_agent/.github/workflows/dart.yml | 33 -- .../fs_test_agent/lib/dart_project_agent.dart | 3 +- .../lib/src/version/version.g.dart | 3 - packages/fs_test_agent/pubspec.yaml | 2 +- .../isolate_exec/.github/workflows/dart.yml | 35 -- packages/isolate_exec/lib/src/executor.dart | 27 +- .../lib/src/source_generator.dart | 4 +- .../lib/src/version/version.g.dart | 3 - packages/isolate_exec/pubspec.yaml | 4 +- .../test/isolate_executor_test.dart | 1 + packages/open_api/.github/workflows/dart.yml | 35 -- .../open_api/lib/src/version/version.g.dart | 3 - packages/open_api/overrides.yaml | 3 + packages/open_api/pubspec.yaml | 3 + .../password_hash/.github/workflows/dart.yml | 33 -- .../lib/src/version/version.g.dart | 3 - packages/password_hash/pubspec.yaml | 4 +- packages/password_hash/test/pbkdf2_test.dart | 4 +- packages/runtime/.github/workflows/dart.yml | 41 -- packages/runtime/lib/src/analyzer.dart | 24 +- packages/runtime/lib/src/build_context.dart | 21 +- packages/runtime/lib/src/build_manager.dart | 5 +- .../runtime/lib/src/version/version.g.dart | 3 - packages/runtime/overrides.yaml | 3 + packages/runtime/pubspec.yaml | 7 +- packages/runtime/test/build_test.dart | 2 +- .../runtime/test/project_analyzer_test.dart | 2 +- .../application/pubspec.yaml | 2 +- .../dependency/pubspec.yaml | 2 +- packages/test_harness/lib/src/matchers.dart | 1 - .../lib/src/version/version.g.dart | 3 - packages/test_harness/overrides.yaml | 17 + packages/test_harness/pubspec.yaml | 23 +- utils/pubspec.yaml | 2 +- 64 files changed, 261 insertions(+), 1027 deletions(-) delete mode 100644 packages/codable/.github/workflows/dart.yml delete mode 100644 packages/codable/lib/src/version/version.g.dart create mode 100644 packages/common/overrides.yaml create mode 100644 packages/common_test/overrides.yaml delete mode 100644 packages/conduit/lib/src/version/version.g.dart create mode 100644 packages/conduit/overrides.yaml delete mode 100644 packages/conduit/tool/release.dart delete mode 100644 packages/config/.github/workflows/dart.yml delete mode 100644 packages/config/lib/src/version/version.g.dart create mode 100644 packages/config/overrides.yaml delete mode 100644 packages/config/tool/runtime_test_runner.dart delete mode 100644 packages/fs_test_agent/.github/workflows/dart.yml delete mode 100644 packages/fs_test_agent/lib/src/version/version.g.dart delete mode 100644 packages/isolate_exec/.github/workflows/dart.yml delete mode 100644 packages/isolate_exec/lib/src/version/version.g.dart delete mode 100644 packages/open_api/.github/workflows/dart.yml delete mode 100644 packages/open_api/lib/src/version/version.g.dart create mode 100644 packages/open_api/overrides.yaml delete mode 100644 packages/password_hash/.github/workflows/dart.yml delete mode 100644 packages/password_hash/lib/src/version/version.g.dart delete mode 100644 packages/runtime/.github/workflows/dart.yml delete mode 100644 packages/runtime/lib/src/version/version.g.dart create mode 100644 packages/runtime/overrides.yaml delete mode 100644 packages/test_harness/lib/src/version/version.g.dart create mode 100644 packages/test_harness/overrides.yaml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f5da34fa90..5b22d6caa1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,10 +29,14 @@ jobs: run: dart pub global activate melos - name: Strip overrides run: melos run strip-overrides + - name: Format + run: dart fix --apply && dart format --fix . - name: Uptick versions run: melos version --yes - name: Changelog run: git diff master packages/conduit/CHANGELOG.md > CHANGES.txt + - name: Cache Source + run: melos cache-source - name: Dry run run: melos publish --dry-run --yes - name: Push tags diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 365b76efa1..67af72966c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,33 +6,6 @@ on: workflow_dispatch: jobs: - test_harness: - env: - TEST_DIR: packages/test_harness - RUNNER_CMD: dart test -r expanded - runs-on: ubuntu-latest - services: - postgres: - image: postgres:14.5 - env: - POSTGRES_USER: conduit_test_user - POSTGRES_PASSWORD: conduit! - POSTGRES_DB: conduit_test_db - POSTGRES_PORT: 15432 - ports: - - 15432:5432 - steps: - - uses: actions/checkout@v3 - - uses: dart-lang/setup-dart@v1 - with: - sdk: dev - - name: Get Dependencies - working-directory: ${{ env.TEST_DIR }} - run: dart pub get - - name: Run tests - working-directory: ${{ env.TEST_DIR }} - run: . ../../ci/.env && ${{ env.RUNNER_CMD }} - all_unit: runs-on: ubuntu-latest services: @@ -53,15 +26,19 @@ jobs: - name: Get Dependencies run: | dart pub global activate melos - melos bootstrap cd packages/isolate_exec_test_packages/test_package && dart pub get + melos bootstrap + melos cache-source - name: Run tests - run: . ./ci/.env && melos test-unit + run: melos test-unit conduit_cli: env: TEST_DIR: packages/conduit runs-on: ubuntu-latest + strategy: + matrix: + runner_args: [dart test -j1 -t cli test/*, dart tool/generated_test_runner.dart] services: postgres: image: postgres:14.5 @@ -79,35 +56,39 @@ jobs: sdk: dev - name: Get Dependencies working-directory: ${{ env.TEST_DIR }} - run: dart pub get - - name: Run tests - working-directory: ${{ env.TEST_DIR }} - run: . ../../ci/.env && dart test -r expanded -j1 -t cli - - conduit_tool: - env: - TEST_DIR: packages/conduit - runs-on: ubuntu-latest - services: - postgres: - image: postgres:14.5 - env: - POSTGRES_USER: conduit_test_user - POSTGRES_PASSWORD: conduit! - POSTGRES_DB: conduit_test_db - POSTGRES_PORT: 15432 - ports: - - 15432:5432 - steps: - - uses: actions/checkout@v3 - - uses: dart-lang/setup-dart@v1 - with: - sdk: dev - - name: Prep Packages run: | dart pub global activate melos melos bootstrap melos cache-source - name: Run tests working-directory: ${{ env.TEST_DIR }} - run: . ../../ci/.env && dart tool/generated_test_runner.dart + run: . ../../ci/.env && ${{ matrix.runner_args }} + + # For help debugging CI problems should normally be commented out + # single_unit: + # env: + # TEST_DIR: packages/runtime + # runs-on: ubuntu-latest + # services: + # postgres: + # image: postgres:14.5 + # env: + # POSTGRES_USER: conduit_test_user + # POSTGRES_PASSWORD: conduit! + # POSTGRES_DB: conduit_test_db + # POSTGRES_PORT: 15432 + # ports: + # - 15432:5432 + # steps: + # - uses: actions/checkout@v3 + # - uses: dart-lang/setup-dart@v1 + # with: + # sdk: dev + # - name: Get Dependencies + # run: | + # dart pub global activate melos + # melos bootstrap + # melos cache-source + # - name: Run tests + # working-directory: ${{ env.TEST_DIR }} + # run: . ../../ci/.env && dart test \ No newline at end of file diff --git a/melos.yaml b/melos.yaml index 01433076ef..c4f7949304 100644 --- a/melos.yaml +++ b/melos.yaml @@ -20,14 +20,22 @@ scripts: select-pacakge: no-private: true analyze: melos exec -- pub global run tuneup check + activate-all: + run: melos exec -- "dart pub global activate '\$MELOS_PACKAGE_NAME'" + select-pacakge: + no-private: true cache-source: - run: melos exec -- "dart pub global activate '\$MELOS_PACKAGE_NAME' && cp -r '\$MELOS_PACKAGE_PATH' '$PUB_CACHE/hosted/pub.dartlang.org/\$MELOS_PACKAGE_NAME-\$MELOS_PACKAGE_VERSION'" + run: melos exec -- "mkdir -p '$PUB_CACHE/hosted/pub.dev/\$MELOS_PACKAGE_NAME-\$MELOS_PACKAGE_VERSION'; cp -R '\$MELOS_PACKAGE_PATH'/* '$PUB_CACHE/hosted/pub.dev/\$MELOS_PACKAGE_NAME-\$MELOS_PACKAGE_VERSION' && ls '$PUB_CACHE/hosted/pub.dev/\$MELOS_PACKAGE_NAME-\$MELOS_PACKAGE_VERSION/' && yq -i 'del(.dependency_overrides)' '$PUB_CACHE/hosted/pub.dev/\$MELOS_PACKAGE_NAME-\$MELOS_PACKAGE_VERSION/pubspec.yaml'" select-pacakge: no-private: true strip-overrides: run: melos exec -- "yq -i 'del(.dependency_overrides)' '\$MELOS_PACKAGE_PATH/pubspec.yaml'" select-pacakge: no-private: true + apply-overrides: + run: melos exec -- "if [ -f '\$MELOS_PACKAGE_PATH/overrides.yaml' ]; then yq -i '. *= load(\"\$MELOS_PACKAGE_PATH/overrides.yaml\")' '\$MELOS_PACKAGE_PATH/pubspec.yaml'; fi" + hard-clean: + run: melos exec -- "rm -rf '\$MELOS_PACKAGE_PATH/.dart_tool' '\$MELOS_PACKAGE_PATH/pubspec.lock'" environment: sdk: ">=2.12.0 <3.0.0" diff --git a/packages/codable/.github/workflows/dart.yml b/packages/codable/.github/workflows/dart.yml deleted file mode 100644 index d102b2dbb4..0000000000 --- a/packages/codable/.github/workflows/dart.yml +++ /dev/null @@ -1,33 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Dart - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: dart-lang/setup-dart@v1 - - - name: Install dependencies - run: dart pub get - - - name: Verify formatting - run: dart format --output=none --set-exit-if-changed . - - - name: Analyze project source - run: dart analyze --fatal-infos - - - name: Run tests - run: dart test diff --git a/packages/codable/lib/src/version/version.g.dart b/packages/codable/lib/src/version/version.g.dart deleted file mode 100644 index 8b2d945c75..0000000000 --- a/packages/codable/lib/src/version/version.g.dart +++ /dev/null @@ -1,3 +0,0 @@ -/// GENERATED BY pub_release do not modify. -/// conduit_codable version -String packageVersion = '3.1.0'; diff --git a/packages/codable/pubspec.yaml b/packages/codable/pubspec.yaml index 62f7a7917e..aab2c79442 100644 --- a/packages/codable/pubspec.yaml +++ b/packages/codable/pubspec.yaml @@ -8,4 +8,4 @@ dependencies: meta: ^1.3.0 dev_dependencies: lint: ^1.0.0 - test: ^1.16.5 + test: ^1.21.6 diff --git a/packages/codable/test/encode_test.dart b/packages/codable/test/encode_test.dart index b250b16cba..26bdbdde73 100644 --- a/packages/codable/test/encode_test.dart +++ b/packages/codable/test/encode_test.dart @@ -319,10 +319,15 @@ void main() { expect(encoded["archive"] is KeyedArchive, false); expect(encoded["list"] is List, true); expect(encoded["list"] is ListArchive, false); + // ignore: avoid_dynamic_calls expect(encoded["list"][0], "value"); + // ignore: avoid_dynamic_calls expect(encoded["list"][1] is Map, true); + // ignore: avoid_dynamic_calls expect(encoded["list"][1] is KeyedArchive, false); + // ignore: avoid_dynamic_calls expect(encoded["list"][2] is List, true); + // ignore: avoid_dynamic_calls expect(encoded["list"][2] is ListArchive, false); }); } diff --git a/packages/common/overrides.yaml b/packages/common/overrides.yaml new file mode 100644 index 0000000000..717f2b560b --- /dev/null +++ b/packages/common/overrides.yaml @@ -0,0 +1,5 @@ +dependency_overrides: + conduit_codable: + path: ../codable + conduit_open_api: + path: ../open_api \ No newline at end of file diff --git a/packages/common/pubspec.yaml b/packages/common/pubspec.yaml index 5ec0d8b456..c268c496f3 100644 --- a/packages/common/pubspec.yaml +++ b/packages/common/pubspec.yaml @@ -8,3 +8,8 @@ dependencies: conduit_open_api: ^3.2.2 dev_dependencies: lint: ^1.0.0 +dependency_overrides: + conduit_codable: + path: ../codable + conduit_open_api: + path: ../open_api diff --git a/packages/common_test/overrides.yaml b/packages/common_test/overrides.yaml new file mode 100644 index 0000000000..146ac6187b --- /dev/null +++ b/packages/common_test/overrides.yaml @@ -0,0 +1,17 @@ +dependency_overrides: + conduit: + path: ../conduit + conduit_common: + path: ../common + conduit_open_api: + path: ../open_api + conduit_codable: + path: ../codable + conduit_config: + path: ../config + conduit_isolate_exec: + path: ../isolate_exec + conduit_password_hash: + path: ../password_hash + conduit_runtime: + path: ../runtime \ No newline at end of file diff --git a/packages/common_test/pubspec.yaml b/packages/common_test/pubspec.yaml index 17e016af76..250e91ae2c 100644 --- a/packages/common_test/pubspec.yaml +++ b/packages/common_test/pubspec.yaml @@ -7,4 +7,21 @@ environment: sdk: ">=2.12.0 <3.0.0" dependencies: conduit: ^3.2.3 - conduit_common: ^3.2.2 \ No newline at end of file + conduit_common: ^3.2.2 +dependency_overrides: + conduit: + path: ../conduit + conduit_common: + path: ../common + conduit_open_api: + path: ../open_api + conduit_codable: + path: ../codable + conduit_config: + path: ../config + conduit_isolate_exec: + path: ../isolate_exec + conduit_password_hash: + path: ../password_hash + conduit_runtime: + path: ../runtime diff --git a/packages/conduit/lib/src/auth/auth_code_controller.dart b/packages/conduit/lib/src/auth/auth_code_controller.dart index b85654722e..a834329e12 100644 --- a/packages/conduit/lib/src/auth/auth_code_controller.dart +++ b/packages/conduit/lib/src/auth/auth_code_controller.dart @@ -93,7 +93,6 @@ class AuthCodeController extends ResourceController { @Operation.get() Future getAuthorizationPage( { - /// A space-delimited list of access scopes to be requested by the form submission on the returned page. @Bind.query("scope") String? scope}) async { if (delegate == null) { @@ -116,7 +115,6 @@ class AuthCodeController extends ResourceController { @Operation.post() Future authorize( { - /// The username of the authenticating user. @Bind.query("username") String? username, diff --git a/packages/conduit/lib/src/auth/auth_redirect_controller.dart b/packages/conduit/lib/src/auth/auth_redirect_controller.dart index c7d445db2e..3497ce8531 100644 --- a/packages/conduit/lib/src/auth/auth_redirect_controller.dart +++ b/packages/conduit/lib/src/auth/auth_redirect_controller.dart @@ -98,7 +98,6 @@ class AuthRedirectController extends ResourceController { @Operation.get() Future getAuthorizationPage( { - /// A space-delimited list of access scopes to be requested by the form submission on the returned page. @Bind.query("scope") String? scope}) async { if (delegate == null) { @@ -132,7 +131,6 @@ class AuthRedirectController extends ResourceController { @Operation.post() Future authorize( { - /// The username of the authenticating user. @Bind.query("username") String? username, diff --git a/packages/conduit/lib/src/http/managed_object_controller.dart b/packages/conduit/lib/src/http/managed_object_controller.dart index 46264c2dcd..d6031a3b0b 100644 --- a/packages/conduit/lib/src/http/managed_object_controller.dart +++ b/packages/conduit/lib/src/http/managed_object_controller.dart @@ -245,7 +245,6 @@ class ManagedObjectController @Operation.get() Future getObjects( { - /// Limits the number of objects returned. @Bind.query("count") int count = 0, diff --git a/packages/conduit/lib/src/runtime/orm_impl.dart b/packages/conduit/lib/src/runtime/orm_impl.dart index f8d586771e..2714a19b3b 100644 --- a/packages/conduit/lib/src/runtime/orm_impl.dart +++ b/packages/conduit/lib/src/runtime/orm_impl.dart @@ -137,7 +137,7 @@ class ManagedEntityRuntimeImpl extends ManagedEntityRuntime return [annotation.toSource().substring(1)]; } else if (isInstanceOfColumn) { final originatingLibrary = element.session! - .getParsedLibraryByElement2(element.library) as ParsedLibraryResult; + .getParsedLibraryByElement(element.library) as ParsedLibraryResult; final elementDeclaration = originatingLibrary .getElementDeclaration(element.variable)! .node as VariableDeclaration; @@ -160,11 +160,11 @@ class ManagedEntityRuntimeImpl extends ManagedEntityRuntime // For the property we are looking at, grab all of its annotations from the analyzer. // We also have all of the instances created by these annotations available in some // way or another in the [property]. - final fieldAnnotations = context.getAnnotationsFromField( + final fieldAnnotations = await context.getAnnotationsFromField( EntityBuilder.getTableDefinitionForType(property.entity.instanceType) .reflectedType, property.name); - final constructorInvocations = (await fieldAnnotations) + final constructorInvocations = fieldAnnotations .map((annotation) => _getValidatorConstructionFromAnnotation( context, annotation, property, importUris: importUris)) diff --git a/packages/conduit/lib/src/version/version.g.dart b/packages/conduit/lib/src/version/version.g.dart deleted file mode 100644 index cd0c6072b9..0000000000 --- a/packages/conduit/lib/src/version/version.g.dart +++ /dev/null @@ -1,3 +0,0 @@ -/// GENERATED BY pub_release do not modify. -/// conduit version -String packageVersion = '3.1.0'; diff --git a/packages/conduit/overrides.yaml b/packages/conduit/overrides.yaml new file mode 100644 index 0000000000..fab23f8359 --- /dev/null +++ b/packages/conduit/overrides.yaml @@ -0,0 +1,17 @@ +dependency_overrides: + conduit_codable: + path: ../codable + conduit_common: + path: ../common + conduit_config: + path: ../config + conduit_isolate_exec: + path: ../isolate_exec + conduit_open_api: + path: ../open_api + conduit_password_hash: + path: ../password_hash + conduit_runtime: + path: ../runtime + conduit_test: + path: ../test_harness \ No newline at end of file diff --git a/packages/conduit/pubspec.yaml b/packages/conduit/pubspec.yaml index d1af7594aa..411d98d407 100644 --- a/packages/conduit/pubspec.yaml +++ b/packages/conduit/pubspec.yaml @@ -6,7 +6,7 @@ environment: sdk: ">=2.12.0 <3.0.0" dependencies: args: ^2.1.1 - analyzer: ^1.3.0 + analyzer: ^5.1.0 collection: ^1.15.0 conduit_common: ^3.2.2 conduit_config: ^3.2.2 @@ -14,7 +14,7 @@ dependencies: conduit_open_api: ^3.2.2 conduit_password_hash: ^3.2.2 conduit_runtime: ^3.2.2 - crypto: ^3.0.0 + crypto: ^3.0.2 logging: ^1.0.0 meta: ^1.1.5 path: ^1.6.1 @@ -24,10 +24,10 @@ dependencies: yaml: ^3.1.0 dev_dependencies: http: ^0.13.0 - matcher: ">=0.12.3 <0.14.0" - mockito: ^5.0.0 + matcher: ^0.12.12 + mockito: ^5.3.2 pedantic: ^1.0.0 - test: ^1.16.5 + test: ^1.21.6 fs_test_agent: path: ../fs_test_agent conduit_common_test: @@ -37,3 +37,20 @@ dev_dependencies: web_socket_channel: ^2.2.0 executables: conduit: conduit +dependency_overrides: + conduit_codable: + path: ../codable + conduit_common: + path: ../common + conduit_config: + path: ../config + conduit_isolate_exec: + path: ../isolate_exec + conduit_open_api: + path: ../open_api + conduit_password_hash: + path: ../password_hash + conduit_runtime: + path: ../runtime + conduit_test: + path: ../test_harness diff --git a/packages/conduit/templates/db/pubspec.yaml b/packages/conduit/templates/db/pubspec.yaml index ba6b363917..374d38acb5 100644 --- a/packages/conduit/templates/db/pubspec.yaml +++ b/packages/conduit/templates/db/pubspec.yaml @@ -10,5 +10,5 @@ dependencies: conduit: ^3.2.0 dev_dependencies: - test: ^1.16.5 + test: ^1.21.6 conduit_test: ^3.2.0 diff --git a/packages/conduit/templates/db_and_auth/pubspec.yaml b/packages/conduit/templates/db_and_auth/pubspec.yaml index f8320688eb..5159815cbf 100644 --- a/packages/conduit/templates/db_and_auth/pubspec.yaml +++ b/packages/conduit/templates/db_and_auth/pubspec.yaml @@ -10,5 +10,5 @@ dependencies: conduit: ^3.2.0 dev_dependencies: - test: ^1.16.5 + test: ^1.21.6 conduit_test: ^3.2.0 diff --git a/packages/conduit/templates/default/pubspec.yaml b/packages/conduit/templates/default/pubspec.yaml index e01760a49f..417698c675 100644 --- a/packages/conduit/templates/default/pubspec.yaml +++ b/packages/conduit/templates/default/pubspec.yaml @@ -10,5 +10,5 @@ dependencies: conduit: ^3.2.0 dev_dependencies: - test: ^1.16.5 + test: ^1.21.6 conduit_test: ^3.2.0 diff --git a/packages/conduit/test/command/create_test.dart b/packages/conduit/test/command/create_test.dart index 85edecdeaa..0ff6965dd1 100644 --- a/packages/conduit/test/command/create_test.dart +++ b/packages/conduit/test/command/create_test.dart @@ -179,8 +179,8 @@ void main() { print(res.stderr); - expect(res.stdout, contains("All tests passed")); expect(res.exitCode, 0); + expect(res.stdout, contains(" passed.")); }); } }); diff --git a/packages/conduit/test/command/migration_execution_test.dart b/packages/conduit/test/command/migration_execution_test.dart index 3633d16c3c..6e986172d0 100644 --- a/packages/conduit/test/command/migration_execution_test.dart +++ b/packages/conduit/test/command/migration_execution_test.dart @@ -263,7 +263,7 @@ List getOrderedTestMigrations( final analyzer = CodeAnalyzer(uri); final migrations = analyzer .getSubclassesFromFile("Migration", analyzer.uri) - .where((cu) => names.contains(cu.name.name)) + .where((cu) => names.contains(cu.name.value())) .map(migrationSourceFromClassDeclaration) .toList(); diff --git a/packages/conduit/test/http/controller_test.dart b/packages/conduit/test/http/controller_test.dart index 7a20f5cb54..8e9eb5a614 100644 --- a/packages/conduit/test/http/controller_test.dart +++ b/packages/conduit/test/http/controller_test.dart @@ -140,6 +140,7 @@ void main() { // ignore: missing_return (req) { set = true; + return null; }); var response = await http.get(Uri.parse("http://localhost:4111")); diff --git a/packages/conduit/tool/release.dart b/packages/conduit/tool/release.dart deleted file mode 100644 index b0e3316402..0000000000 --- a/packages/conduit/tool/release.dart +++ /dev/null @@ -1,537 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; - -import 'package:args/args.dart'; -import 'package:conduit_config/conduit_config.dart'; -import 'package:http/http.dart' as http; -import 'package:yaml/yaml.dart'; - -Future main(List args) async { - var parser = ArgParser() - ..addFlag("dry-run") - ..addFlag("docs-only") - ..addOption("name") - ..addOption("config", abbr: "c", defaultsTo: "release.yaml"); - var runner = Runner(parser.parse(args)); - - try { - exitCode = await runner.run(); - } catch (e, st) { - print("Release failed!"); - print("$e"); - print("$st"); - exitCode = -1; - } finally { - await runner.cleanup(); - } -} - -class Runner { - Runner(this.options) { - configuration = ReleaseConfig(options["config"] as String); - } - - ArgResults options; - late ReleaseConfig configuration; - List _cleanup = []; - bool? get isDryRun => options["dry-run"] as bool?; - bool? get docsOnly => options["docs-only"] as bool?; - String? get name => options["name"] as String?; - Uri baseReferenceURL = - Uri.parse("https://www.dartdocs.org/documentation/conduit/latest/"); - - Future cleanup() async { - return Future.forEach(_cleanup, (dynamic f) => f()); - } - - Future run() async { - // Ensure we have all the appropriate command line utilities as a pre-check - // - git - // - pub - // - mkdocs - - if (name == null && !(isDryRun! || docsOnly!)) { - throw "--name is required."; - } - - print( - "Preparing release: '$name'... ${isDryRun! ? "(dry-run)" : ""} ${docsOnly! ? "(docs-only)" : ""}"); - - var master = await directoryWithBranch("master"); - String? upcomingVersion; - String? changeset; - if (!docsOnly!) { - var previousVersion = await latestVersion(); - upcomingVersion = await versionFromDirectory(master); - if (upcomingVersion == previousVersion) { - throw "Release failed. Version $upcomingVersion already exists."; - } - - print("Preparing to release $upcomingVersion (from $previousVersion)..."); - changeset = await changesFromDirectory(master, upcomingVersion); - } - - // Clone docs/source into another directory. - var docsSource = await directoryWithBranch("docs/source"); - await publishDocs(docsSource, master); - - if (!docsOnly!) { - await postGithubRelease(upcomingVersion, name, changeset); - await publish(master); - } - - return 0; - } - - Future publishDocs(Directory docSource, Directory code) async { - var symbolMap = await generateSymbolMap(code); - var blacklist = ["tools", "build"]; - var transformers = [ - BlacklistTransformer(blacklist), - APIReferenceTransformer(symbolMap, baseReferenceURL) - ]; - - var docsLive = await directoryWithBranch("gh-pages"); - print("Cleaning ${docsLive.path}..."); - docsLive.listSync().where((fse) { - if (fse is Directory) { - var lastPathComponent = - fse.uri.pathSegments[fse.uri.pathSegments.length - 2]; - return lastPathComponent != ".git"; - } else if (fse is File) { - return fse.uri.pathSegments.last != ".nojekyll"; - } - return false; - }).forEach((fse) { - fse.deleteSync(recursive: true); - }); - - print("Transforming docs from ${docSource.path} into ${docsLive.path}..."); - await transformDirectory(transformers, docSource, docsLive); - - print("Building /source to /docs site with mkdoc..."); - var process = await Process.start( - "mkdocs", ["build", "-d", docsLive.uri.resolve("docs").path, "-s"], - workingDirectory: docsLive.uri.resolve("source").path); - // ignore: unawaited_futures - stderr.addStream(process.stderr); - // ignore: unawaited_futures - stdout.addStream(process.stdout); - var exitCode = await process.exitCode; - if (exitCode != 0) { - throw "mkdocs failed with exit code $exitCode."; - } - - var sourceDirectoryInLive = - Directory.fromUri(docsLive.uri.resolve("source")); - sourceDirectoryInLive.deleteSync(recursive: true); - process = await Process.start("git", ["add", "."], - workingDirectory: docsLive.path); - // ignore: unawaited_futures - stderr.addStream(process.stderr); - // ignore: unawaited_futures - stdout.addStream(process.stdout); - exitCode = await process.exitCode; - if (exitCode != 0) { - throw "git add in ${docsLive.path} failed with exit code $exitCode."; - } - - process = await Process.start( - "git", ["commit", "-m", "commit by release tool"], - workingDirectory: docsLive.path); - // ignore: unawaited_futures - stderr.addStream(process.stderr); - // ignore: unawaited_futures - stdout.addStream(process.stdout); - exitCode = await process.exitCode; - if (exitCode != 0) { - throw "git commit in ${docsLive.path} failed with exit code $exitCode."; - } - - // Push gh-pages to remote - if (!isDryRun!) { - print("Pushing gh-pages to remote..."); - var process = - await Process.start("git", ["push"], workingDirectory: docsLive.path); - // ignore: unawaited_futures - stderr.addStream(process.stderr); - // ignore: unawaited_futures - stdout.addStream(process.stdout); - var exitCode = await process.exitCode; - if (exitCode != 0) { - throw "git push to ${docsLive.path} failed with exit code $exitCode."; - } - } - } - - Future directoryWithBranch(String branchName) async { - var dir = - await Directory.current.createTemp(branchName.replaceAll("/", "_")); - _cleanup.add(() => dir.delete(recursive: true)); - - print("Cloning '$branchName' into ${dir.path}..."); - var process = await Process.start("git", [ - "clone", - "-b", - branchName, - "git@github.com:stablekernel/conduit.git", - dir.path - ]); - // ignore: unawaited_futures - stderr.addStream(process.stderr); - // ignore: unawaited_futures - // stdout.addStream(process.stdout); - - var exitCode = await process.exitCode; - if (exitCode != 0) { - throw "directoryWithBranch ($branchName) failed with exit code $exitCode."; - } - - return dir; - } - - Future latestVersion() async { - print("Getting latest version..."); - var response = await http.get( - Uri.parse( - "https://api.github.com/repos/stablekernel/conduit/releases/latest", - ), - headers: {"Authorization": "Bearer ${configuration.githubToken}"}, - ); - - if (response.statusCode != 200) { - throw "latestVersion failed with status code ${response.statusCode}. Reason: ${response.body}"; - } - - final tag = json.decode(response.body)["tag_name"] as String?; - if (tag == null) { - throw "latestVersion failed. Reason: no tag found"; - } - - return tag.trim(); - } - - Future versionFromDirectory(Directory directory) async { - var pubspecFile = File.fromUri(directory.uri.resolve("pubspec.yaml")); - var yaml = loadYaml(await pubspecFile.readAsString()); - - return "v${(yaml["version"] as String).trim()}"; - } - - Future changesFromDirectory( - Directory directory, String prefixedVersion) async { - // Strip "v" - var version = prefixedVersion.substring(1); - assert(version.split(".").length == 3); - - var regex = RegExp(r"^## ([0-9]+\.[0-9]+\.[0-9]+)", multiLine: true); - - var changelogFile = File.fromUri(directory.uri.resolve("CHANGELOG.md")); - var changelogContents = await changelogFile.readAsString(); - var versionContentsList = regex.allMatches(changelogContents).toList(); - var latestChangelogVersion = versionContentsList - .firstWhere((m) => m.group(1) == version, orElse: () { - throw "Release failed. No entry in CHANGELOG.md for $version."; - }); - - var changeset = changelogContents - .substring( - latestChangelogVersion.end, - versionContentsList[ - versionContentsList.indexOf(latestChangelogVersion) + 1] - .start) - .trim(); - - print("Changeset for $prefixedVersion:"); - print("$changeset"); - - return changeset; - } - - Future postGithubRelease( - String? version, String? name, String? description) async { - var body = - json.encode({"tag_name": version, "name": name, "body": description}); - - print("Tagging GitHub release $version"); - print("- $name"); - - if (!isDryRun!) { - var response = await http.post( - Uri.parse("https://api.github.com/repos/stablekernel/conduit/releases"), - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer ${configuration.githubToken}" - }, - body: body, - ); - - if (response.statusCode < 200 || response.statusCode >= 300) { - throw "GitHub release tag failed with status code ${response.statusCode}. Reason: ${response.body}."; - } - } - } - - Future publish(Directory master) async { - print("Formatting code..."); - final fmt = await Process.run("dartfmt", ["-w", "lib/", "bin/"]); - if (fmt.exitCode != 0) { - print("WARNING: Failed to run 'dartfmt -w lib/ bin/"); - } - - print("Publishing to pub..."); - var args = ["publish"]; - if (isDryRun!) { - args.add("--dry-run"); - } else { - args.add("-f"); - } - - var process = - await Process.start("pub", args, workingDirectory: master.path); - // ignore: unawaited_futures - stderr.addStream(process.stderr); - // ignore: unawaited_futures - stdout.addStream(process.stdout); - - var exitCode = await process.exitCode; - if (exitCode != 0) { - throw "Publish failed with exit code: $exitCode."; - } - } - - Future>>> generateSymbolMap( - Directory codeBranchDir) async { - print("Generating API reference..."); - var process = await Process.start("dartdoc", [], - workingDirectory: codeBranchDir.path); - // ignore: unawaited_futures - stderr.addStream(process.stderr); - // ignore: unawaited_futures - stdout.addStream(process.stdout); - - var exitCode = await process.exitCode; - if (exitCode != 0) { - throw "Release failed. Generating API reference failed with exit code: $exitCode."; - } - - print("Building symbol map..."); - var indexFile = File.fromUri(codeBranchDir.uri - .resolve("doc/") - .resolve("api/") - .resolve("index.json")); - final indexJSON = json.decode(await indexFile.readAsString()) - as List>; - var libraries = indexJSON - .where((m) => m["type"] == "library") - .map((lib) => lib["qualifiedName"]) - .toList(); - - List resolutions = indexJSON - .where((m) => m["type"] != "library") - .map((obj) => SymbolResolution.fromMap(obj.cast())) - .toList(); - - var qualifiedMap = >{}; - var nameMap = >{}; - resolutions.forEach((resolution) { - if (!nameMap.containsKey(resolution.name)) { - nameMap[resolution.name] = [resolution]; - } else { - nameMap[resolution.name]!.add(resolution); - } - - var qualifiedKey = - libraries.fold(resolution.qualifiedName, (String? p, e) { - return p!.replaceFirst("$e.", ""); - }); - if (!qualifiedMap.containsKey(qualifiedKey)) { - qualifiedMap[qualifiedKey] = [resolution]; - } else { - qualifiedMap[qualifiedKey]!.add(resolution); - } - }); - - return {"qualified": qualifiedMap, "name": nameMap}; - } - - Future transformDirectory(List transformers, Directory source, - Directory destination) async { - var contents = source.listSync(recursive: false); - var files = contents.whereType(); - for (var f in files) { - var filename = f.uri.pathSegments.last; - - List? contents; - for (var transformer in transformers) { - if (!transformer.shouldIncludeItem(filename)) { - break; - } - - if (!transformer.shouldTransformFile(filename)) { - continue; - } - - contents = contents ?? f.readAsBytesSync(); - contents = await transformer.transform(contents); - } - - var destinationUri = destination.uri.resolve(filename); - if (contents != null) { - var outFile = File.fromUri(destinationUri); - outFile.writeAsBytesSync(contents); - } - } - - Iterable subdirectories = contents.whereType(); - for (var subdirectory in subdirectories) { - var dirName = subdirectory - .uri.pathSegments[subdirectory.uri.pathSegments.length - 2]; - Directory? destinationDir = - Directory.fromUri(destination.uri.resolve("$dirName")); - - for (var t in transformers) { - if (!t.shouldConsiderDirectories) { - continue; - } - - if (!t.shouldIncludeItem(dirName)) { - destinationDir = null; - break; - } - } - - if (destinationDir != null) { - destinationDir.createSync(recursive: false); - await transformDirectory(transformers, subdirectory, destinationDir); - } - } - } -} - -class ReleaseConfig extends Configuration { - ReleaseConfig(String filename) : super.fromFile(File(filename)); - - String? githubToken; -} - -////// - -class SymbolResolution { - SymbolResolution.fromMap(Map map) { - name = map["name"]; - qualifiedName = map["qualifiedName"]; - link = map["href"]; - type = map["type"]; - } - - String? name; - String? qualifiedName; - String? type; - String? link; - - @override - String toString() => "$name: $qualifiedName $link $type"; -} - -abstract class Transformer { - bool shouldTransformFile(String filename) => true; - bool get shouldConsiderDirectories => false; - bool shouldIncludeItem(String filename) => true; - Future> transform(List inputContents) async => inputContents; -} - -class BlacklistTransformer extends Transformer { - BlacklistTransformer(this.blacklist); - List blacklist; - - @override - bool get shouldConsiderDirectories => true; - - @override - bool shouldIncludeItem(String filename) { - if (filename.startsWith(".")) { - return false; - } - - for (var b in blacklist) { - if (b == filename) { - return false; - } - } - - return true; - } -} - -class APIReferenceTransformer extends Transformer { - APIReferenceTransformer(this.symbolMap, this.baseReferenceURL); - - Uri baseReferenceURL; - final RegExp regex = RegExp("`([A-Za-z0-9_\\.\\<\\>@\\(\\)]+)`"); - Map>> symbolMap; - - @override - bool shouldTransformFile(String filename) { - return filename.endsWith(".md"); - } - - @override - Future> transform(List inputContents) async { - var contents = utf8.decode(inputContents); - - var matches = regex.allMatches(contents).toList().reversed; - - matches.forEach((match) { - var symbol = match.group(1); - var resolution = bestGuessForSymbol(symbol); - if (resolution != null) { - symbol = symbol!.replaceAll("<", "<").replaceAll(">", ">"); - var replacement = constructedReferenceURLFrom( - baseReferenceURL, resolution.link!.split("/")); - contents = contents.replaceRange( - match.start, match.end, "$symbol"); - } else { -// missingSymbols.add(symbol); - } - }); - - return utf8.encode(contents); - } - - SymbolResolution? bestGuessForSymbol(String? inputSymbol) { - if (symbolMap.isEmpty) { - return null; - } - - final symbol = inputSymbol! - .replaceAll("", "") - .replaceAll("@", "") - .replaceAll("()", ""); - - var possible = symbolMap["qualified"]![symbol]; - possible ??= symbolMap["name"]![symbol]; - - if (possible == null) { - return null; - } - - if (possible.length == 1) { - return possible.first; - } - - return possible.firstWhere((r) => r.type == "class", - orElse: () => possible!.first); - } -} - -Uri constructedReferenceURLFrom(Uri base, List relativePathComponents) { - var subdirectories = - relativePathComponents.sublist(0, relativePathComponents.length - 1); - Uri enclosingDir = subdirectories.fold(base, (Uri prev, elem) { - return prev.resolve("$elem/"); - }); - - return enclosingDir.resolve(relativePathComponents.last); -} diff --git a/packages/config/.github/workflows/dart.yml b/packages/config/.github/workflows/dart.yml deleted file mode 100644 index 9aef74bdc9..0000000000 --- a/packages/config/.github/workflows/dart.yml +++ /dev/null @@ -1,40 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Dart - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: dart-lang/setup-dart@v1 - - - name: Install dependencies - run: dart pub get - - - name: Analyze project source - run: dart analyze --fatal-infos - - - name: Verify formatting - run: dart format --output=none --set-exit-if-changed . - - - name: Run tests - run: dart test - env: - TEST_VALUE: 1 - TEST_BOOL: true - TEST_DB_ENV_VAR: 'postgres://user:password@host:5432/dbname' - - - name: Run tests with compiled runtime - run: dart tool/runtime_test_runner.dart diff --git a/packages/config/lib/src/version/version.g.dart b/packages/config/lib/src/version/version.g.dart deleted file mode 100644 index daf213ade8..0000000000 --- a/packages/config/lib/src/version/version.g.dart +++ /dev/null @@ -1,3 +0,0 @@ -/// GENERATED BY pub_release do not modify. -/// conduit_config version -String packageVersion = '3.1.0'; diff --git a/packages/config/overrides.yaml b/packages/config/overrides.yaml new file mode 100644 index 0000000000..532c6c9613 --- /dev/null +++ b/packages/config/overrides.yaml @@ -0,0 +1,5 @@ +dependency_overrides: + conduit_isolate_exec: + path: ../isolate_exec + conduit_runtime: + path: ../runtime \ No newline at end of file diff --git a/packages/config/pubspec.yaml b/packages/config/pubspec.yaml index 7bba4f89a1..2e977faa40 100644 --- a/packages/config/pubspec.yaml +++ b/packages/config/pubspec.yaml @@ -10,4 +10,9 @@ dependencies: yaml: ^3.1.0 dev_dependencies: lint: ^1.5.0 - test: ^1.16.5 + test: ^1.21.6 +dependency_overrides: + conduit_isolate_exec: + path: ../isolate_exec + conduit_runtime: + path: ../runtime diff --git a/packages/config/tool/runtime_test_runner.dart b/packages/config/tool/runtime_test_runner.dart deleted file mode 100644 index f4302d60a3..0000000000 --- a/packages/config/tool/runtime_test_runner.dart +++ /dev/null @@ -1,72 +0,0 @@ -// ignore_for_file: avoid_print -import 'dart:async'; -import 'dart:io'; - -import 'package:conduit_runtime/runtime.dart'; - -Future main(List args) async { - final blacklist = ["no_default_constructor_test.dart"]; - final testFiles = Directory.fromUri(Directory.current.uri.resolve("test/")) - .listSync(recursive: true) - .whereType() - .where((f) => f.path.endsWith("_test.dart")) - .where( - (f) => blacklist - .where((blacklisted) => f.uri.path.endsWith(blacklisted)) - .isEmpty, - ) - .toList(); - - var remainingCounter = testFiles.length; - var passCounter = 0; - var failCounter = 0; - void prompt() => print( - """ -Test Files: - Pass : $passCounter - Fail : $failCounter - Remain: $remainingCounter - """, - ); - for (final f in testFiles) { - prompt(); - print("Loading test ${f.path}..."); - final ctx = BuildContext( - Directory.current.uri.resolve("lib/").resolve("conduit_config.dart"), - Directory.current.uri.resolve("build/"), - Directory.current.uri.resolve("run"), - f.readAsStringSync(), - forTests: true, - ); - final bm = BuildManager(ctx); - await bm.build(); - - print("Running tests derived from ${f.path}..."); - final result = await Process.start( - "dart", - ["test/main_test.dart"], - workingDirectory: - ctx.buildDirectoryUri.toFilePath(windows: Platform.isWindows), - environment: { - "TEST_BOOL": "true", - "TEST_DB_ENV_VAR": "postgres://user:password@host:5432/dbname", - "TEST_VALUE": "1" - }, - ); - // ignore: unawaited_futures - stdout.addStream(result.stdout); - // ignore: unawaited_futures - stderr.addStream(result.stderr); - - if (await result.exitCode != 0) { - exitCode = -1; - failCounter++; - print("Tests FAILED in ${f.path}."); - } else { - passCounter++; - } - await bm.clean(); - remainingCounter--; - } - prompt(); -} diff --git a/packages/fs_test_agent/.github/workflows/dart.yml b/packages/fs_test_agent/.github/workflows/dart.yml deleted file mode 100644 index d102b2dbb4..0000000000 --- a/packages/fs_test_agent/.github/workflows/dart.yml +++ /dev/null @@ -1,33 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Dart - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: dart-lang/setup-dart@v1 - - - name: Install dependencies - run: dart pub get - - - name: Verify formatting - run: dart format --output=none --set-exit-if-changed . - - - name: Analyze project source - run: dart analyze --fatal-infos - - - name: Run tests - run: dart test diff --git a/packages/fs_test_agent/lib/dart_project_agent.dart b/packages/fs_test_agent/lib/dart_project_agent.dart index e5cc8e68b5..5b7e764a83 100644 --- a/packages/fs_test_agent/lib/dart_project_agent.dart +++ b/packages/fs_test_agent/lib/dart_project_agent.dart @@ -3,11 +3,10 @@ /// More dartdocs go here. import 'dart:io'; +import 'package:fs_test_agent/working_directory_agent.dart'; import 'package:path/path.dart'; import 'package:pubspec/pubspec.dart'; -import 'working_directory_agent.dart'; - /// A [WorkingDirectoryAgent] with additional behavior for managing a 'Dart package' directory. class DartProjectAgent extends WorkingDirectoryAgent { /// Creates a new package and terminal on that package's working directory. diff --git a/packages/fs_test_agent/lib/src/version/version.g.dart b/packages/fs_test_agent/lib/src/version/version.g.dart deleted file mode 100644 index 468f58b546..0000000000 --- a/packages/fs_test_agent/lib/src/version/version.g.dart +++ /dev/null @@ -1,3 +0,0 @@ -/// GENERATED BY pub_release do not modify. -/// fs_test_agent version -String packageVersion = '3.1.0'; diff --git a/packages/fs_test_agent/pubspec.yaml b/packages/fs_test_agent/pubspec.yaml index 7d05706ae3..94b1e45a22 100644 --- a/packages/fs_test_agent/pubspec.yaml +++ b/packages/fs_test_agent/pubspec.yaml @@ -9,4 +9,4 @@ dependencies: pubspec: ^2.0.1 dev_dependencies: lint: ^1.0.0 - test: ^1.16.4 + test: ^1.21.6 diff --git a/packages/isolate_exec/.github/workflows/dart.yml b/packages/isolate_exec/.github/workflows/dart.yml deleted file mode 100644 index f66d6b505f..0000000000 --- a/packages/isolate_exec/.github/workflows/dart.yml +++ /dev/null @@ -1,35 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Dart - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: dart-lang/setup-dart@v1 - with: - sdk: stable - - - name: Install dependencies - run: dart pub get - - - name: Verify formatting - run: dart format --output=none --set-exit-if-changed . - - - name: Analyze project source - run: dart analyze --fatal-infos - - - name: Run tests - run: dart test -j1 diff --git a/packages/isolate_exec/lib/src/executor.dart b/packages/isolate_exec/lib/src/executor.dart index c2ff379f03..8ecfbdd1f9 100644 --- a/packages/isolate_exec/lib/src/executor.dart +++ b/packages/isolate_exec/lib/src/executor.dart @@ -38,6 +38,7 @@ class IsolateExecutor { ..listen((err) async { if (err is List) { final stack = + // ignore: avoid_dynamic_calls StackTrace.fromString(err.last.replaceAll(scriptSource, "")); completer.completeError(StateError(err.first), stack); @@ -65,23 +66,15 @@ class IsolateExecutor { final dataUri = Uri.parse( "data:application/dart;charset=utf-8,$scriptSource", ); - if (packageConfigURI != null) { - await Isolate.spawnUri( - dataUri, - [], - message, - onError: onErrorPort.sendPort, - packageConfig: packageConfigURI, - ); - } else { - await Isolate.spawnUri( - dataUri, - [], - message, - onError: onErrorPort.sendPort, - automaticPackageResolution: true, - ); - } + + await Isolate.spawnUri( + dataUri, + [], + message, + onError: onErrorPort.sendPort, + packageConfig: packageConfigURI, + automaticPackageResolution: packageConfigURI == null, + ); return await completer.future; } finally { onErrorPort.close(); diff --git a/packages/isolate_exec/lib/src/source_generator.dart b/packages/isolate_exec/lib/src/source_generator.dart index 80e5b8f091..3a4ee7b54f 100644 --- a/packages/isolate_exec/lib/src/source_generator.dart +++ b/packages/isolate_exec/lib/src/source_generator.dart @@ -69,12 +69,12 @@ Future main (List args, Map message) async { final context = _createContext(path); final session = context.currentSession; - final unit = session.getParsedUnit2(path) as ParsedUnitResult; + final unit = session.getParsedUnit(path) as ParsedUnitResult; final typeName = MirrorSystem.getName(reflectClass(type).simpleName); return unit.unit.declarations .whereType() - .firstWhere((classDecl) => classDecl.name.name == typeName); + .firstWhere((classDecl) => classDecl.name.value() == typeName); } } diff --git a/packages/isolate_exec/lib/src/version/version.g.dart b/packages/isolate_exec/lib/src/version/version.g.dart deleted file mode 100644 index d57c483e75..0000000000 --- a/packages/isolate_exec/lib/src/version/version.g.dart +++ /dev/null @@ -1,3 +0,0 @@ -/// GENERATED BY pub_release do not modify. -/// conduit_isolate_exec version -String packageVersion = '3.1.0'; diff --git a/packages/isolate_exec/pubspec.yaml b/packages/isolate_exec/pubspec.yaml index 5066baeba6..0eeb31d215 100644 --- a/packages/isolate_exec/pubspec.yaml +++ b/packages/isolate_exec/pubspec.yaml @@ -5,11 +5,11 @@ description: This library contains types that allow for executing code in a spaw environment: sdk: ">=2.12.0 <3.0.0" dependencies: - analyzer: ^1.3.0 + analyzer: ^5.1.0 glob: ^2.0.0 dev_dependencies: lint: ^1.5.3 path: ^1.8.0 - test: ^1.6.5 + test: ^1.21.6 test_package: path: ../isolate_exec_test_packages/test_package diff --git a/packages/isolate_exec/test/isolate_executor_test.dart b/packages/isolate_exec/test/isolate_executor_test.dart index c9e41f32d0..0c8bfb36bc 100644 --- a/packages/isolate_exec/test/isolate_executor_test.dart +++ b/packages/isolate_exec/test/isolate_executor_test.dart @@ -198,6 +198,7 @@ class AdditionalContentsInstantiator extends Executable { @override Future execute() async { final obj = instanceOf("AdditionalContents"); + // ignore: avoid_dynamic_calls return obj.id; } } diff --git a/packages/open_api/.github/workflows/dart.yml b/packages/open_api/.github/workflows/dart.yml deleted file mode 100644 index f66d6b505f..0000000000 --- a/packages/open_api/.github/workflows/dart.yml +++ /dev/null @@ -1,35 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Dart - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: dart-lang/setup-dart@v1 - with: - sdk: stable - - - name: Install dependencies - run: dart pub get - - - name: Verify formatting - run: dart format --output=none --set-exit-if-changed . - - - name: Analyze project source - run: dart analyze --fatal-infos - - - name: Run tests - run: dart test -j1 diff --git a/packages/open_api/lib/src/version/version.g.dart b/packages/open_api/lib/src/version/version.g.dart deleted file mode 100644 index c481957843..0000000000 --- a/packages/open_api/lib/src/version/version.g.dart +++ /dev/null @@ -1,3 +0,0 @@ -/// GENERATED BY pub_release do not modify. -/// conduit_open_api version -String packageVersion = '3.1.0'; diff --git a/packages/open_api/overrides.yaml b/packages/open_api/overrides.yaml new file mode 100644 index 0000000000..fc0e984183 --- /dev/null +++ b/packages/open_api/overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + conduit_codable: + path: ../codable \ No newline at end of file diff --git a/packages/open_api/pubspec.yaml b/packages/open_api/pubspec.yaml index ce24a352e9..fafa510df3 100644 --- a/packages/open_api/pubspec.yaml +++ b/packages/open_api/pubspec.yaml @@ -10,3 +10,6 @@ dependencies: dev_dependencies: lint: ^1.5.3 test: ^1.3.0 +dependency_overrides: + conduit_codable: + path: ../codable diff --git a/packages/password_hash/.github/workflows/dart.yml b/packages/password_hash/.github/workflows/dart.yml deleted file mode 100644 index 9836344e3b..0000000000 --- a/packages/password_hash/.github/workflows/dart.yml +++ /dev/null @@ -1,33 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Dart - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: dart-lang/setup-dart@v1 - - - name: Install dependencies - run: dart pub get - - - name: Verify formatting - run: dart format --output=none --set-exit-if-changed . - - - name: Run tests - run: dart test -j1 - - - name: Analyze project source - run: dart analyze --fatal-infos diff --git a/packages/password_hash/lib/src/version/version.g.dart b/packages/password_hash/lib/src/version/version.g.dart deleted file mode 100644 index a4555d68d5..0000000000 --- a/packages/password_hash/lib/src/version/version.g.dart +++ /dev/null @@ -1,3 +0,0 @@ -/// GENERATED BY pub_release do not modify. -/// conduit_password_hash version -String packageVersion = '3.1.0'; diff --git a/packages/password_hash/pubspec.yaml b/packages/password_hash/pubspec.yaml index 0b7f3b52d7..77d7508848 100644 --- a/packages/password_hash/pubspec.yaml +++ b/packages/password_hash/pubspec.yaml @@ -5,7 +5,7 @@ description: PBKDF2 password hashing utility environment: sdk: '>=2.12.0 <3.0.0' dependencies: - crypto: ^3.0.0 + crypto: ^3.0.2 dev_dependencies: lint: ^1.5.0 - test: ^1.16.5 + test: ^1.21.6 diff --git a/packages/password_hash/test/pbkdf2_test.dart b/packages/password_hash/test/pbkdf2_test.dart index 38220ee6f8..242f1a2e27 100644 --- a/packages/password_hash/test/pbkdf2_test.dart +++ b/packages/password_hash/test/pbkdf2_test.dart @@ -36,7 +36,7 @@ void main() { group("RFC6070", () { test("Disallow large values of derived key length", () { - final sha = sha1; + const sha = sha1; final hLen = sha.blockSize; final gen = PBKDF2(hashAlgorithm: sha); @@ -121,7 +121,7 @@ void main() { group("Sha256", () { test("Disallow large values of derived key length", () { - final sha = sha256; + const sha = sha256; final hLen = sha.blockSize; final gen = PBKDF2(hashAlgorithm: sha); diff --git a/packages/runtime/.github/workflows/dart.yml b/packages/runtime/.github/workflows/dart.yml deleted file mode 100644 index 3bc4c3c1e2..0000000000 --- a/packages/runtime/.github/workflows/dart.yml +++ /dev/null @@ -1,41 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Dart - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: dart-lang/setup-dart@v1 - - - name: Install dependencies - run: dart pub get - - - name: Install dependencies in test package 'dependency' - working-directory: ./test/test_packages/dependency - run: dart pub get - - - name: Install dependencies in test package 'application' - working-directory: ./test/test_packages/application - run: dart pub get - - - name: Analyze project source - run: dart analyze --fatal-infos - - - name: Verify formatting - run: dart format --output=none --set-exit-if-changed . - - - name: Run tests - run: dart test -j1 diff --git a/packages/runtime/lib/src/analyzer.dart b/packages/runtime/lib/src/analyzer.dart index 31a7e8712e..d53141aba8 100644 --- a/packages/runtime/lib/src/analyzer.dart +++ b/packages/runtime/lib/src/analyzer.dart @@ -46,11 +46,9 @@ class CodeAnalyzer { return _resolvedAsts[path]! as ResolvedLibraryResult; } - final output = await ctx.currentSession.getResolvedLibrary2(path) + final output = await ctx.currentSession.getResolvedLibrary(path) as ResolvedLibraryResult; - if (output.state == ResultState.VALID) { - return _resolvedAsts[path] = output; - } + return _resolvedAsts[path] = output; } throw ArgumentError("'uri' could not be resolved (contexts: " @@ -67,10 +65,8 @@ class CodeAnalyzer { } final output = - await ctx.currentSession.getResolvedUnit2(path) as ResolvedUnitResult; - if (output.state == ResultState.VALID) { - return _resolvedAsts[path] = output; - } + await ctx.currentSession.getResolvedUnit(path) as ResolvedUnitResult; + return _resolvedAsts[path] = output; } throw ArgumentError("'uri' could not be resolved (contexts: " @@ -82,7 +78,7 @@ class CodeAnalyzer { return _getFileAstRoot(fileUri) .declarations .whereType() - .firstWhere((c) => c.name.name == className); + .firstWhere((c) => c.name.value() == className); } catch (e) { if (e is StateError || e is TypeError) { print(e); @@ -107,7 +103,7 @@ class CodeAnalyzer { try { final path = getPath(fileUri); if (_resolvedAsts.containsKey(path)) { - return (_resolvedAsts[path]! as ResolvedUnitResult).unit!; + return (_resolvedAsts[path]! as ResolvedUnitResult).unit; } } catch (e) { print(e); @@ -115,13 +111,7 @@ class CodeAnalyzer { final unit = contexts .contextFor(path) .currentSession - .getParsedUnit2(fileUri.path) as ParsedUnitResult; - if (unit.errors.isNotEmpty) { - throw StateError( - "Project file '$path' could not be analysed for the " - "following reasons:\n\t${unit.errors.join('\n\t')}", - ); - } + .getParsedUnit(fileUri.path) as ParsedUnitResult; return unit.unit; } diff --git a/packages/runtime/lib/src/build_context.dart b/packages/runtime/lib/src/build_context.dart index c95de2db98..4ee05ed7b9 100644 --- a/packages/runtime/lib/src/build_context.dart +++ b/packages/runtime/lib/src/build_context.dart @@ -197,24 +197,35 @@ class BuildContext { MirrorSystem.getName(classMirror.simpleName), uri); } + Future _getField(ClassMirror type, String propertyName) { + return getClassDeclarationFromType(type.reflectedType).then((cd) { + try { + return cd!.members.firstWhere((m) => (m as FieldDeclaration) + .fields + .variables + .any((v) => v.name.value() == propertyName)) as FieldDeclaration; + } catch (e) { + return null; + } + }); + } + Future> getAnnotationsFromField( Type _type, String propertyName) async { var type = reflectClass(_type); - var field = (await getClassDeclarationFromType(type.reflectedType)) - ?.getField(propertyName); + FieldDeclaration? field = await _getField(type, propertyName); while (field == null) { type = type.superclass!; if (type.reflectedType == Object) { break; } - field = (await getClassDeclarationFromType(type.reflectedType)) - ?.getField(propertyName); + field = await _getField(type, propertyName); } if (field == null) { return []; } - return (field.parent!.parent! as FieldDeclaration).metadata.toList(); + return field.metadata; } } diff --git a/packages/runtime/lib/src/build_manager.dart b/packages/runtime/lib/src/build_manager.dart index 790c1f5edb..05cc87ceef 100644 --- a/packages/runtime/lib/src/build_manager.dart +++ b/packages/runtime/lib/src/build_manager.dart @@ -3,7 +3,6 @@ import 'dart:io'; import 'package:analyzer/dart/analysis/results.dart'; import 'package:analyzer/dart/ast/ast.dart'; -import 'package:package_config/package_config.dart'; import 'package:conduit_isolate_exec/conduit_isolate_exec.dart'; import 'package:conduit_runtime/runtime.dart'; @@ -42,11 +41,11 @@ class BuildManager { final analyzer = CodeAnalyzer(strippedScriptFile.absolute.uri); final analyzerContext = analyzer.contexts.contextFor(analyzer.path); final parsedUnit = analyzerContext.currentSession - .getParsedUnit2(analyzer.path) as ParsedUnitResult; + .getParsedUnit(analyzer.path) as ParsedUnitResult; final mainFunctions = parsedUnit.unit.declarations .whereType() - .where((f) => f.name.name == "main") + .where((f) => f.name == "main") .toList(); for (final f in mainFunctions.reversed) { diff --git a/packages/runtime/lib/src/version/version.g.dart b/packages/runtime/lib/src/version/version.g.dart deleted file mode 100644 index 91c31002ca..0000000000 --- a/packages/runtime/lib/src/version/version.g.dart +++ /dev/null @@ -1,3 +0,0 @@ -/// GENERATED BY pub_release do not modify. -/// conduit_runtime version -String packageVersion = '3.1.0'; diff --git a/packages/runtime/overrides.yaml b/packages/runtime/overrides.yaml new file mode 100644 index 0000000000..1a1220538c --- /dev/null +++ b/packages/runtime/overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + conduit_isolate_exec: + path: ../isolate_exec \ No newline at end of file diff --git a/packages/runtime/pubspec.yaml b/packages/runtime/pubspec.yaml index 87eb993577..662c396305 100644 --- a/packages/runtime/pubspec.yaml +++ b/packages/runtime/pubspec.yaml @@ -5,7 +5,7 @@ repository: https://github.com/conduit-dart/conduit-runtime environment: sdk: '>=2.12.0 <3.0.0' dependencies: - analyzer: ^1.2.0 + analyzer: ^5.1.0 args: ^2.0.0 conduit_isolate_exec: ^3.2.2 package_config: ^2.1.0 @@ -14,6 +14,9 @@ dependencies: yaml: ^3.1.0 dev_dependencies: lint: ^1.5.0 - test: ^1.16.5 + test: ^1.21.6 fs_test_agent: path: ../fs_test_agent +dependency_overrides: + conduit_isolate_exec: + path: ../isolate_exec diff --git a/packages/runtime/test/build_test.dart b/packages/runtime/test/build_test.dart index 429efdccf3..79ae353372 100644 --- a/packages/runtime/test/build_test.dart +++ b/packages/runtime/test/build_test.dart @@ -42,7 +42,7 @@ void main() { }); tearDownAll(() { - // Directory.fromUri(tmp).deleteSync(recursive: true); + Directory.fromUri(tmp).deleteSync(recursive: true); }); test("Non-compiled version returns mirror runtimes", () async { diff --git a/packages/runtime/test/project_analyzer_test.dart b/packages/runtime/test/project_analyzer_test.dart index edb39c41a4..b976d77bed 100644 --- a/packages/runtime/test/project_analyzer_test.dart +++ b/packages/runtime/test/project_analyzer_test.dart @@ -18,7 +18,7 @@ void main() { final klass = p.getClassFromFile("ConsumerSubclass", terminal.libraryDirectory.absolute.uri.resolve("application.dart")); expect(klass, isNotNull); - expect(klass!.name.name, "ConsumerSubclass"); + expect(klass!.name.value(), "ConsumerSubclass"); expect(klass.extendsClause!.superclass.name.name, "Consumer"); }); } diff --git a/packages/runtime_test_packages/application/pubspec.yaml b/packages/runtime_test_packages/application/pubspec.yaml index afe37bb845..26f16e13db 100644 --- a/packages/runtime_test_packages/application/pubspec.yaml +++ b/packages/runtime_test_packages/application/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: dev_dependencies: lint: ^1.5.0 - test: ^1.16.5 + test: ^1.21.6 dependency_overrides: conduit_isolate_exec: diff --git a/packages/runtime_test_packages/dependency/pubspec.yaml b/packages/runtime_test_packages/dependency/pubspec.yaml index 7a369b0f89..d43932b8a7 100644 --- a/packages/runtime_test_packages/dependency/pubspec.yaml +++ b/packages/runtime_test_packages/dependency/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: dev_dependencies: lint: ^1.5.0 - test: ^1.16.5 + test: ^1.21.6 dependency_overrides: conduit_isolate_exec: diff --git a/packages/test_harness/lib/src/matchers.dart b/packages/test_harness/lib/src/matchers.dart index 82c03e75e4..988661a577 100644 --- a/packages/test_harness/lib/src/matchers.dart +++ b/packages/test_harness/lib/src/matchers.dart @@ -1,5 +1,4 @@ import 'package:test/test.dart'; -import 'package:matcher/matcher.dart'; import 'agent.dart'; import 'body_matcher.dart'; diff --git a/packages/test_harness/lib/src/version/version.g.dart b/packages/test_harness/lib/src/version/version.g.dart deleted file mode 100644 index e3e010db73..0000000000 --- a/packages/test_harness/lib/src/version/version.g.dart +++ /dev/null @@ -1,3 +0,0 @@ -/// GENERATED BY pub_release do not modify. -/// conduit_test version -String packageVersion = '3.1.0'; diff --git a/packages/test_harness/overrides.yaml b/packages/test_harness/overrides.yaml new file mode 100644 index 0000000000..f53e36a65e --- /dev/null +++ b/packages/test_harness/overrides.yaml @@ -0,0 +1,17 @@ +dependency_overrides: + conduit: + path: ../conduit + conduit_codable: + path: ../codable + conduit_common: + path: ../common + conduit_config: + path: ../config + conduit_isolate_exec: + path: ../isolate_exec + conduit_open_api: + path: ../open_api + conduit_password_hash: + path: ../password_hash + conduit_runtime: + path: ../runtime \ No newline at end of file diff --git a/packages/test_harness/pubspec.yaml b/packages/test_harness/pubspec.yaml index 6de35da222..60a6c0e1e1 100644 --- a/packages/test_harness/pubspec.yaml +++ b/packages/test_harness/pubspec.yaml @@ -5,10 +5,27 @@ description: Utilities for writing automated tests for Conduit applications environment: sdk: ">=2.12.0 <3.0.0" dependencies: - test: ^1.16.5 - matcher: ">=0.12.3 <0.14.0" + test: ^1.21.6 + matcher: ^0.12.12 conduit: ^3.2.3 dev_dependencies: conduit_common_test: path: ../common_test - test_core: ^0.3.29 + test_core: ^0.4.18 +dependency_overrides: + conduit: + path: ../conduit + conduit_codable: + path: ../codable + conduit_common: + path: ../common + conduit_config: + path: ../config + conduit_isolate_exec: + path: ../isolate_exec + conduit_open_api: + path: ../open_api + conduit_password_hash: + path: ../password_hash + conduit_runtime: + path: ../runtime diff --git a/utils/pubspec.yaml b/utils/pubspec.yaml index 8c3692d44c..8bb9b3f077 100644 --- a/utils/pubspec.yaml +++ b/utils/pubspec.yaml @@ -2,4 +2,4 @@ name: utils environment: sdk: ">=2.12.0 <3.0.0" dependencies: - test: ^1.16.5 \ No newline at end of file + test: ^1.21.6 \ No newline at end of file