54 lines
1.6 KiB
Bash
54 lines
1.6 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
SOURCE_DIR="/Users/hamzaaleghwairyeen/development/App"
|
|
TARGET_DIR="/Users/hamzaaleghwairyeen/development/App/Siro"
|
|
|
|
declare -a mappings=(
|
|
"Intaleq:siro_rider:Intaleq:siro_rider"
|
|
"intaleq_driver:siro_driver:sefer_driver:siro_driver"
|
|
"intaleq_admin:siro_admin:sefer_admin1:siro_admin"
|
|
"service_intaleq:siro_service:service:siro_service"
|
|
)
|
|
|
|
for mapping in "${mappings[@]}"; do
|
|
IFS=":" read -r src dst old_pkg new_pkg <<< "$mapping"
|
|
src_path="$SOURCE_DIR/$src"
|
|
dst_path="$TARGET_DIR/$dst"
|
|
|
|
echo "Processing $dst..."
|
|
|
|
# 1. Delete destination lib and assets
|
|
for folder in lib assets secure_string_operations; do
|
|
if [ -d "$dst_path/$folder" ]; then
|
|
rm -rf "$dst_path/$folder"
|
|
fi
|
|
done
|
|
|
|
# 2. Copy lib and assets
|
|
for folder in lib assets secure_string_operations; do
|
|
if [ -d "$src_path/$folder" ]; then
|
|
cp -R "$src_path/$folder" "$dst_path/"
|
|
fi
|
|
done
|
|
|
|
# 3. Copy pubspec.yaml
|
|
if [ -f "$src_path/pubspec.yaml" ]; then
|
|
cp "$src_path/pubspec.yaml" "$dst_path/pubspec.yaml"
|
|
fi
|
|
|
|
# 4. Replace package name in pubspec.yaml using perl
|
|
if [ -f "$dst_path/pubspec.yaml" ]; then
|
|
perl -pi -e "s/^name:\s*$old_pkg\s*$/name: $new_pkg/" "$dst_path/pubspec.yaml"
|
|
fi
|
|
|
|
# 5. Replace imports using perl
|
|
for root_folder in lib test; do
|
|
if [ -d "$dst_path/$root_folder" ]; then
|
|
find "$dst_path/$root_folder" -type f -name "*.dart" -exec perl -pi -e "s/package:$old_pkg\//package:$new_pkg\//g" {} +
|
|
fi
|
|
done
|
|
done
|
|
|
|
echo "Done"
|