mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-22 08:27:12 +00:00

* refactor: using tokio-postgres * chore: update * chore: update env * chore: update * chore: upgrade supabase and add logout button * refactor: update * chore: update * refactor: using message queue to handle the pg connection * refactor: move test * refactor: update sql * chore: create pg database when user login * chore: update scheme * chore: generic user service * chore: update * chore: create statistics * chore: create snapshot * chore: add test * chore: add database cloud service * chore: add document cloud service * chore: update interface * test: add document test * refactor: document interface * chore: fix test * chore: update * chore: update test * test: add test * test: add test * test: add test * chore: update collab rev * fix: flutter analyzer * chore: update * chore: update * chore: update * fix: tests * chore: update * chore: update collab rev * ci: rust fmt --------- Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
68 lines
2.0 KiB
Dart
68 lines
2.0 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:appflowy/env/env.dart';
|
|
import 'package:appflowy_backend/appflowy_backend.dart';
|
|
import 'package:appflowy_backend/env_serde.dart';
|
|
import 'package:path_provider/path_provider.dart';
|
|
import 'package:path/path.dart' as path;
|
|
|
|
import '../startup.dart';
|
|
|
|
class InitRustSDKTask extends LaunchTask {
|
|
const InitRustSDKTask({
|
|
this.directory,
|
|
});
|
|
|
|
// Customize the RustSDK initialization path
|
|
final Directory? directory;
|
|
|
|
@override
|
|
LaunchTaskType get type => LaunchTaskType.dataProcessing;
|
|
|
|
@override
|
|
Future<void> initialize(LaunchContext context) async {
|
|
final dir = directory ?? await appFlowyApplicationDataDirectory();
|
|
|
|
final env = getAppFlowyEnv();
|
|
context.getIt<FlowySDK>().setEnv(env);
|
|
await context.getIt<FlowySDK>().init(dir);
|
|
}
|
|
}
|
|
|
|
AppFlowyEnv getAppFlowyEnv() {
|
|
final postgresConfig = PostgresConfiguration(
|
|
url: Env.supabaseDb,
|
|
password: Env.supabaseDbPassword,
|
|
port: int.parse(Env.supabaseDbPort),
|
|
user_name: Env.supabaseDbUser,
|
|
);
|
|
|
|
final supabaseConfig = SupabaseConfiguration(
|
|
url: Env.supabaseUrl,
|
|
key: Env.supabaseKey,
|
|
jwt_secret: Env.supabaseJwtSecret,
|
|
postgres_config: postgresConfig,
|
|
);
|
|
|
|
return AppFlowyEnv(
|
|
supabase_config: supabaseConfig,
|
|
);
|
|
}
|
|
|
|
/// The default directory to store the user data. The directory can be
|
|
/// customized by the user via the [ApplicationDataStorage]
|
|
Future<Directory> appFlowyApplicationDataDirectory() async {
|
|
switch (integrationEnv()) {
|
|
case IntegrationMode.develop:
|
|
final Directory documentsDir = await getApplicationSupportDirectory()
|
|
..create();
|
|
return Directory(path.join(documentsDir.path, 'data_dev')).create();
|
|
case IntegrationMode.release:
|
|
final Directory documentsDir = await getApplicationSupportDirectory();
|
|
return Directory(path.join(documentsDir.path, 'data')).create();
|
|
case IntegrationMode.unitTest:
|
|
case IntegrationMode.integrationTest:
|
|
return Directory(path.join(Directory.current.path, '.sandbox'));
|
|
}
|
|
}
|