-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage-extension.sh
More file actions
executable file
·74 lines (62 loc) · 1.79 KB
/
package-extension.sh
File metadata and controls
executable file
·74 lines (62 loc) · 1.79 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
#!/bin/bash
# This script compresses the extension into a zip file
# and copies it to the current directory
# usage: package-extension.sh
# Get the current parent directory name
parent_dir=$(basename "$(pwd)")
# Required files for the extension
required_files=(
"manifest.json"
"background.js"
"content.js"
"popup.html"
"popup.js"
"popup.css"
"side-panel.html"
"images/"
"README.md"
)
# Validate that all required files exist
echo "Validating required files..."
for file in "${required_files[@]}"; do
if [ ! -e "$file" ]; then
echo "ERROR: Required file/directory '$file' not found!"
exit 1
fi
done
echo "All required files found."
# Store the original directory path
original_dir=$(pwd)
# Create a temporary directory for packaging
temp_dir=$(mktemp -d)
echo "Creating temporary directory: $temp_dir"
# Copy only the required files to the temporary directory
echo "Copying required files..."
for file in "${required_files[@]}"; do
if [ -d "$file" ]; then
cp -r "$file" "$temp_dir/"
else
cp "$file" "$temp_dir/"
fi
done
# Create the zip file from the temporary directory
echo "Creating distribution package..."
cd "$temp_dir"
zip -r "$parent_dir.zip" . -x "*.DS_Store" "*.log" "*.tmp"
# Move the zip file back to the original directory
mv "$parent_dir.zip" "$original_dir/"
# Clean up the temporary directory
cd "$original_dir"
rm -rf "$temp_dir"
if [ $? -eq 0 ]; then
echo "✅ Compression completed successfully!"
echo "📦 Result saved as: $parent_dir.zip"
echo "📏 Package size: $(du -h "$parent_dir.zip" | cut -f1)"
# List contents of the zip for verification
echo "📋 Package contents:"
unzip -l "$parent_dir.zip" | head -20
echo "..."
else
echo "❌ Compression failed!"
exit 1
fi