diff --git a/Dockerfile b/Dockerfile index 689d894..e14398b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM dart:3.7.2 +FROM dart:3.10.2 RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ @@ -27,5 +27,14 @@ ENV PATH="/root/.cargo/bin:${PATH}" WORKDIR /app +COPY pubspec.yaml pubspec.lock ./ +COPY third_party/sqlite3.dart/sqlite3 ./third_party/sqlite3.dart/sqlite3 + +RUN dart pub get + +RUN dart --disable-analytics + +RUN dart run build_runner build --delete-conflicting-outputs + ENTRYPOINT [ "/bin/zsh" ] -CMD ["-l"] \ No newline at end of file +CMD ["-l"] diff --git a/README.md b/README.md index 646c12f..529b7dc 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,9 @@ Place it in a standard library path (e.g., `/usr/lib`, or use `/usr/local/lib/`) ## ๐Ÿš€ Usage Use **any standard SQLite library** in your language/runtime โ€” this project handles the dynamic strategy and connection logic under the hood. + +--- + +## ๐Ÿงช How to test + +See the dedicated guide: [`README_TESTING.md`](README_TESTING.md). diff --git a/README_TESTING.md b/README_TESTING.md new file mode 100644 index 0000000..2316b91 --- /dev/null +++ b/README_TESTING.md @@ -0,0 +1,38 @@ +# How To Test + +Follow these steps from the project root. + +## 1. Pull the submodule dependencies + +`pubspec.yaml` uses a local path override from the `third_party/sqlite3.dart` submodule, so initialize and update submodules first. + +```bash +git submodule update --init --recursive third_party/sqlite3.dart +``` + +## 2. Build the Docker image + +```bash +docker build -t libturso:sandbox . +``` + +## 3. Run the container with the current directory mounted + +```bash +docker run --rm -it \ + -v "$(pwd):/app" \ + -w /app \ + libturso:sandbox +``` + +## 4. Compile the binary inside the container + +```bash +cargo build +``` + +## 5. Run the Dart file in `bin/` to test + +```bash +dart run bin/libsqlite3_turso.dart +``` diff --git a/bin/libsqlite3_turso.dart b/bin/libsqlite3_turso.dart index 57ec111..b065e87 100644 --- a/bin/libsqlite3_turso.dart +++ b/bin/libsqlite3_turso.dart @@ -30,28 +30,28 @@ void main() async { final database = AppDatabase(); - await database.transaction(() async { - // Create the table if it doesn't exist - final result = await database.into(database.todoItems).insert( - TodoItemsCompanion.insert( - title: 'todo: setup drift', - content: 'We need to set up drift for our SQLite database.', - ), - ); - - await (database - .update(database.todoItems) - ..where((tbl) => tbl.id.equals(result))) - .write(TodoItemsCompanion(content: const Value('Updated content'))); - - - print('Inserted item with ID: $result'); - }); - - // final allItems = await database.select(database.todoItems).get(); - // for (final item in allItems) { - // print('Item: ${item.title}, Content: ${item.content}'); - // } + // await database.transaction(() async { + // // Create the table if it doesn't exist + // final result = await database.into(database.todoItems).insert( + // TodoItemsCompanion.insert( + // title: 'todo: setup drift', + // content: 'We need to set up drift for our SQLite database.', + // ), + // ); + + // await (database + // .update(database.todoItems) + // ..where((tbl) => tbl.id.equals(result))) + // .write(TodoItemsCompanion(content: const Value('Updated content'))); + + + // print('Inserted item with ID: $result'); + // }); + + final allItems = await database.select(database.todoItems).get(); + for (final item in allItems) { + print('Item: ${item.title}, Content: ${item.content}'); + } // final server = await HttpServer.bind(InternetAddress.anyIPv4, 8081); diff --git a/pubspec.lock b/pubspec.lock index 8e4a723..f3c1d09 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: da0d9209ca76bde579f2da330aeb9df62b6319c834fa7baae052021b0462401f + sha256: f0bb5d1648339c8308cc0b9838d8456b3cfe5c91f9dc1a735b4d003269e5da9a url: "https://pub.dev" source: hosted - version: "85.0.0" + version: "88.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "974859dc0ff5f37bc4313244b3218c791810d03ab3470a579580279ba971a48d" + sha256: "0b7b9c329d2879f8f05d6c05b32ee9ec025f39b077864bdb5ac9a7b63418a98f" url: "https://pub.dev" source: hosted - version: "7.7.1" + version: "8.1.1" args: dependency: transitive description: @@ -45,50 +45,34 @@ packages: dependency: transitive description: name: build - sha256: "7174c5d84b0fed00a1f5e7543597b35d67560465ae3d909f0889b8b20419d5e3" + sha256: "275bf6bb2a00a9852c28d4e0b410da1d833a734d57d39d44f94bfc895a484ec3" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "4.0.4" build_config: dependency: transitive description: name: build_config - sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33" + sha256: "4f64382b97504dc2fcdf487d5aae33418e08b4703fc21249e4db6d804a4d0187" url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "1.2.0" build_daemon: dependency: transitive description: name: build_daemon - sha256: "8e928697a82be082206edb0b9c99c5a4ad6bc31c9e9b8b2f291ae65cd4a25daa" + sha256: bf05f6e12cfea92d3c09308d7bcdab1906cd8a179b023269eed00c071004b957 url: "https://pub.dev" source: hosted - version: "4.0.4" - build_resolvers: - dependency: transitive - description: - name: build_resolvers - sha256: "82730bf3d9043366ba8c02e4add05842a10739899520a6a22ddbd22d333bd5bb" - url: "https://pub.dev" - source: hosted - version: "3.0.1" + version: "4.1.1" build_runner: dependency: "direct dev" description: name: build_runner - sha256: "32c6b3d172f1f46b7c4df6bc4a47b8d88afb9e505dd4ace4af80b3c37e89832b" + sha256: "39ad4ca8a2876779737c60e4228b4bcd35d4352ef7e14e47514093edc012c734" url: "https://pub.dev" source: hosted - version: "2.6.1" - build_runner_core: - dependency: transitive - description: - name: build_runner_core - sha256: "4b188774b369104ad96c0e4ca2471e5162f0566ce277771b179bed5eabf2d048" - url: "https://pub.dev" - source: hosted - version: "9.2.1" + version: "2.11.1" built_collection: dependency: transitive description: @@ -101,10 +85,10 @@ packages: dependency: transitive description: name: built_value - sha256: ba95c961bafcd8686d1cf63be864eb59447e795e124d98d6a27d91fcd13602fb + sha256: "7931c90b84bc573fef103548e354258ae4c9d28d140e41961df6843c5d60d4d8" url: "https://pub.dev" source: hosted - version: "8.11.1" + version: "8.12.3" charcode: dependency: transitive description: @@ -141,10 +125,10 @@ packages: dependency: transitive description: name: code_builder - sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e" + sha256: "6a6cab2ba4680d6423f34a9b972a4c9a94ebe1b62ecec4e1a1f2cba91fd1319d" url: "https://pub.dev" source: hosted - version: "4.10.1" + version: "4.11.1" collection: dependency: transitive description: @@ -165,50 +149,50 @@ packages: dependency: transitive description: name: coverage - sha256: aa07dbe5f2294c827b7edb9a87bba44a9c15a3cc81bc8da2ca19b37322d30080 + sha256: "5da775aa218eaf2151c721b16c01c7676fbfdd99cebba2bf64e8b807a28ff94d" url: "https://pub.dev" source: hosted - version: "1.14.1" + version: "1.15.0" crypto: dependency: transitive description: name: crypto - sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf url: "https://pub.dev" source: hosted - version: "3.0.6" + version: "3.0.7" dart_style: dependency: transitive description: name: dart_style - sha256: "8a0e5fba27e8ee025d2ffb4ee820b4e6e2cf5e4246a6b1a477eb66866947e0bb" + sha256: c87dfe3d56f183ffe9106a18aebc6db431fc7c98c31a54b952a77f3d54a85697 url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.2" drift: dependency: "direct main" description: name: drift - sha256: "6aaea757f53bb035e8a3baedf3d1d53a79d6549a6c13d84f7546509da9372c7c" + sha256: "970cd188fddb111b26ea6a9b07a62bf5c2432d74147b8122c67044ae3b97e99e" url: "https://pub.dev" source: hosted - version: "2.28.1" + version: "2.31.0" drift_dev: dependency: "direct dev" description: name: drift_dev - sha256: "2fc05ad458a7c562755bf0cae11178dfc58387a416829b78d4da5155a61465fd" + sha256: "917184b2fb867b70a548a83bf0d36268423b38d39968c06cce4905683da49587" url: "https://pub.dev" source: hosted - version: "2.28.1" + version: "2.31.0" ffi: dependency: transitive description: name: ffi - sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.2.0" file: dependency: transitive description: @@ -273,14 +257,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" - js: - dependency: transitive - description: - name: js - sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf - url: "https://pub.dev" - source: hosted - version: "0.7.1" json_annotation: dependency: transitive description: @@ -309,18 +285,18 @@ packages: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6" url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.18" meta: dependency: transitive description: name: meta - sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + sha256: "9f29b9bcc8ee287b1a31e0d01be0eae99a930dbffdaecf04b3f3d82a969f296f" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.18.1" mime: dependency: transitive description: @@ -357,10 +333,10 @@ packages: dependency: transitive description: name: pool - sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d" url: "https://pub.dev" source: hosted - version: "1.5.1" + version: "1.5.2" pub_semver: dependency: transitive description: @@ -413,18 +389,18 @@ packages: dependency: transitive description: name: shelf_web_socket - sha256: cc36c297b52866d203dbf9332263c94becc2fe0ceaa9681d07b6ef9807023b67 + sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.0" source_gen: dependency: transitive description: name: source_gen - sha256: "7b19d6ba131c6eb98bfcbf8d56c1a7002eba438af2e7ae6f8398b2b0f4f381e3" + sha256: "1d562a3c1f713904ebbed50d2760217fd8a51ca170ac4b05b0db490699dbac17" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "4.2.0" source_map_stack_trace: dependency: transitive description: @@ -445,26 +421,25 @@ packages: dependency: transitive description: name: source_span - sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" url: "https://pub.dev" source: hosted - version: "1.10.1" + version: "1.10.2" sqlite3: dependency: "direct main" description: - name: sqlite3 - sha256: f393d92c71bdcc118d6203d07c991b9be0f84b1a6f89dd4f7eed348131329924 - url: "https://pub.dev" - source: hosted - version: "2.9.0" + path: "third_party/sqlite3.dart/sqlite3" + relative: true + source: path + version: "2.8.0" sqlparser: dependency: transitive description: name: sqlparser - sha256: "7c859c803cf7e9a84d6db918bac824545045692bbe94a6386bd3a45132235d09" + sha256: "337e9997f7141ffdd054259128553c348635fa318f7ca492f07a4ab76f850d19" url: "https://pub.dev" source: hosted - version: "0.41.1" + version: "0.43.1" stack_trace: dependency: transitive description: @@ -509,58 +484,50 @@ packages: dependency: "direct dev" description: name: test - sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7" + sha256: "54c516bbb7cee2754d327ad4fca637f78abfc3cbcc5ace83b3eda117e42cd71a" url: "https://pub.dev" source: hosted - version: "1.26.3" + version: "1.29.0" test_api: dependency: transitive description: name: test_api - sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636" url: "https://pub.dev" source: hosted - version: "0.7.7" + version: "0.7.9" test_core: dependency: transitive description: name: test_core - sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0" + sha256: "394f07d21f0f2255ec9e3989f21e54d3c7dc0e6e9dbce160e5a9c1a6be0e2943" url: "https://pub.dev" source: hosted - version: "0.6.12" - timing: - dependency: transitive - description: - name: timing - sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe" - url: "https://pub.dev" - source: hosted - version: "1.0.2" + version: "0.6.15" typed_data: dependency: transitive description: name: typed_data - sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 url: "https://pub.dev" source: hosted - version: "1.3.2" + version: "1.4.0" vm_service: dependency: transitive description: name: vm_service - sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" url: "https://pub.dev" source: hosted - version: "14.3.1" + version: "15.0.2" watcher: dependency: transitive description: name: watcher - sha256: "0b7fd4a0bbc4b92641dbf20adfd7e3fd1398fe17102d94b674234563e110088a" + sha256: "1398c9f081a753f9226febe8900fce8f7d0a67163334e1c94a2438339d79d635" url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "1.2.1" web: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8f2e0fc..bd46922 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,6 +10,10 @@ dependencies: drift: ^2.28.1 sqlite3: ^2.9.0 +dependency_overrides: + sqlite3: + path: ./third_party/sqlite3.dart/sqlite3 + dev_dependencies: build_runner: ^2.6.1 drift_dev: ^2.28.1