chore: optimize generation speed (#5930)

* chore: optimize language generation speed

* chore: optimize code generation speed

* chore: optimize freezed generation speed

* chore: optimzie appflowy_backend generation speed

* chore: optimize appflowy_result

* chore: optimzie flowy_infra generation speed

* chore: optimzie flowy_infra_ui generation speed

* chore: optimzie appflowy_flutter generation speed

* chore: optimize generate.sh

* chore: optimize the execution order

* chore: use exclude_packages instead of include_packages
This commit is contained in:
Lucas.Xu 2024-08-13 16:13:33 +08:00 committed by GitHub
parent f1ad03eaa9
commit d23977ebb0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 275 additions and 139 deletions

View File

View File

@ -14,20 +14,16 @@ dependencies:
ffi: ^2.0.2
isolates: ^3.0.3+8
protobuf: ^3.1.0
freezed_annotation:
logger: ^2.4.0
plugin_platform_interface: ^2.1.3
json_annotation: ^4.7.0
appflowy_result:
path: ../appflowy_result
fixnum: ^1.1.0
async: ^2.11.0
dev_dependencies:
flutter_test:
sdk: flutter
build_runner:
freezed:
flutter_lints: ^3.0.1
json_serializable: ^6.6.2
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

View File

@ -4,16 +4,10 @@ version: 0.0.1
homepage:
environment:
sdk: '>=3.3.0 <4.0.0'
sdk: ">=3.3.0 <4.0.0"
flutter: ">=1.17.0"
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.0
# For information on the generic Dart part of this file, see the

View File

@ -10,11 +10,9 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_svg: ^2.0.2
json_annotation: ^4.7.0
path_provider: ^2.0.15
path: ^1.8.2
textstyle_extensions: "2.0.0-nullsafety"
time: ">=2.0.0"
uuid: ">=2.2.2"
bloc: ^8.1.2
@ -23,8 +21,6 @@ dependencies:
file: ^7.0.0
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.2.0
flutter_lints: ^3.0.1
freezed: ^2.4.7

View File

@ -13,9 +13,8 @@ dependencies:
sdk: flutter
# Thirdparty packages
provider: ^6.0.5
styled_widget: ^0.4.1
equatable: ^2.0.5
animations: ^2.0.7
loading_indicator: ^3.1.0
async:
@ -25,8 +24,6 @@ dependencies:
# Federated Platform Interface
flowy_infra_ui_platform_interface:
path: flowy_infra_ui_platform_interface
flowy_infra_ui_web:
path: flowy_infra_ui_web
appflowy_popover:
path: ../appflowy_popover
flowy_infra:
@ -35,6 +32,7 @@ dependencies:
path: ../flowy_svg
dev_dependencies:
provider: ^6.0.5
flutter_test:
sdk: flutter
flutter_lints: ^3.0.1

View File

@ -1,3 +1 @@
include: package:very_good_analysis/analysis_options.yaml
linter:

View File

@ -10,7 +10,7 @@ packages:
source: hosted
version: "67.0.0"
analyzer:
dependency: "direct dev"
dependency: transitive
description:
name: analyzer
sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d"
@ -307,7 +307,7 @@ packages:
source: hosted
version: "1.3.0"
charcode:
dependency: "direct main"
dependency: transitive
description:
name: charcode
sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306
@ -322,14 +322,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
clipboard:
dependency: "direct main"
description:
name: clipboard
sha256: "2ec38f0e59878008ceca0ab122e4bfde98847f88ef0f83331362ba4521f565a9"
url: "https://pub.dev"
source: hosted
version: "0.1.3"
clock:
dependency: transitive
description:
@ -410,14 +402,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
custom_sliding_segmented_control:
dependency: "direct main"
description:
name: custom_sliding_segmented_control
sha256: "53c3e931c3ae1f696085d1ec70ac8e934da836595a9b7d9b88fdd0fcbf2a5574"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
dart_style:
dependency: transitive
description:
@ -663,13 +647,6 @@ packages:
relative: true
source: path
version: "0.0.1"
flowy_infra_ui_web:
dependency: transitive
description:
path: "packages/flowy_infra_ui/flowy_infra_ui_web"
relative: true
source: path
version: "0.0.1"
flowy_svg:
dependency: "direct main"
description:
@ -723,14 +700,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.6.13"
flutter_colorpicker:
dependency: "direct main"
description:
name: flutter_colorpicker
sha256: "458a6ed8ea480eb16ff892aedb4b7092b2804affd7e046591fb03127e8d8ef8b"
url: "https://pub.dev"
source: hosted
version: "1.0.3"
flutter_driver:
dependency: transitive
description: flutter
@ -746,7 +715,7 @@ packages:
source: git
version: "1.0.2"
flutter_highlight:
dependency: "direct main"
dependency: transitive
description:
name: flutter_highlight
sha256: "7b96333867aa07e122e245c033b8ad622e4e3a42a1a2372cbb098a2541d8782c"
@ -778,7 +747,7 @@ packages:
source: hosted
version: "3.0.1"
flutter_localizations:
dependency: "direct main"
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
@ -966,7 +935,7 @@ packages:
source: hosted
version: "0.7.0"
hive:
dependency: "direct main"
dependency: transitive
description:
name: hive
sha256: "8dcf6db979d7933da8217edcec84e9df1bdb4e4edc7fc77dbd5aa74356d6d941"
@ -1037,14 +1006,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.2.0"
image_gallery_saver:
dependency: "direct main"
description:
name: image_gallery_saver
sha256: "0aba74216a4d9b0561510cb968015d56b701ba1bd94aace26aacdd8ae5761816"
url: "https://pub.dev"
source: hosted
version: "2.0.3"
image_picker:
dependency: "direct main"
description:
@ -1347,7 +1308,7 @@ packages:
source: hosted
version: "5.4.4"
mocktail:
dependency: "direct main"
dependency: "direct dev"
description:
name: mocktail
sha256: c4b5007d91ca4f67256e720cb1b6d704e79a510183a12fa551021f652577dce6
@ -2153,14 +2114,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.0"
textstyle_extensions:
dependency: transitive
description:
name: textstyle_extensions
sha256: b0538352844fb4d1d0eea82f7bc6b96e4dae03a3a071247e4dcc85ec627b2c6c
url: "https://pub.dev"
source: hosted
version: "2.0.0-nullsafety"
time:
dependency: "direct main"
description:

View File

@ -30,8 +30,6 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
appflowy_backend:
path: packages/appflowy_backend
flowy_infra_ui:
@ -65,12 +63,10 @@ dependencies:
sized_context: ^1.0.0+4
styled_widget: ^0.4.1
expandable: ^5.0.1
flutter_colorpicker: ^1.0.3
flex_color_picker: ^3.5.1
highlight: ^0.7.0
package_info_plus: ^6.0.0
url_launcher: ^6.1.11
clipboard: ^0.1.3
connectivity_plus: ^5.0.2
easy_localization: ^3.0.2
device_info_plus: ^10.1.0
@ -83,7 +79,6 @@ dependencies:
fixnum: ^1.1.0
flutter_svg: ^2.0.7
protobuf: ^3.1.0
charcode: ^1.3.1
collection: ^1.17.1
bloc: ^8.1.2
shared_preferences: ^2.2.2
@ -95,14 +90,13 @@ dependencies:
ref: "6fe0c98"
http: ^1.0.0
path: ^1.8.3
mocktail: ^1.0.1
archive: ^3.4.10
nanoid: ^1.0.0
supabase_flutter: ^1.10.4
envied: ^0.5.2
dotted_border: ^2.0.0+3
url_protocol:
hive: ^2.2.3
hive_flutter: ^1.1.0
super_clipboard: ^0.8.4
go_router: ^13.1.0
@ -121,7 +115,6 @@ dependencies:
app_links: ^3.5.0
flutter_slidable: ^3.0.0
image_picker: ^1.0.4
image_gallery_saver: ^2.0.3
cached_network_image: ^3.3.0
leak_tracker: ^10.0.0
keyboard_height_plugin: ^0.1.5
@ -157,8 +150,6 @@ dependencies:
# BitsDojo Window for Windows
bitsdojo_window: ^0.1.6
flutter_highlight: ^0.7.0
custom_sliding_segmented_control: ^1.8.3
toastification: ^2.0.0
scroll_to_index: ^3.0.1
extended_text_field: ^15.0.0
@ -166,7 +157,6 @@ dependencies:
dev_dependencies:
flutter_lints: ^3.0.1
analyzer: ^6.3.0
flutter_test:
sdk: flutter
@ -182,6 +172,8 @@ dev_dependencies:
url_launcher_platform_interface: any
run_with_network_images: ^0.0.1
mocktail: ^1.0.1
dependency_overrides:
http: ^1.0.0

View File

@ -1,6 +1,40 @@
#!/usr/bin/env bash
echo "Generating flowy icon files"
# check the cost time
start_time=$(date +%s)
# read the arguments to skip the pub get and package get
skip_pub_get=false
skip_pub_packages_get=false
verbose=false
include_packages=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--skip-pub-get)
skip_pub_get=true
shift
;;
--skip-pub-packages-get)
skip_pub_packages_get=true
shift
;;
--verbose)
verbose=true
shift
;;
--exclude-packages)
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
echo "📷 Start generating image/svg files"
# Store the current working directory
original_dir=$(pwd)
@ -14,13 +48,34 @@ rm -rf assets/flowy_icons/
mkdir -p assets/flowy_icons/
rsync -r ../resources/flowy_icons/ assets/flowy_icons/
if [ "$skip_pub_get" = false ]; then
if [ "$verbose" = true ]; then
flutter pub get
else
flutter pub get >/dev/null 2>&1
fi
fi
if [ "$include_packages" = true ]; then
if [ "$verbose" = true ]; then
flutter packages pub get
else
flutter packages pub get >/dev/null 2>&1
fi
fi
echo "Generating FlowySvg classes"
if [ "$verbose" = true ]; then
dart run flowy_svg
echo "Done generating icon files."
else
dart run flowy_svg >/dev/null 2>&1
fi
# Return to the original directory
cd "$original_dir"
echo "📷 Done generating image/svg files."
# echo the cost time
end_time=$(date +%s)
cost_time=$((end_time - start_time))
echo "📷 Image/svg files generation cost $cost_time seconds."

View File

@ -1,5 +1,40 @@
#!/usr/bin/env bash
# check the cost time
start_time=$(date +%s)
# read the arguments to skip the pub get and package get
skip_pub_get=false
skip_pub_packages_get=false
verbose=false
exclude_packages=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--skip-pub-get)
skip_pub_get=true
shift
;;
--skip-pub-packages-get)
skip_pub_packages_get=true
shift
;;
--verbose)
verbose=true
shift
;;
--exclude-packages)
exclude_packages=true
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# Store the current working directory
original_dir=$(pwd)
@ -8,34 +43,60 @@ cd "$(dirname "$0")"
# Navigate to the project root
cd ../../../appflowy_flutter
# Navigate to the appflowy_flutter directory and generate files
echo "Generating files for appflowy_flutter"
flutter packages pub get >/dev/null 2>&1
dart run build_runner build -d
echo "Done generating files for appflowy_flutter"
echo "Generating files for packages"
if [ "$exclude_packages" = false ]; then
# Navigate to the packages directory
cd packages
for d in */; do
# Navigate into the subdirectory
cd "$d"
# Check if the subdirectory contains a pubspec.yaml file
if [ -f "pubspec.yaml" ]; then
echo "Generating freezed files in $d..."
echo "Please wait while we clean the project and fetch the dependencies."
flutter packages pub get >/dev/null 2>&1
dart run build_runner build -d
echo "Done running build command in $d"
# Check if the pubspec.yaml file exists and contains the freezed dependency
if [ -f "pubspec.yaml" ] && grep -q "build_runner" pubspec.yaml; then
echo "🧊 Start generating freezed files ($d)."
if [ "$skip_pub_packages_get" = false ]; then
if [ "$verbose" = true ]; then
flutter packages pub get
else
echo "No pubspec.yaml found in $d, it can\'t be a Dart project. Skipping."
flutter packages pub get >/dev/null 2>&1
fi
fi
if [ "$verbose" = true ]; then
dart run build_runner build
else
dart run build_runner build >/dev/null 2>&1
fi
echo "🧊 Done generating freezed files ($d)."
fi
# Navigate back to the packages directory
cd ..
done
fi
# Navigate to the appflowy_flutter directory and generate files
cd ..
echo "🧊 Start generating freezed files (AppFlowy)."
if [ "$skip_pub_packages_get" = false ]; then
if [ "$verbose" = true ]; then
flutter packages pub get
else
flutter packages pub get >/dev/null 2>&1
fi
fi
if [ "$verbose" = true ]; then
dart run build_runner build -d
else
dart run build_runner build >/dev/null 2>&1
fi
# Return to the original directory
cd "$original_dir"
echo "🧊 Done generating freezed files."
# echo the cost time
end_time=$(date +%s)
cost_time=$((end_time - start_time))
echo "🧊 Freezed files generation cost $cost_time seconds."

View File

@ -1,5 +1,40 @@
#!/usr/bin/env bash
args=("$@")
# check the cost time
start_time=$(date +%s)
# read the arguments to skip the pub get and package get
skip_pub_get=false
skip_pub_packages_get=false
verbose=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--skip-pub-get)
skip_pub_get=true
shift
;;
--skip-pub-packages-get)
skip_pub_packages_get=true
shift
;;
--verbose)
verbose=true
shift
;;
--exclude-packages)
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# Store the current working directory
original_dir=$(pwd)
@ -7,30 +42,34 @@ original_dir=$(pwd)
cd "$(dirname "$0")"
# Call the script in the 'language_files' folder
echo "Generating files using easy_localization"
cd language_files
# Allow execution permissions on CI
chmod +x ./generate_language_files.sh
./generate_language_files.sh "$@"
# Pass the arguments to the script
./generate_language_files.sh "${args[@]}"
# Return to the main script directory
cd ..
# Call the script in the 'flowy_icons' folder
cd flowy_icons
# Allow execution permissions on CI
chmod +x ./generate_flowy_icons.sh
./generate_flowy_icons.sh "${args[@]}"
# Return to the main script directory
cd ..
# Call the script in the 'freezed' folder
echo "Generating files using build_runner"
cd freezed
# Allow execution permissions on CI
chmod +x ./generate_freezed.sh
./generate_freezed.sh "$@"
# Return to the main script directory
cd ..
echo "Generating svg files using flowy_svg"
cd flowy_icons
# Allow execution permissions on CI
chmod +x ./generate_flowy_icons.sh
./generate_flowy_icons.sh "$@"
./generate_freezed.sh "${args[@]}"
# Return to the original directory
cd "$original_dir"
# echo the cost time
end_time=$(date +%s)
cost_time=$((end_time - start_time))
echo "✅ Code generation cost $cost_time seconds."

View File

@ -1,6 +1,41 @@
#!/usr/bin/env bash
echo "Generating language files"
set -e
# check the cost time
start_time=$(date +%s)
# read the arguments to skip the pub get and package get
skip_pub_get=false
skip_pub_packages_get=false
verbose=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--skip-pub-get)
skip_pub_get=true
shift
;;
--skip-pub-packages-get)
skip_pub_packages_get=true
shift
;;
--verbose)
verbose=true
shift
;;
--exclude-packages)
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
echo "🌍 Start generating language files."
# Store the current working directory
original_dir=$(pwd)
@ -19,16 +54,35 @@ cp -f ../resources/translations/*.json assets/translations/
# the ci alwayas return a 'null check operator used on a null value' error.
# so we force to exec the below command to avoid the error.
# https://github.com/dart-lang/pub/issues/3314
if [ "$skip_pub_get" = false ]; then
if [ "$verbose" = true ]; then
flutter pub get
else
flutter pub get >/dev/null 2>&1
fi
fi
if [ "$skip_pub_packages_get" = false ]; then
if [ "$verbose" = true ]; then
flutter packages pub get
else
flutter packages pub get >/dev/null 2>&1
fi
fi
echo "Specifying source directory for AppFlowy Localizations."
if [ "$verbose" = true ]; then
dart run easy_localization:generate -S assets/translations/
echo "Generating language files for AppFlowy."
dart run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations/ -s en.json
else
dart run easy_localization:generate -S assets/translations/ >/dev/null 2>&1
dart run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations/ -s en.json >/dev/null 2>&1
fi
echo "Done generating language files."
echo "🌍 Done generating language files."
# Return to the original directory
cd "$original_dir"
# echo the cost time
end_time=$(date +%s)
cost_time=$((end_time - start_time))
echo "🌍 Language files generation cost $cost_time seconds."

View File

@ -301,7 +301,7 @@ script = ["""
[tasks.code_generation]
script_runner = "@shell"
script = ["""
sh scripts/code_generation/generate.sh
./scripts/code_generation/generate.sh
"""]
[tasks.code_generation.windows]