Skip to content

Commit

Permalink
chore(celest): Migrate to platform_storage
Browse files Browse the repository at this point in the history
Removes old interfaces in favor of `package:platform_storage`.
  • Loading branch information
dnys1 committed Apr 2, 2024
1 parent 388979a commit f114911
Show file tree
Hide file tree
Showing 174 changed files with 50 additions and 15,292 deletions.
132 changes: 5 additions & 127 deletions .github/workflows/celest_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ jobs:
steps:
- name: Git Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # 4.1.2
- name: Setup Flutter
uses: subosito/flutter-action@3d804929922b667a63a229bc59037807f969e885 # 2.15.0
with:
cache: true
- name: Setup Dart
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 # main
- name: Get Packages
working-directory: packages/celest_core
run: dart pub get
Expand All @@ -31,140 +29,20 @@ jobs:
- name: Format
working-directory: packages/celest_core
run: dart format --set-exit-if-changed .
test_darwin:
needs: analyze_and_format
runs-on: macos-latest-xlarge
timeout-minutes: 20
steps:
- name: Git Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # 4.1.2
- name: Setup Flutter
uses: subosito/flutter-action@3d804929922b667a63a229bc59037807f969e885 # 2.15.0
with:
cache: true
- name: Get Packages
working-directory: packages/celest_core
run: dart pub get
- name: Test
working-directory: packages/celest_core
run: dart test
- name: Get Packages (Example)
working-directory: packages/celest_core/example
run: flutter pub get
- name: Setup iOS Simulator
run: |
RUNTIME=$(xcrun simctl list runtimes | grep 'iOS 17' | tail -n 1 | cut -d' ' -f 7)
echo "Using runtime: $RUNTIME"
xcrun simctl create ios 'iPhone 15 Pro Max' $RUNTIME
echo "Booting simulator"
xcrun simctl boot ios
echo "Booted simulator"
- name: Test (iOS)
working-directory: packages/celest_core/example
run: flutter test -d ios integration_test/storage_test.dart
- name: Test (macOS)
working-directory: packages/celest_core/example
run: flutter test -d macos integration_test/storage_test.dart
test_android:
needs: analyze_and_format
runs-on:
group: public
labels: linux
timeout-minutes: 15
steps:
- name: Git Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # 4.1.2
- name: Setup Flutter
uses: subosito/flutter-action@3d804929922b667a63a229bc59037807f969e885 # 2.15.0
with:
cache: true
- name: Get Packages (Example)
working-directory: packages/celest_core/example
run: flutter pub get
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Test (Android)
uses: ReactiveCircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 # 2.30.1
with:
# Matches `package:jni` compileSdkVersion
# https://github.com/dart-lang/native/blob/001910c9f40d637cb25c19bb500fb89cebdf7450/pkgs/jni/android/build.gradle#L57C23-L57C25
api-level: 31
arch: x86_64
script: cd packages/celest_core/example && flutter test -d emulator integration_test/storage_test.dart
test_linux:
needs: analyze_and_format
test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Git Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # 4.1.2
- name: Setup Flutter
uses: subosito/flutter-action@3d804929922b667a63a229bc59037807f969e885 # 2.15.0
with:
cache: true
- name: Install Build Dependencies
run: sudo apt-get update && sudo apt-get install -y clang cmake git ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev
- name: Setup Test Environment
working-directory: packages/celest_core
run: tool/setup-ci.sh
- name: Setup Dart
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 # main
- name: Get Packages
working-directory: packages/celest_core
run: dart pub get
- name: Test
working-directory: packages/celest_core
run: dart test
- name: Get Packages (Example)
working-directory: packages/celest_core/example
run: flutter pub get
- name: Test (Linux)
working-directory: packages/celest_core/example
run: |
# Headless tests require virtual display for the linux tests to run.
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
flutter test -d linux integration_test/storage_test.dart
# TODO: Re-enable
# Need to fix this: Git error. Command: `git clone --mirror https://github.com/dart-lang/native /c/Users/runneradmin/.pub-cache\git\cache\native-647c69ed8027da6d6def6bc40efa87cf1a2f76aa`
# test_windows:
# needs: analyze_and_format
# runs-on: windows-latest
# timeout-minutes: 15
# steps:
# - name: Git Checkout
# uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # 4.1.2
# - name: Setup Flutter
# uses: subosito/flutter-action@3d804929922b667a63a229bc59037807f969e885 # 2.15.0
# with:
# cache: true
# - name: Get Packages
# working-directory: packages/celest_core
# run: dart pub get --no-example
# - name: Test
# working-directory: packages/celest_core
# run: dart test
# - name: Get Packages (Example)
# working-directory: packages/celest_core/example
# run: flutter pub get
# - name: Test (Windows)
# working-directory: packages/celest_core/example
# run: flutter test -d windows integration_test/storage_test.dart
test_web:
needs: analyze_and_format
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Git Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # 4.1.2
- name: Setup Flutter
uses: subosito/flutter-action@3d804929922b667a63a229bc59037807f969e885 # 2.15.0
with:
cache: true
- name: Get Packages
working-directory: packages/celest_core
run: dart pub get
- name: Test (Chrome, dart2js)
working-directory: packages/celest_core
run: dart test -p chrome
Expand Down
5 changes: 1 addition & 4 deletions examples/todo/celest/lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ class Celest with CelestBase {

late CelestEnvironment _currentEnvironment;

late final SecureStorage _secureStorage = SecureStorage();

@override
late _$http.Client httpClient =
CelestHttpClient(secureStorage: _secureStorage);
late _$http.Client httpClient = CelestHttpClient();

late Uri _baseUri;

Expand Down
6 changes: 5 additions & 1 deletion packages/celest_auth/example/celest/lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class Celest with CelestBase {

late CelestEnvironment _currentEnvironment;

late final SecureStorage _secureStorage = SecureStorage();
late final String _namespace = 'TODO';

late final PlatformSecureStorage _secureStorage = PlatformSecureStorage(
namespace: _namespace,
);

@override
late _$http.Client httpClient =
Expand Down
3 changes: 2 additions & 1 deletion packages/celest_auth/example/celest/lib/src/client/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ extension type CelestAuth._(_$auth_impl.AuthImpl _hub)
implements _$celest_auth.Auth {
CelestAuth(
CelestBase celest, {
required SecureStorage secureStorage,
required PlatformSecureStorage secureStorage,
PlatformLocalStorage? localStorage,
}) : _hub = _$auth_impl.AuthImpl(
celest,
secureStorage: secureStorage,
Expand Down
2 changes: 2 additions & 0 deletions packages/celest_auth/example/celest/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ dependency_overrides:
path: ../../
celest_core:
path: ../../../celest_core
platform_storage:
path: ../../../platform/storage

dev_dependencies:
lints: ^3.0.0
Expand Down
19 changes: 13 additions & 6 deletions packages/celest_auth/lib/src/auth_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ export 'flows/email_flow.dart';
final class AuthImpl implements Auth {
AuthImpl(
this.celest, {
required this.secureStorage,
LocalStorage? localStorage,
}) : localStorage = localStorage ?? LocalStorage();
required PlatformSecureStorage secureStorage,
PlatformLocalStorage? localStorage,
}) : secureStorage = secureStorage.scoped('celest_auth'),
localStorage = (localStorage ??
PlatformLocalStorage(
namespace: secureStorage.namespace,
scope: secureStorage.scope))
.scoped('celest_auth');

AuthState? _authState;

Expand Down Expand Up @@ -84,7 +89,7 @@ final class AuthImpl implements Auth {
@override
Future<void> signOut() async {
localStorage.delete('userId');
secureStorage.delete('cork');
secureStorage.isolated.delete('cork').ignore();
try {
await protocol.signOut();
} finally {
Expand All @@ -93,12 +98,14 @@ final class AuthImpl implements Auth {
}

final CelestBase celest;
final LocalStorage localStorage;
final SecureStorage secureStorage;
final PlatformLocalStorage localStorage;
final PlatformSecureStorage secureStorage;

late final AuthClient protocol = AuthClient(celest);

Future<void> close() async {
localStorage.close();
secureStorage.close();
await _authStateSubscription.cancel();
await _authFlowSubscription?.cancel();
await _authStateController.close();
Expand Down
6 changes: 6 additions & 0 deletions packages/celest_auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ dependencies:
shelf_router: ^1.1.4
stream_transform: ^2.1.0

dependency_overrides:
celest_core:
path: ../celest_core
platform_storage:
path: ../platform/storage

dev_dependencies:
build_runner: ^2.4.8
built_value_generator: ^8.9.1
Expand Down
43 changes: 0 additions & 43 deletions packages/celest_core/example/.gitignore

This file was deleted.

45 changes: 0 additions & 45 deletions packages/celest_core/example/.metadata

This file was deleted.

3 changes: 0 additions & 3 deletions packages/celest_core/example/README.md

This file was deleted.

1 change: 0 additions & 1 deletion packages/celest_core/example/analysis_options.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions packages/celest_core/example/android/.gitignore

This file was deleted.

Loading

0 comments on commit f114911

Please sign in to comment.