add git flutter hook

This commit is contained in:
appflowy 2021-07-06 19:56:56 +08:00
parent dfc2cbff4f
commit 3d0200a4a0
14 changed files with 114 additions and 48 deletions

4
.githooks/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
#flutter format .

21
.githooks/pre-push Executable file
View File

@ -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'

View File

@ -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" />

View File

@ -12,7 +12,7 @@ abstract class HomeState implements _$HomeState {
factory HomeState.initial() => HomeState(
isLoading: false,
showMenu: true,
pageContext: BlankPageContext(),
pageContext: const BlankPageContext(),
editContext: none(),
);
}

View File

@ -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();
}

View File

@ -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"

View File

@ -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';

View File

@ -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"

View File

@ -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:

View File

@ -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,

View File

@ -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:

View File

@ -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

View File

@ -16,6 +16,21 @@ fn sign_in_without_password() {
dbg!(&result);
}
#[test]
#[should_panic]
fn sign_in_with_invalid_password() {
let params = UserSignInParams {
email: "annie@appflowy.io".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() {

View File

@ -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();
}