Skip to content

Commit db4b3b3

Browse files
committed
build ready
1 parent fa24fa7 commit db4b3b3

8 files changed

Lines changed: 184 additions & 7 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,5 @@ dist
137137
# Vite logs files
138138
vite.config.js.timestamp-*
139139
vite.config.ts.timestamp-*
140+
141+
*.zip

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,4 +427,3 @@ Each dashboard is mapped to a specific website tab:
427427
- Review the codebase and documentation
428428

429429
Thank you for contributing to CacheCat! 🐱
430-

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"scripts": {
88
"dev": "vite build --watch --mode development",
99
"build": "vite build",
10+
"build:store": "npm run build && bash scripts/create-store-zip.sh",
1011
"lint": "eslint . --ext .js,.jsx --ignore-pattern 'dist/**' --ignore-pattern 'node_modules/**'",
1112
"format": "prettier --write \"**/*.{js,jsx,json,css,md}\""
1213
},

scripts/create-store-zip.sh

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#!/bin/bash
2+
3+
# Script to create Chrome Web Store zip file
4+
# Usage: ./scripts/create-store-zip.sh
5+
6+
set -e
7+
8+
echo "📦 Creating Chrome Web Store zip file..."
9+
echo ""
10+
11+
# Check if dist folder exists
12+
if [ ! -d "dist" ]; then
13+
echo "❌ Error: dist/ folder not found!"
14+
echo " Run 'npm run build' first"
15+
exit 1
16+
fi
17+
18+
# Verify required files exist
19+
echo "🔍 Verifying required files..."
20+
REQUIRED_FILES=("manifest.json" "background.js" "content.js" "agent.js" "dashboard.html")
21+
MISSING_FILES=()
22+
23+
for file in "${REQUIRED_FILES[@]}"; do
24+
if [ ! -f "dist/$file" ]; then
25+
MISSING_FILES+=("$file")
26+
fi
27+
done
28+
29+
if [ ${#MISSING_FILES[@]} -ne 0 ]; then
30+
echo "❌ Error: Missing required files:"
31+
for file in "${MISSING_FILES[@]}"; do
32+
echo " - $file"
33+
done
34+
echo " Run 'npm run build' first"
35+
exit 1
36+
fi
37+
38+
# Check for icons folder
39+
if [ ! -d "dist/icons" ]; then
40+
echo "❌ Error: dist/icons/ folder not found!"
41+
exit 1
42+
fi
43+
44+
# Check for assets folder
45+
if [ ! -d "dist/assets" ]; then
46+
echo "❌ Error: dist/assets/ folder not found!"
47+
exit 1
48+
fi
49+
50+
echo "✅ All required files found"
51+
echo ""
52+
53+
# Remove old zip if exists
54+
if [ -f "cachecat-extension.zip" ]; then
55+
echo "🗑️ Removing old zip file..."
56+
rm cachecat-extension.zip
57+
fi
58+
59+
# Store current directory
60+
PROJECT_ROOT=$(pwd)
61+
62+
# Change to dist directory
63+
cd dist
64+
65+
# Create zip file (exclude src folder and system files)
66+
echo "📝 Creating zip file (excluding src/, system files, and source maps)..."
67+
if zip -r ../cachecat-extension.zip . \
68+
-x "src/*" \
69+
-x "src/**/*" \
70+
-x ".DS_Store" \
71+
-x "Thumbs.db" \
72+
-x "*.map" \
73+
-x ".git/*" \
74+
-x ".git/**/*" \
75+
> /dev/null 2>&1; then
76+
echo "✅ Zip file created"
77+
else
78+
echo "❌ Error: Failed to create zip file"
79+
cd "$PROJECT_ROOT"
80+
exit 1
81+
fi
82+
83+
# Go back to project root
84+
cd "$PROJECT_ROOT"
85+
86+
# Verify zip was created
87+
if [ ! -f "cachecat-extension.zip" ]; then
88+
echo "❌ Error: Zip file was not created"
89+
exit 1
90+
fi
91+
92+
# Get zip file size
93+
SIZE=$(du -h cachecat-extension.zip | cut -f1)
94+
95+
# List files in zip for verification
96+
echo ""
97+
echo "📋 Verifying zip contents..."
98+
# Parse unzip -l output: skip header (3 lines), skip footer (2 lines), get filename (4th column)
99+
ZIP_FILES=$(unzip -l cachecat-extension.zip 2>/dev/null | awk 'NR>3 && NF>=4 && $4!="Name" && $4!="----" && $4!="" {print $4}' | grep -v "^$" || true)
100+
101+
# Check for unwanted files
102+
UNWANTED_FOUND=0
103+
if echo "$ZIP_FILES" | grep -q "^src/"; then
104+
echo "⚠️ Warning: src/ folder found in zip!"
105+
UNWANTED_FOUND=1
106+
fi
107+
108+
if echo "$ZIP_FILES" | grep -q "\.map$"; then
109+
echo "⚠️ Warning: Source map files found in zip!"
110+
UNWANTED_FOUND=1
111+
fi
112+
113+
# Verify required files are in zip
114+
echo ""
115+
echo "✅ Verifying required files in zip..."
116+
for file in "${REQUIRED_FILES[@]}"; do
117+
if echo "$ZIP_FILES" | grep -qE "^$file$|^$file/"; then
118+
echo "$file"
119+
else
120+
echo "$file (MISSING!)"
121+
UNWANTED_FOUND=1
122+
fi
123+
done
124+
125+
# Check for icons (exclude directory entry, count actual files)
126+
ICON_FILES=$(echo "$ZIP_FILES" | grep "^icons/" | grep -v "^icons/$" || true)
127+
ICON_COUNT=$(echo "$ICON_FILES" | grep -c . || echo "0")
128+
if [ "$ICON_COUNT" -ge 3 ]; then
129+
echo " ✓ icons/ ($ICON_COUNT files)"
130+
else
131+
echo " ✗ icons/ (Expected at least 3 files, found $ICON_COUNT)"
132+
UNWANTED_FOUND=1
133+
fi
134+
135+
# Check for assets (exclude directory entry, count actual files)
136+
ASSET_FILES=$(echo "$ZIP_FILES" | grep "^assets/" | grep -v "^assets/$" || true)
137+
ASSET_COUNT=$(echo "$ASSET_FILES" | grep -c . || echo "0")
138+
if [ "$ASSET_COUNT" -ge 1 ]; then
139+
echo " ✓ assets/ ($ASSET_COUNT files)"
140+
else
141+
echo " ✗ assets/ (Expected at least 1 file, found $ASSET_COUNT)"
142+
UNWANTED_FOUND=1
143+
fi
144+
145+
echo ""
146+
if [ $UNWANTED_FOUND -eq 1 ]; then
147+
echo "⚠️ Warnings found! Please review the zip file before uploading."
148+
echo ""
149+
fi
150+
151+
echo "✅ Chrome Web Store zip created successfully!"
152+
echo "📦 File: $(pwd)/cachecat-extension.zip"
153+
echo "📊 Size: $SIZE"
154+
echo ""
155+
# Count total files (excluding directory entries)
156+
TOTAL_FILES=$(echo "$ZIP_FILES" | grep -v "/$" | wc -l | tr -d ' ')
157+
158+
echo "📝 Summary:"
159+
if [ $UNWANTED_FOUND -eq 0 ]; then
160+
echo " - Required files: ✓"
161+
else
162+
echo " - Required files: ⚠️ (see warnings above)"
163+
fi
164+
echo " - Icons: $ICON_COUNT files"
165+
echo " - Assets: $ASSET_COUNT files"
166+
echo " - Total files in zip: $TOTAL_FILES"
167+
echo ""
168+
echo "🚀 Ready to upload to Chrome Web Store!"
169+

src/background/background.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ chrome.action.onClicked.addListener(async () => {
5757
url: activeTab.url,
5858
timestamp: Date.now(),
5959
});
60-
60+
6161
ensureKeepaliveAlarm();
6262

6363
targetTabId = activeTab.id;
@@ -90,7 +90,7 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
9090
}
9191

9292
const { type, payload } = message;
93-
93+
9494
// Handle keepalive messages (keeps service worker alive)
9595
if (type === 'KEEPALIVE') {
9696
// Reset the alarm to keep service worker alive
@@ -397,7 +397,7 @@ async function handleAttachToTab(payload, dashboardTabId) {
397397
url: tab.url,
398398
timestamp: Date.now(),
399399
});
400-
400+
401401
ensureKeepaliveAlarm();
402402

403403
return {

src/dashboard/contexts/AttachContext.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export function AttachProvider({ children }) {
8484
checkAttachedTab();
8585
}
8686
}, 3000);
87-
87+
8888
// Send keepalive messages every 15 seconds to keep service worker alive
8989
// Combined with chrome.alarms in background.js, this ensures the service worker stays active
9090
const keepaliveInterval = setInterval(() => {

vercel.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@
2323
}
2424
]
2525
}
26-

vite.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
33
import { resolve } from 'path';
4-
import { copyFileSync, existsSync, mkdirSync, readdirSync } from 'fs';
4+
import { copyFileSync, existsSync, mkdirSync, readdirSync, rmSync } from 'fs';
55

66
export default defineConfig({
77
plugins: [
@@ -63,6 +63,13 @@ export default defineConfig({
6363
if (existsSync(dashboardSrc)) {
6464
copyFileSync(dashboardSrc, dashboardDest);
6565
console.log('Moved dashboard.html to dist root');
66+
67+
// Clean up the src folder (not needed in dist)
68+
const srcDir = resolve(distDir, 'src');
69+
if (existsSync(srcDir)) {
70+
rmSync(srcDir, { recursive: true, force: true });
71+
console.log('Cleaned up src/ folder from dist');
72+
}
6673
}
6774
},
6875
},

0 commit comments

Comments
 (0)