Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.

Commit 1d1aef5

Browse files
committed
Restructure.
1 parent 624787b commit 1d1aef5

File tree

9 files changed

+343
-220
lines changed

9 files changed

+343
-220
lines changed

.github/workflows/packages.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Packages check
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Install Flutter
14+
uses: subosito/flutter-action@v2
15+
with:
16+
flutter-version: "3.x"
17+
channel: "stable"
18+
19+
- name: Install Melos
20+
run: flutter pub global activate melos
21+
- name: Install dependencies
22+
run: melos bootstrap
23+
- name: Check formatting
24+
run: melos format:check:packages
25+
- name: Lint
26+
run: melos analyze:packages
27+
- name: Publish dry-run
28+
run: melos publish --dry-run --yes
29+
- name: Check publish score
30+
run: |
31+
flutter pub global activate pana
32+
./.github/workflows/scripts/run-pana.sh
33+
34+
test:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v3
38+
- name: Install Flutter
39+
uses: subosito/flutter-action@v2
40+
with:
41+
flutter-version: "3.x"
42+
channel: "stable"
43+
- name: Install melos
44+
run: flutter pub global activate melos
45+
- name: Install dependencies
46+
run: melos bootstrap
47+
- name: Run tests
48+
run: melos test

.github/workflows/scripts/run-pana.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Get the root directory of your project
5+
ROOT_DIR=$(pwd)
6+
7+
# Specify the path to the packages folder
8+
PACKAGES_DIR="$ROOT_DIR/packages"
9+
10+
# Iterate over each package folder
11+
for PACKAGE in "$PACKAGES_DIR"/*; do
12+
# Check if it's a directory
13+
if [ -d "$PACKAGE" ]; then
14+
echo "Analyzing package in: $PACKAGE"
15+
16+
# Change into the package directory
17+
cd "$PACKAGE" || exit
18+
19+
# Run the pana command
20+
flutter pub global run pana --no-warning --exit-code-threshold 0
21+
22+
# Return to the root directory
23+
cd "$ROOT_DIR" || exit
24+
fi
25+
done

melos.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,29 @@ name: drift_sqlite_async_monorepo
33
packages:
44
- demos/**
55
- packages/**
6+
7+
scripts:
8+
format:
9+
description: Format Dart code.
10+
run: dart format .
11+
12+
format:check:packages:
13+
description: Check formatting of Dart code in packages.
14+
run: dart format --output none --set-exit-if-changed packages
15+
16+
analyze:packages:
17+
description: Analyze Dart code in packages.
18+
run: dart analyze packages --fatal-infos
19+
20+
test:
21+
description: Run tests in a specific package.
22+
run: dart test
23+
exec:
24+
concurrency: 1
25+
packageFilters:
26+
dirExists:
27+
- test
28+
# This tells Melos tests to ignore env variables passed to tests from `melos run test`
29+
# as they could change the behaviour of how tests filter packages.
30+
env:
31+
MELOS_TEST: true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
library drift_sqlite_async;
22

3+
export './src/connection.dart';
34
export './src/executor.dart';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import 'dart:async';
2+
3+
import 'package:drift/drift.dart';
4+
import 'package:drift_sqlite_async/src/executor.dart';
5+
import 'package:sqlite_async/sqlite_async.dart';
6+
7+
/// Wraps a sqlite_async [SqliteConnection] as a Drift [DatabaseConnection].
8+
///
9+
/// The SqliteConnection must be instantiated before constructing this, and
10+
/// is not closed when [SqliteAsyncDriftConnection.close] is called.
11+
///
12+
/// This class handles delegating Drift's queries and transactions to the
13+
/// [SqliteConnection], and passes on any table updates from the
14+
/// [SqliteConnection] to Drift.
15+
class SqliteAsyncDriftConnection extends DatabaseConnection {
16+
late StreamSubscription _updateSubscription;
17+
18+
SqliteAsyncDriftConnection(SqliteConnection db)
19+
: super(SqliteAsyncQueryExecutor(db)) {
20+
_updateSubscription = (db as SqliteQueries).updates!.listen((event) {
21+
var setUpdates = <TableUpdate>{};
22+
for (var tableName in event.tables) {
23+
setUpdates.add(TableUpdate(tableName));
24+
}
25+
super.streamQueries.handleTableUpdates(setUpdates);
26+
});
27+
}
28+
29+
@override
30+
Future<void> close() async {
31+
await _updateSubscription.cancel();
32+
await super.close();
33+
}
34+
}

0 commit comments

Comments
 (0)