Skip to content

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.

add git flutter hook

appflowy3d0200a4a0cd
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100755
index 0000000000..eb09ba97ff
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+
+#flutter format .
+
diff --git a/.githooks/pre-push b/.githooks/pre-push
new file mode 100755
index 0000000000..72c666bcb0
--- /dev/null
+++ b/.githooks/pre-push
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+cd flutter-lib
+if [[ `git status --porcelain` ]]; then
+ printf "\e[31;1m%s\e[0m\n" 'This script needs to run against committed code only. Please commit or stash you changes.'
+ exit 1
+fi
+printf "\e[33;1m%s\e[0m\n" 'Running the Flutter analyzer'
+flutter analyze
+if [ $? -ne 0 ]; then
+ printf "\e[31;1m%s\e[0m\n" 'Flutter analyzer error'
+ exit 1
+fi
+printf "\e[33;1m%s\e[0m\n" 'Finished running the Flutter analyzer'
+printf "\e[33;1m%s\e[0m\n" 'Running unit tests'
+
+#flutter test
+#if [ $? -ne 0 ]; then
+# printf "\e[31;1m%s\e[0m\n" 'Unit tests error'
+# exit 1
+#fi
+#printf "\e[33;1m%s\e[0m\n" 'Finished running unit tests'
diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml
index 88a96cd453..f30e73c4f6 100644
--- a/.idea/libraries/Dart_Packages.xml
+++ b/.idea/libraries/Dart_Packages.xml
@@ -524,6 +524,14 @@
</list>
</value>
</entry>
+ <entry key="protobuf">
+ <value>
+ <list>
+ <option value="$PROJECT_DIR$/../../flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-2.0.0/lib" />
+ <option value="$PROJECT_DIR$/../../flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-1.1.4/lib" />
+ </list>
+ </value>
+ </entry>
<entry key="provider">
<value>
<list>
@@ -833,6 +841,8 @@
<root url="file://$PROJECT_DIR$/../../flutter/.pub-cache/hosted/pub.dartlang.org/plugin_platform_interface-2.0.0/lib" />
<root url="file://$PROJECT_DIR$/../../flutter/.pub-cache/hosted/pub.dartlang.org/pool-1.5.0/lib" />
<root url="file://$PROJECT_DIR$/../../flutter/.pub-cache/hosted/pub.dartlang.org/process-4.2.1/lib" />
+ <root url="file://$PROJECT_DIR$/../../flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-1.1.4/lib" />
+ <root url="file://$PROJECT_DIR$/../../flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-2.0.0/lib" />
<root url="file://$PROJECT_DIR$/../../flutter/.pub-cache/hosted/pub.dartlang.org/provider-5.0.0/lib" />
<root url="file://$PROJECT_DIR$/../../flutter/.pub-cache/hosted/pub.dartlang.org/pub_semver-2.0.0/lib" />
<root url="file://$PROJECT_DIR$/../../flutter/.pub-cache/hosted/pub.dartlang.org/pubspec_parse-1.0.0/lib" />
diff --git a/app_flowy/lib/home/application/home_state.dart b/app_flowy/lib/home/application/home_state.dart
index fdbe7d8ab2..ce0be0f38e 100644
--- a/app_flowy/lib/home/application/home_state.dart
+++ b/app_flowy/lib/home/application/home_state.dart
@@ -12,7 +12,7 @@ abstract class HomeState implements _$HomeState {
factory HomeState.initial() => HomeState(
isLoading: false,
showMenu: true,
- pageContext: BlankPageContext(),
+ pageContext: const BlankPageContext(),
editContext: none(),
);
}
diff --git a/app_flowy/lib/home/presentation/home_screen.dart b/app_flowy/lib/home/presentation/home_screen.dart
index 25326edaf5..abbb84c822 100644
--- a/app_flowy/lib/home/presentation/home_screen.dart
+++ b/app_flowy/lib/home/presentation/home_screen.dart
@@ -28,7 +28,7 @@ List<Widget> buildPagesWidget(PageContext pageContext) {
if (pageType == pageContext.pageType) {
return pageType.builder(pageContext);
} else {
- return BlankPage(context: BlankPageContext());
+ return const BlankPage(context: BlankPageContext());
}
}).toList();
}
diff --git a/app_flowy/packages/flowy_sdk/example/pubspec.lock b/app_flowy/packages/flowy_sdk/example/pubspec.lock
index 66181a88e0..fb3fe6cd09 100644
--- a/app_flowy/packages/flowy_sdk/example/pubspec.lock
+++ b/app_flowy/packages/flowy_sdk/example/pubspec.lock
@@ -92,6 +92,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.1"
+ fixnum:
+ dependency: transitive
+ description:
+ name: fixnum
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.0"
flowy_logger:
dependency: transitive
description:
@@ -201,6 +208,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
+ protobuf:
+ dependency: transitive
+ description:
+ name: protobuf
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.0"
sky_engine:
dependency: transitive
description: flutter
@@ -299,4 +313,4 @@ packages:
version: "3.0.0"
sdks:
dart: ">=2.12.0 <3.0.0"
- flutter: ">=1.20.0"
+ flutter: ">=1.17.0"
diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf.dart b/app_flowy/packages/flowy_sdk/lib/protobuf.dart
index edd50e1efa..3927794b79 100644
--- a/app_flowy/packages/flowy_sdk/lib/protobuf.dart
+++ b/app_flowy/packages/flowy_sdk/lib/protobuf.dart
@@ -1,21 +1,6 @@
// Auto-generated, do not edit
-export 'protobuf/sign_in.pbjson.pb.dart';
-export 'protobuf/sign_in.pb.pb.dart';
-export 'protobuf/ffi_response.pbjson.pb.dart';
-export 'protobuf/ffi_request.pbserver.pb.dart';
-export 'protobuf/ffi_response.pb.pb.dart';
-export 'protobuf/user.pbenum.pb.dart';
-export 'protobuf/user.pbserver.pb.dart';
-export 'protobuf/ffi_request.pbjson.pb.dart';
-export 'protobuf/sign_up.pbjson.pb.dart';
-export 'protobuf/ffi_request.pbenum.pb.dart';
-export 'protobuf/sign_up.pbenum.pb.dart';
-export 'protobuf/sign_up.pbserver.pb.dart';
-export 'protobuf/user.pbjson.pb.dart';
-export 'protobuf/ffi_response.pbserver.pb.dart';
-export 'protobuf/ffi_response.pbenum.pb.dart';
-export 'protobuf/sign_in.pbserver.pb.dart';
-export 'protobuf/sign_up.pb.pb.dart';
-export 'protobuf/user.pb.pb.dart';
-export 'protobuf/sign_in.pbenum.pb.dart';
-export 'protobuf/ffi_request.pb.pb.dart';
+export 'protobuf/ffi_response.pb.dart';
+export 'protobuf/ffi_request.pb.dart';
+export 'protobuf/sign_up.pb.dart';
+export 'protobuf/sign_in.pb.dart';
+export 'protobuf/user.pb.dart';
diff --git a/app_flowy/packages/flowy_sdk/pubspec.lock b/app_flowy/packages/flowy_sdk/pubspec.lock
index 226a179f9b..72a28403fd 100644
--- a/app_flowy/packages/flowy_sdk/pubspec.lock
+++ b/app_flowy/packages/flowy_sdk/pubspec.lock
@@ -84,14 +84,14 @@ packages:
name: built_collection
url: "https://pub.dartlang.org"
source: hosted
- version: "4.3.2"
+ version: "5.1.0"
built_value:
dependency: transitive
description:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
- version: "7.1.0"
+ version: "8.1.0"
characters:
dependency: transitive
description:
@@ -196,7 +196,7 @@ packages:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
- version: "0.10.11"
+ version: "1.0.0"
flowy_logger:
dependency: "direct main"
description:
@@ -347,6 +347,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
+ protobuf:
+ dependency: "direct main"
+ description:
+ name: protobuf
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.0"
pub_semver:
dependency: transitive
description:
@@ -361,13 +368,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
- quiver:
- dependency: transitive
- description:
- name: quiver
- url: "https://pub.dartlang.org"
- source: hosted
- version: "2.1.5"
shelf:
dependency: transitive
description:
@@ -494,4 +494,4 @@ packages:
version: "3.1.0"
sdks:
dart: ">=2.12.0 <3.0.0"
- flutter: ">=1.20.0"
+ flutter: ">=1.17.0"
diff --git a/app_flowy/packages/flowy_sdk/pubspec.yaml b/app_flowy/packages/flowy_sdk/pubspec.yaml
index 0f75d84953..54237e247c 100644
--- a/app_flowy/packages/flowy_sdk/pubspec.yaml
+++ b/app_flowy/packages/flowy_sdk/pubspec.yaml
@@ -7,13 +7,14 @@ publish_to: 'none'
environment:
sdk: ">=2.12.0-0 <3.0.0"
- flutter: ">=1.20.0"
+ flutter: ">=1.17.0"
dependencies:
flutter:
sdk: flutter
ffi: ^1.0.0
isolates: ^3.0.3+8
+ protobuf: "2.0.0"
flowy_logger:
path: ../flowy_logger
infra:
diff --git a/app_flowy/packages/flowy_style/lib/route/animation.dart b/app_flowy/packages/flowy_style/lib/route/animation.dart
index 265380353a..b4f53008d3 100644
--- a/app_flowy/packages/flowy_style/lib/route/animation.dart
+++ b/app_flowy/packages/flowy_style/lib/route/animation.dart
@@ -72,7 +72,7 @@ class PageRoutes {
transitionsBuilder: (context, animation, secondaryAnimation, child) {
bool reverse = animation.status == AnimationStatus.reverse;
return SlideTransition(
- position: Tween<Offset>(begin: startOffset, end: Offset(0, 0))
+ position: Tween<Offset>(begin: startOffset, end: const Offset(0, 0))
.animate(CurvedAnimation(
parent: animation, curve: reverse ? easeReverse : easeFwd)),
child: child,
diff --git a/app_flowy/pubspec.lock b/app_flowy/pubspec.lock
index c3225910e2..e5f60700d6 100644
--- a/app_flowy/pubspec.lock
+++ b/app_flowy/pubspec.lock
@@ -259,7 +259,7 @@ packages:
source: hosted
version: "7.0.1"
flutter_lints:
- dependency: "direct dev"
+ dependency: "direct main"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
@@ -494,6 +494,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
+ protobuf:
+ dependency: transitive
+ description:
+ name: protobuf
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.0"
provider:
dependency: transitive
description:
diff --git a/app_flowy/pubspec.yaml b/app_flowy/pubspec.yaml
index 9d276bda02..9655f6414f 100644
--- a/app_flowy/pubspec.yaml
+++ b/app_flowy/pubspec.yaml
@@ -56,8 +56,9 @@ dev_dependencies:
flutter_test:
sdk: flutter
build_runner:
- freezed: '>=0.14.2'
flutter_lints: ^1.0.0
+ freezed: '>=0.14.2'
+
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
diff --git a/rust-lib/flowy-user/tests/sign_in.rs b/rust-lib/flowy-user/tests/sign_in.rs
index c625114b44..4d886d7565 100644
--- a/rust-lib/flowy-user/tests/sign_in.rs
+++ b/rust-lib/flowy-user/tests/sign_in.rs
@@ -16,6 +16,21 @@ fn sign_in_without_password() {
dbg!(&result);
}
+#[test]
+#[should_panic]
+fn sign_in_with_invalid_password() {
+ let params = UserSignInParams {
+ email: "[email protected]".to_string(),
+ password: "123".to_string(),
+ };
+
+ let result = EventTester::new(SignIn)
+ .payload(params)
+ .assert_status_code(StatusCode::Err)
+ .sync_send::<UserSignInResult>();
+ dbg!(&result);
+}
+
#[test]
#[should_panic]
fn sign_in_without_email() {
diff --git a/scripts/flowy-tool/src/proto/proto_gen.rs b/scripts/flowy-tool/src/proto/proto_gen.rs
index 51c8fd56b6..1bb4bb187f 100644
--- a/scripts/flowy-tool/src/proto/proto_gen.rs
+++ b/scripts/flowy-tool/src/proto/proto_gen.rs
@@ -24,7 +24,7 @@ impl ProtoGen {
// FIXME: ignore unchanged file to reduce time cost
let flutter_package = FlutterProtobufInfo::new(self.flutter_package_lib.as_ref());
run_flutter_protoc(&crate_proto_infos, &flutter_package);
- write_flutter_protobuf_package_mod_file(&flutter_package);
+ write_flutter_protobuf_package_mod_file(&crate_proto_infos, &flutter_package);
}
}
@@ -72,7 +72,10 @@ fn write_rust_crate_mod_file(crate_infos: &Vec<CrateProtoInfo>) {
}
}
-fn write_flutter_protobuf_package_mod_file(package_info: &FlutterProtobufInfo) {
+fn write_flutter_protobuf_package_mod_file(
+ crate_infos: &Vec<CrateProtoInfo>,
+ package_info: &FlutterProtobufInfo,
+) {
let mod_path = package_info.mod_file_path();
let model_dir = package_info.model_dir();
match OpenOptions::new()
@@ -85,14 +88,19 @@ fn write_flutter_protobuf_package_mod_file(package_info: &FlutterProtobufInfo) {
Ok(ref mut file) => {
let mut mod_file_content = String::new();
mod_file_content.push_str("// Auto-generated, do not edit \n");
- walk_dir(
- model_dir.as_ref(),
- |e| e.file_type().is_dir() == false,
- |_, name| {
- let c = format!("export 'protobuf/{}.pb.dart';\n", &name);
- mod_file_content.push_str(c.as_ref());
- },
- );
+
+ for crate_info in crate_infos {
+ let mod_path = crate_info.inner.proto_model_mod_file();
+ walk_dir(
+ crate_info.inner.proto_file_output_dir().as_ref(),
+ |e| e.file_type().is_dir() == false,
+ |_, name| {
+ let c = format!("export 'protobuf/{}.pb.dart';\n", &name);
+ mod_file_content.push_str(c.as_ref());
+ },
+ );
+ }
+
file.write_all(mod_file_content.as_bytes()).unwrap();
file.flush().unwrap();
}