mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
[code gen]: generate the protobuf files in corresponding module
This commit is contained in:
parent
1f42fa557b
commit
bf198783e1
@ -19,6 +19,7 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-database/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-sqlite/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-infra/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-workspace/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/app_flowy/packages/af_protobuf/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/app_flowy/packages/af_protobuf/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/app_flowy/packages/af_protobuf/build" />
|
||||
|
@ -5,7 +5,7 @@ import 'package:app_flowy/home/presentation/widgets/prelude.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:flowy_infra/flowy_logger.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/styled_container.dart';
|
||||
import 'package:flowy_sdk/protobuf/user_detail.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:app_flowy/user/domain/interface.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/protobuf/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/user_detail.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
// ignore: import_of_legacy_library_into_null_safe
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'package:flowy_sdk/protobuf/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/user_detail.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
|
||||
abstract class IAuth {
|
||||
|
@ -1,9 +1,6 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
import 'package:flowy_sdk/protobuf/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/sign_in.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/sign_up.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/user_detail.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||
|
||||
class AuthRepository {
|
||||
Future<Either<UserDetail, UserError>> signIn(
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:app_flowy/user/application/sign_in/sign_in_bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/protobuf/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/user_detail.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
import 'package:app_flowy/user/domain/interface.dart';
|
||||
|
@ -5,8 +5,7 @@ import 'package:app_flowy/user/presentation/sign_in/widgets/background.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_infra_ui/widget/rounded_button.dart';
|
||||
import 'package:flowy_infra_ui/widget/rounded_input_field.dart';
|
||||
import 'package:flowy_sdk/protobuf/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/user_detail.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'package:flowy_sdk/protobuf/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/user_detail.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'auth_state.freezed.dart';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:flowy_sdk/protobuf/user_detail.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'auth_state.dart';
|
||||
|
@ -8,7 +8,7 @@ import 'package:app_flowy/welcome/application/welcome_bloc.dart';
|
||||
import 'package:app_flowy/welcome/domain/auth_state.dart';
|
||||
import 'package:app_flowy/welcome/domain/interface.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
import 'package:flowy_sdk/protobuf/user_detail.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'dart:ffi';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_infra/flowy_logger.dart';
|
||||
import 'package:flowy_sdk/protobuf/ffi_response.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/dart-ffi/ffi_response.pb.dart';
|
||||
import 'package:isolates/isolates.dart';
|
||||
import 'package:isolates/ports.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
@ -10,7 +10,10 @@ import 'package:flutter/services.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'package:flowy_sdk/ffi.dart' as ffi;
|
||||
import 'package:flowy_sdk/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||
import 'package:flowy_sdk/protobuf/dart-ffi/protobuf.dart';
|
||||
// ignore: unused_import
|
||||
import 'package:flowy_sdk/protobuf/flowy-infra/protobuf.dart';
|
||||
import 'package:protobuf/protobuf.dart';
|
||||
|
||||
import 'error.dart';
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'package:flowy_sdk/protobuf/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/ffi_response.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/dart-ffi/protobuf.dart';
|
||||
|
||||
class FlowyError {
|
||||
late FFIStatusCode _statusCode;
|
||||
@ -29,12 +28,6 @@ class FlowyError {
|
||||
factory FlowyError.from(FFIResponse resp) {
|
||||
return FlowyError(statusCode: resp.code, error: "");
|
||||
}
|
||||
|
||||
UserError userErrorFromFlowyError() {
|
||||
return UserError.create()
|
||||
..code = UserErrorCode.Unknown
|
||||
..msg = this.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class StackTraceError {
|
||||
|
@ -1,10 +0,0 @@
|
||||
// Auto-generated, do not edit
|
||||
export 'protobuf/kv.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_table.pb.dart';
|
||||
export 'protobuf/errors.pb.dart';
|
||||
export 'protobuf/user_detail.pb.dart';
|
||||
export 'protobuf/event.pb.dart';
|
@ -0,0 +1,3 @@
|
||||
// Auto-generated, do not edit
|
||||
export './ffi_response.pb.dart';
|
||||
export './ffi_request.pb.dart';
|
@ -0,0 +1,2 @@
|
||||
// Auto-generated, do not edit
|
||||
export './kv.pb.dart';
|
@ -0,0 +1,7 @@
|
||||
// Auto-generated, do not edit
|
||||
export './sign_up.pb.dart';
|
||||
export './sign_in.pb.dart';
|
||||
export './user_table.pb.dart';
|
||||
export './errors.pb.dart';
|
||||
export './user_detail.pb.dart';
|
||||
export './event.pb.dart';
|
@ -0,0 +1 @@
|
||||
// Auto-generated, do not edit
|
@ -11,6 +11,7 @@ members = [
|
||||
"flowy-sqlite",
|
||||
"flowy-database",
|
||||
"flowy-infra",
|
||||
"flowy-workspace",
|
||||
]
|
||||
|
||||
[profile.dev]
|
||||
|
@ -442,26 +442,26 @@ static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
_value\x18\x04\x20\x01(\x01H\x02R\nfloatValue\x12\x1f\n\nbool_value\x18\
|
||||
\x05\x20\x01(\x08H\x03R\tboolValueB\x12\n\x10one_of_str_valueB\x12\n\x10\
|
||||
one_of_int_valueB\x14\n\x12one_of_float_valueB\x13\n\x11one_of_bool_valu\
|
||||
eJ\xa9\x03\n\x06\x12\x04\0\0\x07\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\
|
||||
\n\x02\x04\0\x12\x04\x01\0\x07\x01\n\n\n\x03\x04\0\x01\x12\x03\x01\x08\
|
||||
\x10\n\x0b\n\x04\x04\0\x02\0\x12\x03\x02\x04\x13\n\x0c\n\x05\x04\0\x02\0\
|
||||
\x05\x12\x03\x02\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x02\x0b\x0e\n\
|
||||
\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x02\x11\x12\n\x0b\n\x04\x04\0\x08\0\
|
||||
\x12\x03\x03\x044\n\x0c\n\x05\x04\0\x08\0\x01\x12\x03\x03\n\x1a\n\x0b\n\
|
||||
\x04\x04\0\x02\x01\x12\x03\x03\x1d2\n\x0c\n\x05\x04\0\x02\x01\x05\x12\
|
||||
\x03\x03\x1d#\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x03$-\n\x0c\n\x05\
|
||||
\x04\0\x02\x01\x03\x12\x03\x0301\n\x0b\n\x04\x04\0\x08\x01\x12\x03\x04\
|
||||
\x043\n\x0c\n\x05\x04\0\x08\x01\x01\x12\x03\x04\n\x1a\n\x0b\n\x04\x04\0\
|
||||
\x02\x02\x12\x03\x04\x1d1\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\x04\x1d\
|
||||
\"\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x04#,\n\x0c\n\x05\x04\0\x02\x02\
|
||||
\x03\x12\x03\x04/0\n\x0b\n\x04\x04\0\x08\x02\x12\x03\x05\x048\n\x0c\n\
|
||||
\x05\x04\0\x08\x02\x01\x12\x03\x05\n\x1c\n\x0b\n\x04\x04\0\x02\x03\x12\
|
||||
\x03\x05\x1f6\n\x0c\n\x05\x04\0\x02\x03\x05\x12\x03\x05\x1f%\n\x0c\n\x05\
|
||||
\x04\0\x02\x03\x01\x12\x03\x05&1\n\x0c\n\x05\x04\0\x02\x03\x03\x12\x03\
|
||||
\x0545\n\x0b\n\x04\x04\0\x08\x03\x12\x03\x06\x044\n\x0c\n\x05\x04\0\x08\
|
||||
\x03\x01\x12\x03\x06\n\x1b\n\x0b\n\x04\x04\0\x02\x04\x12\x03\x06\x1e2\n\
|
||||
\x0c\n\x05\x04\0\x02\x04\x05\x12\x03\x06\x1e\"\n\x0c\n\x05\x04\0\x02\x04\
|
||||
\x01\x12\x03\x06#-\n\x0c\n\x05\x04\0\x02\x04\x03\x12\x03\x0601b\x06proto\
|
||||
eJ\xa9\x03\n\x06\x12\x04\0\0\x08\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\
|
||||
\n\x02\x04\0\x12\x04\x02\0\x08\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\
|
||||
\x10\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x13\n\x0c\n\x05\x04\0\x02\0\
|
||||
\x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x0b\x0e\n\
|
||||
\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x11\x12\n\x0b\n\x04\x04\0\x08\0\
|
||||
\x12\x03\x04\x044\n\x0c\n\x05\x04\0\x08\0\x01\x12\x03\x04\n\x1a\n\x0b\n\
|
||||
\x04\x04\0\x02\x01\x12\x03\x04\x1d2\n\x0c\n\x05\x04\0\x02\x01\x05\x12\
|
||||
\x03\x04\x1d#\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04$-\n\x0c\n\x05\
|
||||
\x04\0\x02\x01\x03\x12\x03\x0401\n\x0b\n\x04\x04\0\x08\x01\x12\x03\x05\
|
||||
\x043\n\x0c\n\x05\x04\0\x08\x01\x01\x12\x03\x05\n\x1a\n\x0b\n\x04\x04\0\
|
||||
\x02\x02\x12\x03\x05\x1d1\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\x05\x1d\
|
||||
\"\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x05#,\n\x0c\n\x05\x04\0\x02\x02\
|
||||
\x03\x12\x03\x05/0\n\x0b\n\x04\x04\0\x08\x02\x12\x03\x06\x048\n\x0c\n\
|
||||
\x05\x04\0\x08\x02\x01\x12\x03\x06\n\x1c\n\x0b\n\x04\x04\0\x02\x03\x12\
|
||||
\x03\x06\x1f6\n\x0c\n\x05\x04\0\x02\x03\x05\x12\x03\x06\x1f%\n\x0c\n\x05\
|
||||
\x04\0\x02\x03\x01\x12\x03\x06&1\n\x0c\n\x05\x04\0\x02\x03\x03\x12\x03\
|
||||
\x0645\n\x0b\n\x04\x04\0\x08\x03\x12\x03\x07\x044\n\x0c\n\x05\x04\0\x08\
|
||||
\x03\x01\x12\x03\x07\n\x1b\n\x0b\n\x04\x04\0\x02\x04\x12\x03\x07\x1e2\n\
|
||||
\x0c\n\x05\x04\0\x02\x04\x05\x12\x03\x07\x1e\"\n\x0c\n\x05\x04\0\x02\x04\
|
||||
\x01\x12\x03\x07#-\n\x0c\n\x05\x04\0\x02\x04\x03\x12\x03\x0701b\x06proto\
|
||||
3\
|
||||
";
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message KeyValue {
|
||||
string key = 1;
|
||||
oneof one_of_str_value { string str_value = 2; };
|
||||
|
19
rust-lib/flowy-workspace/Cargo.toml
Normal file
19
rust-lib/flowy-workspace/Cargo.toml
Normal file
@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "flowy-workspace"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
flowy-dispatch = { path = "../flowy-dispatch" }
|
||||
flowy-log = { path = "../flowy-log" }
|
||||
flowy-derive = { path = "../flowy-derive" }
|
||||
flowy-database = { path = "../flowy-database" }
|
||||
flowy-sqlite = { path = "../flowy-sqlite" }
|
||||
flowy-infra = { path = "../flowy-infra" }
|
||||
|
||||
protobuf = {version = "2.18.0"}
|
||||
diesel = {version = "1.4.7", features = ["sqlite"]}
|
||||
diesel_derives = {version = "1.4.1", features = ["sqlite"]}
|
||||
lazy_static = "1.4.0"
|
6
rust-lib/flowy-workspace/Flowy.toml
Normal file
6
rust-lib/flowy-workspace/Flowy.toml
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
#proto_crates = ["src/entities", "src/event.rs", "src/errors.rs"]
|
||||
#event_files = ["src/event.rs"]
|
||||
|
||||
proto_crates = []
|
||||
event_files = []
|
0
rust-lib/flowy-workspace/src/entities/mod.rs
Normal file
0
rust-lib/flowy-workspace/src/entities/mod.rs
Normal file
0
rust-lib/flowy-workspace/src/errors.rs
Normal file
0
rust-lib/flowy-workspace/src/errors.rs
Normal file
0
rust-lib/flowy-workspace/src/event.rs
Normal file
0
rust-lib/flowy-workspace/src/event.rs
Normal file
5
rust-lib/flowy-workspace/src/lib.rs
Normal file
5
rust-lib/flowy-workspace/src/lib.rs
Normal file
@ -0,0 +1,5 @@
|
||||
pub mod entities;
|
||||
pub mod errors;
|
||||
pub mod event;
|
||||
pub mod module;
|
||||
mod sql_tables;
|
0
rust-lib/flowy-workspace/src/module.rs
Normal file
0
rust-lib/flowy-workspace/src/module.rs
Normal file
4
rust-lib/flowy-workspace/src/protobuf/mod.rs
Normal file
4
rust-lib/flowy-workspace/src/protobuf/mod.rs
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
mod model;
|
||||
pub use model::*;
|
||||
|
1
rust-lib/flowy-workspace/src/protobuf/model/mod.rs
Normal file
1
rust-lib/flowy-workspace/src/protobuf/model/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
// Auto-generated, do not edit
|
0
rust-lib/flowy-workspace/src/sql_tables/mod.rs
Normal file
0
rust-lib/flowy-workspace/src/sql_tables/mod.rs
Normal file
@ -30,7 +30,6 @@ impl ProtoGen {
|
||||
fn write_proto_files(crate_infos: &Vec<CrateProtoInfo>) {
|
||||
for crate_info in crate_infos {
|
||||
let dir = crate_info.inner.proto_file_output_dir();
|
||||
remove_everything_in_dir(dir.as_str());
|
||||
crate_info.files.iter().for_each(|info| {
|
||||
let proto_file_path = format!("{}/{}.proto", dir, &info.file_name);
|
||||
save_content_to_file_with_diff_prompt(
|
||||
@ -76,36 +75,35 @@ 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()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.append(false)
|
||||
.truncate(true)
|
||||
.open(&mod_path)
|
||||
{
|
||||
Ok(ref mut file) => {
|
||||
let mut mod_file_content = String::new();
|
||||
mod_file_content.push_str("// Auto-generated, do not edit \n");
|
||||
let model_dir = package_info.model_dir();
|
||||
for crate_info in crate_infos {
|
||||
let mod_path = crate_info.flutter_mod_file(model_dir.as_str());
|
||||
match OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.append(false)
|
||||
.truncate(true)
|
||||
.open(&mod_path)
|
||||
{
|
||||
Ok(ref mut file) => {
|
||||
let mut mod_file_content = String::new();
|
||||
mod_file_content.push_str("// Auto-generated, do not edit \n");
|
||||
|
||||
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);
|
||||
let c = format!("export './{}.pb.dart';\n", &name);
|
||||
mod_file_content.push_str(c.as_ref());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
file.write_all(mod_file_content.as_bytes()).unwrap();
|
||||
file.flush().unwrap();
|
||||
}
|
||||
Err(err) => {
|
||||
panic!("Failed to open file: {}", err);
|
||||
file.write_all(mod_file_content.as_bytes()).unwrap();
|
||||
file.flush().unwrap();
|
||||
}
|
||||
Err(err) => {
|
||||
panic!("Failed to open file: {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,17 +132,21 @@ fn run_rust_protoc(crate_infos: &Vec<CrateProtoInfo>) {
|
||||
|
||||
fn run_flutter_protoc(crate_infos: &Vec<CrateProtoInfo>, package_info: &FlutterProtobufInfo) {
|
||||
let model_dir = package_info.model_dir();
|
||||
let removed_dir = format!("{}/", model_dir);
|
||||
remove_everything_in_dir(removed_dir.as_str());
|
||||
if !Path::new(&model_dir).exists() {
|
||||
std::fs::create_dir_all(&model_dir).unwrap();
|
||||
}
|
||||
|
||||
for crate_info in crate_infos {
|
||||
let proto_path = crate_info.inner.proto_file_output_dir();
|
||||
let crate_module_dir = crate_info.flutter_mod_dir(model_dir.as_str());
|
||||
remove_everything_in_dir(crate_module_dir.as_str());
|
||||
|
||||
walk_dir(
|
||||
proto_path.as_ref(),
|
||||
|e| is_proto_file(e),
|
||||
|proto_file, _| {
|
||||
if cmd_lib::run_cmd! {
|
||||
protoc --dart_out=${model_dir} --proto_path=${proto_path} ${proto_file}
|
||||
protoc --dart_out=${crate_module_dir} --proto_path=${proto_path} ${proto_file}
|
||||
}
|
||||
.is_err()
|
||||
{
|
||||
@ -156,16 +158,14 @@ fn run_flutter_protoc(crate_infos: &Vec<CrateProtoInfo>, package_info: &FlutterP
|
||||
}
|
||||
|
||||
fn remove_everything_in_dir(dir: &str) {
|
||||
if !Path::new(dir).exists() {
|
||||
if Path::new(dir).exists() {
|
||||
if cmd_lib::run_cmd! {
|
||||
rm -rf ${dir}
|
||||
mkdir ${dir}
|
||||
}
|
||||
.is_err()
|
||||
{
|
||||
panic!("Reset protobuf directory failed")
|
||||
};
|
||||
} else {
|
||||
std::fs::create_dir_all(dir).unwrap();
|
||||
}
|
||||
std::fs::create_dir_all(dir).unwrap();
|
||||
}
|
||||
|
@ -36,6 +36,16 @@ pub use model::*;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn flutter_mod_dir(&self, root: &str) -> String {
|
||||
let crate_module_dir = format!("{}/{}", root, self.inner.folder_name);
|
||||
crate_module_dir
|
||||
}
|
||||
|
||||
pub fn flutter_mod_file(&self, root: &str) -> String {
|
||||
let crate_module_dir = format!("{}/{}/protobuf.dart", root, self.inner.folder_name);
|
||||
crate_module_dir
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -59,7 +59,7 @@ pub fn save_content_to_file_with_diff_prompt(content: &str, output_file: &str, _
|
||||
.open(output_file)
|
||||
{
|
||||
Ok(ref mut file) => file.write_all(content.as_bytes()).unwrap(),
|
||||
Err(err) => panic!("Open or create file fail: {}", err),
|
||||
Err(err) => panic!("Open or create to {} fail: {}", output_file, err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user