Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: separate develop, release, test working directory
appflowycdec567cbbb6
diff --git a/frontend/app_flowy/.gitignore b/frontend/app_flowy/.gitignoreindex 2994a32631..3421d1450b 100644--- a/frontend/app_flowy/.gitignore+++ b/frontend/app_flowy/.gitignore@@ -60,4 +60,4 @@ windows/flutter/dart_ffi/**/**/*.dll**/**/*.so**/**/Brewfile.lock.json-**/.appflowy_dev\ No newline at end of file+**/.sandbox\ No newline at end of filediff --git a/frontend/app_flowy/lib/main.dart b/frontend/app_flowy/lib/main.dartindex 6b85925542..a2d7f66605 100644--- a/frontend/app_flowy/lib/main.dart+++ b/frontend/app_flowy/lib/main.dart@@ -14,5 +14,5 @@ void main() async {WidgetsFlutterBinding.ensureInitialized();await EasyLocalization.ensureInitialized();- await System.run(FlowyApp());+ await FlowySystem.run(FlowyApp());}diff --git a/frontend/app_flowy/lib/startup/startup.dart b/frontend/app_flowy/lib/startup/startup.dartindex f92a0876a2..d5f618183e 100644--- a/frontend/app_flowy/lib/startup/startup.dart+++ b/frontend/app_flowy/lib/startup/startup.dart@@ -30,15 +30,11 @@ abstract class EntryPoint {Widget create();}-class System {+class FlowySystem {static Future<void> run(EntryPoint f) async {// Specify the envfinal env = integrationEnv();-- // Config the deps graph- getIt.registerFactory<EntryPoint>(() => f);-- resolveDependencies(env);+ initGetIt(getIt, env, f);// add taskgetIt<AppLauncher>().addTask(InitRustSDKTask());@@ -53,12 +49,12 @@ class System {}}-void resolveDependencies(IntegrationEnv env) => initGetIt(getIt, env);-Future<void> initGetIt(GetIt getIt,IntegrationEnv env,+ EntryPoint f,) async {+ getIt.registerFactory<EntryPoint>(() => f);getIt.registerLazySingleton<FlowySDK>(() => const FlowySDK());getIt.registerLazySingleton<AppLauncher>(() => AppLauncher(env, getIt));diff --git a/frontend/app_flowy/lib/startup/tasks/init_sdk.dart b/frontend/app_flowy/lib/startup/tasks/init_sdk.dartindex a707f5954e..730f0c9e7a 100644--- a/frontend/app_flowy/lib/startup/tasks/init_sdk.dart+++ b/frontend/app_flowy/lib/startup/tasks/init_sdk.dart@@ -11,6 +11,12 @@ class InitRustSDKTask extends LaunchTask {Future<void> initialize(LaunchContext context) async {switch (context.env) {case IntegrationEnv.develop:+ Directory directory = await getApplicationDocumentsDirectory();+ return Directory('${directory.path}/flowy_dev').create().then(+ (Directory directory) async {+ await context.getIt<FlowySDK>().init(directory);+ },+ );case IntegrationEnv.release:Directory directory = await getApplicationDocumentsDirectory();return Directory('${directory.path}/flowy').create().then(@@ -19,14 +25,14 @@ class InitRustSDKTask extends LaunchTask {},);case IntegrationEnv.test:- await context.getIt<FlowySDK>().init(testDir());+ await context.getIt<FlowySDK>().init(testWorkingDirectory());break;default:assert(false, 'Unsupported env');}}- Directory testDir() {- return Directory("${Directory.current.path}/.appflowy_dev");+ Directory testWorkingDirectory() {+ return Directory("${Directory.current.path}/.sandbox");}}diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart b/frontend/app_flowy/packages/flowy_sdk/lib/ffi.dartindex 07f12685f7..798c33b318 100644--- a/frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart+++ b/frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart@@ -13,21 +13,21 @@ final DynamicLibrary _dl = _open();final DynamicLibrary dl = _dl;DynamicLibrary _open() {if (Platform.environment.containsKey('FLUTTER_TEST')) {- final prefix = "${Directory.current.path}/.appflowy_dev";+ final prefix = "${Directory.current.path}/.sandbox";if (Platform.isLinux) return DynamicLibrary.open('${prefix}/libdart_ffi.so');if (Platform.isAndroid) return DynamicLibrary.open('${prefix}/libdart_ffi.so');if (Platform.isMacOS) return DynamicLibrary.open('${prefix}/libdart_ffi.dylib');if (Platform.isIOS) return DynamicLibrary.open('${prefix}/libdart_ffi.dylib');if (Platform.isWindows) return DynamicLibrary.open('${prefix}/dart_ffi.dll');- throw UnsupportedError('This platform is not supported.');} else {if (Platform.isLinux) return DynamicLibrary.open('libdart_ffi.so');if (Platform.isAndroid) return DynamicLibrary.open('libdart_ffi.so');if (Platform.isMacOS) return DynamicLibrary.executable();if (Platform.isIOS) return DynamicLibrary.executable();if (Platform.isWindows) return DynamicLibrary.open('dart_ffi.dll');- throw UnsupportedError('This platform is not supported.');}++ throw UnsupportedError('This platform is not supported.');}/// C function `async_event`.diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/log.dart b/frontend/app_flowy/packages/flowy_sdk/lib/log.dartindex b842e8827a..a34faaff0e 100644--- a/frontend/app_flowy/packages/flowy_sdk/lib/log.dart+++ b/frontend/app_flowy/packages/flowy_sdk/lib/log.dart@@ -9,8 +9,7 @@ class Log {_logger = Logger(printer: PrettyPrinter(methodCount: 2, // number of method calls to be displayed- errorMethodCount:- 8, // number of method calls if stacktrace is provided+ errorMethodCount: 8, // number of method calls if stacktrace is providedlineLength: 120, // width of the outputcolors: true, // Colorful log messagesprintEmojis: true, // Print an emoji for each log message@@ -27,6 +26,10 @@ class Log {Log.shared._logger.d(msg);}+ static void warn(dynamic msg) {+ Log.shared._logger.w(msg);+ }+static void trace(dynamic msg) {Log.shared._logger.d(msg);}diff --git a/frontend/app_flowy/test/util/test_env.dart b/frontend/app_flowy/test/util/test_env.dartindex 5fab07d919..9f4c27d2bc 100644--- a/frontend/app_flowy/test/util/test_env.dart+++ b/frontend/app_flowy/test/util/test_env.dart@@ -10,7 +10,7 @@ class FlowyTest {TestWidgetsFlutterBinding.ensureInitialized();// await EasyLocalization.ensureInitialized();- await System.run(FlowyTestApp());+ await FlowySystem.run(FlowyTestApp());return FlowyTest();}diff --git a/frontend/scripts/makefile/desktop.toml b/frontend/scripts/makefile/desktop.tomlindex 00d1c881f7..458801ee26 100644--- a/frontend/scripts/makefile/desktop.toml+++ b/frontend/scripts/makefile/desktop.toml@@ -138,12 +138,10 @@ script = ["""# Copy the flowy_sdk lib to system temp directory for flutter unit test.lib = set lib${LIB_NAME}.${SDK_EXT}- dest = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/.appflowy_dev/${lib}+ dest = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/.sandbox/${lib}rm ${dest}cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${lib} \${dest}-- echo copy ${lib} to ${dest}""",]script_runner = "@duckscript"