From 5477842a72c2629ffbb79a6d67d69a430a7ee6cb Mon Sep 17 00:00:00 2001 From: Dominic Gunther Bauer <46312751+DominicGBauer@users.noreply.github.com> Date: Wed, 14 Feb 2024 15:52:08 +0200 Subject: [PATCH 01/18] chore: deprecate dev connector (#59) Co-authored-by: DominicGBauer --- demos/supabase-anonymous-auth/pubspec.lock | 2 +- demos/supabase-edge-function-auth/pubspec.lock | 2 +- demos/supabase-simple-chat/pubspec.lock | 2 +- demos/supabase-todolist/pubspec.lock | 2 +- packages/powersync/CHANGELOG.md | 4 ++++ packages/powersync/lib/src/connector.dart | 7 +++---- packages/powersync/lib/src/open_factory.dart | 4 ++-- packages/powersync/lib/src/powersync_database.dart | 2 +- packages/powersync/pubspec.yaml | 2 +- .../lib/src/syncing_service.dart | 2 +- 10 files changed, 16 insertions(+), 13 deletions(-) diff --git a/demos/supabase-anonymous-auth/pubspec.lock b/demos/supabase-anonymous-auth/pubspec.lock index 28a50339..dc77f1e4 100644 --- a/demos/supabase-anonymous-auth/pubspec.lock +++ b/demos/supabase-anonymous-auth/pubspec.lock @@ -310,7 +310,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.2.0" + version: "1.2.2" realtime_client: dependency: transitive description: diff --git a/demos/supabase-edge-function-auth/pubspec.lock b/demos/supabase-edge-function-auth/pubspec.lock index 28a50339..dc77f1e4 100644 --- a/demos/supabase-edge-function-auth/pubspec.lock +++ b/demos/supabase-edge-function-auth/pubspec.lock @@ -310,7 +310,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.2.0" + version: "1.2.2" realtime_client: dependency: transitive description: diff --git a/demos/supabase-simple-chat/pubspec.lock b/demos/supabase-simple-chat/pubspec.lock index b3a8064c..0d9a16ca 100644 --- a/demos/supabase-simple-chat/pubspec.lock +++ b/demos/supabase-simple-chat/pubspec.lock @@ -326,7 +326,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.2.0" + version: "1.2.2" realtime_client: dependency: transitive description: diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index cd570c1b..35936ea5 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -414,7 +414,7 @@ packages: path: "../../packages/powersync" relative: true source: path - version: "1.2.0" + version: "1.2.2" powersync_attachments_helper: dependency: "direct main" description: diff --git a/packages/powersync/CHANGELOG.md b/packages/powersync/CHANGELOG.md index d54482bb..1a4b80e5 100644 --- a/packages/powersync/CHANGELOG.md +++ b/packages/powersync/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.2 + +- Deprecate DevConnector and related + ## 1.2.1 - Fix indexes incorrectly dropped after the first run. diff --git a/packages/powersync/lib/src/connector.dart b/packages/powersync/lib/src/connector.dart index 2d4ec38b..1ba0faba 100644 --- a/packages/powersync/lib/src/connector.dart +++ b/packages/powersync/lib/src/connector.dart @@ -11,9 +11,6 @@ import 'powersync_database.dart'; /// 1. Creating credentials for connecting to the PowerSync service. /// 2. Applying local changes against the backend application server. /// -/// [DevConnector] is provided as a quick starting point, without user management -/// or significant security. -/// /// For production, use a custom implementation. abstract class PowerSyncBackendConnector { PowerSyncCredentials? _cachedCredentials; @@ -67,7 +64,7 @@ abstract class PowerSyncBackendConnector { /// Upload local changes to the app backend. /// - /// Use [PowerSyncDatabase.getCrudBatch] to get a batch of changes to upload. See [DevConnector] for an example implementation. + /// Use [PowerSyncDatabase.getCrudBatch] to get a batch of changes to upload. /// /// Any thrown errors will result in a retry after the configured wait period (default: 5 seconds). Future uploadData(PowerSyncDatabase database); @@ -153,6 +150,7 @@ class PowerSyncCredentials { /// /// These cannot be used for the main PowerSync APIs. [DevConnector] uses these /// credentials to automatically fetch [PowerSyncCredentials]. +@Deprecated('We will be removing this in version 2.') class DevCredentials { /// Dev endpoint. String endpoint; @@ -201,6 +199,7 @@ class DevCredentials { /// /// Development mode is intended to get up and running quickly, but is not for /// production use. For production, write a custom connector. +@Deprecated('We will be removing this in version 2.') class DevConnector extends PowerSyncBackendConnector { DevCredentials? _inMemoryDevCredentials; diff --git a/packages/powersync/lib/src/open_factory.dart b/packages/powersync/lib/src/open_factory.dart index a9ea79fd..c601b592 100644 --- a/packages/powersync/lib/src/open_factory.dart +++ b/packages/powersync/lib/src/open_factory.dart @@ -24,13 +24,13 @@ class SqliteConnectionSetup { } class PowerSyncOpenFactory extends DefaultSqliteOpenFactory { - @Deprecated('Override PowerSyncOpenFactory instead') + @Deprecated('Override PowerSyncOpenFactory instead.') final SqliteConnectionSetup? _sqliteSetup; PowerSyncOpenFactory( {required super.path, super.sqliteOptions, - @Deprecated('Override PowerSyncOpenFactory instead') + @Deprecated('Override PowerSyncOpenFactory instead.') // ignore: deprecated_member_use_from_same_package SqliteConnectionSetup? sqliteSetup}) // ignore: deprecated_member_use_from_same_package diff --git a/packages/powersync/lib/src/powersync_database.dart b/packages/powersync/lib/src/powersync_database.dart index 9677afd9..239c7c3b 100644 --- a/packages/powersync/lib/src/powersync_database.dart +++ b/packages/powersync/lib/src/powersync_database.dart @@ -95,7 +95,7 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection { required String path, int maxReaders = SqliteDatabase.defaultMaxReaders, Logger? logger, - @Deprecated("Use [PowerSyncDatabase.withFactory] instead") + @Deprecated("Use [PowerSyncDatabase.withFactory] instead.") // ignore: deprecated_member_use_from_same_package SqliteConnectionSetup? sqliteSetup}) { // ignore: deprecated_member_use_from_same_package diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index dc4cf58f..6c32feff 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -1,5 +1,5 @@ name: powersync -version: 1.2.1 +version: 1.2.2 homepage: https://powersync.com repository: https://github.com/powersync-ja/powersync.dart description: PowerSync Flutter SDK - keep PostgreSQL databases in sync with on-device SQLite databases. diff --git a/packages/powersync_attachments_helper/lib/src/syncing_service.dart b/packages/powersync_attachments_helper/lib/src/syncing_service.dart index 5d24e3de..595b4643 100644 --- a/packages/powersync_attachments_helper/lib/src/syncing_service.dart +++ b/packages/powersync_attachments_helper/lib/src/syncing_service.dart @@ -63,7 +63,7 @@ class SyncingService { await attachmentsService.deleteAttachment(attachment.id); return; } catch (e) { - log.severe('Download attachment error for attachment $attachment}', e); + log.severe('Download attachment error for attachment $attachment', e); return; } } From c67c12aaf02b21586b66f36067a855c4f9b19bd3 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 09:22:29 +0200 Subject: [PATCH 02/18] use Dart script instead of sh script for wasm init --- melos.yaml | 2 +- scripts/init_sqlite_wasm.dart | 44 +++++++++++++++++++++++++++++++++++ scripts/init_sqlite_wasm.sh | 24 ------------------- 3 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 scripts/init_sqlite_wasm.dart delete mode 100644 scripts/init_sqlite_wasm.sh diff --git a/melos.yaml b/melos.yaml index 0ecc1bfa..446f6dbc 100644 --- a/melos.yaml +++ b/melos.yaml @@ -38,7 +38,7 @@ scripts: scope: - powersync_web_worker - update:wasm: sh scripts/init_sqlite_wasm.sh + update:wasm: dart run scripts/init_sqlite_wasm.dart test: description: Run tests in a specific package. diff --git a/scripts/init_sqlite_wasm.dart b/scripts/init_sqlite_wasm.dart new file mode 100644 index 00000000..8ccbc4d8 --- /dev/null +++ b/scripts/init_sqlite_wasm.dart @@ -0,0 +1,44 @@ +/// Downloads sqlite3.wasm and copies it to all demo folders +import 'dart:io'; + +final sqliteUrl = + 'https://github.com/simolus3/sqlite3.dart/releases/download/sqlite3-2.3.0/sqlite3.wasm'; + +void main() async { + // Create assets directory if it doesn't exist + final assetsDir = Directory('assets'); + if (!await assetsDir.exists()) { + await assetsDir.create(); + } + + final sqliteFilename = 'sqlite3.wasm'; + final sqlitePath = 'assets/$sqliteFilename'; + + // Download sqlite3.wasm + await downloadFile(sqliteUrl, sqlitePath); + + await for (var entity in Directory('demos').list()) { + if (entity is Directory) { + var demoDir = entity; + var webDir = Directory('${demoDir.path}/web'); + if (await webDir.exists()) { + await File(sqlitePath).copy('${webDir.path}/$sqliteFilename'); + print('Copied $sqlitePath to ${webDir.path}'); + } + } + } +} + +Future downloadFile(String url, String savePath) async { + print('Downloading: $url'); + var httpClient = HttpClient(); + var request = await httpClient.getUrl(Uri.parse(url)); + var response = await request.close(); + if (response.statusCode == HttpStatus.ok) { + var file = File(savePath); + await response.pipe(file.openWrite()); + } else { + print( + 'Failed to download file: ${response.statusCode} ${response.reasonPhrase}'); + } +} diff --git a/scripts/init_sqlite_wasm.sh b/scripts/init_sqlite_wasm.sh deleted file mode 100644 index e1c972bd..00000000 --- a/scripts/init_sqlite_wasm.sh +++ /dev/null @@ -1,24 +0,0 @@ -# sqlite3.wasm needs to be in the root assets folder -# and inside each Flutter app's web folder - -mkdir -p assets - -sqlite_filename="sqlite3.wasm" -sqlite_path="assets/$sqlite_filename" - -curl -LJ https://github.com/simolus3/sqlite3.dart/releases/download/sqlite3-2.3.0/sqlite3.wasm \ --o $sqlite_path - -# Copy to each demo's web dir - -# Destination directory pattern -destination_pattern="demos/*/web/" - -# Iterate over directories matching the pattern -for dir in $destination_pattern; do - if [ -d "$dir" ]; then - # If the directory exists, copy the file - cp "$sqlite_path" "$dir/$sqlite_filename" - echo "Copied $sqlite_path to $dir" - fi -done \ No newline at end of file From a32302a7e5cb9f42bd1f7599b22f2eff76d7f09e Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 09:30:46 +0200 Subject: [PATCH 03/18] update readme with instructions for fetching powersync_db.worker.js --- packages/powersync/README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/powersync/README.md b/packages/powersync/README.md index 3683b823..2db9c0d1 100644 --- a/packages/powersync/README.md +++ b/packages/powersync/README.md @@ -157,11 +157,8 @@ Web support is currently in an alpha release. Web support requires `sqlite3.wasm` and `powersync_db.worker.js` assets to be served from the web application. This is typically achieved by placing the files in the project `web` directory. -These assets are automatically configured in this monorepo when running `melos prepare`. - - `sqlite3.wasm` can be found [here](https://github.com/simolus3/sqlite3.dart/releases) -- `powersync_db.worker.js` will eventually be released in the repo's releases. - - In the interim the asset can be retrieved from the `./assets` folder after executing `melos prepare` +- `powersync_db.worker.js` can be found in the repo's [releases](https://github.com/powersync-ja/powersync.dart/releases) page. Currently the Drift SQLite library is used under the hood for DB connections. See [here](https://drift.simonbinder.eu/web/#getting-started) for detailed compatibility and setup notes. From 92896fe7bdcecf7d4123f7d64e4d5cc5122cd8c9 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 10:17:41 +0200 Subject: [PATCH 04/18] update PowerSyncDatabase init examples for web --- demos/supabase-anonymous-auth/lib/powersync.dart | 12 ++++++++---- demos/supabase-anonymous-auth/pubspec.lock | 8 ++++++++ demos/supabase-anonymous-auth/pubspec.yaml | 1 + .../lib/powersync.dart | 12 ++++++++---- demos/supabase-edge-function-auth/pubspec.lock | 8 ++++++++ demos/supabase-edge-function-auth/pubspec.yaml | 1 + demos/supabase-simple-chat/lib/powersync.dart | 11 +++++++---- demos/supabase-simple-chat/pubspec.lock | 8 ++++++++ demos/supabase-simple-chat/pubspec.yaml | 1 + demos/supabase-todolist/lib/powersync.dart | 11 +++++++---- demos/supabase-todolist/pubspec.lock | 15 +++++++++++---- demos/supabase-todolist/pubspec.yaml | 1 + packages/powersync/README.md | 10 ++++++++-- packages/powersync/example/getting_started.dart | 11 +++++++---- 14 files changed, 84 insertions(+), 26 deletions(-) diff --git a/demos/supabase-anonymous-auth/lib/powersync.dart b/demos/supabase-anonymous-auth/lib/powersync.dart index 8bf284cc..0a3730ee 100644 --- a/demos/supabase-anonymous-auth/lib/powersync.dart +++ b/demos/supabase-anonymous-auth/lib/powersync.dart @@ -1,6 +1,5 @@ // This file performs setup of the PowerSync database -import 'dart:io'; - +import 'package:universal_io/io.dart'; import 'package:flutter/foundation.dart'; import 'package:logging/logging.dart'; import 'package:path/path.dart'; @@ -137,8 +136,13 @@ String? getUserId() { } Future getDatabasePath() async { - final dir = kIsWeb ? Directory('/') : await getApplicationSupportDirectory(); - return join(dir.path, 'powersync-demo.db'); + const dbFilename = 'powersync-demo.db'; + // getApplicationSupportDirectory is not supported on Web + if (kIsWeb) { + return dbFilename; + } + final dir = await getApplicationSupportDirectory(); + return join(dir.path, dbFilename); } Future openDatabase() async { diff --git a/demos/supabase-anonymous-auth/pubspec.lock b/demos/supabase-anonymous-auth/pubspec.lock index beff5f40..10331e82 100644 --- a/demos/supabase-anonymous-auth/pubspec.lock +++ b/demos/supabase-anonymous-auth/pubspec.lock @@ -540,6 +540,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + universal_io: + dependency: "direct main" + description: + name: universal_io + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" + url: "https://pub.dev" + source: hosted + version: "2.2.2" url_launcher: dependency: transitive description: diff --git a/demos/supabase-anonymous-auth/pubspec.yaml b/demos/supabase-anonymous-auth/pubspec.yaml index ae250d3b..28a76caa 100644 --- a/demos/supabase-anonymous-auth/pubspec.yaml +++ b/demos/supabase-anonymous-auth/pubspec.yaml @@ -17,6 +17,7 @@ dependencies: path: ^1.8.3 logging: ^1.2.0 sqlite_async: ^0.7.0-alpha.1 + universal_io: ^2.2.2 dev_dependencies: flutter_test: diff --git a/demos/supabase-edge-function-auth/lib/powersync.dart b/demos/supabase-edge-function-auth/lib/powersync.dart index 39f5ca83..bc291497 100644 --- a/demos/supabase-edge-function-auth/lib/powersync.dart +++ b/demos/supabase-edge-function-auth/lib/powersync.dart @@ -1,6 +1,5 @@ // This file performs setup of the PowerSync database -import 'dart:io'; - +import 'package:universal_io/io.dart'; import 'package:flutter/foundation.dart'; import 'package:logging/logging.dart'; import 'package:path/path.dart'; @@ -140,8 +139,13 @@ String? getUserId() { } Future getDatabasePath() async { - final dir = kIsWeb ? Directory('/') : await getApplicationSupportDirectory(); - return join(dir.path, 'powersync-demo.db'); + const dbFilename = 'powersync-demo.db'; + // getApplicationSupportDirectory is not supported on Web + if (kIsWeb) { + return dbFilename; + } + final dir = await getApplicationSupportDirectory(); + return join(dir.path, dbFilename); } Future openDatabase() async { diff --git a/demos/supabase-edge-function-auth/pubspec.lock b/demos/supabase-edge-function-auth/pubspec.lock index beff5f40..10331e82 100644 --- a/demos/supabase-edge-function-auth/pubspec.lock +++ b/demos/supabase-edge-function-auth/pubspec.lock @@ -540,6 +540,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + universal_io: + dependency: "direct main" + description: + name: universal_io + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" + url: "https://pub.dev" + source: hosted + version: "2.2.2" url_launcher: dependency: transitive description: diff --git a/demos/supabase-edge-function-auth/pubspec.yaml b/demos/supabase-edge-function-auth/pubspec.yaml index 27025645..00ef5d34 100644 --- a/demos/supabase-edge-function-auth/pubspec.yaml +++ b/demos/supabase-edge-function-auth/pubspec.yaml @@ -17,6 +17,7 @@ dependencies: path: ^1.8.3 logging: ^1.2.0 sqlite_async: ^0.7.0-alpha.1 + universal_io: ^2.2.2 dev_dependencies: flutter_test: diff --git a/demos/supabase-simple-chat/lib/powersync.dart b/demos/supabase-simple-chat/lib/powersync.dart index 6c4770ae..e28a3270 100644 --- a/demos/supabase-simple-chat/lib/powersync.dart +++ b/demos/supabase-simple-chat/lib/powersync.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/foundation.dart'; import 'package:powersync/powersync.dart'; import 'package:supabase_flutter/supabase_flutter.dart'; @@ -27,8 +25,13 @@ final List fatalResponseCodes = [ late final PowerSyncDatabase db; Future getDatabasePath() async { - final dir = kIsWeb ? Directory('/') : await getApplicationSupportDirectory(); - return join(dir.path, 'powersync-demo.db'); + const dbFilename = 'powersync-demo.db'; + // getApplicationSupportDirectory is not supported on Web + if (kIsWeb) { + return dbFilename; + } + final dir = await getApplicationSupportDirectory(); + return join(dir.path, dbFilename); } bool isLoggedIn() { diff --git a/demos/supabase-simple-chat/pubspec.lock b/demos/supabase-simple-chat/pubspec.lock index e35048f5..62fe7ea5 100644 --- a/demos/supabase-simple-chat/pubspec.lock +++ b/demos/supabase-simple-chat/pubspec.lock @@ -604,6 +604,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + universal_io: + dependency: "direct main" + description: + name: universal_io + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" + url: "https://pub.dev" + source: hosted + version: "2.2.2" url_launcher: dependency: transitive description: diff --git a/demos/supabase-simple-chat/pubspec.yaml b/demos/supabase-simple-chat/pubspec.yaml index 1ec83e1d..2d65f680 100644 --- a/demos/supabase-simple-chat/pubspec.yaml +++ b/demos/supabase-simple-chat/pubspec.yaml @@ -41,6 +41,7 @@ dependencies: path_provider: ^2.1.1 path: ^1.8.3 logging: ^1.2.0 + universal_io: ^2.2.2 dev_dependencies: flutter_test: diff --git a/demos/supabase-todolist/lib/powersync.dart b/demos/supabase-todolist/lib/powersync.dart index 0c5f79dd..10c5966a 100644 --- a/demos/supabase-todolist/lib/powersync.dart +++ b/demos/supabase-todolist/lib/powersync.dart @@ -1,6 +1,4 @@ // This file performs setup of the PowerSync database -import 'dart:io'; - import 'package:flutter/foundation.dart'; import 'package:logging/logging.dart'; import 'package:path/path.dart'; @@ -148,8 +146,13 @@ String? getUserId() { } Future getDatabasePath() async { - final dir = kIsWeb ? Directory('/') : await getApplicationSupportDirectory(); - return join(dir.path, 'powersync-demo.db'); + const dbFilename = 'powersync-demo.db'; + // getApplicationSupportDirectory is not supported on Web + if (kIsWeb) { + return dbFilename; + } + final dir = await getApplicationSupportDirectory(); + return join(dir.path, dbFilename); } Future openDatabase() async { diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index 9f83e15f..b70c463d 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -558,10 +558,9 @@ packages: sqlite_async: dependency: "direct main" description: - name: sqlite_async - sha256: "91f454cddc85617bea2c7c1544ff386887d0d2cf0ecdb3599015c05cc141ff4d" - url: "https://pub.dev" - source: hosted + path: "../../../sqlite_async.dart" + relative: true + source: path version: "0.7.0-alpha.1" stack_trace: dependency: transitive @@ -643,6 +642,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + universal_io: + dependency: "direct main" + description: + name: universal_io + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" + url: "https://pub.dev" + source: hosted + version: "2.2.2" url_launcher: dependency: transitive description: diff --git a/demos/supabase-todolist/pubspec.yaml b/demos/supabase-todolist/pubspec.yaml index cfda6024..e8d726f2 100644 --- a/demos/supabase-todolist/pubspec.yaml +++ b/demos/supabase-todolist/pubspec.yaml @@ -20,6 +20,7 @@ dependencies: sqlite_async: ^0.7.0-alpha.1 camera: ^0.10.5+7 image: ^4.1.3 + universal_io: ^2.2.2 dev_dependencies: flutter_test: diff --git a/packages/powersync/README.md b/packages/powersync/README.md index 2db9c0d1..302c3ea1 100644 --- a/packages/powersync/README.md +++ b/packages/powersync/README.md @@ -31,6 +31,7 @@ You'll need to create a PowerSync account and set up a PowerSync instance. You c import 'package:powersync/powersync.dart'; import 'package:path_provider/path_provider.dart'; import 'package:path/path.dart'; +import 'package:flutter/foundation.dart'; // Define the schema for the local SQLite database. // You can automatically generate this schema based on your sync rules: @@ -60,8 +61,13 @@ class MyBackendConnector extends PowerSyncBackendConnector { } openDatabase() async { - final dir = await getApplicationSupportDirectory(); - final path = join(dir.path, 'powersync-dart.db'); + var path = 'powersync-demo.db'; + // getApplicationSupportDirectory is not supported on Web + if (!kIsWeb) { + final dir = await getApplicationSupportDirectory(); + path = join(dir.path, 'powersync-dart.db'); + } + // Setup the database. db = PowerSyncDatabase(schema: schema, path: path); diff --git a/packages/powersync/example/getting_started.dart b/packages/powersync/example/getting_started.dart index 94b6ca34..348b3021 100644 --- a/packages/powersync/example/getting_started.dart +++ b/packages/powersync/example/getting_started.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/foundation.dart'; import 'package:powersync/powersync.dart'; import 'package:path_provider/path_provider.dart'; @@ -28,8 +26,13 @@ class BackendConnector extends PowerSyncBackendConnector { } openDatabase() async { - final dir = kIsWeb ? Directory('/') : await getApplicationSupportDirectory(); - final path = join(dir.path, 'powersync-dart.db'); + var path = 'powersync-demo.db'; + // getApplicationSupportDirectory is not supported on Web + if (!kIsWeb) { + final dir = await getApplicationSupportDirectory(); + path = join(dir.path, 'powersync-dart.db'); + } + // Setup the database. db = PowerSyncDatabase(schema: schema, path: path); await db.initialize(); From 83f06089e4bf2abe94c281a935377cd9916bdab0 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 10:25:47 +0200 Subject: [PATCH 05/18] fix lint --- packages/powersync/lib/src/database/powersync_database.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/powersync/lib/src/database/powersync_database.dart b/packages/powersync/lib/src/database/powersync_database.dart index e941003f..abc68e34 100644 --- a/packages/powersync/lib/src/database/powersync_database.dart +++ b/packages/powersync/lib/src/database/powersync_database.dart @@ -40,7 +40,11 @@ abstract class PowerSyncDatabase // ignore: deprecated_member_use_from_same_package SqliteConnectionSetup? sqliteSetup}) { return PowerSyncDatabaseImpl( - schema: schema, path: path, logger: logger, sqliteSetup: sqliteSetup); + schema: schema, + path: path, + logger: logger, + // ignore: deprecated_member_use_from_same_package + sqliteSetup: sqliteSetup); } /// Open a [PowerSyncDatabase] with a [PowerSyncOpenFactory]. From 92d739046ee83a796e4fa75941f5a4293c17ba15 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 10:47:26 +0200 Subject: [PATCH 06/18] improve pana analyzing to only scan published packages --- .github/workflows/packages.yml | 2 +- .github/workflows/scripts/run-pana.sh | 25 ------------------- melos.yaml | 36 ++++++++++++++++----------- 3 files changed, 22 insertions(+), 41 deletions(-) delete mode 100755 .github/workflows/scripts/run-pana.sh diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index d1d01717..e7323a2b 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -33,7 +33,7 @@ jobs: - name: Check publish score run: | flutter pub global activate pana - ./.github/workflows/scripts/run-pana.sh + melos analyze:packages:pana --no-select test: runs-on: ubuntu-latest diff --git a/.github/workflows/scripts/run-pana.sh b/.github/workflows/scripts/run-pana.sh deleted file mode 100755 index 85905771..00000000 --- a/.github/workflows/scripts/run-pana.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -e - -# Get the root directory of your project -ROOT_DIR=$(pwd) - -# Specify the path to the packages folder -PACKAGES_DIR="$ROOT_DIR/packages" - -# Iterate over each package folder -for PACKAGE in "$PACKAGES_DIR"/*; do - # Check if it's a directory - if [ -d "$PACKAGE" ]; then - echo "Analyzing package in: $PACKAGE" - - # Change into the package directory - cd "$PACKAGE" || exit - - # Run the pana command - flutter pub global run pana --no-warning --exit-code-threshold 10 - - # Return to the root directory - cd "$ROOT_DIR" || exit - fi -done diff --git a/melos.yaml b/melos.yaml index 446f6dbc..2ca07d1b 100644 --- a/melos.yaml +++ b/melos.yaml @@ -11,25 +11,19 @@ ide: scripts: prepare: melos bootstrap && melos compile:webworker && melos update:wasm - format: - description: Format Dart code. - run: dart format . - - format:check:packages: - description: Check formatting of Dart code in packages. - run: dart format --output none --set-exit-if-changed packages - - format:check:demos: - description: Check formatting of Dart code in demos. - run: dart format --output none --set-exit-if-changed demos + analyze:demos: + description: Analyze Dart code in demos. + run: dart analyze demos --fatal-infos analyze:packages: description: Analyze Dart code in packages. run: dart analyze packages --fatal-infos - analyze:demos: - description: Analyze Dart code in demos. - run: dart analyze demos --fatal-infos + analyze:packages:pana: + description: Analyze Dart packages with Pana + exec: flutter pub global run pana --no-warning --exit-code-threshold 10 + packageFilters: + noPrivate: true compile:webworker: description: Compile Javascript web worker distributable @@ -38,7 +32,17 @@ scripts: scope: - powersync_web_worker - update:wasm: dart run scripts/init_sqlite_wasm.dart + format: + description: Format Dart code. + run: dart format . + + format:check:demos: + description: Check formatting of Dart code in demos. + run: dart format --output none --set-exit-if-changed demos + + format:check:packages: + description: Check formatting of Dart code in packages. + run: dart format --output none --set-exit-if-changed packages test: description: Run tests in a specific package. @@ -52,3 +56,5 @@ scripts: # as they could change the behaviour of how tests filter packages. env: MELOS_TEST: true + + update:wasm: dart run scripts/init_sqlite_wasm.dart From 302e5ee3465c57cbaa3aa9ba608d7b0d429848b5 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 11:18:14 +0200 Subject: [PATCH 07/18] optimize webworker filesize --- demos/supabase-todolist/pubspec.lock | 7 ++++--- packages/powersync_web_worker/bin/compile_webworker.dart | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index b70c463d..d9ea70c7 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -558,9 +558,10 @@ packages: sqlite_async: dependency: "direct main" description: - path: "../../../sqlite_async.dart" - relative: true - source: path + name: sqlite_async + sha256: "91f454cddc85617bea2c7c1544ff386887d0d2cf0ecdb3599015c05cc141ff4d" + url: "https://pub.dev" + source: hosted version: "0.7.0-alpha.1" stack_trace: dependency: transitive diff --git a/packages/powersync_web_worker/bin/compile_webworker.dart b/packages/powersync_web_worker/bin/compile_webworker.dart index 217b1898..5f6f11b1 100644 --- a/packages/powersync_web_worker/bin/compile_webworker.dart +++ b/packages/powersync_web_worker/bin/compile_webworker.dart @@ -21,7 +21,7 @@ Future main() async { 'js', '-o', outputPath, - '-O0', + '-O4', workerSourcePath, ], workingDirectory: cwd); From 5c3947fd358be637194822643f41ddc74456b371 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 11:45:16 +0200 Subject: [PATCH 08/18] added automated webworker release action --- .github/workflows/release.yml | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..e60224a3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +# This triggers whenever a tagged release is pushed +name: Compile Assets and Create Draft Release + +on: + push: + tags: + - 'v*' # Trigger on tags beginning with 'v' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.x' + channel: 'stable' + + - name: Install Melos + run: flutter pub global activate melos + + - name: Install dependencies and compile assets + run: melos prepare + + # Extract the tag name from the event payload + - name: Get Tag Name + id: get_tag_name + run: echo ::set-output name=tag_name::${GITHUB_REF/refs\/tags\//} + + # Determine if the release should be a prerelease (true if the version contains "-") + - name: Determine Prerelease + id: determine_prerelease + run: echo ::set-output name=is_prerelease::$(echo ${{ steps.get_tag_name.outputs.tag_name }} | grep -q "-" && echo "true" || echo "false") + + # Create the Draft release using the tag name + - name: Create Draft Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.get_tag_name.outputs.tag_name }} # Use the pushed tag name + release_name: Release ${{ steps.get_tag_name.outputs.tag_name }} + draft: true + prerelease: ${{ steps.determine_prerelease.outputs.is_prerelease }} + + # Upload the compiled assets to the Draft release. + - name: Upload Assets to Draft Release + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./assets/powersync_db.worker.js + asset_name: powersync_db.worker.js + asset_content_type: text/javascript From bdee9cc0bae2a930e72ed1799896fdeb6e8f48f2 Mon Sep 17 00:00:00 2001 From: benitav Date: Thu, 15 Feb 2024 12:26:53 +0200 Subject: [PATCH 09/18] Add testing instructions to Readme --- packages/powersync/README.md | 122 +++++++++++++++++++++-------------- 1 file changed, 72 insertions(+), 50 deletions(-) diff --git a/packages/powersync/README.md b/packages/powersync/README.md index 302c3ea1..c8462921 100644 --- a/packages/powersync/README.md +++ b/packages/powersync/README.md @@ -1,6 +1,73 @@ # PowerSync SDK for Dart/Flutter -[PowerSync](https://powersync.co) is a service and set of SDKs that keeps PostgreSQL databases in sync with on-device SQLite databases. +[PowerSync](https://powersync.com) is a service and set of SDKs that keeps PostgreSQL databases in sync with on-device SQLite databases. + +## *** Web support - Open alpha *** + +Web support is currently in an alpha release. This Readme has been updated to reflect updates that are currently only relevant to this alpha release. + +### Demo app + +The easiest way to test out the alpha is to run the [Supabase Todo-List](./demos/supabase-todolist) demo app: + +1. Checkout the powersync.dart repo's `alpha_release`` branch. + * Note: If you are an existing user updating to the latest code after a git pull, run `melos exec 'flutter pub upgrade'` in the project's root and make sure it succeeds. +2. Run `melos prepare` in the project's root +3. cd into the `demos/supabase-todolist` folder +4. If you haven’t yet: `cp lib/app_config_template.dart lib/app_config.dart` (optionally update this config with your own Supabase and PowerSync project details). +5. Run `flutter run -d chrome` + +### Installing PowerSync in your own project + +Install the latest alpha version of the package, for example: + +```flutter pub add powersync:1.3.0-alpha.1``` + +### Additional config +Web support requires `sqlite3.wasm` and `powersync_db.worker.js` assets to be served from the web application. This is typically achieved by placing the files in the project `web` directory. + +- `sqlite3.wasm` can be found [here](https://github.com/simolus3/sqlite3.dart/releases) +- `powersync_db.worker.js` can be found in the repo's [releases](https://github.com/powersync-ja/powersync.dart/releases) page. + +Currently the Drift SQLite library is used under the hood for DB connections. See [here](https://drift.simonbinder.eu/web/#getting-started) for detailed compatibility +and setup notes. + +The same code is used for initializing native and web `PowerSyncDatabase` clients. + +### Getting started +Follow the [Getting Started](#getting-started) steps further down in this Readme to implement a backend connector and initialize the PowerSync database in your app, and hook PowerSync up with your app's UI. + +### Limitations + +The API for web is essentially the same as for native platforms. Some features within `PowerSyncDatabase` clients are not available. + +Multiple tab support is not yet available. Using multiple tabs will break. + +#### Imports + +Flutter Web does not support importing directly from `sqlite3.dart` as it uses `dart:ffi`. + +Change imports from + +```Dart +import 'package/powersync/sqlite3.dart` +``` + +to + +```Dart +import 'package/powersync/sqlite3_common.dart' +``` + +In code which needs to run on the Web platform. Isolated native specific code can still import from `sqlite3.dart`. + +#### Database connections + +Web DB connections do not support concurrency. A single DB connection is used. `readLock` and `writeLock` contexts do not +implement checks for preventing writable queries in read connections and vice-versa. + +Direct access to the synchronous `CommonDatabase` (`sqlite.Database` equivalent for web) connection is not available. `computeWithDatabase` is not available on web. + ## SDK Features @@ -11,18 +78,18 @@ - No need for client-side database migrations - these are handled automatically. - Subscribe to queries for live updates. -## Examples -For complete app examples, see our [example app gallery](https://docs.powersync.com/resources/demo-apps-example-projects#flutter) - -For examples of some common patterns, see our [example snippets](./example/README.md) ## Getting started You'll need to create a PowerSync account and set up a PowerSync instance. You can do this at [https://www.powersync.com/](https://www.powersync.com/). ### Install the package +To test web support, install the latest alpha version of the SDK, for example: + +```flutter pub add powersync:1.3.0-alpha.1``` +If you want to install the latest stable version of the SDK, run: `flutter pub add powersync` ### Implement a backend connector and initialize the PowerSync database @@ -155,49 +222,4 @@ Logger.root.onRecord.listen((record) { }); ``` -## Web support - -Web support is currently in an alpha release. - -### Setup - -Web support requires `sqlite3.wasm` and `powersync_db.worker.js` assets to be served from the web application. This is typically achieved by placing the files in the project `web` directory. - -- `sqlite3.wasm` can be found [here](https://github.com/simolus3/sqlite3.dart/releases) -- `powersync_db.worker.js` can be found in the repo's [releases](https://github.com/powersync-ja/powersync.dart/releases) page. - -Currently the Drift SQLite library is used under the hood for DB connections. See [here](https://drift.simonbinder.eu/web/#getting-started) for detailed compatibility -and setup notes. - -The same code is used for initializing native and web `PowerSyncDatabase` clients. - -### Limitations - -The API for web is essentially the same as for native platforms. Some features within `PowerSyncDatabase` clients are not available. -#### Imports - -Flutter Web does not support importing directly from `sqlite3.dart` as it uses `dart:ffi`. - -Change imports from - -```Dart -import 'package/powersync/sqlite3.dart` -``` - -to - -```Dart -import 'package/powersync/sqlite3_common.dart' -``` - -In code which needs to run on the Web platform. Isolated native specific code can still import from `sqlite3.dart`. - -#### Database connections - -Web DB connections do not support concurrency. A single DB connection is used. `readLock` and `writeLock` contexts do not -implement checks for preventing writable queries in read connections and vice-versa. - -Direct access to the synchronous `CommonDatabase` (`sqlite.Database` equivalent for web) connection is not available. `computeWithDatabase` is not available on web. - -Multiple tab support is not yet available. Using multiple tabs will break. From f865bf59089978ade43f5875fcc35559cc02cf21 Mon Sep 17 00:00:00 2001 From: benitav Date: Thu, 15 Feb 2024 12:30:04 +0200 Subject: [PATCH 10/18] Restore Flutter examples in Readme. --- packages/powersync/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/powersync/README.md b/packages/powersync/README.md index c8462921..8d26bca5 100644 --- a/packages/powersync/README.md +++ b/packages/powersync/README.md @@ -79,6 +79,13 @@ Direct access to the synchronous `CommonDatabase` (`sqlite.Database` equivalent - Subscribe to queries for live updates. +## Examples + +For complete app examples, see our [example app gallery](https://docs.powersync.com/resources/demo-apps-example-projects#flutter) + + +For examples of some common patterns, see our [example snippets](./example/README.md) + ## Getting started From 16808f37b8cd37cc5bcb3d638172adccd3f1e5a1 Mon Sep 17 00:00:00 2001 From: benitav Date: Thu, 15 Feb 2024 12:34:24 +0200 Subject: [PATCH 11/18] Typo --- packages/powersync/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/powersync/README.md b/packages/powersync/README.md index 8d26bca5..14eb0f66 100644 --- a/packages/powersync/README.md +++ b/packages/powersync/README.md @@ -10,7 +10,7 @@ Web support is currently in an alpha release. This Readme has been updated to re The easiest way to test out the alpha is to run the [Supabase Todo-List](./demos/supabase-todolist) demo app: -1. Checkout the powersync.dart repo's `alpha_release`` branch. +1. Checkout this repo's `alpha_release` branch. * Note: If you are an existing user updating to the latest code after a git pull, run `melos exec 'flutter pub upgrade'` in the project's root and make sure it succeeds. 2. Run `melos prepare` in the project's root 3. cd into the `demos/supabase-todolist` folder @@ -21,7 +21,9 @@ The easiest way to test out the alpha is to run the [Supabase Todo-List](./demos Install the latest alpha version of the package, for example: -```flutter pub add powersync:1.3.0-alpha.1``` +``` +flutter pub add powersync:1.3.0-alpha.1 +``` ### Additional config Web support requires `sqlite3.wasm` and `powersync_db.worker.js` assets to be served from the web application. This is typically achieved by placing the files in the project `web` directory. @@ -81,10 +83,10 @@ Direct access to the synchronous `CommonDatabase` (`sqlite.Database` equivalent ## Examples -For complete app examples, see our [example app gallery](https://docs.powersync.com/resources/demo-apps-example-projects#flutter) +For complete app examples, see our [example app gallery](https://docs.powersync.com/resources/demo-apps-example-projects#flutter). -For examples of some common patterns, see our [example snippets](./example/README.md) +For examples of some common patterns, see our [example snippets](./example/README.md). ## Getting started From 8f793d33da59ef17e409cd3ced7f6c193421bd65 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 13:35:20 +0200 Subject: [PATCH 12/18] neaten up release action --- .github/workflows/release.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e60224a3..1322618b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,16 +26,6 @@ jobs: - name: Install dependencies and compile assets run: melos prepare - # Extract the tag name from the event payload - - name: Get Tag Name - id: get_tag_name - run: echo ::set-output name=tag_name::${GITHUB_REF/refs\/tags\//} - - # Determine if the release should be a prerelease (true if the version contains "-") - - name: Determine Prerelease - id: determine_prerelease - run: echo ::set-output name=is_prerelease::$(echo ${{ steps.get_tag_name.outputs.tag_name }} | grep -q "-" && echo "true" || echo "false") - # Create the Draft release using the tag name - name: Create Draft Release id: create_release @@ -43,10 +33,10 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ steps.get_tag_name.outputs.tag_name }} # Use the pushed tag name - release_name: Release ${{ steps.get_tag_name.outputs.tag_name }} + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} draft: true - prerelease: ${{ steps.determine_prerelease.outputs.is_prerelease }} + prerelease: true # TODO set this as false in future # Upload the compiled assets to the Draft release. - name: Upload Assets to Draft Release From d5abe24598835e8af3053fd274328fa13a225b05 Mon Sep 17 00:00:00 2001 From: benitav Date: Thu, 15 Feb 2024 13:44:10 +0200 Subject: [PATCH 13/18] More helpful information --- packages/powersync/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/powersync/README.md b/packages/powersync/README.md index 14eb0f66..d9a9da34 100644 --- a/packages/powersync/README.md +++ b/packages/powersync/README.md @@ -10,9 +10,9 @@ Web support is currently in an alpha release. This Readme has been updated to re The easiest way to test out the alpha is to run the [Supabase Todo-List](./demos/supabase-todolist) demo app: -1. Checkout this repo's `alpha_release` branch. - * Note: If you are an existing user updating to the latest code after a git pull, run `melos exec 'flutter pub upgrade'` in the project's root and make sure it succeeds. -2. Run `melos prepare` in the project's root +1. Checkout [this repo's](https://github.com/powersync-ja/powersync.dart/tree/alpha-release) `alpha_release` branch. + * Note: If you are an existing user updating to the latest code after a git pull, run `melos exec 'flutter pub upgrade'` in the repo's root and make sure it succeeds. +2. Run `melos prepare` in the repo's root 3. cd into the `demos/supabase-todolist` folder 4. If you haven’t yet: `cp lib/app_config_template.dart lib/app_config.dart` (optionally update this config with your own Supabase and PowerSync project details). 5. Run `flutter run -d chrome` @@ -24,6 +24,7 @@ Install the latest alpha version of the package, for example: ``` flutter pub add powersync:1.3.0-alpha.1 ``` +The latest prerelease version can be found [here](https://pub.dev/packages/powersync/versions). ### Additional config Web support requires `sqlite3.wasm` and `powersync_db.worker.js` assets to be served from the web application. This is typically achieved by placing the files in the project `web` directory. @@ -98,6 +99,8 @@ To test web support, install the latest alpha version of the SDK, for example: ```flutter pub add powersync:1.3.0-alpha.1``` +The latest prerelease version can be found [here](https://pub.dev/packages/powersync/versions). + If you want to install the latest stable version of the SDK, run: `flutter pub add powersync` From b9bce8ccdaa7cfd83448d1bc05a31ce44575dec7 Mon Sep 17 00:00:00 2001 From: benitav Date: Thu, 15 Feb 2024 14:44:22 +0200 Subject: [PATCH 14/18] Version improvement --- packages/powersync/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/powersync/README.md b/packages/powersync/README.md index d9a9da34..15955272 100644 --- a/packages/powersync/README.md +++ b/packages/powersync/README.md @@ -22,8 +22,9 @@ The easiest way to test out the alpha is to run the [Supabase Todo-List](./demos Install the latest alpha version of the package, for example: ``` -flutter pub add powersync:1.3.0-alpha.1 +flutter pub add powersync:'^1.3.0-alpha.1' ``` + The latest prerelease version can be found [here](https://pub.dev/packages/powersync/versions). ### Additional config @@ -97,7 +98,9 @@ You'll need to create a PowerSync account and set up a PowerSync instance. You c ### Install the package To test web support, install the latest alpha version of the SDK, for example: -```flutter pub add powersync:1.3.0-alpha.1``` +``` +flutter pub add powersync:'^1.3.0-alpha.1' +``` The latest prerelease version can be found [here](https://pub.dev/packages/powersync/versions). From b1adb6339be9c52c0e22b5796d6be6fd1c2b7920 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 15:37:26 +0200 Subject: [PATCH 15/18] use better action for automated releases --- .github/workflows/release.yml | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1322618b..f9ec117c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install Flutter uses: subosito/flutter-action@v2 @@ -23,29 +23,14 @@ jobs: - name: Install Melos run: flutter pub global activate melos - - name: Install dependencies and compile assets + - name: Install Dependencies and Compile Assets run: melos prepare - # Create the Draft release using the tag name - name: Create Draft Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: 'marvinpinto/action-automatic-releases@latest' with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} + repo_token: '${{ secrets.GITHUB_TOKEN }}' + prerelease: true # TODO update when out of alpha draft: true - prerelease: true # TODO set this as false in future - - # Upload the compiled assets to the Draft release. - - name: Upload Assets to Draft Release - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./assets/powersync_db.worker.js - asset_name: powersync_db.worker.js - asset_content_type: text/javascript + files: | + assets/powersync_db.worker.js From 93c8b0668f67a94ac0cb21f29d48b9578cf00aee Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 15:44:53 +0200 Subject: [PATCH 16/18] chore(release): publish packages - powersync@1.3.0-alpha.2 --- CHANGELOG.md | 33 +++++++++++++++++++ demos/supabase-anonymous-auth/pubspec.yaml | 2 +- .../supabase-edge-function-auth/pubspec.yaml | 2 +- demos/supabase-simple-chat/pubspec.yaml | 2 +- demos/supabase-todolist/pubspec.yaml | 2 +- packages/powersync/CHANGELOG.md | 5 +++ packages/powersync/pubspec.yaml | 2 +- .../powersync_attachments_helper/pubspec.yaml | 2 +- 8 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..e646bb26 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## 2024-02-15 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`powersync` - `v1.3.0-alpha.2`](#powersync---v130-alpha2) + - [`powersync_attachments_helper` - `v0.3.0-alpha.2`](#powersync_attachments_helper---v030-alpha2) + +Packages with dependency updates only: + +> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. + + - `powersync_attachments_helper` - `v0.3.0-alpha.2` + +--- + +#### `powersync` - `v1.3.0-alpha.2` + + - **FIX**(powersync-attachements-helper): pubspec file (#29). + - **DOCS**: update readme and getting started (#51). + diff --git a/demos/supabase-anonymous-auth/pubspec.yaml b/demos/supabase-anonymous-auth/pubspec.yaml index 28a76caa..f1b08e5e 100644 --- a/demos/supabase-anonymous-auth/pubspec.yaml +++ b/demos/supabase-anonymous-auth/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.3.0-alpha.1 + powersync: ^1.3.0-alpha.2 path_provider: ^2.1.1 supabase_flutter: ^2.0.2 path: ^1.8.3 diff --git a/demos/supabase-edge-function-auth/pubspec.yaml b/demos/supabase-edge-function-auth/pubspec.yaml index 00ef5d34..054d490c 100644 --- a/demos/supabase-edge-function-auth/pubspec.yaml +++ b/demos/supabase-edge-function-auth/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.3.0-alpha.1 + powersync: ^1.3.0-alpha.2 path_provider: ^2.1.1 supabase_flutter: ^2.0.2 path: ^1.8.3 diff --git a/demos/supabase-simple-chat/pubspec.yaml b/demos/supabase-simple-chat/pubspec.yaml index 2d65f680..e7a3630d 100644 --- a/demos/supabase-simple-chat/pubspec.yaml +++ b/demos/supabase-simple-chat/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: supabase_flutter: ^1.10.25 timeago: ^3.6.0 - powersync: ^1.3.0-alpha.1 + powersync: ^1.3.0-alpha.2 path_provider: ^2.1.1 path: ^1.8.3 logging: ^1.2.0 diff --git a/demos/supabase-todolist/pubspec.yaml b/demos/supabase-todolist/pubspec.yaml index e8d726f2..1f538378 100644 --- a/demos/supabase-todolist/pubspec.yaml +++ b/demos/supabase-todolist/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: sdk: flutter powersync_attachments_helper: ^0.3.0-alpha.1 - powersync: ^1.3.0-alpha.1 + powersync: ^1.3.0-alpha.2 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/packages/powersync/CHANGELOG.md b/packages/powersync/CHANGELOG.md index cc929e7a..4f75fe5a 100644 --- a/packages/powersync/CHANGELOG.md +++ b/packages/powersync/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.3.0-alpha.2 + + - **FIX**(powersync-attachements-helper): pubspec file (#29). + - **DOCS**: update readme and getting started (#51). + ## 1.3.0-alpha.1 - Added initial support for Web platform. diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index 6ac5498f..bc707dbb 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -1,5 +1,5 @@ name: powersync -version: 1.3.0-alpha.1 +version: 1.3.0-alpha.2 homepage: https://powersync.com repository: https://github.com/powersync-ja/powersync.dart description: PowerSync Flutter SDK - keep PostgreSQL databases in sync with on-device SQLite databases. diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index 27ec8d8d..0df84e18 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.3.0-alpha.1 + powersync: ^1.3.0-alpha.2 logging: ^1.2.0 sqlite3: ^2.3.0 sqlite_async: ^0.7.0-alpha.1 From d73b322185c2b9d86c6399aba2fbfcaaec2c47b7 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 15:52:37 +0200 Subject: [PATCH 17/18] correct powersync tags for release trigger --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f9ec117c..7191b407 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,9 @@ name: Compile Assets and Create Draft Release on: push: tags: - - 'v*' # Trigger on tags beginning with 'v' + # Trigger on tags beginning with 'powersync-v' + # This is how `melos version ..` tags things + - 'powersync-v*' jobs: build: From 32755dc29b1a3e72dc9c0f2081440d14408f3975 Mon Sep 17 00:00:00 2001 From: Steven Ontong Date: Thu, 15 Feb 2024 16:21:51 +0200 Subject: [PATCH 18/18] give release action the tag it wants --- .github/workflows/release.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7191b407..5b61047d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,9 +4,12 @@ name: Compile Assets and Create Draft Release on: push: tags: - # Trigger on tags beginning with 'powersync-v' - # This is how `melos version ..` tags things - - 'powersync-v*' + # Trigger on tags beginning with 'v' + # Note that `melos version ...` adds the package name as a suffix + # This action is not compatible with tags such as `powersync-v1.1.1` + # marvinpinto/action-automatic-releases struggles to generate changelogs + # Be sure to manually tag the commit to trigger this action + - 'v*' jobs: build: