mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: path issue on windows
This commit is contained in:
parent
ceaf1ccc21
commit
06967d8057
@ -1,3 +1,413 @@
|
||||
|
||||
/// Auto generate. Do not edit
|
||||
part of '../../dispatch.dart';
|
||||
class FolderEventCreateWorkspace {
|
||||
CreateWorkspaceRequest request;
|
||||
FolderEventCreateWorkspace(this.request);
|
||||
|
||||
Future<Either<Workspace, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.CreateWorkspace.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(Workspace.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventReadCurWorkspace {
|
||||
FolderEventReadCurWorkspace();
|
||||
|
||||
Future<Either<CurrentWorkspaceSetting, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.ReadCurWorkspace.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(CurrentWorkspaceSetting.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventReadWorkspaces {
|
||||
QueryWorkspaceRequest request;
|
||||
FolderEventReadWorkspaces(this.request);
|
||||
|
||||
Future<Either<RepeatedWorkspace, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.ReadWorkspaces.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(RepeatedWorkspace.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventDeleteWorkspace {
|
||||
QueryWorkspaceRequest request;
|
||||
FolderEventDeleteWorkspace(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.DeleteWorkspace.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventOpenWorkspace {
|
||||
QueryWorkspaceRequest request;
|
||||
FolderEventOpenWorkspace(this.request);
|
||||
|
||||
Future<Either<Workspace, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.OpenWorkspace.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(Workspace.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventReadWorkspaceApps {
|
||||
QueryWorkspaceRequest request;
|
||||
FolderEventReadWorkspaceApps(this.request);
|
||||
|
||||
Future<Either<RepeatedApp, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.ReadWorkspaceApps.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(RepeatedApp.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventCreateApp {
|
||||
CreateAppRequest request;
|
||||
FolderEventCreateApp(this.request);
|
||||
|
||||
Future<Either<App, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.CreateApp.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(App.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventDeleteApp {
|
||||
QueryAppRequest request;
|
||||
FolderEventDeleteApp(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.DeleteApp.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventReadApp {
|
||||
QueryAppRequest request;
|
||||
FolderEventReadApp(this.request);
|
||||
|
||||
Future<Either<App, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.ReadApp.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(App.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventUpdateApp {
|
||||
UpdateAppRequest request;
|
||||
FolderEventUpdateApp(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.UpdateApp.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventCreateView {
|
||||
CreateViewRequest request;
|
||||
FolderEventCreateView(this.request);
|
||||
|
||||
Future<Either<View, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.CreateView.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(View.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventReadView {
|
||||
QueryViewRequest request;
|
||||
FolderEventReadView(this.request);
|
||||
|
||||
Future<Either<View, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.ReadView.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(View.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventUpdateView {
|
||||
UpdateViewRequest request;
|
||||
FolderEventUpdateView(this.request);
|
||||
|
||||
Future<Either<View, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.UpdateView.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(View.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventDeleteView {
|
||||
QueryViewRequest request;
|
||||
FolderEventDeleteView(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.DeleteView.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventDuplicateView {
|
||||
QueryViewRequest request;
|
||||
FolderEventDuplicateView(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.DuplicateView.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventCopyLink {
|
||||
FolderEventCopyLink();
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.CopyLink.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventOpenDocument {
|
||||
QueryViewRequest request;
|
||||
FolderEventOpenDocument(this.request);
|
||||
|
||||
Future<Either<DocumentDelta, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.OpenDocument.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(DocumentDelta.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventCloseView {
|
||||
QueryViewRequest request;
|
||||
FolderEventCloseView(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.CloseView.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventReadTrash {
|
||||
FolderEventReadTrash();
|
||||
|
||||
Future<Either<RepeatedTrash, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.ReadTrash.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(RepeatedTrash.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventPutbackTrash {
|
||||
TrashId request;
|
||||
FolderEventPutbackTrash(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.PutbackTrash.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventDeleteTrash {
|
||||
RepeatedTrashId request;
|
||||
FolderEventDeleteTrash(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.DeleteTrash.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventRestoreAllTrash {
|
||||
FolderEventRestoreAllTrash();
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.RestoreAllTrash.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventDeleteAllTrash {
|
||||
FolderEventDeleteAllTrash();
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.DeleteAllTrash.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventApplyDocDelta {
|
||||
DocumentDelta request;
|
||||
FolderEventApplyDocDelta(this.request);
|
||||
|
||||
Future<Either<DocumentDelta, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.ApplyDocDelta.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(DocumentDelta.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class FolderEventExportDocument {
|
||||
ExportRequest request;
|
||||
FolderEventExportDocument(this.request);
|
||||
|
||||
Future<Either<ExportData, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = FolderEvent.ExportDocument.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(ExportData.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,20 @@
|
||||
|
||||
/// Auto generate. Do not edit
|
||||
part of '../../dispatch.dart';
|
||||
class NetworkEventUpdateNetworkType {
|
||||
NetworkState request;
|
||||
NetworkEventUpdateNetworkType(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = NetworkEvent.UpdateNetworkType.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,141 @@
|
||||
|
||||
/// Auto generate. Do not edit
|
||||
part of '../../dispatch.dart';
|
||||
class UserEventInitUser {
|
||||
UserEventInitUser();
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.InitUser.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSignIn {
|
||||
SignInRequest request;
|
||||
UserEventSignIn(this.request);
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignIn.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSignUp {
|
||||
SignUpRequest request;
|
||||
UserEventSignUp(this.request);
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignUp.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSignOut {
|
||||
UserEventSignOut();
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignOut.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventUpdateUser {
|
||||
UpdateUserRequest request;
|
||||
UserEventUpdateUser(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.UpdateUser.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventGetUserProfile {
|
||||
UserEventGetUserProfile();
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.GetUserProfile.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventCheckUser {
|
||||
UserEventCheckUser();
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.CheckUser.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSetAppearanceSetting {
|
||||
AppearanceSettings request;
|
||||
UserEventSetAppearanceSetting(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SetAppearanceSetting.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventGetAppearanceSetting {
|
||||
UserEventGetAppearanceSetting();
|
||||
|
||||
Future<Either<AppearanceSettings, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.GetAppearanceSetting.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(AppearanceSettings.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
// Auto-generated, do not edit
|
||||
export './ffi_request.pb.dart';
|
||||
export './ffi_response.pb.dart';
|
||||
export './ffi_request.pb.dart';
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Auto-generated, do not edit
|
||||
export './document_info.pb.dart';
|
||||
export './folder_info.pb.dart';
|
||||
export './revision.pb.dart';
|
||||
export './ws_data.pb.dart';
|
||||
export './revision.pb.dart';
|
||||
export './document_info.pb.dart';
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Auto-generated, do not edit
|
||||
export './app.pb.dart';
|
||||
export './share.pb.dart';
|
||||
export './trash.pb.dart';
|
||||
export './app.pb.dart';
|
||||
export './view.pb.dart';
|
||||
export './trash.pb.dart';
|
||||
export './workspace.pb.dart';
|
||||
|
@ -1,3 +1,3 @@
|
||||
// Auto-generated, do not edit
|
||||
export './event_map.pb.dart';
|
||||
export './network_state.pb.dart';
|
||||
export './event_map.pb.dart';
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Auto-generated, do not edit
|
||||
export './auth.pb.dart';
|
||||
export './errors.pb.dart';
|
||||
export './user_profile.pb.dart';
|
||||
export './auth.pb.dart';
|
||||
export './user_setting.pb.dart';
|
||||
|
@ -7,8 +7,8 @@ edition = "2018"
|
||||
[lib]
|
||||
name = "dart_ffi"
|
||||
# this value will change depending on the target os
|
||||
# default cdylib
|
||||
crate-type = ["cdylib"]
|
||||
# default staticlib
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
@ -36,4 +36,4 @@ http_server = ["flowy-sdk/http_server", "flowy-sdk/use_bunyan"]
|
||||
#use_protobuf= ["protobuf"]
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen", "dart"] }
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "dart"] }
|
@ -19,4 +19,4 @@ lib-dispatch = {path = "../lib-dispatch" }
|
||||
dart = ["lib-infra/dart"]
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] }
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen"] }
|
@ -30,4 +30,4 @@ db = ["flowy-database", "lib-sqlite", "r2d2"]
|
||||
dart = ["flowy-error-code/dart", "lib-infra/dart"]
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] }
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen"] }
|
@ -56,4 +56,4 @@ flowy_unit_test = ["lib-ot/flowy_unit_test", "flowy-sync/flowy_unit_test"]
|
||||
dart = ["lib-infra/dart", "flowy-folder/dart", "flowy-folder/dart",]
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen", "proto_gen"] }
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "proto_gen"] }
|
@ -50,4 +50,4 @@ dart = [
|
||||
]
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] }
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen"] }
|
@ -48,4 +48,4 @@ http_server = []
|
||||
dart = ["lib-infra/dart"]
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] }
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen"] }
|
@ -29,7 +29,7 @@ futures = "0.3.15"
|
||||
async-stream = "0.3.2"
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../lib-infra", features = ["pb_gen"] }
|
||||
lib-infra = { path = "../lib-infra", features = ["protobuf_file_gen"] }
|
||||
|
||||
[features]
|
||||
dart = ["lib-infra/dart"]
|
@ -11,7 +11,7 @@ protobuf = {version = "2.18.0"}
|
||||
derive_more = {version = "0.99", features = ["display"]}
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../lib-infra", features = ["pb_gen"] }
|
||||
lib-infra = { path = "../lib-infra", features = ["protobuf_file_gen"] }
|
||||
|
||||
[features]
|
||||
dart = ["lib-infra/dart"]
|
@ -21,7 +21,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../lib-infra", features = ["pb_gen"] }
|
||||
lib-infra = { path = "../lib-infra", features = ["protobuf_file_gen"] }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
@ -19,7 +19,7 @@ fancy-regex = "0.5.0"
|
||||
lazy_static = "1.4"
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../lib-infra", features = ["pb_gen"] }
|
||||
lib-infra = { path = "../lib-infra", features = ["protobuf_file_gen"] }
|
||||
|
||||
[dev-dependencies]
|
||||
quickcheck = "0.9.2"
|
||||
|
@ -47,6 +47,6 @@ proto_gen = [
|
||||
"console",
|
||||
"toml"
|
||||
]
|
||||
pb_gen = ["cmd_lib", "protoc-rust", "walkdir", "protoc-bin-vendored",]
|
||||
protobuf_file_gen = ["cmd_lib", "protoc-rust", "walkdir", "protoc-bin-vendored",]
|
||||
dart_event = ["walkdir", "flowy-ast", "tera", "syn"]
|
||||
dart = ["proto_gen", "dart_event"]
|
@ -1,10 +1,10 @@
|
||||
use super::event_template::*;
|
||||
use crate::code_gen::flowy_toml::{parse_crate_config_from, CrateConfig};
|
||||
use crate::code_gen::util::{cache_dir, is_crate_dir, is_hidden, read_file};
|
||||
use crate::code_gen::util::{is_crate_dir, is_hidden, path_string_with_component, read_file};
|
||||
use flowy_ast::{event_ast::*, *};
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use syn::Item;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
@ -33,18 +33,22 @@ pub fn gen(crate_name: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
let dart_event_folder = format!(
|
||||
"{}/{}/lib/dispatch/dart_event/{}",
|
||||
std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap(),
|
||||
std::env::var("FLUTTER_FLOWY_SDK_PATH").unwrap(),
|
||||
crate_name
|
||||
);
|
||||
let dart_event_folder: PathBuf = [
|
||||
&std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap(),
|
||||
&std::env::var("FLUTTER_FLOWY_SDK_PATH").unwrap(),
|
||||
"lib",
|
||||
"dispatch",
|
||||
"dart_event",
|
||||
crate_name,
|
||||
]
|
||||
.iter()
|
||||
.collect();
|
||||
|
||||
if !Path::new(&dart_event_folder).exists() {
|
||||
std::fs::create_dir_all(&dart_event_folder).unwrap();
|
||||
if !dart_event_folder.as_path().exists() {
|
||||
std::fs::create_dir_all(dart_event_folder.as_path()).unwrap();
|
||||
}
|
||||
|
||||
let dart_event_file_path = format!("{}/dart_event.dart", dart_event_folder);
|
||||
let dart_event_file_path = path_string_with_component(&dart_event_folder, vec!["dart_event.dart"]);
|
||||
println!("cargo:rerun-if-changed={}", dart_event_file_path);
|
||||
|
||||
match std::fs::OpenOptions::new()
|
||||
@ -69,39 +73,9 @@ const DART_IMPORTED: &str = r#"
|
||||
part of '../../dispatch.dart';
|
||||
"#;
|
||||
|
||||
pub fn write_dart_event_file(file_path: &str) {
|
||||
let cache_dir = cache_dir();
|
||||
let mut content = DART_IMPORTED.to_owned();
|
||||
for path in WalkDir::new(cache_dir)
|
||||
.into_iter()
|
||||
.filter_map(|e| e.ok())
|
||||
.filter(|e| e.path().file_stem().unwrap().to_str().unwrap() == "dart_event")
|
||||
.map(|e| e.path().to_str().unwrap().to_string())
|
||||
{
|
||||
let file_content = read_file(path.as_ref()).unwrap();
|
||||
content.push_str(&file_content);
|
||||
}
|
||||
|
||||
match std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.append(false)
|
||||
.truncate(true)
|
||||
.open(&file_path)
|
||||
{
|
||||
Ok(ref mut file) => {
|
||||
file.write_all(content.as_bytes()).unwrap();
|
||||
File::flush(file).unwrap();
|
||||
}
|
||||
Err(err) => {
|
||||
panic!("Failed to write dart event file: {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DartEventCrate {
|
||||
crate_path: String,
|
||||
crate_path: PathBuf,
|
||||
event_files: Vec<String>,
|
||||
}
|
||||
|
||||
@ -135,7 +109,8 @@ pub fn parse_event_crate(event_crate: &DartEventCrate) -> Vec<EventASTContext> {
|
||||
.event_files
|
||||
.iter()
|
||||
.map(|event_file| {
|
||||
let file_path = format!("{}/{}", event_crate.crate_path, event_file);
|
||||
let file_path = path_string_with_component(&event_crate.crate_path, vec![event_file.as_str()]);
|
||||
|
||||
let file_content = read_file(file_path.as_ref()).unwrap();
|
||||
let ast = syn::parse_file(file_content.as_ref()).expect("Unable to parse file");
|
||||
ast.items
|
||||
|
@ -1,4 +1,6 @@
|
||||
use crate::code_gen::util::path_buf_with_component;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct FlowyConfig {
|
||||
@ -7,7 +9,7 @@ pub struct FlowyConfig {
|
||||
}
|
||||
|
||||
impl FlowyConfig {
|
||||
pub fn from_toml_file(path: &str) -> Self {
|
||||
pub fn from_toml_file(path: &Path) -> Self {
|
||||
let content = fs::read_to_string(path).unwrap();
|
||||
let config: FlowyConfig = toml::from_str(content.as_ref()).unwrap();
|
||||
config
|
||||
@ -15,34 +17,32 @@ impl FlowyConfig {
|
||||
}
|
||||
|
||||
pub struct CrateConfig {
|
||||
pub crate_path: String,
|
||||
pub crate_path: PathBuf,
|
||||
pub folder_name: String,
|
||||
pub flowy_config: FlowyConfig,
|
||||
}
|
||||
|
||||
impl CrateConfig {
|
||||
pub fn proto_paths(&self) -> Vec<String> {
|
||||
pub fn proto_paths(&self) -> Vec<PathBuf> {
|
||||
let proto_paths = self
|
||||
.flowy_config
|
||||
.proto_crates
|
||||
.iter()
|
||||
.map(|name| format!("{}/{}", self.crate_path, name))
|
||||
.collect::<Vec<String>>();
|
||||
.map(|name| path_buf_with_component(&self.crate_path, vec![&name]))
|
||||
.collect::<Vec<PathBuf>>();
|
||||
proto_paths
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_crate_config_from(entry: &walkdir::DirEntry) -> Option<CrateConfig> {
|
||||
let path = entry.path().parent().unwrap();
|
||||
let crate_path = path.to_str().unwrap().to_string();
|
||||
let folder_name = path.file_stem().unwrap().to_str().unwrap().to_string();
|
||||
let config_path = format!("{}/Flowy.toml", crate_path);
|
||||
|
||||
if !std::path::Path::new(&config_path).exists() {
|
||||
let mut config_path = entry.path().parent().unwrap().to_path_buf();
|
||||
config_path.push("Flowy.toml");
|
||||
if !config_path.as_path().exists() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let flowy_config = FlowyConfig::from_toml_file(config_path.as_ref());
|
||||
let crate_path = entry.path().parent().unwrap().to_path_buf();
|
||||
let flowy_config = FlowyConfig::from_toml_file(config_path.as_path());
|
||||
let folder_name = crate_path.file_stem().unwrap().to_str().unwrap().to_string();
|
||||
|
||||
Some(CrateConfig {
|
||||
crate_path,
|
||||
|
@ -1,13 +1,13 @@
|
||||
#[cfg(feature = "pb_gen")]
|
||||
#[cfg(feature = "protobuf_file_gen")]
|
||||
pub mod protobuf_file;
|
||||
|
||||
#[cfg(feature = "dart_event")]
|
||||
pub mod dart_event;
|
||||
|
||||
#[cfg(any(feature = "pb_gen", feature = "dart_event"))]
|
||||
#[cfg(any(feature = "protobuf_file_gen", feature = "dart_event"))]
|
||||
mod flowy_toml;
|
||||
|
||||
#[cfg(any(feature = "pb_gen", feature = "dart_event"))]
|
||||
#[cfg(any(feature = "protobuf_file_gen", feature = "dart_event"))]
|
||||
pub mod util;
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
|
@ -8,6 +8,7 @@ use crate::code_gen::util::*;
|
||||
use fancy_regex::Regex;
|
||||
use flowy_ast::*;
|
||||
use lazy_static::lazy_static;
|
||||
use std::path::PathBuf;
|
||||
use std::{fs::File, io::Read, path::Path};
|
||||
use syn::Item;
|
||||
use walkdir::WalkDir;
|
||||
@ -30,7 +31,7 @@ pub fn parse_crate_protobuf(crate_paths: Vec<String>) -> Vec<ProtobufCrateContex
|
||||
.collect::<Vec<ProtobufCrateContext>>()
|
||||
}
|
||||
|
||||
fn parse_files_protobuf(proto_crate_path: &str, proto_output_dir: &str) -> Vec<ProtoFile> {
|
||||
fn parse_files_protobuf(proto_crate_path: &PathBuf, proto_output_dir: &PathBuf) -> Vec<ProtoFile> {
|
||||
let mut gen_proto_vec: Vec<ProtoFile> = vec![];
|
||||
// file_stem https://doc.rust-lang.org/std/path/struct.Path.html#method.file_stem
|
||||
for (path, file_name) in WalkDir::new(proto_crate_path)
|
||||
@ -52,7 +53,8 @@ fn parse_files_protobuf(proto_crate_path: &str, proto_output_dir: &str) -> Vec<P
|
||||
let ast = syn::parse_file(read_file(&path).unwrap().as_ref())
|
||||
.unwrap_or_else(|_| panic!("Unable to parse file at {}", path));
|
||||
let structs = get_ast_structs(&ast);
|
||||
let proto_file_path = format!("{}/{}.proto", &proto_output_dir, &file_name);
|
||||
let proto_file = format!("{}.proto", &file_name);
|
||||
let proto_file_path = path_string_with_component(&proto_output_dir, vec![&proto_file]);
|
||||
let mut proto_file_content = parse_or_init_proto_file(proto_file_path.as_ref());
|
||||
|
||||
structs.iter().for_each(|s| {
|
||||
|
@ -6,11 +6,10 @@ mod proto_gen;
|
||||
mod proto_info;
|
||||
mod template;
|
||||
|
||||
use crate::code_gen::util::path_string_with_component;
|
||||
use log::info;
|
||||
pub use proto_gen::*;
|
||||
pub use proto_info::*;
|
||||
|
||||
#[cfg(feature = "proto_gen")]
|
||||
use log::info;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
@ -44,7 +43,14 @@ pub fn gen(crate_name: &str, proto_file_dir: &str) {
|
||||
let protoc_bin_path = protoc_bin_vendored::protoc_bin_path().unwrap();
|
||||
|
||||
// 2. generate the protobuf files(Dart)
|
||||
|
||||
#[cfg(feature = "dart")]
|
||||
generate_dart_protobuf_files(
|
||||
crate_name,
|
||||
proto_file_dir,
|
||||
&proto_file_paths,
|
||||
&file_names,
|
||||
&protoc_bin_path,
|
||||
);
|
||||
|
||||
// 3. generate the protobuf files(Rust)
|
||||
generate_rust_protobuf_files(&protoc_bin_path, &proto_file_paths, proto_file_dir);
|
||||
@ -78,10 +84,14 @@ fn generate_dart_protobuf_files(
|
||||
return;
|
||||
}
|
||||
|
||||
let workspace_dir = std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap();
|
||||
let flutter_sdk_path = std::env::var("FLUTTER_FLOWY_SDK_PATH").unwrap();
|
||||
let output = format!("{}/{}/lib/protobuf/{}", workspace_dir, flutter_sdk_path, name);
|
||||
if !std::path::Path::new(&output).exists() {
|
||||
let mut output = PathBuf::new();
|
||||
output.push(std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap());
|
||||
output.push(std::env::var("FLUTTER_FLOWY_SDK_PATH").unwrap());
|
||||
output.push("lib");
|
||||
output.push("protobuf");
|
||||
output.push(name);
|
||||
|
||||
if !output.as_path().exists() {
|
||||
std::fs::create_dir_all(&output).unwrap();
|
||||
}
|
||||
check_pb_dart_plugin();
|
||||
@ -96,7 +106,8 @@ fn generate_dart_protobuf_files(
|
||||
};
|
||||
});
|
||||
|
||||
let protobuf_dart = format!("{}/protobuf.dart", output);
|
||||
let protobuf_dart = path_string_with_component(&output, vec!["protobuf.dart"]);
|
||||
|
||||
match std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
@ -129,7 +140,6 @@ fn check_pb_dart_plugin() {
|
||||
// .status()
|
||||
// .expect("failed to execute process");
|
||||
//panic!("{}", format!("\n❌ The protoc-gen-dart was not installed correctly."))
|
||||
|
||||
} else {
|
||||
let is_success = Command::new("sh")
|
||||
.arg("-c")
|
||||
|
@ -23,14 +23,16 @@ impl ProtoGenerator {
|
||||
crate_info.create_crate_mod_file();
|
||||
}
|
||||
|
||||
let cache = ProtoCache::from_crate_contexts(&crate_contexts);
|
||||
let cache_str = serde_json::to_string(&cache).unwrap();
|
||||
let cache_dir = format!("{}/{}", cache_dir(), crate_name);
|
||||
if !Path::new(&cache_dir).exists() {
|
||||
std::fs::create_dir_all(&cache_dir).unwrap();
|
||||
let proto_cache = ProtoCache::from_crate_contexts(&crate_contexts);
|
||||
let proto_cache_str = serde_json::to_string(&proto_cache).unwrap();
|
||||
|
||||
let crate_cache_dir = path_buf_with_component(&cache_dir(), vec![crate_name]);
|
||||
if !crate_cache_dir.as_path().exists() {
|
||||
std::fs::create_dir_all(&crate_cache_dir).unwrap();
|
||||
}
|
||||
|
||||
let protobuf_cache_path = format!("{}/proto_cache", cache_dir);
|
||||
let protobuf_cache_path = path_string_with_component(&crate_cache_dir, vec!["proto_cache"]);
|
||||
|
||||
match std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
@ -39,7 +41,7 @@ impl ProtoGenerator {
|
||||
.open(&protobuf_cache_path)
|
||||
{
|
||||
Ok(ref mut file) => {
|
||||
file.write_all(cache_str.as_bytes()).unwrap();
|
||||
file.write_all(proto_cache_str.as_bytes()).unwrap();
|
||||
File::flush(file).unwrap();
|
||||
}
|
||||
Err(_err) => {
|
||||
@ -55,7 +57,8 @@ fn write_proto_files(crate_contexts: &[ProtobufCrateContext]) {
|
||||
for context in crate_contexts {
|
||||
let dir = context.protobuf_crate.proto_output_dir();
|
||||
context.files.iter().for_each(|info| {
|
||||
let proto_file_path = format!("{}/{}.proto", dir, &info.file_name);
|
||||
let proto_file = format!("{}.proto", &info.file_name);
|
||||
let proto_file_path = path_string_with_component(&dir, vec![&proto_file]);
|
||||
save_content_to_file_with_diff_prompt(&info.generated_content, proto_file_path.as_ref());
|
||||
});
|
||||
}
|
||||
@ -77,7 +80,7 @@ fn write_rust_crate_mod_file(crate_contexts: &[ProtobufCrateContext]) {
|
||||
mod_file_content.push_str("#![cfg_attr(rustfmt, rustfmt::skip)]\n");
|
||||
mod_file_content.push_str("// Auto-generated, do not edit\n");
|
||||
walk_dir(
|
||||
context.protobuf_crate.proto_output_dir().as_ref(),
|
||||
context.protobuf_crate.proto_output_dir(),
|
||||
|e| !e.file_type().is_dir(),
|
||||
|_, name| {
|
||||
let c = format!("\nmod {};\npub use {}::*;\n", &name, &name);
|
||||
|
@ -3,6 +3,8 @@ use crate::code_gen::flowy_toml::{parse_crate_config_from, CrateConfig};
|
||||
use crate::code_gen::util::*;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -22,7 +24,7 @@ impl ProtobufCrateContext {
|
||||
pub fn create_crate_mod_file(&self) {
|
||||
// mod model;
|
||||
// pub use model::*;
|
||||
let mod_file_path = format!("{}/mod.rs", self.protobuf_crate.protobuf_crate_name());
|
||||
let mod_file_path = path_string_with_component(&self.protobuf_crate.protobuf_crate_name(), vec!["mod.rs"]);
|
||||
let mut content = "#![cfg_attr(rustfmt, rustfmt::skip)]\n".to_owned();
|
||||
content.push_str("// Auto-generated, do not edit\n");
|
||||
content.push_str("mod model;\npub use model::*;");
|
||||
@ -58,8 +60,8 @@ impl ProtobufCrateContext {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ProtobufCrate {
|
||||
pub folder_name: String,
|
||||
pub proto_paths: Vec<String>,
|
||||
pub crate_path: String,
|
||||
pub proto_paths: Vec<PathBuf>,
|
||||
pub crate_path: PathBuf,
|
||||
}
|
||||
|
||||
impl ProtobufCrate {
|
||||
@ -72,24 +74,26 @@ impl ProtobufCrate {
|
||||
}
|
||||
}
|
||||
|
||||
fn protobuf_crate_name(&self) -> String {
|
||||
format!("{}/src/protobuf", self.crate_path)
|
||||
fn protobuf_crate_name(&self) -> PathBuf {
|
||||
path_buf_with_component(&self.crate_path, vec!["src", "protobuf"])
|
||||
}
|
||||
|
||||
pub fn proto_output_dir(&self) -> String {
|
||||
let dir = format!("{}/proto", self.protobuf_crate_name());
|
||||
create_dir_if_not_exist(dir.as_ref());
|
||||
pub fn proto_output_dir(&self) -> PathBuf {
|
||||
let path = self.protobuf_crate_name();
|
||||
let dir = path_buf_with_component(&path, vec!["proto"]);
|
||||
create_dir_if_not_exist(&dir);
|
||||
dir
|
||||
}
|
||||
|
||||
pub fn create_output_dir(&self) -> String {
|
||||
let dir = format!("{}/model", self.protobuf_crate_name());
|
||||
create_dir_if_not_exist(dir.as_ref());
|
||||
pub fn create_output_dir(&self) -> PathBuf {
|
||||
let path = self.protobuf_crate_name();
|
||||
let dir = path_buf_with_component(&path, vec!["model"]);
|
||||
create_dir_if_not_exist(&dir);
|
||||
dir
|
||||
}
|
||||
|
||||
pub fn proto_model_mod_file(&self) -> String {
|
||||
format!("{}/mod.rs", self.create_output_dir())
|
||||
path_string_with_component(&self.create_output_dir(), vec!["mod.rs"])
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,26 +121,3 @@ pub fn parse_crate_info_from_path(roots: Vec<String>) -> Vec<ProtobufCrate> {
|
||||
});
|
||||
protobuf_crates
|
||||
}
|
||||
|
||||
pub struct FlutterProtobufInfo {
|
||||
package_path: String,
|
||||
}
|
||||
impl FlutterProtobufInfo {
|
||||
pub fn new(root: &str) -> Self {
|
||||
FlutterProtobufInfo {
|
||||
package_path: root.to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn model_dir(&self) -> String {
|
||||
let model_dir = format!("{}/protobuf", self.package_path);
|
||||
create_dir_if_not_exist(model_dir.as_ref());
|
||||
model_dir
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn mod_file_path(&self) -> String {
|
||||
let mod_file_path = format!("{}/protobuf.dart", self.package_path);
|
||||
mod_file_path
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
use console::Style;
|
||||
use similar::{ChangeTag, TextDiff};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::str::FromStr;
|
||||
use std::{
|
||||
fs::{File, OpenOptions},
|
||||
io::{Read, Write},
|
||||
path::Path,
|
||||
};
|
||||
use tera::Tera;
|
||||
use walkdir::WalkDir;
|
||||
@ -93,14 +94,26 @@ pub fn is_hidden(entry: &walkdir::DirEntry) -> bool {
|
||||
entry.file_name().to_str().map(|s| s.starts_with('.')).unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn create_dir_if_not_exist(dir: &str) {
|
||||
if !std::path::Path::new(&dir).exists() {
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
pub fn create_dir_if_not_exist(dir: &PathBuf) {
|
||||
if !dir.as_path().exists() {
|
||||
std::fs::create_dir_all(dir).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn path_string_with_component(path: &PathBuf, components: Vec<&str>) -> String {
|
||||
path_buf_with_component(path, components).to_str().unwrap().to_string()
|
||||
}
|
||||
|
||||
pub fn path_buf_with_component(path: &PathBuf, components: Vec<&str>) -> PathBuf {
|
||||
let mut path_buf = path.clone();
|
||||
for component in components {
|
||||
path_buf.push(component);
|
||||
}
|
||||
path_buf
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn walk_dir<F1, F2>(dir: &str, filter: F2, mut path_and_name: F1)
|
||||
pub fn walk_dir<P: AsRef<Path>, F1, F2>(dir: P, filter: F2, mut path_and_name: F1)
|
||||
where
|
||||
F1: FnMut(String, String),
|
||||
F2: Fn(&walkdir::DirEntry) -> bool,
|
||||
@ -153,6 +166,8 @@ pub fn get_tera(directory: &str) -> Tera {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cache_dir() -> String {
|
||||
format!("{}/.cache", env!("CARGO_MANIFEST_DIR"))
|
||||
pub fn cache_dir() -> PathBuf {
|
||||
let mut path_buf = PathBuf::from_str(env!("CARGO_MANIFEST_DIR")).unwrap();
|
||||
path_buf.push(".cache");
|
||||
path_buf
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ parking_lot = "0.11"
|
||||
dashmap = "4.0"
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../lib-infra", features = ["pb_gen"] }
|
||||
lib-infra = { path = "../lib-infra", features = ["protobuf_file_gen"] }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = {version = "1", features = ["full"]}
|
||||
|
Loading…
Reference in New Issue
Block a user