-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild-extensions.sh
More file actions
executable file
·65 lines (49 loc) · 1.92 KB
/
build-extensions.sh
File metadata and controls
executable file
·65 lines (49 loc) · 1.92 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
#!/bin/bash
# Function to create directories if they don't exist
create_directories() {
mkdir -p "$1"
}
# Function to package the extension
zip_files() {
local zipfilename=$1
local sourcedir=$2
local manifestfile=$3
echo "Creating $zipfilename..."
# Ensure build directory exists
mkdir -p "$(dirname "$zipfilename")"
# Remove existing zip if it exists
[ -f "$zipfilename" ] && rm "$zipfilename"
# Create temporary directory for staging
local tempdir=$(mktemp -d)
# Copy all files from source directory to temp staging area
cp -r "$sourcedir/"* "$tempdir/"
# Replace manifest.json with the target version
if [ -f "$tempdir/$manifestfile" ]; then
cp "$tempdir/$manifestfile" "$tempdir/manifest.json"
else
echo "Error: $manifestfile not found in $sourcedir"
rm -rf "$tempdir"
exit 1
fi
# Remove the different manifest versions from the package
rm -f "$tempdir/manifest_v2.json"
rm -f "$tempdir/manifest_v3.json"
# Create the zip file from the temp directory
(cd "$tempdir" && zip -r -q "$zipfilename" .)
# Cleanup temp directory
rm -rf "$tempdir"
}
# Define root directory (where the script is located)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Ensuring folders exist..."
create_directories "$SCRIPT_DIR/build/chrome"
create_directories "$SCRIPT_DIR/build/firefox"
create_directories "$SCRIPT_DIR/debug/chrome"
create_directories "$SCRIPT_DIR/debug/firefox"
echo "Packaging extensions..."
zip_files "$SCRIPT_DIR/build/chrome/release.zip" "$SCRIPT_DIR/extension" "manifest_v3.json"
zip_files "$SCRIPT_DIR/build/firefox/release.zip" "$SCRIPT_DIR/extension" "manifest_v2.json"
echo "Extracting for Debug..."
unzip -o -q "$SCRIPT_DIR/build/chrome/release.zip" -d "$SCRIPT_DIR/debug/chrome"
unzip -o -q "$SCRIPT_DIR/build/firefox/release.zip" -d "$SCRIPT_DIR/debug/firefox"
echo "Build complete."