-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflutterflow-filtered-pull
More file actions
executable file
·70 lines (57 loc) · 2.13 KB
/
flutterflow-filtered-pull
File metadata and controls
executable file
·70 lines (57 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Initialize default values
SOURCE_DIR="$(mktemp -d)"
DESTINATION_DIR="$(pwd)"
PROJECT_ID=""
FLUTTERFLOW_TOKEN=""
INCLUDE_ASSETS=true
BRANCH_NAME=""
ENDPOINT=""
# Function to show usage
usage() {
echo "Usage: $0 [--source <path>] [--destination <path>] -p <id> -t <token> [--no-include-assets] [-b <branch>] [-e <endpoint>]"
exit 1
}
# Parse named parameters
while [[ "$#" -gt 0 ]]; do
case $1 in
--source) SOURCE_DIR="$2"; shift ;;
--destination) DESTINATION_DIR="$2"; shift ;;
-p|--project) PROJECT_ID="$2"; shift ;;
-t|--token) FLUTTERFLOW_TOKEN="$2"; shift ;;
--no-include-assets) INCLUDE_ASSETS= ;;
-b|--branch-name) BRANCH_NAME="$2"; shift ;;
-e|--endpoint) ENDPOINT="$2"; shift ;;
*) usage ;;
esac
shift
done
# Check mandatory parameters
if [[ -z "$PROJECT_ID" || -z "$FLUTTERFLOW_TOKEN" ]]; then
echo "Error: -p/--project and -t/--token are required."
usage
fi
# Path to the .flutterflowignore file in the destination directory
FLUTTERFLOWIGNORE_FILE="$DESTINATION_DIR/.flutterflowignore"
# Check if .flutterflowignore exists
if [ ! -f "$FLUTTERFLOWIGNORE_FILE" ]; then
echo ".flutterflowignore file not found in the destination directory."
exit 1
fi
# Pull code from FlutterFlow with FlutterFlow CLI
flutterflowCommand="dart pub global run flutterflow_cli export-code --project $PROJECT_ID --dest $SOURCE_DIR --token $FLUTTERFLOW_TOKEN --no-parent-folder"
if [ "$INCLUDE_ASSETS" = true ]; then
flutterflowCommand="$flutterflowCommand --include-assets"
else
flutterflowCommand="$flutterflowCommand --no-include-assets"
fi
if [ -n "$BRANCH_NAME" ]; then
flutterflowCommand="$flutterflowCommand --branch-name $BRANCH_NAME"
fi
if [ -n "$ENDPOINT" ]; then
flutterflowCommand="$flutterflowCommand --endpoint $ENDPOINT"
fi
eval $flutterflowCommand
# Use rsync to copy files from source to destination, excluding files as per .flutterflowignore
rsync -av --exclude-from="$FLUTTERFLOWIGNORE_FILE" --prune-empty-dirs "$SOURCE_DIR"/ "$DESTINATION_DIR"
echo "Files copied successfully, excluding patterns defined in .flutterflowignore."