-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmake_ff_extension.sh
72 lines (57 loc) · 1.45 KB
/
make_ff_extension.sh
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
#!/bin/bash
BUILD_DIR="dist"
EXT_BASE_NAME="minim_ff_v"
EXT_DIR="extension_build"
# Get version from src/version.json
VERSION=$(jq -r '.version' src/version.json)
if [ -z "$VERSION" ]; then
echo "Version not found in src/version.json"
exit 1
fi
# Replace dots with underscores for the filename
VERSION_UNDERSCORE=${VERSION//./_}
# Construct package name
PACKAGE_FILE="${EXT_BASE_NAME}${VERSION_UNDERSCORE}.xpi"
echo "Packaging version $VERSION as $PACKAGE_FILE"
# Clean old files
rm -rf "$EXT_DIR" "$PACKAGE_FILE"
# Create extension directory
mkdir "$EXT_DIR"
# Create manifest.json dynamically
cat > "$EXT_DIR/manifest.json" <<EOL
{
"manifest_version": 2,
"name": "Minim: Minimalist New Tab",
"version": "$VERSION",
"description": "A minimal newtab for Firefox",
"chrome_url_overrides": {
"newtab": "index.html"
},
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},
"browser_specific_settings": {
"gecko": {
"id": "[email protected]"
}
}
}
EOL
# Copy build files
cp -r "$BUILD_DIR"/* "$EXT_DIR"
# Ensure icon files exist (adjust paths as needed)
for ICON in icon16.png icon48.png icon128.png; do
if [ ! -f "src/logos/$ICON" ]; then
echo "Warning: src/logos/$ICON not found!"
else
cp "src/logos/$ICON" "$EXT_DIR"
fi
done
rm *.xpi
# Create the XPI (ZIP) - avoid nested folders
cd "$EXT_DIR" || exit 1
zip -r "../$PACKAGE_FILE" ./*
cd ..
echo "Extension packaged as $PACKAGE_FILE"