From 8e9e7fc291311918e6b81b8bbfdc5f11b45ad9a4 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Thu, 15 Sep 2022 23:42:20 +0200 Subject: [PATCH] Use melos to manage packages (#2060) --- .github/workflows/main.yml | 11 +++-- .gitignore | 1 + README.md | 13 +++++- docs/pubspec.yaml | 7 --- drift/pubspec_overrides.yaml | 5 --- drift_dev/pubspec_overrides.yaml | 5 --- drift_sqflite/pubspec.yaml | 4 -- examples/app/pubspec.yaml | 10 ----- examples/encryption/pubspec_overrides.yaml | 10 ----- .../flutter_web_worker_example/pubspec.yaml | 8 ---- examples/migrations_example/pubspec.yaml | 8 ---- examples/web_worker_example/pubspec.yaml | 8 ---- examples/with_built_value/pubspec.yaml | 8 ---- .../lib/database/database.g.dart | 7 +-- extras/tooling/bin/list_public_api.dart | 28 ------------ extras/tooling/pubspec.yaml | 10 ----- melos.yaml | 40 +++++++++++++++++ tool/generate_all.sh | 24 +--------- tool/license.sh | 9 ---- tool/test_all.sh | 45 +------------------ tool/upgrade_all.sh | 3 +- 21 files changed, 68 insertions(+), 196 deletions(-) delete mode 100644 drift/pubspec_overrides.yaml delete mode 100644 drift_dev/pubspec_overrides.yaml delete mode 100644 examples/encryption/pubspec_overrides.yaml delete mode 100644 extras/tooling/bin/list_public_api.dart delete mode 100644 extras/tooling/pubspec.yaml create mode 100644 melos.yaml delete mode 100755 tool/license.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d751a0e9..08192aad 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,7 +67,8 @@ jobs: echo "LD_LIBRARY_PATH=/tmp/sqlite/out" >> $GITHUB_ENV - name: Check sqlite3 version run: sqlite3 --version - - run: dart pub upgrade + - run: dart pub global activate melos && melos bootstrap --scope drift_docs + working-directory: . - run: dart run build_runner build - run: dart test @@ -94,7 +95,8 @@ jobs: echo "LD_LIBRARY_PATH=/tmp/sqlite/out" >> $GITHUB_ENV - name: Check sqlite3 version run: sqlite3 --version - - run: dart pub upgrade + - run: dart pub global activate melos && melos bootstrap --scope drift + working-directory: . - name: Get dependencies for plugin run: | echo "dependency_overrides:" >> pubspec_overrides.yaml @@ -128,7 +130,8 @@ jobs: # setup - uses: actions/checkout@v2 - uses: dart-lang/setup-dart@v1 - - run: dart pub upgrade + - run: dart pub global activate melos && melos bootstrap --scope drift_dev + working-directory: . # analysis - run: dart format -o none --set-exit-if-changed . name: dartfmt @@ -202,6 +205,8 @@ jobs: chmod a+x /tmp/sqlite/out/sqlite3 echo "/tmp/sqlite/out" >> $GITHUB_PATH echo "LD_LIBRARY_PATH=/tmp/sqlite/out" >> $GITHUB_ENV + - run: dart pub global activate melos && melos bootstrap --no-flutter + working-directory: . - run: tool/misc_integration_test.sh # upload_coverage: diff --git a/.gitignore b/.gitignore index dc2b7f41..b6457397 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ flutter_export_environment.sh docs/**/*.g.dart */build/ +**/pubspec_overrides.yaml diff --git a/README.md b/README.md index 8375a9f6..0df640d6 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ _Note: Moor has been renamed to drift_ [![Build Status](https://api.cirrus-ci.com/github/simolus3/moor.svg)](https://github.com/simolus3/drift/actions/workflows/main.yml/badge.svg) [![Chat on Gitter](https://img.shields.io/gitter/room/moor-dart/community)](https://gitter.im/moor-dart/community) +[![Using melos](https://img.shields.io/badge/maintained%20with-melos-f700ff.svg?style=flat-square)](https://github.com/invertase/melos) ## Proudly Sponsored by [Stream 💙](https://getstream.io/chat/sdk/android/?utm_source=Moor&utm_medium=Github_Repo_Content_Ad&utm_content=Developer&utm_campaign=Moor_July2022_AndroidChatSDK_klmh22) @@ -52,9 +53,10 @@ If you have any questions, feedback or ideas, feel free to [create an issue](https://github.com/simolus3/drift/issues/new). If you enjoy this project, I'd appreciate your [🌟 on GitHub](https://github.com/simolus3/drift/). ------ +## Working on this project -Important packages in this repo: +This repository contains a number of packages making up the drift project, most +notably: - `drift`: The main runtime for drift, which provides most apis - `drift_dev`: The compiler for drift tables, databases and daos. It @@ -62,3 +64,10 @@ Important packages in this repo: - `sqlparser`: A sql parser and static analyzer, written in pure Dart. This package can be used without drift to perform analysis on sql statements. It's on pub at [![sqlparser](https://img.shields.io/pub/v/sqlparser.svg)](https://pub.dev/packages/sqlparser) + +We use [melos](https://melos.invertase.dev/) to manage the different packages +in this repository. + +You can install it with `dart pub global activate melos`. If your Dart SDK was +installed as part of Flutter, you can then run `melos bootstrap` to provision +all dependencies. Otherwise, run `flutter pub global run melos bootstrap`. diff --git a/docs/pubspec.yaml b/docs/pubspec.yaml index a4a60f83..94a21755 100644 --- a/docs/pubspec.yaml +++ b/docs/pubspec.yaml @@ -45,13 +45,6 @@ dev_dependencies: dependency_overrides: - drift: - path: ../drift - drift_dev: - path: ../drift_dev - sqlparser: - path: ../sqlparser - # todo: Remove after https://github.com/dart-lang/mime/pull/43 mime: git: diff --git a/drift/pubspec_overrides.yaml b/drift/pubspec_overrides.yaml deleted file mode 100644 index 34155257..00000000 --- a/drift/pubspec_overrides.yaml +++ /dev/null @@ -1,5 +0,0 @@ -dependency_overrides: - drift_dev: - path: ../drift_dev - sqlparser: - path: ../sqlparser diff --git a/drift_dev/pubspec_overrides.yaml b/drift_dev/pubspec_overrides.yaml deleted file mode 100644 index ba6a3b11..00000000 --- a/drift_dev/pubspec_overrides.yaml +++ /dev/null @@ -1,5 +0,0 @@ -dependency_overrides: - drift: - path: ../drift - sqlparser: - path: ../sqlparser diff --git a/drift_sqflite/pubspec.yaml b/drift_sqflite/pubspec.yaml index 1e517580..10977b1a 100644 --- a/drift_sqflite/pubspec.yaml +++ b/drift_sqflite/pubspec.yaml @@ -24,10 +24,6 @@ dev_dependencies: drift_testcases: path: ../extras/integration_tests/drift_testcases -dependency_overrides: - drift: - path: ../drift/ - flutter: assets: - test_asset.db diff --git a/examples/app/pubspec.yaml b/examples/app/pubspec.yaml index 60de52c2..d97a4bf8 100644 --- a/examples/app/pubspec.yaml +++ b/examples/app/pubspec.yaml @@ -38,13 +38,3 @@ dev_dependencies: flutter: uses-material-design: true - -# We override dependencies to ensure that we always use the packages from -# this repository. In your app, just depend on the latest drift version. -dependency_overrides: - drift: - path: ../../drift - drift_dev: - path: ../../drift_dev - sqlparser: - path: ../../sqlparser diff --git a/examples/encryption/pubspec_overrides.yaml b/examples/encryption/pubspec_overrides.yaml deleted file mode 100644 index 5913138b..00000000 --- a/examples/encryption/pubspec_overrides.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# We override dependencies to ensure that we always use the packages from -# this repository. In your app, just depend on the latest drift version by -# removing the `pubspec_overrides.yaml` file. -dependency_overrides: - drift: - path: ../../drift - drift_dev: - path: ../../drift_dev - sqlparser: - path: ../../sqlparser diff --git a/examples/flutter_web_worker_example/pubspec.yaml b/examples/flutter_web_worker_example/pubspec.yaml index 7ee74adc..8f47d29f 100644 --- a/examples/flutter_web_worker_example/pubspec.yaml +++ b/examples/flutter_web_worker_example/pubspec.yaml @@ -16,11 +16,3 @@ dev_dependencies: build_web_compilers: ^3.2.1 flutter_lints: ^1.0.4 drift_dev: - -dependency_overrides: - drift: - path: ../../drift - drift_dev: - path: ../../drift_dev - sqlparser: - path: ../../sqlparser diff --git a/examples/migrations_example/pubspec.yaml b/examples/migrations_example/pubspec.yaml index 095f94f2..03f9942d 100644 --- a/examples/migrations_example/pubspec.yaml +++ b/examples/migrations_example/pubspec.yaml @@ -13,11 +13,3 @@ dev_dependencies: drift_dev: build_runner: ^2.0.0 test: ^1.15.4 - -dependency_overrides: - drift: - path: ../../drift - drift_dev: - path: ../../drift_dev - sqlparser: - path: ../../sqlparser diff --git a/examples/web_worker_example/pubspec.yaml b/examples/web_worker_example/pubspec.yaml index 4dc820ea..f5aa95fd 100644 --- a/examples/web_worker_example/pubspec.yaml +++ b/examples/web_worker_example/pubspec.yaml @@ -16,11 +16,3 @@ dev_dependencies: build_web_compilers: ^3.2.3 lints: ^2.0.0 drift_dev: - -dependency_overrides: - drift: - path: ../../drift - drift_dev: - path: ../../drift_dev - sqlparser: - path: ../../sqlparser diff --git a/examples/with_built_value/pubspec.yaml b/examples/with_built_value/pubspec.yaml index 8d476633..06e9ddb4 100644 --- a/examples/with_built_value/pubspec.yaml +++ b/examples/with_built_value/pubspec.yaml @@ -13,11 +13,3 @@ dev_dependencies: drift_dev: ^2.0.0-dev built_value_generator: ^8.1.1 build_runner: ^2.0.0 - -dependency_overrides: - drift: - path: ../../drift - drift_dev: - path: ../../drift_dev - sqlparser: - path: ../../sqlparser diff --git a/extras/integration_tests/drift_testcases/lib/database/database.g.dart b/extras/integration_tests/drift_testcases/lib/database/database.g.dart index 55e4b800..340f8815 100644 --- a/extras/integration_tests/drift_testcases/lib/database/database.g.dart +++ b/extras/integration_tests/drift_testcases/lib/database/database.g.dart @@ -108,8 +108,8 @@ class User extends DataClass implements Insertable { } @override - int get hashCode => - Object.hash(id, name, birthDate, profilePicture, preferences); + int get hashCode => Object.hash(id, name, birthDate, + $driftBlobEquality.hash(profilePicture), preferences); @override bool operator ==(Object other) => identical(this, other) || @@ -117,7 +117,8 @@ class User extends DataClass implements Insertable { other.id == this.id && other.name == this.name && other.birthDate == this.birthDate && - other.profilePicture == this.profilePicture && + $driftBlobEquality.equals( + other.profilePicture, this.profilePicture) && other.preferences == this.preferences); } diff --git a/extras/tooling/bin/list_public_api.dart b/extras/tooling/bin/list_public_api.dart deleted file mode 100644 index 5edaee2f..00000000 --- a/extras/tooling/bin/list_public_api.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'dart:io'; - -import 'package:analyzer/dart/analysis/analysis_context_collection.dart'; -import 'package:analyzer/dart/analysis/results.dart'; -import 'package:path/path.dart' as p; - -/// Lists all top-level API members of a package. -Future main() async { - final dir = Directory.current.path; - final context = - AnalysisContextCollection(includedPaths: [dir]).contextFor(dir); - - final names = {}; - - await for (final libFile in Directory(p.join(dir, 'lib')).list()) { - final result = await context.currentSession.getUnitElement(libFile.path); - - if (result is UnitElementResult) { - final ns = result.element.library.exportNamespace; - names.addAll(ns.definedNames.keys); - } else { - stderr.writeln('Could not analyze ${libFile.path}'); - } - } - - await stderr.flush(); - names.forEach(print); -} diff --git a/extras/tooling/pubspec.yaml b/extras/tooling/pubspec.yaml deleted file mode 100644 index d3db18c8..00000000 --- a/extras/tooling/pubspec.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: tooling -publish_to: none -description: Tools used during development or in CI runs - -environment: - sdk: '>=2.12.0 <3.0.0' - -dependencies: - analyzer: ^2.5.0 - path: ^1.8.0 diff --git a/melos.yaml b/melos.yaml new file mode 100644 index 00000000..24b7093a --- /dev/null +++ b/melos.yaml @@ -0,0 +1,40 @@ +name: drift +repository: https://github.com/simolus3/drift + +packages: + - docs + - drift + - drift_sqflite + - drift_dev + - sqlparser + - examples/* + - extras/benchmarks + - extras/drift_postgres + - extras/encryption + - extras/integration_tests/* + - extras/plugin_example + +command: + bootstrap: + usePubspecOverrides: true + +scripts: + check_format: + run: dart format -o none --set-exit-if-changed . + + analyze: + run: dart analyze --fatal-infos + exec: {concurrency: 1} + + build: + run: flutter pub run build_runner build --delete-conflicting-outputs + exec: {concurrency: 1} + select-package: + depends-on: build_runner + + test: + run: dart test + exec: {concurrency: 1} + select-package: + depends-on: test + ignore: drift_postgres # this is an integration test diff --git a/tool/generate_all.sh b/tool/generate_all.sh index e168f45e..b8be496f 100755 --- a/tool/generate_all.sh +++ b/tool/generate_all.sh @@ -1,24 +1,2 @@ #!/bin/bash -set -e - -function generate() { - echo "------------- Generate: $1 -------------" - pushd $1 > /dev/null - dart pub upgrade - dart run build_runner build --delete-conflicting-outputs - popd > /dev/null -} - -cd "$(dirname "$0")/.." -generate 'drift' -generate 'drift_dev' -generate 'docs' -generate 'extras/benchmarks' -generate 'extras/integration_tests/drift_testcases' -generate 'extras/integration_tests/web' -generate 'examples/app' -generate 'examples/encryption' -generate 'examples/flutter_web_worker_example' -generate 'examples/migrations_example' -generate 'examples/web_worker_example' -generate 'examples/with_built_value' \ No newline at end of file +melos run build diff --git a/tool/license.sh b/tool/license.sh deleted file mode 100755 index 9b44643e..00000000 --- a/tool/license.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -rm -f moor/LICENSE -rm -f moor_flutter/LICENSE -rm -f moor_generator/LICENSE - -cp LICENSE moor/LICENSE -cp LICENSE moor_flutter/LICENSE -cp LICENSE moor_generator/LICENSE diff --git a/tool/test_all.sh b/tool/test_all.sh index 5ee88d97..8f3049c1 100755 --- a/tool/test_all.sh +++ b/tool/test_all.sh @@ -1,45 +1,2 @@ #!/bin/bash -set -e - -function run_test() { - echo "------------- Running test: $1 -------------" - pushd $1 > /dev/null - dart pub upgrade - dart format -o none --set-exit-if-changed . - dart analyze --fatal-infos --fatal-warnings - if [[ "$2" == 'vm+web' ]]; then - dart test -p vm - dart test -p chrome - elif [[ "$2" == 'web-only' ]]; then - dart test -p chrome - else - dart test -p vm - fi - popd > /dev/null -} - -function run_test_flutter() { - echo "------------- Running flutter test: $1 -------------" - pushd $1 > /dev/null - flutter pub upgrade - flutter clean - dart format -o none --set-exit-if-changed . - flutter analyze --fatal-infos --fatal-warnings - flutter test $2 - popd > /dev/null -} - -cd .. - -if [[ "$1" == 'flutter' ]]; then - run_test_flutter 'drift_sqflite' 'integration_test' - run_test_flutter 'examples/app' - run_test_flutter 'extras/integration_tests/ffi_on_flutter' 'integration_test/drift_native.dart' -else - run_test 'drift' 'vm+web' - run_test 'drift_dev' - run_test 'sqlparser' - run_test 'examples/migrations_example' - run_test 'extras/integration_tests/web' 'web-only' - run_test 'extras/drift_postgres' -fi +melos test diff --git a/tool/upgrade_all.sh b/tool/upgrade_all.sh index 6e6f850e..90379571 100755 --- a/tool/upgrade_all.sh +++ b/tool/upgrade_all.sh @@ -1 +1,2 @@ -find ../ -name pubspec.yaml -execdir dart pub upgrade \; +#!/bin/bash +melos exec -- dart pub upgrade