diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2485ca4..301f426 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: dart run build_runner build --delete-conflicting-outputs - name: Setup Test Database - run: dart run ./bin/tools/migrator.dart migrate + run: dart run --enable-asserts ./bin/tools/migrator.dart migrate - name: Run Tests run: | diff --git a/README.md b/README.md index e55b118..21c19ba 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ $ dart pub get && dart run build_runner build --delete-conflicting-outputs ### Migrate Database Prepare the database **(default: SQLite)** by running the command below. This will create the necessary -tables in the database. You can change the database by editing the `config/database.dart` file. +tables in the database. You can change the database by editing the `database/config.dart` file. Currently supports `MariaB`, `MySQL`, `PostgreSQL` and `SQLite`. @@ -21,11 +21,10 @@ Currently supports `MariaB`, `MySQL`, `PostgreSQL` and `SQLite`. $ dart run bin/tools/migrator.dart migrate ``` -NB: There are only 3 commands for now. `migrate`, `migrate:reset` and `migrate:rollback` and they do -exactly what they are called. +You can run the command below to see which commands are available on the migrator. ```shell -$ dart run bin/tools/migrator.dart +$ dart run bin/tools/migrator.dart ``` ### Start Server diff --git a/database/config.dart b/database/config.dart index 731c9a2..408ae39 100644 --- a/database/config.dart +++ b/database/config.dart @@ -1,3 +1,4 @@ +import 'package:backend/backend.dart'; import 'package:path/path.dart' as path; import 'package:yaroo/yaroo.dart'; import 'package:yaroorm/yaroorm.dart'; @@ -6,13 +7,9 @@ import './migrations/create_articles_table.dart'; import './migrations/create_users_table.dart'; final config = YaroormConfig( - env('DB_CONNECTION', 'test_db'), + isDebugMode ? 'test_db' : 'mysql', connections: [ - DatabaseConnection( - 'test_db', - DatabaseDriverType.sqlite, - database: env('DB_DATABASE', path.absolute('database', 'db.sqlite')), - ), + DatabaseConnection('test_db', DatabaseDriverType.sqlite, database: path.absolute('database', 'db.sqlite')), DatabaseConnection( 'mysql', DatabaseDriverType.mysql, diff --git a/lib/backend.dart b/lib/backend.dart index dfbfd83..d9637bb 100644 --- a/lib/backend.dart +++ b/lib/backend.dart @@ -14,19 +14,18 @@ export 'src/controllers/controllers.dart'; export 'src/models/models.dart'; export 'src/models/dto/dto.dart'; -bool get isTestMode { +bool get isDebugMode { var isDebug = false; assert(() { isDebug = true; return true; }()); - return isDebug; } final blogApp = App(AppConfig( name: 'Dart Blog', - environment: env('APP_ENV', isTestMode ? 'test' : 'development'), + environment: env('APP_ENV', isDebugMode ? 'test' : 'development'), isDebug: env('APP_DEBUG', true), url: env('APP_URL', 'http://localhost'), port: env('PORT', 80), diff --git a/pubspec.lock b/pubspec.lock index f245e9a..8184509 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a url: "https://pub.dev" source: hosted - version: "64.0.0" + version: "61.0.0" adaptive_number: dependency: transitive description: @@ -21,10 +21,10 @@ packages: dependency: transitive description: name: analyzer - sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 url: "https://pub.dev" source: hosted - version: "6.2.0" + version: "5.13.0" ansi_styles: dependency: transitive description: @@ -245,10 +245,10 @@ packages: dependency: transitive description: name: dart_style - sha256: "40ae61a5d43feea6d24bd22c0537a6629db858963b99b4bc1c3db80676f32368" + sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55" url: "https://pub.dev" source: hosted - version: "2.3.4" + version: "2.3.2" dotenv: dependency: transitive description: @@ -636,13 +636,12 @@ packages: source: hosted version: "4.1.0" reflectable: - dependency: transitive + dependency: "direct overridden" description: - path: reflectable - ref: HEAD - resolved-ref: e205b5313d540eecdf75422d5555f2b1ba8e77a3 - url: "https://github.com/codekeyz/reflectable.dart.git" - source: git + name: reflectable + sha256: "775388897bfce5b1d0386b7160706367b565cdc72b5870bc6a198d0f7be1aa0b" + url: "https://pub.dev" + source: hosted version: "4.0.5" sasl_scram: dependency: transitive @@ -985,7 +984,7 @@ packages: description: path: "packages/yaroo" ref: HEAD - resolved-ref: cad334d5a29ef204f3f770614870780fe5ff7b39 + resolved-ref: "44bf4297c219155230f03a0826e88d067b325c22" url: "https://github.com/codekeyz/yaroo.git" source: git version: "0.0.1" @@ -994,18 +993,17 @@ packages: description: path: "packages/yaroo_cli" ref: HEAD - resolved-ref: cad334d5a29ef204f3f770614870780fe5ff7b39 + resolved-ref: "44bf4297c219155230f03a0826e88d067b325c22" url: "https://github.com/codekeyz/yaroo.git" source: git version: "1.0.0" yaroorm: dependency: "direct main" description: - path: "packages/yaroorm" - ref: HEAD - resolved-ref: cad334d5a29ef204f3f770614870780fe5ff7b39 - url: "https://github.com/codekeyz/yaroo.git" - source: git - version: "1.0.0" + name: yaroorm + sha256: "29f299a2c26dcdd3aa93385beaa41fb6a0a6e537e5401fbb8059ed2fafeb425a" + url: "https://pub.dev" + source: hosted + version: "0.0.1" sdks: dart: ">=3.2.2 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 9aaba73..1e87d61 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,16 +18,16 @@ dependencies: git: url: https://github.com/codekeyz/yaroo.git path: packages/yaroo - yaroorm: - git: - url: https://github.com/codekeyz/yaroo.git - path: packages/yaroorm + yaroorm: ^0.0.1 collection: ^1.18.0 logger: ^2.0.2+1 dart_jsonwebtoken: ^2.12.2 json_annotation: ^4.8.1 +dependency_overrides: + reflectable: + dev_dependencies: lints: ^3.0.0 test: ^1.24.0 diff --git a/test/backend_test.dart b/test/backend_test.dart index 05e9133..4180875 100644 --- a/test/backend_test.dart +++ b/test/backend_test.dart @@ -4,25 +4,14 @@ import 'dart:io'; import 'package:backend/backend.dart'; import 'package:yaroo/yaroo.dart'; import 'package:yaroorm/yaroorm.dart'; -import 'package:path/path.dart' as path; +import '../database/config.dart' as orm; import 'backend_test.reflectable.dart'; -final ormConfig = YaroormConfig( - 'sqlite', - connections: [ - DatabaseConnection( - 'sqlite', - DatabaseDriverType.sqlite, - database: path.absolute('database', 'db.sqlite'), - ), - ], -); - void main() { initializeReflectable(); - DB.init(ormConfig); + DB.init(orm.config); late Spookie blogAppTester;