Skip to content

Commit

Permalink
[Chore] Move to monorepo with attachments SDK (#24)
Browse files Browse the repository at this point in the history
* chore: add monorepo

* docs: update readme

* chore: rename ci names

* chore: update readme

* chore: remove submodule

* docs: change image

* chore: use master or main

* chore: rename packages

---------

Co-authored-by: DominicGBauer <dominic@nomanini.com>
  • Loading branch information
DominicGBauer and DominicGBauer authored Dec 20, 2023
1 parent d12b07f commit f91d681
Show file tree
Hide file tree
Showing 359 changed files with 16,050 additions and 167 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/demos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Demos checks

concurrency:
group: demos-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on:
push:
branches:
- master
- main
paths:
- demos/**
- .github/workflows/**
pull_request:
paths:
- demos/**'
- .github/workflows/**

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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
run: melos bootstrap
- name: Check formatting
run: melos format:check:demos
- name: Lint
run: |
./.github/workflows/scripts/copy-config.sh
melos analyze:demos
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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
run: melos bootstrap
- name: Run tests
run: melos test
60 changes: 60 additions & 0 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Packages check

concurrency:
group: packages-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on:
push:
branches:
- master
- main
paths:
- packages/**
- .github/workflows/**
pull_request:
paths:
- packages/**
- .github/workflows/**

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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
run: melos bootstrap
- name: Check formatting
run: melos format:check:packages
- name: Lint
run: melos analyze:packages
- name: Publish dry-run
run: melos publish --dry-run --yes
- name: Check publish score
run: |
flutter pub global activate pana
./.github/workflows/scripts/run-pana.sh
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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
run: melos bootstrap
- name: Run tests
run: melos test
25 changes: 25 additions & 0 deletions .github/workflows/scripts/copy-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
root_path=$(pwd)

TEMPLATE_CONFIG_FILE="app_config_template.dart"
TARGET_CONFIG_FILE="app_config.dart"
DEMOS_FOLDER="$root_path/demos" # Update the path to your demo folder

# Function to find and copy config files
copy_config_files() {
local demos_folder=$1

# Iterate over the files found by find
find "$demos_folder" -type f -name "$TEMPLATE_CONFIG_FILE" | while read -r template_config; do
# Ensure it's a regular file before attempting to copy
if [ -f "$template_config" ]; then
# Create a new file app_config.dart with the contents of app_config_template.dart
echo -n > "${template_config%/*}/$TARGET_CONFIG_FILE"
cat "$template_config" >> "${template_config%/*}/$TARGET_CONFIG_FILE"
echo "Copied contents of $template_config to ${template_config%/*}/$TARGET_CONFIG_FILE"
fi
done
}

# Call the function for the single demos folder
copy_config_files "$DEMOS_FOLDER"
24 changes: 24 additions & 0 deletions .github/workflows/scripts/run-pana.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# 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 0

# Return to the root directory
cd "$ROOT_DIR" || exit
fi
done
46 changes: 0 additions & 46 deletions .github/workflows/test.yaml

This file was deleted.

25 changes: 6 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# IDE files
.DS_Store
pubspec_overrides.yaml
.idea

# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock

doc

/test-db
*.iml
.flutter-plugins-dependencies
67 changes: 22 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,32 @@
# PowerSync SDK for Dart/Flutter
<p align="center">
<a href="https://www.powersync.com" target="_blank">
<img src="https://private-user-images.githubusercontent.com/19345049/283563672-602bafa0-41ce-4cee-a432-56848c278722.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDMwODM0NDUsIm5iZiI6MTcwMzA4MzE0NSwicGF0aCI6Ii8xOTM0NTA0OS8yODM1NjM2NzItNjAyYmFmYTAtNDFjZS00Y2VlLWE0MzItNTY4NDhjMjc4NzIyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzEyMjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMjIwVDE0MzkwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJhOGUwZDE0ODA4ODhhZTY2OGRiMGRiNTM4ZDJlNTBmNWY5NTA0YzNhZWE2NDA3ZjA3OTljNzRmZmU0Y2FlMzkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.MvQghmss9c9w90fCWvzT63RCRRB6sJoHnua1_zve9bs" alt="PowerSync">
</a>
</p>

[PowerSync](https://powersync.co) is a service and set of SDKs that keeps PostgreSQL databases in sync with on-device SQLite databases.
*Bad connectivity is everywhere, and we're tired of it. PowerSync is on a mission to help developers write offline first real-time reactive apps.*

## SDK Features
PowerSync SDK for Dart and Flutter
===========

* Real-time streaming of changes.
* Direct access to the SQLite database - use SQL on the client and server.
* Operations are asynchronous by default - does not block the UI.
* Supports one write and many reads concurrently.
* No need for client-side database migrations - these are handled automatically.
* Subscribe to queries for live updates.
| package | build | pub | likes | popularity | pub points |
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------| ------- | ------- |
| powersync | [![build](https://github.com/powersync-ja/powersync.dart/actions/workflows/packages.yml/badge.svg?branch=main)](https://github.com/powersync-ja/powersync.dart/actions?query=workflow%3Atest) | [![pub package](https://img.shields.io/pub/v/powersync.svg)](https://pub.dev/packages/powersync) | [![likes](https://img.shields.io/pub/likes/powersync?logo=dart)](https://pub.dev/packages/powersync/score) | [![popularity](https://img.shields.io/pub/popularity/powersync?logo=dart)](https://pub.dev/packages/powersync/score) | [![pub points](https://img.shields.io/pub/points/powersync?logo=dart)](https://pub.dev/packages/powersync/score)
| powersync_attachments_helper | [![build](https://github.com/powersync-ja/powersync.dart/actions/workflows/packages.yml/badge.svg?branch=main)](https://github.com/getsentry/powersync.dart/actions?query=workflow%3Asentry-flutter) | [![pub package](https://img.shields.io/pub/v/powersync_attachments_helper.svg)](https://pub.dev/packages/powersync_attachments_helper) | [![likes](https://img.shields.io/pub/likes/powersync_attachments_helper?logo=dart)](https://pub.dev/packages/powersync_attachments_helper/score) | [![popularity](https://img.shields.io/pub/popularity/powersync_attachments_helper?logo=dart)](https://pub.dev/packages/powersync_attachments_helper/score) | [![pub points](https://img.shields.io/pub/points/powersync_attachments_helper?logo=dart)](https://pub.dev/packages/powersync_attachments_helper/score)

## Getting started
#### Usage

This monorepo uses [melos](https://melos.invertase.dev/) to handle command and package management.

```dart
import 'package:powersync/powersync.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart';
For detailed usage, check out the inner [powersync](https://github.com/powersync-ja/powersync.dart/tree/main/packages/powersync.dart), [attachments-helper](https://github.com/powersync-ja/powersync.dart/tree/main/packages/powersync_attachments_helper.dart)

const schema = Schema([
Table('customers', [Column.text('name'), Column.text('email')])
]);
#### Blog posts

late PowerSyncDatabase db;
[Build an offline first Flutter app with Supabase DB](https://www.powersync.com/blog/flutter-tutorial-building-an-offline-first-chat-app-with-supabase-and-powersync).

openDatabase() async {
final dir = await getApplicationSupportDirectory();
final path = join(dir.path, 'powersync-dart.db');
// Setup the database.
db = PowerSyncDatabase(schema: schema, path: path);
await db.initialize();
#### Resources

// Run local statements.
await db.execute(
'INSERT INTO customers(id, name, email) VALUES(uuid(), ?, ?)',
['Fred', 'fred@example.org']);
}
connectPowerSync() async {
// DevConnector stores credentials in-memory by default.
// Extend the class to persist credentials.
final connector = DevConnector();
// Login in dev mode.
await connector.devLogin(
endpoint: 'https://myinstance.powersync.co',
user: 'demo',
password: 'demo');
// Connect to PowerSync service and start sync.
db.connect(connector: connector);
}
```
* [![PowerSync docs](https://img.shields.io/badge/documentation-powersync.com-green.svg?label=flutter%20docs)](https://docs.powersync.com/client-sdk-references/flutter)
* [![Discord Chat](https://img.shields.io/discord/1138230179878154300?style=social&logo=discord&logoColor=%235865f2&label=Join%20Discord%20server)](https://discord.gg/powersync)
* [![Twitter Follow](https://img.shields.io/twitter/follow/powersync?label=powersync&style=social)](https://twitter.com/intent/follow?screen_name=powersync_)
* [![YouTube](https://img.shields.io/youtube/channel/subscribers/UCSDdZvrZuizmc2EMBuTs2Qg?style=social&label=YouTube%20%40powersync_)](https://twitter.com/intent/follow?screen_name=powersync_)
68 changes: 68 additions & 0 deletions demos/powersync-supabase-flutter-simple-chat-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
.env

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/
/build/
.flutter-plugins-dependencies

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
*.jks

# iOS related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*synced_folder_marker_file
**/ios/**/Profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

# Secrets
app_config.dart
Loading

0 comments on commit f91d681

Please sign in to comment.