2024-07-08 05:45:57 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-07-03 14:07:11 +00:00
|
|
|
|
2024-08-13 08:13:33 +00:00
|
|
|
# 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
|
|
|
|
|
2023-07-03 14:07:11 +00:00
|
|
|
# Store the current working directory
|
|
|
|
original_dir=$(pwd)
|
|
|
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
|
|
# Navigate to the project root
|
|
|
|
cd ../../../appflowy_flutter
|
|
|
|
|
2024-08-13 08:13:33 +00:00
|
|
|
if [ "$exclude_packages" = false ]; then
|
|
|
|
# Navigate to the packages directory
|
|
|
|
cd packages
|
|
|
|
for d in */; do
|
|
|
|
# Navigate into the subdirectory
|
|
|
|
cd "$d"
|
2023-10-23 14:17:11 +00:00
|
|
|
|
2024-08-13 08:13:33 +00:00
|
|
|
# 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
|
|
|
|
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
|
2023-10-23 14:17:11 +00:00
|
|
|
|
2024-08-13 08:13:33 +00:00
|
|
|
# Navigate back to the packages directory
|
|
|
|
cd ..
|
|
|
|
done
|
2024-08-13 12:01:32 +00:00
|
|
|
|
|
|
|
cd ..
|
2024-08-13 08:13:33 +00:00
|
|
|
fi
|
2023-07-03 14:07:11 +00:00
|
|
|
|
2024-08-13 08:13:33 +00:00
|
|
|
# Navigate to the appflowy_flutter directory and generate files
|
|
|
|
echo "🧊 Start generating freezed files (AppFlowy)."
|
2023-07-03 14:07:11 +00:00
|
|
|
|
2024-08-13 08:13:33 +00:00
|
|
|
if [ "$skip_pub_packages_get" = false ]; then
|
|
|
|
if [ "$verbose" = true ]; then
|
|
|
|
flutter packages pub get
|
2023-07-03 14:07:11 +00:00
|
|
|
else
|
2024-08-13 08:13:33 +00:00
|
|
|
flutter packages pub get >/dev/null 2>&1
|
2023-07-03 14:07:11 +00:00
|
|
|
fi
|
2024-08-13 08:13:33 +00:00
|
|
|
fi
|
2023-07-03 14:07:11 +00:00
|
|
|
|
2024-08-13 08:13:33 +00:00
|
|
|
if [ "$verbose" = true ]; then
|
|
|
|
dart run build_runner build -d
|
|
|
|
else
|
|
|
|
dart run build_runner build >/dev/null 2>&1
|
|
|
|
fi
|
2023-07-03 14:07:11 +00:00
|
|
|
|
|
|
|
# Return to the original directory
|
2023-07-09 03:03:22 +00:00
|
|
|
cd "$original_dir"
|
2024-08-13 08:13:33 +00:00
|
|
|
|
|
|
|
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."
|