forked from WPManageNinja/fluent-security
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
92 lines (73 loc) · 2.1 KB
/
build.sh
File metadata and controls
92 lines (73 loc) · 2.1 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# Usage: ./build.sh --node-build --loco
# Function to handle copying
copy_items() {
local source_dir="$1"
local destination_dir="$2"
shift 2
local copy_list=("$@")
# Delete existing files in the destination directory
rm -rf "$destination_dir" && mkdir -p "$destination_dir"
# Copy selected folders and files
for item in "${copy_list[@]}"; do
local source_path="$source_dir/$item"
local destination_path="$destination_dir/$item"
if [ -e "$source_path" ]; then
cp -r "$source_path" "$destination_path"
echo "Copied: $item"
else
echo "Warning: $item does not exist in the source directory."
fi
done
echo -e "\nCopy completed."
}
# Function to handle compression
compress_items() {
local destination_dir="$1"
# Compress the copied content
local dest_dir_basename
dest_dir_basename=$(basename "$destination_dir")
(cd "$(dirname "$destination_dir")" && zip -rq "${dest_dir_basename}.zip" "$dest_dir_basename" -x "*.DS_Store")
# Check for errors
if [ $? -ne 0 ]; then
echo "Error occurred while compressing."
exit 1
fi
echo -e "\nCompressing Completed. builds/${dest_dir_basename}.zip is ready. Check the builds directory. Thanks!\n"
}
# Parse command-line arguments
nodeBuild=true
for arg in "$@"; do
case "$arg" in
"--node-build") nodeBuild=true ;;
esac
done
# Execute build steps if required
if "$nodeBuild"; then
echo -e "\nBuilding Main App\n"
npx mix --production
echo -e "\nBuild Completed for Main App\n"
fi
withLoco=false
for arg in "$@"; do
case "$arg" in
"--loco")
withLoco=true
;;
esac
done
if "$withLoco"; then
node i18n.node.js
echo -e "\nExtracting Loco Translations\n"
# shellcheck disable=SC2164
wp loco extract fluent-security
echo -e "\Syncing Loco Translations\n"
wp loco sync fluent-security
# shellcheck disable=SC2164
echo -e "\nLoco Translations synced\n"
fi
# Copy Fluent Boards
copy_items "." "builds/fluent-security" "app" "dist" "language" "fluent-security.php" "index.php" "readme.txt"
# Compress Fluent Boards
compress_items "builds/fluent-security"
exit 0