From 824c7c0e8dcc859a0a3d6f7f55b9cda352c2a806 Mon Sep 17 00:00:00 2001 From: appflowy Date: Sun, 19 Jun 2022 09:42:25 +0800 Subject: [PATCH 1/3] refactor: clean script --- frontend/.vscode/tasks.json | 22 +++++--------------- frontend/scripts/clean.cmd | 8 -------- frontend/scripts/clean.sh | 16 --------------- frontend/scripts/makefile/tool.toml | 32 +++++++++++++++++------------ 4 files changed, 24 insertions(+), 54 deletions(-) delete mode 100644 frontend/scripts/clean.cmd delete mode 100644 frontend/scripts/clean.sh diff --git a/frontend/.vscode/tasks.json b/frontend/.vscode/tasks.json index 34df46ad3e..1ff2ff2874 100644 --- a/frontend/.vscode/tasks.json +++ b/frontend/.vscode/tasks.json @@ -10,13 +10,13 @@ // ${cwd}: the current working directory of the spawned process "tasks": [ { - "label": "AF: Clean + Rebuild All", + "label": "AF: Rust Clean + Rebuild All", "type": "shell", "dependsOrder": "sequence", "dependsOn": [ - "AF: Clean", - "AF: build_flowy_sdk", + "AF: Rust Clean", "AF: Flutter Clean", + "AF: build_flowy_sdk", "AF: Flutter Pub Get", "AF: Flutter Package Get", "AF: Generate Language Files", @@ -139,21 +139,9 @@ } }, { - "label": "AF: Clean", + "label": "AF: Rust Clean", "type": "shell", - "command": "sh ./scripts/clean.sh", - "windows": { - "options": { - "shell": { - "executable": "cmd.exe", - "args": [ - "/d", - "/c", - ".\\scripts\\clean.cmd" - ] - } - } - }, + "command": "cargo make rust_clean", "group": "build", "options": { "cwd": "${workspaceFolder}" diff --git a/frontend/scripts/clean.cmd b/frontend/scripts/clean.cmd deleted file mode 100644 index 46cf54e69c..0000000000 --- a/frontend/scripts/clean.cmd +++ /dev/null @@ -1,8 +0,0 @@ -cd rust-lib -cargo clean - -cd ../../shared-lib - -if exist "lib-infra/.cache" ( - rmdir /s/q "lib-infra/.cache" -) \ No newline at end of file diff --git a/frontend/scripts/clean.sh b/frontend/scripts/clean.sh deleted file mode 100644 index 619853e2fb..0000000000 --- a/frontend/scripts/clean.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -#!/usr/bin/env fish - -cd rust-lib -cargo clean - -cd ../../shared-lib -cargo clean - -CACHE_FILE=lib-infra/.cache -if [ -d "$CACHE_FILE" ]; then - echo "Remove $CACHE_FILE" - rm -rf $CACHE_FILE -fi - - diff --git a/frontend/scripts/makefile/tool.toml b/frontend/scripts/makefile/tool.toml index fcd1d41763..85dc76cb8b 100644 --- a/frontend/scripts/makefile/tool.toml +++ b/frontend/scripts/makefile/tool.toml @@ -1,29 +1,35 @@ [tasks.rust_clean] +run_task = { name = ["cargo_clean","rm_macro_build_cache", "rm_generated_protobuf_files"] } + +[tasks.cargo_clean] script = [ """ cd rust-lib - cargo clean + cargo clean -q cd ../../shared-lib - cargo clean - - CACHE_FILE=lib-infra/.cache - if [ -d "$CACHE_FILE" ]; then - echo "Remove $CACHE_FILE" - rm -rf $CACHE_FILE - fi + cargo clean -q """, ] script_runner = "@shell" -[tasks.rust_clean.windows] + +[tasks.rm_macro_build_cache] +script = [ + """ + path = canonicalize ../shared-lib/lib-infra/.cache + if is_path_exists ${path} + rm -rf ${path} + end + """, +] +script_runner = "@duckscript" + + +[tasks.rm_generated_protobuf_files] script = [ """ - cd rust-lib - cargo clean - cd ../../shared-lib - rmdir /s/q "lib-infra/.cache" """, ] script_runner = "@duckscript" \ No newline at end of file From 64e43fa1f3132688518d5e10d2a128b702b00d34 Mon Sep 17 00:00:00 2001 From: appflowy Date: Sun, 19 Jun 2022 10:40:55 +0800 Subject: [PATCH 2/3] chore: remove rust/dart generated files --- frontend/.vscode/tasks.json | 4 +- frontend/scripts/makefile/tool.toml | 65 +++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/frontend/.vscode/tasks.json b/frontend/.vscode/tasks.json index 1ff2ff2874..7ccb8ae3fe 100644 --- a/frontend/.vscode/tasks.json +++ b/frontend/.vscode/tasks.json @@ -10,7 +10,7 @@ // ${cwd}: the current working directory of the spawned process "tasks": [ { - "label": "AF: Rust Clean + Rebuild All", + "label": "AF: Clean + Rebuild All", "type": "shell", "dependsOrder": "sequence", "dependsOn": [ @@ -141,7 +141,7 @@ { "label": "AF: Rust Clean", "type": "shell", - "command": "cargo make rust_clean", + "command": "cargo make flowy_clean", "group": "build", "options": { "cwd": "${workspaceFolder}" diff --git a/frontend/scripts/makefile/tool.toml b/frontend/scripts/makefile/tool.toml index 85dc76cb8b..876793b882 100644 --- a/frontend/scripts/makefile/tool.toml +++ b/frontend/scripts/makefile/tool.toml @@ -1,5 +1,5 @@ -[tasks.rust_clean] -run_task = { name = ["cargo_clean","rm_macro_build_cache", "rm_generated_protobuf_files"] } +[tasks.flowy_clean] +run_task = { name = ["cargo_clean","rm_macro_build_cache", "rm_rust_generated_files", "rm_dart_generated_files"] } [tasks.cargo_clean] script = [ @@ -25,10 +25,69 @@ script = [ ] script_runner = "@duckscript" +#Rust Clean +[tasks.rm_rust_generated_files] +run_task = { name = ["rm_rust_lib_generated_protobuf_files", "rm_shared_lib_generated_protobuf_files"] } -[tasks.rm_generated_protobuf_files] +[tasks.rm_rust_lib_generated_protobuf_files] +private = true +env = { "rm_proto_path" = "./rust-lib/**/resources/proto", "rm_protobuf_path" = "./rust-lib/**/protobuf" } +run_task = { name = "remove_files_with_pattern" } + +[tasks.rm_shared_lib_generated_protobuf_files] +private = true +env = { "rm_proto_path" = "./shared-lib/**/resources/proto", "rm_protobuf_path" = "./shared-lib/**/protobuf" } +run_task = { name = "remove_files_with_pattern" } + + +#Dart Clean +[tasks.rm_dart_generated_files] +private = true +env = { "dart_flowy_sdk_path" = "./app_flowy/packages/flowy_sdk/" } +run_task = { name = ["rm_dart_generated_protobuf_files"] } + +[tasks.rm_dart_generated_protobuf_files] +private = true script = [ """ + protobuf_file_paths = glob_array ${dart_flowy_sdk_path}/lib/protobuf + if array_is_empty ${protobuf_file_paths} + return + end + + echo Remove generated protobuf files: + for path in ${protobuf_file_paths} + echo remove ${path} + rm -rf ${path} + end + """, +] +script_runner = "@duckscript" + + +[tasks.remove_files_with_pattern] +private = true +script = [ + """ + proto_file_paths = glob_array ${rm_proto_path} + is_proto_file_paths_empty = array_is_empty ${proto_file_paths} + if !is_proto_file_paths_empty + echo Remove generated proto files: + for path in ${proto_file_paths} + echo remove ${path} + rm -rf ${path} + end + end + + protobuf_file_paths = glob_array ${rm_protobuf_path} + is_protobuf_file_paths_empty = array_is_empty ${protobuf_file_paths} + if !is_protobuf_file_paths_empty + echo Remove generated protobuf files: + for path in ${protobuf_file_paths} + echo remove ${path} + rm -rf ${path} + end + end """, ] From 02754eb069d50330ff81ad1ddf3fe502d29e0834 Mon Sep 17 00:00:00 2001 From: appflowy Date: Sun, 19 Jun 2022 10:55:14 +0800 Subject: [PATCH 3/3] chore: print message if the dir is not empty --- frontend/scripts/makefile/tool.toml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/frontend/scripts/makefile/tool.toml b/frontend/scripts/makefile/tool.toml index 876793b882..dc840272d5 100644 --- a/frontend/scripts/makefile/tool.toml +++ b/frontend/scripts/makefile/tool.toml @@ -42,7 +42,6 @@ run_task = { name = "remove_files_with_pattern" } #Dart Clean [tasks.rm_dart_generated_files] -private = true env = { "dart_flowy_sdk_path" = "./app_flowy/packages/flowy_sdk/" } run_task = { name = ["rm_dart_generated_protobuf_files"] } @@ -51,14 +50,13 @@ private = true script = [ """ protobuf_file_paths = glob_array ${dart_flowy_sdk_path}/lib/protobuf - if array_is_empty ${protobuf_file_paths} - return - end - echo Remove generated protobuf files: - for path in ${protobuf_file_paths} - echo remove ${path} - rm -rf ${path} + if not array_is_empty ${protobuf_file_paths} + echo Remove generated protobuf files: + for path in ${protobuf_file_paths} + echo remove ${path} + rm -rf ${path} + end end """, ] @@ -71,7 +69,7 @@ script = [ """ proto_file_paths = glob_array ${rm_proto_path} is_proto_file_paths_empty = array_is_empty ${proto_file_paths} - if !is_proto_file_paths_empty + if not ${is_proto_file_paths_empty} echo Remove generated proto files: for path in ${proto_file_paths} echo remove ${path} @@ -81,7 +79,7 @@ script = [ protobuf_file_paths = glob_array ${rm_protobuf_path} is_protobuf_file_paths_empty = array_is_empty ${protobuf_file_paths} - if !is_protobuf_file_paths_empty + if not ${is_protobuf_file_paths_empty} echo Remove generated protobuf files: for path in ${protobuf_file_paths} echo remove ${path}