Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deployment #20

Merged
merged 6 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ $ 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`.

```shell
$ 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 <command-goes-here>
$ dart run bin/tools/migrator.dart
```

### Start Server
Expand Down
9 changes: 3 additions & 6 deletions database/config.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -6,13 +7,9 @@ import './migrations/create_articles_table.dart';
import './migrations/create_users_table.dart';

final config = YaroormConfig(
env<String>('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,
Expand Down
5 changes: 2 additions & 3 deletions lib/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>('APP_ENV', isTestMode ? 'test' : 'development'),
environment: env<String>('APP_ENV', isDebugMode ? 'test' : 'development'),
isDebug: env<bool>('APP_DEBUG', true),
url: env<String>('APP_URL', 'http://localhost'),
port: env<int>('PORT', 80),
Expand Down
38 changes: 18 additions & 20 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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"
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 2 additions & 13 deletions test/backend_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading